Template:Team:KULeuven/Notebook/DayNavigator

From 2009.igem.org

(Difference between revisions)
 
(10 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
+
-
*/
+
-
var monthNames = new Array('January', 'February', 'March', 'April', 'May',
+
-
'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 */
+
-
function pageDate() {
+
-
// Retrieve page url
+
-
var urlTokens = location.href.split("/");
+
-
var urlLast = urlTokens[urlTokens.length - 1];
+
-
 
+
-
// Retrieve page date
+
-
var wikiTokens = urlLast.split("#");
+
-
var wikiFirst = wikiTokens[0];
+
-
 
+
-
// Retrieve seperate date components
+
-
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;
+
-
}
+
-
 
+
-
function dateDaysFrom(d, ndays) {
+
-
var newDate = new Date();
+
-
var ntime = d.getTime() + ndays*86400*1000;
+
-
newDate.setTime(ntime);
+
-
return newDate;
+
-
}
+
-
 
+
-
function getWeekMonday(d) {
+
-
var dayOfWeek = d.getDay();
+
-
 
+
-
switch(dayOfWeek) {
+
-
// case 0 is Sunday
+
-
case 0: return dateDaysFrom(d, -6); break;
+
-
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();
+
-
}
+
-
 
+
-
function printLink(d, t) {
+
-
    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();
today = pageDate();
-
dmon = getWeekMonday(today);
+
dmin3 = dateDaysFrom(today, -3);
-
dprev = dateDaysFrom(dmon, -1);
+
dmin2 = dateDaysFrom(today, -2);
-
dtue = dateDaysFrom(dmon, 1);
+
dmin1 = dateDaysFrom(today, -1);
-
dwed = dateDaysFrom(dmon, 2);
+
dplus1 = dateDaysFrom(today, 1);
-
dthu = dateDaysFrom(dmon, 3);
+
dplus2 = dateDaysFrom(today, 2);
-
dfri = dateDaysFrom(dmon, 4);
+
dplus3 = dateDaysFrom(today, 3);
-
dsat = dateDaysFrom(dmon, 5);
+
-
dsun = dateDaysFrom(dmon, 6);
+
-
dnext = dateDaysFrom(dmon, 7);
+
 +
-->
</script>
</script>
Line 95: Line 17:
<table id='NBNav'>
<table id='NBNav'>
<tr>
<tr>
-
<td rowspan=3 class='prev'><script type="text/javascript">printLink(dprev, '&lt;&lt;&lt;');</script></td>
+
<script type="text/javascript">
-
<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, '&gt;&gt;&gt;');</script></td>
+
    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>
<tr>
<tr>
-
<script type="text/javascript">printDayCell(dmon, dmon.getDate(), today);</script>
+
<script type="text/javascript">printDayCell(dmin3, dmin3.getDate(), today);</script>
-
<script type="text/javascript">printDayCell(dtue, dtue.getDate(), today);</script>
+
<script type="text/javascript">printDayCell(dmin2, dmin2.getDate(), today);</script>
-
<script type="text/javascript">printDayCell(dwed, dwed.getDate(), today);</script>
+
<script type="text/javascript">printDayCell(dmin1, dmin1.getDate(), today);</script>
-
<script type="text/javascript">printDayCell(dthu, dthu.getDate(), today);</script>
+
<script type="text/javascript">printDayCell(today, today.getDate(), today);</script>
-
<script type="text/javascript">printDayCell(dfri, dfri.getDate(), today);</script>
+
<script type="text/javascript">printDayCell(dplus1, dplus1.getDate(), today);</script>
-
<script type="text/javascript">printDayCell(dsat, dsat.getDate(), today);</script>
+
<script type="text/javascript">printDayCell(dplus2, dplus2.getDate(), today);</script>
-
<script type="text/javascript">printDayCell(dsun, dsun.getDate(), today);</script>
+
<script type="text/javascript">printDayCell(dplus3, dplus3.getDate(), today);</script>
</tr>
</tr>
<script type="text/javascript">
<script type="text/javascript">
<!--
<!--
-
   if(dmon.getMonth() == dsun.getMonth()) {
+
   m = monthNames[today.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>');
+
   document.write('<tr><th class="center" colspan=7>'+m+'</th></tr>');
-->
-->
</script>
</script>
Line 125: Line 49:
</table>
</table>
</center>
</center>
 +
</html>
</html>

Latest revision as of 09:32, 17 July 2009