96 lines
1.9 KiB
JavaScript
96 lines
1.9 KiB
JavaScript
/**
|
|
*
|
|
* $Id$
|
|
*
|
|
* This script waits for the document to be loaded,
|
|
* then seeks the right table cell for today's date
|
|
* and changes it's background color.
|
|
*
|
|
* Fading is just an additional effect.
|
|
*
|
|
**/
|
|
|
|
set_hilight_timer();
|
|
|
|
function set_hilight_timer()
|
|
{
|
|
window.setTimeout(hilight_today, 50);
|
|
}
|
|
|
|
function hilight_today()
|
|
{
|
|
/* Has document fetching completed enough? */
|
|
if (document.getElementById("upcoming"))
|
|
{
|
|
var now = new Date();
|
|
var today_id = "calendar-" +
|
|
now.getFullYear() + "-" +
|
|
(now.getMonth() + 1) + "-" +
|
|
now.getDate();
|
|
|
|
var today = document.getElementById(today_id);
|
|
|
|
var td = today.parentNode;
|
|
if (td)
|
|
{
|
|
td.style.backgroundColor = "#ebc63c";
|
|
td.style.backgroundColor = "black";
|
|
fade_td(td, 0, 100);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
/* No calendar, continue waiting */
|
|
window.setTimeout(hilight_today, 100);
|
|
}
|
|
}
|
|
|
|
function fade_td(td, step, interval)
|
|
{
|
|
var colors = new Array(
|
|
"#edece5",
|
|
"#edece7",
|
|
"#edebe1",
|
|
"#ede9db",
|
|
"#ede8d5",
|
|
"#ede7cf",
|
|
"#ede5c9",
|
|
"#ede4c3",
|
|
"#ede2bc",
|
|
"#ede1b6",
|
|
"#ece0b0",
|
|
"#ecdeaa",
|
|
"#ecdda4",
|
|
"#ecdc9e",
|
|
"#ecda98",
|
|
"#ecd991",
|
|
"#ecd78b",
|
|
"#ecd685",
|
|
"#ecd57f",
|
|
"#ecd379",
|
|
"#ebd273",
|
|
"#ebd16d",
|
|
"#ebcf66",
|
|
"#ebce60",
|
|
"#ebcc5a",
|
|
"#ebcb54",
|
|
"#ebca4e",
|
|
"#ebc848",
|
|
"#ebc742",
|
|
"#ebc63c");
|
|
|
|
td.style.backgroundColor = colors[step];
|
|
var next_step = step + 1;
|
|
if (next_step < colors.length)
|
|
{
|
|
/* These three lines feature two techniques:
|
|
* * lambda
|
|
* * tail-recursive
|
|
*/
|
|
window.setTimeout(function() {
|
|
fade_td(td, next_step, interval);
|
|
}, interval);
|
|
}
|
|
}
|
|
|