home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 10 / AU_CD10.iso / Archived / Internet / jvscript116beta / JvScript / !JvScript / Resources / Scripts / Date+Time / 4 < prev   
Encoding:
Text File  |  1999-08-24  |  2.8 KB  |  118 lines

  1. #newformat
  2. _source:http://javascript.internet.com/
  3. _title:Calendar
  4. _description:Inserts a calendar, with the current day highlighted
  5. _insert-in:inbody
  6. <!-- Monthly Calendar -->
  7. <CENTER>
  8. <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
  9. <!-- This script and many more are available free online at -->
  10. <!-- The JavaScript Source!! http://javascript.internet.com -->
  11. <!-- Begin
  12. monthnames = new Array(
  13. "January",
  14. "Februrary",
  15. "March",
  16. "April",
  17. "May",
  18. "June",
  19. "July",
  20. "August",
  21. "September",
  22. "October",
  23. "November",
  24. "Decemeber");
  25. var linkcount=0;
  26. function addlink(month, day, href) {
  27. var entry = new Array(3);
  28. entry[0] = month;
  29. entry[1] = day;
  30. entry[2] = href;
  31. this[linkcount++] = entry;
  32. }
  33. Array.prototype.addlink = addlink;
  34. linkdays = new Array();
  35. monthdays = new Array(12);
  36. monthdays[0]=31;
  37. monthdays[1]=28;
  38. monthdays[2]=31;
  39. monthdays[3]=30;
  40. monthdays[4]=31;
  41. monthdays[5]=30;
  42. monthdays[6]=31;
  43. monthdays[7]=31;
  44. monthdays[8]=30;
  45. monthdays[9]=31;
  46. monthdays[10]=30;
  47. monthdays[11]=31;
  48. todayDate=new Date();
  49. thisday=todayDate.getDay();
  50. thismonth=todayDate.getMonth();
  51. thisdate=todayDate.getDate();
  52. thisyear=todayDate.getYear();
  53. thisyear = thisyear % 100;
  54. thisyear = ((thisyear < 50) ? (2000 + thisyear) : (1900 + thisyear));
  55. if (((thisyear % 4 == 0) 
  56. && !(thisyear % 100 == 0))
  57. ||(thisyear % 400 == 0)) monthdays[1]++;
  58. startspaces=thisdate;
  59. while (startspaces > 7) startspaces-=7;
  60. startspaces = thisday - startspaces + 1;
  61. if (startspaces < 0) startspaces+=7;
  62. document.write("<table border=2 bgcolor=white ");
  63. document.write("bordercolor=black><font color=black>");
  64. document.write("<tr><td colspan=7><center><strong>" 
  65. + monthnames[thismonth] + " " + thisyear 
  66. + "</strong></center></font></td></tr>");
  67. document.write("<tr>");
  68. document.write("<td align=center>Su</td>");
  69. document.write("<td align=center>M</td>");
  70. document.write("<td align=center>Tu</td>");
  71. document.write("<td align=center>W</td>");
  72. document.write("<td align=center>Th</td>");
  73. document.write("<td align=center>F</td>");
  74. document.write("<td align=center>Sa</td>"); 
  75. document.write("</tr>");
  76. document.write("<tr>");
  77. for (s=0;s<startspaces;s++) {
  78. document.write("<td> </td>");
  79. }
  80. count=1;
  81. while (count <= monthdays[thismonth]) {
  82. for (b = startspaces;b<7;b++) {
  83. linktrue=false;
  84. document.write("<td>");
  85. for (c=0;c<linkdays.length;c++) {
  86. if (linkdays[c] != null) {
  87. if ((linkdays[c][0]==thismonth + 1) && (linkdays[c][1]==count)) {
  88. document.write("<a href=\"" + linkdays[c][2] + "\">");
  89. linktrue=true;
  90. }
  91. }
  92. }
  93. if (count==thisdate) {
  94. document.write("<font color='FF0000'><strong>");
  95. }
  96. if (count <= monthdays[thismonth]) {
  97. document.write(count);
  98. }
  99. else {
  100. document.write(" ");
  101. }
  102. if (count==thisdate) {
  103. document.write("</strong></font>");
  104. }
  105. if (linktrue)
  106. document.write("</a>");
  107. document.write("</td>");
  108. count++;
  109. }
  110. document.write("</tr>");
  111. document.write("<tr>");
  112. startspaces=0;
  113. }
  114. document.write("</table></p>");
  115. // -->
  116. </SCRIPT>
  117. </CENTER>
  118. _end-insert: