/* theme selector
*/

(function() {
  'use strict';

  var themeActive = '';
  var $container = document.querySelector('.themes-box');

  function hashChange () {
    themeActive = window.util.hash('theme');

    // if no theme in the url
    if (!themeActive) {
      // select the first in the list
      $container.querySelector('.theme-item').click();

      return;
    }

    // uncheck previous active theme
    var $themeActive = $container.querySelector('.active');
    if ($themeActive) {
      window.util.removeClass($themeActive, 'active');
    }

    $themeActive = $container.querySelector('.js-' + themeActive);
    window.util.addClass($themeActive, 'active');
  }

  hashChange();
  window.addEventListener('hashchange', hashChange, false);
})();
/* theme selector
*/

(function() {
  'use strict';

  var themeActive = '';
  var $themeActive;
  var $container = document.querySelector('.themes-box');

  function hashChange () {
    themeActive = window.util.hash('theme');

    // if no theme in the url
    if (!themeActive) {
      // select the first in the list
      $container.querySelector('.theme-item').click();

      return;
    }

    // uncheck previous active theme
    $themeActive = $container.querySelector('.active');
    if ($themeActive) {
      window.util.removeClass($themeActive, 'active');
    }

    $themeActive = $container.querySelector('.js-' + themeActive);
    if ($themeActive) {
      window.util.addClass($themeActive, 'active');
    }
  }

  hashChange();
  window.addEventListener('hashchange', hashChange, false);
})();
Check if the dom node for the theme about to be activated exists. To minimize js errors.
Check if the dom node for the theme about to be activated exists. To minimize js errors.
