From 797e32a1791fdff6663c6c4834ec6b1e220165c7 Mon Sep 17 00:00:00 2001 From: wholelotofhs Date: Thu, 20 Nov 2014 15:12:40 -0500 Subject: [PATCH] clean up and added comments --- js/disable-styles.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/js/disable-styles.js b/js/disable-styles.js index c44510e4..823d023a 100644 --- a/js/disable-styles.js +++ b/js/disable-styles.js @@ -2,8 +2,9 @@ /* Adds a checkbox in the General options tab to disable and enable board style sheets. */ -var disableStyleSheet = function () { +$(document).ready(function () { var disableStyles = localStorage['disablestylesheet'] ? true : false; + /* only search for and disable board stylesheets if the user is on a page that uses them */ if(active_page == 'ukko' || active_page == 'thread' || active_page == 'index' || active_page == 'catalog') { var i = 0 @@ -18,22 +19,19 @@ var disableStyleSheet = function () { i++ } } - + /* add the option on all pages so that the user doesn't need to goto a board to toggle it */ if (window.Options && Options.get_tab('general')){ - element = '#disablestyle' - event = 'change' Options.extend_tab('general','') - $(element).find('input').prop('checked', disableStyles) + $('#disablestyle').find('input').prop('checked', disableStyles) } - $(element).on(event, function() { + $('#disablestyle').on('change', function() { if(disableStyles) { - delete localStorage.disablestylesheet; + delete localStorage.disablestylesheet } else { - localStorage.disablestylesheet = true; + localStorage.disablestylesheet = true } - disableStyles =! disableStyles; - if(active_page == 'ukko' || active_page == 'thread' || active_page == 'index' || active_page == 'catalog') document.styleSheets[sheet].disabled = disableStyles; + disableStyles =! disableStyles + if(active_page == 'ukko' || active_page == 'thread' || active_page == 'index' || active_page == 'catalog') document.styleSheets[sheet].disabled = disableStyles }) -} -$(document).ready(disableStyleSheet()); +})