/// Handles lights-switch link var loadTheme = function() { var syntaxCss = document.getElementById('syntax-css'); if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) { document.documentElement.classList.add('dark'); if (syntaxCss) { syntaxCss.href = "/syntax-dark.css"; } } else { document.documentElement.classList.remove('dark'); if (syntaxCss) { syntaxCss.href = "/syntax-light.css"; } } } var updateIcon = function(btn) { var icon = document.createElement('i'); icon.classList.add('fa'); if (localStorage.theme === 'dark') { icon.classList.add('fa-moon'); } else if (localStorage.theme === 'light') { icon.classList.add('fa-sun'); icon.classList.add('font-thin'); } else { if (window.matchMedia('(prefers-color-scheme: dark)').matches) { icon.classList.add('fa-moon'); } else { icon.classList.add('fa-sun'); } icon.classList.add('opacity-40'); } btn.replaceChild(icon, btn.firstElementChild); }; var initTheme = function() { loadTheme(); const switches = document.getElementsByClassName('lights-container'); if (switches) { for (var i=0; i