Changeset 13773
- Timestamp:
- 05/18/12 11:58:31 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/www/shift/calendar.js
r13748 r13773 380 380 }; 381 381 382 var tab = document.createElement("table"); 383 tab.width="100%"; 384 tab.style.border = 0; 385 tab.style.padding = 0; 386 tab.style.margin = 0; 387 tab.style.fontSize = "1.5em"; 388 tab.style.backgroundColor = "transparent"; 389 var tr0 = document.createElement("tr"); 390 var td0 = document.createElement("td"); 391 var td1 = document.createElement("td"); 392 td0.style.textAlign = "left"; 393 td1.style.textAlign = "right"; 394 td1.style.textWeight= "normal"; 395 td0.style.color = "lightgray"; 396 td0.style.border=0; 397 td1.style.border=0; 398 td0.style.padding=0; 399 td1.style.padding=0; 400 tab.appendChild(tr0); 401 tr0.appendChild(td0); 402 tr0.appendChild(td1); 403 //td0.appendChild(document.createTextNode(txt)); 404 405 td1.appendChild(td.firstChild); 406 td.appendChild(tab); 407 408 var IP = this.getMoonPhase(this.yy, this.mm, i); 409 var str = this.getMoonPhaseStr(IP); 410 var phase = 100-Math.abs(IP-0.5)*200; 411 var txt = parseInt(phase+0.5,10)+"%"; 412 if (phase>50) 413 td0.style.color = "gray"; 414 if (phase<3.4) 415 { 416 txt = "o"; 417 td0.style.textWeight = "bolder"; 418 td0.style.fontSize = "0.7em"; 419 td0.style.color = "darkgreen"; 420 } 421 if (phase>96.6) 422 { 423 txt = "•"; 424 td0.style.textWeight = "bolder"; 425 td0.style.fontSize = "0.8em"; 426 td0.style.color = "darkred"; 427 } 428 tab.title = str; 429 td0.innerHTML = txt; 430 382 431 var sp = document.createElement("span"); 383 432 sp.appendChild(document.createTextNode("*")); 384 433 sp.style.color="darkred"; 385 434 sp.style.display="none"; 386 td.appendChild(sp); 435 td1.appendChild(sp); 436 387 437 388 438 tr.appendChild( td ); … … 460 510 return; 461 511 462 while (td.childNodes.length> 2)512 while (td.childNodes.length>1) 463 513 td.removeChild(td.lastChild); 464 514 … … 482 532 } 483 533 484 if (td.childNodes.length> 2)534 if (td.childNodes.length>1) 485 535 td.className += " enabled"; 486 536 else … … 533 583 534 584 var td = document.getElementById(m+"-"+d); 535 alert(td.childNodes[1]+"/"+v);585 var sp = td.firstChild.firstChild.lastChild.lastChild; 536 586 if (v=="") 537 587 { 538 td.childNodes[1].style.display="none";588 sp.style.display="none"; 539 589 td.title="Click to select this date."; 540 590 } 541 591 else 542 592 { 543 td.childNodes[1].style.display="";593 sp.style.display=""; 544 594 td.title=v; 545 595 } … … 573 623 574 624 var td = document.getElementById(mm+"-"+dd); 575 576 c.color="#888"; 577 if (xmlHttp.responseText=="") 578 { 579 c.value="enter comment here"; 580 td.childNodes[1].style.display="none"; 581 td.title=""; 582 } 583 else 584 { 585 c.value = xmlHttp.responseText; 586 td.childNodes[1].style.display=""; 587 td.title=xmlHttp.responseText; 625 var sp = td.firstChild.firstChild.lastChild.lastChild; 626 627 if (sp!=undefined) 628 { 629 c.color="#888"; 630 if (xmlHttp.responseText=="") 631 { 632 c.value="enter comment here"; 633 sp.style.display="none"; 634 td.title=""; 635 } 636 else 637 { 638 c.value = xmlHttp.responseText; 639 sp.style.display=""; 640 td.title=xmlHttp.responseText; 641 } 588 642 } 589 643 … … 677 731 { 678 732 var td = document.getElementById(mm+"-"+dd); 679 td.childNodes[1].style.display=""; 733 var sp = td.firstChild.firstChild.lastChild.lastChild; 734 sp.style.display=""; 680 735 td.title=com; 681 736 } … … 784 839 this.show(); 785 840 } 841 842 this.getMoonPhase = function(Y, M, D) 843 { 844 // calculate the Julian date at 12h UT 845 var YY = Y - Math.floor( ( 12 - M ) / 10 ); 846 var MM = ( M + 9 ) % 12; 847 848 var K1 = Math.floor( 365.25 * ( YY + 4712 ) ); 849 var K2 = Math.floor( 30.6 * MM + 0.5 ); 850 var K3 = Math.floor( Math.floor( ( YY / 100 ) + 49 ) * 0.75 ) - 38; 851 852 var JD = K1 + K2 + D + 59; // for dates in Julian calendar 853 if ( JD > 2299160 ) // for Gregorian calendar 854 JD = JD - K3; 855 856 // calculate moon's age in days 857 var IP = ( ( JD - 2451550.1 ) / 29.530588853 ) % 1; 858 return IP; 859 860 // Moon's age 861 //var AG = IP*29.53; 862 863 } 864 865 this.getMoonPhaseStr = function(IP) 866 { 867 var phase = " ("+(100-Math.abs(IP-0.5)*200).toPrecision(2)+"%)"; 868 869 if (IP*16 < 1) return "New moon" + phase; 870 if (IP*16 < 3) return "Evening crescent" + phase; 871 if (IP*16 < 5) return "First quarter" + phase; 872 if (IP*16 < 7) return "Waxing gibbous" + phase; 873 if (IP*16 < 9) return "Full moon" + phase; 874 if (IP*16 <11) return "Waning gibbous" + phase; 875 if (IP*16 <13) return "Last quarter" + phase; 876 if (IP*16 <15) return "Morning crescent" + phase; 877 878 return "New moon"+phase; 879 } 786 880 } 787 881
Note:
See TracChangeset
for help on using the changeset viewer.