Skip to content

Commit

Permalink
Support for clock with quarantine
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
andOrlando and psvenk committed Oct 24, 2020
1 parent 436b7a5 commit 5f8b28c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 11 deletions.
29 changes: 18 additions & 11 deletions public/js/clock.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
let current_schedule = "regular";
let schedules, logo;
let period_names = {black:[], silver:[]};

Expand All @@ -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.
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
}

27 changes: 27 additions & 0 deletions public/schedule.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
}

0 comments on commit 5f8b28c

Please sign in to comment.