From f45aa57693c1565ea201eba495cc05ee67adefe3 Mon Sep 17 00:00:00 2001 From: Azaaxin Date: Mon, 16 Mar 2020 03:43:44 +0100 Subject: [PATCH] added timer --- index.php | 4 +++- scripts/gameboard.js | 1 + scripts/options.js | 4 ++-- scripts/timer.js | 19 +++++++++++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 scripts/timer.js diff --git a/index.php b/index.php index afa884e..404a114 100644 --- a/index.php +++ b/index.php @@ -43,6 +43,7 @@
+
:
Round: 
 Score: 
0
@@ -85,7 +86,7 @@ off
- Disable spinning board + Disable spinning
@@ -99,6 +100,7 @@ + diff --git a/scripts/gameboard.js b/scripts/gameboard.js index e526127..21c40f2 100644 --- a/scripts/gameboard.js +++ b/scripts/gameboard.js @@ -20,6 +20,7 @@ var no_fail_round = 0; var round_values = 0; function initiate() { // Call all the functions + setInterval(setTime, 1000); round_value(); lifes(); prep(); diff --git a/scripts/options.js b/scripts/options.js index bfec0e0..3c5a2cf 100644 --- a/scripts/options.js +++ b/scripts/options.js @@ -21,11 +21,11 @@ function uncheck() { } function check_allowspin() { allow_spin = true; - document.getElementById("button-text-01-spin").innerHTML = "Disable spinning board"; + document.getElementById("button-text-01-spin").innerHTML = "Disable spinning"; } function uncheck_allowspin() { allow_spin = false; - document.getElementById("button-text-01-spin").innerHTML = "Enable spinning board"; + document.getElementById("button-text-01-spin").innerHTML = "Enable spinning"; } function cardspeed(){ viewspeed = document.getElementById("card-speed-number-value").value; diff --git a/scripts/timer.js b/scripts/timer.js new file mode 100644 index 0000000..93876a8 --- /dev/null +++ b/scripts/timer.js @@ -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; + } + } \ No newline at end of file