switch scheduler to single day rather than week

This commit is contained in:
Sundog Jones 2024-09-09 10:02:10 -04:00
parent a0e8703a9c
commit 1476a9b2b8

View File

@ -287,9 +287,9 @@
<section id="schedule_pane">
<h2>Schedules</h2>
<section id="schedules_time_range_section">
<button id="previous_week_button">&lt;</button>
<p id="current_week_indicator"></p>
<button id="next_week_button">&gt;</button>
<button id="previous_day_button">&lt;</button>
<span id="current_day_indicator"></span>
<button id="next_day_button">&gt;</button>
</section>
<table id="schedule_grid">
@ -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 <strong>${first_day_of_week.toDateString()}</strong>`;
const current_day_indicator = document.querySelector("#current_day_indicator");
current_week_indicator.innerHTML = `Schedule for <strong>${day_of_schedule.toDateString()}</strong>`;
// 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();
}