MediaWiki:Gadget-TotakekeAudioPlayer.js

mw.hook('wikipage.content').add(function($content) { $content.find('.np-audio').on('click', function(e) { var audio = $(this).find('audio')[0]; if (audio.paused) { var playing = $('.np-audio-playing'); for (var i = 0; i < playing.length; i++) { var playingAudio = $(playing[i]).find('audio')[0]; playingAudio.pause; playingAudio.currentTime = 0; $(playing[i]).removeClass('np-audio-playing').prop('title', 'Play audio'); }     audio.play; $(this).addClass('np-audio-playing').prop('title', 'Pause audio'); } else { audio.pause; audio.currentTime = 0; $(this).removeClass('np-audio-playing').prop('title', 'Play audio'); } });  $content.find('.np-audio audio').on('ended', function { $(this).parent.removeClass('np-audio-playing').prop('title', 'Play audio'); }); });