added timer
This commit is contained in:
19
scripts/timer.js
Normal file
19
scripts/timer.js
Normal file
@@ -0,0 +1,19 @@
|
||||
var minutesLabel = document.getElementById("minutes");
|
||||
var secondsLabel = document.getElementById("seconds");
|
||||
var totalSeconds = 0;
|
||||
function setTime() {
|
||||
if(!health == 0){
|
||||
++totalSeconds;
|
||||
secondsLabel.innerHTML = pad(totalSeconds % 60);
|
||||
minutesLabel.innerHTML = pad(parseInt(totalSeconds / 60));
|
||||
}
|
||||
}
|
||||
|
||||
function pad(val) {
|
||||
var valString = val + "";
|
||||
if (valString.length < 2) {
|
||||
return "0" + valString;
|
||||
} else {
|
||||
return valString;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user