第36行: |
第36行: |
| | | |
| /* 生成音频播放按钮 */ | | /* 生成音频播放按钮 */ |
− | (window.onload = function(){
| + | window.onload = function() { |
| var audios = document.getElementsByClassName('audio-player'); | | var audios = document.getElementsByClassName('audio-player'); |
| var notValidAudio = /wpDestFile/; | | var notValidAudio = /wpDestFile/; |
| var currentPlaying = null; | | var currentPlaying = null; |
| | | |
− | for(var i = 0; i < audios.length; i++) { | + | for (var i = 0; i < audios.length; i++) { |
| var audio = audios[i]; | | var audio = audios[i]; |
| var linkEl = audio.firstElementChild; | | var linkEl = audio.firstElementChild; |
第63行: |
第63行: |
| a.preload = 'none'; | | a.preload = 'none'; |
| | | |
− | a.onended = function () { | + | a.onended = function() { |
| currentPlaying = null; | | currentPlaying = null; |
| this.parentNode.classList.remove('audio-player-playing'); | | this.parentNode.classList.remove('audio-player-playing'); |
第72行: |
第72行: |
| button.classList.add('audio-player-button'); | | button.classList.add('audio-player-button'); |
| button.append(a); | | button.append(a); |
− | button.onclick = function () { | + | button.onclick = function() { |
| var a = this.firstElementChild; | | var a = this.firstElementChild; |
| | | |
第86行: |
第86行: |
| this.classList.add('audio-player-playing'); | | this.classList.add('audio-player-playing'); |
| this.classList.remove('audio-player-paused'); | | this.classList.remove('audio-player-paused'); |
− | } | + | } else { |
− | else {
| |
| a.pause(); | | a.pause(); |
| this.classList.add('audio-player-paused'); | | this.classList.add('audio-player-paused'); |
| this.classList.remove('audio-player-playing'); | | this.classList.remove('audio-player-playing'); |
− | }; | + | } |
| }; | | }; |
− |
| + | |
| audio.append(button); | | audio.append(button); |
− | }; | + | } |
− | })(); | + | }; |
| | | |
| /* 重新布局评论区 */ | | /* 重新布局评论区 */ |