Changeset 13886
- Timestamp:
- 05/24/12 21:22:09 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/www/smartfact/index.js
r13881 r13886 160 160 */ 161 161 function $(id) { return document.getElementById(id); } 162 function $new(name) { return document.createElement(name); } 163 function $txt(txt) { return document.createTextNode(txt); } 162 164 function trim(str) { return str.replace("/^\s\s*/", '').replace("/\s\s*$/", ''); } 163 165 function valid(str) { if (str==undefined) return false; if (str.length==0) return false; return true;} 164 166 function isSliding() { var z = $("body").getAttribute("data-visible"); return $("table"+z).offsetLeft!=0; } 165 function htmlDecode(input) { var e = document.createElement('div'); e.innerHTML = input; return e.childNodes[0].nodeValue; } 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 •"; } 166 169 167 170 function cycleCol(el) … … 352 355 $("body").removeChild(table); 353 356 354 table = document.createElement("table");357 table = $new("table"); 355 358 table.setAttribute("class", "tborder"); 356 359 table.id = "table"+z; … … 364 367 // ----------------------------------------------------- 365 368 366 var th = document.createElement("thead");369 var th = $new("thead"); 367 370 th.colSpan = 3; 368 371 th.width = "100%"; 369 372 table.appendChild(th); 370 373 371 var htr = document.createElement("tr");374 var htr = $new("tr"); 372 375 th.appendChild(htr); 373 376 374 var htd = document.createElement("td");377 var htd = $new("td"); 375 378 htd.setAttribute("class", "thead"); 376 379 htd.colSpan = 3; … … 380 383 // ------------- 381 384 382 var htab = document.createElement("table");385 var htab = $new("table"); 383 386 htab.width = "100%"; 384 387 htd.appendChild(htab); 385 388 386 var hhtr = document.createElement("tr");389 var hhtr = $new("tr"); 387 390 htab.appendChild(hhtr); 388 391 389 var htd0 = document.createElement("td");390 var htd1 = document.createElement("td");391 var htd2 = document.createElement("td");392 var htd3 = document.createElement("td");393 var htd4 = document.createElement("td");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"); 394 397 htd0.setAttribute("class", "tcell1"); 395 398 htd1.setAttribute("class", "tcell2"); … … 411 414 htd4.style.verticalAlign = "middle"; 412 415 */ 413 var div1 = document.createElement("div");414 var div2 = document.createElement("div");415 var div3 = document.createElement("div");416 var div4 = document.createElement("div");416 var div1 = $new("div"); 417 var div2 = $new("div"); 418 var div3 = $new("div"); 419 var div4 = $new("div"); 417 420 div4.id = "warn"+z; 418 421 div2.setAttribute("class", "icon_white"); 419 div3.setAttribute("class", "icon_white");420 422 div4.setAttribute("class", "icon_color"); 421 423 div2.setAttribute("style", "background-position:-396px 50%;"); 422 div3.setAttribute("style", "background-position:-575px 50%;");423 424 div4.setAttribute("style", "display:none;background-position:-12px -12px;"); 424 div3.onclick = function() { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('fact', z, -1); }425 425 div2.onclick = function() { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage(fname, z, -dz); } 426 426 div4.onclick = function() { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('error', z, +1); } 427 427 428 var sp0 = document.createElement("span"); 429 var sp1 = document.createElement("span"); 430 var sp2 = document.createElement("span"); 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"); 431 443 sp0.id = "ldot" +z; 432 444 sp1.id = "title"+z; … … 435 447 sp0.setAttribute("data-color", "3"); 436 448 sp2.setAttribute("data-color", "3"); 437 sp0.appendChild( document.createTextNode(" \u2022 "));438 sp1.appendChild( document.createTextNode(title));439 sp2.appendChild( document.createTextNode(" \u2022 "));449 sp0.appendChild($txt(" \u2022 ")); 450 sp1.appendChild($txt(title)); 451 sp2.appendChild($txt(" \u2022 ")); 440 452 if (is_cmd) 441 453 { … … 450 462 div1.setAttribute("style", "font-size:small;"); 451 463 div1.id = "reporttime"+z; 452 div1.appendChild( document.createTextNode("---"));464 div1.appendChild($txt("---")); 453 465 454 466 div1.onclick = function() { this.style.backgroundColor='rgba(0,0,0,0.77)'; sendCommand('stop'); this.style.backgroundColor=''; } … … 461 473 if (dz!=0/* && z+dz!=0*/) 462 474 htd2.appendChild(div2); // back 463 if (lines[0]!="FACT") 464 htd3.appendChild(div3); // home 475 htd3.appendChild(div3); // home 465 476 htd4.appendChild(div4); // Warning 466 477 467 478 // ----------------------------------------------------- 468 479 469 var tbody = document.createElement("tbody");480 var tbody = $new("tbody"); 470 481 table.appendChild(tbody); 471 482 472 483 // ----------------------------------------------------- 473 484 474 var tf = document.createElement("tfoot");485 var tf = $new("tfoot"); 475 486 table.appendChild(tf); 476 487 477 var ftr = document.createElement("tr");488 var ftr = $new("tr"); 478 489 tf.appendChild(ftr); 479 490 480 var ftd = document.createElement("td");491 var ftd = $new("td"); 481 492 ftd.setAttribute("class", "tfoot"); 482 493 ftd.width = "100%"; … … 484 495 ftr.appendChild(ftd); 485 496 486 var ftab = document.createElement("table");497 var ftab = $new("table"); 487 498 ftab.width = "100%"; 488 499 ftd.appendChild(ftab); 489 500 490 var ftdH = document.createElement("td");491 var ftd0 = document.createElement("td");492 var ftd1 = document.createElement("td");493 var ftd2 = document.createElement("td");494 var ftd3 = document.createElement("td");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"); 495 506 ftdH.setAttribute("width", "1px"); 496 507 ftd2.setAttribute("width", "1px"); … … 509 520 ftab.appendChild(ftd3); 510 521 511 var fdivH = document.createElement("div");512 var fdiv0 = document.createElement("span");513 var fdiv1 = document.createElement("span");514 var fdiv2 = document.createElement("div");515 var fdiv3 = document.createElement("div");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"); 516 527 ftd0.style.paddingLeft = "5px"; 517 518 fdivH.setAttribute("class", "icon_white"); 528 fdiv2.id="cmd"+z; 529 519 530 fdiv2.setAttribute("class", "icon_white"); 520 531 fdiv3.setAttribute("class", "icon_white"); 521 fdivH.setAttribute("style", "background-position:-611px 50%;");522 532 fdiv2.setAttribute("style", "background-position:-72px 50%;"); 523 fdivH.onclick = function() { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('help-'+name, z, +1); }524 533 fdiv2.onclick = function() { this.style.backgroundColor='rgba(0,0,0,0.77)'; sendCommand('stop'); this.style.backgroundColor=''; } 525 534 if (is_cmd) … … 533 542 fdiv3.setAttribute("style", "background-position:-288px 50%;"); 534 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 } 550 else 551 { 552 fdivH.setAttribute("class", "icon_white"); 553 fdivH.setAttribute("style", "background-position:-611px 50%;"); 554 fdivH.onclick = function() { this.style.backgroundColor='rgba(0,0,0,0.77)'; loadPage('help-'+name, z, +1); } 555 } 556 535 557 536 558 fdiv0.setAttribute("style", "font-size:large;"); … … 538 560 fdiv1.id = "localtime"+z; 539 561 540 fdiv0.appendChild( document.createTextNode("logbook"));541 fdiv1.appendChild( document.createTextNode("loading..."));562 fdiv0.appendChild($txt("logbook")); 563 fdiv1.appendChild($txt("loading...")); 542 564 543 565 ftdH.appendChild(fdivH); … … 571 593 var data = cols[1].substring(check[0].length+1).split("/"); 572 594 573 var tr = document.createElement("tr");595 var tr = $new("tr"); 574 596 tr.setAttribute("class", "row"); 575 597 //tr.setAttribute("style", "margin:0;padding:0;"); 576 598 577 var td = document.createElement("td");599 var td = $new("td"); 578 600 td.setAttribute("class", "container"); 579 601 td.id = "container"; … … 581 603 tr.appendChild(td); 582 604 583 var canv = document.createElement("canvas");605 var canv = $new("canvas"); 584 606 canv.id = "canvas"+z; 585 607 canv.width = "1"; … … 592 614 td.appendChild(canv); 593 615 594 var img = document.createElement("img");616 var img = $new("img"); 595 617 img.src = "img/dummy.png";//needed in firefox 596 618 img.id = "image"+z; … … 602 624 } 603 625 604 var tr = document.createElement("tr");626 var tr = $new("tr"); 605 627 tr.setAttribute("class", "row"); 606 628 if (valid(cols[0])) … … 609 631 tr.setAttribute("onclick", "this.style.background='#ccb'; loadPage('"+cols[3]+"', "+z+", +1);"); 610 632 611 var td0 = document.createElement("td");633 var td0 = $new("td"); 612 634 td0.setAttribute("class", "tcol0"); 613 635 tr.appendChild(td0); … … 615 637 if (check.length>0 && check[0]=="image") 616 638 { 617 var img = document.createElement("img");639 var img = $new("img"); 618 640 img.style.width="100%"; 619 641 img.src = check[1]; … … 629 651 if (valid(cols[0])) 630 652 { 631 var sp = document.createElement("div");653 var sp = $new("div"); 632 654 sp.setAttribute("class", "icon_black"); 633 655 sp.setAttribute("style", "background-position: -144px 50%;"); … … 635 657 } 636 658 637 var td1 = document.createElement("td");659 var td1 = $new("td"); 638 660 td1.setAttribute("class", "tcol1"); 639 661 td1.width = "100%"; 640 662 tr.appendChild(td1); 641 663 642 var td2 = document.createElement("td");664 var td2 = $new("td"); 643 665 td2.setAttribute("class", "tcol2"); 644 666 td2.width = "18px"; … … 646 668 if (valid(cols[3])) 647 669 { 648 var sp = document.createElement("div");670 var sp = $new("div"); 649 671 sp.setAttribute("class", "icon_black"); 650 672 sp.setAttribute("style", "background-position: -108px 50%;"); … … 653 675 tr.appendChild(td2); 654 676 655 var tab = document.createElement("table");677 var tab = $new("table"); 656 678 tab.width = "100%"; 657 679 td1.appendChild(tab); 658 680 659 var innertr = document.createElement("tr");681 var innertr = $new("tr"); 660 682 tab.appendChild(innertr); 661 683 662 var cell1 = document.createElement("td");684 var cell1 = $new("td"); 663 685 cell1.setAttribute("class", "tcell1"); 664 686 665 var cell2 = document.createElement("td");687 var cell2 = $new("td"); 666 688 cell2.setAttribute("class", valid(cols[1]) ? "tcell2" : "tcell2l"); 667 689 668 690 if (check.length==0 || check[0]!="input") 669 691 { 670 var div = document.createElement("div");692 var div = $new("div"); 671 693 div.innerHTML = cols[1]; 672 694 cell1.appendChild(div); 673 //cell1.appendChild( document.createTextNode(cols[1]));695 //cell1.appendChild($txt(cols[1])); 674 696 675 697 if (cols.length>2 && cols[2].length>0) … … 677 699 cell2.id = "data"+z+"-"+counter; 678 700 cell2.setAttribute("data-form", cols[2]); 679 cell2.appendChild( document.createTextNode("---"));701 cell2.appendChild($txt("---")); 680 702 counter++; 681 703 } … … 690 712 alert("Argument name missing for'"+check[1]+"'"); 691 713 692 var div = document.createElement("div");714 var div = $new("div"); 693 715 div.innerHTML = opt[0]; 694 716 cell1.appendChild(div); 695 //cell1.appendChild( document.createTextNode(opt[0]));696 697 var input = document.createElement("input");717 //cell1.appendChild($txt(opt[0])); 718 719 var input = $new("input"); 698 720 input.name = opt[1]; 699 721 input.type = "text"; … … 713 735 if (true) 714 736 { 715 tr = document.createElement("tr");737 tr = $new("tr"); 716 738 tr.setAttribute("class", "row"); 717 739 718 td = document.createElement("td");740 td = $new("td"); 719 741 td.colSpan = "3"; 720 742 tr.appendChild(td); 721 743 722 var sp = document.createElement("div");744 var sp = $new("div"); 723 745 sp.setAttribute("class", "icon_color"); 724 746 sp.setAttribute("style", "background-position: -144px -14px;"); 725 747 td.appendChild(sp); 726 748 727 sp = document.createElement("div");749 sp = $new("div"); 728 750 sp.setAttribute("class", "icon_color"); 729 751 sp.setAttribute("style", "background-position: -56px -14px;"); … … 738 760 if (debug == true) 739 761 { 740 tr = document.createElement("tr");762 tr = $new("tr"); 741 763 tr.setAttribute("class", "row"); 742 764 743 td = document.createElement("td");765 td = $new("td"); 744 766 td.id = "debug"+z; 745 767 td.colSpan = 3; … … 923 945 { 924 946 var z=$("body").getAttribute("data-visible"); 925 var table = $("table"+z); 926 927 // Is sliding or no file defined? 928 var fname = table.getAttribute("data-file"); 929 if (isSliding() || !valid(fname)) 930 { 947 948 var fname = $("table"+z).getAttribute("data-file"); 949 950 var is_help = fname.substr(0,5)=="help-"; 951 952 // Is sliding, no file defined or just help text? 953 if (isSliding() || !valid(fname) || is_help) 954 { 955 if (is_help) 956 { 957 setUTC($("localtime"+z), new Date()); 958 $("reporttime"+z).innerHTML=""; 959 } 960 931 961 // invalidate? 932 962 timeoutText = setTimeout(refresh_text, 1000); … … 998 1028 rtime.style.color = ""; 999 1029 1000 var str_file = stamp.toUTCString(); 1001 var str_now = now.toUTCString(); 1002 1003 var utc_file = str_file.substr(str_file.length-12, 8); 1004 var utc_now = str_now.substr(str_now.length-12, 8); 1005 1006 rtime.innerHTML = "• "+utc_file+" UTC •" 1007 ltime.innerHTML = "• "+utc_now +" UTC •"; 1008 1009 $("warn"+z).style.display = header.length<2 || header[1]=='0' ? "none" : ""; 1030 setUTC(rtime, stamp); 1031 setUTC(ltime, now); 1032 1033 // ---------------------------------------------------- 1034 1035 $("warn"+z).style.display = header.length>=2 && header[1]=='1' ? "" : "none"; 1036 1037 if (header.length==3) 1038 $("cmd"+z).style.backgroundColor = header[2]=='1' ? "darkgreen" : "darkred"; 1010 1039 1011 1040 // ---------------------------------------------------- … … 1019 1048 continue; 1020 1049 1021 var e = document.getElementById("data"+z+"-"+line);1050 var e = $("data"+z+"-"+line); 1022 1051 if (e == undefined) 1023 1052 continue; … … 1041 1070 form = form.replace(/--:--:--/g, "<pre> </pre> <pre> </pre> <pre> </pre>"); 1042 1071 1043 var newe = document.createElement("div");1072 var newe = $new("div"); 1044 1073 newe.innerHTML = form; 1045 1074 e.replaceChild(newe, e.lastChild); … … 1100 1129 if (hue<4) return parseInt(255*(4-hue), 10); 1101 1130 1102 /*1103 if (hue<1*5/4) return parseInt(255*hue*4/5);1104 if (hue<2*5/4) return parseInt(255);1105 if (hue<3*5/4) return parseInt(255*(3*5/4-hue)*4/5);1106 */1107 /*1108 if (hue<1.5) return parseInt(255*hue/1.5);1109 if (hue<3.0) return parseInt(255);1110 if (hue<4.5) return parseInt(255*(4.5-hue)/1.5);1111 */1112 1131 return 0. 1113 1132 } … … 1129 1148 return sr+sg+sb; 1130 1149 } 1131 1132 1150 1133 1151 function color(col) … … 1296 1314 function drawCamLegend(canv, data) 1297 1315 { 1316 var unit = htmlDecode(canv.getAttribute("data-data")); 1317 1298 1318 var umin = data[1]; 1299 1319 var umax = data[2]; 1300 1320 1301 var unit = htmlDecode(canv.getAttribute("data-data")); 1302 //unit = unit.replace("°", "\u00B0"); 1303 //unit = unit.replace("µ", "\u00B5"); 1304 //unit = unit.replace("²", "\u00B2"); 1305 //unit = unit.replace("³", "\u00B3"); 1306 1307 var min = data[3]+unit 1308 var med = data[4]+unit; 1309 var max = data[5]+unit; 1321 var min = data[3]+unit 1322 var med = data[4]+unit; 1323 var max = data[5]+unit; 1310 1324 1311 1325 var v0 = parseFloat(umin); … … 1345 1359 var unit = htmlDecode(canv.getAttribute("data-data"));//.split("/"); 1346 1360 1347 //unit = unit.replace("°", "\u00B0");1348 //unit = unit.replace("µ", "\u00B5");1349 //unit = unit.replace("²", "\u00B2");1350 //unit = unit.replace("³", "\u00B3");1351 1352 1361 var umin = vals[1]+unit; 1353 1362 var umax = vals[2]+unit; … … 1361 1370 1362 1371 var dw = 3; // tick width 1363 1364 1372 var fs = 8; // font size 1365 1373 … … 1493 1501 if (tm.getTime()+60000<now.getTime()) 1494 1502 { 1495 ctx.fillStyle = "rgba(255, 255, 255, 0. 85)";1503 ctx.fillStyle = "rgba(255, 255, 255, 0.75)"; 1496 1504 ctx.fillRect(0, 0, canv.width, canv.height); 1497 1505 }
Note:
See TracChangeset
for help on using the changeset viewer.