Team:NCHU Taichung/js/extra.js

// fill the month table with column headings

   function day_title(day_name) {
document.write("
" + day_name + "
");
   }
   // fills the month table with numbers
   function fill_table(month, month_length, indexMonth) {
     day = 1;
     // begin the new month table
document.write("
");
     // document.write(""+month+" "+year+"")
     // column headings
document.write("
");
     day_title("Sun");
     day_title("Mon");
     day_title("Tue");
     day_title("Wed");
     day_title("Thu");
     day_title("Fri");
     day_title("Sat");
document.write("
");
     // pad cells before first day of month
document.write("
");
     for (var i = 1; i < start_day; i++) {
       if (start_day > 7) {
       } else {
document.write("
");
       }
     }
     // fill the first week of days
     for (var i = start_day; i < 8; i++) {
       document.write(
"

" + day + "

"
       );
       day++;
     }
document.write("
");
     // fill the remaining weeks
     while (day <= month_length) {
document.write("
");
       for (var i = 1; i <= 7 && day <= month_length; i++) {
         if (day >= 1 && day <= 9) {
document.write("

" + day + "

");
           day++;
         } else {
document.write("

" + day + "

");
           day++;
         }
       }
document.write("
");
       // the first day of the next month
       start_day = i;
     }
document.write("
");
   }