Path: blob/master/final-grade-calculator/secondary.js
574 views
/* secondary.js1* Handles what dialogs (the messages up top, not the alert boxes) to show and whether to show them or not2* Also handles the theme toggle button3* (C) 2019 Ryan Zhang. All Rights Reserved.4* Interested in anything on here? Contact me at https://ryan778.github.io/about-me/ and we can discuss.5*/67let s_dismissed = [];8let s_curTheme = 1; // 1 = light, 0 = dark9if(localStorage.fgc_dismissedDialogs){10$('#sp-resetDialogs').show();11s_dismissed = localStorage.fgc_dismissedDialogs.split('|')}1213function d_show(ele, key){14if(s_dismissed.indexOf(key) === -1){15$(ele).show();16}17}1819$('.btn-close').on('click', (e) => {20$('#sp-resetDialogs').show();21s_dismissed.push(e.currentTarget.dataset.key);22localStorage.fgc_dismissedDialogs = s_dismissed.join('|');23$(e.currentTarget.parentElement.parentElement).hide();24})2526$('#a-resetDialogs').on('click', (e) => {27if(e.currentTarget.dataset.hasReset){location.reload()}28localStorage.removeItem('fgc_dismissedDialogs');29e.currentTarget.innerText = 'Success! (Reload to show)';30e.currentTarget.dataset.hasReset = '1';31})3233$('#i-toggleTheme').on('click', (e) => {34s_curTheme = !s_curTheme;35e.currentTarget.innerHTML = s_curTheme?'nights_stay':'wb_sunny';36document.getElementById('theme').href = `themes/${s_curTheme?'default':'dark'}.css`;37})3839d_show('#al_rel', 'r1.0.0')40if(!window.matchMedia("(prefers-color-scheme: light)").matches || new Date().getHours() > 22 || new Date().getHours() < 6){41s_curTheme = 0;42d_show('#al_dark', 'autodark')}4344