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,