MediaWiki:StyleSwitcher3.js

importScriptPage("MediaWiki:JacobsLadderSuite.js","d97");

StyleSwitcher = { VERSION: "3.0.3", circleType: "square", alignType: "right", loaded: false, defaultLogoUrl: "", normal: "", skinType: 0,

report: function(styleIDtext) { if (styleIDtext != "default") { styleID = parseInt(styleIDtext, 10); //Gets the ID of the selected style $('#skinBackground').remove; //Removes old style $('#ChatSkins').remove; //Removes old style $('#ChatSkinsAdditional').remove; //Removes old style $('#ChatSkinsTransparent').remove; //Removes old style $('#HeaderLogo').remove; //Removes old style StyleSwitcher.skinType = stylesheetsArray[styleID].name; //Sets page variable StyleSwitcher.skinType to the new skin $.cookie('StyleSwitcher.skinType', styleID, {               expires: 5            }); //Sets cookie StyleSwitcher.skinType to the new skin ID

if (stylesheetsArray[styleID].clear === true) { $('head').append(''); //Adds the clearBase CSS if required (for image-background skins) }

$('head').append(''); //Adds the new skin CSS if (stylesheetsArray[styleID].logo !== null) { $('#ChatHeader').append(''); //If a logo is defined in the stylesheetArray, add it to the header. } else { $('#ChatHeader').append(''); //If a logo is not defined in the stylesheetArray, use the default. }       } else { styleID = parseInt(defaultSkin, 10); //Gets the ID of the default skin $('#skinBackground').remove; //Removes old style $('#ChatSkins').remove; //Removes old style $('#ChatSkinsAdditional').remove; //Removes old style $('#ChatSkinsTransparent').remove; //Removes old style $('#HeaderLogo').remove; //Removes old style StyleSwitcher.skinType = stylesheetsArray[styleID].name; //Sets page variable StyleSwitcher.skinType to the new skin $.cookie('StyleSwitcher.skinType', styleID, {               expires: 5            }); //Sets cookie StyleSwitcher.skinType to the new skin ID

if (stylesheetsArray[styleID].clear === true) { $('head').append(''); //Adds the clearBase CSS if required (for image-background skins) }

$('head').append(''); //Adds the new skin CSS if (stylesheetsArray[styleID].logo !== null) { $('#ChatHeader').append(''); //If a logo is defined in the stylesheetArray, add it to the header. } else { $('#ChatHeader').append(''); //If a logo is not defined in the stylesheetArray, use the default. }       }    },

circleToggle: function { if (StyleSwitcher.circleType == "circle") { $('#ChatSkinsCircle').remove; $.cookie('StyleSwitcher.circleType', 'square', {               expires: 5            }); StyleSwitcher.circleType = "square"; $("a.circle-button").text("Circle"); } else { $('head').append(''); $.cookie('StyleSwitcher.circleType', 'circle', {               expires: 5            }); StyleSwitcher.circleType = "circle"; $("a.circle-button").text("Square"); }   },

alignToggle: function { if (StyleSwitcher.alignType == "left") { $('#ChatSkinsLeft').remove; $.cookie('StyleSwitcher.alignType', 'right', {               expires: 5            }); StyleSwitcher.alignType = "right"; $("a.align-button").text("Left"); } else { $('head').append(''); $.cookie('StyleSwitcher.alignType', 'left', {               expires: 5            }); StyleSwitcher.alignType = "left"; $("a.align-button").text("Right"); }   },

loadApp: function { $('.ChatWindow').attr('id', 'ChatWindow'); StyleSwitcher.normalLogoUrl = $("#ChatHeader > h1.public.wordmark > a > img").attr("src");

if (typeof stylesheetsArray === 'undefined') { console.log("[STYLE] ERROR: No styles defined!"); }

if (typeof defaultSkin === 'undefined') { console.log("[STYLE] ERROR: No default skin defined! Setting to 0"); var defaultSkin = 0; }

if ($.cookie("StyleSwitcher.skinType") === null) { if (typeof StyleSwitcher.normal != "undefined") { StyleSwitcher.skinType = defaultSkin; } else { console.log("[STYLE] ERROR: No default skin defined. Setting skin to 0"); StyleSwitcher.skinType = "0"; StyleSwitcher.normal = "0"; }       } else { StyleSwitcher.skinType = $.cookie("StyleSwitcher.skinType"); }

$('#ChatHeader > h1.public.wordmark > a').remove; // Removes the default logo

if (!$(".stylechanger").length) { $('#sidebar-top').prepend(' '); }

if (StyleSwitcher.loaded === false) { for (i = 0; i < stylesheetsArray.length; i++) { $(".stylechanger").append("" + stylesheetsArray[i].name + " "); }           StyleSwitcher.loaded = true; }

StyleSwitcher.report(StyleSwitcher.skinType); if ($.cookie("StyleSwitcher.alignType") == "left") { StyleSwitcher.alignToggle; }

if ($.cookie("StyleSwitcher.circleType") == "circle") { StyleSwitcher.circleToggle; }       console.log("[StyleSwitcher] StyleSwitcher "+ StyleSwitcher.VERSION +" loaded!"); } };

styleSwitcherTimeout = setInterval(function {   if($("#sidebar-top").length) {        StyleSwitcher.loadApp;        clearInterval(styleSwitcherTimeout);    } }, 1000);