portal: added wip for PI validation page
[myslice.git] / sample / templates / websockets.html
1 <!DOCTYPE html>
2 <html>
3    <head>
4       <script type="text/javascript">
5          var sock = null;
6          var wsuri = "ws://dev.myslice.info:9000";
7  
8          window.onload = function() {
9  
10             sock = new WebSocket(wsuri);
11  
12             sock.onopen = function() {
13                console.log("connected to " + wsuri);
14             }
15  
16             sock.onclose = function(e) {
17                console.log("connection closed (" + e.code + ")");
18             }
19  
20             sock.onmessage = function(e) {
21                console.log("message received: " + e.data);
22             }
23          };
24  
25          function send() {
26             var msg = document.getElementById('message').value;
27             sock.send(msg);
28          };
29       </script>
30    </head>
31    <body>
32       <h1>WebSocket Echo Test</h1>
33       <form>
34          <p>
35             Message:
36             <input id="message" type="text" value="Hello, world!">
37          </p>
38       </form>
39       <button onclick='send();'>Send Message</button>
40    </body>
41 </html>