mirror of
https://github.com/rickbarrette/redmine_qbo_calendar.git
synced 2026-10-03 20:40:43 -04:00
Moved javascript into javascript file
This commit is contained in:
1 parent
46784cff44
commit
2acbbd343a
2 files changed
+65
-67
No files matched your search
@@ -272,69 +272,4 @@
|
|||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= context_menu %>
|
<%= context_menu %>
|
||||||
|
|
||||||
<script>
|
|
||||||
(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 not present in 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 not present in 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 specific 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();
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
@@ -19,4 +19,67 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
clickedBlock.classList.toggle('open');
|
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();
|
||||||
|
};
|
||||||
|
})();
|
||||||
Reference in new issue
Block a user