User:Old Man Leon/common.js

/** * experimental style switcher by User:Pecoes */ (function ($, window) {  'use strict';    function modifySassParams (params, noBlackOut) {        var p = [], sass, $blackOut;        params = $.extend(window.sassParams, params);        for (var i in window.sassParams) {            if (window.sassParams.hasOwnProperty(i)) {                p.push(i + '=' + encodeURIComponent(params[i]));            }        }        sass = encodeURIComponent(p.join('&'));        if (!noBlackOut) {            $blackOut = $(' ')            .css({ backgroundColor: window.sassParams['color-page'], position: 'absolute', left: 0, top: 0, width: $(window.document).width + 'px', height: $(window.document).height + 'px', zIndex: 1000000000000 })           .appendTo(window.document.body)            .delay(50)            .fadeOut(1000, function  { $blackOut.remove; });       }        $('link[rel="stylesheet"]')        .each(function  { var $this = $(this), m, href = $this.attr('href'); if (!/\.scss$/.test(href)) return; $this.attr('href',               href.replace(/\/sass\/[^\/]+/, '/sass/' + sass)            ); });   }    $(function  { var styles = { defaultStyle: function { window.localStorage.setItem('style', 'defaultStyle'); modifySassParams({                   'color-buttons': 'black',                    'color-links':   '#6c93b1',                    'color-header':  'black',                    'color-page':    '#474646'                }, true); },           altStyle1: function  { window.localStorage.setItem('style', 'altStyle1'); modifySassParams({                   'color-buttons': '#481b68',                    'color-links':   '#fec356',                    'color-header':  '#d06700',                    'color-page':    '#3a1e29'                }); },           altStyle2: function  { window.localStorage.setItem('style', 'altStyle2'); modifySassParams({                   'color-buttons': '#003816',                    'color-links':   '#F8E9AE',                    'color-header':  '#A1774F',                    'color-page':    '#2d2c18'                }); }       };        styles[window.localStorage.getItem('style') || 'defaultStyle']; var $Container = $('').append($('Style Switcher')).append('').insertAfter(           $('.wds-global-navigation__user-menu').find('a[data-tracking-label="account.preferences"]').parent        ); var $defaultStyle = $('Default Style') .click(function(e) {           e.stopImmediatePropagation;            e.preventDefault;            styles.defaultStyle;        }); var $altStyle1 = $('Alt Style 1') .click(function(e) {           e.stopImmediatePropagation;            e.preventDefault;            styles.altStyle1;        }); var $altStyle2 = $('Alt Style 2') .click(function(e) {           e.stopImmediatePropagation;            e.preventDefault;            styles.altStyle2;        }); $Container.find('.listType').append($defaultStyle).append($altStyle1).append($altStyle2); }); }(jQuery, window));