MediaWiki:Common.js

MediaWiki interface page

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* Any JavaScript here will be loaded for all users on every page load. */
/*
FOR SOUND TEMPLATE
*/
$(function(){
	$('.mw-parser-output .sound').prop('title', "Click to play").on('click', function(e){
		// Ignore links
		if (e.target.tagName === 'A') {
			return;
		}
		var audio = $(this).find('audio')[0];
		if (audio) {
			audio.paused ? audio.play() : audio.pause();
		}
	}).find('audio').on('play', function(){
		// Stop any already playing sounds
		var playing = $('.sound-playing audio')[0];
		playing && playing.pause();
		$(this).closest('.sound').addClass('sound-playing').prop('title', "Click to stop");
	}).on('pause', function(){
		// Reset back to the start
		this.currentTime = 0;
		$(this).closest('.sound').removeClass('sound-playing').prop('title', "Click to play");
	});
});
Cookies help us deliver our services. By using our services, you agree to our use of cookies.