MediaWiki:Common.js

importScriptPage('ShowHide/code.js','dev'); importScriptPage('AjaxRC/code.js','dev');

AjaxRCRefreshText = 'Auto-refresh'; AjaxRCRefreshHoverText = 'Automatically refresh the page'; importScriptPage('AjaxRC/code.js', 'dev');

/** Archive edit tab disabling ************************************* * Disables the edit tab on old forum topic pages to stop new people bumping old topics. * Page can still be edited by going via the edit tab on the history etc, or by * typing the edit address manually. * By Spang * Monaco support by Uberfuzzy * Oasis support by Uberfuzzy */ if(wgNamespaceNumber == 110) { function disableOldForumEdit { if( typeof( enableOldForumEdit ) != 'undefined' && enableOldForumEdit ) { return; }	if( !document.getElementById('old-forum-warning') ) { return; }	if( skin == 'oasis' ) {		$('#WikiaPageHeader .wikia-menu-button a:first').html('Archived').removeAttr('href'); return; }	if( !document.getElementById('ca-edit') ) { return; }	var editLink = null; if( skin == 'monaco' ) {		editLink = document.getElementById('ca-edit'); }	else if( skin == 'monobook' ) {		editLink = document.getElementById('ca-edit').firstChild; }	else {		return; }	editLink.removeAttribute('href', 0); editLink.removeAttribute('title', 0); editLink.style.color = 'gray'; editLink.innerHTML = 'Archived'; $('span.editsection-upper').remove; } addOnloadHook( disableOldForumEdit ); }

/* //////////////////////////////////////////////////////////////////// // THE BELOW CODE ADDS CUSTOM BUTTONS TO THE JAVASCRIPT EDIT TOOLBAR //////////////////////////////////////////////////////////////////// if (mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images1.wikia.nocookie.net/youngjustice/images/5/57/CIT_Button.png", "speedTip": "Canon-In-Training", "tagOpen": "", "sampleText": "Insert text"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/youngjustice/images/2/2f/TS_Button.png", "speedTip": "Timestamp", "tagOpen": "", "sampleText": "Place"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/youngjustice/images/c/ce/Ep_ref_Button.png", "speedTip": "Episode/issue reference tag", "tagOpen": " ", "sampleText": "number"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images4.wikia.nocookie.net/youngjustice/images/2/24/AG_Button.png", "speedTip": "Ask Greg reference", "tagOpen": "Weisman, Gr\eg (2012-MONTH-DAY). "tagClose": " Question #. Ask Gr\eg. Retr\ieved 2012-MONTH-DAY. ",    "sampleText": "QID"};   mwCustomEditButtons[mwCustomEditButtons.length] = {     "imageFile": "http://images3.wikia.nocookie.net/marvel_dc/images/2/29/Character_Button.png",     "speedTip": "Insert character template",     "tagOpen": "\{\{Character\r| name        = ",     "tagClose": "\r| image       = \r| real name   = \r| alias       = \r| age         = \r| species     = \r| designation = \r| gender      = \r| hair color  = \r| eye color   = \r| relatives   = \r| mentor      = \r| affiliation = \r| powers      = \r| weaknesses  = \r| equipment   = \r| first       = \r| voice       = \r\}\}",     "sampleText": ""};   mwCustomEditButtons[mwCustomEditButtons.length] = {     "imageFile": "http://images1.wikia.nocookie.net/marvel_dc/images/d/de/Film_Button.png",     "speedTip": "Insert episode template",     "tagOpen": "\{\{Episode\r| episode  = ",     "tagClose": "\r| image    = \r| airdate  = \r| director = \r| writer   = \r| prev     = \r| next     = \r\}\}", "sampleText": ""}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/marvel_dc/images/3/3a/Comic_Button.png", "speedTip": "Insert comics template", "tagOpen": "\{\{Comic\r| image   = ", "tagClose": "\r| issue   = \r| date     = \r| penciler = \r| cover    = \r| writer   = \r| inker    = \r| color    = \r| letter   = \r| editor   = \r| aeditor  = \r| pages    = \r| prev     = \r| next     = \r\}\}", "sampleText": ""}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images4.wikia.nocookie.net/marvel_dc/images/5/5d/Team_Button.png", "speedTip": "Insert organization template", "tagOpen": "\{\{Organization\r| name      = ", "tagClose": "\r| image     = \r| location   = \r| leader     = \r| goal       = \r| members    = \r| attributes = \r| first      = \r\}\}", "sampleText": ""}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images3.wikia.nocookie.net/youngjustice/images/d/dc/Image_Button.png", "speedTip": "Insert filebox template", "tagOpen": "\{\{Filebox\r| description = ", "tagClose": "\r| season     = \r| episode     = \r| source      = \r| origin      = \r| license     = screenshot\r\}\}", "sampleText": ""}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images2.wikia.nocookie.net/youngjustice/images/1/1d/Copyrights_needed_Button.png", "speedTip": "Uncredited image tag", "tagOpen": "\{\{subst:Unknown/ukn|", "tagClose": "}}", "sampleText": "both"}; }

/* Ability to change full page title * See w:c:dev:DISPLAYTITLE for info and attribution */

function fixPageName{ var newPageTitle = getElementsByClassName(document, 'span', 'changePageTitle')[0]; // Find the span with the new title if(newPageTitle == null) return; // If not found exit var oldPageTitle = getElementsByClassName(document, 'header', 'WikiaPageHeader')[0].getElementsByTagName( "h1" )[0]; //Find the page's title if(oldPageTitle == null) return; // If not found exit oldPageTitle.innerHTML = newPageTitle.innerHTML; // Set the title } addOnloadHook(fixPageName);

/* Add social Twitter button to blog posts to replace the one Wikia removed * By: User:The 888th Avatar */

!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");

function BlogLike { if (wgCanonicalNamespace == 'User_blog') { $('#WikiaUserPagesHeader .author-details').prepend(' '); } } addOnloadHook(BlogLike);

/* lock blog comments for blogs that haven't been commented on for more than 30 days. * by: Joey Ahmadi with modifications by Pecoes */

function isCategoryBlacklisted (blacklist) { for (var i = 0; i < wgCategories.length; i++) if (-1 < $.inArray(wgCategories[i], blacklist )) return true; return false; }

$(function {    if (isCategoryBlacklisted(["Blog posts", "Site news"]) && wgNamespaceNumber == 500 && $('#article-comments-ul li').size > 1) {        var then = $('#article-comments-ul > .SpeechBubble:first .permalink').attr('href');        then = new String(then.match(/\d{8}/));        var monthnames = ['January','February','March','April','May','June','July',        'August','September','October','November','December'];        var year = then.match(/^\d{4}/);        var month = then.substring(4,6);         month--;        month= monthnames[month];        var day = then.match(/\d{2}$/);        then = new Date(month+''+day+', '+year);         var old = parseInt(now - then);        old = Math.floor(old/(1000*60*60*24));        if (old > 30) {            $('#article-comm').attr('disabled','disabled').text('This blog post hasn\'t been commented on for over 30 days. There is no need to comment.');           $('#article-comm-submit').attr('disabled','disabled');            $('.article-comm-reply').remove;        }    } });

/* support for the Countdown template */ var oldTime = new Date; var timerID = null; var entry = 0; var target; var dst; var jan = new Date(oldTime.getFullYear, 0, 1); var jul = new Date(oldTime.getFullYear, 6, 1); var stdOffset = Math.max(jan.getTimezoneOffset, jul.getTimezoneOffset); if (oldTime.getTimezoneOffset < stdOffset) {    dst = 60; } else {    dst = 0; }

function Timecount { entry++; var basedate = oldTime; if (entry == 1) { if (document.getElementById('TimeLeftCounter') != null) { target = new Date(document.getElementById('TimeLeftCounter').innerHTML); }               else { return; }           }           var now = new Date; oldTime = now; var diff = new Date; var days = 0; var hours = 0; var minutes = 0; var seconds = 0; var daystring = ""; var hourstring = ""; var minutestring = ""; var secondstring = ""; diff.setTime(target.getTime - basedate.getTime); if (diff.getTime > new Date("January 1, 1970 00:00:00")) { days = Math.floor((diff.getTime-((now.getTimezoneOffset+dst)*60000)) / 86400000); hours = diff.getHours; minutes = diff.getMinutes; seconds = diff.getSeconds;

if (days != 0) { daystring = days.toString + "d, "; }

if (hours != 0) { hourstring = hours.toString + "h "; }                   else { if (days != 0) hourstring = hours.toString + "h "; }

if (minutes != 0) { minutestring = minutes.toString + "m "; }                   else { if ((hours != 0) || (days != 0)) minutestring = minutes.toString + "m "; }

secondstring = seconds.toString + "s";

document.getElementById("TimeLeftCounter").innerHTML = daystring + hourstring + minutestring + secondstring; timerID = self.setTimeout(Timecount, 1000); }               else { document.getElementById("TimeLeftCounter").innerHTML = "0s"; }           } addOnloadHook(Timecount);