MCPcopy Create free account
hub / github.com/ampproject/amphtml / ix

Function ix

ads/vendors/ix.js:17–62  ·  view source on GitHub ↗
(global, data)

Source from the content-addressed store, hash-verified

15 * @param {!Object} data
16 */
17export function ix(global, data) {
18 if (!('slot' in data)) {
19 global.CasaleArgs = data;
20 writeScript(global, 'https://js-sec.indexww.com/indexJTag.js');
21 } else {
22 //DFP ad request call
23
24 const start = Date.now();
25 let calledDoubleclick = false;
26 data.ixTimeout = isNaN(data.ixTimeout) ? DEFAULT_TIMEOUT : data.ixTimeout;
27 const timer = setTimeout(() => {
28 callDoubleclick(EVENT_TIMEOUT);
29 }, data.ixTimeout);
30
31 const callDoubleclick = function (code) {
32 if (calledDoubleclick) {
33 return;
34 }
35 calledDoubleclick = true;
36 clearTimeout(timer);
37 reportStats(data.ixId, data.ixSlot, data.slot, start, code);
38 prepareData(data);
39 doubleclick(global, data);
40 };
41
42 if (typeof data.ixId === 'undefined' || isNaN(data.ixId)) {
43 callDoubleclick(EVENT_BADTAG);
44 return;
45 }
46
47 global.IndexArgs = {
48 ampCallback: callDoubleclick,
49 ampSuccess: EVENT_SUCCESS,
50 ampError: EVENT_ERROR,
51 };
52
53 loadScript(
54 global,
55 'https://js-sec.indexww.com/apl/amp.js',
56 undefined,
57 () => {
58 callDoubleclick(EVENT_ERROR);
59 }
60 );
61 }
62}
63
64/**
65 * @param {!Object} data

Callers

nothing calls this directly

Calls 4

writeScriptFunction · 0.90
loadScriptFunction · 0.90
nowMethod · 0.80
callDoubleclickFunction · 0.70

Tested by

no test coverage detected