1 var head = 0, tail = 0, ring = new Array();
3 function get_appropriate_ws_url(extra_url)
9 * We open the websocket encrypted if this page came on an
10 * https:// url itself, otherwise unencrypted
13 if (u.substring(0, 5) === "https") {
18 if (u.substring(0, 4) === "http")
24 /* + "/xxx" bit is for IE10 workaround */
26 return pcol + u[0] + "/" + extra_url;
29 function new_ws(urlpath, protocol)
31 if (typeof MozWebSocket != "undefined")
32 return new MozWebSocket(urlpath, protocol);
34 return new WebSocket(urlpath, protocol);
37 document.addEventListener("DOMContentLoaded", function() {
39 ws = new_ws(get_appropriate_ws_url(""), "lws-minimal");
41 ws.onopen = function() {
42 document.getElementById("r").disabled = 0;
45 ws.onmessage =function got_packet(msg) {
48 ring[head] = msg.data + "\n";
49 head = (head + 1) % 50;
51 tail = (tail + 1) % 50;
59 document.getElementById("r").value = s;
60 document.getElementById("r").scrollTop =
61 document.getElementById("r").scrollHeight;
64 ws.onclose = function(){
65 document.getElementById("r").disabled = 1;
68 alert("<p>Error " + exception);