-
Notifications
You must be signed in to change notification settings - Fork 0
/
idg.js
205 lines (173 loc) · 14 KB
/
idg.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
var IDGdfpAds = {};
googletag.cmd.push(function() {
var pubads = googletag.pubads();
IDGdfpAds['ad_layer'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[1, 1], [640, 480]], 'ad_layer').setTargeting('NL_Position','ad_layer').addService(googletag.pubads());
if (Modernizr.mq('only screen and (min-width:1700px)')) {
IDGdfpAds['ad_billboard'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[2,2], [728, 90], [970, 250]], 'ad_billboard').setTargeting('NL_Position','ad_billboard').addService(googletag.pubads());
IDGdfpAds['ad_skyscraper'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[120, 600], [160, 600]], 'ad_skyscraper').setTargeting('NL_Position','ad_skyscraper').addService(googletag.pubads());
IDGdfpAds['ad_adv1'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[555, 112],[555,125]], 'ad_adv1').setTargeting('NL_Position','ad_adv1').addService(googletag.pubads());
IDGdfpAds['ad_in_page_video'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[545,306],[2,1]], 'ad_in_page_video').setTargeting('NL_Position','ad_in_page_video').addService(googletag.pubads());
IDGdfpAds['ad_mpu'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[120, 600], [160, 600], [300,250], [300, 600]], 'ad_mpu').setTargeting('NL_Position','ad_mpu').addService(googletag.pubads());
IDGdfpAds['ad_interscroller'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[970, 252]], 'ad_interscroller').setTargeting('NL_Position','ad_interscroller').addService(googletag.pubads());
IDGdfpAds['ad_leaderboard-bottom'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[728, 90]], 'ad_leaderboard-bottom').setTargeting('NL_Position','ad_leaderboard-bottom').addService(googletag.pubads());
IDGdfpAds['ad_skin-left'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[160, 1200]], 'ad_skin-left').setTargeting('NL_Position','ad_skin-left').addService(googletag.pubads());
IDGdfpAds['ad_skin-right'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[160, 1201]], 'ad_skin-right').setTargeting('NL_Position','ad_skin-right').addService(googletag.pubads());
IDGdfpAds['ad_leaderboard-top'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[728, 90],[1800, 1000]], 'ad_leaderboard-top').setTargeting('NL_Position','ad_leaderboard-top').addService(googletag.pubads());
} else if (Modernizr.mq('only screen and (min-width:1241px)')) {
IDGdfpAds['ad_billboard'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[2,2], [728, 90], [970, 250]], 'ad_billboard').setTargeting('NL_Position','ad_billboard').addService(googletag.pubads());
IDGdfpAds['ad_adv1'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[555, 112],[555,125]], 'ad_adv1').setTargeting('NL_Position','ad_adv1').addService(googletag.pubads());
IDGdfpAds['ad_in_page_video'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[545,306],[2,1]], 'ad_in_page_video').setTargeting('NL_Position','ad_in_page_video').addService(googletag.pubads());
IDGdfpAds['ad_mpu'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[120, 600], [160, 600], [300,250], [300, 600]], 'ad_mpu').setTargeting('NL_Position','ad_mpu').addService(googletag.pubads());
IDGdfpAds['ad_interscroller'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[970, 252]], 'ad_interscroller').setTargeting('NL_Position','ad_interscroller').addService(googletag.pubads());
IDGdfpAds['ad_leaderboard-bottom'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[728, 90]], 'ad_leaderboard-bottom').setTargeting('NL_Position','ad_leaderboard-bottom').addService(googletag.pubads());
IDGdfpAds['ad_skin-left'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[160, 1200]], 'ad_skin-left').setTargeting('NL_Position','ad_skin-left').addService(googletag.pubads());
IDGdfpAds['ad_skin-right'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[160, 1201]], 'ad_skin-right').setTargeting('NL_Position','ad_skin-right').addService(googletag.pubads());
IDGdfpAds['ad_leaderboard-top'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[728, 90],[1800, 1000]], 'ad_leaderboard-top').setTargeting('NL_Position','ad_leaderboard-top').addService(googletag.pubads());
} else if (Modernizr.mq('only screen and (min-width:1000px)')) {
IDGdfpAds['ad_billboard'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[2,2], [728, 90], [970, 250]], 'ad_billboard').setTargeting('NL_Position','ad_billboard').addService(googletag.pubads());
IDGdfpAds['ad_adv1'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[555, 112],[555,125]], 'ad_adv1').setTargeting('NL_Position','ad_adv1').addService(googletag.pubads());
IDGdfpAds['ad_in_page_video'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[545,306],[2,1]], 'ad_in_page_video').setTargeting('NL_Position','ad_in_page_video').addService(googletag.pubads());
IDGdfpAds['ad_mpu'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[120, 600], [160, 600], [300,250], [300, 600]], 'ad_mpu').setTargeting('NL_Position','ad_mpu').addService(googletag.pubads());
IDGdfpAds['ad_interscroller'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[970, 252]], 'ad_interscroller').setTargeting('NL_Position','ad_interscroller').addService(googletag.pubads());
IDGdfpAds['ad_leaderboard-bottom'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[728, 90]], 'ad_leaderboard-bottom').setTargeting('NL_Position','ad_leaderboard-bottom').addService(googletag.pubads());
IDGdfpAds['ad_skin-left'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[160, 1200]], 'ad_skin-left').setTargeting('NL_Position','ad_skin-left').addService(googletag.pubads());
IDGdfpAds['ad_skin-right'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[160, 1201]], 'ad_skin-right').setTargeting('NL_Position','ad_skin-right').addService(googletag.pubads());
} else if (Modernizr.mq('only screen and (min-width:780px)')) {
IDGdfpAds['ad_mpu-mob'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[300, 250], [300, 600]], 'ad_mpu-mob').setTargeting('NL_Position','ad_mpu-mob').addService(googletag.pubads());
} else if (Modernizr.mq('only screen and (min-width:500px)')) {
IDGdfpAds['ad_mpu-mob'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[300, 250], [300, 600]], 'ad_mpu-mob').setTargeting('NL_Position','ad_mpu-mob').addService(googletag.pubads());
} else if (Modernizr.mq('only screen and (max-width:499px)')) {
IDGdfpAds['ad_mpu-mob'] = googletag.defineSlot('/8456/IDG.NL_B2B_WebWereld.nl/homepage_door',[[300, 250], [300, 600]], 'ad_mpu-mob').setTargeting('NL_Position','ad_mpu-mob').addService(googletag.pubads());
}
})
function loadPersonalizedDfp() {
fob.dfp = {}
$.ajax('/ajax/dfp-user-data?hash=' + getParameterByName('hash'), {
cache : false,
dataType : 'json',
success: function(data, text, xhr) {
fob.dfp = {
data : data.data,
hash : data.hash,
};
},
complete : function() {
googletag.cmd.push(function() {
var pubads = googletag.pubads();
pubads.collapseEmptyDivs(true);
pubads.addEventListener('slotRenderEnded', function(e) {
if ($('#ad_mpu div').height() >= 600) {
$('#one #right').addClass('large-ad');
}
if ($('.article-list-simple .advertorial').height() != 0) {
$('.article-list-simple .advertorial').addClass('active');
}
});
if (fob.dfp.data && typeof fob.dfp.data === 'object') {
Object.keys(fob.dfp.data).forEach(function(k) {
googletag.pubads().setTargeting(k, fob.dfp.data[k]);
});
}
console.log('Googletag services enabled');
// defineAdUnits is a function defined by Adhese when this script has been loaded
typeof defineAdUnits === 'function' ? defineAdUnits() : googletag.pubads().refresh();
});
},
error : function(...args) {
console.log(args);
console.log('An error occurred while trying to set DFP user data');
}
});
}
// Consent Management
window.admiral = window.admiral || function() {(admiral.q = admiral.q || []).push(arguments)};
var debug = false;
window.idgnl = window.idgnl || {};
window.idgnl.cmp = (function() {
var debug = false;
var PERSONALIZATION_PURPOSE_ID = 2;
var checkIfInEU = new Promise(function(resolve, reject) {
var promiseResolved = false;
setTimeout(function() {
if(debug) { console.log('GDPR checkIfInEU timeout reached promiseResolved', promiseResolved); }
if (!promiseResolved) {
promiseResolved=true;
resolve(); // effectively in eu (most conservative)
}
}, 10000);
window.admiral('after', 'cmp.loaded', function(e) {
if (promiseResolved) { return; }
promiseResolved = true;
if (debug) { console.log('GDPR checkIfInEU - cmp.loaded', e); }
var isEuVisitor = e.euVisitor || false;
if (isEuVisitor) { resolve(); }
else { reject(); }
});
});
// util to check for 1 purpose or 1 vendor in consent data structure
var checkConsentData = function(ConsentData, purposeId, vendorId){
var _ConsentData = {standardPurposes:{}}; // normalise due to different naming conventions
if ('standardPurposes' in ConsentData) { // prefer standardPurposes as defined on PublisherConsents which is not global and does not return early
_ConsentData.standardPurposes = ConsentData.standardPurposes
} else if('purposeConsents' in ConsentData) { //comes from Vendor Consents
_ConsentData.standardPurposes = ConsentData.purposeConsents
}
_ConsentData.vendorConsents = ConsentData.vendorConsents || {}; //comes from VendorConsents
_ConsentData.customPurposes = ConsentData.customPurposes || {}; //comes from PublisherConsents
if (debug) { console.log('GDPR', 'checkConsentData', 'purposeId', purposeId, 'vendorId', vendorId, _ConsentData); }
if (typeof vendorId !== 'undefined'){
if (vendorId in _ConsentData.vendorConsents && _ConsentData.vendorConsents[''+vendorId]){
return true;
}
//vendor id match is wanted but is false or not defined
return false;
}
if (typeof purposeId !== 'undefined' && purposeId !== null){
if( (purposeId in _ConsentData.standardPurposes && _ConsentData.standardPurposes[''+purposeId]) ||
(purposeId in _ConsentData.customPurposes && _ConsentData.customPurposes[''+purposeId])
) {
return true;
}
}
if (debug) { console.log('GDPR','checkConsentData',false); }
return false;
};
//util create promise for cmp for a purposeid
var checkCMPForPurposeConsent = function(purposeId) {
return new Promise(function (resolve, reject) {
checkIfInEU.then(function() {
__cmp('getPublisherConsents', [], function(PublisherConsents, success){
if (debug) {
console.log('GDPR',' checkCMPForPurposeConsent - PublisherConsents ','purposeId', purposeId, 'PublisherConsents=' ,PublisherConsents, 'success=', success);
}
resolve(checkConsentData(PublisherConsents,purposeId));
});
}).catch(function(){
resolve(true);
});
});
};
return {
isDebug : function() { return debug; },
adsense : checkCMPForPurposeConsent(PERSONALIZATION_PURPOSE_ID),
gpt : checkCMPForPurposeConsent(PERSONALIZATION_PURPOSE_ID)
};
})();
googletag.cmd = googletag.cmd || [];
if (window.idgnl.cmp) {
if (debug) { console.log('GDPR','gpt.js delayed loading'); }
window.idgnl.cmp.gpt.then( function(hasConsent) {
googletag.enableServices();
if (hasConsent) {
loadPersonalizedDfp();
} else {
googletag.cmd.unshift(function() {
if (debug) { console.log('GDPR','setRequestNonPersonalizedAds set'); }
googletag.pubads().setRequestNonPersonalizedAds(1);
googletag.pubads().refresh();
});
}
});
} else {
if (debug) { console.log('GDPR','gpt.js delayed loading skipped'); }
}