Moved javascript into javascript file

This commit is contained in:
ricky committed 2026-08-25 14:38:24 -04:00
1 parent 46784cff44
commit 2acbbd343a
2 files changed
+65 -67

No files matched your search

+64 -1
View File
@@ -19,4 +19,67 @@ document.addEventListener('DOMContentLoaded', function() {
clickedBlock.classList.toggle('open');
}
});
});
});
(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();
};
})();