- Timestamp:
- 06/10/12 14:50:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/www/smartfact/index.js
r14138 r14144 38 38 { 39 39 //alert("ERROR[0] - HTTP request '"+xmlLoad.statusText+" ["+xmlLoad.status+"]"); 40 return;40 //return; 41 41 } 42 42 if (xmlLoad.responseText.length>0) … … 742 742 743 743 // This might create the scroll bar 744 img.style.height = ih+"px"; 745 canv.height = ih; 744 745 if (img.style.height!=ih+"px") 746 img.style.height = ih+"px"; 747 if (canv.height!=ih) 748 canv.height = ih; 746 749 747 750 // now we can evaluate the correct view-port … … 750 753 var sW = fixedw ? fixedw : canv.parentNode.clientWidth; 751 754 752 img.style.width = sW+"px"; 753 canv.width = sW; 755 if (img.style.width!=sW+"px") 756 img.style.width = sW+"px"; 757 if (canv.width!=sW) 758 canv.width = sW; 754 759 755 760 // ------ debug ----- … … 905 910 cycleCol($("ldot"+z)); 906 911 update_text(fname, xmlText.responseText); 912 doresize(z); 907 913 } 908 914 timeoutText = setTimeout(refresh_text, 3000); … … 967 973 if (header.length>=3 && $("body").sound) 968 974 { 969 $("speaker"+z).style.display = "none";975 $("speaker"+z).style.display = "none"; 970 976 971 977 var audio = $("audio"); … … 985 991 ogg.src = name+".ogg"; 986 992 987 // If audio file has changed play the new one 988 if (audio.firstChild.src!=mp3.src) 989 { 990 audio.replaceChild(mp3, audio.firstChild); 991 audio.replaceChild(ogg, audio.lastChild); 992 993 } 993 audio.replaceChild(mp3, audio.firstChild); 994 audio.replaceChild(ogg, audio.lastChild); 995 996 audio.load(); 997 audio.play(); 994 998 995 999 audio.date = audio_date; 996 997 /*998 audio.firstChild.src = name_mp3;999 audio.lastChild.src = name_ogg;1000 audio.load();1001 */1002 1000 } 1003 1001 } … … 1304 1302 for (var i=0; i<11; i++) 1305 1303 { 1306 ctx.strokeStyle = "#"+color(1 6*i);1304 ctx.strokeStyle = "#"+color(126*i/10); 1307 1305 ctx.strokeText((v0+diff*i/10).toPrecision(3)+unit, cw-5, 125-i*12); 1308 1306 } … … 1327 1325 var umax = vals[2]+unit; 1328 1326 1329 var stat = vals[3]+unit+" / "+vals[4]+unit+" / "+vals[5]+unit; 1327 var stat = vals.length==4 ? vals[3] : 1328 vals[3]+unit+" / "+vals[4]+unit+" / "+vals[5]+unit; 1330 1329 1331 1330 var cw = canv.width; … … 1433 1432 } 1434 1433 1435 /* 1436 function drawZd(result) 1437 { 1438 function frac(x) { return(x-Math.floor(x)); } 1439 function Mod(a, b) { return(a-Math.floor(a/b)*b); } 1440 1441 var z = $("body").visiblePage; 1442 var canv = $("canvas"+z); 1443 1434 function invalidateCanvas(canv) 1435 { 1444 1436 var ctx = canv.getContext("2d"); 1445 1437 1446 // 16:57:58.210572 - Mrk 421: Ra=11.074266h Dec= 38.208801deg 1447 // 16:57:58.210782 - Mrk 501: Ra=16.897867h Dec= 39.760201deg 1448 // 16:57:58.210941 - 1ES 2344+51.4: Ra=23.784733h Dec= 51.705002deg 1449 // 16:57:58.211060 - PKS 2155-304: Ra=21.981134h Dec=-30.225599deg 1450 // 16:57:58.211189 - Crab: Ra= 5.575539h Dec= 22.014500deg 1451 // 16:57:58.211312 - H 1426+428: Ra=14.475734h Dec= 42.674702deg 1452 // 16:57:58.211429 - 1ES 1959+650: Ra=19.999933h Dec= 65.148499deg 1453 // 16:57:58.211544 - Dark Patch 3: Ra= 3.100000h Dec= 31.183333deg 1454 // 16:57:58.211651 - 1ES 1218+304: Ra=12.356089h Dec= 30.176897deg 1455 1456 var now = new Date(); 1457 1458 var RAD = Math.Pi/180.; 1459 1460 var lon = -(17.+53./60+26.525/3600) * Math.PI/180; 1461 var lat = (28.+45./60+42.462/3600) * Math.PI/180; 1462 1463 var ra = 16.897867 * Math.PI/ 12; //h 1464 var dec = 39.760201 * Math.PI/180; //deg 1465 1466 var arr = ""; 1467 1468 var date = Date.UTC(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0); 1469 date /= 86400000; 1470 date += 40587; 1471 1472 var coslat = Math.cos(lat); 1473 var sinlat = Math.sin(lat); 1474 1475 // 21 1476 for (var h=-4*12; h<6*12; h++) 1477 { 1478 var mjd = date + h/(24.*12); // Modified julian date 1479 var t = (mjd-51544.5) / 36525; // Julian centuries since J2000. 1480 1481 // GMST at this UT1 1482 var r = 24110.54841+(8640184.812866+(0.093104-6.2e-6*t)*t)*t; 1483 var sum = r/86400 + frac(mjd); 1484 var gmst = frac(sum)*Math.PI*2; 1485 1486 var lmst = Mod(gmst + lon, Math.PI*2); 1487 var lha = ra - lmst; 1488 1489 var alt = Math.asin(sinlat * Math.sin(dec) + 1490 coslat * Math.cos(dec) * Math.cos(lha)); 1491 alt *= 256/Math.PI; // 128/90*180/Math.Pi 1492 if (alt<0) 1493 alt = 0; 1494 if (alt>127) 1495 alt=127; 1496 1497 arr += String.fromCharCode(alt); 1498 } 1499 1500 var vals = new Array(5);//[] = { 0, 0, 0, 0, 0 }; 1501 vals[1] = "90"; 1502 vals[2] = " 0"; 1503 vals[3] = " "; 1504 vals[4] = " "; 1505 vals[5] = " "; 1506 drawGraph(canv, vals, arr); 1507 } 1508 */ 1509 1510 function process_eventdata(result) 1438 ctx.fillStyle = "rgba(255, 255, 255, 0.75)"; 1439 ctx.fillRect(0, 0, canv.width, canv.height); 1440 } 1441 1442 function processGraphicsData(canv, result) 1511 1443 { 1512 1444 if (result.length==0) 1513 return; 1514 1515 var z = $("body").visiblePage;//getAttribute("data-visible"); 1516 var canv = $("canvas"+z); 1517 if (!canv) 1518 return; 1519 1520 var type = canv.dataType;//getAttribute("data-type"); 1445 return false; 1521 1446 1522 1447 var ctx = canv.getContext("2d"); … … 1525 1450 var data = result.split('\x7f'); 1526 1451 if (data.length<2) 1527 return ;1452 return false; 1528 1453 1529 1454 var header = data[0].split('\n'); 1530 1455 if (header.length<4) 1531 return ;1532 1533 switch ( type)1456 return false; 1457 1458 switch (canv.dataType) 1534 1459 { 1535 1460 //case "camera": drawCam(result); break; … … 1545 1470 var now = new Date(); 1546 1471 var tm = new Date(); 1547 tm.setTime(data[0]); 1472 tm.setTime(header[0]); 1473 1548 1474 if (tm.getTime()+60000<now.getTime()) 1549 { 1550 ctx.fillStyle = "rgba(255, 255, 255, 0.75)"; 1551 ctx.fillRect(0, 0, canv.width, canv.height); 1552 } 1475 return false; 1553 1476 1554 1477 //$("image"+z).src = canv.toDataURL("image/png"); 1478 1479 return true; 1480 } 1481 1482 function process_eventdata(result) 1483 { 1484 var z = $("body").visiblePage;//getAttribute("data-visible"); 1485 var canv = $("canvas"+z); 1486 if (!canv) 1487 return; 1488 1489 if (!processGraphicsData(canv, result)) 1490 invalidateCanvas(canv); 1555 1491 } 1556 1492
Note:
See TracChangeset
for help on using the changeset viewer.