‘,
calendar:’

{days}
Su Mo Tu We Th Fr Sa

‘,
week:’

{week}

‘,
dayClickable:’

{date}

‘,
dayCurrent:’

{date}

‘,
dayNone:’

‘,
day:’

{date}

‘,
search:”
},

// Stored objects
$container = $(loc),
now = new Date(),
current = now,
minDate = new Date(’12/5/2007′),
station = wng_pageInfo.affiliateName||’kotv’,
months = [‘January’, ‘February’, ‘March’, ‘April’, ‘May’, ‘June’, ‘July’, ‘August’, ‘September’, ‘October’, ‘November’, ‘December’],
monthLengths = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],

// Helper methods
renderTemplate = function(tpl, vars) {
var retVal = templates[tpl];
if (typeof(retVal) === ‘string’) {
for (var i in vars) {
var regEx = new RegExp(‘{‘ + i + ‘}’, ‘g’);
retVal = retVal.replace(regEx, vars[i]);
}
} else {
retVal = null;
}
return retVal;
},

// Renderers
makeCalendar = function(date) {

// Copy the date to a new object (so as not to overwrite the original) and set us to the beginning of the month
date = new Date(date);
date.setDate(1);
current = date;

var
month = date.getMonth(),
year = date.getFullYear(),
firstDay = date.getDay(),
out = ”,
days = ”,
colCount = 0,
monthLength = monthLengths[month] + (month == 1 && year % 4 == 0 ? 2 : 1); // Figure up the month length taking into consideration leap years. Not accurate to 100+ years

// Render the days before the start of the month if necessary
for (var i = 0; i = minDate) {
tpl = ‘dayClickable’;
}
days += renderTemplate(tpl, {date:i});
colCount++;
if (colCount % 7 == 0) {
out += renderTemplate(‘week’, {week:days});
days = ”;
}
}

// Tack on the last week
if (days != ”) {
out += renderTemplate(‘week’, {week:days});
}

// Render to the DOM
out = renderTemplate(‘calendar’, {days:out});
out = renderTemplate(‘controls’, {month:months[month], year:year}) + out + templates.search;
$container.html(out);

// Determine whether the previous/next buttons should be shown
date.setDate(1);
if (date 12) {
month = 1;
year++;
}
makeCalendar(new Date(month + ‘/1/’ + year));
}
},

// Init
init = function() {
$container.addClass(‘gnmCalendar’);
makeCalendar(now);
};

init();

};

Go to Source

Capitol Week In Review: Budget Talks, Medicaid Benefits