Compare commits
No commits in common. "729b477d44c0e416504fcdaaf57de92d6e48fdd2" and "ee8dc84628266309ace6500614d4ddf4c2a3f3b9" have entirely different histories.
729b477d44
...
ee8dc84628
46
www/app.js
46
www/app.js
|
@ -95,35 +95,6 @@ document.getElementById('createBackup').addEventListener('click', async e => {
|
||||||
await updateBackupsList();
|
await updateBackupsList();
|
||||||
});
|
});
|
||||||
|
|
||||||
async function cloneSchedule(includeAssignments) {
|
|
||||||
let name = document.getElementById('cloneName').value;
|
|
||||||
if (name.length === 0) {
|
|
||||||
name = new Date().toISOString().replaceAll(':', '-');
|
|
||||||
}
|
|
||||||
|
|
||||||
const file = await dirHandle.getFileHandle(name + '.json', {create: true});
|
|
||||||
if ((await file.getFile()).size !== 0) {
|
|
||||||
alert("Failed to create new schedule. Schedule \"" + name
|
|
||||||
+ "\" already exists.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const writable = await file.createWritable();
|
|
||||||
if (!includeAssignments) schedule.assignments = [];
|
|
||||||
await writable.write(JSON.stringify(schedule.asJsonObject(), null, 2));
|
|
||||||
await writable.close();
|
|
||||||
|
|
||||||
window.location.reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById('cloneSch').addEventListener('click', async e => {
|
|
||||||
cloneSchedule(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
document.getElementById('cloneSchNoAssignments').addEventListener('click', async e => {
|
|
||||||
cloneSchedule(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
const titleInput = document.getElementById('title');
|
const titleInput = document.getElementById('title');
|
||||||
let allowEdits = false;
|
let allowEdits = false;
|
||||||
async function updateScheduleSettings() {
|
async function updateScheduleSettings() {
|
||||||
|
@ -217,23 +188,6 @@ async function loadDir(dir) {
|
||||||
options.sort((a, b) => b.timestamp - a.timestamp).forEach(opt =>
|
options.sort((a, b) => b.timestamp - a.timestamp).forEach(opt =>
|
||||||
schedulesList.appendChild(opt));
|
schedulesList.appendChild(opt));
|
||||||
|
|
||||||
if (newest === undefined) {
|
|
||||||
const file = await dirHandle.getFileHandle('default.json', {create: true});
|
|
||||||
|
|
||||||
const writable = await file.createWritable();
|
|
||||||
await writable.write(JSON.stringify(new Schedule({
|
|
||||||
title: "DEFAULT TITLE",
|
|
||||||
assignments: [],
|
|
||||||
all_days: ['M', 'T', 'W', 'R', 'F'],
|
|
||||||
start_time: { hour: 9 },
|
|
||||||
end_time: { hour: 17 },
|
|
||||||
}).asJsonObject(), null, 2));
|
|
||||||
await writable.close();
|
|
||||||
|
|
||||||
window.location.reload();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await loadFile(newest, false);
|
await loadFile(newest, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,9 +27,9 @@
|
||||||
<label>Schedule: <select id="schedules"></select></label>
|
<label>Schedule: <select id="schedules"></select></label>
|
||||||
</div>
|
</div>
|
||||||
<div id="clone">
|
<div id="clone">
|
||||||
<label>New schedule name: <input id="cloneName" pattern="[-_ a-zA-Z0-9]+"></label>
|
<label>New schedule name: <input id="cloneName" pattern="[-_ a-zA-Z0-9]+" disabled></label>
|
||||||
<button id="cloneSch">Clone to New Schedule</button>
|
<button id="cloneSch" disabled>Clone to New Schedule</button>
|
||||||
<button id="cloneSchNoAssignments">Clone to New Schedule without Assignments</button>
|
<button id="cloneSchNoAssignments" disabled>Clone to New Schedule without Assignments</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="backupsSettings">
|
<div id="backupsSettings">
|
||||||
<label>Load backup: <select id="backups"></select></label><br>
|
<label>Load backup: <select id="backups"></select></label><br>
|
||||||
|
|
|
@ -9,9 +9,9 @@ export default class Schedule {
|
||||||
// TODO Custom day names? Schedules might not be weekly.
|
// TODO Custom day names? Schedules might not be weekly.
|
||||||
this.all_days = obj.all_days;
|
this.all_days = obj.all_days;
|
||||||
// TODO Remove hard-coded participant kinds.
|
// TODO Remove hard-coded participant kinds.
|
||||||
this.all_students = obj.all_students ?? [];
|
this.all_students = obj.all_students;
|
||||||
this.all_staff = obj.all_staff ?? [];
|
this.all_staff = obj.all_staff;
|
||||||
this.all_teachers = obj.all_teachers ?? [];
|
this.all_teachers = obj.all_teachers;
|
||||||
this.granularity = obj.granularity !== undefined
|
this.granularity = obj.granularity !== undefined
|
||||||
? new utils.Duration(obj.granularity)
|
? new utils.Duration(obj.granularity)
|
||||||
: new utils.Duration({minute: 10});
|
: new utils.Duration({minute: 10});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user