User:Jäzzi/global.js

/* * ADVANCED AJAX AUTO-REFRESHING ARTICLES * Code courtesy of "pcj" of Wowpedia. */ ajaxIndicator = 'http://images2.wikia.nocookie.net/dev/images/8/82/Facebook_throbber.gif'; if (!window.ajaxPages) ajaxPages = new Array("Special:RecentChanges"); if (!window.ajaxCallAgain) ajaxCallAgain = []; var ajaxTimer; var ajaxRefresh = 60000; var refreshText = 'AJAX'; if( typeof AjaxRCRefreshText == "string" ) { refreshText = AjaxRCRefreshText; } var refreshHover = 'Enable auto-refreshing page loads'; if( typeof AjaxRCRefreshHoverText == "string" ) { refreshHover = AjaxRCRefreshHoverText; } var doRefresh = true; function setCookie(c_name,value,expiredays) { var exdate=new Date exdate.setDate(exdate.getDate+expiredays) document.cookie=c_name+ "=" +escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString) } function getCookie(c_name) { if (document.cookie.length>0) { c_start=document.cookie.indexOf(c_name + "=") if (c_start!=-1) { c_start=c_start + c_name.length+1 c_end=document.cookie.indexOf(";",c_start) if (c_end==-1) c_end=document.cookie.length return unescape(document.cookie.substring(c_start,c_end)) } } return "" } function preloadAJAXRL { ajaxRLCookie = (getCookie("ajaxload-"+wgPageName)=="on") ? true:false; appTo = ($("#WikiaPageHeader").length)?$("#WikiaPageHeader"):$(".firstHeading"); appTo.append(' ' + refreshText + ':   '); $("#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; for(i in ajaxCallAgain){ajaxCallAgain[i]};} }); $("#ajaxToggle").click(toggleAjaxReload); $("#ajaxToggle").attr("checked", ajaxRLCookie); if (getCookie("ajaxload-"+wgPageName)=="on") loadPageData; } function toggleAjaxReload { if ($("#ajaxToggle").attr("checked") == true) { setCookie("ajaxload-"+wgPageName, "on", 30); doRefresh = true; loadPageData; } else { setCookie("ajaxload-"+wgPageName, "off", 30); doRefresh = false; clearTimeout(ajaxTimer); } }

function loadPageData { var cC = ($("#WikiaArticle").length)?"#WikiaArticle":"#bodyContent"; $(cC).load(location.href + " " + cC + " > *", function (data) { if (doRefresh) ajaxTimer = setTimeout("loadPageData;", ajaxRefresh); }); }

$(function { for (x in ajaxPages) { if (wgPageName == ajaxPages[x] && $("#ajaxToggle").length==0) preloadAJAXRL; } });

/* ############################################ */ /* ##            SIDEBAR                    ## */ /* ##        ORIGINALLY BY GRUNNY           ## */ /* ##        TWEAKED BY ISDRAKTHÜL          ## */ /* ############################################ */

//Adds a new box in the sidebar and populates it with custom links; originally by User:Grunny addOnloadHook( function {	$('#p-cactions').after(' My Tools     ');	addPortletLink('p-pql','/wiki/Special:RecentChanges','Recent Changes');	addPortletLink('p-pql','/wiki/Special:RandomPage','Random Page');        addPortletLink('p-pql','/wiki/Special:WhatLinksHere/' + wgPageName,'What Links Here');        addPortletLink('p-pql','/wiki/Special:CreatePage','Create a New Page');        addPortletLink('p-pql','/wiki/Special:Upload','Upload');        addPortletLink('p-pql','/wiki/Special:MultipleUpload','Multiple Upload');        if(wgCanonicalNamespace=="User" || wgCanonicalNamespace=="User_talk" || wgCanonicalNamespace=="User_blog") addPortletLink('p-pql','/wiki/Special:Editcount/' + wgPageName,'Edit Count');        else addPortletLink('p-pql','/wiki/Special:Editcount/','Edit Count');        addPortletLink('p-pql','/wiki/User_talk:BassJapas','Messages');        addPortletLink('p-pql','/wiki/Special:Disambiguations','Disambigs'); addPortletLink('p-pql','/wiki/Special:SpecialPages','Special Pages'); addPortletLink('p-pql','/wiki/Special:ListRedirects','Redirects'); addPortletLink('p-pql','/wiki/Special:Contributions','Contribs'); addPortletLink('p-pql','/wiki/Special:Categories','Categories'); } );

// ============================================================ // displayTimer - 2/1/11 // ============================================================ //Add a clock to the WikiHeader //Modified from work by Patrick Westerhoff [poke]: //http://bulbapedia.bulbagarden.net/wiki/MediaWiki:Monobook.js hookEvent( 'load', displayTimer ); 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' ); timerLink.href              = '/wiki/' + wgPageName + '?action=purge'; timerLink.title             = 'Purge the server cache and update the contents of this page.' timerObj.id                 = 'displayTimer'; timerObj.style.textTransform = 'none'; timerObj.style.fontWeight   = 'bold'; timerObj.style.fontSize     = '100%'; timerObj.appendChild( timerLink ); timerParent.insertBefore( timerObj, timerParent.firstChild ); if (skin == 'oasis') {       $('#displayTimer').css({'position': "inherit", 'right': "0px", 'top': "-28px"}); }   var month = new Array(12); month[0] = "Jan"; month[1] = "Feb"; month[2] = "Mar"; month[3] = "Apr"; month[4] = "May"; month[5] = "Jun"; month[6] = "Jul"; month[7] = "Aug"; month[8] = "Sep"; month[9] = "Oct"; month[10] = "Nov"; month[11] = "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 ); } } /* skin change buttons - 2/1/11 */ function CreateSkinChangeButtons { //Oasis buttons $('section header div.buttons a:first-child').before('MonobookVector'); //Monobook buttons $('div#p-cactions.portlet div.pBody ul li:nth-last-child(1)').after('OasisVector</li>'); //Vector buttons $('div#p-namespaces.vectorTabs').after(' <li id="ca-nstab-main"><a href="/index.php?title='+ encodeURIComponent(wgPageName) +'&useskin=wikia" title="Change to Oasis [o]" id="skinChangeButton" accesskey="o"> Oasis </a></li><li id="ca-nstab-main"><a href="/index.php?title='+ encodeURIComponent(wgPageName) +'&useskin=monobook" title="Change to Monobook [m]" id="skinChangeButton" accesskey="m"> Monobook </a></li></ul> '); } addOnloadHook(CreateSkinChangeButtons);

/* 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. */ $(function {    window.chatcheck = setInterval('ChatCheck', 200);    if(skin == 'monobook') {        var a = document.getElementsByTagName('a');        for(var i in a) {            if(a[i].href && a[i].href.indexOf('/wiki/Special:Chat') != -1) {                a[i].href = 'javascript:OpenChatWindow; ';            }        }    } }); function ChatCheck { if($('.chat-join button').length != 0) { $('.chat-join button').replaceWith('<a class="wikia-button" onclick="OpenChatWindow"><img src="http://images.wikia.com/common/__cb36140/extensions/wikia/Chat/images/chat_icon.png" style="margin-right:3px;">Join the Chat</a>'); clearInterval(window.chatcheck); } } function OpenChatWindow { window.chatwindow = window.open('/index.php?title=Special:Chat&useskin=wikia'); 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'); } }