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('.'); }

/* Import script pages */ importArticles({   type: "script",    articles: [        "w:c:dev:ShowHide/code.js",        "w:c:dev:CollapsibleEdittools/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 */ // things only admins should use        "w:c:dev:AjaxBatchDelete/code.js",        "w:c:dev:DupImageList/code.js",    ] });

/* added condition so that section edits gets the proper edit summary */ /* 3 Aug '13 - replaced with less intrusive highlights on hovering publish button */ /* 17 Aug '13 - placeholder changes on hover (hope it'll me more persuasive :P ) */ /* if ( $('textarea#wpSummary').val == '' ) { *   $('textarea#wpSummary').val('Can\'t be bothered with the edit summary');//.attr('readonly','readonly'); * } */ $('input[type="submit"]').mouseenter( function{	if ( $('textarea#wpSummary').val.length==0 ) {		$('textarea#wpSummary').css('border','2px dashed #ff0000').attr('placeholder','Bitte, add a summary of your edit. BITTE!')	} }).mouseleave( function{	$('textarea#wpSummary').css('border','1px solid #797979').attr('placeholder','Add a summary of your edit') })

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

/* * 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 ( $('#AccountNavigation a[href*="/User:Mfaizsyahmi"]').length == 0) 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 ');

/* ************ 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		);	} });

// Hidden Jodl Head. Random position. probability of occurring is 20% for October /* 4 OCT 13 - moved to user:Mfaizsyahmi/object.js with more streamlined code. hope it continues to work as normal. See the importArticles at top of this js page */

// SEASONAL BACKGROUND MUSIC // if ( $.cookie("HPW-nomusic") == null ) $(".WikiaArticle").append(' <iframe width="280" height="230" src="http://www.youtube.com/embed/SeGjS3ZDASc?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' //})