source: trunk/FACT++/www/smartfact/index.js@ 13762

Last change on this file since 13762 was 13747, checked in by tbretz, 13 years ago
Some littel fixed; added a time-tag to the graphics files; added some possibility to link to the control-section
File size: 39.8 KB
Line 
1var debug = false;
2
3var map = [ 393, 390, 391, 394, 1098, 395, 392, 389, 387, 388, 386,
41001, 1004, 1099, 1101, 1100, 1111, 1108, 286, 283, 377, 375, 376, 383,
5384, 999, 1002, 1005, 1007, 1102, 1104, 1103, 1114, 1113, 1110, 1107,
6285, 282, 280, 374, 372, 373, 380, 381, 382, 385, 1000, 1003, 1006,
7990, 992, 1105, 1089, 1106, 1126, 1125, 1115, 1112, 1109, 287, 284,
8281, 279, 277, 371, 369, 370, 413, 378, 379, 422, 425, 428, 431, 983,
9986, 991, 993, 995, 1090, 1092, 1091, 1129, 1128, 1127, 1138, 1135,
101150, 1147, 1144, 259, 256, 278, 276, 274, 368, 366, 367, 410, 411,
11412, 419, 420, 423, 426, 429, 981, 984, 987, 989, 994, 996, 998, 1093,
121095, 1094, 1132, 1131, 1130, 1141, 1140, 1137, 1134, 1149, 1146, 1143,
13258, 255, 253, 275, 273, 271, 365, 363, 364, 407, 408, 409, 416, 417,
14418, 421, 424, 427, 430, 982, 985, 988, 972, 974, 997, 1035, 1037,
151096, 1080, 1097, 1117, 1116, 1133, 1234, 1233, 1142, 1139, 1136, 1151,
161148, 1145, 260, 257, 254, 252, 268, 272, 270, 322, 362, 360, 361, 404,
17405, 406, 521, 414, 415, 512, 533, 536, 539, 920, 923, 926, 911, 914,
18973, 975, 977, 1036, 1038, 1040, 1081, 1083, 1082, 1120, 1119, 1118,
191237, 1236, 1235, 1228, 1225, 1258, 1255, 1252, 205, 202, 199, 196,
20193, 269, 267, 265, 323, 321, 319, 359, 357, 358, 401, 402, 403, 518,
21519, 520, 509, 510, 531, 534, 537, 918, 921, 924, 909, 912, 915, 917,
22976, 978, 980, 1039, 1041, 1043, 1084, 1086, 1085, 1123, 1122, 1121,
231240, 1239, 1238, 1231, 1230, 1227, 1224, 1257, 1254, 1251, 204, 201,
24198, 195, 192, 190, 266, 264, 262, 320, 318, 316, 356, 354, 355, 398,
25399, 400, 515, 516, 517, 506, 507, 508, 511, 532, 535, 538, 919, 922,
26925, 910, 913, 916, 900, 902, 979, 963, 965, 1042, 1026, 1028, 1087,
271071, 1088, 1180, 1179, 1124, 1216, 1215, 1241, 1288, 1287, 1232, 1229,
281226, 1259, 1256, 1253, 206, 203, 200, 197, 194, 191, 189, 187, 263,
29261, 250, 317, 315, 313, 353, 351, 352, 467, 396, 397, 503, 513, 514,
30575, 504, 505, 611, 524, 527, 530, 929, 932, 935, 848, 851, 854, 821,
31824, 901, 903, 905, 964, 966, 968, 1027, 1029, 1031, 1072, 1074, 1073,
321183, 1182, 1181, 1219, 1218, 1217, 1291, 1290, 1289, 1327, 1324, 1249,
331246, 1243, 214, 211, 208, 142, 139, 136, 106, 103, 188, 186, 184, 251,
34249, 247, 314, 312, 310, 350, 348, 349, 464, 465, 466, 500, 501, 502,
35572, 573, 574, 608, 609, 522, 525, 528, 927, 930, 933, 846, 849, 852,
36819, 822, 825, 827, 904, 906, 908, 967, 969, 971, 1030, 1032, 1034,
371075, 1077, 1076, 1186, 1185, 1184, 1222, 1221, 1220, 1294, 1293, 1292,
381330, 1329, 1326, 1323, 1248, 1245, 1242, 213, 210, 207, 141, 138, 135,
39105, 102, 100, 185, 183, 181, 248, 246, 244, 311, 309, 307, 347, 345,
40346, 461, 462, 463, 497, 498, 499, 569, 570, 571, 605, 606, 607, 610,
41523, 526, 529, 928, 931, 934, 847, 850, 853, 820, 823, 826, 810, 812,
42907, 891, 893, 970, 954, 956, 1033, 1017, 1019, 1078, 1062, 1079, 1171,
431170, 1187, 1207, 1206, 1223, 1279, 1278, 1295, 1315, 1314, 1331, 1328,
441325, 1250, 1247, 1244, 215, 212, 209, 143, 140, 137, 107, 104, 101,
4599, 97, 182, 180, 178, 245, 243, 241, 308, 306, 304, 344, 342, 343,
46458, 459, 460, 494, 495, 496, 566, 567, 568, 602, 603, 604, 647, 650,
47653, 656, 659, 662, 665, 857, 860, 863, 839, 842, 845, 830, 833, 811,
48813, 815, 892, 894, 896, 955, 957, 959, 1018, 1020, 1022, 1063, 1065,
491064, 1174, 1173, 1172, 1210, 1209, 1208, 1282, 1281, 1280, 1318, 1317,
501316, 1363, 1360, 1375, 1372, 1369, 1384, 1381, 1378, 133, 130, 127,
51124, 121, 118, 115, 112, 98, 96, 94, 179, 177, 175, 242, 240, 238, 305,
52303, 301, 332, 330, 331, 455, 456, 457, 491, 492, 493, 563, 564, 565,
53599, 600, 601, 644, 645, 648, 651, 654, 657, 660, 663, 855, 858, 861,
54837, 840, 843, 828, 831, 834, 836, 814, 816, 818, 895, 897, 899, 958,
55960, 962, 1021, 1023, 1025, 1066, 1068, 1067, 1177, 1176, 1175, 1213,
561212, 1211, 1285, 1284, 1283, 1321, 1320, 1319, 1366, 1365, 1362, 1359,
571374, 1371, 1368, 1383, 1380, 1377, 132, 129, 126, 123, 120, 117, 114,
58111, 109, 95, 93, 91, 176, 174, 172, 239, 237, 235, 302, 300, 298, 329,
59327, 328, 452, 453, 454, 488, 489, 490, 560, 561, 562, 596, 597, 598,
60641, 642, 643, 646, 649, 652, 655, 658, 661, 664, 856, 859, 862, 838,
61841, 844, 829, 832, 835, 756, 758, 817, 792, 794, 898, 882, 884, 961,
62945, 947, 1024, 1008, 1010, 1069, 1044, 1070, 1162, 1161, 1178, 1198,
631197, 1214, 1270, 1269, 1286, 1306, 1305, 1322, 1342, 1341, 1367, 1364,
641361, 1376, 1373, 1370, 1385, 1382, 1379, 134, 131, 128, 125, 122, 119,
65116, 113, 110, 108, 43, 92, 90, 79, 173, 171, 169, 236, 234, 232, 299,
66297, 295, 326, 324, 325, 449, 450, 451, 485, 486, 487, 557, 558, 559,
67593, 594, 595, 629, 639, 640, 638, 695, 698, 701, 668, 671, 674, 677,
68680, 683, 749, 752, 755, 740, 743, 746, 775, 777, 757, 759, 761, 793,
69795, 797, 883, 885, 887, 946, 948, 950, 1009, 1011, 1013, 1045, 1047,
701046, 1165, 1164, 1163, 1201, 1200, 1199, 1273, 1272, 1271, 1309, 1308,
711307, 1345, 1344, 1343, 1353, 1351, 1420, 1417, 1414, 1393, 1390, 1387,
721402, 1399, 1396, 34, 31, 28, 25, 22, 19, 62, 60, 44, 42, 40, 80, 78,
7376, 170, 168, 166, 233, 231, 229, 296, 294, 292, 341, 339, 340, 446,
74447, 448, 482, 483, 484, 554, 555, 556, 590, 591, 592, 626, 627, 628,
75636, 637, 693, 696, 699, 666, 669, 672, 675, 678, 681, 747, 750, 753,
76738, 741, 744, 774, 776, 778, 779, 760, 762, 764, 796, 798, 800, 886,
77888, 890, 949, 951, 953, 1012, 1014, 1016, 1054, 1057, 1048, 1168,
781167, 1166, 1204, 1203, 1202, 1276, 1275, 1274, 1312, 1311, 1310, 1348,
791347, 1346, 1355, 1354, 1352, 1350, 1419, 1416, 1413, 1392, 1389, 1386,
801401, 1398, 1395, 33, 30, 27, 24, 21, 18, 61, 59, 58, 41, 39, 37, 77,
8175, 73, 167, 165, 163, 230, 228, 226, 293, 291, 289, 338, 336, 337,
82443, 444, 445, 479, 480, 481, 551, 552, 553, 587, 588, 589, 623, 624,
83625, 634, 635, 684, 687, 694, 697, 700, 667, 670, 673, 676, 679, 682,
84748, 751, 754, 739, 742, 745, 787, 789, 791, 780, 765, 763, 769, 770,
85799, 801, 803, 889, 875, 864, 952, 936, 938, 1015, 1053, 1055, 1058,
861061, 1059, 1050, 1049, 1169, 1153, 1152, 1205, 1188, 1260, 1277, 1297,
871296, 1313, 1337, 1336, 1349, 1332, 1356, 1412, 1410, 1408, 1421, 1418,
881415, 1394, 1391, 1388, 1403, 1400, 1397, 35, 32, 29, 26, 23, 20, 65,
8963, 56, 55, 53, 38, 36, 48, 74, 72, 161, 164, 162, 152, 227, 225, 224,
90290, 288, 219, 335, 333, 334, 435, 441, 442, 440, 477, 478, 476, 549,
91550, 548, 585, 586, 615, 621, 622, 620, 631, 632, 633, 685, 688, 691,
92709, 706, 703, 718, 715, 712, 736, 733, 730, 727, 724, 721, 783, 785,
93788, 790, 781, 782, 766, 767, 771, 773, 802, 804, 873, 874, 865, 866,
94937, 939, 940, 942, 1056, 1060, 1052, 1051, 1157, 1156, 1155, 1154,
951190, 1189, 1262, 1261, 1299, 1298, 1339, 1338, 1334, 1333, 1358, 1357,
961411, 1409, 1406, 1404, 1424, 1427, 1430, 1433, 1436, 1439, 11, 14, 17,
972, 5, 8, 69, 67, 64, 57, 54, 52, 51, 50, 47, 89, 88, 84, 160, 159, 151,
98150, 148, 223, 222, 221, 218, 216, 433, 434, 437, 438, 439, 473, 474,
99475, 546, 547, 579, 583, 584, 614, 617, 618, 619, 630, 686, 689, 692,
100708, 705, 702, 717, 714, 711, 735, 732, 729, 726, 723, 720, 784, 786,
101768, 772, 805, 806, 808, 880, 877, 876, 867, 869, 871, 941, 943, 944,
1021160, 1159, 1158, 1194, 1192, 1191, 1263, 1265, 1264, 1302, 1301, 1300,
1031340, 1335, 1407, 1405, 1422, 1425, 1428, 1431, 1434, 1437, 9, 12, 15,
1040, 3, 6, 71, 68, 66, 49, 46, 45, 87, 83, 82, 158, 156, 149, 147, 146,
105144, 220, 217, 432, 436, 469, 470, 471, 472, 543, 545, 577, 578, 582,
106612, 613, 616, 710, 707, 704, 719, 716, 713, 737, 734, 731, 728, 725,
107722, 807, 809, 878, 879, 881, 868, 870, 872, 1196, 1195, 1193, 1268,
1081267, 1266, 1304, 1303, 1423, 1426, 1429, 1432, 1435, 1438, 10, 13, 16,
1091, 4, 7, 86, 85, 81, 157, 155, 154, 153, 145, 468, 540, 541, 542, 544,
110576, 580, 581, 70, 690 ];
111
112/*
113
114<a href="#" onMouseover="playsound(soundfile)">Example 1</a>
115<a href="#" onMouseover="playsound('different.wav')">Example 2</a>
116
117<div id="coolmenu" onMouseover="bindsound('A', soundfile, this)">
118
119<script type="text/javascript">
120
121//
122// JavaScript Sound effect- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
123// Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
124// This notice must stay intact for legal use
125//
126
127var soundfile="sidebar.wav" //path to sound file, or pass in filename directly into playsound()
128
129function playsound(soundfile){
130if (document.all && document.getElementById){
131document.getElementById("soundeffect").src="" //reset first in case of problems
132document.getElementById("soundeffect").src=soundfile
133}
134}
135
136function bindsound(tag, soundfile, masterElement){
137if (!window.event) return
138var source=event.srcElement
139while (source!=masterElement && source.tagName!="HTML"){
140if (source.tagName==tag.toUpperCase()){
141playsound(soundfile)
142break
143}
144source=source.parentElement
145}
146}
147
148</script>
149
150Function "bindsound()" accepts 3 parameters- 1) The tag name of the element to bind the sound to ("A" for <a>, "SPAN" for <span> etc), 2) the sound file to play, whether a variable or path to sound file, and finally, 3), the keyword "this", which should never be modified.
151
152// -----------------------
153<audio controls="controls" height="50px" width="100px">
154 <source src="song.mp3" type="audio/mpeg" />
155 <source src="song.ogg" type="audio/ogg" />
156<embed height="50px" width="100px" src="song.mp3" />
157</audio>
158// ------------------------
159
160*/
161function $(id) { return document.getElementById(id); }
162function trim(str) { return str.replace("/^\s\s*/", '').replace("/\s\s*$/", ''); }
163function valid(str) { if (str==undefined) return false; if (str.length==0) return false; return true;}
164function isSliding() { var z = $("body").getAttribute("data-visible"); return $("table"+z).offsetLeft!=0; }
165
166function cycleCol(el)
167{
168 var col = el.getAttribute("data-color");
169 col++;
170 col %= 31;
171 el.setAttribute("data-color", col);
172 if (col>16)
173 col = 31-col;
174 var hex = col.toString(16);
175 el.style.color = "#"+hex+"0"+hex+"0"+hex+"f";
176}
177
178/*
179function newWindow(newContent)
180{
181 if (document.referrer != "http://www.referringPageName.html")
182 return;
183
184 winContent = window.open(newContent,
185 'nextWin',
186 'right=0,top=20,width=350,height=350,toolbar=no,scrollbars=no,resizable=no');
187 }*/
188
189function onload()
190{
191 try { new XMLHttpRequest(); }
192 catch(e)
193 {
194 alert("Your browser doesn't support dynamic reload.");
195 return;
196 }
197
198 var name = location.hash.length==0 ? "fact" : location.hash.substr(1);
199
200 var args = location.search.substr(1).split('&');
201
202 for (var i=0; i<args.length; i++)
203 {
204 var entry = args[i].split('=');
205 if (entry.length!=2)
206 continue;
207
208 switch (entry[0])
209 {
210 case "w": $("body").setAttribute("data-width", entry[1]); break;
211 case "h": $("body").setAttribute("data-height", entry[1]); break;
212 }
213 }
214
215
216 /*
217 alert("0 -- "+navigator.appCodeName+"\n"+
218 "1 -- "+navigator.appName+"\n"+
219 "2 -- "+navigator.appVersion+"\n"+
220 "3 -- "+navigator.platform+"\n"+
221 "4 -- "+navigator.userAgent);
222 */
223 loadPage(name, 0, 0);
224}
225
226function onresize()
227{
228 var z = $("body").getAttribute("data-visible");
229 doresize(z);
230}
231
232function loadPage(name, z, dz)
233{
234 var xmlPage = new XMLHttpRequest();
235 xmlPage.open('POST', "struct/"+name+'.table', true);
236 xmlPage.onload = function ()
237 {
238 if (xmlPage.status!=200)
239 {
240 alert("ERROR[0] - HTTP request '"+name+".table': "+xmlPage.statusText+" ["+xmlPage.status+"]");
241 //setTimeout("loadPage('+name+')", 5000);
242 /****** invalidate ******/
243 return;
244 }
245
246 buildPage(name, xmlPage.responseText, z, dz);
247 changePage(z, z+dz);
248
249 //changePage(name, xmlHttp.resposeText);
250 //slideOut(name, xmlHttp.responseText);
251 //displayPage(name, xmlHttp.responseText);
252 //onresize(true);
253 };
254
255 xmlPage.send(null);
256
257 location.hash = name;
258}
259
260function sendCommand(command, debug)
261{
262 var uri = "index.php?";
263 if (debug==true)
264 uri += "debug&";
265 uri += command;
266
267 var xmlCmd = new XMLHttpRequest();
268 xmlCmd.open('POST', uri, true);
269 xmlCmd.onload = function()
270 {
271 if (xmlCmd.status!=200)
272 {
273 alert("ERROR[1] - HTTP request: "+xmlCmd.statusText+" ["+xmlCmd.status+"]");
274 return;
275 }
276
277 if (xmlCmd.responseText.length==0)
278 {
279 alert("No proper acknowledgment of command execution received.");
280 return;
281 }
282
283 var txt = xmlCmd.responseText.split('\n');
284 switch (txt[0])
285 {
286 case "1": alert("dimctrl unreachable."); break;
287 case "2": /*success*/ break;
288 default: alert("Return code '"+txt[0]+"' unknown."); break;
289 }
290 if (txt.length>1)
291 alert(xmlCmd.responseText);
292 };
293 xmlCmd.send(null);
294}
295
296
297function submit(script)
298{
299 var inputs = document.getElementsByTagName("input");
300
301 var args = "start="+script;
302 for (var i=0; i<inputs.length; i++)
303 args += "&"+inputs[i].name+"="+inputs[i].value;
304
305 alert(args);
306
307 sendCommand(args);
308
309}
310
311function buildPage(name, text, oldz, dz)
312{
313 var fname = dz==0 ? "fact" : $("table"+oldz).getAttribute("data-file");
314
315 var z = oldz + dz;
316
317 var lines = text.split('\n');
318
319 if (lines.length==0)
320 {
321 alert("buildPage - received data empty.");
322 return;
323 }
324
325 if (lines[0].length==0)
326 {
327 alert("buildPage - title missing");
328 return;
329 }
330
331 var title = lines[0].split('/');
332
333 var table = $("table"+z);
334 if (table != undefined)
335 $("body").removeChild(table);
336
337 table = document.createElement("table");
338 table.setAttribute("class", "tborder");
339 table.id = "table"+z;
340 table.border = 0;
341 table.cellSpacing = 0;
342 table.cellPadding = "0px";
343 /*table.width = "100%";*/
344 table.setAttribute("style", "overflow:hidden;position:fixed;top:0px;left:"+window.innerWidth+"px;");
345
346 // -----------------------------------------------------
347
348 var th = document.createElement("thead");
349 th.colSpan = 3;
350 th.width = "100%";
351 table.appendChild(th);
352
353 var htr = document.createElement("tr");
354 th.appendChild(htr);
355
356 var htd = document.createElement("td");
357 htd.setAttribute("class", "thead");
358 htd.colSpan = 3;
359 htd.width = "100%";
360 htr.appendChild(htd);
361
362 // -------------
363
364 var htab = document.createElement("table");
365 htab.width = "100%";
366 htd.appendChild(htab);
367
368 var hhtr = document.createElement("tr");
369 htab.appendChild(hhtr);
370
371 var htd0 = document.createElement("td");
372 var htd1 = document.createElement("td");
373 var htd2 = document.createElement("td");
374 var htd3 = document.createElement("td");
375 var htd4 = document.createElement("td");
376 htd0.setAttribute("class", "tcell1");
377 htd1.setAttribute("class", "tcell2");
378 htd2.setAttribute("class", "tcell1");
379 htd2.setAttribute("width", "1px");
380 htd3.setAttribute("class", "tcell1");
381 htd3.setAttribute("width", "1px");
382 htd4.setAttribute("width", "1px");
383 hhtr.appendChild(htd4);
384 hhtr.appendChild(htd3);
385 hhtr.appendChild(htd0);
386 hhtr.appendChild(htd1);
387 hhtr.appendChild(htd2);
388
389 var div1 = document.createElement("div");
390 var div2 = document.createElement("div");
391 var div3 = document.createElement("div");
392 var div4 = document.createElement("div");
393 div4.id = "warn"+z;
394 div2.setAttribute("class", "icon_white");
395 div3.setAttribute("class", "icon_white");
396 div4.setAttribute("class", "icon_color");
397 div2.setAttribute("style", "background-position:-396px 50%;");
398 div3.setAttribute("style", "background-position:-575px 50%;");
399 div4.setAttribute("style", "display:none;background-position:-12px -12px;");
400 div3.onclick = function() { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('fact', z, -z); }
401 div2.onclick = function() { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage(fname, z, -dz); }
402
403 var sp0 = document.createElement("span");
404 var sp1 = document.createElement("span");
405 var sp2 = document.createElement("span");
406 sp0.id = "ldot" +z;
407 sp1.id = "title"+z;
408 sp2.id = "rdot" +z;
409 sp1.setAttribute("style", "font-size:large;");
410 sp0.setAttribute("data-color", "3");
411 sp2.setAttribute("data-color", "3");
412 sp0.appendChild(document.createTextNode(" \u2022 "));
413 sp1.appendChild(document.createTextNode(title[0]));
414 sp2.appendChild(document.createTextNode(" \u2022 "));
415 if (title[1]!=undefined)
416 {
417 // sp1.onclick = function() { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('fact', z, -1); }
418 }
419 else
420 {
421 if (name!='control')
422 sp1.onclick = function() { this.style.backgroundColor='rgba(0,0,0,0.15)'; loadPage('control', z, +1); }
423 }
424
425 div1.setAttribute("style", "font-size:small;");
426 div1.id = "reporttime"+z;
427 div1.appendChild(document.createTextNode("---"));
428
429 htd0.appendChild(sp0);
430 htd0.appendChild(sp1);
431 htd0.appendChild(sp2);
432
433 htd1.appendChild(div1);
434 if (dz!=0/* && z+dz!=0*/)
435 htd2.appendChild(div2); // back
436 if (lines[0]!="FACT")
437 htd3.appendChild(div3); // home
438 htd4.appendChild(div4); // Warning
439
440 // -----------------------------------------------------
441
442 var tbody = document.createElement("tbody");
443 table.appendChild(tbody);
444
445 // -----------------------------------------------------
446
447 var tf = document.createElement("tfoot");
448 table.appendChild(tf);
449
450 var ftr = document.createElement("tr");
451 tf.appendChild(ftr);
452
453 var ftd = document.createElement("td");
454 ftd.setAttribute("class", "tfoot");
455 ftd.width = "100%";
456 ftd.colSpan = 3;
457 ftr.appendChild(ftd);
458
459 var ftab = document.createElement("table");
460 ftab.width = "100%";
461 ftd.appendChild(ftab);
462
463 var ftd0 = document.createElement("td");
464 var ftd1 = document.createElement("td");
465
466 ftd0.setAttribute("class", "tcell1");
467 ftd1.setAttribute("class", "tcell2");
468
469 ftab.appendChild(ftd0);
470 ftab.appendChild(ftd1);
471
472 var fdiv0 = document.createElement("span");
473 var fdiv1 = document.createElement("span");
474
475 fdiv0.setAttribute("style", "font-size:large;");
476 fdiv1.setAttribute("style", "font-size:small;");
477 fdiv1.id = "localtime"+z;
478
479 fdiv0.appendChild(document.createTextNode("logbook"));
480 fdiv1.appendChild(document.createTextNode("loading..."));
481
482 ftd0.appendChild(fdiv0);
483 ftd1.appendChild(fdiv1);
484
485 $("body").appendChild(table);
486
487 var counter = 1;
488 for (var i=1; i<lines.length; i++)
489 {
490 lines[i] = trim(lines[i]);
491
492 if (lines[i].length==0 || lines[i][0] == '#')
493 continue;
494
495 var cols = lines[i].split(':');
496 if (cols.length != 3 && cols.length !=4)
497 {
498 alert("Wrong number of columns in line #"+i+" in '"+name+"': '"+lines[i]+"' N(cols)="+cols.length);
499 continue;
500 }
501
502 var check = cols[1].split("=");
503
504 if (check.length>1 && (check[0]=="camera" || check[0]=="hist"))
505 {
506 var data = cols[1].substring(check[0].length+1).split("/");
507
508 var tr = document.createElement("tr");
509 tr.setAttribute("class", "row");
510 //tr.setAttribute("style", "margin:0;padding:0;");
511
512 var td = document.createElement("td");
513 td.setAttribute("class", "container");
514 td.id = "container";
515 td.colSpan = 3;
516 tr.appendChild(td);
517
518 var canv = document.createElement("canvas");
519 canv.id = "canvas"+z;
520 canv.width = "1";
521 canv.height = "1";
522 //canv.onclick = function() { save(); }
523 canv.setAttribute("data-type", check[0]);
524 canv.setAttribute("data-file", data[0]);
525 canv.setAttribute("data-data", cols[1].substring(check[0].length+data[0].length+2));
526// canv.setAttribute("style", "display:none;");
527 td.appendChild(canv);
528
529 var img = document.createElement("img");
530 img.src = "img/dummy.png";//needed in firefox
531 img.id = "image"+z;
532 img.setAttribute("style", "width:1px;height:1px;display:none;");
533 td.appendChild(img);
534
535 tbody.appendChild(tr);
536 continue;
537 }
538
539 var tr = document.createElement("tr");
540 tr.setAttribute("class", "row");
541 if (valid(cols[0]))
542 tr.setAttribute("onclick", "this.style.background='#ccb'; loadPage('"+cols[0]+"', "+z+", -1);");
543 if (valid(cols[3]))
544 tr.setAttribute("onclick", "this.style.background='#ccb'; loadPage('"+cols[3]+"', "+z+", +1);");
545
546 var td0 = document.createElement("td");
547 td0.setAttribute("class", "tcol0");
548 tr.appendChild(td0);
549
550 if (check.length>0 && check[0]=="image")
551 {
552 var img = document.createElement("img");
553 img.style.width="100%";
554 img.src = check[1];
555 td0.style.paddingLeft=0;
556 td0.style.border=0;
557 td0.colSpan=3;
558 td0.appendChild(img);
559
560 tbody.appendChild(tr);
561 continue;
562 }
563
564 if (valid(cols[0]))
565 {
566 var sp = document.createElement("div");
567 sp.setAttribute("class", "icon_black");
568 sp.setAttribute("style", "background-position: -144px 50%;");
569 td0.appendChild(sp);
570 }
571
572 var td1 = document.createElement("td");
573 td1.setAttribute("class", "tcol1");
574 td1.width = "100%";
575 tr.appendChild(td1);
576
577 var td2 = document.createElement("td");
578 td2.setAttribute("class", "tcol2");
579 td2.width = "18px";
580 if (valid(cols[3]))
581 {
582 var sp = document.createElement("div");
583 sp.setAttribute("class", "icon_black");
584 sp.setAttribute("style", "background-position: -108px 50%;");
585 td2.appendChild(sp);
586 }
587 tr.appendChild(td2);
588
589 var tab = document.createElement("table");
590 tab.width = "100%";
591 td1.appendChild(tab);
592
593 var innertr = document.createElement("tr");
594 tab.appendChild(innertr);
595
596 var cell1 = document.createElement("td");
597 cell1.setAttribute("class", "tcell1");
598
599 var cell2 = document.createElement("td");
600 cell2.setAttribute("class", "tcell2");
601
602 if (check.length==0 || check[0]!="input")
603 {
604 var div = document.createElement("div");
605 div.innerHTML = cols[1];
606 cell1.appendChild(div);
607 //cell1.appendChild(document.createTextNode(cols[1]));
608
609 if (cols.length>2 && cols[2].length>0)
610 {
611 cell2.id = "data"+z+"-"+counter;
612 cell2.setAttribute("data-form", cols[2]);
613 cell2.appendChild(document.createTextNode("---"));
614 counter++;
615 }
616 else
617 cell1.setAttribute("class", "description");
618 }
619 else
620 {
621 var opt = check[1].split('/');
622
623 if (opt.length<2)
624 alert("Argument name missing for'"+check[1]+"'");
625
626 var div = document.createElement("div");
627 div.innerHTML = opt[0];
628 cell1.appendChild(div);
629 //cell1.appendChild(document.createTextNode(opt[0]));
630
631 var input = document.createElement("input");
632 input.name = opt[1];
633 input.type = "text";
634 input.maxlength = 80;
635 if (opt.length>2)
636 input.value=opt[2];
637
638 cell2.appendChild(input);
639 }
640
641 innertr.appendChild(cell1);
642 innertr.appendChild(cell2);
643
644 tbody.appendChild(tr);
645 }
646/*
647 if (true)
648 {
649 tr = document.createElement("tr");
650 tr.setAttribute("class", "row");
651
652 td = document.createElement("td");
653 td.colSpan = "3";
654 tr.appendChild(td);
655
656 var sp = document.createElement("div");
657 sp.setAttribute("class", "icon_color");
658 sp.setAttribute("style", "background-position: -144px -14px;");
659 td.appendChild(sp);
660
661 sp = document.createElement("div");
662 sp.setAttribute("class", "icon_color");
663 sp.setAttribute("style", "background-position: -56px -14px;");
664 td.appendChild(sp);
665
666 tr.appendChild(td);
667
668 tbody.appendChild(tr);
669 }
670*/
671 // ---------------------------------------
672 if (debug == true)
673 {
674 tr = document.createElement("tr");
675 tr.setAttribute("class", "row");
676
677 td = document.createElement("td");
678 td.id = "debug"+z;
679 td.colSpan = 3;
680 tr.appendChild(td);
681
682 tbody.appendChild(tr);
683 }
684
685 // ---------------------------------------
686
687 table.setAttribute("data-file", name);
688 doresize(z);
689}
690
691function resizeimpl(z, cnt)
692{
693 // 393 / 482 488/482 / 200 200+482-488
694 var img = $("image"+z);
695 var canv = $("canvas"+z);
696 if (img == undefined || canv == undefined)
697 return;
698
699 var h = $("table"+z).offsetHeight;
700 if (h == 0)
701 return;
702
703 var fixedw = $("body").getAttribute("data-width");
704 var fixedh = $("body").getAttribute("data-height");
705
706 var W = fixedw>0 ? fixedw : window.innerWidth;
707 var H = fixedh>0 ? fixedh : window.innerHeight;
708
709 $("table"+z).style.width = W+"px";
710
711/*
712 if (W==0 || H==0)
713 {
714 var w = $("table"+z).offsetWidth;
715 img.style.width = w+"px";
716 img.style.height= w+"px";
717
718 canv.width = w;
719 canv.height = w;
720 return;
721 }
722*/
723
724 var ih = H - h + parseInt(img.style.height, 10);
725
726 img.style.width = W +"px";
727 img.style.height= ih+"px";
728
729 canv.width = W;
730 canv.height = ih;
731
732 // ------ debug -----
733 if (debug == true)
734 {
735 $('debug'+z).innerHTML = "";
736 $('debug'+z).innerHTML += "|W="+W +"/"+H;
737 $('debug'+z).innerHTML += "|H="+h+"/"+$("table"+z).offsetHeight+"/"+img.offsetHeight;
738 $('debug'+z).innerHTML += "|I="+img.style.height+"+"+H+"-"+h;
739 }
740
741 if ($("table"+z).offsetHeight == H || cnt==2)
742 return;
743
744 resizeimpl(z, ++cnt);
745}
746
747function doresize(z)
748{
749 resizeimpl(z, 0);
750}
751
752var intervalSlide = null;
753
754function changePage(oldz, newz)
755{
756 // No page displayed yet
757 if (oldz==newz)
758 {
759 $("table"+newz).style.left="0px";
760 $("body").setAttribute("data-visible", newz);
761
762 doresize(0);
763
764 //setInterval(refresh_text, 1000);
765 //setInterval(refresh_graphics, 5000);
766
767 refresh_text();
768 refresh_graphics();
769 return;
770 }
771
772 var W = window.innerWidth;
773 if (W==0)
774 {
775 $("table"+newz).style.left="0px";
776 $("body").setAttribute("data-visible", newz);
777 $("body").removeChild($("table"+oldz));
778 return;
779 }
780
781 if (newz>oldz)
782 $("table"+newz).style.left = W+"px";
783 else
784 $("table"+newz).style.left = (-W-1)+"px";
785
786 //window.clearTimeout(timeoutText);
787 //window.clearTimeout(timeoutGraphics);
788
789 $("body").setAttribute("data-visible", newz);
790 intervalSlide = setInterval(function(){doShift(oldz,newz)}, 75);
791}
792
793function doShift(oldz, newz)
794{
795 var t0 = $("table"+oldz);
796 var t1 = $("table"+newz);
797
798 if (t0.style.display=="none")
799 {
800 clearInterval(intervalSlide);
801 $("body").removeChild(t0);
802 return;
803 }
804
805 var x0 = t0.offsetLeft;
806 var x1 = t1.offsetLeft;
807
808 var W = window.innerWidth;
809
810 if (newz<oldz)
811 {
812 x0 += W/5;
813 x1 += W/5;
814 }
815
816 if (newz>oldz)
817 {
818 x0 -= W/5;
819 x1 -= W/5;
820 }
821
822 if ((newz<oldz && x1>=0) || (newz>oldz && x1<=0))
823 {
824 t0.style.display="none";
825 x1 = 0;
826 }
827
828 t0.style.left = x0+"px";
829 t1.style.left = x1+"px";
830}
831
832var timeoutText = null;
833var timeoutGraphics = null;
834
835function refresh_text()
836{
837 var z=$("body").getAttribute("data-visible");
838 var table = $("table"+z);
839
840 // Is sliding or no file defined?
841 var fname = table.getAttribute("data-file");
842 if (isSliding() || !valid(fname))
843 {
844 // invalidate?
845 timeoutText = setTimeout(refresh_text, 1000);
846 return;
847 }
848
849 var xmlText = new XMLHttpRequest();
850 xmlText.open('POST', "data/"+fname+'.txt', true);
851 xmlText.onload = function ()
852 {
853 if (xmlText.status!=200)
854 {
855 alert("ERROR[1] - HTTP request '"+fname+".txt': "+xmlText.statusText+" ["+xmlText.status+"]");
856 timeoutText = setTimeout(refresh_text, 10000);
857 return;
858 }
859
860 if (!isSliding())
861 {
862 cycleCol($("ldot"+z));
863 update_text(fname, xmlText.responseText);
864 }
865 timeoutText = setTimeout(refresh_text, 3000);
866 };
867 xmlText.send(null);
868}
869
870function strike(e, status)
871{
872 if (!e)
873 return;
874
875 if (!status)
876 e.style.textDecoration="line-through";
877 else
878 e.style.textDecoration="";
879}
880
881/*
882function gray(id, str)
883{
884 var e = $(id);
885 if (!e)
886 return;
887
888 if (valid(str))
889 {
890 e.style.color="#000";
891 e.style.textDecoration="";
892 }
893 else
894 {
895 e.style.color="#daa";
896 e.style.textDecoration="line-through";
897 }
898}
899*/
900var date0 = null;
901
902function update_text(fname, result)
903{
904 var z=$("body").getAttribute("data-visible");
905 var table = $("table"+z);
906
907 if (table.getAttribute("data-file") != fname)
908 return;
909
910 var tokens = result.split('\n');
911
912 // ----------------------------------------------------
913
914 var time = $("reporttime"+z);
915 var ltime = $("localtime"+z);
916
917 var date1 = new Date();
918
919 var header = tokens[0].split('\t');
920
921 // File corrupted /should we remove the date?)
922 if (header.length!=2 && header.length!=1 && header[0].length!=13)
923 {
924 if (date0 != null)
925 strike(time, date0.getTime()+60000>date1.getTime());
926 return;
927 }
928
929 var date2 = new Date();
930 date2.setTime(header[0]);
931
932 $("warn"+z).style.display = header.length!=2 || header[1]=='1' ? "none" : "";
933
934 strike(time, date2.getTime()+60000>date1.getTime());
935
936 date0 = date2;
937
938 var utc = date0.toUTCString();
939
940 time.innerHTML =
941 "&#8226;&nbsp;"+utc.substr(utc.length-12, 8)+"&nbsp;UTC&nbsp;&#8226;"
942 ltime.innerHTML =
943 "&#8226;&nbsp;"+date1.toLocaleString()+"&nbsp;&#8226;";
944
945 // ----------------------------------------------------
946
947 var p = table.tBodies.length==3 ? 1 : 0;
948 var tbody = table.tBodies[p];
949
950 for (var line=1; line<tokens.length; line++)
951 {
952 if (tokens[line].length==0)
953 continue;
954
955 var e = document.getElementById("data"+z+"-"+line);
956 if (e == undefined)
957 continue;
958
959 var form = e.getAttribute("data-form");
960 if (form==undefined)
961 continue;
962
963 var cols = tokens[line].split('\t');
964 for (var col=1; col<cols.length; col++)
965 form = form.replace("\$"+(col-1), cols[col].length==0 ? "&mdash;" : cols[col]);
966
967 if (cols.length<=1)
968 form = "&mdash;";
969
970 var newe = document.createElement("div");
971 newe.innerHTML = form;
972 e.replaceChild(newe, e.lastChild);
973
974 e.parentNode.parentNode.parentNode.parentNode.style.background=cols[0];
975 }
976}
977
978// http://billmill.org/static/canvastutorial/index.html
979// http://www.netmagazine.com/tutorials/learning-basics-html5-canvas
980// http://www.alistapart.com/articles/responsive-web-design/
981
982function refresh_graphics()
983{
984 var z = $("body").getAttribute("data-visible");
985
986 var canvas = $("canvas"+z);
987
988 // Is sliding or no data file defined?
989 var fname = canvas==null ? "" : canvas.getAttribute("data-file");
990 if (isSliding() || !valid(fname))
991 {
992 // invalidate?
993 timeoutGraphics = setTimeout(refresh_graphics, 1000);
994 return;
995 }
996
997 var xmlGfx = new XMLHttpRequest();
998 xmlGfx.open('POST', "data/"+fname, true);
999 xmlGfx.onload = function()
1000 {
1001 if (xmlGfx.status!=200)
1002 {
1003 alert("ERROR[2] - Request '"+fname+"': "+xmlGfx.statusText+" ["+xmlGfx.status+"]");
1004 timeoutGraphics = setTimeout(refresh_graphics, 10000);
1005 //****** invalidate ******
1006 return;
1007 }
1008
1009 if (!isSliding())
1010 {
1011 cycleCol($("rdot"+z));
1012 process_eventdata(xmlGfx.responseText);
1013 }
1014 timeoutGraphics = setTimeout(refresh_graphics, 5000)
1015 };
1016 xmlGfx.send(null);
1017}
1018
1019
1020function hueToRGB(hue)
1021{
1022 hue /= 3;
1023 hue %= 6;
1024
1025 if (hue<1) return parseInt(255*hue, 10);
1026 if (hue<3) return parseInt(255, 10);
1027 if (hue<4) return parseInt(255*(4-hue), 10);
1028
1029/*
1030 if (hue<1*5/4) return parseInt(255*hue*4/5);
1031 if (hue<2*5/4) return parseInt(255);
1032 if (hue<3*5/4) return parseInt(255*(3*5/4-hue)*4/5);
1033*/
1034/*
1035 if (hue<1.5) return parseInt(255*hue/1.5);
1036 if (hue<3.0) return parseInt(255);
1037 if (hue<4.5) return parseInt(255*(4.5-hue)/1.5);
1038*/
1039 return 0.
1040}
1041
1042function hueToHex(flt)
1043{
1044 var s = hueToRGB(flt).toString(16);
1045 return s.length==2 ? s : "0"+s;
1046}
1047
1048function HLStoRGB(hue)
1049{
1050 hue *= 14;
1051
1052 var sr = hueToHex(20-hue);
1053 var sg = hueToHex(14-hue);
1054 var sb = hueToHex(26-hue);
1055
1056 return sr+sg+sb;
1057}
1058
1059
1060function color(col)
1061{
1062 if (col==65533)
1063 col = 0;
1064
1065 var hue = col/128;
1066 return HLStoRGB(hue);
1067}
1068
1069function toHex(str, idx)
1070{
1071 var ch = str[idx].toString(16);
1072 return ch.length==2 ? ch : "0"+ch;
1073}
1074
1075function drawHex(ctx, x, y, col)
1076{
1077 ctx.fillStyle = "#"+color(col);
1078
1079 ctx.save();
1080
1081 ctx.translate(x, y);
1082 ctx.scale(1/2, 1/3);
1083
1084 ctx.beginPath();
1085 ctx.moveTo( 1, 1);
1086 ctx.lineTo( 0, 2);
1087 ctx.lineTo(-1, 1);
1088 ctx.lineTo(-1, -1);
1089 ctx.lineTo( 0, -2);
1090 ctx.lineTo( 1, -1);
1091 ctx.fill();
1092
1093 ctx.restore();
1094}
1095
1096function drawDisc(ctx, x, y, r, col)
1097{
1098 ctx.fillStyle = "#"+color(col);
1099
1100 ctx.save();
1101
1102 ctx.translate(x, y);
1103
1104 ctx.beginPath();
1105 ctx.arc(0, 0, r, 0, Math.PI*2, true);
1106 ctx.fill();
1107
1108 ctx.restore();
1109}
1110
1111function beginDrawCam(scale)
1112{
1113 var z = $("body").getAttribute("data-visible");
1114 var canv = $("canvas"+z);
1115
1116 var w = Math.min(canv.width/scale, canv.height/scale);
1117
1118 var ctx = canv.getContext("2d");
1119
1120 ctx.save();
1121 ctx.translate(canv.width/2, canv.height/2);
1122 ctx.scale(w*2, w*2);
1123
1124 return ctx;
1125}
1126
1127/**
1128 * @constructor
1129 */
1130function position(s, ring, i)
1131{
1132 switch (s)
1133 {
1134 case 1: this.x = ring - i*0.5; this.y = + i; break;
1135 case 2: this.x = ring*0.5 - i; this.y = ring ; break;
1136 case 3: this.x = -ring*0.5 - i*0.5; this.y = ring - i; break;
1137 case 4: this.x = -ring + i*0.5; this.y = - i; break;
1138 case 5: this.x = -ring*0.5 + i; this.y = -ring ; break;
1139 case 0: this.x = ring*0.5 + i*0.5; this.y = -ring + i; break;
1140 }
1141 this.d = function() { return this.x*this.x + this.y*this.y*3/4; }
1142}
1143
1144function drawFullCam(data)
1145{
1146 if (data.length!=40 && data.length!=160 && data.length!=320 && data.length!=1440)
1147 {
1148 alert("Camera - Received data has invalid size ("+data.length+"b)");
1149 return;
1150 }
1151
1152 var div = map.length/data.length;
1153 var off = data.length==320 ? 0.2 : 0;
1154
1155 var ctx = beginDrawCam(83);
1156 // ctx.rotate(Math.PI/3);
1157
1158 ctx.scale(1, Math.sqrt(3)/2);
1159 ctx.translate(-0.5, 0);
1160
1161 drawHex(ctx, 0, 0, data.charCodeAt(parseInt(map[0]/div+off, 10)));
1162
1163 var cnt = 1;
1164 for (var ring=1; ring<24; ring++)
1165 {
1166 for (var s=0; s<6; s++)
1167 {
1168 for (var i=1; i<=ring; i++)
1169 {
1170 var pos = new position(s, ring, i);
1171 if (pos.d() - pos.x > 395.75)
1172 continue;
1173
1174 var p = parseInt(map[cnt]/div+off, 10);
1175
1176 drawHex(ctx, pos.x, pos.y, data.charCodeAt(p));
1177 cnt++;
1178 }
1179 }
1180 }
1181
1182 drawHex(ctx, 7, -22, data.charCodeAt(parseInt(map[1438]/div+off, 10)));
1183 drawHex(ctx, 7, 22, data.charCodeAt(parseInt(map[1439]/div+off, 10)));
1184
1185 ctx.restore();
1186}
1187
1188function drawCam(data)
1189{
1190 var ctx = beginDrawCam(27);
1191 ctx.rotate(Math.PI/6);
1192 ctx.scale(1, Math.sqrt(3)/2);
1193
1194 drawHex(ctx, 0, 0, data.charCodeAt(0));
1195
1196 var cnt = 1;
1197 for (var ring=1; ring<=7; ring++)
1198 {
1199 for (var s=0; s<6; s++)
1200 {
1201 for (var i=1; i<=ring; i++)
1202 {
1203 var pos = new position(s, ring, i);
1204 if (pos.d() > 44)
1205 continue;
1206
1207 if (ring==7)
1208 {
1209 if (i==6 && (s==0 || s==3))
1210 continue;
1211 if (i==1 && (s==1 || s==4))
1212 continue;
1213 }
1214
1215 drawHex(ctx, pos.x, pos.y, data.charCodeAt(cnt++));
1216 }
1217 }
1218 }
1219
1220 ctx.restore();
1221}
1222
1223function drawCamLegend(canv, min, max)
1224{
1225 var unit = canv.getAttribute("data-data");//.split("/");
1226 if (unit.length>0)
1227 unit = " "+unit;
1228
1229 var v0 = parseFloat(min);
1230 var v1 = parseFloat(max);
1231
1232 var diff = v1-v0;
1233
1234 var cw = canv.width;
1235 var ch = canv.height;
1236
1237 var ctx = canv.getContext("2d");
1238
1239 ctx.font = "8pt Arial";
1240 ctx.textAlign = "right";
1241 ctx.textBaseline = "top";
1242
1243 for (var i=0; i<11; i++)
1244 {
1245 ctx.strokeStyle = "#"+color(16*i);
1246 ctx.strokeText((v0+diff*i/10).toPrecision(3)+unit, cw-5, 120-i*12);
1247 }
1248}
1249
1250function drawGraph(canv, min, max, data)
1251{
1252 var unit = canv.getAttribute("data-data");//.split("/");
1253 if (unit.length>0)
1254 unit = " "+unit;
1255
1256 var cw = canv.width;
1257 var ch = canv.height;
1258
1259 var ctx = canv.getContext("2d");
1260
1261 var dw = 3; // tick width
1262
1263 var fs = 8; // font size
1264
1265 ctx.font = fs+"pt Arial";
1266 ctx.textAlign = "right";
1267
1268 var dim0 = ctx.measureText(min+unit);
1269 var dim1 = ctx.measureText(max+unit);
1270
1271 var tw = Math.max(dim0.width, dim1.width)+dw+2;
1272
1273 var ml = 5+tw; // margin left
1274 var mr = 10; // margin right
1275
1276 var mt = fs/2+5; // margin top
1277 var mb = fs/2+4; // margin bottom
1278
1279 var nx = 20;
1280 var ny = 10;
1281
1282 var w = cw-ml-mr;
1283 var h = ch-mt-mb;
1284
1285 ctx.strokeStyle = "#666";
1286
1287 // --- data ---
1288 ctx.beginPath();
1289 ctx.moveTo(ml, ch-mb-data.charCodeAt(0)/128*h);
1290 for (var i=1; i<data.length; i++)
1291 ctx.lineTo(ml+w/(data.length-1)*i, ch-mb-data.charCodeAt(i)/128*h);
1292
1293 // --- finalize data ---
1294 ctx.lineTo(cw-mr, ch-mb);
1295 ctx.lineTo(ml, ch-mb);
1296 ctx.fillStyle = "#"+color(100);
1297 ctx.stroke();
1298 ctx.fill();
1299
1300 ctx.beginPath();
1301
1302 // --- grid ---
1303
1304 ctx.strokeStyle = "#eee";
1305
1306 for (var i=1; i<=nx; i++)
1307 {
1308 ctx.moveTo(ml+w/nx*i, ch-mb);
1309 ctx.lineTo(ml+w/nx*i, mt);
1310 }
1311 for (var i=0; i<ny; i++)
1312 {
1313 ctx.moveTo(ml, mb+h/ny*i);
1314 ctx.lineTo(ml+w, mb+h/ny*i);
1315 }
1316 ctx.stroke();
1317 ctx.closePath();
1318 ctx.beginPath();
1319
1320 ctx.strokeStyle = "#000";
1321
1322 // --- axes ---
1323 ctx.moveTo(ml, mt);
1324 ctx.lineTo(ml, ch-mb);
1325 ctx.lineTo(cw-mr, ch-mb);
1326
1327 for (var i=1; i<=nx; i++)
1328 {
1329 ctx.moveTo(ml+w/nx*i, ch-mb-dw);
1330 ctx.lineTo(ml+w/nx*i, ch-mb+dw);
1331 }
1332 for (var i=0; i<ny; i++)
1333 {
1334 ctx.moveTo(ml-dw, mb+h/ny*i);
1335 ctx.lineTo(ml+dw, mb+h/ny*i);
1336 }
1337 ctx.stroke();
1338 ctx.closePath();
1339
1340 ctx.textBaseline = "bottom";
1341 ctx.strokeText(min+unit, ml-dw-2, ch-1);
1342
1343 ctx.textBaseline = "top";
1344 ctx.strokeText(max+unit, ml-dw-2, 0);
1345}
1346
1347function process_eventdata(result)
1348{
1349 if (result.length==0)
1350 return;
1351
1352 var z = $("body").getAttribute("data-visible");
1353 var canv = $("canvas"+z);
1354 if (canv == undefined)
1355 return;
1356
1357 var type = canv.getAttribute("data-type");
1358
1359 var ctx = canv.getContext("2d");
1360 ctx.clearRect(0, 0, canv.width, canv.height);
1361
1362 var data = result.split('\n');
1363 if (result.length<4)
1364 return;
1365
1366 var l = data[0].length+1+data[1].length+1+data[2].length+1;
1367
1368 switch (type)
1369 {
1370 //case "camera": drawCam(result); break;
1371 case "hist":
1372 drawGraph(canv, data[1], data[2], result.substr(l));
1373 break;
1374 case "camera":
1375 drawFullCam(result.substr(l));
1376 drawCamLegend(canv, data[1], data[2]);
1377 break;
1378 }
1379
1380 var now = new Date();
1381 var tm = new Date();
1382 tm.setTime(data[0]);
1383 if (tm.getTime()+60000<now.getTime())
1384 {
1385 ctx.fillStyle = "rgba(255, 255, 255, 0.85)";
1386 ctx.fillRect(0, 0, canv.width, canv.height);
1387 }
1388
1389 //$("image"+z).src = canv.toDataURL("image/png");
1390}
1391
1392function save()
1393{
1394 var z = $("body").getAttribute("data-visible");
1395
1396 var canvas = $("canvas"+z);
1397 var img = canvas.toDataURL("image/png");
1398
1399 img = img.replace("image/png", "image/octet-stream");
1400
1401 document.location.href = img;
1402}
1403
1404window['onload'] = onload;
Note: See TracBrowser for help on using the repository browser.