MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */

/* Common routines */ function commafy( num ) { /* from stackoverflow */ /* trying to catch an error in Chrome about num being undefined */ if (typeof num == 'undefined') return null; var str = num.toString.split('.'); if (str[0].length >= 4) { str[0] = str[0].replace(/(\d)(?=(\d{3})+$)/g, '$1,'); }	if (str[1] && str[1].length >= 4) { str[1] = str[1].replace(/(\d{3})/g, '$1 '); }	return str.join('.'); }

/* UserTags configuration, see w:c:dev:UserTags * currently only testing this thing out, will add actual tags later once I learn more */ window.UserTagsJS = { modules: {}, tags: { // group: { associated tag data } //montheditor: { u:'Editor of the Month' }, // unused //featured: { u:'Featured' }, // unused //templates: { u:'Templates Guru' }, // unused //senioreditor: { u:'Senior Editor', title:'This person has made 500 or more edits on this wiki'} technician: { u:'Technician', title:'Maintainers of the back-end templates, javascript and stylesheets of this wiki' }	} }; UserTagsJS.modules.mwGroups = ['bureaucrat', 'sysop', 'rollback', 'moderator']; UserTagsJS.modules.custom = { 'Mfaizsyahmi': ['technician'], 'FegeleinParodies': ['technician'], 'Blakegripling ph': ['technician'], 'Yhynerson1' : ['technician'] }; UserTagsJS.modules.inactive = 90; // 3 months /*UserTagsJS.modules.senioreditor = { namespace: 0, computation: function(edits) { return edits >= 500; } };*/ /* ========= End of UserTags ========= */

/* Standard edit summary settings */ // Create the "dev" namespace if it doesn't exist already: window.dev = window.dev || {}; // Create the sub-namespace for this addon and set some options: window.dev.editSummaries = { css: '#stdSummaries { ... }',    select: 'MediaWiki:StandardEditSummary' }; /* "Our words are backed... with SOURCE CODE!" -Nuclear Mfaizsyahmi*/ if (mw.user.name=='Yhynerson1'){ $('#wpSave').click(function(e){       if ($('#wpSummary').val.length==0) {            $('#wpSummary').val('I can\'t be bothered with the edit summary.');            e.preventDefault;        }    }); }

/* Import script pages */ importArticles({   type: "script",    articles: [        "w:c:dev:ShowHide/code.js",        "w:c:deadisland:User:Jgjake2/js/DISPLAYTITLE.js",        "MediaWiki:FloatingTableHeader.js",        "w:c:dev:Countdown/code.js",        "User:Mfaizsyahmi/object.js", /* Jodl Head */        "User:Mfaizsyahmi/UserTags/senioreditor.js", // for UserTags        "w:c:dev:UserTags/code.js",        "w:c:dev:Standard_Edit_Summary/code.js"    ] });

// SocialBlade Widget (now supports multiple tags) $('.SocialBladeWidget').each(function {   var sbname=$(this).attr("data-name");    $(this).html(' ').show; });

$(".custom-dropdown.wikia-menu-button a").removeClass("external text");

/* * CODE FOR LIST OF UNTERGANGERS * NOW MOVED TO MediaWiki:UntergangerList.js * TO IMPROVE PERFORMANCE */ // since the verbatim proved to be useless, opted to use this instead // to load the script for the List of Untergangers page // // 13.9.12 Disabled for debugging - rows at bottom not being parsed correctly // 25.9.12 added button to load the script manually so that users can get back some functionality even as the script's being debugged // ==== // $(".page-List_of_Untergangers").append(' '); $('table.untergangers').after('Enable list enhancements '); function importUntergangerListScript { importScriptPage('MediaWiki:UntergangerList.js', 'hitlerparody'); $('button#ULscriptimport').remove; } // execute if not mfaizsyahmi logged in if ( mw.user.name!=='Mfaizsyahmi') importUntergangerListScript;

// I want to put stuff directly beneath the infobox! :@ // 6 Jan 13 - this seemed to be interfering with Infobox Extensions //$(".infobox").wrap(' '); //$(".underinfobox").appendTo(".infoboxcolumn");

// Marquee text, might come in handy for main page announcements //$('div.marquee').wrapInner(' ').show;

// *********** Grand Unified Downfall Scenes Database ************************** $(".scenes.list ol").find("ol, ul, dl").remove; $(".scenes.list+.alt-text").hide; $(".scenes.list").show;

function RepeatText(text, times) { return (new Array(times + 1)).join(text); }

if ( $("table.scenes").length && $("div.scenes.db").length ) {

$("div.scenes.db>ol").addClass("master"); $db = $("div.scenes.db").eq(0).clone; scenecount = $("ol.master>li", $db).length

$("table.scenes").each( function {       col = $("tr:first-child th", this).length;        rowstring = ' '+ RepeatText('  ',col) + ' ';        $(this).append( RepeatText(rowstring, scenecount) );

// applying header classes to cells, one column at a time for (j=1; j <= col; j++) { $( "td:nth-child(" +j+ ")", this).attr("class", $( "th:nth-child(" +j+ ")", this).attr("class") ); }       $(this).append( ' List retrieved from the Grand Unified Downfall Scenes Database.  ' ); });   $("ol.master>li", $db).each( function { idx = $(this).index+1; $desc = $("ul",this); // notes = $("dt",this).text; $link = $("dd a",this); id = $("ol>li", this); // haven't figured out how to use this $("ul, dl, ol", this).remove; scenename = $(this).html;

$row = $("table.scenes tr").eq(idx); $("td.index", $row).text(idx); $("td.name", $row).html(scenename); $("td.desc", $row).prepend($desc); // $("td.notes", $row).append(notes); $("td.links", $row).html( $link ); $("td.links a", $row).wrap(""); $("td.links", $row).wrapInner(""); }); } // ***************************************************************************

// NEWS (MAIN PAGE AND SELF PAGE) $(".scrollbox-news").after(' [Expand All] '); $('.page-Hitler_Parody_Wiki_News table.mw-collapsible th').prepend(' [All] ');

$(".newsExpander").click(function{   if ($(this).hasClass("newsExpander-collapsed")){        $(".scrollbox-news .mw-collapsible-toggle-collapsed, .page-Hitler_Parody_Wiki_News .mw-collapsible-toggle-collapsed").trigger("click");        $(".newsExpander").removeClass("newsExpander-collapsed").addClass("newsExpander-expanded");        if ($('.scrollbox-news').length ) $(this).text("[Collapse All]");    } else {        $(".scrollbox-news .mw-collapsible-toggle-expanded, .page-Hitler_Parody_Wiki_News .mw-collapsible-toggle-expanded").trigger("click");        $(".newsExpander").removeClass("newsExpander-expanded").addClass("newsExpander-collapsed");        if ($('.scrollbox-news').length ) $(this).text("[Expand All]");    } });

$(".scrollbox-news").prepend(' '); $(".scrollbox-news h3").append(' ↑top ');

/* Unterganger Infobox award headers show/hide toggle */ if ( $('.UntergangerInfobox .award').length >=3 ) { $('.UntergangerInfobox .award-header').append(' [Show] ') $('.award-toggle').click( function {       if ($(this).hasClass("award-toggle-collapsed")) {             $(".award").fadeOut;            $(this).removeClass("award-toggle-collapsed").text('[Show]')         } else {            $(".award").fadeIn;            $(this).addClass("award-toggle-collapsed").text('[Hide]')        }    }) $(".award").hide; }

/* ************ Template:Deadline ************* */ /* 1 Aug 13: turned into a named function so that it can be triggered anytime */

function deadlineFlags { var now = new Date; $('.contest-entry-stats').each( function {		var deadline = new Date( $(this).attr('data-date') );		//var deadline = new Date( '25 April 2013' );		if (deadline.getUTCHours+':'+deadline.getUTCMinutes+':'+deadline.getUTCSeconds == '0:0:0') { 			deadline.setUTCHours(23,59,59)		}		if ( now > deadline ) {			$(this).html(' ');		} else if ( (deadline-now)/(24*3600*1000) <= 3 ) { /* parseInt? */			$(this).html(' ');		} else {			$(this).html(' ');		}		//$(this).append(' '); }) } deadlineFlags;

/* ***** Downfall Scenes successor box ***** */ if ( $('.navbox.downfallscenes .scenes.list .selflink').length == 1 ) { $('.navbox.downfallscenes').before(' ') $('div.scenes-successor').load('/wiki/Template:Downfall_Scene_Successor?action=render table.scenes-successor', function{		var list = $('.navbox.downfallscenes .scenes.list ol')		var idx = $('.selflink', list).parent.index		$('table.scenes-successor .cur').html( $('li',list).eq(idx).clone.html )		if (idx > 0) $('table.scenes-successor .prev').html( $('li',list).eq(idx-1).clone.html )		if (idx < $('li',list).length ) $('table.scenes-successor .next').html( $('li',list).eq(idx+1).clone.html )	}); }

// Parody feed modifications - turn YT links into embedded players if( $('.page-Hitler_Parody_Wiki').length ) { console.log('page is Main Page, setting up timer for parody feed...') var parodyFeedChecker = setInterval( function{ checkParodyFeed }, 500); function checkParodyFeed{ if( $('.scrollbox#DPFparodies dl').length) { console.log('parody feed loaded!') clearInterval(parodyFeedChecker) $('.scrollbox#DPFparodies dl dd a[href*="//www.youtube.com/watch?"]').each(function{				var vidID = new RegExp("[\\?&]v=([^&#]*)").exec( $(this).attr('href') )				console.log(vidID)				$(this).hide.after(' ')			}); // $('.scrollbox#DPFparodies dl').after('complete!') }	} }

// moved here as this should be applied last... $('a.external').attr({ target: '_blank' });

/** Extra toolbar options ****************************************************** *  *  Description: Adds extra buttons to the old (non-enhanced) editing toolbar. *  *  Maintainers: User:MarkS, User:Voice of All, User:R. Koot */ mw.loader.using( 'mediawiki.action.edit', function {	var buttons, i, len;	buttons = ;	for ( i = 0, len = buttons.length; i < len; i++ ) {		mw.toolbar.addButton( buttons[i].imageFile, buttons[i].speedTip, buttons[i].tagOpen, buttons[i].tagClose, buttons[i].sampleText, buttons[i].id, buttons[i].id		);	} });

// SEASONAL BACKGROUND MUSIC //if ( $.cookie("HPW-nomusic") == null ) $(".WikiaArticle").append(' <iframe width="280" height="230" src="http://www.youtube.com/embed/6JMvYKrnseI?autoplay=1" frameborder="0"> ');

/* ************************ From the Jodl Files ************************* */ // something for rob and his hobo piret ;)

/* steamed fish ftw */ //$('a.external:not([href*="www.youtube.com/watch"])').click(function(e) { //   e.preventDefault //    window.location = 'http://www.wikihow.com/Cook-Steamed-Fish' //})

$('#closewindowbutton').on('click',function{$('.msgbox').fadeOut(150);});

/* MANUALLY switch off ads */ $('#removeads').on('click',function{     $('.WikiaTopAds').fadeOut(250);      $('.home-top-right-ads').fadeOut(250);      $('.wikia-ad').fadeOut(250);      $('.SelfServeUrl').fadeOut(250);      $('#WikiaArticleBottomAd').fadeOut(250);      $('.WikiaAdInContentPlaceHolder').fadeOut(250);      $('.WikiaAdInContent').fadeOut(250); });

/******************** Level system ********************/ document.onreadystatechange = function { if (document.readyState == "complete") { if ($("#UserProfileMasthead").size) { editRanks = { 1:"LEVEL 1", 10:"LEVEL 2", 25:"LEVEL 3", 50:"LEVEL 4", 90:"LEVEL 5", 150:"LEVEL 6", 235:"LEVEL 7", 350:"LEVEL 8", 500:"LEVEL 9", 690:"LEVEL 10", 925:"LEVEL 11", 1210:"LEVEL 12", 1550:"LEVEL 13", 1950:"LEVEL 14", 2415:"LEVEL 15", 2950:"LEVEL 16", 3560:"LEVEL 17", 4250:"LEVEL 18", 5025:"LEVEL 19", 5890:"LEVEL 20", 6850:"LEVEL 21", 7910:"LEVEL 22", 9075:"LEVEL 23", 10350:"LEVEL 24", 11740:"LEVEL 25", 13250:"LEVEL 26", 14885:"LEVEL 27", 16650:"LEVEL 28", 18550:"LEVEL 29", 20590:"LEVEL 30", 22775:"LEVEL 31", 25110:"LEVEL 32", 27600:"LEVEL 33", 30250:"LEVEL 34", 33065:"LEVEL 35", 36050:"LEVEL 36", 39210:"LEVEL 37", 42550:"LEVEL 38", 46075:"LEVEL 39", 49790:"LEVEL 40", 53700:"LEVEL 41", 57810:"LEVEL 42", 62125:"LEVEL 43", 66650:"LEVEL 44", 71390:"LEVEL 45", 76350:"LEVEL 46", 81535:"LEVEL 47", 86950:"LEVEL 48", 93110:"LEVEL 49", 100000:"LEVEL 50", }           editCount = $("#UserProfileMasthead .tally em").html.replace(",",""); if (editCount) { for(i in editRanks) if (editCount >= parseInt(i)) editRank = editRanks[i]; $("#UserProfileMasthead hgroup").append($(" ").addClass("tag").html(editRank)); }       }    } }