|
20 | 20 |
|
21 | 21 | {% block header %}{% endblock %} |
22 | 22 |
|
| 23 | + <script type="text/javascript"> |
| 24 | + const html = document.documentElement; |
| 25 | + |
| 26 | + const bulbOn = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-lightbulb-fill" viewBox="0 0 16 16"> |
| 27 | + <path d="M2 6a6 6 0 1 1 10.174 4.31c-.203.196-.359.4-.453.619l-.762 1.769A.5.5 0 0 1 10.5 13h-5a.5.5 0 0 1-.46-.302l-.761-1.77a2 2 0 0 0-.453-.618A5.98 5.98 0 0 1 2 6m3 8.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1l-.224.447a1 1 0 0 1-.894.553H6.618a1 1 0 0 1-.894-.553L5.5 15a.5.5 0 0 1-.5-.5"/> |
| 28 | + </svg>`; |
| 29 | + |
| 30 | + const bulbOff = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-lightbulb-off" viewBox="0 0 16 16"> |
| 31 | + <path fill-rule="evenodd" d="M2.23 4.35A6 6 0 0 0 2 6c0 1.691.7 3.22 1.826 4.31.203.196.359.4.453.619l.762 1.769A.5.5 0 0 0 5.5 13a.5.5 0 0 0 0 1 .5.5 0 0 0 0 1l.224.447a1 1 0 0 0 .894.553h2.764a1 1 0 0 0 .894-.553L10.5 15a.5.5 0 0 0 0-1 .5.5 0 0 0 0-1 .5.5 0 0 0 .288-.091L9.878 12H5.83l-.632-1.467a3 3 0 0 0-.676-.941 4.98 4.98 0 0 1-1.455-4.405zm1.588-2.653.708.707a5 5 0 0 1 7.07 7.07l.707.707a6 6 0 0 0-8.484-8.484zm-2.172-.051a.5.5 0 0 1 .708 0l12 12a.5.5 0 0 1-.708.708l-12-12a.5.5 0 0 1 0-.708"/> |
| 32 | + </svg>`; |
| 33 | + |
| 34 | + let currentTheme = localStorage.getItem('theme'); |
| 35 | + if (!currentTheme) { |
| 36 | + const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches; |
| 37 | + if (prefersDark) { |
| 38 | + currentTheme = 'dark'; |
| 39 | + } else { |
| 40 | + currentTheme = 'light'; |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | + html.setAttribute('data-bs-theme', currentTheme); |
| 45 | + |
| 46 | + document.addEventListener('DOMContentLoaded', () => { |
| 47 | + const toggle = document.getElementById('theme-toggle'); |
| 48 | + toggle.innerHTML = currentTheme === 'dark' ? bulbOff : bulbOn; |
| 49 | + toggle.onclick = function() { |
| 50 | + currentTheme = currentTheme === 'dark' ? 'light' : 'dark'; |
| 51 | + html.setAttribute('data-bs-theme', currentTheme); |
| 52 | + localStorage.setItem('theme', currentTheme); |
| 53 | + this.innerHTML = currentTheme === 'dark' ? bulbOff : bulbOn; |
| 54 | + }; |
| 55 | + }); |
| 56 | + </script> |
| 57 | + |
23 | 58 | </head> |
24 | 59 |
|
25 | 60 | <body |
|
228 | 263 | delay: 600, |
229 | 264 | }); |
230 | 265 | }); |
231 | | - |
232 | | - const html = document.documentElement; |
233 | | - |
234 | | - const bulbOn = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-lightbulb-fill" viewBox="0 0 16 16"> |
235 | | - <path d="M2 6a6 6 0 1 1 10.174 4.31c-.203.196-.359.4-.453.619l-.762 1.769A.5.5 0 0 1 10.5 13h-5a.5.5 0 0 1-.46-.302l-.761-1.77a2 2 0 0 0-.453-.618A5.98 5.98 0 0 1 2 6m3 8.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1l-.224.447a1 1 0 0 1-.894.553H6.618a1 1 0 0 1-.894-.553L5.5 15a.5.5 0 0 1-.5-.5"/> |
236 | | - </svg>`; |
237 | | - |
238 | | - const bulbOff = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-lightbulb-off" viewBox="0 0 16 16"> |
239 | | - <path fill-rule="evenodd" d="M2.23 4.35A6 6 0 0 0 2 6c0 1.691.7 3.22 1.826 4.31.203.196.359.4.453.619l.762 1.769A.5.5 0 0 0 5.5 13a.5.5 0 0 0 0 1 .5.5 0 0 0 0 1l.224.447a1 1 0 0 0 .894.553h2.764a1 1 0 0 0 .894-.553L10.5 15a.5.5 0 0 0 0-1 .5.5 0 0 0 0-1 .5.5 0 0 0 .288-.091L9.878 12H5.83l-.632-1.467a3 3 0 0 0-.676-.941 4.98 4.98 0 0 1-1.455-4.405zm1.588-2.653.708.707a5 5 0 0 1 7.07 7.07l.707.707a6 6 0 0 0-8.484-8.484zm-2.172-.051a.5.5 0 0 1 .708 0l12 12a.5.5 0 0 1-.708.708l-12-12a.5.5 0 0 1 0-.708"/> |
240 | | - </svg>`; |
241 | | - |
242 | | - const toggle = document.getElementById('theme-toggle'); |
243 | | - let currentTheme = localStorage.getItem('theme'); |
244 | | - if (!currentTheme) { |
245 | | - const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches; |
246 | | - if (prefersDark) { |
247 | | - currentTheme = 'dark'; |
248 | | - } else { |
249 | | - currentTheme = 'light'; |
250 | | - } |
251 | | - } |
252 | | - |
253 | | - html.setAttribute('data-bs-theme', currentTheme); |
254 | | - toggle.innerHTML = currentTheme === 'dark' ? bulbOff : bulbOn; |
255 | | - toggle.onclick = function() { |
256 | | - currentTheme = currentTheme === 'dark' ? 'light' : 'dark'; |
257 | | - html.setAttribute('data-bs-theme', currentTheme); |
258 | | - localStorage.setItem('theme', currentTheme); |
259 | | - toggle.innerHTML = currentTheme === 'dark' ? bulbOff : bulbOn; |
260 | | - }; |
261 | | - |
262 | 266 | </script> |
263 | 267 | {% block jscript %}{% endblock %} |
264 | 268 | </body> |
|
0 commit comments