var headerColor = "midnightblue" // color of table's header var headerSize = "-1" // size of tables header font var colWidth = 50// width of columns in table var dayCellHeight = 10 // height of cells containing days of the week var dayColor = "ffae88" // color of font representing week days var cellHeight = 20// height of cells representing dates in the calendar var todayColor = "red" // color specifying today's date in the calendar var timeColor = "purple" // color of font representing current time
// create basic table structure var text = "" // initialize accumulative variable to empty string text += '<CENTER>' text += '<TABLE BORDER=0' + ' CELLSPACING=0' + 'style="font-size: 9pt">' // table settings text += '<TH COLSPAN=7 HEIGHT=' + '>' // create table header cell text += '' // set font for table header
text += '' // close table header's font settings text += '</TH>' // close header cell
// variables to hold constant settings var openCol = '<TD WIDTH=' + colWidth + ' HEIGHT=' + dayCellHeight + '>' openCol += '<FONT COLOR="' + dayColor + '">' var closeCol = '</FONT></TD>'
// create array of abbreviated day names var weekDay = new Array(7) weekDay[0] = "日" weekDay[1] = "一" weekDay[2] = "二" weekDay[3] = "三" weekDay[4] = "四" weekDay[5] = "五" weekDay[6] = "六"
// create first row of table to set column width and specify week day text += '<TR bgcolor="black" ALIGN="center" VALIGN="center" style="font-size: 9pt">' for (var dayNum = 0; dayNum < 7; ++dayNum) { text += openCol + weekDay[dayNum] + closeCol } text += '</TR>'
// declaration and initialization of two variables to help with tables var digit = 1 var curCell = 1
for (var row = 1; row <= Math.ceil((lastDate + firstDay - 1) / 7); ++row) { text += '<TR ALIGN="right" VALIGN="top" style="font-size: 9pt">' for (var col = 1; col <= 7; ++col) { if (digit > lastDate) break if (curCell < firstDay) { text += '<TD></TD>'; curCell++ } else { if (digit == date) { // current cell represent today's date text += '<TD HEIGHT=1>' text += '<FONT COLOR="' + todayColor + '">' text += digit text += '</FONT><BR>' text += '<FONT COLOR="' + timeColor + '" SIZE=2 style="font-size: 9pt">' text += '<CENTER>' + '</CENTER>' text += '</FONT>' text += '</TD>' } else text += '<TD HEIGHT=' + cellHeight + '>' + digit + '</TD>' digit++ } } text += '</TR>' }
// close all basic table tags text += '</TABLE>' text += '</CENTER>'
// print accumulative HTML string document.write(text) }