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 <script src="/js/jquery.min.js"></script>
16 <script src="/js/crel.js"></script>
17 <script src="/js/json.human.js"></script>
20 function convert(input, output) {
21 var output = document.getElementById("output"),
22 raw = document.getElementById("output-raw");
23 var node = JsonHuman.format(input);
25 output.innerHTML = "";
26 output.appendChild(node);
33 function get_appropriate_ws_url()
38 //document.writeln( u + "<br>" );
41 * We open the websocket encrypted if this page came on an
42 * https:// url itself, otherwise unencrypted
45 if (u.substring(0, 5) == "https") {
50 if (u.substring(0, 4) == "http")
57 /* + "/xxx" bit is for IE10 workaround */
58 /* ":7681" bit makes this function work even if this html file gets served from another server */
59 /* browser may complain about it but it works in firefox 30.0. If you do this umurmurd_websocket */
60 /* will just act as the websocket server. I will make a reduced down version of the server if */
61 /* enough people request it */
62 return pcol + m[0] + ":7681" + "/xxx";
67 if (typeof MozWebSocket != "undefined") {
68 socket_json = new MozWebSocket(get_appropriate_ws_url(),
69 "umurmur-json-protocol");
71 socket_json = new WebSocket(get_appropriate_ws_url(),
72 "umurmur-json-protocol");
76 socket_json.onopen = function() {
77 socket_json.send("update\n");
79 socket_json.onmessage = function (jmsg) {
81 json_data = JSON.parse(jmsg.data);
83 convert(json_data, output);
86 socket_json.onclose = function(){
90 socket_json.send("update\n");