SVGHMI: moved static JS code to a separate file included at xhtml generation time svghmi
authorEdouard Tisserant
Thu, 19 Sep 2019 09:01:49 +0200
branchsvghmi
changeset 2780 e468f18df200
parent 2779 75c6a31caca6
child 2781 fbdd0fd8ee4f
SVGHMI: moved static JS code to a separate file included at xhtml generation time
svghmi/gen_index_xhtml.ysl2
svghmi/svghmi.js
--- a/svghmi/gen_index_xhtml.ysl2	Wed Sep 18 11:09:35 2019 +0200
+++ b/svghmi/gen_index_xhtml.ysl2	Thu Sep 19 09:01:49 2019 +0200
@@ -47,20 +47,14 @@
                   }
                   apply "@* | node()";
               }
-              script
-                  ||
-                  (function(){
-                      var relative_URI = window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws');
-                      var ws = new WebSocket(relative_URI);
-                      ws.onmessage = function (evt) {
-                          var received_msg = evt.data;
-                          alert("Message is received..."+received_msg); 
-                      };
-                      ws.onopen = function (evt) {
-                          ws.send("test");
-                      };
-                  })();
-                  ||
+              script{
+                  /*TODO add :
+                    - pages content
+                      + with ref to elt ?
+                    - widgets parameters
+                  */
+                  include text svghmi.js
+              }
           }
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/svghmi/svghmi.js	Thu Sep 19 09:01:49 2019 +0200
@@ -0,0 +1,11 @@
+(function(){
+    var relative_URI = window.location.href.replace(/^http(s?:\/\/[^\/]*)\/.*$/, 'ws$1/ws');
+    var ws = new WebSocket(relative_URI);
+    ws.onmessage = function (evt) {
+        var received_msg = evt.data;
+        alert("Message is received..."+received_msg); 
+    };
+    ws.onopen = function (evt) {
+        ws.send("test");
+    };
+})();