mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-30 14:02:06 +00:00
1 line
803 B
JavaScript
1 line
803 B
JavaScript
const DARK_MODE="dark",LIGHT_MODE="light",AUTO_MODE="auto",THEME="hugo-geekdoc",TOGGLE_MODES=[AUTO_MODE,DARK_MODE,LIGHT_MODE];function toggle(e=[],t){return current=e.indexOf(t),max=e.length-1,next=0,current<max&&(next=current+1),next}(applyTheme=function(e=!0){let t=document.documentElement;var o=TOGGLE_MODES.includes(localStorage.getItem(THEME))?localStorage.getItem(THEME):AUTO_MODE;t.setAttribute("class","color-toggle-"+o),localStorage.setItem(THEME,o),o===AUTO_MODE?t.removeAttribute("color-mode"):t.setAttribute("color-mode",o),e||location.reload()})(),document.addEventListener("DOMContentLoaded",e=>{const t=document.getElementById("gdoc-dark-mode");t.onclick=function(){var e=localStorage.getItem(THEME),e=toggle(TOGGLE_MODES,e);localStorage.setItem(THEME,TOGGLE_MODES[e]),applyTheme(!1)}}); |