From 5f8b28cc9e6fa9dd6ecdecb7ad2e9de825b87856 Mon Sep 17 00:00:00 2001 From: Bennett Gillig Date: Fri, 23 Oct 2020 14:49:29 -0400 Subject: [PATCH] Support for clock with quarantine Adds "covid" option to schedule.json and changes clock.js to use the quarantine schedule Co-authored-by: psvenk <45520974+psvenk@users.noreply.github.com> --- public/js/clock.js | 29 ++++++++++++++++++----------- public/schedule.json | 27 +++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 11 deletions(-) diff --git a/public/js/clock.js b/public/js/clock.js index 1283eeb2..c2e7fbb3 100755 --- a/public/js/clock.js +++ b/public/js/clock.js @@ -1,4 +1,3 @@ -let current_schedule = "regular"; let schedules, logo; let period_names = {black:[], silver:[]}; @@ -16,6 +15,10 @@ large_ctx.translate(large_radius, large_radius); logo = document.getElementById("logo"); +// Controls whether to use the covid-19 schedule or the regular schedule +const covid_schedule = true; +let current_schedule = covid_schedule ? "covid" : "regular"; + // For testing. // If this is set to a valid date/time string, that will be used instead of the // current date and time. @@ -109,15 +112,20 @@ function fitText(ctx, text, fontface, width) { } function update_lunch() { - switch(Number(document.getElementById("lunch_range").value)) { - case 0: - current_schedule = "regular-a"; - break; - case 1: - current_schedule = "regular-b"; - break; - case 2: - current_schedule = "regular-c"; + if (covid_schedule) { + current_schedule = "covid"; + } + else { + switch(Number(document.getElementById("lunch_range").value)) { + case 0: + current_schedule = "regular-a"; + break; + case 1: + current_schedule = "regular-b"; + break; + case 2: + current_schedule = "regular-c"; + } } redraw_clock(); } @@ -245,4 +253,3 @@ function redraw_clock() { drawHand(large_ctx, large_radius, pos, large_radius * .94, large_radius * .095); drawNumber(large_ctx, large_radius, pos, number); } - diff --git a/public/schedule.json b/public/schedule.json index c792b0c3..5d5cc9fd 100755 --- a/public/schedule.json +++ b/public/schedule.json @@ -136,5 +136,32 @@ "start": 47400000, "end": 52200000 } + ], + "covid":[ + { + "name":"Period 1", + "start": 33000000, + "end": 36000000 + }, + { + "name":"Period 2", + "start": 36600000, + "end": 39600000 + }, + { + "name":"Period 3", + "start": 40200000, + "end": 43200000 + }, + { + "name":"Lunch", + "start": 43200000, + "end": 46800000 + }, + { + "name":"Period 4", + "start": 46800000, + "end": 49800000 + } ] }