/*! Script NoBeta http://nobeta.com.br (r) */
var nbt_cl_css = "color: darkslategray; background-color: sandybrown; padding:1px 3px; border-radius: 3px; margin-right: 7px";
console.log('%cnobeta%c formats alert', nbt_cl_css, '');
if (typeof (_nbtframeads) == "undefined") {
var _nbtframeads = {
isDebug: false,
_frame_intercontent: null,
d: function(value){
if( this.isDebug )
console.log("%cnobeta%c " + value, nbt_cl_css, '')
},
src_alert: 'ALERT TEMPLATE | NOBETA',
getSize: function(){
return {
largura : window.innerWidth,
altura : window.innerHeight
}
},
setCookie: function(name, hours, imps){
var now = new Date();
var time = now.getTime();
var expireTime = time + (60000*(60*hours));
console.log(now);
now.setTime(expireTime);
console.log(now);
document.cookie = name+'='+imps+';expires='+now.toGMTString()+';path=/';
},
setFrame : function(framename, src, csstxt, target = null){
if( document.getElementById(framename) != undefined ){
this.d('skipped');
return;
}
if(!target){
target = document.getElementsByTagName('body')[0];
}
var iframe = document.createElement('iframe');
iframe.id=framename;
iframe.scrolling="no";
(iframe.frameElement || iframe).style.cssText = csstxt;
iframe.src = "javascript:false";
var where = target;
where.appendChild( iframe );
var doc = iframe.contentWindow.document;
doc.open().write( src );
doc.close();
return iframe;
},
info: function(){
var protocol = window.location.protocol;
var uri = window.location.href;
uri = encodeURIComponent(uri.replace(protocol + "//", ''));
var px = document.createElement('img');
px.src = '//api.nobeta.com.br/trackpage&u=' + uri;
px.style.display = 'none';
document.body.appendChild(px);
},
listenerMessages: function(){
this.d('listener set');
var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
var eventer = window[eventMethod];
var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";
eventer(messageEvent,function(e) {
var key = e.message ? "message" : "data";
var data = e[key];
if(data.nbtalertsize != undefined){
console.log(data.nbtalertsize);
document.getElementById('_nbtads_alert').style.width = data.nbtalertsize [0] + "px";
document.getElementById('_nbtads_alert').style.height = (data.nbtalertsize [1] + 45) + "px";
}
if(data == "nbtalertclick"){
setTimeout( function(){
document.getElementById("_nbtads_alert").style.display="none";
},1000);
}
if( data.nbtsignal ){
if( typeof _nbtframeads.setIntercontentAds !== "undefined" )
_nbtframeads.setIntercontentAds();
}
if( data.nbtalert_signal ){
if( typeof _nbtframeads.setAlertAds !== "undefined" )
_nbtframeads.setAlertAds();
}
},false);
},
setAlertAds : function(idx = ""){
var csstxt = "width:470px; height:290px; position: fixed; right :0px; top: 70px ; border:none; z-index:2147483645";
this.setFrame("_nbtads_alert"+idx, this.src_alert, csstxt);
}, adInit: function(){
_nbtframeads.setAlertAds();
},
init: function(){
this.d('nbtframeads init');
this.listenerMessages();
if (document.readyState === 'complete' || document.readyState === 'interactive'){
_nbtframeads.adInit();
console.log('%cnobeta%c nb initialize ad', nbt_cl_css, '');
}else{
document.addEventListener("DOMContentLoaded", function() {
_nbtframeads.adInit(),
console.log('%cnobeta%c nb initialize ad onloaded', nbt_cl_css, '');
});
}
}
}
_nbtframeads.init();
}