MediaWiki:Gadget-TotakekeAudioPlayer.js
From Nookipedia, the Animal Crossing wiki
Note: After saving, 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: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
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');
});
});