assets/js/darkmode-toggle.js in jekyll-theme-peaceful-gates-1.2.0 vs assets/js/darkmode-toggle.js in jekyll-theme-peaceful-gates-2.0.0
- old
+ new
@@ -1,45 +1,45 @@
-$(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()
- })
+$(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()
+ })
})
\ No newline at end of file