calendar.html 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <!--
  2. Title: Tigra Calendar
  3. URL: http://www.softcomplex.com/products/tigra_calendar/
  4. Version: 3.2
  5. Date: 10/14/2002 (mm/dd/yyyy)
  6. Feedback: feedback@softcomplex.com (specify product title in the subject)
  7. Note: Permission given to use this script in ANY kind of applications if
  8. header lines are left unchanged.
  9. Note: Script consists of two files: calendar?.js and calendar.html
  10. About us: Our company provides offshore IT consulting services.
  11. Contact us at sales@softcomplex.com if you have any programming task you
  12. want to be handled by professionals. Our typical hourly rate is $20.
  13. -->
  14. <html>
  15. <head>
  16. <title>Select Date, Please.</title>
  17. <style>
  18. td {font-family: Tahoma, Verdana, sans-serif; font-size: 12px;}
  19. </style>
  20. <script language="JavaScript">
  21. // months as they appear in the calendar's title
  22. var ARR_MONTHS = ["January", "February", "March", "April", "May", "June",
  23. "July", "August", "September", "October", "November", "December"];
  24. // week day titles as they appear on the calendar
  25. var ARR_WEEKDAYS = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
  26. // day week starts from (normally 0-Su or 1-Mo)
  27. var NUM_WEEKSTART = 1;
  28. // path to the directory where calendar images are stored. trailing slash req.
  29. var STR_ICONPATH = 'img/';
  30. var re_url = new RegExp('datetime=(\\-?\\d+)');
  31. var dt_current = (re_url.exec(String(window.location))
  32. ? new Date(new Number(RegExp.$1)) : new Date());
  33. var re_id = new RegExp('id=(\\d+)');
  34. var num_id = (re_id.exec(String(window.location))
  35. ? new Number(RegExp.$1) : 0);
  36. var obj_caller = (window.opener ? window.opener.calendars[num_id] : null);
  37. if (obj_caller && obj_caller.year_scroll) {
  38. // get same date in the previous year
  39. var dt_prev_year = new Date(dt_current);
  40. dt_prev_year.setFullYear(dt_prev_year.getFullYear() - 1);
  41. if (dt_prev_year.getDate() != dt_current.getDate())
  42. dt_prev_year.setDate(0);
  43. // get same date in the next year
  44. var dt_next_year = new Date(dt_current);
  45. dt_next_year.setFullYear(dt_next_year.getFullYear() + 1);
  46. if (dt_next_year.getDate() != dt_current.getDate())
  47. dt_next_year.setDate(0);
  48. }
  49. // get same date in the previous month
  50. var dt_prev_month = new Date(dt_current);
  51. dt_prev_month.setMonth(dt_prev_month.getMonth() - 1);
  52. if (dt_prev_month.getDate() != dt_current.getDate())
  53. dt_prev_month.setDate(0);
  54. // get same date in the next month
  55. var dt_next_month = new Date(dt_current);
  56. dt_next_month.setMonth(dt_next_month.getMonth() + 1);
  57. if (dt_next_month.getDate() != dt_current.getDate())
  58. dt_next_month.setDate(0);
  59. // get first day to display in the grid for current month
  60. var dt_firstday = new Date(dt_current);
  61. dt_firstday.setDate(1);
  62. dt_firstday.setDate(1 - (7 + dt_firstday.getDay() - NUM_WEEKSTART) % 7);
  63. // function passing selected date to calling window
  64. function set_datetime(n_datetime, b_close) {
  65. if (!obj_caller) return;
  66. var dt_datetime = obj_caller.prs_time(
  67. (document.cal ? document.cal.time.value : ''),
  68. new Date(n_datetime)
  69. );
  70. if (!dt_datetime) return;
  71. if (b_close) {
  72. window.close();
  73. obj_caller.target.value = (document.cal
  74. ? obj_caller.gen_tsmp(dt_datetime)
  75. : obj_caller.gen_date(dt_datetime)
  76. );
  77. }
  78. else obj_caller.popup(dt_datetime.valueOf());
  79. }
  80. </script>
  81. </head>
  82. <body bgcolor="#FFFFFF" marginheight="5" marginwidth="5" topmargin="5" leftmargin="5" rightmargin="5">
  83. <table class="clsOTable" cellspacing="0" border="0" width="100%">
  84. <tr><td bgcolor="#4682B4">
  85. <table cellspacing="1" cellpadding="3" border="0" width="100%">
  86. <tr><td colspan="7"><table cellspacing="0" cellpadding="0" border="0" width="100%">
  87. <tr>
  88. <script language="JavaScript">
  89. document.write(
  90. '<td>'+(obj_caller&&obj_caller.year_scroll?'<a href="javascript:set_datetime('+dt_prev_year.valueOf()+')"><img src="'+STR_ICONPATH+'prev_year.gif" width="16" height="16" border="0" alt="previous year"></a>&nbsp;':'')+'<a href="javascript:set_datetime('+dt_prev_month.valueOf()+')"><img src="'+STR_ICONPATH+'prev.gif" width="16" height="16" border="0" alt="previous month"></a></td>'+
  91. '<td align="center" width="100%"><font color="#ffffff">'+ARR_MONTHS[dt_current.getMonth()]+' '+dt_current.getFullYear() + '</font></td>'+
  92. '<td><a href="javascript:set_datetime('+dt_next_month.valueOf()+')"><img src="'+STR_ICONPATH+'next.gif" width="16" height="16" border="0" alt="next month"></a>'+(obj_caller && obj_caller.year_scroll?'&nbsp;<a href="javascript:set_datetime('+dt_next_year.valueOf()+')"><img src="'+STR_ICONPATH+'next_year.gif" width="16" height="16" border="0" alt="next year"></a>':'')+'</td>'
  93. );
  94. </script>
  95. </tr>
  96. </table></td></tr>
  97. <tr>
  98. <script language="JavaScript">
  99. // print weekdays titles
  100. for (var n=0; n<7; n++)
  101. document.write('<td bgcolor="#87cefa" align="center"><font color="#ffffff">'+ARR_WEEKDAYS[(NUM_WEEKSTART+n)%7]+'</font></td>');
  102. document.write('</tr>');
  103. // print calendar table
  104. var dt_current_day = new Date(dt_firstday);
  105. while (dt_current_day.getMonth() == dt_current.getMonth() ||
  106. dt_current_day.getMonth() == dt_firstday.getMonth()) {
  107. // print row heder
  108. document.write('<tr>');
  109. for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
  110. if (dt_current_day.getDate() == dt_current.getDate() &&
  111. dt_current_day.getMonth() == dt_current.getMonth())
  112. // print current date
  113. document.write('<td bgcolor="#ffb6c1" align="center" width="14%">');
  114. else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
  115. // weekend days
  116. document.write('<td bgcolor="#dbeaf5" align="center" width="14%">');
  117. else
  118. // print working days of current month
  119. document.write('<td bgcolor="#ffffff" align="center" width="14%">');
  120. document.write('<a href="javascript:set_datetime('+dt_current_day.valueOf() +', true);">');
  121. if (dt_current_day.getMonth() == this.dt_current.getMonth())
  122. // print days of current month
  123. document.write('<font color="#000000">');
  124. else
  125. // print days of other months
  126. document.write('<font color="#606060">');
  127. document.write(dt_current_day.getDate()+'</font></a></td>');
  128. dt_current_day.setDate(dt_current_day.getDate()+1);
  129. }
  130. // print row footer
  131. document.write('</tr>');
  132. }
  133. if (obj_caller && obj_caller.time_comp)
  134. document.write('<form onsubmit="javascript:set_datetime('+dt_current.valueOf()+', true)" name="cal"><tr><td colspan="7" bgcolor="#87CEFA"><font color="White" face="tahoma, verdana" size="2">Time: <input type="text" name="time" value="'+obj_caller.gen_time(this.dt_current)+'" size="8" maxlength="8"></font></td></tr></form>');
  135. </script>
  136. </table></tr></td>
  137. </table>
  138. </body>
  139. </html>