User:Monchoman45/global.js

/************************************ stuff here goes on every wiki ************************************/ /*** Please note that functions on this page are heavily integrated with one another, and will not work by themselves. ***/ /*** Many of these are derivatives of publicly available fixes - see User blog:Monchoman45/Improving your interface with CSS/JS. ***/ /*** If you'd like to use something in here, ask me on my talk page and I'll gladly give you the function in a form that will work for you. ***/ /*** Note to self - pretty much everything in here can be updated, and should be as soon as possible ***/

/* Hopefully this'll fix my JS at school. Still need to figure out how to make the defaults work, though. Dropdown menus that actually drop down would be nice */ //Get our import functions back function importScript(b){var a=wgScript+"?title="+encodeURIComponent(b.replace(/ /g,"_")).replace(/%2F/ig,"/").replace(/%3A/ig,":")+"&action=raw&ctype=text/javascript";return importScriptURI(a)} function importScriptURI(a){var b=document.createElement("script");b.setAttribute("src",a);b.setAttribute("type","text/javascript");document.getElementsByTagName("head")[0].appendChild(b);return b} function importScriptPage(b,d){var a="/index.php?title="+encodeURIComponent(b.replace(/ /g,"_")).replace("%2F","/").replace("%3A",":")+"&action=raw&ctype=text/javascript";if(typeof d=="string"){if(d.indexOf("://")==-1){a="http://"+d+".wikia.com"+a}else{a=d+a}}return importScriptURI(a)} function importStylesheet(a){return importStylesheetURI(wgScript+"?action=raw&ctype=text/css&title="+encodeURIComponent(a.replace(/ /g,"_")))} function importStylesheetURI(b,d){var a=document.createElement("link");a.type="text/css";a.rel="stylesheet";a.href=b;if(d){a.media=d}document.getElementsByTagName("head")[0].appendChild(a);return a} function importStylesheetPage(b,d){var a="/index.php?title="+encodeURIComponent(b.replace(/ /g,"_")).replace("%2F","/").replace("%3A",":")+"&action=raw&ctype=text/css";if(typeof d=="string"){if(d.indexOf("://")==-1){a="http://"+d+".wikia.com"+a}else{a=d+a}}return importStylesheetURI(a)} //And get addOnloadHook back window.doneOnloadHook = false; window.onloadFuncts = []; function addOnloadHook(hookFunct) {if(!doneOnloadHook){onloadFuncts[onloadFuncts.length]=hookFunct;}else{hookFunct;}} function runOnloadHook {if(doneOnloadHook||!(document.getElementById&&document.getElementsByTagName)){return;}doneOnloadHook=true;setTimeout('for(var i=0;i<onloadFuncts.length;i++){try {onloadFuncts[i];} catch(err) {}}', 200);} //Get enhanced RC back function appendCSS(text){var s=document.createElement('style');s.type='text/css';s.rel='stylesheet';if(s.styleSheet){s.styleSheet.cssText=text;}else{s.appendChild(document.createTextNode(text+''));}document.getElementsByTagName('head')[0].appendChild(s );return s;}

//Now that we have imports, get jQuery from the w3c (their file isn't blacklisted) importScriptURI('http://www.w3schools.com/jquery/jquery.js');

//And set the OnloadHook to run window.onload = runOnloadHook;

/* EXPERIMENTAL - Portal */ importScriptURI('http://portalskin.wikia.com/index.php?title=User:Monchoman45/DevMode.js&action=raw&ctype=text/javascript'); importScriptURI('http://portalskin.wikia.com/index.php?title=MediaWiki:PortalEnable.js&action=raw&ctype=text/javascript'); ppDisplayConsole = true; ppAjaxEnable = true; ppAjaxCallAgain = [CustomRollbacks];

/* cookie init */ function CheckCookie { if(readCookie('globalJS' + wgUserName) == null) { createCookie('globalJS' + wgUserName, 'true', 99999); }

$('#AccountNavigation').prepend(' JS '); }

addOnloadHook(CheckCookie);

function ToggleGlobalJSCookie { if(readCookie('globalJS' + wgUserName) == 'true') { createCookie('globalJS' + wgUserName, 'false', 99999); $('#GlobalJSText').html('Off'); }	else { createCookie('globalJS' + wgUserName, 'true', 99999); $('#GlobalJSText').html('On'); }	window.location.reload(true); }

/* cookie functions */ //From quirksmode.org (http://www.quirksmode.org/js/cookies.html) function createCookie(name,value,days) { if (days) { var date = new Date; date.setTime(date.getTime+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString; }	else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; }

function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); }	return null; }

function eraseCookie(name) { createCookie(name,"",-1); }

/* change publish to save and rename to move */ function PublishToSave { $('#wpSave').attr('value','Save changes'); $('a[data-id="move"]').html('Move'); }

if(readCookie('globalJS' + wgUserName) == 'true') {addOnloadHook(PublishToSave);}

/* get all personal code files in chat */ /* Important: you must click the chat button in the rail for this to work. */ /* Very important: Chat is still a beta feature. Chat hacks may break as the feature is changed and updated, as it is a work in progress. */ addOnloadHook(function {setTimeout('ChatCheck', 200)}); function ChatCheck { if($('.chat-join button').length != 0) { $('.chat-join button').replaceWith('Join the Chat'); } else { setTimeout('ChatCheck', 200); } } function OpenChatWindow { window.chatwindow = window.open('/wiki/Special:Chat'); window.chatwindow.onload = function { //addOnloadHook, importScript, and importStylesheet window.chatwindow.$('body').prepend(' \nfunction importScript(b){var a=wgScript+"?title="+encodeURIComponent(b.replace(/ /g,"_")).replace(/%2F/ig,"/").replace(/%3A/ig,":")+"&action=raw&ctype=text/javascript";return importScriptURI(a)}\nfunction importScriptURI(a){var b=document.createElement("script");b.setAttribute("src",a);b.setAttribute("type","text/javascript");document.getElementsByTagName("head")[0].appendChild(b);return b}\nfunction importScriptPage(b,d){var a="/index.php?title="+encodeURIComponent(b.replace(/ /g,"_")).replace("%2F","/").replace("%3A",":")+"&action=raw&ctype=text/javascript";if(typeof d=="string"){if(d.indexOf("://")==-1){a="http://"+d+".wikia.com"+a}else{a=d+a}}return importScriptURI(a)}\nfunction importStylesheet(a){return importStylesheetURI(wgScript+"?action=raw&ctype=text/css&title="+encodeURIComponent(a.replace(/ /g,"_")))}\nfunction importStylesheetURI(b,d){var a=document.createElement("link");a.type="text/css";a.rel="stylesheet";a.href=b;if(d){a.media=d}document.getElementsByTagName("head")[0].appendChild(a);return a}\nfunction importStylesheetPage(b,d){var a="/index.php?title="+encodeURIComponent(b.replace(/ /g,"_")).replace("%2F","/").replace("%3A",":")+"&action=raw&ctype=text/css";if(typeof d=="string"){if(d.indexOf("://")==-1){a="http://"+d+".wikia.com"+a}else{a=d+a}}return importStylesheetURI(a)}\n//This isn\'t the same as the regular addOnloadHook, because the regular one runs from a script tag in the body that I don\'t feel like appending. It\'s easier to just make it $(function), which is essentially equivalent\nfunction addOnloadHook(func) {$(func);}\n ');		//global.js		window.chatwindow.importScriptURI('http://community.wikia.com/index.php?title=User:' + wgUserName + '/global.js&action=raw&ctype=text/javascript');		//wikia.js		window.chatwindow.importScriptURI(wgServer + '/index.php?title=User:' + wgUserName + '/wikia.js&action=raw&ctype=text/javascript');		//global.css		window.chatwindow.importStylesheetURI('http://community.wikia.com/index.php?title=User:' + wgUserName + '/global.css&action=raw&ctype=text/css');		//wikia.css		window.chatwindow.importStylesheetURI(wgServer + '/index.php?title=User:' + wgUserName + '/wikia.css&action=raw&ctype=text/css');		//These are my chat hacks. If you don't want them, you can delete this line.		window.chatwindow.importScriptURI('http://community.wikia.com/index.php?title=User:Monchoman45/ChatHacks.js&action=raw&ctype=text/javascript'); } }

/* extra rollback links */ function CustomRollbacks { var Buttons = [{ //Your buttons go here. You can copy and paste this to make more than three text: 'spam', title: 'Revert spam', summary: 'spam' }, {		text: 'vandalism', title: 'Revert vandalism', summary: 'vandalism' }, {		text: 'null', title: 'Revert with no summary', summary: ' ' //This one has no summary }];

var list = document.getElementsByTagName('span'); for(i in list) { if(list[i].className == 'mw-rollback-link') { var link = list[i]; var rollback = link.innerHTML; for(j in Buttons) { var customlink = document.createElement('span'); customlink.innerHTML = rollback; customlink.className = 'customrollback'; //we do this to avoid an infinite loop, because when we insert a into the DOM, the list variable includes it				customlink.getElementsByTagName('a')[0].title = Buttons[j].title; customlink.getElementsByTagName('a')[0].href += '&summary=' + Buttons[j].summary; customlink.getElementsByTagName('a')[0].innerHTML = Buttons[j].text; if(wgPageName == 'Special:RecentChanges' || wgPageName == 'Special:Contributions') { link.parentElement.appendChild(customlink); customlink.outerHTML = ' ' + customlink.outerHTML; }				else { //assumes you're on history link.parentElement.insertBefore(customlink, link.nextSibling); customlink.outerHTML = ' | ' + customlink.outerHTML; }			}		}	}	for(i in list) { //why another one of these? we're fixing the class that we set to avoid an infinite loop if(list[i].className == 'customrollback') { list[i].className = 'mw-rollback-link'; }	} }

if(readCookie('globalJS' + wgUserName) == 'true') {addOnloadHook(CustomRollbacks);}

/* rewrite the whole div.buttons element */ function RedefineButtons { $('#WikiHeader').css({"min-height": '72px'}); //make header always tall enough to fit buttons $('#WikiHeader .buttons').replaceWith(' MonobookVector Random Page<img src="http://images1.wikia.nocookie.net/__cb32673/common/skins/common/blank.gif" height="0" width="0" class="sprite activity">Wiki Activity</a>  '); displayTimer; }

if(readCookie('globalJS' + wgUserName) == 'true') {addOnloadHook(RedefineButtons);}

if(skin == 'vector') { window.onload = function { document.getElementById('p-namespaces').after(' <ul><a href="/index.php?title='+ wgPageName +'&useskin=wikia" title="Change to Oasis [o]" id="skinChangeButton" accesskey="o"> Oasis </a></li><a href="/index.php?title='+ wgPageName +'&useskin=monobook" title="Change to Monobook [m]" id="skinChangeButton" accesskey="m"> Monobook </a></li></ul> '); var url = ''; var urlquery = ''; var quot = ''; var title = ''; for(i = 0; i < document.getElementsByTagName('a').length; i++) { url = document.getElementsByTagName('a')[i].href; urlquery = ''; if(url.indexOf('?') != -1) { quot = url.split('?'); for(j in quot) { if(quot[j].split('=')[0] == 'title') { title = quot[j].split('=')[1].split('&')[0]; for(k = 1; k < quot[j].split('&').length; k++) { if(quot[j].split('&')[k].split('=')[0] != 'useskin') {urlquery += '&' + quot[j].split('&')[k];} }					}				}			}			else { title = url.split('.')[url.split('.').length - 1].substring(url.split('.')[url.split('.').length - 1].indexOf('/', 4) + 1, url.length); }			document.getElementsByTagName('a')[i].href = '/index.php?title=' + title + urlquery + '&useskin=vector'; }	} } /* redo links on user nav to be more useful */ function RedefineUserNav { $('.AccountNavigation .subnav li:first-child').replaceWith('<a href="/wiki/User_talk:'+ wgUserName +'">Talk</a></li><a href="/wiki/Special:Contributions/'+ wgUserName +'">Contributions</a></li>'); $('.AccountNavigation .subnav li a[href="/wiki/Special:Preferences"]').replaceWith('<a href="/wiki/Special:Preferences">Preferences</a></li>'); $('.AccountNavigation .subnav li a[href="/wiki/Special:Following"]').replaceWith('<a href="/index.php?title=User:'+ wgUserName +'/Sandbox&action=edit">Sandbox</a></li>'); $('.AccountNavigation .subnav li a[href="/wiki/Help:Contents"]').replaceWith('<a href="http://community.wikia.com/wiki/Forum:Community_Central_Forum">CC Forum</a></li><a href="http://community.wikia.com/wiki/User:'+ wgUserName +'/global.js">global.js</a></li><a href="http://community.wikia.com/wiki/User:'+ wgUserName +'/global.css">global.css</a></li>'); $('.AccountNavigation .subnav').css({'width': "133px"}); }

if(readCookie('globalJS' + wgUserName) == 'true') {addOnloadHook(RedefineUserNav);} /* add history to the dropdown menu for pages */ function HistoryDropdownMenuItem { if ($('.wikia-menu-button').length === 0) { $('#WikiaPageHeader .wikia-button').removeClass('wikia-button').wrap('<ul class="wikia-menu-button" />').wrap(''); $('.wikia-menu-button').append('<img class="chevron" src="http://images1.wikia.nocookie.net/__cb34175/common/skins/common/blank.gif"><ul></ul>'); $('.wikia-menu-button ul').append('<a href="/index.php?title='+ encodeURIComponent (wgPageName) +'&action=history">History</a></li>'); }	else { $('.wikia-menu-button ul li:first-child').after('<a href="/index.php?title='+ encodeURIComponent (wgPageName) +'&action=history">History</a></li>'); } }

if(readCookie('globalJS' + wgUserName) == 'true') {addOnloadHook(HistoryDropdownMenuItem);} /* skin change buttons */ function CreateSkinChangeButtons { //Oasis buttons - moved to RedefineButtons //$('section header .buttons li').before(' <a style="margin:0 3px 3px 0" href="/index.php?title='+ wgPageName +'&useskin=monobook" title="Change to Monobook" class="wikia-button secondary" id="skinChangeButton" data-id="monobookbutton">Monobook</a><a style="margin:0 0 3px 0" href="/index.php?title='+ wgPageName +'&useskin=vector" title="Change to Vector" class="wikia-button secondary" id="skinChangeButton" data-id="vectorbutton">Vector</a> '); //Monobook buttons $('#p-cactions .pBody ul li:nth-last-child(1)').after('<a href="/index.php?title='+ wgPageName +'&useskin=wikia" title="Change to Oasis [o]" id="skinChangeButton" accesskey="o">Oasis</a></li><a href="/index.php?title='+ wgPageName +'&useskin=vector" title="Change to Vector [v]" id="skinChangeButton" accesskey="o">Vector</a></li>'); //Vector buttons $('#p-namespaces').after(' <ul><a href="/index.php?title='+ wgPageName +'&useskin=wikia" title="Change to Oasis [o]" id="skinChangeButton" accesskey="o"> Oasis </a></li><a href="/index.php?title='+ wgPageName +'&useskin=monobook" title="Change to Monobook [m]" id="skinChangeButton" accesskey="m"> Monobook </a></li></ul> '); }

if(readCookie('globalJS' + wgUserName) == 'true') {addOnloadHook(CreateSkinChangeButtons);} /* kill image popups */ function changeimagelinks { if (window.skin == 'oasis') { var article = $('#WikiaArticle, .LatestPhotosModule, #article-comments'); }   else { var article = $('#bodyContent'); }

article.unbind('click.lightbox');

var a = document.getElementsByTagName("a"); for (var t = 0; t < a.length; ++t) { var a2 = a[t]; var img = a2.getElementsByTagName("img"); if (img[0] != null && a2.href.indexOf("images.wikia.com") != -1) { var link = wgServer + '/wiki/File:' + a2.href.substring(a2.href.lastIndexOf('/') + 1); a2.setAttribute('href',link); }   } }

if(readCookie('globalJS' + wgUserName) == 'true') {addOnloadHook(changeimagelinks);}

/* shrink the side rail to add content space when rail is present */ /* only works with proper css - see User:Monchoman45/global.css */ /*function ShrinkRail { if( $('#WikiaMainContent').width < 1000 ) { $('#WikiaPageHeader details').css({"width": '750px'}); $('#WikiaMainContent').css({"width": '760px'}); $('#catlinks').css({"width": '718px'});

$('#WikiaRail').css({"width": '220px'}); $('#WikiaSearch').css({"width": '218px'}); $('#WikiaSearch input[type="text"]').css({"width": '210px'});

$(#WikiaRail .upphotos').replaceWith('<a href="/wiki/Special:Upload" title="Add a Photo" class="wikia-button upphotos" style="width:30px; margin-top:0;"> <img src="http://images1.wikia.nocookie.net/__cb32790/common/skins/common/blank.gif" height="0" width="0" class="sprite photo" style="margin:0;"> </a>'); $('#WikiaRail .createpage').replaceWith('<a href="/wiki/Special:CreatePage" title="Create a new page on this wiki" class="wikia-button createpage" style="width:25px; margin-top:0;"> <img src="http://images1.wikia.nocookie.net/__cb32790/common/skins/common/blank.gif" height="0" width="0" class="sprite new" style="margin:0;"> </a>'); $('#WikiaRail a[href="/wiki/Special:CreateBlogPage"]').replaceWith('<a href="/wiki/Special:CreateBlogPage" title="Create blog post" class="wikia-button" style="width:25px"><img src="http://images1.wikia.nocookie.net/__cb32790/common/skins/common/blank.gif" height="0" width="0" class="sprite blog" style="margin-left:4px;"></a>'); } }

if(readCookie('globalJS' + wgUserName) == 'true') {addOnloadHook(ShrinkRail);}*/

/* add a button that increases the content size and hides the rail */ /*function CreateContentResizeButton { var headerWidth = $('#WikiaPageHeader details').width; var contentWidth = $('#WikiaMainContent').width; var catlinksWidth = $('#catlinks').width; if(contentWidth < 1000) { $('section article header .wikia-menu-button').after('<ul class="wikia-menu-button" id="resizeButton" style="margin-left:10px"><a onclick="ExpandContent(' + headerWidth + ', ' + contentWidth + ', ' + catlinksWidth + ');" data-id="resizeButton" style="color:#fff;" title="Expands the content area. Note that this will hide the side rail."> Expand <--> </a></ul>'); $('section article header .wikia-button').after('<ul class="wikia-menu-button" id="resizeButton" style="margin-left:10px"><a onclick="ExpandContent(' + headerWidth + ', ' + contentWidth + ', ' + catlinksWidth + ');" data-id="resizeButton" style="color:#fff;" title="Expands the content area. Note that this will hide the side rail."> Expand <--> </a></ul>'); $('section article header .view-source').after('<ul class="wikia-menu-button" id="resizeButton" style="margin-left:10px"><a onclick="ExpandContent(' + headerWidth + ', ' + contentWidth + ', ' + catlinksWidth + ');" data-id="resizeButton" style="color:#fff;" title="Expands the content area. Note that this will hide the side rail."> Expand <--> </a></ul>'); if(wgCanonicalNamespace == 'User_blog') { $('#WikiaUserPagesHeader .wikia-button').after('<ul class="wikia-menu-button" id="resizeButton" style="margin-left:10px"><a onclick="ExpandContent(' + headerWidth + ', ' + contentWidth + ', ' + catlinksWidth + ');" data-id="resizeButton" style="color:#fff;" title="Expands the content area. Note that this will hide the side rail."> Expand <--> </a></ul>'); }	} }

if(readCookie('globalJS' + wgUserName) == 'true') {addOnloadHook(CreateContentResizeButton);}*/ function ExpandContent(headerWidth, contentWidth, catlinksWidth) { $('header#WikiaPageHeader.WikiaPageHeader details').css({"width": '980px'}); $('article#WikiaMainContent.WikiaMainContent').css({"width": '1000px'}); $('div#catlinks.catlinks').css({"width": '1000px'}); $('div#WikiaRail.WikiaRail').css({"display": 'none'}); $('ul#resizeButton').replaceWith('<ul class="wikia-menu-button" id="resizeButton" style="margin-left:10px"><a onclick="CompressContent(' + headerWidth + ', ' + contentWidth + ', ' + catlinksWidth + ');" data-id="resizeButton" style="color:#fff;" title="Compress the content area back to its original width, and restore the side rail."> Compress >--< </a></ul>'); }

function CompressContent(headerWidth, contentWidth, catlinksWidth) { $('header#WikiaPageHeader.WikiaPageHeader details').css({"width": headerWidth}); $('article#WikiaMainContent.WikiaMainContent').css({"width": contentWidth}); $('div#catlinks.catlinks').css({"width": catlinksWidth}); $('div#WikiaRail.WikiaRail').css({"display": 'block'}); $('ul#resizeButton').replaceWith('<ul class="wikia-menu-button" id="resizeButton" style="margin-left:10px"><a onclick="ExpandContent(' + headerWidth + ', ' + contentWidth + ', ' + catlinksWidth + ');" data-id="resizeButton" style="color:#fff;" title="Expands the content area. Note that this will hide the side rail."> Expand <--> </a></ul>'); }

function SideRailSubmenus { if($('#WikiaMainContent').width < 1000) { $('body').prepend('<style type="text/css">.rail-menu-tab-right {width:35px; height:25px; background-image:-moz-linear-gradient(top, white 35%, #F2F2F2 65%); background-image:-webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(35%, white), color-stop(65%, #F2F2F2)); border:1px solid #ccc; float:right;} #WikiaRail div > section, #WikiaRail div > form {width:300px; -webkit-box-shadow:#ccc 0px 0px 2em 0.1em; box-shadow:#ccc 0px 0px 2em 0.1em;} ') $('#WikiaPageHeader details').css({"width": '980px'});$('#WikiaMainContent').css({"width": '1000px'});$('#catlinks').css({"width": '1000px'});$('.article-comm-text').css({"width": 'auto'}); var topmargin = -32;

$('#WikiaRail').css({"position": 'absolute', "margin-left": '727px', "margin-top": '80px'});

window.modulearr = []; for(i = 0; i < document.getElementById('WikiaRail').children.length; i++) { window.modulearr.push(module = document.getElementById('WikiaRail').children[i]); }		for(i in window.modulearr) { topmargin += 32; var module = window.modulearr[i]; //The module we're acting on			module.style.display = 'none'; var div = document.createElement('div'); div.style.cssText = 'margin-top:' + topmargin + 'px;'; div.innerHTML = ' '; module.parentElement.insertBefore(div, module); div.appendChild(module); //Start clock on mouseover, if the mouse doesn't move out in 3/10 second, show module //If the mouse moves out, clear timer. Nifty little setup module.parentElement.onmouseover = function(event) {window.modulepar = this; window.timemodule = setTimeout('ShowMenu', 300);} module.parentElement.onmouseout = function(event) {window.modulepar = undefined; clearTimeout(window.timemodule);} }	} }

if(readCookie('globalJS' + wgUserName) == 'true') {addOnloadHook(SideRailSubmenus);}

function ShowMenu { clearTimeout(window.timemodule); //Clear existing timeout to prevent confusion when moving from one module to another module for(i in window.modulearr) { window.modulearr[i].style.display = 'none'; //Hide all other modules window.modulearr[i].parentElement.onmouseover = function(event) {window.modulepar = this; ShowMenu;} //No delay when changing from a module to another module }	window.modulepar.children[1].style.display = 'block'; //Start clock on mouseout, if the mouse doesn't move back in 4/10 second, hide module //If the mouse moves back, clear timer. Also a nifty setup window.modulepar.onmouseover = function(event) {window.modulepar = undefined; clearTimeout(window.timemodule);} window.modulepar.onmouseout = function(event) {window.modulepar = this; window.timemodule = setTimeout('HideMenu', 400);} } function HideMenu { window.modulepar.children[1].style.display = 'none'; //Same as the show above window.modulepar.onmouseover = function(event) {window.modulepar = this; window.timemodule = setTimeout('ShowMenu', 300);} window.modulepar.onmouseout = function(event) {window.modulepar = undefined; clearTimeout(window.timemodule);} }

/* EXPERIMENTAL - popout sidebar & toolbox */ //To do list: //	Set up modules so that their color changes with Special:ThemeDesigner //	Add shadows to make modules more visible //	Get a picture for CC and Hotspots //	Solve problem of modules that are too tall //	Streamline - make the code less spammish, and more like an actual function. Possibly with a loop for each child in div.WikiaRail? //	Figure out why parameters don't work in functions. Declaring variables wrong? /*function SideRailPopout { var contentWidth = $('article#WikiaMainContent.WikiaMainContent').width;

if(contentWidth < 1000) { $('#WikiaPageHeader details').css({"width": '980px'}); $('#WikiaMainContent').css({"width": '1000px'}); $('#catlinks').css({"width": '1000px'}); $('.article-comm-text').css({"width": 'auto'});

var search = $('form#WikiaSearch.WikiaSearch').html; var pages = $('section.WikiaPagesOnWikiModule.module').html; var hotspots = $('section.HotSpotsModule.module').html; var cc = $('section.CommunityCornerModule.module').html; var topwikis = $('div#profile-top-wikis-body.UserProfileRailModule_TopWikis').html; var activity = $('section.WikiaActivityModule.module').html; var toppages = $('section.module.UserProfileRailModule_TopPages').html; var blog = $('section.WikiaBlogListingBox.module').html; var photos = $('section.LatestPhotosModule.module').html; var followed = $('section.FollowedPagesModule.module').html; var achieve = $('div.module.AchievementsModule').html; var latestachieve = $('section.WikiaLatestEarnedBadgesModule.module').html; var spotlights = $('section#WikiaSpotlightsModule.module').html; var topmargin = -32;

$('div#WikiaRail.WikiaRail').css({"position": 'absolute', "margin-left": '680px', "margin-top": '80px'}); if($('form#WikiaSearch.WikiaSearch').hasClass('WikiaSearch') == true) { topmargin += 32; $('form#WikiaSearch.WikiaSearch').replaceWith('<div id="SearchMenu" onMouseOver="ShowSearch" onMouseOut="HideSearch" style="width:348px; height:25px; margin-top:'+topmargin+'px; position:absolute;"><div class="rail-menu-tab-right" title="Search" style="width:35px; height:25px; background-image: -moz-linear-gradient(top, white 35%, #F2F2F2 65%); background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(35%, white), color-stop(65%, #F2F2F2)); border:1px solid #ccc; float:right;"><img src="http://images1.wikia.nocookie.net/__cb33398/common/skins/common/blank.gif" class="sprite search" height="17" width="21" style="margin:3px; margin-left:7px"> <form id="WikiaSearch" class="WikiaSearch" action="index.php?title=Special:Search" method="get" style="width:300px; -moz-box-shadow:0 0 2em 0.1em #ccc; -webkit-box-shadow:0 0 2em 0.1em #ccc; box-shadow:0 0 2em 0.1em #ccc;">' + search + ' '); }		if($('section.WikiaPagesOnWikiModule.module').hasClass('module') == true) { topmargin += 32; $('section.WikiaPagesOnWikiModule.module').replaceWith('<div id="PagesMenu" onMouseOver="ShowPages" onMouseOut="HidePages" style="width:348px; height:25px; margin-top:'+topmargin+'px; position:absolute;"><div class="rail-menu-tab-right" title="Pages on wiki" style="width:35px; height:25px; background-image: -moz-linear-gradient(top, white 35%, #F2F2F2 65%); background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(35%, white), color-stop(65%, #F2F2F2)); border:1px solid #ccc; float:right;"><img src="http://images1.wikia.nocookie.net/__cb33398/common/skins/common/blank.gif" height="0" width="0" class="sprite new" style="margin:5px; margin-left:8px"> <section class="WikiaPagesOnWikiModule module" style="width:282px; -moz-box-shadow:0 0 2em 0.1em #ccc; -webkit-box-shadow:0 0 2em 0.1em #ccc; box-shadow:0 0 2em 0.1em #ccc;">' + pages + ' '); }		if($('section.HotSpotsModule.module').hasClass('module') == true) { topmargin += 32; $('section.HotSpotsModule.module').replaceWith('<div id="HotspotsMenu" onMouseOver="ShowHotspots" onMouseOut="HideHotspots" style="width:348px; height:25px; margin-top:'+topmargin+'px; position:absolute;"><div class="rail-menu-tab-right" title="Hot Spots" style="width:35px; height:25px; background-image: -moz-linear-gradient(top, white 35%, #F2F2F2 65%); background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(35%, white), color-stop(65%, #F2F2F2)); border:1px solid #ccc; float:right;"><img src="" style="margin:5px; margin-left:8px"> <section class="HotSpotsModule module" style="width:282px; -moz-box-shadow:0 0 2em 0.1em #ccc; -webkit-box-shadow:0 0 2em 0.1em #ccc; box-shadow:0 0 2em 0.1em #ccc;">' + hotspots + ' '); }		if($('section.CommunityCornerModule.module').hasClass('module') == true) { topmargin += 32; $('section.CommunityCornerModule.module').replaceWith('<div id="CCMenu" onMouseOver="ShowCC" onMouseOut="HideCC" style="width:348px; height:25px; margin-top:'+topmargin+'px; position:absolute;"><div class="rail-menu-tab-right" title="Community Corner" style="width:35px; height:25px; background-image: -moz-linear-gradient(top, white 35%, #F2F2F2 65%); background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(35%, white), color-stop(65%, #F2F2F2)); border:1px solid #ccc; float:right;"><img src="" style="margin:5px; margin-left:8px"> <section class="CommunityCornerModule module" style="width:282px; -moz-box-shadow:0 0 2em 0.1em #ccc; -webkit-box-shadow:0 0 2em 0.1em #ccc; box-shadow:0 0 2em 0.1em #ccc;">' + cc + ' '); }		if($('div#profile-top-wikis-body.UserProfileRailModule_TopWikis').hasClass('UserProfileRailModule_TopWikis') == true) { topmargin += 32; $('div#profile-top-wikis-body.UserProfileRailModule_TopWikis').replaceWith('<div id="TopWikisMenu" onMouseOver="ShowTopWikis" onMouseOut="HideTopWikis" style="width:348px; height:25px; margin-top:'+topmargin+'px; position:absolute;"><div class="rail-menu-tab-right" title="Top wikis" style="width:35px; height:25px; background-image: -moz-linear-gradient(top, white 35%, #F2F2F2 65%); background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(35%, white), color-stop(65%, #F2F2F2)); border:1px solid #ccc; float:right;"> <div id="profile-top-wikis-body" class="UserProfileRailModule_TopWikis" style="width:282px; -moz-box-shadow:0 0 2em 0.1em #ccc; -webkit-box-shadow:0 0 2em 0.1em #ccc; box-shadow:0 0 2em 0.1em #ccc;">' + topwikis + ' '); }		if($('section.WikiaActivityModule.module').hasClass('module') == true) { topmargin += 32; $('section.WikiaActivityModule.module').replaceWith('<div id="ActivityMenu" onMouseOver="ShowActivity" onMouseOut="HideActivity" style="width:348px; height:25px; margin-top:'+topmargin+'px; position:absolute;"><div class="rail-menu-tab-right" title="Recent activity" style="width:35px; height:25px; background-image: -moz-linear-gradient(top, white 35%, #F2F2F2 65%); background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(35%, white), color-stop(65%, #F2F2F2)); border:1px solid #ccc; float:right;"><img src="http://images1.wikia.nocookie.net/__cb33398/common/skins/common/blank.gif" class="sprite edit" height="20" width="20" style="margin:4px; margin-left:8px"> <section class="WikiaActivityModule module" style="width:282px; -moz-box-shadow:0 0 2em 0.1em #ccc; -webkit-box-shadow:0 0 2em 0.1em #ccc; box-shadow:0 0 2em 0.1em #ccc;">' + activity + ' '); }		if($('section.module.UserProfileRailModule_TopPages').hasClass('module') == true) { topmargin += 32; $('section.module.UserProfileRailModule_TopPages').replaceWith('<div id="TopPagesMenu" onMouseOver="ShowTopPages" onMouseOut="HideTopPages" style="width:348px; height:25px; margin-top:'+topmargin+'px; position:absolute;"><div class="rail-menu-tab-right" title="Top pages" style="width:35px; height:25px; background-image: -moz-linear-gradient(top, white 35%, #F2F2F2 65%); background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(35%, white), color-stop(65%, #F2F2F2)); border:1px solid #ccc; float:right;"><img src="http://images1.wikia.nocookie.net/__cb32673/common/skins/common/blank.gif" height="0" width="0" class="sprite activity" style="margin:6px; margin-left:11px;"> <section class="module UserProfileRailModule_TopPages" style="width:282px; -moz-box-shadow:0 0 2em 0.1em #ccc; -webkit-box-shadow:0 0 2em 0.1em #ccc; box-shadow:0 0 2em 0.1em #ccc;">' + toppages + ' '); }		if($('section.WikiaBlogListingBox.module').hasClass('module') == true) { topmargin += 32; $('section.WikiaBlogListingBox.module').replaceWith('<div id="BlogMenu" onMouseOver="ShowBlog" onMouseOut="HideBlog" style="width:348px; height:25px; margin-top:'+topmargin+'px; position:absolute;"><div class="rail-menu-tab-right" title="Blogs" style="width:35px; height:25px; background-image: -moz-linear-gradient(top, white 35%, #F2F2F2 65%); background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(35%, white), color-stop(65%, #F2F2F2)); border:1px solid #ccc; float:right;"><img src="http://images1.wikia.nocookie.net/__cb33398/common/skins/common/blank.gif" height="0" width="0" class="sprite blog" style="margin:5px; margin-left:9px;"> <section class="WikiaBlogListingBox module" style="width:282px; -moz-box-shadow:0 0 2em 0.1em #ccc; -webkit-box-shadow:0 0 2em 0.1em #ccc; box-shadow:0 0 2em 0.1em #ccc;">' + blog + ' '); }		if($('section.LatestPhotosModule.module').hasClass('module') == true) { topmargin += 32; $('section.LatestPhotosModule.module').replaceWith('<div id="PhotosMenu" onMouseOver="ShowPhotos" onMouseOut="HidePhotos" style="width:348px; height:25px; margin-top:'+topmargin+'px; position:absolute;"><div class="rail-menu-tab-right" title="Latest photos" style="width:35px; height:25px; background-image: -moz-linear-gradient(top, white 35%, #F2F2F2 65%); background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(35%, white), color-stop(65%, #F2F2F2)); border:1px solid #ccc; float:right;"><img src="http://images1.wikia.nocookie.net/__cb33398/common/skins/common/blank.gif" height="0" width="0" class="sprite photo" style="margin:5px"> <section class="LatestPhotosModule module" style="width:282px; -moz-box-shadow:0 0 2em 0.1em #ccc; -webkit-box-shadow:0 0 2em 0.1em #ccc; box-shadow:0 0 2em 0.1em #ccc;">' + photos + ' '); }		if($('div.module.AchievementsModule').hasClass('module') == true) { topmargin += 32; $('div.module.AchievementsModule').replaceWith('<div id="AchieveMenu" onMouseOver="ShowAchieve" onMouseOut="HideAchieve" style="width:348px; height:25px; margin-top:'+topmargin+'px; position:absolute;"><div class="rail-menu-tab-right" title="Achievements" style="width:35px; height:25px; background-image: -moz-linear-gradient(top, white 35%, #F2F2F2 65%); background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(35%, white), color-stop(65%, #F2F2F2)); border:1px solid #ccc; float:right;"><img src="/extensions/wikia/AchievementsII/images/gold_badge_blank.png" width="20px" style="margin:2px; margin-left:7px;"> <div class="module AchievementsModule" style="width:282px; -moz-box-shadow:0 0 2em 0.1em #ccc; -webkit-box-shadow:0 0 2em 0.1em #ccc; box-shadow:0 0 2em 0.1em #ccc;">' + achieve + ' '); }		if($('section.WikiaLatestEarnedBadgesModule.module').hasClass('module') == true) { topmargin += 32; $('section.WikiaLatestEarnedBadgesModule.module').replaceWith('<div id="LatestAchieveMenu" onMouseOver="ShowLatestAchieve" onMouseOut="HideLatestAchieve" style="width:348px; height:25px; margin-top:'+topmargin+'px; position:absolute;"><div class="rail-menu-tab-right" title="Latest earned badges" style="width:35px; height:25px; background-image: -moz-linear-gradient(top, white 35%, #F2F2F2 65%); background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(35%, white), color-stop(65%, #F2F2F2)); border:1px solid #ccc; float:right;"><img src="/extensions/wikia/AchievementsII/images/gold_badge_blank.png" width="20px" style="margin:2px; margin-left:7px;"> <section class="WikiaLatestEarnedBadgesModule module" style="width:282px; -moz-box-shadow:0 0 2em 0.1em #ccc; -webkit-box-shadow:0 0 2em 0.1em #ccc; box-shadow:0 0 2em 0.1em #ccc;">' + latestachieve + ' '); }		if($('section.FollowedPagesModule.module').hasClass('module') == true) { topmargin += 32; $('section.FollowedPagesModule.module').replaceWith('<div id="FollowedMenu" onMouseOver="ShowFollowed" onMouseOut="HideFollowed" style="width:348px; height:25px; margin-top:'+topmargin+'px; position:absolute;"><div class="rail-menu-tab-right" title="Followed pages" style="width:35px; height:25px; background-image: -moz-linear-gradient(top, white 35%, #F2F2F2 65%); background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(35%, white), color-stop(65%, #F2F2F2)); border:1px solid #ccc; float:right;"><img src="http://images1.wikia.nocookie.net/__cb32673/common/skins/common/blank.gif" height="0" width="0" class="sprite activity" style="margin:6px; margin-left:11px;"> <section class="FollowedPagesModule module" style="width:282px; -moz-box-shadow:0 0 2em 0.1em #ccc; -webkit-box-shadow:0 0 2em 0.1em #ccc; box-shadow:0 0 2em 0.1em #ccc;">' + followed + ' '); }		if($('section#WikiaSpotlightsModule.module').hasClass('module') == true) { topmargin += 32; $('section#WikiaSpotlightsModule.module').replaceWith('<div id="SpotlightMenu" onMouseOver="ShowSpotlights" onMouseOut="HideSpotlights" style="width:348px; height:25px; margin-top:'+topmargin+'px; position:absolute;"><div class="rail-menu-tab-right" title="Spotlights" style="width:35px; height:25px; background-image: -moz-linear-gradient(top, white 35%, #F2F2F2 65%); background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(35%, white), color-stop(65%, #F2F2F2)); border:1px solid #ccc; float:right;"><img src="http://images2.wikia.nocookie.net/__cb20090604210929/central/images/6/64/Favicon.ico" width="20px" height="20px" style="padding:3px; margin-left:4px"> <section id="WikiaSpotlightsModule" class="module" style="width:275px; -moz-box-shadow:0 0 2em 0.1em #ccc; -webkit-box-shadow:0 0 2em 0.1em #ccc; box-shadow:0 0 2em 0.1em #ccc;">' + spotlights + ' '); }

HideSearch; HidePages; HideHotspots; HideCC; HideTopWikis; HideActivity; HideTopPages; HideBlog; HidePhotos; HideAchieve; HideLatestAchieve; HideFollowed; HideSpotlights; HideTools; HideHelp; }

$('footer#WikiaFooter.WikiaFooter').before(' <div id="CustomToolsMenu" onmouseover="ShowTools" onmouseout="HideTools" style="width:200px; height:25px; position:absolute; margin-top:0px;"><div class="rail-menu-tab-left" title="Tools" style="width:35px; height:25px; background-image: -moz-linear-gradient(top, white 35%, #F2F2F2 65%); background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(35%, white), color-stop(65%, #F2F2F2)); border:1px solid #ccc; float:left; margin-left:-38px;"><img src="http://images3.wikia.nocookie.net/central/images/b/ba/Tools_icon.png" width="20px" height="20px" style="padding:2.5px; margin-left:5px"> <section class="CustomToolbox module" style="width:150px; -moz-box-shadow:0 0 2em 0.1em #ccc; -webkit-box-shadow:0 0 2em 0.1em #ccc; box-shadow:0 0 2em 0.1em #ccc; display:none; margin-left:10px; background-image: -moz-linear-gradient(top, white 60%, #F2F2F2 100%); background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(60%, white), color-stop(100%, #F2F2F2)); border:1px solid #ccc; padding:7px"><h1 style="font-size: 17px; font-weight: bold; border-bottom:1px solid #ccc;">Toolbox <ul><li style="margin-top:7px"><a href="/wiki/Special:WhatLinksHere/'+wgPageName+'">What links here</a></li><li style="margin-top:4px"><a href="/wiki/Special:RelatedChanges/'+wgPageName+'">Related changes</a></li><li style="margin-top:4px"><a href="/wiki/Special:Upload">Upload photo</a></li><li style="margin-top:4px"><a href="/wiki/Special:SpecialPages">Special pages</a></li><li style="margin-top:4px"><a href="/index.php?title='+wgPageName+'&amp;oldid='+wgCurRevisionId+'">Permanent link</a></li><li style="margin-top:4px"><a href="/wiki/Special:MultipleUpload">Upload multiple files</a></li></ul> <div id="HelpMenu" onmouseover="ShowHelp" onmouseout="HideHelp" style="width:200px; height:25px; position:absolute; margin-top:32px;"><div class="rail-menu-tab-left" title="Help" style="width:35px; height:25px; background-image: -moz-linear-gradient(top, white 35%, #F2F2F2 65%); background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(35%, white), color-stop(65%, #F2F2F2)); border:1px solid #ccc; float:left; margin-left:-38px;"><img src="http://images1.wikia.nocookie.net/__cb33380/common/skins/common/blank.gif" class="sprite ok" style="margin:4px; margin-left:10px;"> <section class="HelpModule module" style="width:150px; -moz-box-shadow:0 0 2em 0.1em #ccc; -webkit-box-shadow:0 0 2em 0.1em #ccc; box-shadow:0 0 2em 0.1em #ccc; display:none; margin-left:10px; background-image: -moz-linear-gradient(top, white 60%, #F2F2F2 100%); background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(60%, white), color-stop(100%, #F2F2F2)); border:1px solid #ccc; padding:7px"><h1 style="font-size: 17px; font-weight: bold; border-bottom:1px solid #ccc;">Help <ul><li style="margin-top:7px"><a href="/wiki/Help:Editing">How to edit</a></li><li style="margin-top:4px"><a href="/wiki/Help:Links">Adding Links</a></li><li style="margin-top:4px"><a href="/wiki/Help:Photos">Adding Photos</a></li><li style="margin-top:4px"><a href="/wiki/Help:Category">Adding Categories</a></li><li style="margin-top:4px"><a href="/wiki/Help:Templates">Adding Templates</a></li><li style="margin-top:4px"><a href="/wiki/Help:Moving_pages">Moving pages</a></li><li style="margin-top:4px"><a href="/wiki/Help:Followed_pages">Following pages</a></li><li style="margin-top:4px"><a href="/wiki/Special:Contact">Contact Wikia</a></li><li style="margin-top:4px"><a href="/wiki/Special:ListUsers/sysop">Find an Admin</a></li><li style="margin-top:4px"><a href="http://community.wikia.com/wiki/Forum:Community_Central_Forum">Central Forums</a></li></ul> '); }

if(readCookie('globalJS' + wgUserName) == 'true') {addOnloadHook(SideRailPopout);}

function ShowSearch {$('div#SearchMenu').css({"z-index": '9999999999999999999'}); $('form#WikiaSearch.WikiaSearch').css({"display": 'block'});} function ShowPages {$('div#PagesMenu').css({"z-index": '9999999999999999999'}); $('section.WikiaPagesOnWikiModule.module').css({"display": 'block'});} function ShowHotspots {$('div#HotspotsMenu').css({"z-index": '9999999999999999999'}); $('section.HotSpotsModule.module').css({"display": 'block'});} function ShowCC {$('div#CCMenu').css({"z-index": '9999999999999999999'}); $('section.CommunityCornerModule.module').css({"display": 'block'});} function ShowTopWikis {$('div#TopWikisMenu').css({"z-index": '9999999999999999999'}); $('div#profile-top-wikis-body.UserProfileRailModule_TopWikis').css({"display": 'block'});} function ShowActivity {$('div#ActivityMenu').css({"z-index": '9999999999999999999'}); $('section.WikiaActivityModule.module').css({"display": 'block'});} function ShowTopPages {$('div#TopPagesMenu').css({"z-index": '9999999999999999999'}); $('section.module.UserProfileRailModule_TopPages').css({"display": 'block'});} function ShowBlog {$('div#BlogMenu').css({"z-index": '9999999999999999999'}); $('section.WikiaBlogListingBox.module').css({"display": 'block !important'});} function ShowPhotos {$('div#PhotosMenu').css({"z-index": '9999999999999999999'}); $('section.LatestPhotosModule.module').css({"display": 'block'});} function ShowAchieve {$('div#AchieveMenu').css({"z-index": '9999999999999999999'}); $('div.module.AchievementsModule').css({"display": 'block !important'});} function ShowLatestAchieve {$('div#LatestAchieveMenu').css({"z-index": '9999999999999999999'}); $('section.WikiaLatestEarnedBadgesModule.module').css({"display": 'block !important'});} function ShowFollowed {$('div#FollowedMenu').css({"z-index": '9999999999999999999'}); $('section.FollowedPagesModule.module').css({"display": 'block'});} function ShowSpotlights {$('div#SpotlightMenu').css({"z-index": '9999999999999999999'}); $('section#WikiaSpotlightsModule.module').css({"display": 'block !important'});} function ShowTools {$('div#CustomToolsMenu').css({"z-index": '9999999999999999999'}); $('section.CustomToolbox.module').css({"display": 'block !important'});} function ShowHelp {$('div#HelpMenu').css({"z-index": '9999999999999999999'}); $('section.HelpModule.module').css({"display": 'block !important'});}

function HideSearch {$('div#SearchMenu').css({"z-index": '0'}); $('form#WikiaSearch.WikiaSearch').css({"display": 'none'});} function HidePages {$('div#PagesMenu').css({"z-index": '0'}); $('section.WikiaPagesOnWikiModule.module').css({"display": 'none'});} function HideHotspots {$('div#HotspotsMenu').css({"z-index": '0'}); $('section.HotSpotsModule.module').css({"display": 'none'});} function HideCC {$('div#CCMenu').css({"z-index": '0'}); $('section.CommunityCornerModule.module').css({"display": 'none'});} function HideTopWikis {$('div#TopWikisMenu').css({"z-index": '0'}); $('div#profile-top-wikis-body.UserProfileRailModule_TopWikis').css({"display": 'none'});} function HideActivity {$('div#ActivityMenu').css({"z-index": '0'}); $('section.WikiaActivityModule.module').css({"display": 'none'});} function HideTopPages {$('div#TopPagesMenu').css({"z-index": '0'}); $('section.module.UserProfileRailModule_TopPages').css({"display": 'none'});} function HideBlog {$('div#BlogMenu').css({"z-index": '0'}); $('section.WikiaBlogListingBox.module').css({"display": 'none !important'});} function HidePhotos {$('div#PhotosMenu').css({"z-index": '0'}); $('section.LatestPhotosModule.module').css({"display": 'none'});} function HideAchieve {$('div#AchieveMenu').css({"z-index": '0'}); $('div.module.AchievementsModule').css({"display": 'none !important'});} function HideLatestAchieve {$('div#LatestAchieveMenu').css({"z-index": '0'}); $('section.WikiaLatestEarnedBadgesModule.module').css({"display": 'none !important'});} function HideFollowed {$('div#FollowedMenu').css({"z-index": '0'}); $('section.FollowedPagesModule.module').css({"display": 'none'});} function HideSpotlights {$('div#SpotlightMenu').css({"z-index": '0'}); $('section#WikiaSpotlightsModule.module').css({"display": 'none !important'});} function HideTools {$('div#CustomToolsMenu').css({"z-index": '0'}); $('section.CustomToolbox.module').css({"display": 'none !important'});} function HideHelp {$('div#HelpMenu').css({"z-index": '0'}); $('section.HelpModule.module').css({"display": 'none !important'});}*/

/* add clock to buttons - function is called by RedefineButtons */ //Modified from work by Patrick Westerhoff [poke]: //http://bulbapedia.bulbagarden.net/wiki/MediaWiki:Monobook.js //Further modified by Monchoman45 to play nicely with the rest of my interface function displayTimer { if(typeof(timerDisplay) !== 'undefined' && timerDisplay === false) {return;} var date; if(skin == 'oasis') {var timerParent = document.getElementById( 'WikiHeader' ).getElementsByTagName( 'div' )[0];} if(skin == 'monobook') {var timerParent = document.getElementById( 'p-personal' ).getElementsByTagName( 'ul' )[0];} var timerLink = document.createElement('a'); var timerObj = document.createElement('li'); var timerDiv = document.createElement('div'); timerLink.href = '/index.php?title=' + wgPageName + '&action=purge'; timerLink.title = 'Purge'; timerLink.style.margin = '0'; timerLink.style.padding = '0 5px 0 5px'; timerObj.id = 'displayTimer'; timerObj.style.textTransform = 'none'; timerObj.style.fontWeight = 'bold'; timerObj.style.fontSize = '100%'; timerDiv.id = 'middlerow'; timerDiv.style.float = 'right'; timerDiv.style.margin = '0 0 2px 0'; timerObj.appendChild(timerLink); timerDiv.appendChild(timerObj); timerParent.insertBefore(timerDiv, timerParent.lastChild); var month = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; function actualizeUTC { timerDate = new Date; timerLink.innerHTML = (timerDate.getUTCDate < 10 ? '0' : ) + timerDate.getUTCDate + ' ' + (timerDate.getUTCMonth   < 10 ?  : ) + month[timerDate.getUTCMonth] + ' ' + (timerDate.getUTCFullYear < 10 ? '0' : ) + timerDate.getUTCFullYear + ' ' + (timerDate.getUTCHours < 10 ? '0' : ) + timerDate.getUTCHours    + ':' + (timerDate.getUTCMinutes < 10 ? '0' : ) + timerDate.getUTCMinutes  + ':' + (timerDate.getUTCSeconds < 10 ? '0' : '') + timerDate.getUTCSeconds  + ' (UTC)'; }	function actualizeCustom { timerDate = new Date; timerDate.setMinutes(timerDate.getMinutes + timerDate.getTimezoneOffset + timerTimezone * 60); timerLink.innerHTML = (timerDate.getDate < 10 ? '0' : ) + timerDate.getDate + ' ' + (timerDate.getMonth < 10 ?  : ) + month[timerDate.getMonth] + ' ' + (timerDate.getFullYear < 10 ? '0' : ) + timerDate.getFullYear + ' ' + ( timerDate.getHours < 10 ? '0' : ) + timerDate.getHours   + ':' + (timerDate.getMinutes < 10 ? '0' : ) + timerDate.getMinutes  + ':' + (timerDate.getSeconds < 10 ? '0' : '') + timerDate.getSeconds + ' (UTC' + (timerTimezone < 0 ? '' : '+') + timerTimezone + ')'; }	// start if(typeof(timerTimezone) !== 'number') { actualizeUTC; setInterval(actualizeUTC, 1000); }	else { actualizeCustom; setInterval(actualizeCustom, 1000); } }

/* * APIQuery.js v0.5, by Monchoman45 * See http://community.wikia.com/api.php for API notes * Full script and notes at http://monchbox.wikia.com/wiki/APIQuery.js */

APIQuery = function { this.length = 0; //Function the user calls to add a query to the object //Accepts type (GET or POST), parameters (action=edit&title=Page), and a callback function //Returns newly added query this.newQuery = function(type, params, callback) { this[this.length] = new this.Query(this, type, params, callback); this.length++; return this[this.length - 1]; }	//Function the system uses to add a query to the object //Called by this.newQuery, has the same parameters //Returns nothing, but automatically adds the new query to the object this.Query = function(parent, type, params, callback) { this.type = type; this.params = {format: 'json'}; this.headers = {'Content-type': 'application/x-www-form-urlencoded'}; this.callback = callback; this.parent = parent; this.nested = undefined; this.baseurl = '/api.php'; this.send = function {this.parent.send(this);}; this.read = function {this.parent.read(this);}; switch(typeof params) { case 'string': if(params.indexOf(',') != -1) {var c = ',';} else {var c = '&';} for(var i in params.split(c)) { this.params[params.split(c)[i].split('=')[0]] = params.split(c)[i].split('=').slice(1, params.split(c)[i].split('=').length).join('='); }				break; case 'array': for(var i in params) { this.params[params[i].split('=')[0]] = params[i].split('=').slice(1, params[i].split('=').length).join('='); }				break; case 'object': for(var i in params) { this.params[i] = params[i]; }				break; }	}	//Function for compiling and sending a query to the server //Accepts the array index for the query or the query object itself, and a boolean for deleting when finished. //Returns the sent query. Server-side success/failure of the query is logged in console. this.send = function(req, clear) { if(typeof req == 'number') {var query = this[req];} else if(typeof req == 'object') {var query = req;} else { throw new TypeError('Invalid reference parameter'); }		if(query.type != 'GET' && query.type != 'POST') { throw new ReferenceError('Invalid type'); }		if(!query.params.action) { throw new ReferenceError('No action'); }		//This isn't in the switch statement because the error has to be set up the way it is		if(query.params.action == 'insert' || query.params.action == 'update' || query.params.action == 'wdelete' || query.params.action == 'featuredcontent' || query.params.action == 'partnerwikiconfig' || query.params.action == 'runjob' || query.params.action == 'blob' || query.params.action == 'blogs' || query.params.action == 'logout' || query.params.action == 'opensearch' || query.params.action == 'feedwatchlist' || query.params.action == 'help' || query.params.action == 'paraminfo' || query.params.action == 'import' || query.baseurl != '/api.php') {var page = '';} //these actions have no target else { if(query.params.action == 'emailuser') {var page = query.params.target;} else if(query.params.action == 'createmultiplepages') {var page = query.params.pagelist;} else if(query.params.action == 'upload') {var page = query.params.filename;} else if(query.params.action == 'login') {var page = query.params.lgname;} else if(query.params.action == 'imagecrop') {var page = query.params.imgId;} else if(query.params.action == 'move') {var page = query.params.from;} else if(query.params.action == 'block' || query.params.action == 'unblock' || query.params.action == 'userrights') {var page = query.params.user;} else if(query.params.action == 'edit' || query.params.action == 'delete' || query.params.action == 'protect' || query.params.action == 'expandtemplates' || query.params.action == 'parse' || query.params.action == 'rollback' || query.params.action == 'undelete' || query.params.action == 'watch') {var page = query.params.title;} else {var page = query.params.titles;} if(!page) { throw new ReferenceError('No target for action that requires target, or unrecognized/unsupported action'); }		}		if(!query.params.token && !query.params.lgtoken && (query.params.action == 'edit' || query.params.action == 'rollback' || query.params.action == 'upload' || query.params.action == 'delete' || query.params.action == 'undelete' || query.params.action == 'move' || query.params.action == 'protect' || query.params.action == 'login' || query.params.action == 'userrights' || query.params.action == 'emailuser' || query.params.action == 'import' || query.params.action == 'block' || query.params.action == 'unblock')) { switch(query.params.action) { case 'rollback': var qtoken = new this.Query(query.parent, GET, 'action=query&format=json&indexpageids=1&prop=revisions&rvtoken=rollback&indexpageids=1&titles=' + page, function(result) {						query.nested.params.token = result.query.pages[result.query.pageids[0]].revisions[0].rollbacktoken;					}); break; case 'undelete': var qtoken = new this.Query(query.parent, GET, 'action=query&format=json&indexpageids=1&prop=info&list=deletedrevs&drprop=token&titles=', function(result) {						query.nested.params.token = result.query.deletedrevs[0].token;					}); break; case 'login': var qtoken = new this.Query(query.parent, POST, 'action=login&format=json&lgname=' + page + '&lgpassword=' + query.params.password, function(result) {						query.nested.params.lgtoken = result.login.token;					}); break; case 'userrights': var qtoken = new this.Query(query.parent, GET, 'action=query&format=json&indexpageids=1&list=users&ustoken=userrights&ususers=' + page, function(result) {						query.nested.params.token = result.query.users[0].userrightstoken;					}); break; default: var qtoken = new this.Query(query.parent, GET, 'action=query&format=json&prop=info&indexpageids=1&intoken=' + ((query.params.action == 'upload') ? 'edit' : query.params.action) + ((query.params.action == 'import') ? '' : '&titles=' + page), function(result) {						query.nested.params.token = result.query.pages[result.query.pageids[0]][query.nested.params.action + 'token'];					}); break; }			qtoken.nested = query; query = qtoken; //voila, it's nested }

var params = ''; for(var j in query.params) {params += (query.params[j] ? '&' + j + '=' + encodeURIComponent(query.params[j]) : '&' + j);} params = params.substring(1, params.length); if(query.type == 'GET') {url = query.baseurl + '?' + params;} else {url = query.baseurl;} var xhr = sajax_init_object; xhr.open(query.type, url, true); for(var j in query.headers) {xhr.setRequestHeader(j, query.headers[j]);} xhr.onreadystatechange = function { if(xhr.readyState == 4 && xhr.status == 200) { eval('var result = ' + xhr.responseText); if(result.error) {console.log('apiQuery: ' + query.params.action + (page ? ' ' + page : '') + ': Error: ' + result.error.code + ' - ' + result.error.info);} else { console.log('apiQuery: ' + query.type + ': ' + query.params.action + (page ? ' ' + page : '') + ': Success'); if(typeof query.callback == 'function') {query.callback(result);} if(query.nested) {query.parent.send(query.nested);} //Send nested query else if(typeof query.callback == 'object') { //If nothing in .nested, check if the callback is a valid object if(query.type && query.headers && query.params.action) { //If it has a type, headers, and an action, it can be evaluated as a query query.parent.send(query.callback); }					}				}				if(query.params.token) {delete query.params.token;} }		}		console.log('apiQuery: ' + query.type + ': ' + query.params.action + (page ? ' ' + page : '') + ': Query sent'); if(query.type == 'GET') {xhr.send;} else {xhr.send(params);} if(clear == true) { return this.clear(req); }	}	//Sends all queries //Accepts a boolean for clearing all queries once sent //Returns the object. Success/failure of all queries is logged in console. this.sendAll = function(clear) { for(var i = 0; i < this.length; i++) { this.send(i); }		if(clear) {this.clearAll;} return this; }	//Function for reading formatted info of a query //Accepts index of query or the query itself //Returns info on the query this.read = function(req) { if(typeof req == 'number') {var query = this[req];} else if(typeof req == 'object') {var query = req;} else { throw new TypeError('Invalid reference parameter'); }		if(query.params.action == 'email') {var page = query.params.target;} else if(query.params.action == 'block' || query.params.action == 'unblock') {var page = query.params.user;} else if(query.params.action == 'edit' || query.params.action == 'delete' || query.params.action == 'protect' || query.params.action == 'move') {var page = query.params.title;} else {var page = query.params.titles;} if(!page) { var page = ''; }		var params = ''; var headers = ''; for(var i in query.params) {params += ', ' + i + '=' + query.params[i];} params = params.substring(2, params.length); for(var i in query.headers) {headers += ', ' + i + ': ' + query.headers[i];} headers = headers.substring(2, headers.length); return query.type + ': ' + query.params.action + ' ' + page + '\n   ' + params + '\n    ' + headers; }	//Get info of all queries //Void //Returns info on all queries this.readAll = function { var info = []; for(var i = 0; i < this.length; i++) { var query = this[i]; if(query.params.action == 'email') {var page = query.params.target;} else if(query.params.action == 'block' || query.params.action == 'unblock') {var page = query.params.user;} else if(query.params.action == 'edit' || query.params.action == 'delete' || query.params.action == 'protect' || query.params.action == 'move') {var page = query.params.title;} else {var page = query.params.titles;} if(!page) { var page = ''; }			var query = this[i]; var params = ''; var headers = ''; for(var j in query.params) {params += ', ' + j + '=' + query.params[j];} params = params.substring(2, params.length); for(var j in query.headers) {headers += ', ' + j + ': ' + query.headers[j];} headers = headers.substring(2, headers.length); info.push(query.type + ': ' + query.params.action + ' ' + page + '\n   ' + params + '\n    ' + headers); }		return info.join('\n '); }	//Function for removing a query //Accepts the index of the query or the query itself //Returns the removed query this.clear = function(ref) { var reqs = []; var query = this[ref]; for(var i = 0; i < this.length; i++) {reqs[i] = this[i]; delete this[i];} reqs.splice(ref, 1); for(var i in reqs) {this[i] = reqs[i];} this.length--; return query; }	//Remove all queries //Void //Returns nothing this.clearAll = function { for(var i = 0; i < this.length; i++) { delete this[i]; }		this.length = 0; } } window.api = new APIQuery; //These make it easier to make new queries, because you won't need to use quotes window.GET = 'GET'; window.POST = 'POST';

//We don't really need this logging stuff every time it runs function sajax_init_object {var a;try{a=new XMLHttpRequest}catch(d){try{a=new ActiveXObject("Msxml2.XMLHTTP")}catch(d){try{a=new ActiveXObject("Microsoft.XMLHTTP")}catch(b){a=null}}}return a}

//ajax RecentChanges from dev.wikia /* * ADVANCED AJAX AUTO-REFRESHING ARTICLES * Code courtesy of "pcj" of Wowpedia. * Modified to work in my interface and to my liking by Monchoman45 */ if (!window.ajaxPages) {ajaxPages = ['Special:RecentChanges', 'Special:Watchlist', 'Special:Log'];} var ajaxTimer; var doRefresh = true; function preloadAJAXRL { if(readCookie('ajaxload-' + wgPageName) == null) {createCookie('ajaxload-' + wgPageName, 'on', 99999);} ajaxRLCookie = (readCookie('ajaxload-' + wgPageName) == 'on') ? true : false; appTo = ($('#WikiaPageHeader').length) ? $('#WikiaPageHeader') : $('.firstHeading'); appTo.append(' AJAX: <input type="checkbox" style="position:relative; top:2px;" id="ajaxToggle"><a onclick="loadPageData" style="cursor:pointer; margin-top:1px;" class="wikia-button secondary">Refresh now</a>  <img src="http://images2.wikia.nocookie.net/dev/images/8/82/Facebook_throbber.gif" style="vertical-align: baseline;" border="0" alt="Refreshing page" />  '); $('#ajaxLoadProgress').ajaxSend(function (event, xhr, settings){		if (location.href == settings.url) {$(this).show;}	}).ajaxComplete (function (event, xhr, settings) {		if (location.href == settings.url) {$(this).hide; CustomRollbacks;}	}); $('#ajaxToggle').click(toggleAjaxReload); $('#ajaxToggle').attr('checked', ajaxRLCookie); if (readCookie('ajaxload-' + wgPageName) == 'on') {loadPageData;} } function toggleAjaxReload { if ($('#ajaxToggle').attr('checked') == true) { createCookie('ajaxload-' + wgPageName, 'on', 30); doRefresh = true; loadPageData; }	else { createCookie('ajaxload-' + wgPageName, 'off', 30); doRefresh = false; clearTimeout(ajaxTimer); } } function loadPageData { cC = ($('#WikiaArticle').length) ? '#WikiaArticle' : '#bodyContent'; $(cC).load(location.href + ' ' + cC + ' > *', function (data) { 		if (doRefresh) {ajaxTimer = setTimeout('loadPageData;', 60000);}	}); } if(readCookie('globalJS' + wgUserName) == 'true') {addOnloadHook(function { 	for (i in ajaxPages) {		if (wgPageName == ajaxPages[i] && $('#ajaxToggle').length == 0) {preloadAJAXRL;}	} });}

/* fix styling fail */ function DefaultOasisCSS { $('.skiplinkcontainer').prepend('<a onclick="ToggleCSSCookie" class="skiplink" rel="nofollow" style="cursor:pointer; cursor:hand;">Toggle default CSS</a> '); if(readCookie('OasisCSS') == 'true') { $('body').prepend('<style type="text/css">/*<![CDATA[*/@import "http://community.wikia.com/index.php?title=User:Monchoman45/global.css/defaultoasis.css";/*]]>*/ '); } }

addOnloadHook(DefaultOasisCSS);

function ToggleCSSCookie { if(readCookie('OasisCSS') == 'false') { createCookie('OasisCSS', 'true', 99999); }	else { createCookie('OasisCSS', 'false', 99999); }

window.location.reload(true); }