node-red-contrib-snap4city-user
Version:
Nodes for Snap4city project, targeted to standard user (no developer)
42 lines (34 loc) • 1.33 kB
HTML
<html manifest="s4ciframe.appcache">
<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="generalIframe" 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('generalIframe').src = data.src;
}
};
}
console.log("CONNECT TO", location.pathname + 'socket');
connect();
</script>
</body>
</html>