1function InlinePlayer() { 2 function removeTheSound(s) { 3 self.soundsByURL[s.url] = null; 4 var index = self.sounds.indexOf(s); 5 self.sounds.splice(index, 1) 6 } 7 var self = this, 8 pl = this, 9 sm = soundManager, 10 isIE = navigator.userAgent.match(/msie/i); 11 this.domTime = null; 12 this.playableClass = "inline-playable"; 13 this.excludeClass = "inline-exclude"; 14 this.links = []; 15 this.sounds = []; 16 this.soundsByURL = []; 17 this.indexByURL = []; 18 this.lastSound = null; 19 this.soundCount = 0; 20 this.config = { 21 playNext: false, 22 autoPlay: false 23 }; 24 this.css = { 25 sDefault: "sm2_link", 26 sLoading: "sm2_loading", 27 sPlaying: "sm2_playing", 28 sPaused: "sm2_paused" 29 }; 30 this.addEventHandler = void 0 !== window.addEventListener ? function(o, evtName, evtHandler) { 31 return o.addEventListener(evtName, evtHandler, false) 32 } : function(o, evtName, evtHandler) { 33 o.attachEvent("on" + evtName, evtHandler) 34 }; 35 this.removeEventHandler = void 0 !== window.removeEventListener ? function(o, evtName, evtHandler) { 36 return o.removeEventListener(evtName, evtHandler, false) 37 } : function(o, evtName, evtHandler) { 38 return o.detachEvent("on" + evtName, evtHandler) 39 }; 40 this.classContains = function(o, cStr) { 41 return void 0 !== o.className && o.className.match(new RegExp("(\\s|^)" + cStr + "(\\s|$)")) 42 }; 43 this.addClass = function(o, cStr) { 44 if (!o || !cStr || self.classContains(o, cStr)) return false; 45 o.className = (o.className ? o.className + " " : "") + cStr 46 }; 47 this.removeClass = function(o, cStr) { 48 if (!o || !cStr || !self.classContains(o, cStr)) return false; 49 o.className = o.className.replace(new RegExp("( " + cStr + ")|(" + cStr + ")", "g"), "") 50 }; 51 this.getSoundByURL = function(sURL) { 52 return void 0 !== self.soundsByURL[sURL] ? self.soundsByURL[sURL] : null 53 }; 54 this.setVolume = function(soundUrl, volume) { 55 var sound = self.getSoundByURL(soundUrl); 56 null != sound && sm.setVolume(sound.id, volume) 57 }; 58 this.destroySound = function(soundId) { 59 sm.destroySound(soundId) 60 }; 61 this.isChildOfNode = function(o, sNodeName) { 62 if (!o || !o.parentNode) return false; 63 sNodeName = sNodeName.toLowerCase(); 64 for (; 65 (o = o.parentNode) && o.parentNode && o.nodeName.toLowerCase() != sNodeName;); 66 return o.nodeName.toLowerCase() == sNodeName ? o : null 67 }; 68 this.events = { 69 play: function() { 70 pl.removeClass(this._data.oLink, this._data.className); 71 this._data.className = pl.css.sPlaying; 72 pl.addClass(this._data.oLink, this._data.className) 73 }, 74 stop: function() { 75 pl.removeClass(this._data.oLink, this._data.className); 76 this._data.className = "" 77 }, 78 pause: function() { 79 pl.removeClass(this._data.oLink, this._data.className); 80 this._data.className = pl.css.sPaused; 81 pl.addClass(this._data.oLink, this._data.className) 82 }, 83 resume: function() { 84 pl.removeClass(this._data.oLink, this._data.className); 85 this._data.className = pl.css.sPlaying; 86 pl.addClass(this._data.oLink, this._data.className) 87 }, 88 finish: function() { 89 pl.removeClass(this._data.oLink, this._data.className); 90 this._data.className = ""; 91 if (pl.config.playNext) { 92 var nextLink = pl.indexByURL[this._data.oLink.href] + 1; 93 nextLink < pl.links.length && pl.handleClick({ 94 target: pl.links[nextLink] 95 }) 96 } 97 } 98 }; 99 this.stopEvent = function(e) { 100 void 0 !== e && void 0 !== e.preventDefault ? e.preventDefault() : "undefined" != typeof event && void 0 !== event.returnValue && (event.returnValue = false); 101 return false 102 }; 103 this.getTheDamnLink = isIE ? function(e) { 104 return e && e.target ? e.target : window.event.srcElement 105 } : function(e) { 106 return e.target 107 }; 108 this.getTheAudioId = function(url) { 109 if (null == url) return null; 110 var indexFace = url.indexOf("audio_id="); 111 return url.substring(indexFace + "audio_id=".length) 112 }; 113 this.handleClick = function(e) { 114 if (void 0 !== e.button && 1 < e.button) return true; 115 var o = self.getTheDamnLink(e); 116 if ("a" != o.nodeName.toLowerCase() && !(o = self.isChildOfNode(o, "a"))) return true; 117 if (!o.href || !sm.canPlayLink(o) && !self.classContains(o, self.playableClass) || self.classContains(o, self.excludeClass)) return true; 118 self.domTime = o.querySelector(".dyna-sitebuild-block-aud-track-time"); 119 if(!self.domTime){ 120 let domTime = document.createElement("div"); 121 domTime.classList.add("dyna-sitebuild-block-aud-track-time"); 122 domTime.innerText = '0:00/0:00'; 123 124 self.domTime = domTime; 125 o.children[0].before(domTime); 126 } 127 var soundURL = o.href, 128 thisSound = self.getSoundByURL(soundURL); 129 if (thisSound) 130 if (thisSound == self.lastSound) thisSound.togglePause(); 131 else { 132 sm._writeDebug("sound different than last sound: " + self.lastSound.id); 133 self.lastSound && self.stopSound(self.lastSound); 134 removeTheSound(self.lastSound); 135 thisSound.togglePause() 136 } 137 else { 138 if (self.lastSound) { 139 self.stopSound(self.lastSound); 140 removeTheSound(self.lastSound) 141 } 142 thisSound = sm.createSound({ 143 id: "inlineMP3Sound" + self.soundCount++, 144 url: soundURL, 145 onplay: self.events.play, 146 onstop: self.events.stop, 147 onpause: self.events.pause, 148 onresume: self.events.resume, 149 onfinish: self.events.finish, 150 type: o.type || null, 151 whileplaying: function() { 152 soundManager._writeDebug('whileplaying(): '+ self.getTime(this.position, true)+' / '+self.getTime(this.duration, true)); 153 self.domTime && (self.domTime.innerHTML = self.getTime(this.position, true)+'/'+self.getTime(this.duration, true)); 154 }, 155 }); 156 var theAudioId = self.getTheAudioId(soundURL); 157 if (null != theAudioId) { 158 var volume = $("#slider" + theAudioId).slider("value"); 159 null != volume && sm.setVolume(thisSound.id, volume) 160 } 161 thisSound._data = { 162 oLink: o, 163 className: self.css.sPlaying 164 }; 165 self.soundsByURL[soundURL] = thisSound; 166 self.sounds.push(thisSound); 167 ! function(sound, o) { 168 var loop = o.getAttribute("loop"); 169 ! function loopSound(sound, n) { 170 sound.play({ 171 onfinish: function() { 172 0 < n ? loopSound(sound, n - 1) : function(s) { 173 pl.removeClass(s._data.oLink, s._data.className); 174 s._data.className = ""; 175 if (pl.config.playNext) { 176 var nextLink = pl.indexByURL[s._data.oLink.href] + 1; 177 nextLink < pl.links.length && pl.handleClick({ 178 target: pl.links[nextLink] 179 }) 180 } 181 removeTheSound(s) 182 }(this) 183 } 184 }) 185 }(sound, -1 == loop ? Number.MAX_VALUE : loop) 186 }(thisSound, o) 187 } 188 self.lastSound = thisSound; 189 void 0 !== e && void 0 !== e.preventDefault ? e.preventDefault() : event.returnValue = false;
190 return false 191 }; 192 this.stopSound = function(oSound) { 193 soundManager.stop(oSound.id); 194 soundManager.unload(oSound.id) 195 }; 196 // convert milliseconds to hh:mm:ss, return as object literal or string. 197 this.getTime = function (msec, useString) { 198 var nSec = Math.floor(msec / 1000), 199 hh = Math.floor(nSec / 3600), 200 min = Math.floor(nSec / 60) - Math.floor(hh * 60), 201 sec = Math.floor(nSec - (hh * 3600) - (min * 60)); 202 return (useString ? ((hh ? hh + ':' : '') + (hh && min < 10 ? '0' + min : min) + ':' + (sec < 10 ? '0' + sec : sec)) : { min: min, sec: sec }); 203 } 204 this.init = function() { 205 sm._writeDebug("inlinePlayer.init()"); 206 for (var oLinks = document.getElementsByTagName("a"), foundItems = 0, i = 0, j = oLinks.length; i < j; i++) 207 if ((sm.canPlayLink(oLinks[i]) || self.classContains(oLinks[i], self.playableClass)) && !self.classContains(oLinks[i], self.excludeClass)) { 208 self.addClass(oLinks[i], self.css.sDefault); 209 self.links[foundItems] = oLinks[i]; 210 self.indexByURL[oLinks[i].href] = foundItems; 211 foundItems++ 212 } if (0 < foundItems) { 213 self.addEventHandler(document, "click", self.handleClick); 214 self.config.autoPlay && self.handleClick({ 215 target: self.links[0], 216 preventDefault: function() {} 217 }) 218 } 219 sm._writeDebug("inlinePlayer.init(): Found " + foundItems + " relevant items.") 220 }; 221 this.init() 222} 223 224function reloadAudio() { 225 inlinePlayer = new InlinePlayer 226} 227 228function stopAllSounds() { 229 soundManager.stopAll() 230} 231 232function setVolume(soundUrl, volume) { 233 inlinePlayer.setVolume(getFullUrl(soundUrl), volume) 234} 235 236function getFullUrl(soundUrl) { 237 var protocol = window.location.protocol; 238 null == protocol && (protocol = document.location.protocol); 239 null == protocol && (protocol = "https:"); 240 var fullUrl = protocol + "//"; 241 fullUrl += $(location).attr("host"); 242 return (fullUrl += soundUrl).replace(/\s+/g, "%20") 243} 244 245function destroyTheSound(sURL) { 246 var s = inlinePlayer.getSoundByURL(getFullUrl(sURL)); 247 null != s && inlinePlayer.destroySound(s.id) 248} 249var inlinePlayer = null; 250soundManager.setup({ 251 debugMode: false, 252 preferFlash: false, 253 useFlashBlock: true, 254 url: "../edit/", 255 flashVersion: 9, 256 defaultOptions: { 257 volume: 50 258 } 259}); 260soundManager.onready(function() { 261 inlinePlayer = new InlinePlayer 262});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.