Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* V1 - 19/12/2016 */
- 'use strict';
- var _fixed = true;
- var _tipo = 1; /* 1=300x50 | 2=300x250 */
- var container = document.createElement('div');
- var imagen = document.createElement('img');
- var texto = document.createElement('h1');
- var descri = document.createElement('div');
- var boton = document.createElement('div');
- var html = document.getElementsByTagName('html')[0];
- var viewport = document.querySelector('meta[name="viewport"]');
- var meta = document.createElement('meta');
- var iOS_ID = "ACA_ID_IOS";
- var Android_ID = "ACA_ID_ANDROID";
- var __URL;
- var __TXT;
- var __IMG;
- var __LNK;
- var __DES;
- var __PIX;
- 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_ID;
- if(cual=="Android") return Android_ID;
- return "no";
- };
- function loadJSON() {
- var data_file = "https://admin.appnext.com/offerWallApi.aspx?pimp=1&tid=API&id="+VerCualDisp()+"&cnt=10";
- var http_request = new XMLHttpRequest();
- try {
- http_request = new XMLHttpRequest();
- } catch (e) {
- try {
- http_request = new ActiveXObject("Msxml2.XMLHTTP");
- } catch (e) {
- try {
- http_request = new ActiveXObject("Microsoft.XMLHTTP");
- } catch (e) {
- return false;
- };
- };
- };
- http_request.onreadystatechange = function() {
- if (http_request.readyState == 4) {
- var jsonObj = JSON.parse(http_request.responseText);
- if (jsonObj.apps.length > 0) {
- var entry = jsonObj.apps[Math.floor(Math.random() * jsonObj.apps.length)];
- __URL = "";
- __TXT = entry.title;
- if(_tipo==1){
- __IMG = entry.urlImg;
- }else{
- __IMG = entry.urlImgWide;
- };
- __LNK = entry.urlApp;
- __DES = entry.desc;
- __PIX = entry.pixelImp;
- new Image().src = __PIX;
- MeterViewPort();
- CrearTodo();
- if(_fixed && _tipo==1){
- var list = html;
- list.insertBefore(container, list.nextSibling);
- }else{
- var _DIVF = document.getElementById("ForoBetaB");
- if(_DIVF != null){
- _DIVF.appendChild(container);
- };
- };
- };
- };
- };
- http_request.open("GET", data_file, true);
- http_request.send();
- };
- function MeterViewPort() {
- 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 CrearTodo(){
- container.id = "ForoBetaBaner";
- if(_fixed && _tipo==1){
- html.style.marginBottom = "55px";
- container.style.position = "fixed";
- }else{
- container.style.position = "relative";
- };
- container.style.overflow = "hidden";
- container.style['vertical-align'] = "middle";
- if(_tipo==1){
- container.style.bottom = '0';
- container.style.left = '0';
- container.style.maxHeight = '50px';
- container.style.height = '50px';
- container.style.width = '100%';
- container.style.zIndex = '2147483647';
- }else{
- container.style.maxHeight = '250px';
- container.style.height = '250px';
- container.style.width = '300px';
- };
- container.style.backgroundColor = '#000';
- container.style['font-family'] = "sans-serif";
- container.addEventListener('click', function () {
- window.open(__LNK);
- if(_fixed && _tipo==1){
- container.style.display = "none";
- };
- }, false);
- imagen.src = __IMG;
- if(_tipo==1){
- imagen.style['float'] = 'left';
- imagen.style['height'] = '50px';
- imagen.style['width'] = '50px';
- imagen.style['margin'] = '0px 4px 0px 0px';
- }else{
- imagen.style['overflow'] = 'hidden';
- imagen.style['width'] = '300px';
- imagen.style['margin'] = '0px';
- };
- texto.style['display'] = "block";
- if(_tipo==1){
- texto.style['margin'] = '5px 0px 0px 10px';
- }else{
- texto.style['margin'] = '0px';
- };
- texto.style['font-size'] = 'calc(15px + .5vw)';
- texto.style['color'] = '#6E6E6E';
- texto.innerHTML = __TXT;
- descri.style['display'] = "block";
- descri.style['color'] = "#fff";
- descri.style['font-size'] = "12px";
- if(_tipo==1){
- descri.innerHTML = "Aplicacion Recomendada";
- }else{
- descri.innerHTML = __DES;
- }
- boton.style['display'] = "block";
- boton.style['color'] = "#fff";
- boton.style['background-color'] = "#9ACD32";
- if(_tipo==1){
- boton.style['height'] = "50px";
- boton.style['maxHeight'] = "50px";
- boton.style['float'] = "right";
- boton.style.position = "absolute";
- boton.style.top = "0px";
- boton.style.right = "0px";
- boton.style['padding-left'] = "5px";
- boton.style['padding-right'] = "5px";
- boton.style['line-height'] = "50px";
- }else{
- boton.style.position = "absolute";
- boton.style.left = "0px";
- boton.style.bottom = "0px";
- boton.style['height'] = "30px";
- boton.style['maxHeight'] = "30px";
- boton.style['width'] = "300px";
- boton.style['line-height'] = "30px";
- }
- boton.style['cursor'] = "default";
- boton.style['text-align'] = "center";
- boton.style['vertical-align'] = "middle";
- boton.innerHTML = "Descargar";
- container.appendChild(imagen);
- container.appendChild(texto);
- container.appendChild(descri);
- container.appendChild(boton);
- };
- document.addEventListener('DOMContentLoaded', function () {
- if(VerCualDisp()!="no"){ loadJSON(); };
- });
Advertisement
Add Comment
Please, Sign In to add comment