Sha256: 5a908154a82f47bc7daf423aca919ac23d3a55ee2abb28595dc876fa8d2fdaf8
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
$(function() { // Get body jQuery let $body = $('body') /** * Enable darkmode */ function darkmodeEnable() { $body.addClass('darkmode') console.log('Darkmode enabled!') } /** * Disable darkmode */ function darkmodeDisable() { $body.removeClass('darkmode') console.log('Darkmode disabled!') } // Get darkmode from localstorage let darkmode = localStorage.getItem('darkmode') || 'off' console.log('Darkmode:', darkmode) // Set initial darkmode if (darkmode === 'on') darkmodeEnable(); else darkmodeDisable(); // Darkmode toggle $('#toggle-darkmode').click(function() { console.group('Darkmode Toggle') console.log('Current darkmode:', darkmode) if (darkmode === 'on') { darkmodeDisable(); darkmode = 'off'; } else { darkmodeEnable() darkmode = 'on' } console.log('Next darkmode:', darkmode) localStorage.setItem('darkmode', darkmode) console.groupEnd() }) })
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jekyll-theme-peaceful-gates-2.0.0 | assets/js/darkmode-toggle.js |