~ubuntu-it-wiki/wiki-ubuntu-it/wiki-repo

« back to all changes in this revision

Viewing changes to htdocs/light/js/countdown.js

  • Committer: Leo Iannacone
  • Date: 2011-06-01 19:48:26 UTC
  • Revision ID: l3on@ubuntu.com-20110601194826-a8zt6and1d9gqmfu
Update light theme to ubuntu-it style

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
var state = 0; // 0: start; 1: long count; 2: short count; 3: timeout; 4/5: blink
 
2
var counter = 0, step = 1, delay = 1;
 
3
 
 
4
function countdown() {
 
5
    // change state if counter is down
 
6
    if (counter <= 1) {
 
7
        state += 1
 
8
        if (state == 1) {
 
9
            counter = countdown_timeout_min
 
10
            step = 1
 
11
            delay = 60000
 
12
        }
 
13
        if (state == 2) {
 
14
            counter = 60
 
15
            step = 5
 
16
            delay = step * 1000
 
17
        }
 
18
        if (state == 3 || state == 5) {
 
19
            window.status = countdown_lock_expire
 
20
            state = 3
 
21
            counter = 1
 
22
            step = 1
 
23
            delay = 500
 
24
        }
 
25
        if (state == 4) {
 
26
            // blink the above text
 
27
            window.status = " "
 
28
            counter = 1
 
29
            delay = 250
 
30
        }
 
31
    }
 
32
 
 
33
    // display changes
 
34
    if (state < 3) {
 
35
        var msg
 
36
        if (state == 1) msg = countdown_lock_mins
 
37
        if (state == 2) msg = countdown_lock_secs
 
38
        window.status = msg.replace(/#/, counter)
 
39
    }
 
40
    counter -= step
 
41
 
 
42
    // Set timer for next update
 
43
    setTimeout("countdown()", delay);    
 
44
}
 
45