|
|
(12 intermediate revisions not shown) |
Line 1: |
Line 1: |
| <html> | | <html> |
| + | <script type="text/javascript" src="https://2009.igem.org/wiki/index.php?title=Template:Team:KULeuven/Common/JSLibrary&action=raw"></script> |
| <script type="text/javascript"> | | <script type="text/javascript"> |
- | /*
| + | <!-- |
- | * @author KULeuven
| + | today = pageDate(); |
- | */
| + | dmin3 = dateDaysFrom(today, -3); |
- | var monthNames = new Array('January', 'February', 'March', 'April', 'May',
| + | dmin2 = dateDaysFrom(today, -2); |
- | 'June', 'July', 'August', 'September', 'October', 'November', 'December');
| + | dmin1 = dateDaysFrom(today, -1); |
| + | dplus1 = dateDaysFrom(today, 1); |
| + | dplus2 = dateDaysFrom(today, 2); |
| + | dplus3 = dateDaysFrom(today, 3); |
| | | |
- | document.write(pageDate().toString().substring(0,11));
| + | --> |
| + | </script> |
| | | |
- | /* Extracts the corresponding calendar date out of the page url */ | + | <center> |
- | function pageDate() {
| + | <table id='NBNav'> |
- | // Retrieve page url
| + | <tr> |
- | var urlTokens = location.href.split("/");
| + | <script type="text/javascript"> |
- | var urlLast = urlTokens[urlTokens.length - 1];
| + | <!-- |
| + | document.write("<th class='"+dayNames[dmin3.getDay()]+"'>"+dayNames[dmin3.getDay()]+"</th>"); |
| + | document.write("<th class='"+dayNames[dmin2.getDay()]+"'>"+dayNames[dmin2.getDay()]+"</th>"); |
| + | document.write("<th class='"+dayNames[dmin1.getDay()]+"'>"+dayNames[dmin1.getDay()]+"</th>"); |
| + | document.write("<th class='"+dayNames[today.getDay()]+"'>"+dayNames[today.getDay()]+"</th>"); |
| + | document.write("<th class='"+dayNames[dplus1.getDay()]+"'>"+dayNames[dplus1.getDay()]+"</th>"); |
| + | document.write("<th class='"+dayNames[dplus2.getDay()]+"'>"+dayNames[dplus2.getDay()]+"</th>"); |
| + | document.write("<th class='"+dayNames[dplus3.getDay()]+"'>"+dayNames[dplus3.getDay()]+"</th>"); |
| + | --> |
| + | </script> |
| + | </tr> |
| + | <tr> |
| + | <script type="text/javascript">printDayCell(dmin3, dmin3.getDate(), today);</script> |
| + | <script type="text/javascript">printDayCell(dmin2, dmin2.getDate(), today);</script> |
| + | <script type="text/javascript">printDayCell(dmin1, dmin1.getDate(), today);</script> |
| + | <script type="text/javascript">printDayCell(today, today.getDate(), today);</script> |
| + | <script type="text/javascript">printDayCell(dplus1, dplus1.getDate(), today);</script> |
| + | <script type="text/javascript">printDayCell(dplus2, dplus2.getDate(), today);</script> |
| + | <script type="text/javascript">printDayCell(dplus3, dplus3.getDate(), today);</script> |
| + | </tr> |
| | | |
- | // Retrieve page date
| + | <script type="text/javascript"> |
- | var wikiTokens = urlLast.split("#");
| + | <!-- |
- | var wikiFirst = wikiTokens[0];
| + | m = monthNames[today.getMonth()]; |
| | | |
- | // Retrieve seperate date components
| + | document.write('<tr><th class="center" colspan=7>'+m+'</th></tr>'); |
- | var dateTokens = wikiFirst.split("_");
| + | --> |
- | | + | |
- | var day = parseInt(dateTokens[0]);
| + | |
- | var month;
| + | |
- | for (x in monthNames) {
| + | |
- | if(dateTokens[1] == monthNames[x]) {month = x; break;}
| + | |
- | }
| + | |
- | var year = parseInt(dateTokens[2]);
| + | |
- | | + | |
- | // Construct a Date object and return the result
| + | |
- | var date = new Date();
| + | |
- | date.setFullYear(year, month, day);
| + | |
- | | + | |
- | return date;
| + | |
- | }
| + | |
- | | + | |
- | /* Retrieves date ndays before this page date */
| + | |
- | function datePast(ndays) {
| + | |
- | var pastDate = new Date();
| + | |
- | // getDate, setDate methods are rubbish, stick to numeric substraction!
| + | |
- | var ntime = pageDate().getTime() - ndays*86400*1000;
| + | |
- | pastDate.setTime(ntime);
| + | |
- | | + | |
- | return pastDate;
| + | |
- | }
| + | |
- | | + | |
- | /* Searches date ndays after this page date */
| + | |
- | function dateFuture(ndays) {
| + | |
- | var futureDate = new Date();
| + | |
- | // getDate, setDate methods are rubbish, stick to numeric adding!
| + | |
- | var ntime = pageDate().getTime() + ndays*86400*1000;
| + | |
- | futureDate.setTime(ntime);
| + | |
- | | + | |
- | return futureDate;
| + | |
- | }
| + | |
- | | + | |
- | /* Returns the date of Friday previous week */
| + | |
- | function previousWeekFriday() {
| + | |
- | var dayOfWeek = pageDate().getDay();
| + | |
- | var previousWeekFriday = new Date();
| + | |
- | | + | |
- | switch(dayOfWeek) {
| + | |
- | // case 0 is Sunday, substract 9 days
| + | |
- | case 0: previousWeekFriday = datePast(9); break;
| + | |
- | default: previousWeekFriday = datePast(dayOfWeek + 2); break;
| + | |
- | }
| + | |
- | | + | |
- | return previousWeekFriday;
| + | |
- | }
| + | |
- | | + | |
- | /* Returns the date of Monday next week */ | + | |
- | function nextWeekMonday() {
| + | |
- | var dayOfWeek = pageDate().getDay();
| + | |
- | var nextWeekMonday = new Date();
| + | |
- | | + | |
- | switch(dayOfWeek) {
| + | |
- | // case 0 is Sunday, add 1 day
| + | |
- | case 0: nextWeekMonday = dateFuture(1); break;
| + | |
- | default: nextWeekMonday = dateFuture(8 - dayOfWeek); break;
| + | |
- | }
| + | |
- | | + | |
- | return nextWeekMonday;
| + | |
- | }
| + | |
- | | + | |
- | /* Returns the date of Friday this week */
| + | |
- | function thisFriday() {
| + | |
- | var dayOfWeek = pageDate().getDay();
| + | |
- | var thisFriday;
| + | |
- | | + | |
- | switch(dayOfWeek) {
| + | |
- | // case 0 is Sunday, substract 2 days
| + | |
- | case 0: thisFriday = datePast(2); break;
| + | |
- | // case 6 is Saturday, substract 1 day, can also be merged into default, in which case we look -1 day // ahead, corresponding to going 1 day back in the past
| + | |
- | case 6: thisFriday = datePast(1); break;
| + | |
- | default: thisFriday = dateFuture(5 - dayOfWeek); break;
| + | |
- | }
| + | |
- | | + | |
- | return thisFriday;
| + | |
- | }
| + | |
- | | + | |
- | /* Converts a date into a valid url for the KULeuven wiki and loads the page */
| + | |
- | function goToDate(date) {
| + | |
- | // base wiki url of KULeuven
| + | |
- | var URL = "https://2009.igem.org/Team:KULeuven/";
| + | |
- | URL += date.getDate();
| + | |
- | URL += '_';
| + | |
- | // month indexing of Date object index matching to array monthNames indexing
| + | |
- | URL += monthNames[date.getMonth()];
| + | |
- | URL += '_';
| + | |
- | URL += date.getFullYear();
| + | |
- | // redirect browser to desired day
| + | |
- | window.location.href = URL;
| + | |
- | }
| + | |
| </script> | | </script> |
| | | |
- | <center>
| |
- | <table width="70%">
| |
- | <tr align="center">
| |
- | <td align="left" width="25%"><a href="javascript:void(0);" onClick="goToDate(previousWeekFriday());">< previous friday</a></td>
| |
- | <td width="25%"><a href="javascript:void(0);" onClick="goToDate(datePast(1));">← yesterday</a></td>
| |
- | <td width="25%"><a href="javascript:void(0);" onClick="goToDate(dateFuture(1));">tomorrow →</a></td>
| |
- | <td align="right" width="25%"><a href="javascript:void(0);" onClick="goToDate(nextWeekMonday());">next monday ></a></td>
| |
- | </tr>
| |
| </table> | | </table> |
| </center> | | </center> |
| | | |
| </html> | | </html> |