Template:Team:KULeuven/Notebook/DayNavigator
From 2009.igem.org
(Difference between revisions)
(New page: <html> <script type="text/javascript"> - →* @author KULeuven: var monthNames = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October',...) |
|||
Line 7: | Line 7: | ||
'June', 'July', 'August', 'September', 'October', 'November', 'December'); | 'June', 'July', 'August', 'September', 'October', 'November', 'December'); | ||
- | + | var dayNames = new Array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'); | |
+ | |||
+ | |||
/* Extracts the corresponding calendar date out of the page url */ | /* Extracts the corresponding calendar date out of the page url */ | ||
Line 36: | Line 38: | ||
} | } | ||
- | + | function dateDaysFrom(d, ndays) { | |
- | function | + | var newDate = new Date(); |
- | var | + | var ntime = d.getTime() + ndays*86400*1000; |
- | + | newDate.setTime(ntime); | |
- | var ntime = | + | return newDate; |
- | + | ||
- | + | ||
- | return | + | |
} | } | ||
- | + | function getWeekMonday(d) { | |
- | function | + | var dayOfWeek = d.getDay(); |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | var dayOfWeek = | + | |
- | + | ||
switch(dayOfWeek) { | switch(dayOfWeek) { | ||
- | // case 0 is Sunday | + | // case 0 is Sunday |
- | case 0: | + | case 0: return dateDaysFrom(d, -6); break; |
- | default: | + | default: return dateDaysFrom(d, -dayOfWeek + 1); break; |
} | } | ||
- | |||
- | |||
} | } | ||
- | |||
- | |||
- | |||
- | |||
- | + | function printDate(d) { | |
- | + | document.write(d.toUTCString()); | |
- | + | document.write('<br>'); | |
- | + | } | |
- | + | ||
- | + | function getLink(d) { | |
+ | return d.getDate() + '_' + monthNames[d.getMonth()] + '_' + d.getFullYear() + '.html'; | ||
} | } | ||
- | + | function printLink(d, t) { | |
- | function | + | document.write('<a href="'+getLink(d)+'">'+t+'</a>'); |
- | + | } | |
- | + | ||
- | + | function printDayCell(d,t, tod) { | |
- | + | document.write('<td class="'+dayNames[d.getDay()]) | |
- | + | if(d.getDay() == tod.getDay()) { | |
- | + | document.write(' selected'); | |
- | + | } | |
- | + | document.write('">'); | |
- | + | printLink(d,t); | |
- | + | document.write('</td>'); | |
- | + | ||
} | } | ||
- | + | today = pageDate(); | |
- | + | dmon = getWeekMonday(today); | |
- | + | dprev = dateDaysFrom(dmon, -1); | |
- | + | dtue = dateDaysFrom(dmon, 1); | |
- | + | dwed = dateDaysFrom(dmon, 2); | |
- | + | dthu = dateDaysFrom(dmon, 3); | |
- | + | dfri = dateDaysFrom(dmon, 4); | |
- | + | dsat = dateDaysFrom(dmon, 5); | |
- | + | dsun = dateDaysFrom(dmon, 6); | |
- | + | dnext = dateDaysFrom(dmon, 7); | |
- | + | ||
- | + | ||
- | + | ||
</script> | </script> | ||
<center> | <center> | ||
- | <table | + | <table id='NBNav'> |
- | <tr | + | <tr> |
- | <td | + | <td rowspan=3 class='prev'><script type="text/javascript">printLink(dprev, '<<<');</script></td> |
- | < | + | <th>Mon</th> <th>Tue</th> <th>Wed</th> <th>Thu</th> <th>Fri</th> <th>Sat</th> <th>Sun</th> |
- | < | + | <td rowspan=3 class='next'><script type="text/javascript">printLink(dnext, '>>>');</script></td> |
- | <td | + | |
</tr> | </tr> | ||
+ | <tr> | ||
+ | <script type="text/javascript">printDayCell(dmon, dmon.getDate(), today);</script> | ||
+ | <script type="text/javascript">printDayCell(dtue, dtue.getDate(), today);</script> | ||
+ | <script type="text/javascript">printDayCell(dwed, dwed.getDate(), today);</script> | ||
+ | <script type="text/javascript">printDayCell(dthu, dthu.getDate(), today);</script> | ||
+ | <script type="text/javascript">printDayCell(dfri, dfri.getDate(), today);</script> | ||
+ | <script type="text/javascript">printDayCell(dsat, dsat.getDate(), today);</script> | ||
+ | <script type="text/javascript">printDayCell(dsun, dsun.getDate(), today);</script> | ||
+ | </tr> | ||
+ | |||
+ | <script type="text/javascript"> | ||
+ | <!-- | ||
+ | if(dmon.getMonth() == dsun.getMonth()) { | ||
+ | m1 = ""; | ||
+ | m2 = monthNames[dmon.getMonth()]; | ||
+ | } else { | ||
+ | m1 = monthNames[dmon.getMonth()]; | ||
+ | m2 = monthNames[dsun.getMonth()]; | ||
+ | } | ||
+ | |||
+ | document.write('<tr><th class="left" colspan=4>'+m1+'</th><th class="right" colspan=3>'+m2+'</th></tr>'); | ||
+ | --> | ||
+ | </script> | ||
+ | |||
</table> | </table> | ||
</center> | </center> | ||
- | |||
</html> | </html> |
Revision as of 09:51, 9 July 2009
Mon | Tue | Wed | Thu | Fri | Sat | Sun | ||
---|---|---|---|---|---|---|---|---|