Notegram early calendar template code
This is the code I wrote on my tablet in preparation for making a new template
JavaScript
console.log('-----');
//this function deals with the fact that javascript Date has Sunday as 0
//when the correct way is clearly 6
function unsunday(a, b)
{
if(b == false) //if we do not unsunday, just return the number
{
return a;
}
if(a == 0)
{
return 6;
}
else
{
return a - 1;
}
}
//this function goes in the opposite direction from the first one for printing the weekdays on top
function unsunday2(a, b)
{
if(b == false) //if we do not unsunday, just return the number
{
return a;
}
if(a == 6)
{
return 0;
}
else
{
return a + 1;
}
}
var weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; //hey this might actually work with i18n. pass weekdays to table and we're good
function generateMonthTable(year, month, unsun)
{
var jsMonth = month - 1; //because months are meant to be 1-indexed >:(
var start = unsunday(new Date(year, jsMonth).getDay(), unsun); //day 1 of month
var table = '<table border="2" style="border:1px solid;border-collapse:collapse">';
//list days
table += "<tr>";
for(j = 0; j < 7; j++)
{
table += '<td style="background-color:#bfbfbf;width:120;border:1px solid"><h1 style="font-size:16pt;color:#1e4e79;margin-top:0pt;margin-bottom:0pt">';
table += weekdays[unsunday2(j, unsun)];
table += '</h1></td>';
console.log(weekdays[unsunday2(j, unsun)]);
}
table += "</tr>";
for(i = 1; i < 7; i++) //i = 1 because first row is the day list
{
table += "<tr>";
for(j = 0; j < 7; j++)
{
table += '<td style="width:120;border:1px solid"><h1 style="font-size:16pt;color: #';
//if the month does not match jsMonth, the letters will be grey to indicate
if (new Date( year, jsMonth, calMath(i,j,start) ).getMonth() != jsMonth)
{
console.log(new Date( year, jsMonth, calMath(i,j,start) ).getMonth() + '; ' + jsMonth);
table += 'bfbfbf';
}
else
{
console.log('???')
...