scripts/wiki-lenny/static/common/js/countdown.js
Antoine Durand-Gasselin 3275986a70 [wiki-lenny/static/] ajout des ressources statiques du wiki dans le repo (css)
darcs-hash:20081109214403-bd074-aea913ab711cbdb465ead1d96003dbcf5b52c7c3.gz
2008-11-09 22:44:03 +01:00

45 lines
1.1 KiB
JavaScript

var state = 0; // 0: start; 1: long count; 2: short count; 3: timeout; 4/5: blink
var counter = 0, step = 1, delay = 1;
function countdown() {
// change state if counter is down
if (counter <= 1) {
state += 1
if (state == 1) {
counter = countdown_timeout_min
step = 1
delay = 60000
}
if (state == 2) {
counter = 60
step = 5
delay = step * 1000
}
if (state == 3 || state == 5) {
window.status = countdown_lock_expire
state = 3
counter = 1
step = 1
delay = 500
}
if (state == 4) {
// blink the above text
window.status = " "
counter = 1
delay = 250
}
}
// display changes
if (state < 3) {
var msg
if (state == 1) msg = countdown_lock_mins
if (state == 2) msg = countdown_lock_secs
window.status = msg.replace(/#/, counter)
}
counter -= step
// Set timer for next update
setTimeout("countdown()", delay);
}