MediaWiki:Common.js

function loadScripts(scripts) { var deferreds = []; $.each(scripts, function (i, script) {		// External script, use $.getScript		if (script.match(/^(https?:|\/\/)/)) {			deferreds.push($.getScript(script));		// Use mw.using, convert callbacks to Deferreds		} else {			var d = $.Deferred;			// TODO: make only one mw.loader.using call, passing an array of module names			mw.loader.using(script, d.resolve, d.reject);			deferreds.push(d);		}	}); return $.when.apply($, deferreds); }

function handler(event) { var requires = ['https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.3.5/js/swiper.min.js']; loadScripts(requires).done(function {		var swiper = new Swiper('.blog-slider', { spaceBetween: 30, effect: 'fade', loop: true, mousewheel: { invert: false, },			// autoHeight: true, pagination: { el: '.blog-slider__pagination', clickable: true, }		});	}); } var headerTitle = document.querySelector('.header-titles') if (headerTitle) { $(document).ready(function {		$('.header-titles li a').click(function(e) { $(".firstSelected").removeClass("firstSelected"); });	});	headerTitle.addEventListener('click', handler); if (document.readyState === 'loading') { window.addEventListener('DOMContentLoaded', handler); } else { handler; }	$('.header-titles li a').click(function{   $('.header-titles li a').removeClass('selected'); // remove selected from any other item first    (this).addClass('selected');});//add selected to the one just clicked. }

var toCopy = document.getElementById('to-copy'); if (toCopy) { toCopy.addEventListener( 'click', function{   	navigator.clipboard.writeText(toCopy.innerHTML);    	var copyText = document.getElementById('clickToCopyText').innerHTML;    	document.getElementById('clickToCopyText').innerHTML = '(copied)';    	setTimeout(function { document.getElementById('clickToCopyText').innerHTML = copyText; }, 1500);	}); }