6 <title>uMurmurd Websocket demo HTML page</title>
7 <link rel="stylesheet" href="css/mon_umurmurd.css" >
8 <link rel="stylesheet" href="css/json.human.css" >
13 <div id="output"> </div>
14 <input type=button id=offset value="Update" onclick="update();">
15 <input type=button id=offset value="AutoUpdate" onclick="autoupdate();">
16 <script src="/js/jquery.min.js"></script>
17 <script src="/js/crel.js"></script>
18 <script src="/js/json.human.js"></script>
21 function convert(input, output) {
22 var output = document.getElementById("output"),
23 raw = document.getElementById("output-raw");
24 var node = JsonHuman.format(input);
26 output.innerHTML = "";
27 output.appendChild(node);
34 function get_appropriate_ws_url()
39 //document.writeln( u + "<br>" );
42 * We open the websocket encrypted if this page came on an
43 * https:// url itself, otherwise unencrypted
46 if (u.substring(0, 5) == "https") {
51 if (u.substring(0, 4) == "http")
58 /* + "/xxx" bit is for IE10 workaround */
59 /* ":7681" bit makes this function work even if this html file gets served from another server */
60 /* browser may complain about it but it works in firefox 30.0. If you do this umurmurd_websocket */
61 /* will just act as the websocket server. I will make a reduced down version of the server if */
62 /* enough people request it */
63 return pcol + m[0] + ":7681" + "/xxx";
68 if (typeof MozWebSocket != "undefined") {
69 socket_json = new MozWebSocket(get_appropriate_ws_url(),
70 "umurmurd-json-protocol");
72 socket_json = new WebSocket(get_appropriate_ws_url(),
73 "umurmurd-json-protocol");
77 socket_json.onopen = function() {
78 socket_json.send("update\n");
80 socket_json.onmessage = function (jmsg) {
82 json_data = JSON.parse(jmsg.data);
84 convert(json_data, output);
87 socket_json.onclose = function(){
91 socket_json.send("update\n");
93 function autoupdate() {
94 socket_json.send("autoupdate\n");