diff --git a/content/static/script/calendar.js b/content/static/script/calendar.js new file mode 100644 index 000000000..992c6ad12 --- /dev/null +++ b/content/static/script/calendar.js @@ -0,0 +1,95 @@ +/** + * + * $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); + } +} + diff --git a/xsl/calendar.xsl b/xsl/calendar.xsl index 7a582c537..59c265cb9 100644 --- a/xsl/calendar.xsl +++ b/xsl/calendar.xsl @@ -77,7 +77,9 @@ - + diff --git a/xsl/header.xsl b/xsl/header.xsl index f0fb2f15a..3dfed1357 100644 --- a/xsl/header.xsl +++ b/xsl/header.xsl @@ -36,6 +36,12 @@ + + + +