all repos — h3rald @ 6c3bc3fe9eee362d27e51983890d848deaf755a7

The sources of https://h3rald.com

assets/js/scripts.js

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
(function(window){
  'use strict';

  // Theme Switching
  var themeSwitcher = document.getElementById('theme-switcher');
  var themeLinks = document.getElementsByClassName('theme-css-link');

  themeSwitcher.addEventListener('click', function(){
    var currentTheme = themeLinks[0].href.match(/(light|dark)/)[1];
    var newTheme = currentTheme === 'light' ? 'dark' : 'light';
    for (var i=0; i<themeLinks.length; i++) {
      themeLinks[i].href = themeLinks[i].href.replace(currentTheme, newTheme);
    }
    themeSwitcher.title = themeSwitcher.title.replace(newTheme, currentTheme);
    themeSwitcher.innerText = currentTheme;
  });
})(window)