Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* V5 (CPALead) - 19/12/2016 */
- var CualD = VerCualDisp();
- var viewport = document.querySelector('meta[name="viewport"]');
- var meta = document.createElement('meta');
- var html = document.getElementsByTagName('html')[0];
- var cantidadI = DameCookie("nopINTER");
- if(cantidadI<0) cantidadI = 0;
- var MaxI = 12;
- var QueMostrar = "ALL";
- var cuantasEntro = 0;
- function CargarInter(a,b,c,d){
- SacarScroll(true);
- cantidadI++
- MeterCookie(cantidadI);
- var css = "<link rel=\"stylesheet\" type=\"text/css\" href=\"https://fonts.googleapis.com/css?family=Open+Sans\" /><style>.barrita{background-color:#eeeeee;height:25px;text-align:right;width:100%;position:absolute;top:0px;left:0px;z-index:2147483647;}.barrita a{font-family:'Open Sans';font-size:13px;padding:5px;text-decoration:none;color:#000}.fondo{z-index:147483600;position:fixed;background-color:#000;top:0px;left:0px;width:100%;height:100%;opacity:0.5;filter:alpha(opacity=50)}.alerta{width: 100%;height: 100%;position: fixed;top: 0px;left: 0px;z-index: 2147483640;font-family:'Open Sans',Verdana;}.clase0{z-index:2147483640;border-radius:3px;background:#eeeeee;width:90%;margin:auto;position:absolute;left:0;right:0;top:30%;border:1px solid #fff}.clase0 img{width:30px;height:30px;border-radius:5px;margin:4px 0px 0px 5%;float:left}.clase0 header{font-weight:bold;color:#3c3c3c;padding:10px 0px 0px 5%}.clase0 article{font-weight:500;margin:4px 5% 0px 5%;font-size:14px;color:#3c3c3c}.clase0 footer{float:left;width:100%;text-align:right;margin-bottom:10px;margin-left:-10px}.clase0 footer .boton{font-size:14px;color:#009688;font-weight:bold;margin:2%}.clase0 .nombreAPP{font-size:14px;float:left;font-weight:bold;color:#3c3c3c;margin:10px 0px 0px 1%;padding:0px}@media only screen and (min-width: 768px){.clase0 footer{margin-bottom:10px;margin-left:0px}}.clase1{z-index:2147483640;border-radius:8px;background:#e6e6e6;width:90%;margin:auto;position:absolute;left:0;right:0;top:30%;border:1px solid #fff}.clase1 img{width:30px;height:30px;border-radius:5px;margin:4px 0px 8px 5%;vertical-align:middle}.clase1 header{font-weight:bold;color:#4f4f4f;width:100%;text-align:center;padding-top:10px}.clase1 article{width:100%;text-align:center;font-size:14px;color:#3c3c3c}.clase1 footer{margin-bottom:10px;width:100%;text-align:center;border-top:solid 1px #dcdcdc}.clase1 footer .boton{font-size:14px;color:#6dacf3;font-weight:bold;padding:15px}.clase1 .nombreAPP{font-size:14px;font-weight:bold;color:#3c3c3c}@media only screen and (min-width: 768px){.clase1 footer{margin-bottom:10px;margin-left:0px}}</style>";
- var info = "<div class=\"barrita\"><a href=\"javascript:void(0);\" onclick=\"CerrarX();\">x</a></div><div class=\"alerta\"> <div class=\"clase0\"> <header>Alerta</header> <article>Para ver el contenido es necesario instalar esta aplicacion</article> <img src=\""+c+"\"> <span class=\"nombreAPP\">"+b+"</span> <footer><span class=\"boton\">OK</span></footer> </div></div><div class=\"fondo\"></div>";
- if(document.body != null){
- document.body.innerHTML += css + info;
- if(CualD=="1"){
- document.getElementsByClassName("clase0")[0].className = "clase1";
- };
- document.getElementsByClassName("alerta")[0].addEventListener('click', function () {
- CerrarX();
- MeterCookie(1000);
- if(d){ CerrarX(); window.open(a,'_blank'); }else{ top.location.href = a; }
- }, false);
- }else{
- if(cuantasEntro<=2){
- cuantasEntro++;
- console.log('Entro con el timer ' + cuantasEntro);
- setTimeout(function(){ CargarInter(a,b,c); }, 3000);
- }
- };
- };
- function CerrarX(){
- SacarScroll(false);
- document.getElementsByClassName("fondo")[0].style.display = "none";
- document.getElementsByClassName("alerta")[0].style.display = "none";
- document.getElementsByClassName("barrita")[0].style.display = "none";
- };
- function SacarScroll(n) {
- if (n) {
- html.style['overflow'] = 'hidden';
- html.style['width'] = '100%';
- html.style['height'] = '100%';
- html.style['max-height'] = '100%';
- html.style['position'] = 'fixed';
- html.style['top'] = '0';
- html.style['left'] = '0';
- } else {
- html.style['overflow'] = 'initial';
- html.style['height'] = 'auto';
- html.style['width'] = 'auto';
- html.style['position'] = 'static';
- html.style['max-height'] = 'initial';
- };
- };
- function DameCookie(cname) {
- var name = cname + "=";
- var ca = document.cookie.split(';');
- for(var i = 0; i <ca.length; i++) {
- var c = ca[i];
- while (c.charAt(0)==' ') {
- c = c.substring(1);
- };
- if (c.indexOf(name) == 0) {
- return c.substring(name.length,c.length);
- };
- };
- return "";
- };
- function setVP() {
- meta.name = 'viewport';
- meta.content = 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no';
- if (viewport) {
- viewport.parentNode.removeChild(viewport);
- };
- document.head.appendChild(meta);
- };
- function MeterCookie(cantidad){
- var cad = new Date();
- cad['setTime'](cad['getTime']() + (24 * 60 * 60 * 1000));
- var expira = '; expires=' + cad['toGMTString']();
- document.cookie = 'nopINTER=' + cantidad + expira + ';path=/';
- };
- function loadJSON() {
- var ID_USER = "ACA_ID_CPALEAD";
- var script = document.createElement('script');
- script.src = "https://www.cpalead.com/dashboard/reports/campaign_json_load_offers.php?id="+ID_USER+"&format=json&geoip=user&show=10&offer_type=mobile&ua=user&format=JSONP&callback=SacarDatos";
- document.getElementsByTagName('head')[0].appendChild(script);
- };
- function VerCualDisp(){
- var t=navigator.userAgent||navigator.vendor||window.opera;
- var cual = t.match(/Opera Mini/i)||t.match(/Windows/i)?"unknown":t.match(/iPad/i)||t.match(/iPhone/i)||t.match(/iPod/i)||t.match(/iOS/i)?"iOS":t.match(/Android/i)?"Android":"unknown";
- if(cual=="iOS") return "ios";
- if(cual=="Android") return "android";
- return 3;
- };
- var CantidadVueltas = 0;
- function SacarDatos(data){
- CantidadVueltas++;
- if(CantidadVueltas>3) return;
- var popono = false;
- var imgicon = "http://icons.iconarchive.com/icons/custom-icon-design/flatastic-1/64/alert-icon.png";
- var titulo = "";
- var jsonObj = data;
- if (jsonObj.offers.length > 0) {
- var entry = jsonObj.offers[Math.floor(Math.random() * jsonObj.offers.length)];
- console.log("entry.mobile_app_type = " + entry.mobile_app_type);
- if(QueMostrar=="CPI"){
- if(VerCualDisp() != entry.mobile_app_type){ SacarDatos(data); };
- }else{
- if(entry.mobile_app_type != null){ if(VerCualDisp() != entry.mobile_app_type){ SacarDatos(data); }; };
- };
- if(entry.mobile_app_type != null){ popono = false; }else{ popono = true; }
- setVP();
- if(entry.mobile_app_icon_url != null) imgicon = entry.mobile_app_icon_url;
- titulo = entry.title.split("-");
- if(titulo[0] != null){ titulo = titulo[0]; }else{ titulo = entry.title; };
- CargarInter(entry.link,titulo,imgicon,popono);
- };
- };
- document.addEventListener('DOMContentLoaded', function () {
- if(CualD!=3 && cantidadI<=MaxI){
- loadJSON();
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment