1 function lwsgt_get_appropriate_ws_url()
6 if (u.substring(0, 5) === "https") {
11 if (u.substring(0, 4) === "http")
18 function lwsgt_app_hdr(j, bc, ws)
24 for (n = 0; n < j.cols.length; n++)
28 s = "<tr><td colspan=\"" + m + "\" class=\"lwsgt_title\">" +
29 ws.lwsgt_title + "</td></tr>";
32 s += "<tr><td colspan=\"" + m + "\" class=\"lwsgt_breadcrumbs\">";
33 for (n = 0; n < bc.length; n++) {
35 if (!bc[n].url && bc[n].url !== "")
36 s += " " + lws_san(bc[n].name) + " ";
38 s += "<a href=# id=\"bc_"+ ws.divname + ws.bcq + "\" h=\"" +
39 ws.lwsgt_cb + "\" p=\""+ws.lwsgt_parent+"\" aa=\"="+
40 lws_san(encodeURI(bc[n].url))+"\" m=\"-1\" n=\"-1\">" +
41 lws_san(bc[n].name) + "</a> ";
48 for (n = 0; n < j.cols.length; n++)
50 s = s + "<td class=\"lwsgt_hdr\">" + lws_san(j.cols[n].name) +
58 function lwsgt_click_callthru()
60 window[this.getAttribute("h")](this.getAttribute("p"), this.getAttribute("aa"), this.getAttribute("m"), this.getAttribute("n"));
61 event.preventDefault();
64 function lwsgt_initial(title, pcol, divname, cb, gname)
66 this.divname = divname;
68 lws_gray_out(true,{"zindex":"499"});
70 if (typeof MozWebSocket != "undefined")
71 this.lwsgt_ws = new MozWebSocket(lwsgt_get_appropriate_ws_url(), pcol);
73 this.lwsgt_ws = new WebSocket(lwsgt_get_appropriate_ws_url(), pcol);
74 this.lwsgt_ws.divname = divname;
75 this.lwsgt_ws.lwsgt_cb = cb;
76 this.lwsgt_ws.lwsgt_parent = gname;
77 this.lwsgt_ws.lwsgt_title = title;
79 this.lwsgt_ws.onopen = function() {
81 // document.getElementById("debug").textContent =
82 // "ws opened " + lwsgt_get_appropriate_ws_url();
84 this.lwsgt_ws.onmessage = function got_packet(msg) {
85 var s, m, n, j = JSON.parse(msg.data);
86 document.getElementById("debug").textContent = msg.data;
91 this.breadcrumbs = j.breadcrumbs;
95 s = "<table class=\"lwsgt_table\">" +
96 lwsgt_app_hdr(this.hdr, this.breadcrumbs, this);
97 for (m = 0; m < j.data.length; m++) {
98 s = s + "<tr class=\"lwsgt_tr\">";
99 for (n = 0; n < this.hdr.cols.length; n++) {
100 if (!this.hdr.cols[n].hide) {
101 if (!this.hdr.cols[n].align)
102 s = s + "<td class=\"lwsgt_td\">";
104 s = s + "<td class=\"lwsgt_td\" style=\"text-align: right\">";
106 if (this.hdr.cols[n].href &&
107 !!j.data[m][this.hdr.cols[n].href]) {
108 s = s + "<a href=# id=\""+ this.divname + q + "\" h=\"" + this.lwsgt_cb + "\" p=\""+this.lwsgt_parent+"\" aa=\""+
109 lws_san(encodeURI(j.data[m][this.hdr.cols[n].href]))+"\" m=\""+m+"\" n=\""+n+"\">" +
110 lws_san(j.data[m][this.hdr.cols[n].name]) +
115 s = s + lws_san(j.data[m][this.hdr.cols[n].name]);
124 document.getElementById(this.divname).innerHTML = s;
125 for (n = 0; n < q; n++)
126 document.getElementById(this.divname + n).onclick =
127 lwsgt_click_callthru;
129 for (n = 0; n < this.bcq; n++)
130 document.getElementById("bc_" + this.divname + n).onclick =
131 lwsgt_click_callthru;
135 this.lwsgt_ws.onclose = function(){
136 lws_gray_out(true,{"zindex":"499"});
139 alert("<p>Error" + exception);