User:Flex217/wikia.js

// ============================================================ // 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 ); } } // ============================================================ // wikiSidething // // Function: Adds a counter // ============================================================ $(function {	if(skin == "oasis") {		var $sidebar = $('.WikiaPagesOnWikiModule:first');		var comboString = " ";		$sidebar.html($sidebar.html + comboString);	} else if(skin == "monobook") {		var $sidebar = $('#p-wikicities-nav');		var comboString = "";		$sidebar.html($sidebar.html + comboString);	} }); /* shrink the side rail to add content space when rail is present - 2/1/11 */ /* only works with proper css - see Forum:Why not get rid of the right sidebar altogether? */ function ShrinkRail { if( $('article#WikiaMainContent.WikiaMainContent').width < 1000 ) { $('header#WikiaPageHeader.WikiaPageHeader details').css({"width": '750px'}); $('article#WikiaMainContent.WikiaMainContent').css({"width": '760px'}); $('div#catlinks.catlinks').css({"width": '718px'}); $('div#WikiaRail.WikiaRail').css({"width": '220px'}); $('form#WikiaSearch').css({"width": '218px'}); $('form#WikiaSearch input[type="text"]').css({"width": '210px'}); $('div#WikiaRail a.wikia-button.upphotos').replaceWith('  '); $('div#WikiaRail a.wikia-button.createpage').replaceWith('  '); $('div#WikiaRail a.wikia-button[href="/wiki/Special:CreateBlogPage"]').replaceWith(''); } } addOnloadHook(ShrinkRail); /* add a button that increases the content size and hides the rail - 2/1/11 */ function CreateContentResizeButton { var headerWidth = $('header#WikiaPageHeader.WikiaPageHeader details').width; var contentWidth = $('article#WikiaMainContent.WikiaMainContent').width; var catlinksWidth = $('div#catlinks.catlinks').width; if(contentWidth < 1000) { $('section article header ul.wikia-menu-button').after(' Expand <--> '); $('section article header a.wikia-button').after(' Expand <--> </a></ul>'); $('section article header a.view-source').after('<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') { $('section article div#WikiaUserPagesHeader a.wikia-button').after('<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>'); }	} } 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('<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('<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 (mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images.wikia.com/central/images/7/74/Button_comment.png", "speedTip": "Add sig on Wiki", "tagOpen": "", "tagClose": "", "sampleText": ""} } /////////////////////////////////////////////////////////////////////////////////////////////////////////// // ADVANCED AJAX AUTO-REFRESHING ARTICLES // Code courtesy of "pcj" of WoWWiki. // Bug fixes and maintenance by Grunny /////////////////////////////////////////////////////////////////////////////////////////////////////////// var indicator = 'http://i25.servimg.com/u/f25/16/05/86/66/poptar10.gif'; if (!window.ajaxPages) ajaxPages = new Array("Special:WikiActivity"); var ajaxTimer; var ajaxRefresh = 60000; var refreshText = 'Automatically refresh'; 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(' <span style="border-bottom: 1px dotted; cursor: help;" id="ajaxToggleText" title="' + refreshHover + '">' + refreshText + ': <input type="checkbox" style="margin-bottom: 0;" id="ajaxToggle"> <img src="' + indicator + '" style="vertical-align: baseline;" border="0" alt="AJAX operation in progress" /> '); $("#ajaxLoadProgress").bind("ajaxSend", function { $(this).show; }).bind("ajaxComplete", function { $(this).hide; }); $("#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; } }); /////////////////////////////////////////////////////////////////////////////////////////////////////////// // END OF AJAX AUTO-REFRESH /////////////////////////////////////////////////////////////////////////////////////////////////////////// importScriptURI("http://vda.wikia.com/index.php?action=raw&ctype=text/javascript&title=MediaWiki%3AVDA2.js&cache=" + Math.random); window.addEventListener("load", function {    var eb = document.getElementById("wpTextbox1");    if (eb) {        eb.select;    } }, false); window.addEventListener("load", function {    var me = document.getElementById("wpMinoredit");    if (me) {        me.setAttribute("checked", "checked");    }    var eb = document.getElementById("wpTextbox1");    eb.value = eb.value.replace(/<\/?noinclude>/, ""); }, false);