From 9bbc30ce4144ea97f44749fde940338de3d2cb57 Mon Sep 17 00:00:00 2001 From: Jason Tarka Date: Wed, 14 Mar 2018 13:26:26 -0400 Subject: [PATCH] Make game start countdown timer count down Rather than being a static number updated on page refresh, the countdown clock will not update itself. This makes for a more interesting display. Using time remaining rather than an absolute time to prevent jittery behaviour at the start, though at the expense of accuracy. --- src/controllers/IndexController.php | 12 +++--- src/static/js/countdown.js | 61 +++++++++++++++++++++++++++++ src/static/js/fb-ctf.js | 4 ++ 3 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 src/static/js/countdown.js diff --git a/src/controllers/IndexController.php b/src/controllers/IndexController.php index 10f9971f..733c8b09 100644 --- a/src/controllers/IndexController.php +++ b/src/controllers/IndexController.php @@ -124,6 +124,7 @@ class="fb-cta cta--yellow"> ); $game = $config_game->getValue(); $next_game = $config_next_game->getValue(); + $remaining = 0; if ($game === '1') { $next_game_text = tr('In Progress'); $countdown = array('--', '--', '--', '--'); @@ -137,6 +138,7 @@ class="fb-cta cta--yellow"> $now = new DateTime('now'); $countdown_diff = $now->diff($game_start); $countdown = explode('-', $countdown_diff->format('%d-%h-%i-%s')); + $remaining = $game_start->getTimestamp() - $now->getTimestamp(); } return
@@ -149,21 +151,21 @@ class=

{$next_game_text}

-