Template:Team:Uppsala/JS/notebook

From 2013.igem.org

(Difference between revisions)
(Blanked the page)
Line 1: Line 1:
 +
<script type="text/javascript">
 +
var month = new Date().getMonth(); 
 +
var year = new Date().getFullYear(); 
 +
var cal_table = '';   
 +
var days_in_month = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
 +
 
 +
Date.prototype.getWeek = function()
 +
{
 +
  var onejan = new Date(this.getFullYear(),0,1);
 +
  return Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7);
 +
}
 +
function calendar()
 +
{
 +
  var m = month+1;
 +
  var date = new Date();   
 +
  var today = date.getDate();   
 +
  cal_table = ''; 
 +
 +
  if(year<=200)
 +
  {
 +
    year += 1900;
 +
  }
 +
  months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
 +
  var weekDay = new Array('Mon', 'Tue', 'We', 'Thu', 'Fri', 'Sat', 'Sun');
 +
  days_in_month = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
 +
 
 +
    if(year%4 == 0 && year!=1900)
 +
  {
 +
      days_in_month[1]=29;
 +
    }
 +
 
 +
    total = days_in_month[month];
 +
    var date_today = months[month]+' '+year;
 +
 +
    cal_table = cal_table + '<table class="cal_calendar" ><tbody id="cal_body"><tr class="head"><th class="arrow"><input id="left" type="image" onclick="left_arrow()" src="image/buttons/arrowleft.png"></th><th colspan="6" >'+date_today+'</th><th class="arrow"><input id="right" type="image" onclick="right_arrow()" src="image/buttons/arrowright.png"></th></tr>';
 +
    cal_table = cal_table + '<tr class="cal_d_weeks"><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th><th>Fri</th><th>Sat</th><th>Sun</th><th>Week</th></tr><tr>';
 +
    week = 0;
 +
 
 +
    var first_week_day = new Date(year, month, 0).getDay();
 +
 
 +
    for(week_day = 0; week_day < first_week_day; week_day++)
 +
    {
 +
      cal_table = cal_table +'<td class="cal_days_bef_aft"></td>';
 +
      week++;
 +
    }
 +
   
 +
for(i=1;i<=total;i++)
 +
    {
 +
        if(week==0)
 +
        {
 +
            cal_table = cal_table + '<tr>';
 +
        }
 +
   
 +
        if(today==i && month == date.getMonth() && year == date.getFullYear())
 +
        {
 +
            cal_table = cal_table +'<td id="'+'t'+year+m+i+'" class="cal_today"><input type="submit" onclick="" value="'+i+'"></td>';
 +
        }
 +
   
 +
        else
 +
        {
 +
            cal_table = cal_table +'<td id="'+'t'+year+m+i+'" class="not_today"><input type="submit" onclick="" value="'+i+'"></td>';
 +
        }
 +
   
 +
        week++;
 +
        if(week==7)
 +
        {
 +
  var weeknr = new Date(year, month, i-1).getWeek();
 +
  cal_table = cal_table + '<td class="week"><input type="submit" onclick="" value="'+weeknr+'"></td>';
 +
        cal_table = cal_table + '</tr>';   
 +
  week=0;
 +
        }
 +
   
 +
        }
 +
 
 +
        for(i=1;week!=0;i++)
 +
        {
 +
                cal_table = cal_table + '<td class="cal_days_bef_aft"></td>';
 +
                week++;
 +
   
 +
                if(week==7)
 +
                { 
 +
      if(weeknr == 53)
 +
      {
 +
      var weeknr = 1;
 +
      }
 +
      else
 +
      {
 +
      var weeknr = weeknr+1;
 +
      }
 +
      cal_table = cal_table + '<td class="week"><input type="submit" onclick="" value="'+weeknr+'"></td>';
 +
                        cal_table = cal_table + '</tr>';
 +
                        week=0;
 +
                }
 +
        }
 +
        cal_table = cal_table + '</tbody></table>';
 +
}
 +
 +
</script>

Revision as of 11:22, 25 August 2013

<script type="text/javascript"> var month = new Date().getMonth(); var year = new Date().getFullYear(); var cal_table = ; var days_in_month = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

Date.prototype.getWeek = function() {

 var onejan = new Date(this.getFullYear(),0,1);
 return Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7);

}

function calendar() {

 var m = month+1;
 var date = new Date();    
 var today = date.getDate();     
 cal_table = ;  
  if(year<=200)
  {
   year += 1900;
  } 
  months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
  var weekDay = new Array('Mon', 'Tue', 'We', 'Thu', 'Fri', 'Sat', 'Sun');
  days_in_month = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
  
    if(year%4 == 0 && year!=1900)
 {
     days_in_month[1]=29;
    }
  
   total = days_in_month[month];
   var date_today = months[month]+' '+year;

cal_table = cal_table + '<tbody id="cal_body">'; cal_table = cal_table + '';
   week = 0;
 
   var first_week_day = new Date(year, month, 0).getDay();
 
   for(week_day = 0; week_day < first_week_day; week_day++) 
   {
cal_table = cal_table +'';
     week++;
   }
   
for(i=1;i<=total;i++)
   {
       if(week==0)
       {
cal_table = cal_table + ''; } if(today==i && month == date.getMonth() && year == date.getFullYear()) { cal_table = cal_table +'';
       }
   
       else
       {
cal_table = cal_table +'';
       }
   
       week++;
       if(week==7)
       {
 var weeknr = new Date(year, month, i-1).getWeek();
cal_table = cal_table + ''; cal_table = cal_table + ''; week=0; } } for(i=1;week!=0;i++) { cal_table = cal_table + '';
               week++;
   
               if(week==7)
               {  
     if(weeknr == 53)
     {
     var weeknr = 1;
     }
     else
     {
     var weeknr = weeknr+1;
     }
cal_table = cal_table + '';
                       cal_table = cal_table + '</tr>';
                       week=0;
               }
       }
cal_table = cal_table + '</tbody>
<input id="left" type="image" onclick="left_arrow()" src="image/buttons/arrowleft.png">'+date_today+'<input id="right" type="image" onclick="right_arrow()" src="image/buttons/arrowright.png">
MonTueWedThuFriSatSunWeek
<input type="submit" onclick="" value="'+i+'"><input type="submit" onclick="" value="'+i+'"><input type="submit" onclick="" value="'+weeknr+'">
<input type="submit" onclick="" value="'+weeknr+'">
';
}

</script>