User:Sirlance3000/global.js

/* Any JavaScript here will be loaded for all users on every page load. */ /* JavaScript die hier wordt geplaatst heeft invloed op alle pagina's voor alle gebruikers */ if (mw.config.get('wgNamespaceNumber') === 0	&& /Miraheze-[0-9]{1,}-year/.test(mw.config.get( 'wgPageName' ))	&& /year$/.test( document.URL ) ) { $( "#p-navigation" ).remove; $( "#p-tb" ).remove; $( "#p-Administration" ).remove; $( "#mw-head" ).remove; $( "#footer-info-lastmod" ).remove; $( "#firstHeading" ).remove; $( "#p-Requests" ).remove; $( "#siteNotice" ).remove; $( "#p-Miraheze" ).remove; $( ".mw-editsection" ).remove; $( ".page-actions-menu" ).remove; $( ".last-modified-bar" ).remove; $( "#p-coll-print_export" ).remove; }

if (mw.config.get('wgNamespaceNumber') === 0	&& /Fundraising_campaign_December_2020$/.test(mw.config.get( 'wgRelevantPageName' )) ) { $( "#p-navigation" ).remove; $( "#p-tb" ).remove; $( "#p-Administration" ).remove; $( "#mw-head" ).remove; $( "#footer-info-lastmod" ).remove; $( "#firstHeading" ).remove; $( "#p-Requests" ).remove; $( "#siteNotice" ).remove; $( "#p-Miraheze" ).remove; $( ".mw-editsection" ).remove; $( ".page-actions-menu" ).remove; $( ".last-modified-bar" ).remove; $( "#p-coll-print_export" ).remove; $( "#p-managewiki-sidebar-header" ).remove; $( "#catlinks" ).remove $( ".minerva-user-navigation" ).remove; $( "#p-Noticeboards" ).remove; $( "#p-donate" ).remove; }

/** * EditTools support: add a selector, change  into buttons. * The special characters to insert are defined at MediaWiki:Edittools. * * @author Arnomane, 2006 (on the commons.wikimedia.org/wiki/MediaWiki:Edittools.js) * @author Kaganer, 2007 (adapting to www.mediawiki.org) * @author Krinkle, 2012 * @source www.mediawiki.org/wiki/MediaWiki:Gadget-Edittools.js * @revision 2012-02-29 */ /*jslint browser: true*/ /*global jQuery, mediaWiki*/ (function ($, mw) {	"use strict";

var conf, editTools, $sections;

conf = { initialSubset: window.EditTools_initial_subset === undefined ? window.EditTools_initial_subset : 0 };

editTools = {

/**		 * Creates the selector */		setup: function { var $container, $select, initial;

$container = $('#mw-edittools-charinsert'); if (!$container.length) { return; }			$sections = $container.find('.mw-edittools-section'); if ($sections.length <= 1) { // Only care if there is more than one return; }

$select = $(' ').css('display', 'inline');

initial = conf.initialSubset; if (isNaN(initial) || initial < 0 || initial >= $select.length) { initial = 0; }

$sections.each(function (i, el) {				var $section, sectionTitle, $option;

$section = $(el); sectionTitle = $section.data('sectionTitle');

$option = $(' ') .text(sectionTitle) .prop('value', i)					.prop('selected', i === initial);

$select.append($option); });

$select.change(editTools.handleOnchange); $container.prepend($select);

editTools.chooseSection(initial); },

/**		 * Handle onchange event of the *		 * @context {Element} * @param e {jQuery.Event} */		handleOnchange: function { editTools.chooseSection(Number($(this).val));

return true; },

/**		 * Toggle the currently visible section *		 * @param sectionNr {Number} * @param setFocus {Boolean} */		chooseSection: function (sectionNr) { var $choise = $sections.eq(sectionNr); if ($choise.length !== 1) { return; }

// Making these buttons is a little slow, // If we made them all at once the browser would hang // for over 2 seconds, so instead we're doing it on-demand // for each section. No need to do it twice thoguh, so remember // in data whether it was done already if (!$choise.data('charInsert.buttonsMade')) { $choise.data('charInsert.buttonsMade', true); editTools.makeButtons($choise); }

$choise.show; $sections.not($choise).hide; },

/**		 * Convert the links to buttons in a given section. *		 * @param $section {jQuery} */		makeButtons: function ($section) { var $links;

if (!$section.length) { return; }

$links = $section.find('a'); $links.each(function (i, a) {				var $a, $button, start, end;				$a = $(a);				$button = $( ' ' ).attr( 'type', 'button' );				start = $a.data( 'mw-charinsert-start' );				end = $a.data( 'mw-charinsert-end' );				if ( start !== undefined && end !== undefined ) {					$button.click( function( e ) { e.preventDefault; mw.toolbar.insertTags( start, end, '' ); } );				} else {					$button[0].onclick = a.onclick;                               }				$button[0].value = $a.text;				$a.replaceWith($button);			}); }

};

$(document).ready(editTools.setup);

}(jQuery, mediaWiki)); //Adapted from Terraria Wiki MediaWiki:Common.js

$(function { // Disable triggering of new browser tab when clicking URL links that point to internal wiki addresses (purge, edit, etc) $('a[href^="//thoriummod.fandom.com/"]').removeAttr('target');

// Select links to new tabs for Template:ilnt and Template:elnt $('.linkNewTab a').attr('target','_blank'); });

// Implement border-collapse + border-radius workaround for "terraria"-class tables /* (temporarily?) disabled, broke display for tables with percentage widths $('.terraria:not(.outer)') .removeClass('terraria') .addClass('inner') .wrap(' ');

// Desktop view for mobile screen $(window).on('load', function{  // desktop view for mobile screen.   var $btn = $('#mw-panel .resize-sensor');   var $menu = $('#mw-panel .portal');   $btn.on('click', function{ $('#mw-panel').toggleClass('on'); }); });

// Disable creation of non-talk pages by anonymous IP editors and link to registration (also disabled by abuse filter but this provides warning before attempting edit) var wgPageName = mw.config.get( 'wgPageName' ); var wgUserName = mw.config.get( 'wgUserName' );

var isTalk = false, isAnon = false; if (wgPageName.indexOf('talk:') > -1 || wgPageName.indexOf('Talk:') > -1) isTalk = true; if (wgUserName === null) isAnon = true;

if (isAnon == true){ $('a.new').each(function{       var href = $(this).attr('href');        $(this).attr('href', href.replace(/&action=edit/g, '') );    }); }

if (isAnon == true && isTalk == false) { var anonWarnText = 'Page creation by anonymous editors is currently disabled. To create this page, please register an account first.'; $('body').append(' '); $('body').prepend('' + anonWarnText + ' ');

$('#ca-edit a:contains(Create), #ca-ve-edit a:contains(Create), a.external.text:contains(edit this page)').attr('href', '#').click(function{       $('.anonWarnBox').show;        $('.anonWarnOverlay').show;    }); $('.anonWarnOverlay').click(function{       $('.anonWarnBox').hide;        $(this).hide;    }); }

// AJAX tables function addAjaxDisplayLink { $("table.ajax").each(function (i) {		var table = $(this).attr("id", "ajaxTable" + i);		table.find(".nojs-message").remove;		var headerLinks = $(' ').appendTo(table.find('th').first);		var cell = table.find("td").first, needLink = true;		cell.parent.show;		if (cell.hasClass("showLinkHere")) {			var old = cell.html, rep = old.replace(/\[link\](.*?)\[\/link\]/, '$1');			if (rep != old) {				cell.html(rep);				needLink = false;			}		}		if (needLink) headerLinks.html('[show data]');		table.find(".ajax-load-link").parent.addBack.filter('a').click(function(event) { event.preventDefault; var sourceTitle = table.data('ajax-source-page'), baseLink = mw.config.get('wgScript') + '?'; cell.text('Please wait, the content is being loaded...'); $.get(baseLink + $.param({ action: 'render', title: sourceTitle }), function (data) {				if (data) {					cell.html(data);					cell.find('.ajaxHide').remove;					cell.find('.terraria').removeClass('terraria');					if (cell.find("table.sortable").length) {						mw.loader.using('jquery.tablesorter', function { cell.find("table.sortable").tablesorter; });					}					headerLinks.text('[');					headerLinks.append($('edit').attr('href', baseLink + $.param({ action: 'edit', title: sourceTitle })));					headerLinks.append(document.createTextNode(']\u00A0['));					var shown = true;					$("hide").click(function { shown = !shown; shown ? cell.show : cell.hide; $(this).text(shown ? "hide" : "show"); }).appendTo(headerLinks);					headerLinks.append(document.createTextNode(']'));				}			}).error(function {				cell.text('Unable to load table; the source article for it might not exist.');			}); });	}); }

$(addAjaxDisplayLink); $.when( $.ready ).then(function { // Document is ready.   // desktop view for mobile screen.   $('#mw-panel').append(' ');   var $btn = $('#menu-toggle-button');   var $menu = $('#mw-panel .portal');   $btn.on('click', function{ $('#mw-panel').toggleClass('on'); }); });

$(window).on('load', function{

//main page header. var $btn = $('#mf-wikiheader #mf-wikiheader-toggle-link'); if($btn.length){ var $box = $('#mf-wikiheader'); $btn.css('display', 'inline'); if($box.innerHeight > 180){ $box.addClass('collapsed'); }     $btn.on('click', function{         $box.toggleClass('collapsed');      }); }

//sidebar height fix. var $sidebar = $('#mw-panel'); var $bottom = $sidebar.offset.top + $sidebar.outerHeight(true); var $wrapper = $('#global-wrapper'); var $left_height = $bottom-($wrapper.outerHeight(true)-$wrapper.outerHeight); if ($left_height > $wrapper.height){ $wrapper.css('min-height', $left_height+'px'); } });

/** * Make sidebar sections collapsible */ $(function{	width = $(window).width;	$("#mw-panel .portal").each(function(index, el){ var $el = $(el); var $id = $el.attr("id"); if(!$id){ return; }		if(localStorage.getItem('sidebar_c_'+$id) === "y" || width <= 1024 ){ $el.addClass('collapsed').find('.body').slideUp(0); }	});	$("#mw-panel .portal").on("click", "h3", function(event){ var $el = $(this).parent; var $id = $el.attr("id"); if(!$id){ return; }		event.stopPropagation; $el.toggleClass('collapsed'); if($el.hasClass('collapsed')){ // more consistent between class and slide status. if($(window).width > 1024){ // for resize, don't use `width > 1024`. localStorage.setItem('sidebar_c_'+$id, "y"); $el.find('.body').slideUp('fast'); }			$el.removeClass('expanded'); }		else{ if($(window).width > 1024){ localStorage.setItem('sidebar_c_'+$id, "n"); $el.find('.body').slideDown('fast'); }			else{ $("#mw-panel .portal").removeClass('expanded').addClass('collapsed'); }			$el.addClass('expanded').removeClass('collapsed'); }	}); });

/** * content width toggle */ $(function{	$body = $('body');	$('  ')	.prependTo($('#mw-head'))	.on('click', function{ $body.toggleClass('content-size-expanded'); }); });