Sha256: 2c061b06aa13f0d8ea5feadc28bce9bffeb2b53addc7dc1ff92164bcaecd2ac7
Contents?: true
Size: 1.57 KB
Versions: 34
Compression:
Stored size: 1.57 KB
Contents
<!DOCTYPE html> <head> <meta charset='UTF-8'> <style> html, body {width: 100%; height:100%;} body {font-size: 1.5em; background-color: #eee;} p {padding: 0.2em; margin: 0;} .received { color: #00f;} .sent { color: #f0f;} .connection { color: #0f0;} .error { color: #f00;} input, #output {font-size: 1em; width: 60%; margin: 0.5em 19%; padding: 0.5em 1%;} #output {height: 60%; overflow: auto; background-color: #fff;} </style> <script> var websocket = NaN; function connect() { websocket = new WebSocket( (window.location.protocol.match(/https/) ? 'wws' : 'ws') + '://' + window.location.hostname + (window.location.port == '' ? '' : (':' + window.location.port) ) + "/" ); } function init() { connect() websocket.onopen = function(evt) { WriteMessage("Connected.", "connection") }; websocket.onclose = function(evt) { WriteMessage("Disconnected.", "connection");connect(); }; websocket.onmessage = function(evt) { WriteMessage(evt.data); }; websocket.onerror = function(evt) { WriteMessage(evt.data, 'error'); }; } function WriteMessage( message, message_type ) { if (!message_type) message_type = 'received' var msg = document.createElement("p"); msg.className = message_type; msg.innerHTML = message; document.getElementById("output").appendChild(msg); } function Send(message) { WriteMessage(message, 'sent'); websocket.send(message); } window.addEventListener("load", init, false); </script> </head> <body> <div id='output'>test</div> <input type='text' placeholder='your message goes here.' value='' /> </body>
Version data entries
34 entries across 34 versions & 1 rubygems