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