diff --git a/templates/index.html b/templates/index.html index 4b84afc..7e700df 100644 --- a/templates/index.html +++ b/templates/index.html @@ -27,6 +27,16 @@ import listPlugin from '@fullcalendar/list' import gbLocale from '@fullcalendar/core/locales/en-gb'; + // Function to save the current view to local storage + function saveView(view) { + localStorage.setItem('fullCalendarDefaultView', view); + } + + // Function to get the saved view from local storage + function getSavedView() { + return localStorage.getItem('fullCalendarDefaultView') || 'dayGridMonth'; + } + document.addEventListener('DOMContentLoaded', function() { const calendarEl = document.getElementById('calendar') const calendar = new Calendar(calendarEl, { @@ -34,7 +44,10 @@ plugins: [dayGridPlugin, timeGridPlugin, listPlugin ], themeSystem: 'bootstrap5', firstDay: 1, - initialView: 'dayGridMonth', + initialView: getSavedView(), + viewDidMount: function(info) { + saveView(info.view.type); + }, headerToolbar: { left: 'prev,next today', center: 'title', @@ -54,6 +67,7 @@ }) calendar.render() }) +