~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to wiki/htdocs/common/js/countdown.js

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20080622211713-inlv5k4eifxckelr
ImportĀ upstreamĀ versionĀ 1.7.0

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