function lwsgt_get_appropriate_ws_url() { var pcol; var u = document.URL; if (u.substring(0, 5) == "https") { pcol = "wss://"; u = u.substr(8); } else { pcol = "ws://"; if (u.substring(0, 4) == "http") u = u.substr(7); } return pcol + u; } function lwsgt_app_hdr(j, bc, ws) { var s = "", n, m = 0; for (n = 0; n < j.cols.length; n++) if (!j.cols[n].hide) m++; s = "" + ws.lwsgt_title + "" if (!!bc) { s += ""; for (n = 0; n < bc.length; n++) { s += " / "; if (!bc[n].url && bc[n].url !== "") s += " " + lws_san(bc[n].name) + " "; else s += " " + lws_san(bc[n].name) + " "; } s += ""; } s += ""; for (n = 0; n < j.cols.length; n++) if (!j.cols[n].hide) s = s + "" + lws_san(j.cols[n].name) + ""; s += ""; return s; } function lwsgt_initial(title, pcol, divname, cb, gname) { this.divname = divname; lws_gray_out(true,{'zindex':'499'}); if (typeof MozWebSocket != "undefined") this.lwsgt_ws = new MozWebSocket(lwsgt_get_appropriate_ws_url(), pcol); else this.lwsgt_ws = new WebSocket(lwsgt_get_appropriate_ws_url(), pcol); this.lwsgt_ws.divname = divname; this.lwsgt_ws.lwsgt_cb = cb; this.lwsgt_ws.lwsgt_parent = gname; this.lwsgt_ws.lwsgt_title = title; try { this.lwsgt_ws.onopen = function() { lws_gray_out(false); // document.getElementById("debug").textContent = // "ws opened " + lwsgt_get_appropriate_ws_url(); } this.lwsgt_ws.onmessage = function got_packet(msg) { var s, m, n, j = JSON.parse(msg.data); // document.getElementById("debug").textContent = msg.data; if (j.cols) { this.hdr = j; } if (j.breadcrumbs) this.breadcrumbs = j.breadcrumbs; if (j.data) { s = "" + lwsgt_app_hdr(this.hdr, this.breadcrumbs, this); for (m = 0; m < j.data.length; m++) { s = s + ""; for (n = 0; n < this.hdr.cols.length; n++) { if (!this.hdr.cols[n].hide) { if (!this.hdr.cols[n].align) s = s + ""; } } s = s + ""; } s = s + "
"; else s = s + ""; if (this.hdr.cols[n].href && !!j.data[m][this.hdr.cols[n].href]) s = s + "" + lws_san(j.data[m][this.hdr.cols[n].name]) + ""; else s = s + lws_san(j.data[m][this.hdr.cols[n].name]); s = s + "
"; document.getElementById(this.divname).innerHTML = s; } } this.lwsgt_ws.onclose = function(){ lws_gray_out(true,{'zindex':'499'}); } } catch(exception) { alert('

Error' + exception); } }