UNPKG

node-red-contrib-snap4city-user

Version:

Nodes for Snap4city project, targeted to standard user (no developer)

40 lines (33 loc) 1.39 kB
<head> <meta name="mobile-web-app-capable" content="yes"> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="lib/sockjs.min.js"></script> </head> <body onunload="ws.send(JSON.stringify({'action':'end'}));"> <iframe id="s4cmicroapp" style="width:100%;height:100%;border:none;"></iframe> <script language="javascript" type="text/javascript"> var ws; // Create the socket var connect = function () { ws = new SockJS(location.pathname + 'socket'); ws.onopen = function () { console.log("CONNECTED"); ws.send(JSON.stringify({ action: "connected" })); }; ws.onclose = function () { console.log("DISCONNECTED"); setTimeout(function () { connect(); }, 2500); }; ws.onmessage = function (e) { var data = JSON.parse(e.data); console.log(data); if (typeof data.src != "undefined") { document.getElementById('s4cmicroapp').src = "https://" + document.location.host + "/webapp-new/?geoJsonUri=https://" + document.location.host + data.src; } }; } console.log("CONNECT TO", location.pathname + 'socket'); connect(); </script> </body> </html>