Download shared/js/theme.js from Tonic/uas-eus: direct link, hf CLI and curl.
- Browser
- Download file 1.35 kB
-
https://huggingface.co/spaces/Tonic/uas-eus/resolve/main/shared/js/theme.js
- Command line
-
hf download hf://spaces/Tonic/uas-eus/shared/js/theme.js
-
curl -L -o theme.js https://huggingface.co/spaces/Tonic/uas-eus/resolve/main/shared/js/theme.js
1.35 kB
| /* Light/dark mode on both sites. Persisted (strictly necessary localStorage), honors | |
| prefers-color-scheme on first visit. Toggle button: #theme-btn in the nav. */ | |
| (function () { | |
| var KEY = 'uas_theme'; | |
| function apply(t) { | |
| document.documentElement.setAttribute('data-theme', t); | |
| var b = document.getElementById('theme-btn'); | |
| if (b) b.textContent = t === 'dark' ? '☀️' : '🌙'; | |
| var m = document.querySelector('meta[name="theme-color"]'); | |
| if (m) m.setAttribute('content', t === 'dark' ? '#08111B' : '#ffffff'); | |
| } | |
| window.Theme = { | |
| current: function () { | |
| var s = null; | |
| try { s = localStorage.getItem(KEY); } catch (e) {} | |
| if (!s) s = document.documentElement.getAttribute('data-theme'); // brand default in HTML | |
| if (!s) s = (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) ? 'dark' : 'light'; | |
| return s; | |
| }, | |
| init: function () { apply(this.current()); }, | |
| toggle: function () { | |
| var t = this.current() === 'dark' ? 'light' : 'dark'; | |
| try { localStorage.setItem(KEY, t); } catch (e) {} | |
| apply(t); | |
| } | |
| }; | |
| window.addEventListener('DOMContentLoaded', function () { | |
| Theme.init(); | |
| var b = document.getElementById('theme-btn'); | |
| if (b) b.addEventListener('click', function () { Theme.toggle(); }); | |
| }); | |
| })(); | |