From 9d9a1a09d9ef1c0e32eecd5b83d8223141d2c34f Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Tue, 26 Jul 2022 15:26:22 +0200 Subject: [PATCH] =?UTF-8?q?Factorise=20l'url,=20et=20rajoute=20la=20s?= =?UTF-8?q?=C3=A9lection=20de=20la=20vue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.svelte | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/App.svelte b/src/App.svelte index f16fa35..1e82ee4 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -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,