1 | "use strict";
|
---|
2 |
|
---|
3 | var debug = false;
|
---|
4 |
|
---|
5 | var codedMap = "966676:6:A;68656364626Y?\\?;A=A<AGADAN4K4i5g5h5o506W?Z?]?_?>A@A?AJAIAFACAM4J4H4f5d5e5l5m5n516X?[?^?N?P?AA1ABAVAUAKAHAEAO4L4I4G4E4c5a5b5M6j5k5V6Y6\\6_6G?J?O?Q?S?2A4A3AYAXAWAbA_AnAkAhA3404F4D4B4`5^5_5J6K6L6S6T6W6Z6]6E?H?K?M?R?T?V?5A7A6A\\A[AZAeAdAaA^AmAjAgA24o3m3C4A4?4]5[5\\5G6H6I6P6Q6R6U6X6[6^6F?I?L?<?>?U?;@=@8Ah@9AMALA]ABCACfAcA`AoAlAiA4414n3l3<4@4>425Z5X5Y5D6E6F698N6O608E8H8K8H>K>N>?>B>=???A?<@>@@@i@k@j@PAOANAECDCCC<C9CZCWCTC=3:3734313=4;4943515o4W5U5V5A6B6C6687888m7n7C8F8I8F>I>L>=>@>C>E>@?B?D??@A@C@l@n@m@SARAQAHCGCFC?C>C;C8CYCVCSC<393633303n2:4846405n4l4T5R5S5>6?6@6384858j7k7l7o7D8G8J8G>J>M>>>A>D>4>6>C?3?5?B@2@4@o@_@0ALBKBTA0CoBIC8D7D@C=C:C[CXCUC>3;3835323o2m2k27454j3m4k4i4Q5O5P5C7<6=6g71828o8h7i7S9<8?8B8Q>T>W>@=C=F=e<h<5>7>9>4?6?8?3@5@7@`@b@a@OBNBMB3C2C1C;D:D9D_D\\DQCNCKCF3C3@3>2;282Z1W1l2j2h2k3i3g3j4h4f4N5L5M5@7A7B7d7e7f7l8m8n8P9Q9:8=8@8O>R>U>>=A=D=c<f<i<k<8>:><>7?9?;?6@8@:@c@e@d@RBQBPB6C5C4C>D=D<DbDaD^D[DPCMCJCE3B3?3=2:272Y1V1T1i2g2e2h3f3d3g4e4c4K5I5J5=7>7?7a7b7c7i8j8k8M9N9O9R9;8>8A8P>S>V>?=B=E=d<g<j<Z<\\<;>k=m=:?j>l>9@i?k?f@V@g@CBBBSBgBfB7CoCnC?DSDRDcD`D]DRCOCLCG3D3A3?2<292[1X1U1S1Q1f2d2b2e3c3a3d4b4`4H5F5G5:7;7<7^7_7`7f8g8h8J9K9L97:::=:@:C:F:I:I=L=O=7=:===n<1=[<]<_<l=n=0>k>m>o>j?l?n?W@Y@X@FBEBDBjBiBhB2D1D0DVDUDTDCE@EOELEIEXEUERE5222o1l1i1f1c1`1R1P1N1c2a2_2b3`3^3a4_4]4<5:5;5778797[7\\7]7c8d8e8G9H9I94:5:8:;:>:A:D:G:G=J=M=5=8=;=l<o<2=4=^<`<b<o=1>3>n>0?2?m?o?1@Z@\\@[@IBHBGBmBlBkB5D4D3DYDXDWDFEEEBE?ENEKEHEWETEQE4212n1k1h1e1b1_1]1O1M1K1`2^2\\2_3]3[3^4\\4Z4957585475767X7Y7Z7`8a8b8D9E9F91:2:3:6:9:<:?:B:E:H:H=K=N=6=9=<=m<0=3=d;f;a<H<J<2>b=d=1?a>c>0@`?b?]@D@^@:B9BJB^B]BnBfCeC6DJDIDZDnDmDGEDEAEPEMEJEYEVESE623202m1j1g1d1a1^1\\1[0L1J1?1]2[2Y2\\3Z3X3[4Y4W4654555172737U7V7W7]8^8_8A9B9C9e9o90:n9g:j:m:L:O:R:U:X:[:];`;c;T;W;Z;7<9<e;g;i;I<K<M<c=e=g=b>d>f>a?c?e?E@G@F@=B<B;BaB`B_BiChCgCMDLDKD1E0EoD9E7E<F9F6FaE^E[EjEgEdER0O0L0I0F0C0n0l0\\0Z0X0@1>1<1Z2X2V2Y3W3U3X4V4T4E5C5D5n6o607R7S7T7Z8[8\\8>9?9@9b9c9d9l9m9e:h:k:J:M:P:S:V:Y:[;^;a;R;U;X;6<8<:<;<h;j;l;L<N<P<f=h=j=e>g>i>d?f?h?N@Q@H@@B?B>BdBcBbBlCkCjCPDODND4E3E2E;E:E8E6E;F8F5F`E]EZEiEfEcEQ0N0K0H0E0B0m0k0j0Y0W0U0=1;191W2U2S2V3T3R3U4S4Q4B5@5A5k6l6m6O7P7Q7W8X8Y8;9<9=9_9`9a9j9k9\\:_:f:i:l:K:N:Q:T:W:Z:\\;_;b;S;V;Y;C<E<G<<<m;k;1<2<O<Q<S<i=[=P=h>X>Z>g?M@O@R@U@S@J@I@AB1B0BeBTB\\CmCAD@DQDiDhD5EdD<E4F2F0F=F:F7FbE_E\\EkEhEeES0P0M0J0G0D011o0h0g0e0V0T0`0:181Q2T2R2H2S3Q3P3R4P4K3?5=5>5c6i6j6h6M7N7L7U8V8T899:9W9]9^9\\9g9h9i9]:`:c:5;2;o:>;;;8;P;M;J;G;D;A;?<A<D<F<=<><n;o;3<5<R<T<Y=Z=Q=R=Y>[>\\>^>P@T@L@K@5B4B3B2BVBUB^C]CCDBDkDjDfDeD>E=E3F1FnElE@FCFFFIFLFOF;0>0A0205080513101i0f0d0c0b0_0I1H1D1P2O2G2F2D2O3N3M3J3H3a6b6e6f6g6I7J7K7R8S8397989V9Y9Z9[9f9^:a:d:4;1;n:=;:;7;O;L;I;F;C;@;@<B<0<4<U<V<X<`=]=\\=S=U=W=]>_>`>8B7B6BZBXBWB_CaC`CFDEDDDlDgDoEmE>FAFDFGFJFMF90<0?0003060714121a0^0]0G1C1B1N2L2E2C2B2@2L3I3`6d6E7F7G7H7O8Q8192969T9U9X96;3;0;?;<;9;Q;N;K;H;E;B;W<Y<^=_=a=T=V=X=\\B[BYBdCcCbCHDGD?FBFEFHFKFNF:0=0@0104070F1E1A1M2K2J2I2A2D7L8M8N8P809495961b:";
|
---|
6 | var map = new Array(1440);
|
---|
7 |
|
---|
8 | function $(id) { return document.getElementById(id); }
|
---|
9 | function $new(name) { return document.createElement(name); }
|
---|
10 | function $txt(txt) { return document.createTextNode(txt); }
|
---|
11 | function trim(str) { return str.replace(/^\s\s*/, "").replace(/\s*\s$/, ""); }
|
---|
12 | function valid(str) { if (!str) return false; if (str.length==0) return false; return true;}
|
---|
13 | function isSliding() { var z = $("body").getAttribute("data-visible"); return $("table"+z) ? $("table"+z).offsetLeft!=0 : false; }
|
---|
14 | function htmlDecode(input) { var e = $new('div'); e.innerHTML = input; return e.firstChild ? e.firstChild.nodeValue : input; }
|
---|
15 | function setUTC(el, time) { var str = time.toUTCString(); var utc = str.substr(str.length-12, 8); el.innerHTML = "• "+utc+" UTC •"; }
|
---|
16 |
|
---|
17 | function cycleCol(el)
|
---|
18 | {
|
---|
19 | var col = el.getAttribute("data-color");
|
---|
20 | col++;
|
---|
21 | col %= 31;
|
---|
22 | el.setAttribute("data-color", col);
|
---|
23 | if (col>16)
|
---|
24 | col = 31-col;
|
---|
25 | var hex = col.toString(16);
|
---|
26 | el.style.color = "#"+hex+"0"+hex+"0"+hex+"f";
|
---|
27 | }
|
---|
28 |
|
---|
29 | function onload()
|
---|
30 | {
|
---|
31 | try { var dummy = new XMLHttpRequest(); }
|
---|
32 | catch(e)
|
---|
33 | {
|
---|
34 | // FIXME: Add a message to the body.
|
---|
35 | alert("Your browser doesn't support dynamic reload.");
|
---|
36 | return;
|
---|
37 | }
|
---|
38 |
|
---|
39 | var name = location.hash.length==0 ? "fact" : location.hash.substr(1);
|
---|
40 |
|
---|
41 | var args = location.search.substr(1).split('&');
|
---|
42 |
|
---|
43 | for (var i=0; i<args.length; i++)
|
---|
44 | {
|
---|
45 | switch (args[i])
|
---|
46 | {
|
---|
47 | case "max": $("body").setAttribute("data-max", "yes"); continue;
|
---|
48 | case "noslide": $("body").setAttribute("data-noslide", "yes"); continue;
|
---|
49 | }
|
---|
50 |
|
---|
51 | var entry = args[i].split('=');
|
---|
52 | if (entry.length!=2)
|
---|
53 | continue;
|
---|
54 |
|
---|
55 | switch (entry[0])
|
---|
56 | {
|
---|
57 | case "w": $("body").setAttribute("data-width", entry[1]); break;
|
---|
58 | case "h": $("body").setAttribute("data-height", entry[1]); break;
|
---|
59 | }
|
---|
60 | }
|
---|
61 |
|
---|
62 |
|
---|
63 | /*
|
---|
64 | alert("0 -- "+navigator.appCodeName+"\n"+
|
---|
65 | "1 -- "+navigator.appName+"\n"+
|
---|
66 | "2 -- "+navigator.appVersion+"\n"+
|
---|
67 | "3 -- "+navigator.platform+"\n"+
|
---|
68 | "4 -- "+navigator.userAgent);
|
---|
69 | */
|
---|
70 | loadPage(name, 0, 0);
|
---|
71 | }
|
---|
72 |
|
---|
73 | function onresize()
|
---|
74 | {
|
---|
75 | var z = $("body").getAttribute("data-visible");
|
---|
76 |
|
---|
77 | //$("table"+z).style.width="100%";
|
---|
78 | $("image"+z).style.width="1px";
|
---|
79 | $("canvas"+z).width=1;
|
---|
80 |
|
---|
81 | doresize(z);
|
---|
82 |
|
---|
83 | }
|
---|
84 |
|
---|
85 | function loadPage(name, z, dz)
|
---|
86 | {
|
---|
87 | if (isSliding())
|
---|
88 | return;
|
---|
89 |
|
---|
90 | var xmlPage = new XMLHttpRequest();
|
---|
91 | xmlPage.open('POST', "struct/"+name+'.page', true);
|
---|
92 | xmlPage.onload = function ()
|
---|
93 | {
|
---|
94 | if (xmlPage.status!=200)
|
---|
95 | {
|
---|
96 | alert("ERROR[0] - HTTP request '"+name+".page': "+xmlPage.statusText+" ["+xmlPage.status+"]");
|
---|
97 | //setTimeout("loadPage('+name+')", 5000);
|
---|
98 | /****** invalidate ******/
|
---|
99 | return;
|
---|
100 | }
|
---|
101 |
|
---|
102 | buildPage(name, xmlPage.responseText, z, dz);
|
---|
103 | changePage(z, z+dz);
|
---|
104 |
|
---|
105 | //changePage(name, xmlHttp.resposeText);
|
---|
106 | //slideOut(name, xmlHttp.responseText);
|
---|
107 | //displayPage(name, xmlHttp.responseText);
|
---|
108 | //onresize(true);
|
---|
109 | };
|
---|
110 |
|
---|
111 | xmlPage.send(null);
|
---|
112 |
|
---|
113 | location.hash = name;
|
---|
114 | }
|
---|
115 |
|
---|
116 | function sendCommand(command)
|
---|
117 | {
|
---|
118 | var debug = false;
|
---|
119 |
|
---|
120 | var uri = "index.php?";
|
---|
121 | if (debug==true)
|
---|
122 | uri += "debug&";
|
---|
123 | uri += command;
|
---|
124 |
|
---|
125 | var xmlCmd = new XMLHttpRequest();
|
---|
126 | xmlCmd.open('POST', uri, true);
|
---|
127 | xmlCmd.onload = function ()
|
---|
128 | {
|
---|
129 | if (xmlCmd.status!=200)
|
---|
130 | {
|
---|
131 | alert("ERROR[1] - HTTP request: "+xmlCmd.statusText+" ["+xmlCmd.status+"]");
|
---|
132 | return;
|
---|
133 | }
|
---|
134 |
|
---|
135 | if (xmlCmd.responseText.length==0)
|
---|
136 | {
|
---|
137 | alert("No proper acknowledgment of command execution received.");
|
---|
138 | return;
|
---|
139 | }
|
---|
140 |
|
---|
141 | var txt = xmlCmd.responseText.split('\n');
|
---|
142 | switch (txt[0])
|
---|
143 | {
|
---|
144 | case "1": alert("dimctrl unreachable."); break;
|
---|
145 | case "2": /*success*/ break;
|
---|
146 | default: alert("Return code '"+txt[0]+"' unknown."); break;
|
---|
147 | }
|
---|
148 | if (txt.length>1)
|
---|
149 | alert(xmlCmd.responseText);
|
---|
150 | };
|
---|
151 | xmlCmd.send(null);
|
---|
152 | }
|
---|
153 |
|
---|
154 |
|
---|
155 | function submit(script)
|
---|
156 | {
|
---|
157 | var inputs = document.getElementsByTagName("input");
|
---|
158 |
|
---|
159 | var args = "start="+script+".dim";
|
---|
160 | for (var i=0; i<inputs.length; i++)
|
---|
161 | args += "&"+inputs[i].name+"="+inputs[i].value;
|
---|
162 |
|
---|
163 | //alert(args);
|
---|
164 |
|
---|
165 | sendCommand(args);
|
---|
166 | }
|
---|
167 |
|
---|
168 | function buildPage(name, text, oldz, dz)
|
---|
169 | {
|
---|
170 | var fname = dz==0 ? "fact" : $("table"+oldz).getAttribute("data-file");
|
---|
171 |
|
---|
172 | var z = oldz + dz;
|
---|
173 |
|
---|
174 | var lines = text.split('\n');
|
---|
175 |
|
---|
176 | if (lines.length==0)
|
---|
177 | {
|
---|
178 | alert("buildPage - received data empty.");
|
---|
179 | return;
|
---|
180 | }
|
---|
181 |
|
---|
182 | if (lines[0].length==0)
|
---|
183 | {
|
---|
184 | alert("buildPage - title missing");
|
---|
185 | return;
|
---|
186 | }
|
---|
187 |
|
---|
188 | var title = lines[0];
|
---|
189 | var is_cmd = title[0]=='*';
|
---|
190 | if (is_cmd)
|
---|
191 | title = title.substr(1);
|
---|
192 |
|
---|
193 | // ==================================================================
|
---|
194 |
|
---|
195 | var th = $new("thead");
|
---|
196 | th.colSpan = 3;
|
---|
197 | th.width = "100%";
|
---|
198 |
|
---|
199 | var htr = $new("tr");
|
---|
200 | th.appendChild(htr);
|
---|
201 |
|
---|
202 | var htd = $new("td");
|
---|
203 | htd.setAttribute("class", "thead");
|
---|
204 | htd.colSpan = 3;
|
---|
205 | htd.width = "100%";
|
---|
206 | htr.appendChild(htd);
|
---|
207 |
|
---|
208 | // -------------
|
---|
209 |
|
---|
210 | var htab = $new("table");
|
---|
211 | htab.width = "100%";
|
---|
212 | htd.appendChild(htab);
|
---|
213 |
|
---|
214 | var hhtr = $new("tr");
|
---|
215 | htab.appendChild(hhtr);
|
---|
216 |
|
---|
217 | var htd0 = $new("td");
|
---|
218 | var htd1 = $new("td");
|
---|
219 | var htd2 = $new("td");
|
---|
220 | var htd3 = $new("td");
|
---|
221 | var htd4 = $new("td");
|
---|
222 | htd0.setAttribute("class", "tcell1");
|
---|
223 | htd1.setAttribute("class", "tcell2");
|
---|
224 | htd2.setAttribute("class", "tcell1");
|
---|
225 | htd2.setAttribute("width", "1px");
|
---|
226 | htd3.setAttribute("class", "tcell1");
|
---|
227 | htd3.setAttribute("width", "1px");
|
---|
228 | htd4.setAttribute("width", "1px");
|
---|
229 | hhtr.appendChild(htd4);
|
---|
230 | hhtr.appendChild(htd3);
|
---|
231 | hhtr.appendChild(htd0);
|
---|
232 | hhtr.appendChild(htd1);
|
---|
233 | hhtr.appendChild(htd2);
|
---|
234 |
|
---|
235 | var div1 = $new("div");
|
---|
236 | var div2 = $new("div");
|
---|
237 | var div3 = $new("div");
|
---|
238 | var div4 = $new("div");
|
---|
239 | div4.id = "warn"+z;
|
---|
240 | div2.setAttribute("class", "icon_white");
|
---|
241 | div4.setAttribute("class", "icon_color");
|
---|
242 | div2.setAttribute("style", "background-position:-396px 50%;");
|
---|
243 | div4.setAttribute("style", "display:none;background-position:-12px -12px;");
|
---|
244 | div2.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage(fname, z, -dz); };
|
---|
245 | div4.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('error', z, +1); };
|
---|
246 |
|
---|
247 | if (name=="fact")
|
---|
248 | {
|
---|
249 | div3.setAttribute("class", "icon_color");
|
---|
250 | div3.setAttribute("style", "background-position:-58px -146px;");
|
---|
251 | }
|
---|
252 | else
|
---|
253 | {
|
---|
254 | div3.setAttribute("class", "icon_white");
|
---|
255 | div3.setAttribute("style", "background-position:-575px 50%;");
|
---|
256 | div3.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('fact', z, -1); };
|
---|
257 | }
|
---|
258 |
|
---|
259 | var sp0 = $new("span");
|
---|
260 | var sp1 = $new("span");
|
---|
261 | var sp2 = $new("span");
|
---|
262 | sp0.id = "ldot" +z;
|
---|
263 | sp1.id = "title"+z;
|
---|
264 | sp2.id = "rdot" +z;
|
---|
265 | sp1.setAttribute("style", "font-size:large;");
|
---|
266 | sp0.setAttribute("data-color", "3");
|
---|
267 | sp2.setAttribute("data-color", "3");
|
---|
268 | sp0.appendChild($txt(" \u2022 "));
|
---|
269 | sp1.appendChild($txt(title));
|
---|
270 | sp2.appendChild($txt(" \u2022 "));
|
---|
271 | if (is_cmd)
|
---|
272 | {
|
---|
273 | sp1.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; submit(name); this.style.backgroundColor=''; };
|
---|
274 | }
|
---|
275 | else
|
---|
276 | {
|
---|
277 | if (name!='control')
|
---|
278 | sp1.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.15)'; loadPage('control', z, +1); };
|
---|
279 | }
|
---|
280 |
|
---|
281 | div1.setAttribute("style", "font-size:small;");
|
---|
282 | div1.id = "reporttime"+z;
|
---|
283 | div1.appendChild($txt("---"));
|
---|
284 |
|
---|
285 | div1.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; sendCommand('stop'); this.style.backgroundColor=''; };
|
---|
286 |
|
---|
287 | htd0.appendChild(sp0);
|
---|
288 | htd0.appendChild(sp1);
|
---|
289 | htd0.appendChild(sp2);
|
---|
290 |
|
---|
291 | htd1.appendChild(div1);
|
---|
292 | if (dz!=0/* && z+dz!=0*/)
|
---|
293 | htd2.appendChild(div2); // back
|
---|
294 | htd3.appendChild(div3); // home
|
---|
295 | htd4.appendChild(div4); // Warning
|
---|
296 |
|
---|
297 | // ==================================================================
|
---|
298 |
|
---|
299 | var tf = $new("tfoot");
|
---|
300 |
|
---|
301 | var ftr = $new("tr");
|
---|
302 | tf.appendChild(ftr);
|
---|
303 |
|
---|
304 | var ftd = $new("td");
|
---|
305 | ftd.setAttribute("class", "tfoot");
|
---|
306 | ftd.width = "100%";
|
---|
307 | ftd.colSpan = 3;
|
---|
308 | ftr.appendChild(ftd);
|
---|
309 |
|
---|
310 | var ftab = $new("table");
|
---|
311 | ftab.width = "100%";
|
---|
312 | ftd.appendChild(ftab);
|
---|
313 |
|
---|
314 | var ftdH = $new("td");
|
---|
315 | var ftd0 = $new("td");
|
---|
316 | var ftd1 = $new("td");
|
---|
317 | var ftd2 = $new("td");
|
---|
318 | var ftd3 = $new("td");
|
---|
319 | var ftd4 = $new("td");
|
---|
320 | ftdH.setAttribute("width", "1px");
|
---|
321 | ftd2.setAttribute("width", "1px");
|
---|
322 | ftd3.setAttribute("width", "1px");
|
---|
323 | ftd4.setAttribute("width", "1px");
|
---|
324 |
|
---|
325 | ftdH.setAttribute("class", "tcell1");
|
---|
326 | ftd0.setAttribute("class", "tcell1");
|
---|
327 | ftd1.setAttribute("class", "tcell2");
|
---|
328 | ftd2.setAttribute("class", "tcell2");
|
---|
329 | ftd3.setAttribute("class", "tcell2");
|
---|
330 | ftd4.setAttribute("class", "tcell2");
|
---|
331 |
|
---|
332 | ftab.appendChild(ftdH);
|
---|
333 | ftab.appendChild(ftd0);
|
---|
334 | ftab.appendChild(ftd1);
|
---|
335 | ftab.appendChild(ftd2);
|
---|
336 | ftab.appendChild(ftd3);
|
---|
337 | ftab.appendChild(ftd4);
|
---|
338 |
|
---|
339 | var fdivH = $new("div");
|
---|
340 | var fdiv0 = $new("span");
|
---|
341 | var fdiv1 = $new("span");
|
---|
342 | var fdiv2 = $new("div");
|
---|
343 | var fdiv3 = $new("div");
|
---|
344 | var fdiv4 = $new("div");
|
---|
345 | ftd0.style.paddingLeft = "5px";
|
---|
346 | fdiv4.id="cmd"+z;
|
---|
347 |
|
---|
348 | fdiv2.setAttribute("class", "icon_white");
|
---|
349 | fdiv3.setAttribute("class", "icon_white");
|
---|
350 | fdiv4.setAttribute("class", "icon_white");
|
---|
351 | fdiv2.setAttribute("style", "background-position:-72px 50%;");
|
---|
352 | fdiv4.setAttribute("style", "background-position:-432px 50%;");
|
---|
353 | fdiv2.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; sendCommand('stop'); this.style.backgroundColor=''; };
|
---|
354 | if (is_cmd)
|
---|
355 | {
|
---|
356 | fdiv3.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; submit(name); this.style.backgroundColor=''; };
|
---|
357 | fdiv3.setAttribute("style", "background-position:-109px 50%;");
|
---|
358 | }
|
---|
359 | else
|
---|
360 | {
|
---|
361 | fdiv3.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('control', z, +1); };
|
---|
362 | fdiv3.setAttribute("style", "background-position:-288px 50%;");
|
---|
363 | }
|
---|
364 |
|
---|
365 | if (name.substr(0, 5)=="help-")
|
---|
366 | {
|
---|
367 | fdivH.setAttribute("class", "icon_color");
|
---|
368 | fdivH.setAttribute("style", "background-position:-408px -57px;");
|
---|
369 | //fdivH.setAttribute("style", "background-position:-13px -57px;");
|
---|
370 | }
|
---|
371 | else
|
---|
372 | {
|
---|
373 | fdivH.setAttribute("class", "icon_white");
|
---|
374 | fdivH.setAttribute("style", "background-position:-611px 50%;");
|
---|
375 | fdivH.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('help-'+name, z, +1); };
|
---|
376 | }
|
---|
377 | fdiv4.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('scriptlog', z, +1); };
|
---|
378 |
|
---|
379 |
|
---|
380 | fdiv0.setAttribute("style", "font-size:large;");
|
---|
381 | fdiv1.setAttribute("style", "font-size:small;");
|
---|
382 | fdiv1.id = "localtime"+z;
|
---|
383 |
|
---|
384 | fdiv0.appendChild($txt("logbook"));
|
---|
385 | fdiv1.appendChild($txt("loading..."));
|
---|
386 |
|
---|
387 | ftdH.appendChild(fdivH);
|
---|
388 | ftd0.appendChild(fdiv0);
|
---|
389 | ftd1.appendChild(fdiv1);
|
---|
390 | ftd2.appendChild(fdiv2);
|
---|
391 | if (name!='control')
|
---|
392 | ftd3.appendChild(fdiv3);
|
---|
393 | if (name!='scriptlog')
|
---|
394 | ftd4.appendChild(fdiv4);
|
---|
395 |
|
---|
396 | // ==================================================================
|
---|
397 |
|
---|
398 | var tbody = $new("tbody");
|
---|
399 |
|
---|
400 | for (var i=0; i<lines.length; i++)
|
---|
401 | {
|
---|
402 | lines[i] = trim(lines[i]);
|
---|
403 |
|
---|
404 | if (lines[i][0] == '#')
|
---|
405 | lines.splice(i--, 1);
|
---|
406 | }
|
---|
407 |
|
---|
408 | // Concatenate consecutive lines until they have at least two colons
|
---|
409 | for (var i=2; i<lines.length; i++)
|
---|
410 | {
|
---|
411 | if (lines[i].length==0)
|
---|
412 | continue;
|
---|
413 |
|
---|
414 | while (i<lines.length)
|
---|
415 | {
|
---|
416 | var cols = lines[i-1].split('|');
|
---|
417 | if (cols.length>=3)
|
---|
418 | break;
|
---|
419 |
|
---|
420 | lines[i-1] += lines[i].length==0 ? '<p/>' : " "+lines[i];
|
---|
421 | lines.splice(i,1);
|
---|
422 | }
|
---|
423 | }
|
---|
424 |
|
---|
425 | var counter = 1;
|
---|
426 | for (var i=1; i<lines.length; i++)
|
---|
427 | {
|
---|
428 | lines[i] = trim(lines[i]);
|
---|
429 |
|
---|
430 | if (lines[i].length==0)
|
---|
431 | continue;
|
---|
432 |
|
---|
433 | var cols = lines[i].split('|');
|
---|
434 | if (cols.length != 3 && cols.length !=4)
|
---|
435 | {
|
---|
436 | alert("Wrong number of columns in line #"+i+" in '"+name+"': '"+lines[i]+"' N(cols)="+cols.length);
|
---|
437 | continue;
|
---|
438 | }
|
---|
439 |
|
---|
440 | var check = cols[1].split("=");
|
---|
441 |
|
---|
442 | if (check.length>1 && (check[0]=="camera" || check[0]=="hist"))
|
---|
443 | {
|
---|
444 | var data = cols[1].substring(check[0].length+1).split("/");
|
---|
445 |
|
---|
446 | var tr = $new("tr");
|
---|
447 | tr.setAttribute("class", "row");
|
---|
448 | //tr.setAttribute("style", "margin:0;padding:0;");
|
---|
449 |
|
---|
450 | var td = $new("td");
|
---|
451 | td.setAttribute("class", "container");
|
---|
452 | td.id = "container";
|
---|
453 | td.colSpan = 3;
|
---|
454 | tr.appendChild(td);
|
---|
455 |
|
---|
456 | var canv = $new("canvas");
|
---|
457 | canv.id = "canvas"+z;
|
---|
458 | canv.width = "1";
|
---|
459 | canv.height = "1";
|
---|
460 | //canv.onclick = function () { save(); }
|
---|
461 | canv.setAttribute("data-type", check[0]);
|
---|
462 | canv.setAttribute("data-file", data[0]);
|
---|
463 | canv.setAttribute("data-data", cols[1].substring(check[0].length+data[0].length+2));
|
---|
464 | // canv.setAttribute("style", "display:none;");
|
---|
465 | td.appendChild(canv);
|
---|
466 |
|
---|
467 | var img = $new("img");
|
---|
468 | img.src = "img/dummy.png";//needed in firefox
|
---|
469 | img.id = "image"+z;
|
---|
470 | img.setAttribute("style", "width:1px;height:1px;display:none;");
|
---|
471 | td.appendChild(img);
|
---|
472 |
|
---|
473 | tbody.appendChild(tr);
|
---|
474 | continue;
|
---|
475 | }
|
---|
476 |
|
---|
477 | var tr = $new("tr");
|
---|
478 | tr.setAttribute("class", "row");
|
---|
479 | if (valid(cols[0]))
|
---|
480 | tr.setAttribute("onclick", "this.style.background='#ccb'; loadPage('"+cols[0]+"', "+z+", -1);");
|
---|
481 | if (valid(cols[3]))
|
---|
482 | tr.setAttribute("onclick", "this.style.background='#ccb'; loadPage('"+cols[3]+"', "+z+", +1);");
|
---|
483 |
|
---|
484 | var td0 = $new("td");
|
---|
485 | td0.setAttribute("class", "tcol0");
|
---|
486 | tr.appendChild(td0);
|
---|
487 |
|
---|
488 | if (check.length>0 && check[0]=="image")
|
---|
489 | {
|
---|
490 | var img = $new("img");
|
---|
491 | img.style.width="100%";
|
---|
492 | img.style.display="block";
|
---|
493 | img.src = "img/"+check[1];
|
---|
494 | td0.style.paddingLeft=0;
|
---|
495 | td0.style.border=0;
|
---|
496 | td0.colSpan=3;
|
---|
497 | td0.appendChild(img);
|
---|
498 |
|
---|
499 | tbody.appendChild(tr);
|
---|
500 | continue;
|
---|
501 | }
|
---|
502 |
|
---|
503 | if (valid(cols[0]))
|
---|
504 | {
|
---|
505 | var sp = $new("div");
|
---|
506 | sp.setAttribute("class", "icon_black");
|
---|
507 | sp.setAttribute("style", "background-position: -144px 50%;");
|
---|
508 | td0.appendChild(sp);
|
---|
509 | }
|
---|
510 |
|
---|
511 | var td1 = $new("td");
|
---|
512 | td1.setAttribute("class", "tcol1");
|
---|
513 | td1.width = "100%";
|
---|
514 | tr.appendChild(td1);
|
---|
515 |
|
---|
516 | var td2 = $new("td");
|
---|
517 | td2.setAttribute("class", "tcol2");
|
---|
518 | td2.width = "18px";
|
---|
519 |
|
---|
520 | if (valid(cols[3]))
|
---|
521 | {
|
---|
522 | var sp = $new("div");
|
---|
523 | sp.setAttribute("class", "icon_black");
|
---|
524 | sp.setAttribute("style", "background-position: -108px 50%;");
|
---|
525 | td2.appendChild(sp);
|
---|
526 | }
|
---|
527 | tr.appendChild(td2);
|
---|
528 |
|
---|
529 | var tab = $new("table");
|
---|
530 | tab.width = "100%";
|
---|
531 | td1.appendChild(tab);
|
---|
532 |
|
---|
533 | var innertr = $new("tr");
|
---|
534 | tab.appendChild(innertr);
|
---|
535 |
|
---|
536 | var cell1 = $new("td");
|
---|
537 | cell1.setAttribute("class", "tcell1");
|
---|
538 |
|
---|
539 | var cell2 = $new("td");
|
---|
540 | cell2.setAttribute("class", valid(cols[1]) ? "tcell2" : "tcell2l");
|
---|
541 |
|
---|
542 | if (check.length==0 || check[0]!="input")
|
---|
543 | {
|
---|
544 | var div = $new("div");
|
---|
545 | div.innerHTML = cols[1];
|
---|
546 | cell1.appendChild(div);
|
---|
547 | //cell1.appendChild($txt(cols[1]));
|
---|
548 |
|
---|
549 | if (cols.length>2 && cols[2].length>0)
|
---|
550 | {
|
---|
551 | cell2.id = "data"+z+"-"+counter;
|
---|
552 | cell2.setAttribute("data-form", cols[2]);
|
---|
553 | cell2.appendChild($txt("---"));
|
---|
554 | counter++;
|
---|
555 | }
|
---|
556 | else
|
---|
557 | cell1.setAttribute("class", "description");
|
---|
558 | }
|
---|
559 | else
|
---|
560 | {
|
---|
561 | var opt = check[1].split('/');
|
---|
562 |
|
---|
563 | if (opt.length<2)
|
---|
564 | alert("Argument name missing for'"+check[1]+"'");
|
---|
565 |
|
---|
566 | var div = $new("div");
|
---|
567 | div.innerHTML = opt[0];
|
---|
568 | cell1.appendChild(div);
|
---|
569 | //cell1.appendChild($txt(opt[0]));
|
---|
570 |
|
---|
571 | var input = $new("input");
|
---|
572 | input.name = opt[1];
|
---|
573 | input.type = "text";
|
---|
574 | input.maxlength = 80;
|
---|
575 | if (opt.length>2)
|
---|
576 | input.value=opt[2];
|
---|
577 |
|
---|
578 | cell2.appendChild(input);
|
---|
579 | }
|
---|
580 |
|
---|
581 | innertr.appendChild(cell1);
|
---|
582 | innertr.appendChild(cell2);
|
---|
583 |
|
---|
584 | tbody.appendChild(tr);
|
---|
585 | }
|
---|
586 |
|
---|
587 | // ==================================================================
|
---|
588 |
|
---|
589 | if (debug == true)
|
---|
590 | {
|
---|
591 | tr = $new("tr");
|
---|
592 | tr.setAttribute("class", "row");
|
---|
593 |
|
---|
594 | td = $new("td");
|
---|
595 | td.id = "debug"+z;
|
---|
596 | td.colSpan = 3;
|
---|
597 | tr.appendChild(td);
|
---|
598 |
|
---|
599 | tbody.appendChild(tr);
|
---|
600 | }
|
---|
601 |
|
---|
602 | // ==================================================================
|
---|
603 |
|
---|
604 | var table = $("table"+z);
|
---|
605 | if (table)
|
---|
606 | $("body").removeChild(table);
|
---|
607 |
|
---|
608 | table = $new("table");
|
---|
609 | table.id = "table"+z;
|
---|
610 | table.border = 0;
|
---|
611 | table.cellSpacing = 0;
|
---|
612 | table.cellPadding = "0px";
|
---|
613 | //table.setAttribute("style", "overflow:hidden;position:fixed;top:0px;left:"+window.innerWidth+"px;")
|
---|
614 | table.setAttribute("style",
|
---|
615 | "position:fixed;width:100%;top:0px;"+
|
---|
616 | "left:"+window.innerWidth+"px;");
|
---|
617 |
|
---|
618 | table.appendChild(th);
|
---|
619 | table.appendChild(tbody);
|
---|
620 | table.appendChild(tf);
|
---|
621 |
|
---|
622 | $("body").appendChild(table);
|
---|
623 |
|
---|
624 | // ==================================================================
|
---|
625 |
|
---|
626 | /*
|
---|
627 | // Scrollbar for just the body
|
---|
628 | table.style.position = "fixed";
|
---|
629 | th.style.position = "aboslute";
|
---|
630 | tf.style.position = "aboslute";
|
---|
631 | tbody.style.overflowY = "auto";
|
---|
632 | tbody.style.display = "block";
|
---|
633 | tbody.style.height = (window.innerHeight-th.clientHeight-tf.clientHeight)+"px";
|
---|
634 | tbody.id = "tbody"+z;
|
---|
635 | th.id = "thead"+z;
|
---|
636 | tf.id = "tfoot"+z;
|
---|
637 | */
|
---|
638 |
|
---|
639 | // ==================================================================
|
---|
640 |
|
---|
641 | table.setAttribute("data-file", name);
|
---|
642 | doresize(z);
|
---|
643 | }
|
---|
644 |
|
---|
645 | function doresize(z)
|
---|
646 | {
|
---|
647 | var img = $("image"+z);
|
---|
648 | var canv = $("canvas"+z);
|
---|
649 | if (!img || !canv)
|
---|
650 | return;
|
---|
651 |
|
---|
652 | var h = $("table"+z).offsetHeight;
|
---|
653 | if (h == 0)
|
---|
654 | return;
|
---|
655 |
|
---|
656 | // ===========================================
|
---|
657 | /*
|
---|
658 | var tb = $("tbody"+z);
|
---|
659 | var hw = $("thead"+z).clientHeight;
|
---|
660 | var fw = $("tfoot"+z).clientHeight;
|
---|
661 |
|
---|
662 | tb.style.height = (window.innerHeight-hw-fw)+"px";
|
---|
663 | */
|
---|
664 | // ===========================================
|
---|
665 |
|
---|
666 | var fixedw = $("body").getAttribute("data-width");
|
---|
667 | var fixedh = $("body").getAttribute("data-height");
|
---|
668 |
|
---|
669 | var W = fixedw>0 ? fixedw : window.innerWidth;
|
---|
670 | var H = fixedh>0 ? fixedh : window.innerHeight;
|
---|
671 |
|
---|
672 | var max = $("body").getAttribute("data-max")=="yes";
|
---|
673 |
|
---|
674 | var ih = max ? W : H - h + parseInt(img.style.height, 10);
|
---|
675 |
|
---|
676 | // This might create the scroll bar
|
---|
677 | img.style.height = ih+"px";
|
---|
678 | canv.height = ih;
|
---|
679 |
|
---|
680 | // now we can evaluate the correct view-port
|
---|
681 | // (-2 is the border size of the parent element 'container')
|
---|
682 | //var sW = (fixedw ? fixedw : $("table"+z).scrollWidth)-2;
|
---|
683 | var sW = fixedw ? fixedw : canv.parentNode.clientWidth;
|
---|
684 |
|
---|
685 | img.style.width = sW+"px";
|
---|
686 | canv.width = sW;
|
---|
687 |
|
---|
688 | // ------ debug -----
|
---|
689 | if (debug == true)
|
---|
690 | {
|
---|
691 | $('debug'+z).innerHTML = "";
|
---|
692 | $('debug'+z).innerHTML += "|W="+W +"/"+H;
|
---|
693 | $('debug'+z).innerHTML += "|H="+h+"/"+$("table"+z).offsetHeight+"/"+img.offsetHeight;
|
---|
694 | $('debug'+z).innerHTML += "|I="+img.style.height+"+"+H+"-"+h;
|
---|
695 | }
|
---|
696 | }
|
---|
697 |
|
---|
698 | var intervalSlide = null;
|
---|
699 |
|
---|
700 | function changePage(oldz, newz)
|
---|
701 | {
|
---|
702 | // No page displayed yet
|
---|
703 | if (oldz==newz)
|
---|
704 | {
|
---|
705 | $("table"+newz).style.left="0px";
|
---|
706 | $("body").setAttribute("data-visible", newz);
|
---|
707 |
|
---|
708 | doresize(0);
|
---|
709 |
|
---|
710 | //setInterval(refresh_text, 1000);
|
---|
711 | //setInterval(refresh_graphics, 5000);
|
---|
712 |
|
---|
713 | refresh_text();
|
---|
714 |
|
---|
715 | // first: decode the pixel mapping!
|
---|
716 | var sum = 1036080;
|
---|
717 | for (var i=0; i<1440; i++)
|
---|
718 | {
|
---|
719 | var d0 = codedMap.charCodeAt(i*2) -48;
|
---|
720 | var d1 = codedMap.charCodeAt(i*2+1)-48;
|
---|
721 |
|
---|
722 | map[i] = d0 | (d1<<6);
|
---|
723 | sum -= map[i];
|
---|
724 | }
|
---|
725 | if (sum!=0)
|
---|
726 | alert("Pixel mapping table corrupted!");
|
---|
727 |
|
---|
728 | refresh_graphics();
|
---|
729 | return;
|
---|
730 | }
|
---|
731 |
|
---|
732 | var W = window.innerWidth;
|
---|
733 | if (W==0 || $("body").getAttribute("data-noslide")=="yes")
|
---|
734 | {
|
---|
735 | $("body").setAttribute("data-visible", newz);
|
---|
736 | $("body").removeChild($("table"+oldz));
|
---|
737 | $("table"+newz).style.left="0px";
|
---|
738 | return;
|
---|
739 | }
|
---|
740 |
|
---|
741 | if (newz>oldz)
|
---|
742 | $("table"+newz).style.left = W+"px";
|
---|
743 | else
|
---|
744 | $("table"+newz).style.left = (-W-1)+"px";
|
---|
745 |
|
---|
746 | $("body").setAttribute("data-visible", newz);
|
---|
747 |
|
---|
748 | // This is needed on my mobile to ensure that te browser
|
---|
749 | // doesn't try to zoom during shifting
|
---|
750 | $("table"+newz).style.position="fixed";
|
---|
751 | $("table"+oldz).style.position="fixed";
|
---|
752 |
|
---|
753 | intervalSlide = setInterval(function (){doShift(oldz,newz);}, 75);
|
---|
754 | }
|
---|
755 |
|
---|
756 | function doShift(oldz, newz)
|
---|
757 | {
|
---|
758 | var t0 = $("table"+oldz);
|
---|
759 | var t1 = $("table"+newz);
|
---|
760 |
|
---|
761 | if (t0.style.display=="none")
|
---|
762 | {
|
---|
763 | clearInterval(intervalSlide);
|
---|
764 | $("body").removeChild(t0);
|
---|
765 |
|
---|
766 | t1.style.position="absolute";
|
---|
767 |
|
---|
768 | // Now the scroll bar might have to appear or disappear
|
---|
769 | doresize(newz);
|
---|
770 | return;
|
---|
771 | }
|
---|
772 |
|
---|
773 | var x0 = t0.offsetLeft;
|
---|
774 | var x1 = t1.offsetLeft;
|
---|
775 |
|
---|
776 | var W = window.innerWidth;
|
---|
777 |
|
---|
778 | if (newz<oldz)
|
---|
779 | {
|
---|
780 | x0 += W/5;
|
---|
781 | x1 += W/5;
|
---|
782 | }
|
---|
783 |
|
---|
784 | if (newz>oldz)
|
---|
785 | {
|
---|
786 | x0 -= W/5;
|
---|
787 | x1 -= W/5;
|
---|
788 | }
|
---|
789 |
|
---|
790 | if ((newz<oldz && x1>=0) || (newz>oldz && x1<=0))
|
---|
791 | {
|
---|
792 | t0.style.display="none";
|
---|
793 | x1 = 0;
|
---|
794 | }
|
---|
795 |
|
---|
796 | t0.style.left = x0+"px";
|
---|
797 | t1.style.left = x1+"px";
|
---|
798 | }
|
---|
799 |
|
---|
800 | var timeoutText = null;
|
---|
801 | var timeoutGraphics = null;
|
---|
802 |
|
---|
803 | function refresh_text()
|
---|
804 | {
|
---|
805 | var z=$("body").getAttribute("data-visible");
|
---|
806 |
|
---|
807 | var fname = $("table"+z).getAttribute("data-file");
|
---|
808 |
|
---|
809 | var is_help = fname.substr(0,5)=="help-";
|
---|
810 |
|
---|
811 | // Is sliding, no file defined or just help text?
|
---|
812 | if (isSliding() || !valid(fname) || is_help)
|
---|
813 | {
|
---|
814 | if (is_help)
|
---|
815 | {
|
---|
816 | setUTC($("localtime"+z), new Date());
|
---|
817 | $("reporttime"+z).innerHTML="";
|
---|
818 | }
|
---|
819 |
|
---|
820 | // invalidate?
|
---|
821 | timeoutText = setTimeout(refresh_text, 1000);
|
---|
822 | return;
|
---|
823 | }
|
---|
824 |
|
---|
825 | var xmlText = new XMLHttpRequest();
|
---|
826 | xmlText.open('POST', "data/"+fname+'.data', true);
|
---|
827 | xmlText.onload = function ()
|
---|
828 | {
|
---|
829 | if (xmlText.status!=200)
|
---|
830 | {
|
---|
831 | alert("ERROR[1] - HTTP request '"+fname+".data': "+xmlText.statusText+" ["+xmlText.status+"]");
|
---|
832 | timeoutText = setTimeout(refresh_text, 10000);
|
---|
833 | return;
|
---|
834 | }
|
---|
835 |
|
---|
836 | if (!isSliding())
|
---|
837 | {
|
---|
838 | cycleCol($("ldot"+z));
|
---|
839 | update_text(fname, xmlText.responseText);
|
---|
840 | }
|
---|
841 | timeoutText = setTimeout(refresh_text, 3000);
|
---|
842 | };
|
---|
843 | xmlText.send(null);
|
---|
844 | }
|
---|
845 |
|
---|
846 | var date0 = null;
|
---|
847 |
|
---|
848 | function update_text(fname, result)
|
---|
849 | {
|
---|
850 | var z=$("body").getAttribute("data-visible");
|
---|
851 | var table = $("table"+z);
|
---|
852 |
|
---|
853 | if (table.getAttribute("data-file") != fname)
|
---|
854 | return;
|
---|
855 |
|
---|
856 | var tokens = result.split('\n');
|
---|
857 |
|
---|
858 | // ----------------------------------------------------
|
---|
859 |
|
---|
860 | var rtime = $("reporttime"+z);
|
---|
861 | var ltime = $("localtime"+z);
|
---|
862 |
|
---|
863 | var now = new Date();
|
---|
864 |
|
---|
865 | var header = tokens[0].split('\t');
|
---|
866 |
|
---|
867 | // File corrupted / should we remove the date?)
|
---|
868 | if (header.length!=3 && header.length!=2 && header.length!=1 && header[0].length!=13)
|
---|
869 | {
|
---|
870 | // we ignore corrupted files for one minute
|
---|
871 | if (date0==null || date0.getTime()+60000<now.getTime())
|
---|
872 | rtime.style.color = "darkred";
|
---|
873 |
|
---|
874 | return;
|
---|
875 | }
|
---|
876 |
|
---|
877 | // File OK
|
---|
878 | date0 = now;
|
---|
879 |
|
---|
880 | var stamp = new Date();
|
---|
881 | stamp.setTime(header[0]);
|
---|
882 |
|
---|
883 | // File older than 1min
|
---|
884 | if (stamp.getTime()+60000<now.getTime())
|
---|
885 | rtime.style.color = "darkred";
|
---|
886 | else
|
---|
887 | rtime.style.color = "";
|
---|
888 |
|
---|
889 | setUTC(rtime, stamp);
|
---|
890 | setUTC(ltime, now);
|
---|
891 |
|
---|
892 | // ----------------------------------------------------
|
---|
893 |
|
---|
894 | $("warn"+z).style.display = header.length>=2 && header[1]=='1' ? "" : "none";
|
---|
895 |
|
---|
896 | if (header.length==3)
|
---|
897 | $("cmd"+z).style.backgroundColor = header[2]=='1' ? "darkgreen" : "darkred";
|
---|
898 |
|
---|
899 | // ----------------------------------------------------
|
---|
900 |
|
---|
901 | //var p = table.tBodies.length==3 ? 1 : 0;
|
---|
902 | //var tbody = table.tBodies[p];
|
---|
903 |
|
---|
904 | for (var line=1; line<tokens.length; line++)
|
---|
905 | {
|
---|
906 | if (tokens[line].length==0)
|
---|
907 | continue;
|
---|
908 |
|
---|
909 | var e = $("data"+z+"-"+line);
|
---|
910 | if (!e)
|
---|
911 | continue;
|
---|
912 |
|
---|
913 | var form = e.getAttribute("data-form");
|
---|
914 | if (!form)
|
---|
915 | continue;
|
---|
916 |
|
---|
917 | var cols = tokens[line].split('\t');
|
---|
918 | for (var col=1; col<cols.length; col++)
|
---|
919 | form = form.replace("\$"+(col-1), cols[col].length==0 ? "—" : cols[col]);
|
---|
920 |
|
---|
921 | if (cols.length<=1)
|
---|
922 | form = "—";
|
---|
923 |
|
---|
924 | form = form.replace(/<#(.*?)>/g, "<font color='$1'>");
|
---|
925 | form = form.replace(/<([\+-])>/g, "<font size='$11'>");
|
---|
926 | form = form.replace(/<\/([#\+-])>/g, "</font>");
|
---|
927 | form = form.replace(/([0-9][0-9]):([0-9][0-9]):([0-9][0-9])/g,
|
---|
928 | "<pre>$1</pre>:<pre>$2</pre>:<pre>$3</pre>");
|
---|
929 | form = form.replace(/--:--:--/g, "<pre> </pre> <pre> </pre> <pre> </pre>");
|
---|
930 |
|
---|
931 | var newe = $new("div");
|
---|
932 | newe.innerHTML = form;
|
---|
933 | e.replaceChild(newe, e.lastChild);
|
---|
934 |
|
---|
935 | e.parentNode.parentNode.parentNode.parentNode.style.background=cols[0];
|
---|
936 | }
|
---|
937 | }
|
---|
938 |
|
---|
939 | // http://billmill.org/static/canvastutorial/index.html
|
---|
940 | // http://www.netmagazine.com/tutorials/learning-basics-html5-canvas
|
---|
941 | // http://www.alistapart.com/articles/responsive-web-design/
|
---|
942 |
|
---|
943 | function refresh_graphics()
|
---|
944 | {
|
---|
945 | var z = $("body").getAttribute("data-visible");
|
---|
946 |
|
---|
947 | var canvas = $("canvas"+z);
|
---|
948 |
|
---|
949 | // Is sliding or no data file defined?
|
---|
950 | var fname = canvas==null ? "" : canvas.getAttribute("data-file");
|
---|
951 | if (isSliding() || !valid(fname))
|
---|
952 | {
|
---|
953 | // invalidate?
|
---|
954 | timeoutGraphics = setTimeout(refresh_graphics, 3000);
|
---|
955 | return;
|
---|
956 | }
|
---|
957 |
|
---|
958 | var xmlGfx = new XMLHttpRequest();
|
---|
959 | xmlGfx.open('POST', "data/"+fname, true);
|
---|
960 | xmlGfx.onload = function ()
|
---|
961 | {
|
---|
962 | if (xmlGfx.status!=200)
|
---|
963 | {
|
---|
964 | alert("ERROR[2] - Request '"+fname+"': "+xmlGfx.statusText+" ["+xmlGfx.status+"]");
|
---|
965 | timeoutGraphics = setTimeout(refresh_graphics, 10000);
|
---|
966 | //****** invalidate ******
|
---|
967 | return;
|
---|
968 | }
|
---|
969 |
|
---|
970 | if (!isSliding())
|
---|
971 | {
|
---|
972 | cycleCol($("rdot"+z));
|
---|
973 | process_eventdata(xmlGfx.responseText);
|
---|
974 | }
|
---|
975 | timeoutGraphics = setTimeout(refresh_graphics, 5000)
|
---|
976 | };
|
---|
977 | xmlGfx.send(null);
|
---|
978 | }
|
---|
979 |
|
---|
980 |
|
---|
981 | function hueToRGB(hue)
|
---|
982 | {
|
---|
983 | hue /= 3;
|
---|
984 | hue %= 6;
|
---|
985 |
|
---|
986 | if (hue<1) return parseInt(255*hue, 10);
|
---|
987 | if (hue<3) return parseInt(255, 10);
|
---|
988 | if (hue<4) return parseInt(255*(4-hue), 10);
|
---|
989 |
|
---|
990 | return 0.
|
---|
991 | }
|
---|
992 |
|
---|
993 | function hueToHex(flt)
|
---|
994 | {
|
---|
995 | var s = hueToRGB(flt).toString(16);
|
---|
996 | return s.length==2 ? s : "0"+s;
|
---|
997 | }
|
---|
998 |
|
---|
999 | function HLStoRGB(hue)
|
---|
1000 | {
|
---|
1001 | hue *= 14;
|
---|
1002 |
|
---|
1003 | var sr = hueToHex(20-hue);
|
---|
1004 | var sg = hueToHex(14-hue);
|
---|
1005 | var sb = hueToHex(26-hue);
|
---|
1006 |
|
---|
1007 | return sr+sg+sb;
|
---|
1008 | }
|
---|
1009 |
|
---|
1010 | function color(col)
|
---|
1011 | {
|
---|
1012 | if (col==65533)
|
---|
1013 | col = 0;
|
---|
1014 |
|
---|
1015 | var hue = col/128;
|
---|
1016 | return HLStoRGB(hue);
|
---|
1017 | }
|
---|
1018 |
|
---|
1019 | function toHex(str, idx)
|
---|
1020 | {
|
---|
1021 | var ch = str[idx].toString(16);
|
---|
1022 | return ch.length==2 ? ch : "0"+ch;
|
---|
1023 | }
|
---|
1024 |
|
---|
1025 | function drawHex(ctx, x, y, col)
|
---|
1026 | {
|
---|
1027 | ctx.fillStyle = "#"+color(col);
|
---|
1028 |
|
---|
1029 | ctx.save();
|
---|
1030 |
|
---|
1031 | ctx.translate(x, y);
|
---|
1032 | ctx.scale(1/2, 1/3);
|
---|
1033 |
|
---|
1034 | ctx.beginPath();
|
---|
1035 | ctx.moveTo( 1, 1);
|
---|
1036 | ctx.lineTo( 0, 2);
|
---|
1037 | ctx.lineTo(-1, 1);
|
---|
1038 | ctx.lineTo(-1, -1);
|
---|
1039 | ctx.lineTo( 0, -2);
|
---|
1040 | ctx.lineTo( 1, -1);
|
---|
1041 | ctx.fill();
|
---|
1042 |
|
---|
1043 | ctx.restore();
|
---|
1044 | }
|
---|
1045 |
|
---|
1046 | function drawDisc(ctx, x, y, r, col)
|
---|
1047 | {
|
---|
1048 | ctx.fillStyle = "#"+color(col);
|
---|
1049 |
|
---|
1050 | ctx.save();
|
---|
1051 |
|
---|
1052 | ctx.translate(x, y);
|
---|
1053 |
|
---|
1054 | ctx.beginPath();
|
---|
1055 | ctx.arc(0, 0, r, 0, Math.PI*2, true);
|
---|
1056 | ctx.fill();
|
---|
1057 |
|
---|
1058 | ctx.restore();
|
---|
1059 | }
|
---|
1060 |
|
---|
1061 | function beginDrawCam(scale)
|
---|
1062 | {
|
---|
1063 | var z = $("body").getAttribute("data-visible");
|
---|
1064 | var canv = $("canvas"+z);
|
---|
1065 |
|
---|
1066 | var w = Math.min(canv.width/scale, canv.height/scale);
|
---|
1067 |
|
---|
1068 | var ctx = canv.getContext("2d");
|
---|
1069 |
|
---|
1070 | ctx.save();
|
---|
1071 | ctx.translate(canv.width/2, canv.height/2);
|
---|
1072 | ctx.scale(w*2, w*2);
|
---|
1073 |
|
---|
1074 | return ctx;
|
---|
1075 | }
|
---|
1076 |
|
---|
1077 | /**
|
---|
1078 | * @constructor
|
---|
1079 | */
|
---|
1080 | function Position(s, ring, i)
|
---|
1081 | {
|
---|
1082 | switch (s)
|
---|
1083 | {
|
---|
1084 | case 1: this.x = ring - i*0.5; this.y = + i; break;
|
---|
1085 | case 2: this.x = ring*0.5 - i; this.y = ring ; break;
|
---|
1086 | case 3: this.x = -ring*0.5 - i*0.5; this.y = ring - i; break;
|
---|
1087 | case 4: this.x = -ring + i*0.5; this.y = - i; break;
|
---|
1088 | case 5: this.x = -ring*0.5 + i; this.y = -ring ; break;
|
---|
1089 | case 0: this.x = ring*0.5 + i*0.5; this.y = -ring + i; break;
|
---|
1090 | }
|
---|
1091 | this.d = (function () { return this.x*this.x + this.y*this.y*3/4; });
|
---|
1092 | }
|
---|
1093 |
|
---|
1094 | function drawFullCam(data)
|
---|
1095 | {
|
---|
1096 | if (data.length!=40 && data.length!=160 && data.length!=320 && data.length!=1440)
|
---|
1097 | {
|
---|
1098 | alert("Camera - Received data has invalid size ("+data.length+"b)");
|
---|
1099 | return;
|
---|
1100 | }
|
---|
1101 |
|
---|
1102 | var div = map.length/data.length;
|
---|
1103 | var off = data.length==320 ? 0.2 : 0;
|
---|
1104 |
|
---|
1105 | var ctx = beginDrawCam(83);
|
---|
1106 | // ctx.rotate(Math.PI/3);
|
---|
1107 |
|
---|
1108 | ctx.scale(1, Math.sqrt(3)/2);
|
---|
1109 | ctx.translate(-0.5, 0);
|
---|
1110 |
|
---|
1111 | drawHex(ctx, 0, 0, data.charCodeAt(parseInt(map[0]/div+off, 10)));
|
---|
1112 |
|
---|
1113 | var cnt = 1;
|
---|
1114 | for (var ring=1; ring<24; ring++)
|
---|
1115 | {
|
---|
1116 | for (var s=0; s<6; s++)
|
---|
1117 | {
|
---|
1118 | for (var i=1; i<=ring; i++)
|
---|
1119 | {
|
---|
1120 | var pos = new Position(s, ring, i);
|
---|
1121 | if (pos.d() - pos.x > 395.75)
|
---|
1122 | continue;
|
---|
1123 |
|
---|
1124 | var p = parseInt(map[cnt]/div+off, 10);
|
---|
1125 |
|
---|
1126 | drawHex(ctx, pos.x, pos.y, data.charCodeAt(p));
|
---|
1127 | cnt++;
|
---|
1128 | }
|
---|
1129 | }
|
---|
1130 | }
|
---|
1131 |
|
---|
1132 | drawHex(ctx, 7, -22, data.charCodeAt(parseInt(map[1438]/div+off, 10)));
|
---|
1133 | drawHex(ctx, 7, 22, data.charCodeAt(parseInt(map[1439]/div+off, 10)));
|
---|
1134 |
|
---|
1135 | ctx.restore();
|
---|
1136 | }
|
---|
1137 |
|
---|
1138 | function drawCam(data)
|
---|
1139 | {
|
---|
1140 | var ctx = beginDrawCam(27);
|
---|
1141 | ctx.rotate(Math.PI/6);
|
---|
1142 | ctx.scale(1, Math.sqrt(3)/2);
|
---|
1143 |
|
---|
1144 | drawHex(ctx, 0, 0, data.charCodeAt(0));
|
---|
1145 |
|
---|
1146 | var cnt = 1;
|
---|
1147 | for (var ring=1; ring<=7; ring++)
|
---|
1148 | {
|
---|
1149 | for (var s=0; s<6; s++)
|
---|
1150 | {
|
---|
1151 | for (var i=1; i<=ring; i++)
|
---|
1152 | {
|
---|
1153 | var pos = new Position(s, ring, i);
|
---|
1154 | if (pos.d() > 44)
|
---|
1155 | continue;
|
---|
1156 |
|
---|
1157 | if (ring==7)
|
---|
1158 | {
|
---|
1159 | if (i==6 && (s==0 || s==3))
|
---|
1160 | continue;
|
---|
1161 | if (i==1 && (s==1 || s==4))
|
---|
1162 | continue;
|
---|
1163 | }
|
---|
1164 |
|
---|
1165 | drawHex(ctx, pos.x, pos.y, data.charCodeAt(cnt++));
|
---|
1166 | }
|
---|
1167 | }
|
---|
1168 | }
|
---|
1169 |
|
---|
1170 | ctx.restore();
|
---|
1171 | }
|
---|
1172 |
|
---|
1173 | function drawCamLegend(canv, data)
|
---|
1174 | {
|
---|
1175 | var unit = htmlDecode(canv.getAttribute("data-data"));
|
---|
1176 |
|
---|
1177 | var umin = data[1];
|
---|
1178 | var umax = data[2];
|
---|
1179 |
|
---|
1180 | var min = data[3]+unit
|
---|
1181 | var med = data[4]+unit;
|
---|
1182 | var max = data[5]+unit;
|
---|
1183 |
|
---|
1184 | var v0 = parseFloat(umin);
|
---|
1185 | var v1 = parseFloat(umax);
|
---|
1186 |
|
---|
1187 | var diff = v1-v0;
|
---|
1188 |
|
---|
1189 | var cw = canv.width;
|
---|
1190 | //var ch = canv.height;
|
---|
1191 |
|
---|
1192 | var ctx = canv.getContext("2d");
|
---|
1193 |
|
---|
1194 | ctx.font = "8pt Arial";
|
---|
1195 | ctx.textAlign = "right";
|
---|
1196 | ctx.textBaseline = "top";
|
---|
1197 |
|
---|
1198 | for (var i=0; i<11; i++)
|
---|
1199 | {
|
---|
1200 | ctx.strokeStyle = "#"+color(16*i);
|
---|
1201 | ctx.strokeText((v0+diff*i/10).toPrecision(3)+unit, cw-5, 125-i*12);
|
---|
1202 | }
|
---|
1203 |
|
---|
1204 | var mw = Math.max(ctx.measureText(min).width,
|
---|
1205 | ctx.measureText(med).width,
|
---|
1206 | ctx.measureText(max).width);
|
---|
1207 |
|
---|
1208 | ctx.textBaseline = "top";
|
---|
1209 | ctx.strokeStyle = "#000";
|
---|
1210 |
|
---|
1211 | ctx.strokeText(min, 5+mw, 5+24);
|
---|
1212 | ctx.strokeText(med, 5+mw, 5+12);
|
---|
1213 | ctx.strokeText(max, 5+mw, 5);
|
---|
1214 | }
|
---|
1215 |
|
---|
1216 | function drawGraph(canv, vals, data)
|
---|
1217 | {
|
---|
1218 | var unit = htmlDecode(canv.getAttribute("data-data"));//.split("/");
|
---|
1219 |
|
---|
1220 | var umin = vals[1]+unit;
|
---|
1221 | var umax = vals[2]+unit;
|
---|
1222 |
|
---|
1223 | var stat = vals[3]+unit+" / "+vals[4]+unit+" / "+vals[5]+unit;
|
---|
1224 |
|
---|
1225 | var cw = canv.width;
|
---|
1226 | var ch = canv.height;
|
---|
1227 |
|
---|
1228 | var ctx = canv.getContext("2d");
|
---|
1229 |
|
---|
1230 | var dw = 3; // tick width
|
---|
1231 | var fs = 8; // font size
|
---|
1232 |
|
---|
1233 | ctx.font = fs+"pt Arial";
|
---|
1234 | ctx.textAlign = "right";
|
---|
1235 |
|
---|
1236 | var dim0 = ctx.measureText(umin);
|
---|
1237 | var dim1 = ctx.measureText(umax);
|
---|
1238 |
|
---|
1239 | var tw = Math.max(dim0.width, dim1.width)+dw+2;
|
---|
1240 |
|
---|
1241 | var ml = 5+tw; // margin left
|
---|
1242 | var mr = 10; // margin right
|
---|
1243 |
|
---|
1244 | var mt = 5+2*fs+4; // margin top
|
---|
1245 | var mb = fs/2+4; // margin bottom
|
---|
1246 |
|
---|
1247 | var nx = 20;
|
---|
1248 | var ny = 10;
|
---|
1249 |
|
---|
1250 | var w = cw-ml-mr;
|
---|
1251 | var h = ch-mt-mb;
|
---|
1252 |
|
---|
1253 | ctx.strokeStyle = "#666";
|
---|
1254 |
|
---|
1255 | // --- data ---
|
---|
1256 | if (data.length>1)
|
---|
1257 | {
|
---|
1258 | ctx.beginPath();
|
---|
1259 | ctx.moveTo(ml, ch-mb-data.charCodeAt(0)/128*h);
|
---|
1260 | for (var i=1; i<data.length; i++)
|
---|
1261 | ctx.lineTo(ml+w/(data.length-1)*i, ch-mb-data.charCodeAt(i)/128*h);
|
---|
1262 |
|
---|
1263 | // --- finalize data ---
|
---|
1264 | ctx.lineTo(cw-mr, ch-mb);
|
---|
1265 | ctx.lineTo(ml, ch-mb);
|
---|
1266 | ctx.fillStyle = "#"+color(100);
|
---|
1267 | ctx.stroke();
|
---|
1268 | ctx.fill();
|
---|
1269 | }
|
---|
1270 |
|
---|
1271 | ctx.beginPath();
|
---|
1272 |
|
---|
1273 | // --- grid ---
|
---|
1274 |
|
---|
1275 | ctx.strokeStyle = "#eee";
|
---|
1276 |
|
---|
1277 | for (var i=1; i<=nx; i++)
|
---|
1278 | {
|
---|
1279 | ctx.moveTo(ml+w*i/nx, ch-mb);
|
---|
1280 | ctx.lineTo(ml+w*i/nx, mt);
|
---|
1281 | }
|
---|
1282 | for (var i=0; i<ny; i++)
|
---|
1283 | {
|
---|
1284 | ctx.moveTo(ml, mt+h*i/ny);
|
---|
1285 | ctx.lineTo(ml+w, mt+h*i/ny);
|
---|
1286 | }
|
---|
1287 | ctx.stroke();
|
---|
1288 | ctx.closePath();
|
---|
1289 | ctx.beginPath();
|
---|
1290 |
|
---|
1291 | ctx.strokeStyle = "#000";
|
---|
1292 |
|
---|
1293 | // --- axes ---
|
---|
1294 | ctx.moveTo(ml, mt);
|
---|
1295 | ctx.lineTo(ml, ch-mb);
|
---|
1296 | ctx.lineTo(cw-mr, ch-mb);
|
---|
1297 |
|
---|
1298 | for (var i=1; i<=nx; i++)
|
---|
1299 | {
|
---|
1300 | ctx.moveTo(ml+w*i/nx, ch-mb-dw);
|
---|
1301 | ctx.lineTo(ml+w*i/nx, ch-mb+dw);
|
---|
1302 | }
|
---|
1303 | for (var i=0; i<ny; i++)
|
---|
1304 | {
|
---|
1305 | ctx.moveTo(ml-dw, mt+h*i/ny);
|
---|
1306 | ctx.lineTo(ml+dw, mt+h*i/ny);
|
---|
1307 | }
|
---|
1308 | ctx.stroke();
|
---|
1309 | ctx.closePath();
|
---|
1310 |
|
---|
1311 | ctx.textBaseline = "bottom";
|
---|
1312 | ctx.strokeText(umin, ml-dw-2, ch-1);
|
---|
1313 |
|
---|
1314 | ctx.textBaseline = mt>fs/2 ? "middle" : "top";
|
---|
1315 | ctx.strokeText(umax, ml-dw-2, mt);
|
---|
1316 |
|
---|
1317 | ctx.textBaseline = "top";
|
---|
1318 | ctx.textAlign = "center";
|
---|
1319 | ctx.strokeText(stat, ml+w/2, 5);
|
---|
1320 | }
|
---|
1321 |
|
---|
1322 | function process_eventdata(result)
|
---|
1323 | {
|
---|
1324 | if (result.length==0)
|
---|
1325 | return;
|
---|
1326 |
|
---|
1327 | var z = $("body").getAttribute("data-visible");
|
---|
1328 | var canv = $("canvas"+z);
|
---|
1329 | if (!canv)
|
---|
1330 | return;
|
---|
1331 |
|
---|
1332 | var type = canv.getAttribute("data-type");
|
---|
1333 |
|
---|
1334 | var ctx = canv.getContext("2d");
|
---|
1335 | ctx.clearRect(0, 0, canv.width, canv.height);
|
---|
1336 |
|
---|
1337 | var data = result.split('\n');
|
---|
1338 | if (result.length<4)
|
---|
1339 | return;
|
---|
1340 |
|
---|
1341 | var len = 0;
|
---|
1342 | for (var i=0; i<6; i++)
|
---|
1343 | len += data[i].length+1;
|
---|
1344 |
|
---|
1345 | switch (type)
|
---|
1346 | {
|
---|
1347 | //case "camera": drawCam(result); break;
|
---|
1348 | case "hist":
|
---|
1349 | drawGraph(canv, data, result.substr(len));
|
---|
1350 | break;
|
---|
1351 | case "camera":
|
---|
1352 | drawFullCam(result.substr(len));
|
---|
1353 | drawCamLegend(canv, data);
|
---|
1354 | break;
|
---|
1355 | }
|
---|
1356 |
|
---|
1357 | var now = new Date();
|
---|
1358 | var tm = new Date();
|
---|
1359 | tm.setTime(data[0]);
|
---|
1360 | if (tm.getTime()+60000<now.getTime())
|
---|
1361 | {
|
---|
1362 | ctx.fillStyle = "rgba(255, 255, 255, 0.75)";
|
---|
1363 | ctx.fillRect(0, 0, canv.width, canv.height);
|
---|
1364 | }
|
---|
1365 |
|
---|
1366 | //$("image"+z).src = canv.toDataURL("image/png");
|
---|
1367 | }
|
---|
1368 |
|
---|
1369 | function save()
|
---|
1370 | {
|
---|
1371 | var z = $("body").getAttribute("data-visible");
|
---|
1372 |
|
---|
1373 | var canvas = $("canvas"+z);
|
---|
1374 | var img = canvas.toDataURL("image/png");
|
---|
1375 |
|
---|
1376 | img = img.replace("image/png", "image/octet-stream");
|
---|
1377 |
|
---|
1378 | document.location.href = img;
|
---|
1379 | }
|
---|
1380 |
|
---|
1381 | window['onload'] = onload;
|
---|