-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQ_n_A_CountDown_sc.js
executable file
·109 lines (94 loc) · 2.99 KB
/
Q_n_A_CountDown_sc.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* This countdown script adapted from one available at The JavaScript Source :: http://javascript.internet.com
Original script created by: Neill Broderick :: http://www.bespoke-software-solutions.co.uk/downloads/downjs.php */
var sc_mins;
var sc_secs;
function sc_cd(sc_Minutes, sc_Seconds) {
sc_mins = 1 * sc_m(sc_Minutes); // change minutes here
sc_secs = 0 + sc_s(":"+sc_Seconds); // change seconds here (always add an additional second to your total)
sc_secs++;
sc_CountPause();
}
function sc_reset(sc_Minutes, sc_Seconds) {
sc_mins = 1 * sc_m(sc_Minutes); // change minutes here
sc_secs = 0 + sc_s(":"+sc_Seconds); // change seconds here (always add an additional second to your total)
sc_secs++;
sc_CountPause();
}
function sc_restart(sc_Minutes, sc_Seconds) {
sc_mins = 1 * sc_m(sc_Minutes); // change minutes here
sc_secs = 0 + sc_s(":"+sc_Seconds); // change seconds here (always add an additional second to your total)
sc_secs++;
clearTimeout(sc_cd);
document.sc_cd.sc_cp.value="Pause";
document.getElementById('sc_PauseIndicator').innerHTML=" ";
sc_redo("Count");
}
function sc_m(sc_obj) {
for(var i = 0; i < sc_obj.length; i++) {
if(sc_obj.substring(i, i + 1) == ":")
break;
}
return(sc_obj.substring(0, i));
}
function sc_s(sc_obj) {
for(var i = 0; i < sc_obj.length; i++) {
if(sc_obj.substring(i, i + 1) == ":")
break;
}
return(sc_obj.substring(i + 1, sc_obj.length));
}
function sc_dis(sc_mins,sc_secs) {
var sc_disp;
sc_disp = " ";
sc_disp += sc_mins + ":";
if(sc_secs <= 9) {
sc_disp += "0" + sc_secs;
} else {
sc_disp += sc_secs;
}
return(sc_disp);
}
function sc_ProjDisplay()
{
try
{
Display.document.getElementById('SCReadOut').innerHTML=sc_dis(sc_mins,sc_secs);
}
catch (err)
{
alert(err);
}
}
function sc_redo(paused){
if (paused=="Pause")
{document.getElementById('sc_ReadOut').innerHTML = sc_dis(sc_mins,sc_secs-1); clearTimeout (sc_cd);}
else
{
sc_secs--;
if(sc_secs == -1) {
sc_secs = 59;
sc_mins--;
}
// document.sc_cd.sc_disp.value = sc_dis(sc_mins,sc_secs);
document.getElementById('sc_ReadOut').innerHTML=sc_dis(sc_mins,sc_secs); sc_ProjDisplay();
// setup additional displays here.
if((sc_mins == 0) && (sc_secs == 0)) {
sc_reset(); // change timeout message as required
// window.location = "yourpage.htm" // redirects to specified page once timer ends and ok button is pressed
}
else {
sc_cd = setTimeout("sc_redo('Count')",1000);
}
}
}
function sc_init() {
sc_cd("2","00");
}
function sc_CountPause()
{
if (document.sc_cd.sc_cp.value!="Pause")
{ document.sc_cd.sc_cp.value="Pause"; document.getElementById('sc_PauseIndicator').innerHTML=" "; sc_redo ('Count'); }
else
{ document.sc_cd.sc_cp.value="Count"; document.getElementById('sc_PauseIndicator').innerHTML="Paused"; sc_redo ('Pause'); }
}
window.onload=sc_init();