diff --git a/app/views/common/_calendar.html.erb b/app/views/common/_calendar.html.erb
index 8ba0f71..d97166a 100644
--- a/app/views/common/_calendar.html.erb
+++ b/app/views/common/_calendar.html.erb
@@ -272,69 +272,4 @@
<% end %>
-<%= context_menu %>
-
-
\ No newline at end of file
+<%= context_menu %>
\ No newline at end of file
diff --git a/assets/javascripts/calendar.js b/assets/javascripts/calendar.js
index 255cacf..b903cb8 100644
--- a/assets/javascripts/calendar.js
+++ b/assets/javascripts/calendar.js
@@ -19,4 +19,67 @@ document.addEventListener('DOMContentLoaded', function() {
clickedBlock.classList.toggle('open');
}
});
-});
\ No newline at end of file
+});
+
+(function() {
+ const STORAGE_KEY_ONLY_APPTS = 'redmine_cal_only_appointments';
+ const STORAGE_KEY_HIDE_PAST = 'redmine_cal_hide_past_weeks';
+
+ window.scrollToToday = function() {
+ const todayElement = document.getElementById('today');
+ if (todayElement) {
+ todayElement.scrollIntoView({ behavior: 'smooth', block: 'center' });
+ }
+ };
+
+ document.addEventListener('DOMContentLoaded', function() {
+ const urlParams = new URLSearchParams(window.location.search);
+ let needsRedirect = false;
+
+ // Sync "Show Customer Appointments Only" with localStorage if missing from URL
+ if (!urlParams.has('only_appointments') && localStorage.getItem(STORAGE_KEY_ONLY_APPTS) === '1') {
+ urlParams.set('only_appointments', '1');
+ needsRedirect = true;
+ }
+
+ // Sync "Hide Past Weeks" with localStorage if missing from URL
+ if (!urlParams.has('hide_past_weeks') && localStorage.getItem(STORAGE_KEY_HIDE_PAST) === '1') {
+ urlParams.set('hide_past_weeks', '1');
+ needsRedirect = true;
+ }
+
+ if (needsRedirect) {
+ window.location.search = urlParams.toString();
+ return;
+ }
+
+ // Automatically scroll to today if present and no hash anchor is in the URL
+ if (!window.location.hash) {
+ window.scrollToToday();
+ }
+ });
+
+ window.toggleOnlyAppointments = function(checked) {
+ const urlParams = new URLSearchParams(window.location.search);
+ if (checked) {
+ urlParams.set('only_appointments', '1');
+ localStorage.setItem(STORAGE_KEY_ONLY_APPTS, '1');
+ } else {
+ urlParams.delete('only_appointments');
+ localStorage.setItem(STORAGE_KEY_ONLY_APPTS, '0');
+ }
+ window.location.search = urlParams.toString();
+ };
+
+ window.toggleHidePastWeeks = function(checked) {
+ const urlParams = new URLSearchParams(window.location.search);
+ if (checked) {
+ urlParams.set('hide_past_weeks', '1');
+ localStorage.setItem(STORAGE_KEY_HIDE_PAST, '1');
+ } else {
+ urlParams.delete('hide_past_weeks');
+ localStorage.setItem(STORAGE_KEY_HIDE_PAST, '0');
+ }
+ window.location.search = urlParams.toString();
+ };
+})();
\ No newline at end of file