MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */ // 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.andSelf.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'); }); });

const images = document.querySelectorAll("#content img"); const regex = new RegExp(/cb=\d+/);

images.forEach(function(image) {   image.setAttribute("src", image.src.replace(regex, "format=original")); });

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