mirror of
https://github.com/nextcloud/all-in-one.git
synced 2026-05-28 06:20:14 +00:00
Agent-Logs-Url: https://github.com/nextcloud/all-in-one/sessions/bc95f559-e0c7-4682-96fb-0799956a95c6 Co-authored-by: szaimen <42591237+szaimen@users.noreply.github.com>
15 lines
644 B
JavaScript
15 lines
644 B
JavaScript
"use strict";
|
|
|
|
// Apply the saved theme immediately to avoid a flash of the wrong theme.
|
|
try { document.documentElement.setAttribute('data-theme', localStorage.getItem('theme') ?? ''); } catch (e) {}
|
|
|
|
// React when the user toggles the theme on the parent page while this page is
|
|
// open in an iframe. localStorage.setItem() fires a 'storage' event on every
|
|
// other window / frame that shares the same origin, so we can keep in sync
|
|
// without the parent having to know about us.
|
|
window.addEventListener('storage', (e) => {
|
|
if (e.key === 'theme') {
|
|
document.documentElement.setAttribute('data-theme', e.newValue ?? '');
|
|
}
|
|
});
|