diff --git a/bower.json b/bower.json index ce399120..dbbfa180 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "vast-client-js", "author": ["Olivier Poitrey "], - "version": "1.1.0", + "version": "1.1.1", "main": "vast-client.js", "licenses": [{"type": "MIT", "url": "https://github.com/rs/vast-client-js/raw/master/LICENSE"}], "ignore": [ diff --git a/package.json b/package.json index cf136214..1e63b5ce 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vast-client-js", "author": "Olivier Poitrey ", - "version": "1.0.0", + "version": "1.1.1", "description": "Javascript VAST Client", "keywords": ["vast", "ad", "advertising", "iab", "in-stream", "video"], "repository": {"type": "git", "url": "https://github.com/rs/vast-client-js"}, diff --git a/vast-client.js b/vast-client.js index 658230d1..0dafbf56 100644 --- a/vast-client.js +++ b/vast-client.js @@ -441,6 +441,11 @@ VASTTracker = (function(_super) { } if (creative instanceof VASTCreativeLinear) { this.assetDuration = creative.duration; + this.quartiles = { + 'firstQuartile': Math.round(25 * this.assetDuration) / 100, + 'midpoint': Math.round(50 * this.assetDuration) / 100, + 'thirdQuartile': Math.round(75 * this.assetDuration) / 100 + }; this.skipDelay = creative.skipDelay; this.linear = true; this.clickThroughURLTemplate = creative.videoClickThroughURLTemplate; @@ -455,7 +460,7 @@ VASTTracker = (function(_super) { } VASTTracker.prototype.setProgress = function(progress) { - var eventName, events, percent, skipDelay, _i, _len; + var eventName, events, percent, quartile, skipDelay, time, _i, _len, _ref; skipDelay = this.skipDelay === null ? this.skipDelayDefault : this.skipDelay; if (skipDelay !== -1 && !this.skipable) { if (skipDelay > progress) { @@ -471,9 +476,11 @@ VASTTracker = (function(_super) { events.push("start"); percent = Math.round(progress / this.assetDuration * 100); events.push("progress-" + percent + "%"); - if (percent >= 25) events.push("firstQuartile"); - if (percent >= 50) events.push("midpoint"); - if (percent >= 75) events.push("thirdQuartile"); + _ref = this.quartiles; + for (quartile in _ref) { + time = _ref[quartile]; + if ((time <= progress && progress <= (time + 1))) events.push(quartile); + } } for (_i = 0, _len = events.length; _i < _len; _i++) { eventName = events[_i]; @@ -977,38 +984,61 @@ module.exports = { VASTCreativeCompanion: VASTCreativeCompanion }; -},{}],11:[function(require,module,exports){ -var VASTAd; +},{}],10:[function(require,module,exports){ +var VASTResponse; -VASTAd = (function() { +VASTResponse = (function() { - function VASTAd() { + function VASTResponse() { + this.ads = []; this.errorURLTemplates = []; - this.impressionURLTemplates = []; - this.creatives = []; } - return VASTAd; + return VASTResponse; })(); -module.exports = VASTAd; +module.exports = VASTResponse; -},{}],10:[function(require,module,exports){ -var VASTResponse; +},{}],12:[function(require,module,exports){ +var VASTMediaFile; -VASTResponse = (function() { +VASTMediaFile = (function() { - function VASTResponse() { - this.ads = []; + function VASTMediaFile() { + this.fileURL = null; + this.deliveryType = "progressive"; + this.mimeType = null; + this.codec = null; + this.bitrate = 0; + this.minBitrate = 0; + this.maxBitrate = 0; + this.width = 0; + this.height = 0; + } + + return VASTMediaFile; + +})(); + +module.exports = VASTMediaFile; + +},{}],11:[function(require,module,exports){ +var VASTAd; + +VASTAd = (function() { + + function VASTAd() { this.errorURLTemplates = []; + this.impressionURLTemplates = []; + this.creatives = []; } - return VASTResponse; + return VASTAd; })(); -module.exports = VASTResponse; +module.exports = VASTAd; },{}],9:[function(require,module,exports){ var URLHandler, flash, xhr; @@ -1037,30 +1067,7 @@ URLHandler = (function() { module.exports = URLHandler; -},{"./urlhandlers/xmlhttprequest.coffee":13,"./urlhandlers/flash.coffee":14}],12:[function(require,module,exports){ -var VASTMediaFile; - -VASTMediaFile = (function() { - - function VASTMediaFile() { - this.fileURL = null; - this.deliveryType = "progressive"; - this.mimeType = null; - this.codec = null; - this.bitrate = 0; - this.minBitrate = 0; - this.maxBitrate = 0; - this.width = 0; - this.height = 0; - } - - return VASTMediaFile; - -})(); - -module.exports = VASTMediaFile; - -},{}],14:[function(require,module,exports){ +},{"./urlhandlers/xmlhttprequest.coffee":13,"./urlhandlers/flash.coffee":14}],14:[function(require,module,exports){ var FlashURLHandler; FlashURLHandler = (function() {