-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patht1.flow
More file actions
1 lines (1 loc) · 4.41 KB
/
Copy patht1.flow
File metadata and controls
1 lines (1 loc) · 4.41 KB
1
[{"id":"2ebd310e.e0531e","type":"template","z":"4a62e07.6e0a32","name":"HTML template","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n <title>Terminal</title>\n <link href=\"https://fonts.googleapis.com/css?family=VT323\" rel=\"stylesheet\">\n <script src=\"https://code.jquery.com/jquery-1.11.3.min.js\"></script>\n <script src=\"https:///code.jquery.com/jquery-migrate-1.2.1.min.js\"></script>\n <style>\n body { overflow: hidden; background-color: #000; color: white; font-size: 1.5rem; font-family: 'VT323', monospace;}\n #messages {width: 80%; margin-left:8%; margin-bottom: 5%;}\n ::-webkit-scrollbar {\n width: 0px; /* remove scrollbar space */\n background: transparent; /* optional: just make scrollbar invisible */\n}\n body {text-shadow: 0px 0px 15px rgba(50,205,50,.6);}\n .msg { }\n .server {margin-top: .5em; margin-bottom: .5em; font-size:1.5rem; opacity:.5;}\n #form {}\n input[type=\"text\"] { font-family: 'VT323'; }\n #form input { font-family: 'VT323'; margin-left: 8%; background-color: #000; padding-bottom: .5rem; padding-left: 2em; position: fixed; bottom: 0; color: white; font-size: 1em; background: none; border: none; width:100%;}\n .caret {margin-bottom: .5rem; position: fixed; bottom: 0; left: 8%; ; width: 1.5em; height:1em; line-height: .9em; text-shadow: 0px 0px 5px white;}\n #form input:focus {outline: none; background: none;}\n </style>\n</head>\n<body>\n {{msg}}\n <div id=\"messages\"></div>\n <form id=\"form\" onsubmit=\"return false;\">\n <div class=\"caret\">></div><input id=\"text\" type=\"text\" onkeypress=\"return sendText(event)\" />\n </form>\n\n <script type=\"text/javascript\">\n \n var urlParams;\n (window.onpopstate = function () {\n var match,\n pl = /\\+/g, // Regex for replacing addition symbol with a space\n search = /([^&=]+)=?([^&]*)/g,\n decode = function (s) { return decodeURIComponent(s.replace(pl, \" \")); },\n query = window.location.search.substring(1);\n\n urlParams = {};\n while (match = search.exec(query))\n urlParams[decode(match[1])] = decode(match[2]);\n })();\n \n // Focus the text input on page load\n $(\"input:text:visible:first\").focus();\n \n // Open a websocket using FRED.\n var publishSocket = new WebSocket(\"ws://t1.local:1880/public/messagereceive\");\n var listenSocket = new WebSocket(\"ws://t1.local:1880/public/messagepublish\");\n\n listenSocket.onmessage = function (event) {\n // When receiving a message append a div child to #messages\n data = JSON.parse(event.data);\n \n if (!data.id) {\n var id = \"??\";\n } else if (data.id === \"1\" || data.id === \"2\" || data.id === \"3\" || data.id === \"4\" || data.id === \"5\"){\n var id = \"T\"+data.id;\n } else {\n var id = data.id;\n }\n \n if (data.msg !== \"\") {\n $(\"#messages\").append(\"<div class='msg' >[\"+id+\"] \"+data.msg+\"</div>\")\n //$('#messages').animate({ \n // scrollTop: $(document).height()-$(window).height()}, \n // 1400, \n // \"easeOutQuint\"\n //);\n if ($(\"#messages\").children().length > 14 ) { $(\"#messages :first-child\").remove()}\n }\n }\n\n listenSocket.onclose = function(event){\n $(\"#messages\").append(\"<div class='msg server'>Disconnected. Retrying connection...</div>\");\n \n setTimeout(function() {\n location.reload();\n }, 10000);\n }\n\n listenSocket.onopen = function(event){\n $(\"#messages\").append(\"<div class='msg server'>Connected.</div>\")\n }\n\n function sendText(event) {\n // Only if return key pressed\n if (event.keyCode == 13) {\n // Construct object containing the data the server needs.\n d = new Date();\n var data = {\n time: d.getHours() +\":\"+ d.getMinutes() + \":\" + d.getSeconds(),\n id: urlParams[\"id\"],\n msg: $(\"#text\").val(),\n };\n \n if ($(\"#text\").val() === \"/reload\") {\n location.reload();\n } else if ($(\"#text\").val() !== \"\") {\n // Send the msg object as a JSON-formatted string.\n publishSocket.send(JSON.stringify(data));\n // Blank the text input element\n $(\"#text\").val(\"\");\n }\n }\n}\n </script>\n\n</body>\n</html>","output":"str","x":840,"y":1080,"wires":[["7b9a2a9d.f531b4"]]}]