diff --git a/sites/all/themes/custom/edlptheme/assets/dist/scripts/main.min.js b/sites/all/themes/custom/edlptheme/assets/dist/scripts/main.min.js index fb3155a94..8bc2d06df 100644 --- a/sites/all/themes/custom/edlptheme/assets/dist/scripts/main.min.js +++ b/sites/all/themes/custom/edlptheme/assets/dist/scripts/main.min.js @@ -555,7 +555,8 @@ .emmit('stop-shuffle') .openDocument({ nid:$link.attr('nid'), - audio_url:$link.attr('audio_url') + audio_url:$link.attr('audio_url'), + title:$link.find('.field--name-title').html() }); return false; } @@ -759,6 +760,22 @@ this.emmit('audio-open-document', {caller:caller}); + + // piwik + debugger; + if(typeof _paq !== 'undefined'){ + // page tracking + // https://matomo.org/blog/2017/02/how-to-track-single-page-websites-using-piwik-analytics/ + // _paq.push(['setCustomUrl', state.url]); + // _paq.push(['setDocumentTitle', data.title]); + // _paq.push(['trackPageView']); + // js event + // trackEvent(category, action, [name], [value]) + if(typeof node.title != 'undefined'){ + _paq.push(['trackEvent', 'Audio', 'play', node.title]); + } + } + this.launch(); }, launch(){ @@ -792,15 +809,18 @@ this.updateLoadingBar(); }, updateLoadingBar(){ - this.$loader.css({ - 'width':parseInt((100 * this.audio.buffered.end(0) / this.audio.duration), 10)+'%' - }); - if( this.audio.buffered.end(0) < this.audio.duration ){ - // loop through this function until file is fully loaded - var that = this; - window.requestAnimationFrame(that.updateLoadingBar.bind(that)); - }else{ - //console.log('Audio fully loaded'); + // if (track.readyState === 4){ + if(track.buffered.length>0){ + this.$loader.css({ + 'width':parseInt((100 * this.audio.buffered.end(0) / this.audio.duration), 10)+'%' + }); + if( this.audio.buffered.end(0) < this.audio.duration ){ + // loop through this function until file is fully loaded + var that = this; + window.requestAnimationFrame(that.updateLoadingBar.bind(that)); + }else{ + //console.log('Audio fully loaded'); + } } }, onCanplay(){ diff --git a/sites/all/themes/custom/edlptheme/assets/scripts/main.js b/sites/all/themes/custom/edlptheme/assets/scripts/main.js index fb3155a94..8bc2d06df 100644 --- a/sites/all/themes/custom/edlptheme/assets/scripts/main.js +++ b/sites/all/themes/custom/edlptheme/assets/scripts/main.js @@ -555,7 +555,8 @@ .emmit('stop-shuffle') .openDocument({ nid:$link.attr('nid'), - audio_url:$link.attr('audio_url') + audio_url:$link.attr('audio_url'), + title:$link.find('.field--name-title').html() }); return false; } @@ -759,6 +760,22 @@ this.emmit('audio-open-document', {caller:caller}); + + // piwik + debugger; + if(typeof _paq !== 'undefined'){ + // page tracking + // https://matomo.org/blog/2017/02/how-to-track-single-page-websites-using-piwik-analytics/ + // _paq.push(['setCustomUrl', state.url]); + // _paq.push(['setDocumentTitle', data.title]); + // _paq.push(['trackPageView']); + // js event + // trackEvent(category, action, [name], [value]) + if(typeof node.title != 'undefined'){ + _paq.push(['trackEvent', 'Audio', 'play', node.title]); + } + } + this.launch(); }, launch(){ @@ -792,15 +809,18 @@ this.updateLoadingBar(); }, updateLoadingBar(){ - this.$loader.css({ - 'width':parseInt((100 * this.audio.buffered.end(0) / this.audio.duration), 10)+'%' - }); - if( this.audio.buffered.end(0) < this.audio.duration ){ - // loop through this function until file is fully loaded - var that = this; - window.requestAnimationFrame(that.updateLoadingBar.bind(that)); - }else{ - //console.log('Audio fully loaded'); + // if (track.readyState === 4){ + if(track.buffered.length>0){ + this.$loader.css({ + 'width':parseInt((100 * this.audio.buffered.end(0) / this.audio.duration), 10)+'%' + }); + if( this.audio.buffered.end(0) < this.audio.duration ){ + // loop through this function until file is fully loaded + var that = this; + window.requestAnimationFrame(that.updateLoadingBar.bind(that)); + }else{ + //console.log('Audio fully loaded'); + } } }, onCanplay(){