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