From 1476a9b2b8704df77fc2018b6dcab6a590dd8a2b Mon Sep 17 00:00:00 2001 From: Sundog Date: Mon, 9 Sep 2024 10:02:10 -0400 Subject: [PATCH] switch scheduler to single day rather than week --- layout.html | 46 +++++++++++----------------------------------- 1 file changed, 11 insertions(+), 35 deletions(-) diff --git a/layout.html b/layout.html index 9455b92..86baa11 100644 --- a/layout.html +++ b/layout.html @@ -287,9 +287,9 @@

Schedules

- -

- + + +
@@ -617,41 +617,17 @@ init_schedules(); }); - const init_schedules = (first_day_of_week) => { - const first_day_of_schedule = new Date(Date.now()); - if (first_day_of_week === undefined) { - const today = new Date(Date.now()).getDay(); - - if (today < 1) { - // today is Sunday, the week started six days ago - first_day_of_schedule.setDate(first_day_of_schedule.getDate() - 6); - } else if (today > 1) { - // monday already passed, go back - offset = today - 1; - first_day_of_schedule.setDate(first_day_of_schedule.getDate() - offset); - } else { - // today is monday, the week has begun! - } - - current_day = first_day_of_schedule; - for (let i = 0; i < 7; i++) { - console.log(current_day.toISOString()); - current_day.setDate(current_day.getDate() + 1); - } - } - - first_day_of_week = first_day_of_week || first_day_of_schedule; - - current_day = first_day_of_week; + const init_schedules = (day) => { + const day_of_schedule = day || new Date(Date.now()); for (let i = 0; i < 8; i++) { if (i === 0) { // first column of schedule, set up the grid - const current_week_indicator = document.querySelector("#current_week_indicator"); - current_week_indicator.innerHTML = `Schedule for the week beginning ${first_day_of_week.toDateString()}`; + const current_day_indicator = document.querySelector("#current_day_indicator"); + current_week_indicator.innerHTML = `Schedule for ${day_of_schedule.toDateString()}`; // set up previous/next buttons - document.querySelector('#previous_week_button').addEventListener("click", previous_week_schedule); - document.querySelector('#next_week_button').addEventListener("click", next_week_schedule); + document.querySelector('#previous_day_button').addEventListener("click", previous_day_schedule); + document.querySelector('#next_day_button').addEventListener("click", next_day_schedule); // init grid structure itself const template = document.querySelector("#schedule_header_row_template"); const template_clone = template.content.cloneNode(true); @@ -666,12 +642,12 @@ } } - const previous_week_schedule = (e) => { + const previous_day_schedule = (e) => { e.preventDefault(); } - const next_week_schedule = (e) => { + const next_day_schedule = (e) => { e.preventDefault(); }