|
45 | 45 | }); |
46 | 46 |
|
47 | 47 | gtag('js', new Date()); |
48 | | - gtag('config', 'G-FMRJ311LEF', { |
49 | | - anonymize_ip: true, |
50 | | - send_page_view: true |
51 | | - }); |
| 48 | + gtag('config', 'G-FMRJ311LEF'); |
52 | 49 | </script> |
53 | 50 |
|
54 | 51 | <!-- Favicon --> |
|
90 | 87 | <a href="{{ '/templates' | relative_url }}" {% if page.url == '/templates.html' %}class="active"{% endif %}>Templates</a> |
91 | 88 | <a href="https://github.com/managedcode/MCAF" target="_blank" rel="noopener">GitHub</a> |
92 | 89 | <a href="https://managed-code.com" target="_blank" rel="noopener" class="nav-brand">ManagedCode</a> |
| 90 | + <label class="dark-toggle-label" title="Toggle dark mode"> |
| 91 | + <input type="checkbox" id="dark-toggle"> |
| 92 | + <svg class="icon-sun" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="5"/><path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42"/></svg> |
| 93 | + <svg class="icon-moon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/></svg> |
| 94 | + </label> |
93 | 95 | </div> |
94 | 96 | </nav> |
95 | 97 |
|
|
141 | 143 | backToTop.addEventListener('click', () => { |
142 | 144 | window.scrollTo({ top: 0, behavior: 'smooth' }); |
143 | 145 | }); |
| 146 | + |
| 147 | + // Copy code button |
| 148 | + document.querySelectorAll('pre').forEach(pre => { |
| 149 | + const btn = document.createElement('button'); |
| 150 | + btn.className = 'copy-btn'; |
| 151 | + btn.textContent = 'Copy'; |
| 152 | + btn.addEventListener('click', () => { |
| 153 | + const code = pre.querySelector('code') || pre; |
| 154 | + navigator.clipboard.writeText(code.textContent).then(() => { |
| 155 | + btn.textContent = 'Copied!'; |
| 156 | + setTimeout(() => btn.textContent = 'Copy', 2000); |
| 157 | + }); |
| 158 | + }); |
| 159 | + pre.style.position = 'relative'; |
| 160 | + pre.appendChild(btn); |
| 161 | + }); |
| 162 | + |
| 163 | + // Dark mode |
| 164 | + const darkToggle = document.getElementById('dark-toggle'); |
| 165 | + const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches; |
| 166 | + const stored = localStorage.getItem('darkMode'); |
| 167 | + |
| 168 | + if (stored === 'true' || (stored === null && prefersDark)) { |
| 169 | + document.body.classList.add('dark'); |
| 170 | + if (darkToggle) darkToggle.checked = true; |
| 171 | + } |
| 172 | + |
| 173 | + if (darkToggle) { |
| 174 | + darkToggle.addEventListener('change', () => { |
| 175 | + document.body.classList.toggle('dark'); |
| 176 | + localStorage.setItem('darkMode', document.body.classList.contains('dark')); |
| 177 | + }); |
| 178 | + } |
144 | 179 | </script> |
145 | 180 | </body> |
146 | 181 | </html> |
0 commit comments