Skip to content

Commit

Permalink
Version 1.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
dharFr committed Mar 6, 2015
1 parent b35524c commit e69d3ca
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 40 deletions.
3 changes: 1 addition & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"name": "vast-client-js",
"author": ["Olivier Poitrey <[email protected]>"],
"version": "1.3.2",
"version": "1.3.3",
"main": "vast-client.js",
"licenses": [{"type": "MIT", "url": "https://github.com/rs/vast-client-js/raw/master/LICENSE"}],
"ignore": [
"**/.*",
"node_modules",
"components",
"src",
"test",
"package.json"
]
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.2",
"version": "1.3.3",
"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
99 changes: 62 additions & 37 deletions vast-client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.DMVAST=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.DMVAST=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
Expand Down Expand Up @@ -146,10 +146,7 @@ EventEmitter.prototype.addListener = function(type, listener) {
'leak detected. %d listeners added. ' +
'Use emitter.setMaxListeners() to increase limit.',
this._events[type].length);
if (typeof console.trace === 'function') {
// not supported in IE 10
console.trace();
}
console.trace();
}
}

Expand Down Expand Up @@ -335,20 +332,29 @@ VASTClient = (function() {

VASTClient.cappingMinimumTimeInterval = 0;

VASTClient.timeout = 0;
VASTClient.options = {
withCredentials: false,
timeout: 0
};

VASTClient.get = function(url, opts, cb) {
var now, options;
var extend, now, options;
now = +new Date();
options = {};
if (opts) {
if (typeof opts === 'object') {
options = opts;
extend = exports.extend = function(object, properties) {
var key, val;
for (key in properties) {
val = properties[key];
object[key] = val;
}
return object;
};
if (!cb) {
if (typeof opts === 'function') {
cb = opts;
}
options = {};
}
options = extend(this.options, opts);
if (this.totalCallsTimeout < now) {
this.totalCalls = 1;
this.totalCallsTimeout = now + (60 * 60 * 1000);
Expand Down Expand Up @@ -498,6 +504,7 @@ var VASTMediaFile;

VASTMediaFile = (function() {
function VASTMediaFile() {
this.id = null;
this.fileURL = null;
this.deliveryType = "progressive";
this.mimeType = null;
Expand All @@ -508,6 +515,8 @@ VASTMediaFile = (function() {
this.width = 0;
this.height = 0;
this.apiFramework = null;
this.scalable = null;
this.maintainAspectRatio = null;
}

return VASTMediaFile;
Expand Down Expand Up @@ -565,9 +574,11 @@ VASTParser = (function() {
};

VASTParser.parse = function(url, options, cb) {
if (typeof options === 'function') {
cb = options;
options = null;
if (!cb) {
if (typeof options === 'function') {
cb = options;
}
options = {};
}
return this._parse(url, null, options, function(err, response) {
return cb(response);
Expand All @@ -591,6 +602,12 @@ VASTParser = (function() {

VASTParser._parse = function(url, parentURLs, options, cb) {
var filter, _i, _len;
if (!cb) {
if (typeof options === 'function') {
cb = options;
}
options = {};
}
for (_i = 0, _len = URLTemplateFilters.length; _i < _len; _i++) {
filter = URLTemplateFilters[_i];
url = filter(url);
Expand All @@ -599,13 +616,6 @@ VASTParser = (function() {
parentURLs = [];
}
parentURLs.push(url);
if (typeof options === 'function') {
cb = options;
options = {};
}
if (!options) {
options = {};
}
return URLHandler.get(url, options, (function(_this) {
return function(err, xml) {
var ad, complete, loopIndex, node, response, _j, _k, _len1, _len2, _ref, _ref1;
Expand Down Expand Up @@ -682,7 +692,7 @@ VASTParser = (function() {
baseURL = url.slice(0, url.lastIndexOf('/'));
ad.nextWrapperURL = "" + baseURL + "/" + ad.nextWrapperURL;
}
return _this._parse(ad.nextWrapperURL, parentURLs, function(err, wrappedResponse) {
return _this._parse(ad.nextWrapperURL, parentURLs, options, function(err, wrappedResponse) {
var creative, errorAlreadyRaised, eventName, index, wrappedAd, _base, _l, _len3, _len4, _len5, _len6, _m, _n, _o, _ref3, _ref4, _ref5, _ref6;
errorAlreadyRaised = false;
if (err != null) {
Expand Down Expand Up @@ -858,7 +868,7 @@ VASTParser = (function() {
};

VASTParser.parseCreativeLinearElement = function(creativeElement) {
var clickTrackingElement, creative, eventName, mediaFile, mediaFileElement, mediaFilesElement, percent, skipOffset, trackingElement, trackingEventsElement, trackingURLTemplate, videoClicksElement, _base, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4;
var clickTrackingElement, creative, eventName, maintainAspectRatio, mediaFile, mediaFileElement, mediaFilesElement, percent, scalable, skipOffset, trackingElement, trackingEventsElement, trackingURLTemplate, videoClicksElement, _base, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4;
creative = new VASTCreativeLinear();
creative.duration = this.parseDuration(this.parseNodeText(this.childByName(creativeElement, "Duration")));
if (creative.duration === -1 && creativeElement.parentNode.parentNode.parentNode.nodeName !== 'Wrapper') {
Expand Down Expand Up @@ -905,6 +915,7 @@ VASTParser = (function() {
for (_m = 0, _len4 = _ref4.length; _m < _len4; _m++) {
mediaFileElement = _ref4[_m];
mediaFile = new VASTMediaFile();
mediaFile.id = mediaFileElement.getAttribute("id");
mediaFile.fileURL = this.parseNodeText(mediaFileElement);
mediaFile.deliveryType = mediaFileElement.getAttribute("delivery");
mediaFile.codec = mediaFileElement.getAttribute("codec");
Expand All @@ -915,6 +926,24 @@ VASTParser = (function() {
mediaFile.maxBitrate = parseInt(mediaFileElement.getAttribute("maxBitrate") || 0);
mediaFile.width = parseInt(mediaFileElement.getAttribute("width") || 0);
mediaFile.height = parseInt(mediaFileElement.getAttribute("height") || 0);
scalable = mediaFileElement.getAttribute("scalable");
if (scalable && typeof scalable === "string") {
scalable = scalable.toLowerCase();
if (scalable === "true") {
mediaFile.scalable = true;
} else if (scalable === "false") {
mediaFile.scalable = false;
}
}
maintainAspectRatio = mediaFileElement.getAttribute("maintainAspectRatio");
if (maintainAspectRatio && typeof maintainAspectRatio === "string") {
maintainAspectRatio = maintainAspectRatio.toLowerCase();
if (maintainAspectRatio === "true") {
mediaFile.maintainAspectRatio = true;
} else if (maintainAspectRatio === "false") {
mediaFile.maintainAspectRatio = false;
}
}
creative.mediaFiles.push(mediaFile);
}
}
Expand Down Expand Up @@ -1244,6 +1273,12 @@ URLHandler = (function() {
function URLHandler() {}

URLHandler.get = function(url, options, cb) {
if (!cb) {
if (typeof options === 'function') {
cb = options;
}
options = {};
}
if (typeof window === "undefined" || window === null) {
return _dereq_('./urlhandlers/' + 'node.coffee').get(url, options, cb);
} else if (xhr.supported()) {
Expand Down Expand Up @@ -1282,20 +1317,15 @@ FlashURLHandler = (function() {

FlashURLHandler.get = function(url, options, cb) {
var xdr, xmlDocument;
if (typeof options === 'function') {
cb = options;
options = null;
}
if (xmlDocument = typeof window.ActiveXObject === "function" ? new window.ActiveXObject("Microsoft.XMLDOM") : void 0) {
xmlDocument.async = false;
} else {
return cb();
}
xdr = this.xdr();
xdr.open('GET', url);
if (options && options.withCredentials === true) {
xdr.withCredentials = true;
}
xdr.timeout = options.timeout || 0;
xdr.withCredentials = options.withCredentials || false;
xdr.send();
return xdr.onload = function() {
xmlDocument.loadXML(xdr.responseText);
Expand Down Expand Up @@ -1330,16 +1360,11 @@ XHRURLHandler = (function() {

XHRURLHandler.get = function(url, options, cb) {
var xhr;
if (typeof options === 'function') {
cb = options;
options = null;
}
try {
xhr = this.xhr();
xhr.open('GET', url);
if (options && options.withCredentials === true) {
xhr.withCredentials = true;
}
xhr.timeout = options.timeout || 0;
xhr.withCredentials = options.withCredentials || false;
xhr.send();
return xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
Expand Down

0 comments on commit e69d3ca

Please sign in to comment.