Announcement

Collapse
No announcement yet.

Blank application with custom html and third party javascript library MQTT how to ?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Blank application with custom html and third party javascript library MQTT how to ?

    I am trying to write an application which has to connect to a MQTT server and publish / subscribe data (Before anybody says MQTT not in the scope , please go thru the entire post).
    My problem is with including a third party javascript library from eclipse https://www.eclipse.org/paho/clients/js/
    I have written the html code as follows


    //C:\Program Files\NetMake\v9\wwwroot\scriptcase\devel\conf\sys \libraries THIS IS WHERE EXTERNAL LIBRARIES are PRESENT when loaded
    //<script type="text/javascript" src=" echo sc_url_library('prj', 'jsmqtt', 'pahojs/paho-mqtt,js'); ">
    //Point 1
    ?>

    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Machine Status Reflection</title>
    <meta name="generator" content="WYSIWYG Web Builder 15 Trial Version - http://www.wysiwygwebbuilder.com">
    <link href="WPLLineClearance.css" rel="stylesheet">
    <link href="index.css" rel="stylesheet">
    </head>
    <body>
    <a href="http://www.wysiwygwebbuilder.com" target="_blank"><img src="images/builtwithwwb15.png" alt="WYSIWYG Web Builder" style="position:absolute;left:441px;top:967px;marg in: 0;border-width:0;z-index:250"></a>
    <div id="wb_Image1" style="position:absolute;left:50px;top:8px;width:8 51px;height:898px;z-index:1;">
    <div id="wb_Heading1" style="position:absolute;left:109px;top:20px;width :694px;height:84px;z-index:3;">
    <h1 id="Heading1">WEST PHARMA LINE CLEARANCE SYSTEM<br>MACHINE STATUS MONITOR /CHANGE</h1></div>
    <img src="images/machineImage.jpg" id="Image1" alt=""></div>
    <input type="button" id="Button4" name="Connect" value="Connect" onclick="startConnect()" style="position:absolute;left:196px;top:136px;widt h:175px;height:50px;z-index:2;background-color:#FFFF00;font-size : 18px;border-radius: 15px;">
    <input type="button" id="Button5" name="DisConnect" value="Disconnect" onclick="stopConnect()" style="position:absolute;left:400px;top:136px;widt h:175px;height:50px;z-index:2;background-color:#FFFF00;font-size : 18px;border-radius: 15px;">


    <input type="button" id="Button1" name="ShowStatus" value="Show Status" onclick="showstatus()" style="position:absolute;left:176px;top:195px;widt h:175px;height:50px;z-index:2;background-color:#FFFF00;font-size : 18px;border-radius: 15px;">

    <input type="button" id="Button2" name="LCRInterlockOff" value="Release Interlock" style="position:absolute;left:176px;top:251px;widt h:175px;height:50px;z-index:4;background-color:#00FF00;font-size : 18px;border-radius: 15px;">
    <input type="button" id="Button3" name="LCRInterlockOn" value="Enable Interlock" style="position:absolute;left:176px;top:307px;widt h:175px;height:50px;z-index:5;background-color:#FF0000;font-size : 18px;border-radius: 15px;">
    </body>
    </html>

    <?php
    When I try to add this line "<script type="text/javascript" src="<?php echo sc_url_library('prj', 'jsmqtt', 'pahojs/paho-mqtt.js'); ?>">" in above code, I get error.
    If this code is above the "?>" which I have marked as point one above it gives "unexpected character > error"

    I have uploaded the paho library as external library and set to use, please check the screen shots attached with this post.
    I am not sure where I am going wrong. Can some one please point out my mistake
    Thanks In advance.


  • #2
    External Libraries is designed for PHP not js

    Try breaking it down into parts. I think you will find as I did it does not produce the code. Not even if the file is PHP.
    $js =sc_url_library('prj', 'jsmqtt', 'pahojs/paho-mqtt.js');
    echo $js;

    That is probably because the substitute for sc_url_library in PHP is not the code on its own but include('the_php file_goes_here.php");
    You cannot echo "include()". That is not how it is designed to work.

    The work around is to put the js file somewhere (even where it is) and using the right path to it in your normal echo "<script></script>" tags. I believe someone has just posted the absolute path technique here so you can keep the js in the external libraries folder so it gets copied to the production server as normal.

    https://forum.scriptcase.net/forum/s...ect-at-runtime
    Last edited by charlesfairbairn; 09-06-2019, 04:37 AM.

    Comment

    Working...
    X