From 12b0482dfa059f0cc7d0042de4f199be0c667df7 Mon Sep 17 00:00:00 2001 From: Michael Bensoussan Date: Fri, 23 May 2014 19:09:50 +0200 Subject: [PATCH] #7 dist/videojs.ga.js does not contain licene header --- Gruntfile.js | 22 +++++++++++++--------- dist/videojs.ga.js | 8 ++++++++ dist/videojs.ga.min.js | 9 ++++++--- package.json | 2 ++ src/videojs.ga.coffee | 10 +++++----- 5 files changed, 34 insertions(+), 17 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 8cd79b6..9129e48 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -6,11 +6,11 @@ module.exports = function(grunt) { grunt.initConfig({ // Metadata. pkg: grunt.file.readJSON('package.json'), - banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' + - '<%= grunt.template.today("yyyy-mm-dd") %>\n' + - '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' + - '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' + - ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n', + banner: '/*\n* <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' + + '<%= grunt.template.today("yyyy-mm-dd") %>\n' + + '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' + + '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>\n' + + '* Licensed <%= pkg.license %>\n*/', clean: { files: ['dist'] }, @@ -22,22 +22,26 @@ module.exports = function(grunt) { } }, uglify: { - options: { - banner: '<%= banner %>' - }, dist: { src: 'dist/videojs.ga.js', dest: 'dist/videojs.ga.min.js' }, }, + usebanner: { + taskName: { + options: { banner: '<%= banner %>' }, + files: { src: [ 'dist/*' ] } + } + } }); // These plugins provide necessary tasks. grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-coffee'); + grunt.loadNpmTasks('grunt-banner'); // Default task. - grunt.registerTask('default', ['clean', 'coffee', 'uglify']); + grunt.registerTask('default', ['clean', 'coffee', 'uglify', 'usebanner']); }; diff --git a/dist/videojs.ga.js b/dist/videojs.ga.js index 2489974..fecded3 100644 --- a/dist/videojs.ga.js +++ b/dist/videojs.ga.js @@ -1,8 +1,16 @@ +/* +* videojs-ga - v0.3.0 - 2014-05-23 +* Copyright (c) 2014 Michael Bensoussan +* Licensed MIT +*/ (function() { var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; videojs.plugin('ga', function(options) { var dataSetupOptions, defaultsEventsToTrack, end, error, eventCategory, eventLabel, eventsToTrack, fullscreen, gaLibrary, loaded, parsedOptions, pause, percentsAlreadyTracked, percentsPlayedInterval, play, resize, seekEnd, seekStart, seeking, sendbeacon, timeupdate, volumeChange; + if (options == null) { + options = {}; + } dataSetupOptions = {}; if (this.options()["data-setup"]) { parsedOptions = JSON.parse(this.options()["data-setup"]); diff --git a/dist/videojs.ga.min.js b/dist/videojs.ga.min.js index 61f467e..c1740ae 100644 --- a/dist/videojs.ga.min.js +++ b/dist/videojs.ga.min.js @@ -1,3 +1,6 @@ -/*! videojs-ga - v0.1.0 - 2014-02-10 -* Copyright (c) 2014 Michael Bensoussan; Licensed */ -(function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};videojs.plugin("ga",function(b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x;c={},this.options()["data-setup"]&&(m=JSON.parse(this.options()["data-setup"]),m.ga&&(c=m.ga)),d=["loaded","percentsPlayed","start","srcType","end","seek","play","pause","resize","volumeChange","error","fullscreen"],i=b.eventsToTrack||c.eventsToTrack||d,p=b.percentsPlayedInterval||c.percentsPlayedInterval||10,g=b.eventCategory||c.eventCategory||"Video",h=b.eventLabel||c.eventLabel,k=b.gaLibrary||c.gaLibrary||"ga.js",o=[],t=s=0,u=!1,l=function(){var b,c;h||(h=this.currentSrc().split("/").slice(-1)[0].replace(/\.(\w{3,4})(\?.*)?$/i,"")),a.call(i,"loadedmetadata")>=0&&v("loadedmetadata",!0),a.call(i,"srcType")>=0&&(c=this.currentSrc().split("."),b=c[c.length-1],v("source type - "+(""+this.techName+"/"+b),!0))},w=function(){var b,c,d,e,f;for(b=Math.round(this.currentTime()),c=Math.round(this.duration()),e=Math.round(b/c*100),d=f=0;99>=f;d=f+=p)e>=d&&a.call(o,d)<0&&(a.call(i,"start")>=0&&0===d&&e>0?v("start",!0):a.call(i,"percentsPlayed")>=0&&0!==e&&v("percent played",!0,d),e>0&&o.push(d));a.call(i,"seek")>=0&&(t=s,s=b,Math.abs(t-s)>1&&(u=!0,v("seek start",!1,t),v("seek end",!1,s)))},e=function(){v("end",!0)},q=function(){var a;a=Math.round(this.currentTime()),a>0&&!u&&v("play",!0,a),u=!0},n=function(){var a,b;a=Math.round(this.currentTime()),b=Math.round(this.duration()),a===b||u||v("pause",!1,a)},x=function(){var a;a=this.muted()===!0?0:this.volume(),v("volume change",!1,a)},r=function(){v("resize - "+this.width()+"*"+this.height(),!0)},f=function(){var a;a=Math.round(this.currentTime()),v("error",!0,a)},j=function(){var a;a=Math.round(this.currentTime()),this.isFullScreen?v("enter fullscreen",!1,a):v("exit fullscreen",!1,a)},v=function(a,b,c){try{"analytics.js"===k?ga("send","event",{eventCategory:g,eventAction:a,eventLabel:h,eventValue:c,nonInteraction:b}):_gaq.push(["_trackEvent",g,a,h,c,b])}catch(d){}},this.on("loadedmetadata",l),this.on("timeupdate",w),a.call(i,"end")>=0&&this.on("ended",e),a.call(i,"play")>=0&&this.on("play",q),a.call(i,"pause")>=0&&this.on("pause",n),a.call(i,"volumeChange")>=0&&this.on("volumechange",x),a.call(i,"resize")>=0&&this.on("resize",r),a.call(i,"error")>=0&&this.on("error",f),a.call(i,"fullscreen")>=0&&this.on("fullscreenchange",j)})}).call(this); \ No newline at end of file +/* +* videojs-ga - v0.3.0 - 2014-05-23 +* Copyright (c) 2014 Michael Bensoussan +* Licensed MIT +*/ +(function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};videojs.plugin("ga",function(b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x;null==b&&(b={}),c={},this.options()["data-setup"]&&(m=JSON.parse(this.options()["data-setup"]),m.ga&&(c=m.ga)),d=["loaded","percentsPlayed","start","srcType","end","seek","play","pause","resize","volumeChange","error","fullscreen"],i=b.eventsToTrack||c.eventsToTrack||d,p=b.percentsPlayedInterval||c.percentsPlayedInterval||10,g=b.eventCategory||c.eventCategory||"Video",h=b.eventLabel||c.eventLabel,k=b.gaLibrary||c.gaLibrary||"ga.js",o=[],t=s=0,u=!1,l=function(){var b,c;h||(h=this.currentSrc().split("/").slice(-1)[0].replace(/\.(\w{3,4})(\?.*)?$/i,"")),a.call(i,"loadedmetadata")>=0&&v("loadedmetadata",!0),a.call(i,"srcType")>=0&&(c=this.currentSrc().split("."),b=c[c.length-1],v("source type - "+(""+this.techName+"/"+b),!0))},w=function(){var b,c,d,e,f;for(b=Math.round(this.currentTime()),c=Math.round(this.duration()),e=Math.round(b/c*100),d=f=0;99>=f;d=f+=p)e>=d&&a.call(o,d)<0&&(a.call(i,"start")>=0&&0===d&&e>0?v("start",!0):a.call(i,"percentsPlayed")>=0&&0!==e&&v("percent played",!0,d),e>0&&o.push(d));a.call(i,"seek")>=0&&(t=s,s=b,Math.abs(t-s)>1&&(u=!0,v("seek start",!1,t),v("seek end",!1,s)))},e=function(){v("end",!0)},q=function(){var a;a=Math.round(this.currentTime()),a>0&&!u&&v("play",!0,a),u=!0},n=function(){var a,b;a=Math.round(this.currentTime()),b=Math.round(this.duration()),a===b||u||v("pause",!1,a)},x=function(){var a;a=this.muted()===!0?0:this.volume(),v("volume change",!1,a)},r=function(){v("resize - "+this.width()+"*"+this.height(),!0)},f=function(){var a;a=Math.round(this.currentTime()),v("error",!0,a)},j=function(){var a;a=Math.round(this.currentTime()),this.isFullScreen?v("enter fullscreen",!1,a):v("exit fullscreen",!1,a)},v=function(a,b,c){try{"analytics.js"===k?ga("send","event",{eventCategory:g,eventAction:a,eventLabel:h,eventValue:c,nonInteraction:b}):_gaq.push(["_trackEvent",g,a,h,c,b])}catch(d){}},this.on("loadedmetadata",l),this.on("timeupdate",w),a.call(i,"end")>=0&&this.on("ended",e),a.call(i,"play")>=0&&this.on("play",q),a.call(i,"pause")>=0&&this.on("pause",n),a.call(i,"volumeChange")>=0&&this.on("volumechange",x),a.call(i,"resize")>=0&&this.on("resize",r),a.call(i,"error")>=0&&this.on("error",f),a.call(i,"fullscreen")>=0&&this.on("fullscreenchange",j)})}).call(this); \ No newline at end of file diff --git a/package.json b/package.json index faea3bb..0c001b3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "videojs-ga", "version": "0.1.0", + "license": "MIT", "author": { "name": "Michael Bensoussan", "email": "mbensoussan.is@gmail.com" @@ -12,6 +13,7 @@ "grunt-contrib-uglify": "~0.2.0", "grunt-contrib-clean": "~0.4.0", "grunt-contrib-coffee": "~0.4.0", + "grunt-banner": "~0.2.2", "grunt": "~0.4.1" } } \ No newline at end of file diff --git a/src/videojs.ga.coffee b/src/videojs.ga.coffee index f77ba0e..4bcc9e3 100644 --- a/src/videojs.ga.coffee +++ b/src/videojs.ga.coffee @@ -6,7 +6,7 @@ # Licensed under the MIT license. ## -videojs.plugin 'ga', (options) -> +videojs.plugin 'ga', (options = {}) -> # this loads options from the data-setup attribute of the video tag dataSetupOptions = {} if @options()["data-setup"] @@ -24,10 +24,10 @@ videojs.plugin 'ga', (options) -> eventCategory = options.eventCategory || dataSetupOptions.eventCategory || 'Video' # if you didn't specify a name, it will be 'guessed' from the video src after metadatas are loaded eventLabel = options.eventLabel || dataSetupOptions.eventLabel - + # determine if we are using ga.js or analytics.js gaLibrary = options.gaLibrary || dataSetupOptions.gaLibrary || 'ga.js' - + # init a few variables percentsAlreadyTracked = [] seekStart = seekEnd = 0 @@ -115,7 +115,7 @@ videojs.plugin 'ga', (options) -> else sendbeacon( 'exit fullscreen', false, currentTime ) return - + sendbeacon = ( action, nonInteraction, value ) -> try if 'analytics.js' == gaLibrary @@ -129,7 +129,7 @@ videojs.plugin 'ga', (options) -> else _gaq.push(['_trackEvent', eventCategory, action, eventLabel, value, nonInteraction]) return - + @on("loadedmetadata", loaded) @on("timeupdate", timeupdate) @on("ended", end) if "end" in eventsToTrack