Factorise l'url, et rajoute la sélection de la vue

This commit is contained in:
Tom Hubrecht 2022-07-26 15:26:22 +02:00
parent 8279d15c04
commit 9d9a1a09d9

View file

@ -36,8 +36,19 @@
return time.toLocaleTimeString();
})();
const params = new URL(document.location).searchParams.getAll('c');
const date = new Date(new URL(document.location).searchParams.get('d'));
const allowedViews = [
'resourceTimelineDay',
'dayGridMonth',
'timeGridWeek',
'timeGridDay',
'listWeek'
];
const search = new URL(document.location).searchParams;
const params = search.getAll('c');
const date = new Date(search.get('d'));
const view = search.get('v');
const headers = mobile
? {
@ -54,7 +65,11 @@
let calendar;
let options = writable({
initialView: mobile ? 'listWeek' : 'timeGridWeek',
initialView: allowedViews.includes(view)
? view
: mobile
? 'listWeek'
: 'timeGridWeek',
initialDate: date.toString() === 'Invalid Date' ? now : date,
plugins: [
timeGridPlugin,