MediaWiki:StyleSwitcher2.js

// Necessary for debug purposes

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

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

var ssCircleType = "square"; var ssAlignType = "right"; var styleSwitcherLoaded = 0;

// $("#Rail > h1.public.wordmark").css("margin-top","32px"); // Clears space for the buttons

$('.ChatWindow').attr('id','ChatWindow'); // Adds an ID to the chat window. Necessary for background changing

var defaultLogoUrl = $("#ChatHeader > h1.public.wordmark > a > img").attr("src"); // Grabs normal logo

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

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

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

// Adds the dropdown menu to the rail.

if (styleSwitcherLoaded==0){ for (i=0; i < stylesheetsArray.length; i++) { $(".stylechanger").append(""+stylesheetsArray[i].name+" "); }   styleSwitcherLoaded = 1; }

// Adds the styles to the dropdown.

function report(styleIDtext) { if (styleIDtext!="default") { styleID = parseInt(styleIDtext); //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 ssSkinType = stylesheetsArray[styleID].name; //Sets page variable ssSkinType to the new skin $.cookie('ssSkinType',styleID,{expires: 5}); //Sets cookie ssSkinType 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(ssDefaultSkin); //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 ssSkinType = stylesheetsArray[styleID].name; //Sets page variable ssSkinType to the new skin $.cookie('ssSkinType',styleID,{expires: 5}); //Sets cookie ssSkinType 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. }   } }

// Circle toggler function circleToggle { if (ssCircleType=="circle") { $('#ChatSkinsCircle').remove; $.cookie('ssCircleType','square',{expires: 5}); ssCircleType = "square"; } else { $('head').append(''); $.cookie('ssCircleType','circle',{expires: 5}); ssCircleType = "circle"; } } // Alignment toggler function alignToggle { if (ssAlignType=="left") { $('#ChatSkinsLeft').remove; $.cookie('ssAlignType','right',{expires: 5}); ssAlignType = "right"; $("a.align-button").text("Left"); } else { $('head').append(''); $.cookie('ssAlignType','left',{expires: 5}); ssAlignType = "left"; $("a.align-button").text("Right"); } }

// Loader for cookied skin

report(ssSkinType);

if ($.cookie("ssAlignType") == "left") { alignToggle; }

if ($.cookie("ssCircleType") == "circle") { circleToggle; }

// Finalise

console.log("[STYLE] Loaded StyleSwitcher version 2.0.2.4");