forked from jamescun/iPG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.js
85 lines (62 loc) · 1.33 KB
/
functions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* --- Question Functions ---
-------------------------------------------------- */
function next_q()
{
if ( $('#end').hasClass('hide') == true )
{
var question = q.shift();
if (question != 'done')
{
$('#question').html(question);
timer_restart();
display_tip();
} else
{
$('#question').addClass('hide');
$('#timer').addClass('hide');
$('.pg').addClass('hide');
$('#end').removeClass('hide');
}
}
}
/* --- Timer Functions ---
-------------------------------------------------- */
function timer_tick()
{
$('#timer').removeClass('warning');
$('#timer').removeClass('fail');
timer = timer - 1;
$('#timer').html(timer + ' s');
if (timer < 10)
{
$('#timer').addClass('warning');
}
if (timer < 5)
{
$('#timer').removeClass('warning');
$('#timer').addClass('fail');
}
if (timer <= 0)
{
$('#timer').addClass('hide');
$('.pg').removeClass('hide');
}
setTimeout('timer_tick();', 1000);
}
function timer_restart()
{
$('#timer').removeClass('warning');
$('#timer').removeClass('fail');
$('.pg').addClass('hide');
$('#timer').removeClass('hide');
timer = 15;
$('#timer').html('15 s');
}
/* --- Tip Functions ---
-------------------------------------------------- */
function display_tip()
{
var tip = tips.shift();
$('#tip').html(tip);
tips.push(tip);
}