Skip to content

Instantly share code, notes, and snippets.

@sgulseth
Created November 10, 2015 14:07
Show Gist options
  • Select an option

  • Save sgulseth/fc26cc2a62f617f0dcff to your computer and use it in GitHub Desktop.

Select an option

Save sgulseth/fc26cc2a62f617f0dcff to your computer and use it in GitHub Desktop.
/* AST v0.2.6 Updated : 2015-10-13 (1444771604718) */ ! function(e) {
function t(a) {
if (n[a]) return n[a].exports;
var r = n[a] = {
exports: {},
id: a,
loaded: !1
};
return e[a].call(r.exports, r, r.exports, t), r.loaded = !0, r.exports
}
var n = {};
return t.m = e, t.c = n, t.p = "", t(0)
}([
function(e, t, n) {
(function(e) {
function t() {
if (L) try {} catch (e) {
L = l()
} else L = l();
return L
}
function a(e) {
e ? (f = m.stringContains(e, "http") ? e : t().document.location.protocol + "//" + e, m.logMessage("Setting endpoint to: " + f)) : m.logError("Cannot set an empty endpoint")
}
function r(e) {
_[e.targetId] = J(e)
}
function o(e) {
var t = de(e);
return t
}
function i(e) {
var t = "defaultKey";
return e.targetId && (t = e.targetId), t
}
function s(e) {
m.logMessage("showTag called for " + e), I[e] = !0;
var t = we(e);
if (t) {
var n = apntag.requests.tags[e];
n.showTagCalled = !0, apntag.requests.utCalled ? n.adResponse ? (g(n), apntag.requests.hasLeft && be()) : (apntag.requests.checkDisplay = !0, m.logMessage("showTag called before ad response is available : " + e)) : apntag.timeoutSet || m.logError("ut request did not call. This placement may be pending on other coordinated request on page")
} else m.logError("the " + e + " tag is not defined.", h.LOG.WARN)
}
function d(e, t) {
var n = t,
a = i(e);
n || (n = _[a]);
var r = null;
if (!n) return void m.logError("Issue writing iframe into document. No ad available to render");
try {
r = JSON.parse(n)
} catch (o) {
return void m.logError("Issue writing iframe into document :" + o.message)
}
if (r && r.tags) {
var s = r.tags[0];
if (!s) return void m.logError("Issue writing iframe into document. No ad available to render");
var d = s.ad,
u = d[S],
g = d[C],
l = window.document.getElementsByTagName("script")[0];
if (d && d.banner && d.banner.content) try {
window.document.write(d.banner.content), m.logTimestamp("Ad is loaded"), m.loadPixelUrl(window.document, l, g, u), m.logMessage("Win notification sent for creative ID: " + u)
} catch (o) {
m.logError("Issue writing iframe into document :" + o.message)
}
}
}
function u(e, t) {
m._each(w[t], function(t) {
apntag.recordErrorEvent(e, t)
})
}
function g(e) {
var n, a, r = t(),
o = e.adResponse;
if (typeof o !== x && e.showTagCalled) {
if (o && o.ad.renderer_url && o.ad.renderer_id) {
var i = o.ad.renderer_id;
v[i] ? "function" == typeof v[i] ? (v[i].call(apntag, e, c), E.emit("adLoaded", e.targetId), m.logTimestamp("The " + e.targetId + " ad is loaded."), e.displayed = !0) : (y[i] = typeof y[i] === x ? [] : y[i], y[i].push(e)) : (m.loadScript(t(), o.ad.renderer_url), y[i] = typeof y[i] === x ? [] : y[i], y[i].push(e), v[i] = !0)
} else if (o.ad[O] === N) m.logMessage("Render for the following ad should be handled outside of ast.js :" + e.tagId), E.emit("adLoaded", e.targetId), m.logTimestamp("The " + e.targetId + " ad is loaded."), e.displayed = !0;
else if (o.ad[O] === R) {
var s = o.ad[P];
if (m.isEmpty(s) || typeof s !== M) return void m.logError("Response has no banner object");
if (!m.hasOwn(s, D)) return void m.logError("Response has no banner content");
if (!m.hasOwn(s, "width")) return void m.logError("Response has no banner width");
if (!m.hasOwn(s, "height")) return void m.logError("Response has no banner height");
if (n = ie(e), a = oe(e), a.appendChild(n), r.document.body) try {
e.showTagCalled && (se(e, a, n), a.style.display = "inline")
} catch (d) {
m.logError("Error rendering ad: " + d.message)
} else m.logError("Error rendering ad: window.document.body is undefined");
e.displayed = !0
}
T.push(e.targetId)
}
}
function l() {
var t, n = !1;
try {
var a = e && e.window ? e.window : window;
do {
if (a.parent.document.getElementsByTagName("frameset").length > 0) {
n = !0;
break
}
if (a.parent.document.getElementsByTagName("iframe").length > 0) break;
a = a.parent
} while (a.document !== a.parent.document);
if (n)
for (var r = a.parent.document.getElementsByTagName("frame"), o = 0; o < r.length; o++)
if (r[o].contentWindow.document === a.document) {
a = r[o].contentWindow;
break
}
t = a
} catch (i) {
t = e.window
}
return t
}
function c(e, n, a) {
if (m.logMessage("handling event for: " + e + " eventType : " + n), E.emit(n, e), n === A) {
var r = p(e);
try {
var o = r.utDivId,
i = t().document.getElementById(o),
s = r.adResponse.ad[C];
m.loadPixelUrl(), m.loadPixelUrl(t().document, i, s, e)
} catch (d) {
m.logError("Error sending notify_url: " + d.message)
}
}
}
function p(e) {
var t = null;
return m._each(apntag.requests.tags, function(n, a) {
n.uuid === e && (t = n)
}), t
}
var f, m = n(1),
E = n(3),
h = n(2),
v = (n(4), {}),
y = {}, T = [],
w = {}, b = 0,
q = 0,
I = {}, _ = {}, O = (h.UT_RESPONSE_PROP.MEDIA_TYPE, h.MEDIA_TYPE.NATIVE, h.UT_RESPONSE_PROP.AD_TYPE),
N = h.AD_TYPE.NATIVE,
R = h.AD_TYPE.BANNER,
P = h.UT_RESPONSE_PROP.BANNER,
D = h.UT_RESPONSE_PROP.CONTENT,
C = h.AD.NOTIFY,
S = (h.UT_RESPONSE_PROP.UUID, h.AD.CREATIVE_ID),
A = h.RENDERER_EVENTS.LOADED,
x = h.OBJECT_TYPE.UNDEFINED,
M = h.OBJECT_TYPE.OBJECT,
U = h.OBJECT_TYPE.NUMBER,
B = h.DEBUG.AST_DONGLE,
L = t();
try {
console.info("apntag library loaded")
} catch (W) {}
apntag = typeof apntag !== x ? apntag : {}, apntag.anq = apntag.anq || [], apntag.debug = apntag.debug || !1, apntag.dongle = apntag.dongle || void 0, apntag.loaded = !0, apntag.requests = apntag.requests || [], a(h.ENDPOINT.IMPBUS), apntag.requests.tagsOnPageCount = apntag.requests.tagsOnPageCount || b, apntag.requests.waitOnTagsCount = apntag.requests.waitOnTagsCount || q, apntag.requests.showTagDefinedMap = apntag.requests.showTagDefinedMap || I, apntag.anq.push = function(e) {
e.call()
}, apntag.setEndpoint = function(e) {
a(e)
}, apntag.setPageOpts = function(e) {
e && (e.member && (apntag.requests.member = e.member), e.targetingParams && (apntag.requests.targetingParams = e.targetingParams), e.user && (apntag.requests.user = e.user), e.app && (apntag.requests.app = e.app), e.device && (apntag.requests.device = e.device), e.site && (apntag.requests.site = e.site))
}, apntag.defineTag = function(e) {
var t = null;
return apntag.syncLoad ? r(e) : t = o(e), t
}, apntag.getTag = function(e) {
return m.logMessage("getTag called for tag " + e), we(e) ? e && apntag.requests.tags && apntag.requests.tags[e] ? apntag.requests.tags[e] : void 0 : void m.logError("the " + e + " tag is not defined.", h.LOG.WARN)
}, apntag.getAdData = function(e) {
return we(e) ? e && apntag.requests.tags && apntag.requests.tags[e] && apntag.requests.tags[e].adResponse ? apntag.requests.tags[e].adResponse : void 0 : void m.logError("the " + e + " tag is not defined.", h.LOG.WARN)
}, apntag.setSizes = function(e, t) {
return arguments.length < 2 && (t = e, e = this.targetId), we(e) ? void(apntag.requests.tags[e].sizes = t) : void m.logError("the " + e + " tag is not defined.", h.LOG.WARN)
}, apntag.modifyTag = function(e, t) {
var n = {};
return arguments.length < 2 && (t = e, e = this.targetId), we(e) ? (m._each(apntag.requests.tags[e], function(e, t) {
n[t] = e
}), m._each(t, function(e, t) {
n[t] = e
}), void(apntag.requests.tags[e] = n)) : void m.logError("the " + e + " tag is not defined.", h.LOG.WARN)
}, apntag.onEvent = function(e, t, n) {
return arguments.length < 3 && (n = t, t = this.targetId), we(t) ? void E.on(e, t, n) : void m.logError("the " + t + " tag is not defined.", h.LOG.WARN)
}, apntag.offEvent = function(e, t, n) {
return arguments.length < 2 && (t = this.targetId), we(t) ? void E.off(e, t, n) : void m.logError("the " + t + " tag is not defined.", h.LOG.WARN)
}, apntag.loadTags = function() {
ge()
}, apntag.refresh = function() {
m.logMessage("refresh tags"), ue()
}, apntag.showAdFromURL = function(e) {
var t = J(e);
d(e, t)
}, apntag.collapseAd = function(e, n, a) {
m.logMessage("Calling callapseAd function");
var r, o = 0,
i = 0,
s = apntag.getTag(e);
if (!s) return void m.logError("CollapseAd failed to find targetId : " + e);
r = re(s), typeof n === U && (o = n), typeof a === U && (i = a);
var d = t().document.getElementById(r);
return null === d ? void m.logError("CollapseAd failed to find ad div : " + e) : (d.style.height = o, d.style.width = i, d.style.display = "none", void E.emit("adCollapse", e))
}, apntag.showTag = function(e) {
apntag.syncLoad ? d(e) : s(e)
}, apntag.setPageTargeting = function(e, t) {
m.logMessage("setPageTargeting called " + e + "=" + t), apntag.requests.targetingParams && e && t && (apntag.requests.targetingParams[e] = t)
}, apntag.getPageTargeting = function(e) {
return m.logMessage("getPageTargeting called: requesting key " + e), apntag.requests.targetingParams && e ? apntag.requests.targetingParams[e] : void 0
}, apntag.clearPageTargeting = function(e) {
m.logMessage("clearPageTargeting called: clearing " + e), apntag.requests.targetingParams && e && delete apntag.requests.targetingParams[e]
}, apntag.enableDebug = function() {
apntag.debug = !0
}, apntag.disableDebug = function() {
apntag.debug = !1
}, apntag.registerRenderer = function(e, t) {
m.logMessage("ast.js: Renderer registered with id: " + e), e && m.isFn(t) ? (v[e] = t, y[e] && m._each(y[e], function(t) {
t.displayed || (v[e].call(apntag, t, c), t.displayed = !0)
})) : m.logError("ast.js", "registerRenderer must be called with (id, cbFn)")
}, apntag.recordErrorEvent = function(e, t) {
m.logError("Error event :" + e), E.emit("adError", t, e)
};
var F = function(e) {
m._each(w[e], function(e) {
E.emit("adRequested", e)
}), m.logTimestamp("Ad is requested for member " + e)
};
apntag.handleCb = function(e) {
var n = (t(), e);
if (typeof n === x || null === n || n.error) {
var a = "malformed response";
return n && n.error && (a = n.error), m.logError("Error response from impbus: " + a), void m._each(apntag.requests.tags, function(e, t) {
E.emit("adRequestFailure", t)
})
}
m._each(n.tags, function(e) {
m._each(apntag.requests.tags, function(t, n) {
t.uuid === e.uuid && (e.nobid === !0 ? (m.logMessage("No bid for targetId:" + t.targetId), E.emit("adNoBid", n)) : (t.adResponse = e, t.utCalled = !0, E.emit("adAvailable", n), g(t)))
})
}), apntag.requests.checkDisplay && be()
};
var j = function() {
for (var e = 0; e < apntag.anq.length; e++) typeof apntag.anq[e].called === x && (apntag.anq[e].call(), apntag.anq[e].called = !0)
}, k = function(e, t) {
var n = !0;
return m._each(t, function(t) {
m.isEmpty(e[t]) && (m.logError("Tag has missing paramater: " + t), n = !1)
}), n
}, J = function(e) {
var t = ["utUrlEncoded"];
if (k(e, t)) {
var n = decodeURIComponent(e.utUrlEncoded),
a = null,
r = new XMLHttpRequest;
return r.open("GET", n, !1), r.send(null), m.logTimestamp("Ad is requested"), 200 === r.status ? a = r.responseText : m.logError("Error request ut URL"), a
}
}, Y = function(e, t) {
var n = e.data,
a = !0,
r = new XMLHttpRequest;
r.onload = function() {
if (200 === r.status) try {
var e = JSON.parse(r.responseText);
apntag.handleCb(e)
} catch (n) {
m.logError("failed to parse ad response from impbus: " + n.message), u(n.message, t)
} else m.logError(r.status + " : " + r.statusText), u(r.statusText, t)
}, r.onerror = function(n) {
var a = n.target.status,
r = "Error contacting impbus endpoint: " + e.url + " http response code:" + a;
u(r, t)
}, r.open("POST", e.url, a), r.setRequestHeader("Content-Type", "application/json"), r.withCredentials = !0;
try {
r.send(n), apntag.requests.utCalled = !0, F(t)
} catch (o) {
m.logError("Error making POST request: " + o), ve(e, t)
}
}, z = function(e) {
var t = {}, n = [];
m._each(apntag.requests.tags, function(t) {
if (!t.utCalled && t.member === e) {
var a = Z(t);
t.utCalled = !0, n.push(a)
}
}), t.uuid = m.getUUID(), t.member_id = e, m.isEmpty(apntag.requests.targetingParams) || (t.keyval = apntag.requests.targetingParams), m.isEmpty(apntag.requests.user) || (t.user = X()), m.isEmpty(apntag.requests.device) || (t.device = H()), m.isEmpty(apntag.requests.app) || (t.app = V()), m.isEmpty(apntag.requests.site) || (t.site = G()), t.tags = n;
var a = m.getParameterByName(B);
if (a && "" !== a && (apntag.dongle = a), apntag.debug && !m.isEmpty(apntag.dongle)) {
var r = Q(e, apntag.dongle);
t.debug = r
}
return t
}, G = function() {
var e = {}, t = apntag.requests.site;
return m.isEmpty(t) || m.isEmpty(t.id) || (e.id = t.id), e
}, V = function() {
var e = {}, t = apntag.requests.app;
return m.isEmpty(t) || m.isEmpty(t.appid) || (e.appid = t.appid), e
}, H = function() {
var e = {}, t = apntag.requests.device;
return m.isEmpty(t) || (m.isEmpty(t.useragent) || (e.useragent = t.useragent), m.isEmpty(t.geo) || (e.geo = t.geo), m.isEmpty(t.ip) || (e.ip = t.ip), m.isEmpty(t.devicetype) || (e.devicetype = t.devicetype), m.isEmpty(t.make) || (e.make = t.make), m.isEmpty(t.model) || (e.model = t.model), m.isEmpty(t.os) || (e.os = t.os), m.isEmpty(t.os_version) || (e.os_version = t.os_version), m.isEmpty(t.carrier) || (e.carrier = t.carrier), m.isEmpty(t.connectiontype) || (e.connectiontype = t.connectiontype), m.isEmpty(t.mcc) || (e.mcc = t.mcc), m.isEmpty(t.mnc) || (e.mnc = t.mnc), m.isEmpty(t.lmt) || (e.lmt = t.lmt), m.isEmpty(t.device_id) || (e.device_id = t.device_id), m.isEmpty(t.devtime) || (e.devtime = t.devtime)), e
}, X = function() {
var e = {}, t = apntag.requests.user;
return m.isEmpty(t) || (m.isEmpty(t.segments) || (e.segments = t.segments), m.isEmpty(t.age) || (e.age = t.age), m.isEmpty(t.gender) || (e.gender = t.gender), m.isEmpty(t.language) || (e.language = t.language)), e
}, K = function(e) {
var t = [],
n = {};
if (typeof e.sizes === M && 2 === e.sizes.length && typeof e.sizes[0] === h.OBJECT_TYPE.NUMBER) n.width = e.sizes[0], n.height = e.sizes[1], t.push(n);
else if (typeof e.sizes === M)
for (var a = 0; a < e.sizes.length; a++) {
var r = e.sizes[a];
n = {}, n.width = r[0], n.height = r[1], t.push(n)
}
return t
}, Z = function(e) {
var t = {};
e.uuid = m.getUUID();
var n = K(e);
if (m.isEmpty(n) || (t.sizes = n, t.primary_size = n[0]), t.uuid = e.uuid, e.tagId && (t.id = e.tagId), m.isEmpty(e.formats) || (t.formats = e.formats), m.isEmpty(e.position) || (t.position = e.position), e.invCode && (t.code = e.invCode), e.prebid && (t.prebid = e.prebid), e.impId && (t.imp_id = e.impId), e.allowSmallerSizes === !0 ? t.allow_smaller_sizes = !0 : t.allow_smaller_sizes = !1, t.ad_types = e.allowedFormats || [0], !m.isEmpty(e.video)) {
var a = e.video,
r = {};
a.id && (r.id = a.id), m.isEmpty(a.mimes) || (r.mimes = a.mimes), a.maxDuration && (r.maxduration = a.maxDuration), a.minDuration && (r.minduration = a.minDuration), a.startDelay && (r.startdelay = a.startDelay), m.isEmpty(a.skippable.toString()) || (r.skippable = a.skippable), m.isEmpty(a.playbackMethod) || (r.playback_method = a.playbackMethod), m.isEmpty(a.frameworks) || (r.frameworks = a.frameworks), t.video = r
}
if (m.isEmpty(e.rendererOptions) || (t.rendererOptions = e.rendererOptions), !m.isEmpty(e.customKeyValues)) {
var o = [];
m._each(e.customKeyValues, function(e, t) {
var n = {
key: t,
value: e
};
o.push(n)
}), t.custom_key_values = o
}
return t
}, Q = function(e, t) {
var n = {};
return n.enabled = !0, n.member_id = e, n.dongle = t, n.debug_timeout = 1e3, n
}, $ = function(e) {
var t = {}, n = ne();
return t.url = n, t.data = JSON.stringify(e), t
}, ee = function() {
var e = te(),
t = /(webkit)[ \/]([\w.]+)/.exec(e) || /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e) || /(msie) ([\w.]+)/.exec(e) || e.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e) || [];
return t[1]
}, te = function() {
return navigator.userAgent.toLowerCase()
}, ne = function() {
return f + h.ENDPOINT.UT_BASE
}, ae = function(e) {
return h.PREFIX.UT_IFRAME + e.targetId
}, re = function(e) {
return h.PREFIX.UT_DIV + e.targetId
}, oe = function(e) {
var n, a = re(e),
r = t();
return n = r.document.getElementById(a) ? r.document.getElementById(a) : r.document.createElement("div"), n.style.display = "none", n.id = a, n
}, ie = function(e) {
var n, a = ae(e),
r = e.adResponse.ad[P],
o = t();
return n = null !== o.document.getElementById(a) ? o.document.getElementById(a) : o.document.createElement("iframe"), n.id = a, n.name = a, n.setAttribute("height", r.height), n.setAttribute("width", r.width), n.style.width = r.width + "px", n.style.height = r.height + "px", n.border = "0", n.hspace = "0", n.vspace = "0", n.marginWidth = "0", n.marginHeight = "0", n.style.border = "0", n.scrolling = "no", n.frameBorder = "0", n
}, se = function(e, n, a) {
var r = ee(),
o = t().document.getElementById(e.targetId);
o ? (o.appendChild(n), e.utDivId = n.id, e.utiframeId = a.id, r === h.BROWSER_TYPE.IE || r === h.BROWSER_TYPE.OPERA ? pe(a, e, e.targetId) : fe(a, e, e.targetId), m.logMessage("The " + e.targetId + " ad is loaded."), m.logTimestamp("The " + e.targetId + " ad is loaded."), E.emit("adLoaded", e.targetId)) : m.logMessage("No div element found with display ad. Div id: " + e.targetId)
}, de = function(e) {
if (e.debug && (apntag.debug = e.debug), e.size) return void m.logError("Size is deprecated, please use sizes instead.");
if (e.member || (e.member = apntag.requests.member), !e.member) return void m.logError("member id should be defined for targetId: " + e.targetId);
if (!(e.tagId && e.member || e.invCode && e.member)) return void m.logError("tagId & memberId or invCode & memberId should be defined for targetId: " + e.targetId);
try {
var t = e.targetId,
n = ce(e, t);
return m.logMessage("defineTag called for: " + t), apntag.requests && apntag.requests.utCalled === !0 && !apntag.requests.tags[t].utCalled && m.logMessage("A placement was loaded after ut call was started. These ad calls will not be coordinated"), n
} catch (a) {
m.logError("buildAdTagContainer: " + a.message)
}
}, ue = function() {
apntag.requests.utCalled = !1, apntag.requests.hasLeft = !1, m._each(T, function(e) {
for (var n = t().document, a = n.getElementById(e); a.hasChildNodes();) a.removeChild(a.firstChild)
}), m._each(apntag.requests.tags, function(e) {
e.utCalled = !1, e.displayed = !1
});
try {
ge()
} catch (e) {
m.logError("refreshTags " + e.message)
}
}, ge = function() {
m._each(w, function(e, t) {
var n = Number(t);
isNaN(n) ? m.logError("Invalid value for member") : le(n)
})
}, le = function(e) {
var t = z(e),
n = $(t),
a = ee();
m.isEmpty(t.tags) || (a === h.BROWSER_TYPE.IE ? ve(n, e) : Y(n, e))
}, ce = function(e, t) {
var n = e.member;
return apntag.requests = apntag.requests || {}, apntag.requests.tags = apntag.requests.tags || {}, apntag.requests.utCalled = apntag.requests.utCalled || !1, apntag.requests.hasLeft = apntag.requests.hasLeft || !1, apntag.requests.tags[t] = e, apntag.requests.tags[t].utCalled = apntag.requests.tags[t].utCalled || !1, apntag.requests.tags[t].showTagCalled = apntag.requests.tags[t].showTagCalled || !1, apntag.requests.tags[t].displayed = apntag.requests.tags[t].displayed || !1, apntag.requests.tags[t].on = apntag.onEvent || void 0, apntag.requests.tags[t].off = apntag.offEvent || void 0, apntag.requests.tags[t].setSizes = apntag.setSizes || void 0, apntag.requests.tags[t].modifyTag = apntag.modifyTag || void 0, w[n] = typeof w[n] === x ? [] : w[n], w[n].push(e.targetId), I[e.targetId] && (apntag.requests.tags[t].showTagCalled = !0), apntag.requests.tags[t]
}, pe = function(e, t) {
var n = "";
Te(e), n = Ee(t, t.targetId), e.contentWindow.contents = n, e.src = 'javascript:window["contents"];'
}, fe = function(e, t) {
var n = "";
Te(e);
var a = he(e);
n = Ee(t, t.targetId), a.open("text/html", "replace"), a.write(n), a.close(), m.loadPixelUrl(document, e, t.adResponse.ad[C], t.uuid), m.logMessage("Win notification sent for ad tag: " + t.targetId)
}, me = function(e, t) {
var n = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><base target="_top" /><script>inDapIF=true;window.onerror = function(e){ window.parent.apntag.recordErrorEvent(e,"' + t + '"); return true; };</script><body>' + e + '<script>document.body.id = "' + t + '";</script></body></html>';
return n
}, Ee = function(e, t) {
e.adWrap = me(e.adResponse.ad[P][D], t);
var n = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><base target="_top" /><script>inDapIF=true;window.onload = function(){window.onerror = function(e){ window.parent.apntag.recordErrorEvent(e,"' + t + '"); return true; };var tag = window.parent.apntag.getTag("' + t + '");document.open("text/html", "replace");document.write(tag.adWrap);document.close();};</script></head><body></body></html>';
return n
}, he = function(e) {
var t;
try {
t = e.contentWindow ? e.contentWindow.document : e.contentDocument.document ? e.contentDocument.document : e.contentDocument
} catch (n) {
m.logError("Error getting iframe document: " + n)
}
return t
}, ve = function(e, n) {
var a = t(),
r = ye(e),
o = m.loadScript(a, r);
apntag.requests.utCalled = !0, F(n), o.onload = function() {
m.logMessage("JSONP fallback used instead of POST.")
}
}, ye = function(e) {
var t = e.url + (e.url.indexOf("?") + 1 ? "&" : "?") + "cb=apntag.handleCb&q=" + e.data;
return t
}, Te = function(e) {
if (e.contentWindow) try {} catch (n) {
e.src = 'javascript:(function(){document.open(); document.domain = "' + t().document.domain + '";document.close();})();'
}
}, we = function(e) {
apntag.requests.tags = apntag.requests.tags || {};
var t = !0,
n = apntag.requests.tags[e];
return typeof n === x && (t = !1), t
}, be = function() {
apntag.requests.hasLeft = !1, m._each(apntag.requests.tags, function(e, t) {
e.displayed || (m.logError(t + " is not displayed.", h.LOG.WARN), apntag.requests.hasLeft = !0)
}), apntag.requests.hasLeft || m.logMessage("all Tags are displayed.")
}, qe = function(e) {
function t() {
n || (n = !0, e())
}
var n = !1;
if (document.addEventListener) document.addEventListener("DOMContentLoaded", t, !1);
else if (document.attachEvent) {
try {
var a = null !== window.frameElement
} catch (r) {}
if (document.documentElement.doScroll && !a) {
var o = function() {
if (!n) try {
document.documentElement.doScroll("left"), t()
} catch (e) {
setTimeout(o, 10)
}
};
o()
}
document.attachEvent("onreadystatechange", function() {
"complete" === document.readyState && t()
})
}
if (window.addEventListener) window.addEventListener("load", t, !1);
else if (window.attachEvent) window.attachEvent("onload", t);
else {
var i = window.onload;
window.onload = function() {
i && i(), t()
}
}
};
Array.prototype.indexOf || (Array.prototype.indexOf = function(e, t) {
var n;
if (null === this) throw new TypeError('"this" is null or not defined');
var a = Object(this),
r = a.length >>> 0;
if (0 === r) return -1;
var o = +t || 0;
if (Math.abs(o) === 1 / 0 && (o = 0), o >= r) return -1;
for (n = Math.max(o >= 0 ? o : r - Math.abs(o), 0); r > n;) {
if (n in a && a[n] === e) return n;
n++
}
return -1
}), m.logTimestamp("apntag library loaded"), j(), apntag.requests.checkDisplay || qe(be), apn_testonly = {}, apn_testonly.getPageTargetingParams = function() {
return apntag.requests.targetingParams
}, apn_testonly.getEvents = function() {
return E.get()
}, apn_testonly.getEvent = function(e, t) {
var n, a = E.get();
return m._each(a[e], function(e) {
null !== e[t] && void 0 !== e[t] && (n = e[t])
}), n
}
}).call(t, function() {
return this
}())
},
function(e, t, n) {
var a = n(2),
r = "Array",
o = "String",
i = "Function",
s = Object.prototype.hasOwnProperty,
d = !1,
u = a.DEBUG.DEBUG_MODE,
g = a.OBJECT_TYPE.UNDEFINED;
t.addEventHandler = function(e, t, n) {
e.addEventListener ? e.addEventListener(t, n, !0) : e.attachEvent && e.attachEvent("on" + t, n)
}, t.isA = function(e, t) {
return Object.prototype.toString.call(e) === "[object " + t + "]"
}, t.isFn = function(e) {
return this.isA(e, i)
}, t.isStr = function(e) {
return this.isA(e, o)
}, t.isArray = function(e) {
return this.isA(e, r)
}, t.isEmpty = function(e) {
if (!e) return !0;
if (this.isArray(e) || this.isStr(e)) return !(e.length > 0);
for (var t in e)
if (s.call(e, t)) return !1;
return !0
}, t.logMessage = function(e) {
var t = c();
this.debugTurnedOn() && l() && console.log(t + "MESSAGE: " + e)
}, t.logError = function(e, t) {
var n = t || "GENERAL_ERROR",
a = c();
this.debugTurnedOn() && l() && (console.error ? console.error(a + n + ": " + e) : console.log(a + n + ": " + e))
}, t.logTimestamp = function(e) {
this.debugTurnedOn() && l() && console.timeStamp && console.timeStamp(e)
}, t.loadScript = function(e, t, n) {
var a = e.document,
r = a.createElement("script");
r.type = "text/javascript", r.async = !0, n && "function" == typeof n && (r.readyState ? r.onreadystatechange = function() {
("loaded" === r.readyState || "complete" === r.readyState) && (r.onreadystatechange = null, n())
} : r.onload = function() {
n()
}), r.src = t;
var o = a.getElementsByTagName("head");
return o = o.length ? o : a.getElementsByTagName("body"), o.length && (o = o[0], o.insertBefore(r, o.firstChild)), r
}, t.getUUID = function() {
var e = (new Date).getTime(),
t = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(t) {
var n = (e + 16 * Math.random()) % 16 | 0;
return e = Math.floor(e / 16), ("x" === t ? n : 3 & n | 8).toString(16)
});
return t
}, t.loadPixelUrl = function(e, t, n, a) {
var r;
if (e && t && n) {
r = new Image, r.id = a, r.src = n, r.height = 0, r.width = 0, r.style.display = "none", r.onload = function() {
try {
this.parentNode.removeChild(this)
} catch (e) {}
};
try {
t.insertBefore(r, t.firstChild)
} catch (o) {
this.logError("Error logging impression for tag: " + a + " :" + o.message)
}
}
}, t._each = function(e, t) {
if (!this.isEmpty(e)) {
if (this.isFn(e.forEach)) return e.forEach(t);
var n = 0,
a = e.length;
if (a > 0)
for (; a > n; n++) t(e[n], n, e);
else
for (n in e) s.call(e, n) && t(e[n], n, e)
}
}, t.contains = function(e, t) {
if (this.isEmpty(e)) return !1;
for (var n = e.length; n--;)
if (e[n] === t) return !0;
return !1
};
var l = function() {
return window.console && window.console.log
};
t.debugTurnedOn = function() {
return apntag.debug === !1 && d === !1 && (apntag.debug = "TRUE" === this.getParameterByName(u).toUpperCase(), d = !0), apntag.debug ? !0 : !1
}, t.stringContains = function(e, t) {
return -1 != e.indexOf(t)
}, t.getParameterByName = function(e) {
var t = "[\\?&]" + e + "=([^&#]*)",
n = new RegExp(t),
a = n.exec(window.location.search);
return null === a ? "" : decodeURIComponent(a[1].replace(/\+/g, " "))
}, t.hasOwn = function(e, t) {
return e.hasOwnProperty ? e.hasOwnProperty(t) : typeof e[t] !== g && e.constructor.prototype[t] !== e[t]
};
var c = function() {
var e = new Date,
t = "[" + e.getHours() + ":" + e.getMinutes() + ":" + e.getSeconds() + ":" + e.getMilliseconds() + "] ";
return t
}
},
function(e, t) {
e.exports = {
PREFIX: {
UT_IFRAME: "utif_",
UT_DIV: "div_utif_"
},
LOG: {
WARN: "WARN"
},
DEBUG: {
DEBUG_MODE: "ast_debug",
AST_DONGLE: "ast_dongle"
},
OBJECT_TYPE: {
UNDEFINED: "undefined",
OBJECT: "object",
STRING: "string",
NUMBER: "number"
},
BROWSER_TYPE: {
IE: "msie",
OPERA: "opera"
},
RENDERER_EVENTS: {
LOADED: "loaded",
IMPRESSION: "impression"
},
ENDPOINT: {
UT_BASE: "/ut",
IMPBUS: "ib.adnxs.com"
},
UT_RESPONSE_PROP: {
MEDIA_TYPE: "media_type",
CREATIVE_ID: "creative_id",
AD_TYPE: "ad_type",
BANNER: "banner",
CONTENT: "content",
UUID: "uuid"
},
MEDIA_TYPE: {
BANNER: "banner",
NATIVE: "native",
VIDEO: "video"
},
AD: {
CREATIVE_ID: "creative_id",
NOTIFY: "notify_url"
},
AD_TYPE: {
BANNER: "banner",
NATIVE: "native",
VIDEO: "video"
}
}
},
function(e, t, n) {
var a = n(1),
r = Array.prototype.slice,
o = ["adRequested", "adAvailable", "adLoaded", "adRequestFailure", "adNoBid", "adDefault", "adError", "adCollapse"];
e.exports = function() {
function e(e, t) {
var r = t[0],
o = t[1];
a.logMessage("Emitting event for: " + e + " for ad tag: " + r), a._each(n[e], function(e) {
var t = e[r];
return null !== t && void 0 !== t && "function" == typeof t ? void t.call(null, o) : void 0
})
}
function t(e) {
return a.contains(o, e)
}
var n = {}, i = {};
return i.on = function(e, r, i) {
if (t(e)) {
var s = {};
s[r] = i, n[e] = n[e] || [], n[e].push(s)
} else a.logError("Wrong event name : " + e + " Valid event names :" + o)
}, i.emit = function(t) {
var n = r.call(arguments, 1);
e(t, n)
}, i.off = function(e, t, r) {
a.isEmpty(n[e]) || a._each(n[e], function(e) {
null !== e[t] && void 0 !== e[t] && ("undefined" == typeof r || e[t] === r) && (e[t] = null)
})
}, i.get = function() {
return n
}, i
}()
},
function(e, t) {
"object" != typeof JSON && (JSON = {}),
function() {
"use strict";
function e(e) {
return 10 > e ? "0" + e : e
}
function t() {
return this.valueOf()
}
function n(e) {
return r.lastIndex = 0, r.test(e) ? '"' + e.replace(r, function(e) {
var t = s[e];
return "string" == typeof t ? t : "\\u" + ("0000" + e.charCodeAt(0).toString(16)).slice(-4)
}) + '"' : '"' + e + '"'
}
function a(e, t) {
var r, s, u, g, l, c = o,
p = t[e];
switch (p && "object" == typeof p && "function" == typeof p.toJSON && (p = p.toJSON(e)), "function" == typeof d && (p = d.call(t, e, p)), typeof p) {
case "string":
return n(p);
case "number":
return isFinite(p) ? String(p) : "null";
case "boolean":
case "null":
return String(p);
case "object":
if (!p) return "null";
if (o += i, l = [], "[object Array]" === Object.prototype.toString.apply(p)) {
for (g = p.length, r = 0; g > r; r += 1) l[r] = a(r, p) || "null";
return u = 0 === l.length ? "[]" : o ? "[\n" + o + l.join(",\n" + o) + "\n" + c + "]" : "[" + l.join(",") + "]", o = c, u
}
if (d && "object" == typeof d)
for (g = d.length, r = 0; g > r; r += 1) "string" == typeof d[r] && (s = d[r], u = a(s, p), u && l.push(n(s) + (o ? ": " : ":") + u));
else
for (s in p) Object.prototype.hasOwnProperty.call(p, s) && (u = a(s, p), u && l.push(n(s) + (o ? ": " : ":") + u));
return u = 0 === l.length ? "{}" : o ? "{\n" + o + l.join(",\n" + o) + "\n" + c + "}" : "{" + l.join(",") + "}", o = c, u
}
}
var r = /[\\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
"function" != typeof Date.prototype.toJSON && (Date.prototype.toJSON = function() {
return isFinite(this.valueOf()) ? this.getUTCFullYear() + "-" + e(this.getUTCMonth() + 1) + "-" + e(this.getUTCDate()) + "T" + e(this.getUTCHours()) + ":" + e(this.getUTCMinutes()) + ":" + e(this.getUTCSeconds()) + "Z" : null
}, Boolean.prototype.toJSON = t, Number.prototype.toJSON = t, String.prototype.toJSON = t);
var o, i, s, d;
"function" != typeof JSON.stringify && (s = {
"\b": "\\b",
" ": "\\t",
"\n": "\\n",
"\f": "\\f",
"\r": "\\r",
'"': '\\"',
"\\": "\\\\"
}, JSON.stringify = function(e, t, n) {
var r;
if (o = "", i = "", "number" == typeof n)
for (r = 0; n > r; r += 1) i += " ";
else "string" == typeof n && (i = n); if (d = t, t && "function" != typeof t && ("object" != typeof t || "number" != typeof t.length)) throw new Error("JSON.stringify");
return a("", {
"": e
})
})
}()
}
]);
AppNexus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment