switch scheduler to single day rather than week
This commit is contained in:
parent
a0e8703a9c
commit
1476a9b2b8
46
layout.html
46
layout.html
@ -287,9 +287,9 @@
|
|||||||
<section id="schedule_pane">
|
<section id="schedule_pane">
|
||||||
<h2>Schedules</h2>
|
<h2>Schedules</h2>
|
||||||
<section id="schedules_time_range_section">
|
<section id="schedules_time_range_section">
|
||||||
<button id="previous_week_button"><</button>
|
<button id="previous_day_button"><</button>
|
||||||
<p id="current_week_indicator"></p>
|
<span id="current_day_indicator"></span>
|
||||||
<button id="next_week_button">></button>
|
<button id="next_day_button">></button>
|
||||||
</section>
|
</section>
|
||||||
<table id="schedule_grid">
|
<table id="schedule_grid">
|
||||||
|
|
||||||
@ -617,41 +617,17 @@
|
|||||||
init_schedules();
|
init_schedules();
|
||||||
});
|
});
|
||||||
|
|
||||||
const init_schedules = (first_day_of_week) => {
|
const init_schedules = (day) => {
|
||||||
const first_day_of_schedule = new Date(Date.now());
|
const day_of_schedule = day || 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;
|
|
||||||
|
|
||||||
for (let i = 0; i < 8; i++) {
|
for (let i = 0; i < 8; i++) {
|
||||||
if (i === 0) {
|
if (i === 0) {
|
||||||
// first column of schedule, set up the grid
|
// first column of schedule, set up the grid
|
||||||
const current_week_indicator = document.querySelector("#current_week_indicator");
|
const current_day_indicator = document.querySelector("#current_day_indicator");
|
||||||
current_week_indicator.innerHTML = `Schedule for the week beginning <strong>${first_day_of_week.toDateString()}</strong>`;
|
current_week_indicator.innerHTML = `Schedule for <strong>${day_of_schedule.toDateString()}</strong>`;
|
||||||
// set up previous/next buttons
|
// set up previous/next buttons
|
||||||
document.querySelector('#previous_week_button').addEventListener("click", previous_week_schedule);
|
document.querySelector('#previous_day_button').addEventListener("click", previous_day_schedule);
|
||||||
document.querySelector('#next_week_button').addEventListener("click", next_week_schedule);
|
document.querySelector('#next_day_button').addEventListener("click", next_day_schedule);
|
||||||
// init grid structure itself
|
// init grid structure itself
|
||||||
const template = document.querySelector("#schedule_header_row_template");
|
const template = document.querySelector("#schedule_header_row_template");
|
||||||
const template_clone = template.content.cloneNode(true);
|
const template_clone = template.content.cloneNode(true);
|
||||||
@ -666,12 +642,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const previous_week_schedule = (e) => {
|
const previous_day_schedule = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const next_week_schedule = (e) => {
|
const next_day_schedule = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user