forked from stfc2/UI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstgc2.js
73 lines (60 loc) · 2.6 KB
/
stgc2.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
function start() {
for ( var i = 1; i <= 10; i++ ) {
if ( document.getElementById( "timer"+i )) {
var params = document.getElementById( "timer"+i ).title.split( "_" );
var time = parseInt( params[1] );
var type = params[3];
timer( "timer"+i, time, type );
}
}
}
function timer( timer, time, type ) {
var t = time;
if ( t > 0 ) {
var h = Math.floor( t / 3600 );
var m = Math.floor( ( t - h * 3600 ) / 60 );
var s = t - h * 3600 - m * 60;
if ( type == 1 ) {
if ( h == 0 ) h = "";
else h = h + " Stunden ";
if ( m == 0 && h == 0 ) m = "";
else m = m + " Minuten ";
if ( s == 0 && m == 0 && h == 0 ) s = "";
else s = s + " Sekunden";
document.getElementById( timer ).firstChild.nodeValue = h + m + s;
}
else if ( type == 2 ) {
if ( m < 10 ) m = "0" + m;
if ( s < 10 ) s = "0" + s;
document.getElementById( timer ).firstChild.nodeValue = h + ":" + m + ":" + s;
}
else if ( type == 3 ) {
if ( h == 0 ) h = "";
else h = h + " Stunden ";
if ( m == 0 && h == 0 ) m = "";
else m = m + " Minuten ";
if ( s == 0 && m == 0 && h == 0 ) s = "";
else s = s + " Sekunden";
document.getElementById( timer ).firstChild.nodeValue = h + m + s;
}
else if ( type == 4 ) {
if ( m < 10 ) m = "0" + m;
if ( s < 10 ) s = "0" + s;
document.getElementById( timer ).firstChild.nodeValue = h + ":" + m + ":" + s;
}
else if ( type == 5 ) {
if ( m < 10 ) m = "0" + m;
if ( s < 10 ) s = "0" + s;
document.getElementById( timer ).firstChild.nodeValue = h + ":" + m + ":" + s;
}
var time = t - 1;
window.setTimeout( 'timer( "'+timer+'", "'+time+'", "'+type+'" )', 1000 );
}
else {
if ( type == 1 ) document.getElementById( timer ).firstChild.nodeValue= "Fertiggestellt";
else if ( type == 2 ) document.getElementById( timer ).firstChild.nodeValue= "0:00:00";
else if ( type == 3 ) window.setTimeout( 'timer( "'+timer+'", "180", "'+type+'" )', 1000 );
else if ( type == 4 ) window.setTimeout( 'timer( "'+timer+'", "180", "'+type+'" )', 1000 );
else if ( type == 5 ) document.getElementById( timer ).firstChild.nodeValue= "Fertig";
}
}