added timer

This commit is contained in:
2020-03-16 03:43:44 +01:00
parent 3e7d944827
commit f45aa57693
4 changed files with 25 additions and 3 deletions

19
scripts/timer.js Normal file
View 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;
}
}