Full document, spreadsheet, slideshow, and diagram tooling
1// Theme init — runs before paint to avoid FOUC.
2// Must be loaded from <head> as a blocking <script src="/theme-init.js">
3// so that data-theme is set before the body renders.
4// Served with long cache headers since the content is stable; bump the URL
5// query string (e.g. /theme-init.js?v=2) when editing to bust caches.
6(function () {
7 var saved = localStorage.getItem('atmos-theme');
8 if (saved === 'dark' || saved === 'light') {
9 document.documentElement.setAttribute('data-theme', saved);
10 }
11 if (window.electronAPI) document.documentElement.classList.add('is-electron');
12 // Enable focus rings only when keyboard navigation is detected
13 document.addEventListener('keydown', function (e) {
14 if (e.key === 'Tab') document.documentElement.setAttribute('data-a11y-focus', '');
15 });
16 document.addEventListener('mousedown', function () {
17 document.documentElement.removeAttribute('data-a11y-focus');
18 });
19})();