c3d2-web/content/static/script/calendar.js

24 lines
795 B
JavaScript

function hilight_today() {
var now = new Date();
var ClassName = 'today';
var today = document.getElementById( "calendar-" +
now.getFullYear() + "-" +
(now.getMonth() + 1) + "-" +
now.getDate() );
var oldtoday = document.getElementById( document.getElementsByClassName(ClassName)[0].id );
/* Has document fetching completed enough? */
if (today) {
oldtoday.className = oldtoday.className.replace(/\btoday\b/,'');
var td = today.parentNode;
var klass = td.getAttribute('class');
klass = (klass || "") + ' ' + ClassName;
td.setAttribute('class', klass);
} else {
/* Not in calendar yet, retry later: */
window.setTimeout(hilight_today, 100);
}
}
window.setTimeout(hilight_today, 1);