Changeset 13949 for trunk/FACT++/www/smartfact
- Timestamp:
- 05/28/12 10:45:51 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/www/smartfact/index.js
r13943 r13949 11 11 function trim(str) { return str.replace(/^\s\s*/, "").replace(/\s*\s$/, ""); } 12 12 function valid(str) { if (!str) return false; if (str.length==0) return false; return true;} 13 function isSliding() { var z = $("body"). getAttribute("data-visible"); return $("table"+z) ? $("table"+z).offsetLeft!=0 : false; }13 function isSliding() { var z = $("body").visiblePage/*getAttribute("data-visible")*/; return $("table"+z) ? $("table"+z).offsetLeft!=0 : false; } 14 14 function htmlDecode(input) { var e = $new('div'); e.innerHTML = input; return e.firstChild ? e.firstChild.nodeValue : input; } 15 15 function setUTC(el, time) { var str = time.toUTCString(); var utc = str.substr(str.length-12, 8); el.innerHTML = "• "+utc+" UTC •"; } … … 17 17 function cycleCol(el) 18 18 { 19 var col = el. getAttribute("data-color");19 var col = el.dotColor;//el.getAttribute("data-color"); 20 20 col++; 21 21 col %= 31; 22 el. setAttribute("data-color", col);22 el.dotColor = col; //setAttribute("data-color", col); 23 23 if (col>16) 24 24 col = 31-col; … … 45 45 switch (args[i]) 46 46 { 47 case "max": $("body").setAttribute("data-max", "yes"); continue; 48 case "noslide": $("body").setAttribute("data-noslide", "yes"); continue; 47 //case "max": $("body").setAttribute("data-max", "yes"); continue; 48 //case "noslide": $("body").setAttribute("data-noslide", "yes"); continue; 49 case "max": $("body").displayMax = true; continue; 50 case "noslide": $("body").displayNoslide = true; continue; 49 51 } 50 52 … … 55 57 switch (entry[0]) 56 58 { 57 case "w": $("body"). setAttribute("data-width", entry[1]); break;58 case "h": $("body"). setAttribute("data-height", entry[1]); break;59 case "w": $("body").displayFixedWidth = entry[1]; break; //setAttribute("data-width", entry[1]); break; 60 case "h": $("body").displayFixedHeight = entry[1]; break; //setAttribute("data-height", entry[1]); break; 59 61 } 60 62 } … … 73 75 function onresize() 74 76 { 75 var z = $("body"). getAttribute("data-visible");77 var z = $("body").visiblePage/*getAttribute("data-visible")*/; 76 78 77 79 //$("table"+z).style.width="100%"; … … 100 102 } 101 103 102 buildPage(name, xmlPage.responseText, z, dz); 103 changePage(z, z+dz); 104 if (!isSliding()) 105 { 106 buildPage(name, xmlPage.responseText, z, dz); 107 changePage(z, z+dz); 108 } 104 109 105 110 //changePage(name, xmlHttp.resposeText); … … 168 173 function buildPage(name, text, oldz, dz) 169 174 { 170 var fname = dz==0 ? "fact" : $("table"+oldz). getAttribute("data-file");175 var fname = dz==0 ? "fact" : $("table"+oldz).pageName;//getAttribute("data-file"); 171 176 172 177 var z = oldz + dz; … … 264 269 sp2.id = "rdot" +z; 265 270 sp1.setAttribute("style", "font-size:large;"); 266 sp0.setAttribute("data-color", "3"); 267 sp2.setAttribute("data-color", "3"); 271 //sp0.setAttribute("data-color", "3"); 272 //sp2.setAttribute("data-color", "3"); 273 sp0.dotColor = 3; 274 sp2.dotColor = 3; 268 275 sp0.appendChild($txt(" \u2022 ")); 269 276 sp1.appendChild($txt(title)); … … 459 466 canv.height = "1"; 460 467 //canv.onclick = function () { save(); } 461 canv.setAttribute("data-type", check[0]); 462 canv.setAttribute("data-file", data[0]); 463 canv.setAttribute("data-data", cols[1].substring(check[0].length+data[0].length+2)); 468 //canv.setAttribute("data-type", check[0]); 469 //canv.setAttribute("data-file", data[0]); 470 //canv.setAttribute("data-data", cols[1].substring(check[0].length+data[0].length+2)); 471 canv.dataType = check[0]; 472 canv.fileName = data[0]; 473 canv.dataUnit = htmlDecode(cols[1].substring(check[0].length+data[0].length+2)); 464 474 // canv.setAttribute("style", "display:none;"); 465 475 td.appendChild(canv); … … 478 488 tr.setAttribute("class", "row"); 479 489 480 var cols0 = cols[0];481 490 if (valid(cols[0])) 482 tr.onclick = function () { this.style.background='#ccb'; loadPage(cols0, z, -1); }; 483 484 var cols3 = cols[3]; 491 { 492 tr.linkName = cols[0]; 493 tr.onclick = function () { this.style.background='#ccb'; loadPage(this.linkName, z, -1); }; 494 } 495 485 496 if (valid(cols[3])) 486 tr.onclick = function () { this.style.background='#cbb'; loadPage(cols3, z, +1); }; 497 { 498 tr.linkName = cols[3]; 499 tr.onclick = function () { this.style.background='#cbb'; loadPage(this.linkName, z, +1); }; 500 } 487 501 488 502 var td0 = $new("td"); … … 554 568 { 555 569 cell2.id = "data"+z+"-"+counter; 556 cell2.setAttribute("data-form", cols[2]); 570 //cell2.setAttribute("data-form", cols[2]); 571 cell2.dataFormat = cols[2]; 557 572 cell2.appendChild($txt("---")); 558 573 counter++; … … 643 658 // ================================================================== 644 659 645 table. setAttribute("data-file", name);660 table.pageName = name;//setAttribute("data-file", name); 646 661 doresize(z); 647 662 } … … 668 683 // =========================================== 669 684 670 var fixedw = $("body"). getAttribute("data-width");671 var fixedh = $("body"). getAttribute("data-height");685 var fixedw = $("body").displayFixedWidth;//getAttribute("data-width"); 686 var fixedh = $("body").displayFixedHeight;//getAttribute("data-height"); 672 687 673 688 var W = fixedw>0 ? fixedw : window.innerWidth; 674 689 var H = fixedh>0 ? fixedh : window.innerHeight; 675 690 676 var max = $("body").getAttribute("data-max")=="yes"; 691 //var max = $("body").getAttribute("data-max")=="yes"; 692 var max = $("body").displayMax; 677 693 678 694 var ih = max ? W : H - h + parseInt(img.style.height, 10); … … 708 724 { 709 725 $("table"+newz).style.left="0px"; 710 $("body"). setAttribute("data-visible", newz);726 $("body").visiblePage = newz; //.setAttribute("data-visible", newz); 711 727 712 728 doresize(0); … … 735 751 736 752 var W = window.innerWidth; 737 if (W==0 || $("body"). getAttribute("data-noslide")=="yes")738 { 739 $("body"). setAttribute("data-visible", newz);753 if (W==0 || $("body").displayNoslide)//$("body").getAttribute("data-noslide")=="yes") 754 { 755 $("body").visiblePage = newz;//setAttribute("data-visible", newz); 740 756 $("body").removeChild($("table"+oldz)); 741 757 $("table"+newz).style.left="0px"; … … 748 764 $("table"+newz).style.left = (-W-1)+"px"; 749 765 750 $("body"). setAttribute("data-visible", newz);766 $("body").visiblePage = newz;//setAttribute("data-visible", newz); 751 767 752 768 // This is needed on my mobile to ensure that te browser … … 807 823 function refresh_text() 808 824 { 809 var z=$("body"). getAttribute("data-visible");810 811 var fname = $("table"+z). getAttribute("data-file");825 var z=$("body").visiblePage;//getAttribute("data-visible"); 826 827 var fname = $("table"+z).pageName;//getAttribute("data-file"); 812 828 813 829 var is_help = fname.substr(0,5)=="help-"; … … 852 868 function update_text(fname, result) 853 869 { 854 var z=$("body"). getAttribute("data-visible");870 var z=$("body").visiblePage;//getAttribute("data-visible"); 855 871 var table = $("table"+z); 856 872 857 if (table. getAttribute("data-file")!= fname)873 if (table.pageName/*getAttribute("data-file")*/ != fname) 858 874 return; 859 875 … … 915 931 continue; 916 932 917 var form = e. getAttribute("data-form");933 var form = e.dataFormat;//getAttribute("data-form"); 918 934 if (!form) 919 935 continue; … … 947 963 function refresh_graphics() 948 964 { 949 var z = $("body"). getAttribute("data-visible");965 var z = $("body").visiblePage;//getAttribute("data-visible"); 950 966 951 967 var canvas = $("canvas"+z); 952 968 953 969 // Is sliding or no data file defined? 954 var fname = canvas==null ? "" : canvas. getAttribute("data-file");970 var fname = canvas==null ? "" : canvas.fileName;//getAttribute("data-file"); 955 971 if (isSliding() || !valid(fname)) 956 972 { … … 1065 1081 function beginDrawCam(scale) 1066 1082 { 1067 var z = $("body"). getAttribute("data-visible");1083 var z = $("body").visiblePage;//getAttribute("data-visible"); 1068 1084 var canv = $("canvas"+z); 1069 1085 … … 1177 1193 function drawCamLegend(canv, data) 1178 1194 { 1179 var unit = htmlDecode(canv.getAttribute("data-data"));1195 var unit = canv.dataUnit;//htmlDecode(canv.getAttribute("data-data")); 1180 1196 1181 1197 var umin = data[1]; … … 1220 1236 function drawGraph(canv, vals, data) 1221 1237 { 1222 var unit = htmlDecode(canv.getAttribute("data-data"));//.split("/");1238 var unit = canv.dataUnit;//htmlDecode(canv.getAttribute("data-data"));//.split("/"); 1223 1239 1224 1240 var umin = vals[1]+unit; … … 1329 1345 return; 1330 1346 1331 var z = $("body"). getAttribute("data-visible");1347 var z = $("body").visiblePage;//getAttribute("data-visible"); 1332 1348 var canv = $("canvas"+z); 1333 1349 if (!canv) 1334 1350 return; 1335 1351 1336 var type = canv. getAttribute("data-type");1352 var type = canv.dataType;//getAttribute("data-type"); 1337 1353 1338 1354 var ctx = canv.getContext("2d"); … … 1373 1389 function save() 1374 1390 { 1375 var z = $("body"). getAttribute("data-visible");1391 var z = $("body").visiblePage;//getAttribute("data-visible"); 1376 1392 1377 1393 var canvas = $("canvas"+z);
Note:
See TracChangeset
for help on using the changeset viewer.