Skip to content

Commit

Permalink
version 1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
briganti committed Nov 7, 2014
1 parent 86b4489 commit 10f8f30
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 22 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vast-client-js",
"author": ["Olivier Poitrey <[email protected]>"],
"version": "1.3.0",
"version": "1.3.1",
"main": "vast-client.js",
"licenses": [{"type": "MIT", "url": "https://github.com/rs/vast-client-js/raw/master/LICENSE"}],
"ignore": [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vast-client-js",
"author": "Olivier Poitrey <[email protected]>",
"version": "1.3.0",
"version": "1.3.1",
"description": "Javascript VAST Client",
"keywords": ["vast", "ad", "advertising", "iab", "in-stream", "video"],
"repository": {"type": "git", "url": "https://github.com/rs/vast-client-js"},
Expand Down
69 changes: 49 additions & 20 deletions vast-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ module.exports = VASTMediaFile;

},{}],8:[function(_dereq_,module,exports){
// Generated by CoffeeScript 1.7.1
var URLHandler, VASTAd, VASTCompanionAd, VASTCreativeCompanion, VASTCreativeLinear, VASTMediaFile, VASTParser, VASTResponse, VASTUtil,
var EventEmitter, URLHandler, VASTAd, VASTCompanionAd, VASTCreativeCompanion, VASTCreativeLinear, VASTMediaFile, VASTParser, VASTResponse, VASTUtil,
__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; };

URLHandler = _dereq_('./urlhandler.coffee');
Expand All @@ -528,6 +528,8 @@ VASTMediaFile = _dereq_('./mediafile.coffee');

VASTCompanionAd = _dereq_('./companionad.coffee');

EventEmitter = _dereq_('events').EventEmitter;

VASTParser = (function() {
var URLTemplateFilters;

Expand Down Expand Up @@ -559,6 +561,21 @@ VASTParser = (function() {
});
};

VASTParser.vent = new EventEmitter();

VASTParser.track = function(templates, errorCode) {
this.vent.emit('VAST-error', errorCode);
return VASTUtil.track(templates, errorCode);
};

VASTParser.on = function(eventName, cb) {
return this.vent.on(eventName, cb);
};

VASTParser.once = function(eventName, cb) {
return this.vent.once(eventName, cb);
};

VASTParser._parse = function(url, parentURLs, cb) {
var filter, _i, _len;
for (_i = 0, _len = URLTemplateFilters.length; _i < _len; _i++) {
Expand Down Expand Up @@ -594,14 +611,17 @@ VASTParser = (function() {
if (ad != null) {
response.ads.push(ad);
} else {
VASTUtil.track(response.errorURLTemplates, {
_this.track(response.errorURLTemplates, {
ERRORCODE: 101
});
}
}
}
complete = function() {
complete = function(errorAlreadyRaised) {
var _l, _len3, _ref2;
if (errorAlreadyRaised == null) {
errorAlreadyRaised = false;
}
if (!response) {
return;
}
Expand All @@ -613,9 +633,11 @@ VASTParser = (function() {
}
}
if (response.ads.length === 0) {
VASTUtil.track(response.errorURLTemplates, {
ERRORCODE: 303
});
if (!errorAlreadyRaised) {
_this.track(response.errorURLTemplates, {
ERRORCODE: 303
});
}
response = null;
}
return cb(null, response);
Expand All @@ -629,7 +651,7 @@ VASTParser = (function() {
(function(ad) {
var baseURL, _ref2;
if (parentURLs.length >= 10 || (_ref2 = ad.nextWrapperURL, __indexOf.call(parentURLs, _ref2) >= 0)) {
VASTUtil.track(ad.errorURLTemplates, {
_this.track(ad.errorURLTemplates, {
ERRORCODE: 302
});
response.ads.splice(response.ads.indexOf(ad), 1);
Expand All @@ -641,17 +663,20 @@ VASTParser = (function() {
ad.nextWrapperURL = "" + baseURL + "/" + ad.nextWrapperURL;
}
return _this._parse(ad.nextWrapperURL, parentURLs, function(err, wrappedResponse) {
var creative, eventName, index, wrappedAd, _base, _l, _len3, _len4, _len5, _len6, _m, _n, _o, _ref3, _ref4, _ref5, _ref6;
var creative, errorAlreadyRaised, eventName, index, wrappedAd, _base, _l, _len3, _len4, _len5, _len6, _m, _n, _o, _ref3, _ref4, _ref5, _ref6;
errorAlreadyRaised = false;
if (err != null) {
VASTUtil.track(ad.errorURLTemplates, {
_this.track(ad.errorURLTemplates, {
ERRORCODE: 301
});
response.ads.splice(response.ads.indexOf(ad), 1);
errorAlreadyRaised = true;
} else if (wrappedResponse == null) {
VASTUtil.track(ad.errorURLTemplates, {
_this.track(ad.errorURLTemplates, {
ERRORCODE: 303
});
response.ads.splice(response.ads.indexOf(ad), 1);
errorAlreadyRaised = true;
} else {
response.errorURLTemplates = response.errorURLTemplates.concat(wrappedResponse.errorURLTemplates);
index = response.ads.indexOf(ad);
Expand Down Expand Up @@ -688,7 +713,7 @@ VASTParser = (function() {
}
}
delete ad.nextWrapperURL;
return complete();
return complete(errorAlreadyRaised);
});
})(ad);
}
Expand Down Expand Up @@ -937,7 +962,7 @@ VASTParser = (function() {

module.exports = VASTParser;

},{"./ad.coffee":2,"./companionad.coffee":4,"./creative.coffee":5,"./mediafile.coffee":7,"./response.coffee":9,"./urlhandler.coffee":11,"./util.coffee":14}],9:[function(_dereq_,module,exports){
},{"./ad.coffee":2,"./companionad.coffee":4,"./creative.coffee":5,"./mediafile.coffee":7,"./response.coffee":9,"./urlhandler.coffee":11,"./util.coffee":14,"events":1}],9:[function(_dereq_,module,exports){
// Generated by CoffeeScript 1.7.1
var VASTResponse;

Expand Down Expand Up @@ -1265,14 +1290,18 @@ XHRURLHandler = (function() {

XHRURLHandler.get = function(url, cb) {
var xhr;
xhr = this.xhr();
xhr.open('GET', url);
xhr.send();
return xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
return cb(null, xhr.responseXML);
}
};
try {
xhr = this.xhr();
xhr.open('GET', url);
xhr.send();
return xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
return cb(null, xhr.responseXML);
}
};
} catch (_error) {
return cb();
}
};

return XHRURLHandler;
Expand Down

0 comments on commit 10f8f30

Please sign in to comment.