52 lines
1.6 KiB
JavaScript
52 lines
1.6 KiB
JavaScript
(function () {
|
|
var normalizedPathname = window.location.pathname.replace(/\/$/, '');
|
|
if (normalizedPathname !== '/settings/tasks-background' && normalizedPathname !== '/settings/tasks-scheduled') {
|
|
return;
|
|
}
|
|
|
|
function updateBackgroundTasksCardHeight() {
|
|
var card = document.getElementById('background-tasks-task-card');
|
|
if (!card) {
|
|
return;
|
|
}
|
|
|
|
var cardRect = card.getBoundingClientRect();
|
|
var bottomInset = 16;
|
|
var availableHeight = Math.max(0, window.innerHeight - cardRect.top - bottomInset);
|
|
card.style.setProperty('--background-tasks-task-card-max-height', availableHeight + 'px');
|
|
}
|
|
|
|
var scheduleUpdate = window.requestAnimationFrame ? function () {
|
|
window.requestAnimationFrame(updateBackgroundTasksCardHeight);
|
|
} : updateBackgroundTasksCardHeight;
|
|
|
|
if (window.addEventListener) {
|
|
window.addEventListener('resize', scheduleUpdate);
|
|
window.addEventListener('orientationchange', scheduleUpdate);
|
|
window.addEventListener('load', scheduleUpdate);
|
|
}
|
|
|
|
if (window.ResizeObserver) {
|
|
try {
|
|
var summary = document.getElementById('background-tasks-summary');
|
|
if (summary) {
|
|
new ResizeObserver(scheduleUpdate).observe(summary);
|
|
}
|
|
} catch (_error) {
|
|
// Ignore ResizeObserver setup failures.
|
|
}
|
|
}
|
|
|
|
scheduleUpdate();
|
|
|
|
try {
|
|
var url = new URL(window.location.href);
|
|
if (!url.searchParams.has('message')) {
|
|
return;
|
|
}
|
|
url.searchParams.delete('message');
|
|
window.history.replaceState({}, document.title, url.pathname + (url.search ? url.search : '') + url.hash);
|
|
} catch (_error) {
|
|
// Ignore URL cleanup failures.
|
|
}
|
|
}()); |