// polyfill
if (('forEach' in window.NodeList.prototype) === false)
NodeList.prototype.forEach = Array.prototype.forEach;
var onmeda_ads = {};
onmeda_ads.get_window_dimension = function () {
var w = top.window,
d = top.document,
e = d.documentElement,
g = d.getElementsByTagName('body')[0],
x = w.innerWidth || e.clientWidth || g.clientWidth,
y = w.innerHeight|| e.clientHeight|| g.clientHeight;
return {width: x, height: y};
};
onmeda_ads.get_window_width = function () {
return onmeda_ads.get_window_dimension().width;
};
onmeda_ads.get_window_height = function () {
return onmeda_ads.get_window_dimension().height;
};
// returns the previous sibling that is not a textnode..
onmeda_ads.getPreviousSibling = function(node) {
var new_node = node.previousSibling;
while(new_node && new_node.nodeName === '#text') {
new_node = new_node.previousSibling;
}
return new_node;
};
window.addEventListener('message', function (evt) {
//if (evt.origin !== 'http://ygg.li') return;
switch (evt.data) {
case 'dfp_noAd':
var ifrs = document.querySelectorAll('iframe');
var ifrCb = function(ifr) {
if (ifr.contentWindow === evt.source) {
var ad_label = onmeda_ads.getPreviousSibling(
onmeda_ads.getPreviousSibling(ifr.parentNode.parentNode)
);
// safety-net, because I'm afraid I might break something..
if (ad_label &&
ad_label.classList &&
ad_label.classList.contains('ad__label'))
ad_label.style.display = 'none';
return true;
}
};
ifrs.forEach(ifrCb);
break;
case 'sprout_sponsored_init':
window.addEventListener('load', function() {
window.sprout.core.sponsored.init();
}, false);
break;
}
}, false);
// jshint ignore:start
if (document.compatMode == "BackCompat" && navigator.userAgent.indexOf("MSIE") != -1) {
document.write('');
} else {
document.write('');
}
// jshint ignore:end
function sdibgclick(sdibgclickurl){
var div = document.createElement('div');
div.id = 'background-click-layer';
if (document.body.firstChild) {
document.body.insertBefore(div, document.body.firstChild);
} else {
document.body.appendChild(div);
}
document.getElementById('background-click-layer').innerHTML += '';
}