cicklow

Banner - ForoBeta

Dec 19th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     /* V1 - 19/12/2016 */
  2.     'use strict';
  3.  
  4.     var _fixed  = true;
  5.     var _tipo   = 1; /* 1=300x50 | 2=300x250 */
  6.  
  7.     var container   = document.createElement('div');
  8.     var imagen  = document.createElement('img');
  9.     var texto   = document.createElement('h1');
  10.     var descri  = document.createElement('div');
  11.     var boton   = document.createElement('div');
  12.     var html    = document.getElementsByTagName('html')[0];
  13.     var viewport    = document.querySelector('meta[name="viewport"]');
  14.     var meta    = document.createElement('meta');
  15.  
  16.     var iOS_ID = "ACA_ID_IOS";
  17.     var Android_ID = "ACA_ID_ANDROID";
  18.  
  19.     var __URL;
  20.     var __TXT;
  21.     var __IMG;
  22.     var __LNK;
  23.     var __DES;
  24.     var __PIX;
  25.  
  26.     function VerCualDisp(){
  27.         var t=navigator.userAgent||navigator.vendor||window.opera;
  28.         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";
  29.  
  30.         if(cual=="iOS") return iOS_ID;
  31.         if(cual=="Android") return Android_ID;
  32.  
  33.         return "no";
  34.     };
  35.  
  36.     function loadJSON() {
  37.         var data_file = "https://admin.appnext.com/offerWallApi.aspx?pimp=1&tid=API&id="+VerCualDisp()+"&cnt=10";
  38.         var http_request = new XMLHttpRequest();
  39.         try {
  40.             http_request = new XMLHttpRequest();
  41.         } catch (e) {
  42.             try {
  43.                 http_request = new ActiveXObject("Msxml2.XMLHTTP");
  44.             } catch (e) {
  45.                 try {
  46.                     http_request = new ActiveXObject("Microsoft.XMLHTTP");
  47.                 } catch (e) {
  48.                     return false;
  49.                 };
  50.             };
  51.         };
  52.         http_request.onreadystatechange = function() {
  53.             if (http_request.readyState == 4) {
  54.                 var jsonObj = JSON.parse(http_request.responseText);
  55.                 if (jsonObj.apps.length > 0) {
  56.                     var entry = jsonObj.apps[Math.floor(Math.random() * jsonObj.apps.length)];
  57.  
  58.                     __URL = "";
  59.             __TXT = entry.title;
  60.             if(_tipo==1){
  61.                 __IMG = entry.urlImg;
  62.             }else{
  63.                 __IMG = entry.urlImgWide;
  64.             };
  65.             __LNK = entry.urlApp;
  66.             __DES = entry.desc;
  67.             __PIX = entry.pixelImp;
  68.  
  69.             new Image().src = __PIX;
  70.  
  71.                     MeterViewPort();
  72.             CrearTodo();
  73.  
  74.             if(_fixed && _tipo==1){
  75.                 var list = html;
  76.                 list.insertBefore(container, list.nextSibling);
  77.             }else{
  78.                 var _DIVF = document.getElementById("ForoBetaB");
  79.                 if(_DIVF != null){
  80.                     _DIVF.appendChild(container);
  81.                 };
  82.             };
  83.                 };
  84.             };
  85.         };
  86.         http_request.open("GET", data_file, true);
  87.         http_request.send();
  88.     };
  89.  
  90.     function MeterViewPort() {
  91.  
  92.         meta.name = 'viewport';
  93.  
  94.         meta.content = 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no';
  95.  
  96.         if (viewport) {
  97.  
  98.             viewport.parentNode.removeChild(viewport);
  99.  
  100.         };
  101.  
  102.         document.head.appendChild(meta);
  103.  
  104.     };
  105.  
  106.     function CrearTodo(){
  107.         container.id            = "ForoBetaBaner";
  108.         if(_fixed && _tipo==1){
  109.             html.style.marginBottom = "55px";
  110.             container.style.position    = "fixed";
  111.         }else{
  112.             container.style.position    = "relative";
  113.         };
  114.         container.style.overflow        = "hidden";
  115.         container.style['vertical-align']   = "middle";
  116.         if(_tipo==1){
  117.             container.style.bottom      = '0';
  118.  
  119.             container.style.left        = '0';
  120.             container.style.maxHeight   = '50px';
  121.             container.style.height      = '50px';
  122.             container.style.width       = '100%';
  123.             container.style.zIndex      = '2147483647';
  124.         }else{
  125.             container.style.maxHeight   = '250px';
  126.             container.style.height      = '250px';
  127.             container.style.width       = '300px';
  128.         };
  129.         container.style.backgroundColor = '#000';
  130.         container.style['font-family'] = "sans-serif";
  131.         container.addEventListener('click', function () {
  132.             window.open(__LNK);
  133.             if(_fixed && _tipo==1){
  134.                 container.style.display = "none";
  135.             };
  136.         }, false);
  137.  
  138.         imagen.src = __IMG;
  139.         if(_tipo==1){
  140.             imagen.style['float']       = 'left';
  141.             imagen.style['height']      = '50px';
  142.  
  143.             imagen.style['width']       = '50px';
  144.             imagen.style['margin']      = '0px 4px 0px 0px';
  145.         }else{
  146.             imagen.style['overflow']    = 'hidden';
  147.  
  148.             imagen.style['width']       = '300px';
  149.             imagen.style['margin']      = '0px';
  150.         };
  151.  
  152.         texto.style['display']      = "block";
  153.         if(_tipo==1){
  154.             texto.style['margin']       = '5px 0px 0px 10px';
  155.         }else{
  156.             texto.style['margin']       = '0px';
  157.         };
  158.         texto.style['font-size']    = 'calc(15px + .5vw)';
  159.         texto.style['color']        = '#6E6E6E';
  160.         texto.innerHTML         = __TXT;
  161.  
  162.         descri.style['display']     = "block";
  163.         descri.style['color']       = "#fff";
  164.         descri.style['font-size']   = "12px";
  165.         if(_tipo==1){
  166.             descri.innerHTML    = "Aplicacion Recomendada";
  167.         }else{
  168.             descri.innerHTML    = __DES;
  169.         }
  170.  
  171.         boton.style['display']      = "block";
  172.         boton.style['color']        = "#fff";
  173.         boton.style['background-color'] = "#9ACD32";
  174.         if(_tipo==1){
  175.             boton.style['height']       = "50px";
  176.             boton.style['maxHeight']    = "50px";
  177.             boton.style['float']        = "right";
  178.             boton.style.position        = "absolute";
  179.             boton.style.top         = "0px";
  180.             boton.style.right       = "0px";
  181.             boton.style['padding-left'] = "5px";
  182.             boton.style['padding-right']    = "5px";
  183.             boton.style['line-height']  = "50px";
  184.         }else{
  185.             boton.style.position        = "absolute";
  186.             boton.style.left        = "0px";
  187.             boton.style.bottom      = "0px";
  188.             boton.style['height']       = "30px";
  189.             boton.style['maxHeight']    = "30px";
  190.             boton.style['width']        = "300px";
  191.             boton.style['line-height']  = "30px";
  192.         }
  193.         boton.style['cursor']       = "default";
  194.         boton.style['text-align']   = "center";
  195.         boton.style['vertical-align']   = "middle";
  196.         boton.innerHTML         = "Descargar";
  197.  
  198.         container.appendChild(imagen);
  199.         container.appendChild(texto);
  200.         container.appendChild(descri);
  201.         container.appendChild(boton);
  202.     };
  203.  
  204.     document.addEventListener('DOMContentLoaded', function () {
  205.         if(VerCualDisp()!="no"){ loadJSON(); };
  206.     });
Advertisement
Add Comment
Please, Sign In to add comment