Factorise l'url, et rajoute la sélection de la vue
This commit is contained in:
parent
8279d15c04
commit
9d9a1a09d9
1 changed files with 18 additions and 3 deletions
|
@ -36,8 +36,19 @@
|
||||||
return time.toLocaleTimeString();
|
return time.toLocaleTimeString();
|
||||||
})();
|
})();
|
||||||
|
|
||||||
const params = new URL(document.location).searchParams.getAll('c');
|
const allowedViews = [
|
||||||
const date = new Date(new URL(document.location).searchParams.get('d'));
|
'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
|
const headers = mobile
|
||||||
? {
|
? {
|
||||||
|
@ -54,7 +65,11 @@
|
||||||
let calendar;
|
let calendar;
|
||||||
|
|
||||||
let options = writable({
|
let options = writable({
|
||||||
initialView: mobile ? 'listWeek' : 'timeGridWeek',
|
initialView: allowedViews.includes(view)
|
||||||
|
? view
|
||||||
|
: mobile
|
||||||
|
? 'listWeek'
|
||||||
|
: 'timeGridWeek',
|
||||||
initialDate: date.toString() === 'Invalid Date' ? now : date,
|
initialDate: date.toString() === 'Invalid Date' ? now : date,
|
||||||
plugins: [
|
plugins: [
|
||||||
timeGridPlugin,
|
timeGridPlugin,
|
||||||
|
|
Loading…
Reference in a new issue