Changeset 13925 for trunk/FACT++/www
- Timestamp:
- 05/26/12 18:47:20 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/www/smartfact/index.js
r13903 r13925 1 "use strict"; 2 1 3 var debug = false; 2 4 … … 163 165 function $txt(txt) { return document.createTextNode(txt); } 164 166 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;}167 function valid(str) { if (str===undefined) return false; if (str.length==0) return false; return true;} 166 168 function isSliding() { var z = $("body").getAttribute("data-visible"); return $("table"+z) ? $("table"+z).offsetLeft!=0 : false; } 167 function htmlDecode(input) { var e = $new('div'); e.innerHTML = input; return e.firstChild== undefined ? input : e.firstChild.nodeValue; }169 function htmlDecode(input) { var e = $new('div'); e.innerHTML = input; return e.firstChild===undefined ? input : e.firstChild.nodeValue; } 168 170 function setUTC(el, time) { var str = time.toUTCString(); var utc = str.substr(str.length-12, 8); el.innerHTML = "• "+utc+" UTC •"; } 169 171 … … 193 195 function onload() 194 196 { 195 try { new XMLHttpRequest(); }197 try { var dummy = new XMLHttpRequest(); } 196 198 catch(e) 197 199 { … … 289 291 var xmlCmd = new XMLHttpRequest(); 290 292 xmlCmd.open('POST', uri, true); 291 xmlCmd.onload = function ()293 xmlCmd.onload = function () 292 294 { 293 295 if (xmlCmd.status!=200) … … 356 358 357 359 var table = $("table"+z); 358 if (table != undefined)360 if (table) 359 361 $("body").removeChild(table); 360 362 … … 427 429 div2.setAttribute("style", "background-position:-396px 50%;"); 428 430 div4.setAttribute("style", "display:none;background-position:-12px -12px;"); 429 div2.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage(fname, z, -dz); }430 div4.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('error', z, +1); }431 div2.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage(fname, z, -dz); } 432 div4.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('error', z, +1); } 431 433 432 434 if (name=="fact") … … 439 441 div3.setAttribute("class", "icon_white"); 440 442 div3.setAttribute("style", "background-position:-575px 50%;"); 441 div3.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('fact', z, -1); }443 div3.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('fact', z, -1); } 442 444 } 443 445 … … 456 458 if (is_cmd) 457 459 { 458 sp1.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; submit(name); this.style.backgroundColor=''; }460 sp1.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; submit(name); this.style.backgroundColor=''; } 459 461 } 460 462 else 461 463 { 462 464 if (name!='control') 463 sp1.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.15)'; loadPage('control', z, +1); }465 sp1.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.15)'; loadPage('control', z, +1); } 464 466 } 465 467 … … 468 470 div1.appendChild($txt("---")); 469 471 470 div1.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; sendCommand('stop'); this.style.backgroundColor=''; }472 div1.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; sendCommand('stop'); this.style.backgroundColor=''; } 471 473 472 474 htd0.appendChild(sp0); … … 535 537 fdiv3.setAttribute("class", "icon_white"); 536 538 fdiv2.setAttribute("style", "background-position:-72px 50%;"); 537 fdiv2.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; sendCommand('stop'); this.style.backgroundColor=''; }539 fdiv2.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; sendCommand('stop'); this.style.backgroundColor=''; } 538 540 if (is_cmd) 539 541 { 540 fdiv3.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; submit(name); this.style.backgroundColor=''; }542 fdiv3.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; submit(name); this.style.backgroundColor=''; } 541 543 fdiv3.setAttribute("style", "background-position:-109px 50%;"); 542 544 } 543 545 else 544 546 { 545 fdiv3.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('control', z, +1); }547 fdiv3.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('control', z, +1); } 546 548 fdiv3.setAttribute("style", "background-position:-288px 50%;"); 547 549 } … … 557 559 fdivH.setAttribute("class", "icon_white"); 558 560 fdivH.setAttribute("style", "background-position:-611px 50%;"); 559 fdivH.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('help-'+name, z, +1); }561 fdivH.onclick = function () { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('help-'+name, z, +1); } 560 562 } 561 563 … … 634 636 canv.width = "1"; 635 637 canv.height = "1"; 636 //canv.onclick = function () { save(); }638 //canv.onclick = function () { save(); } 637 639 canv.setAttribute("data-type", check[0]); 638 640 canv.setAttribute("data-file", data[0]); … … 809 811 var img = $("image"+z); 810 812 var canv = $("canvas"+z); 811 if (img == undefined || canv== undefined)813 if (img === undefined || canv === undefined) 812 814 return; 813 815 … … 920 922 $("table"+oldz).style.position="fixed"; 921 923 922 intervalSlide = setInterval(function (){doShift(oldz,newz)}, 75);924 intervalSlide = setInterval(function (){doShift(oldz,newz);}, 75); 923 925 } 924 926 … … 1077 1079 1078 1080 var e = $("data"+z+"-"+line); 1079 if (e == undefined)1081 if (e === undefined) 1080 1082 continue; 1081 1083 1082 1084 var form = e.getAttribute("data-form"); 1083 if (form== undefined)1085 if (form===undefined) 1084 1086 continue; 1085 1087 … … 1127 1129 var xmlGfx = new XMLHttpRequest(); 1128 1130 xmlGfx.open('POST', "data/"+fname, true); 1129 xmlGfx.onload = function ()1131 xmlGfx.onload = function () 1130 1132 { 1131 1133 if (xmlGfx.status!=200) … … 1247 1249 * @constructor 1248 1250 */ 1249 function position(s, ring, i)1251 function Position(s, ring, i) 1250 1252 { 1251 1253 switch (s) … … 1258 1260 case 0: this.x = ring*0.5 + i*0.5; this.y = -ring + i; break; 1259 1261 } 1260 this.d = function() { return this.x*this.x + this.y*this.y*3/4; }1262 this.d = (function () { return this.x*this.x + this.y*this.y*3/4; }) 1261 1263 } 1262 1264 … … 1287 1289 for (var i=1; i<=ring; i++) 1288 1290 { 1289 var pos = new position(s, ring, i);1291 var pos = new Position(s, ring, i); 1290 1292 if (pos.d() - pos.x > 395.75) 1291 1293 continue; … … 1320 1322 for (var i=1; i<=ring; i++) 1321 1323 { 1322 var pos = new position(s, ring, i);1324 var pos = new Position(s, ring, i); 1323 1325 if (pos.d() > 44) 1324 1326 continue; … … 1496 1498 var z = $("body").getAttribute("data-visible"); 1497 1499 var canv = $("canvas"+z); 1498 if (canv == undefined)1500 if (canv === undefined) 1499 1501 return; 1500 1502
Note:
See TracChangeset
for help on using the changeset viewer.