function UnityProgress (dom) {
this.progress = 0.0;
this.message = "";
this.dom = dom;
var parent = dom.parentNode,
configData = config(1),
path = '/webgl/' + configData[2] + '/thumbnails/',
pacoThumbnail = configData[1],
gameTitle = configData[0],
pacoLink = configData[3];
var background = document.createElement("div");
background.style.background = "#000000";
background.setAttribute('id', 'background');
parent.appendChild(background);
this.background = background;
var screenbox = document.createElement('section');
screenbox.setAttribute('id','screenbox');
var printscreens = document.createElement('div');
printscreens.setAttribute('id','printscreens');
var img = document.createElement('img');
img.src = path + 'img1.jpg';
printscreens.appendChild(img);
var logo = document.createElement('img');
logo.setAttribute('id','logo');
logo.src = "/webgl/template/pacogames-logo.png";
screenbox.appendChild(printscreens);
var liBox = document.createElement('div');
liBox.setAttribute('id','libox');
screenbox.appendChild(liBox);
screenbox.appendChild(logo);
for(var j=0;j<10;j++){
var lidiv = document.createElement('div');
lidiv.setAttribute('class','circleDiv');
liBox.appendChild(lidiv);
};
var th = 1,
allDivs = document.getElementsByClassName("circleDiv");
setTimeout(function(args){
allDivs[0].style.backgroundColor = "#afafaf";
}, 800);
var thumbnailInterval = setInterval(preview, 10000);
function preview(){
th++;
printscreens.removeChild(printscreens.children[0]);
if(th < 11){
var img = document.createElement('img');
img.src = path + 'img'+th+'.jpg';
printscreens.appendChild(img);
allDivs[th - 2].style.backgroundColor = "#2b2c2c";
allDivs[th - 1].style.backgroundColor = "#afafaf";
} else {
th = 1;
var img = document.createElement('img');
img.src = path + 'img'+th+'.jpg';
printscreens.appendChild(img);
allDivs[9].style.backgroundColor = "#2b2c2c";
allDivs[0].style.backgroundColor = "#afafaf";
};
};
background.appendChild(screenbox);
this.screenbox = screenbox;
var infobar = document.createElement("section");
infobar.setAttribute('id','webglbar');
var thumbnail = document.createElement('img');
thumbnail.setAttribute('id','thumbnail');
thumbnail.src = pacoThumbnail;
infobar.appendChild(thumbnail);
var title = document.createElement('H1'),
gTitle = document.createTextNode(gameTitle.toUpperCase());
title.appendChild(gTitle);
infobar.appendChild(title);
var working = document.createElement('img');
working.setAttribute('id','working');
working.src = '/webgl/template/working.gif';
infobar.appendChild(working);
background.appendChild(infobar);
this.infobar = infobar;
var progressFrameLoader = document.createElement("div");
progressFrameLoader.setAttribute('id', 'progress-frame-loader');
infobar.appendChild(progressFrameLoader);
var progressFrame = document.createElement("img");
progressFrame.setAttribute('id', 'progress-frame');
progressFrame.src = "/webgl/template/loadingbar.png";
progressFrameLoader.appendChild(progressFrame);
this.progressFrame = progressFrame;
var progressBarLoader = document.createElement("div");
progressBarLoader.setAttribute('id', 'progress-bar-loader');
infobar.appendChild(progressBarLoader);
var progressBar = document.createElement("img");
progressBar.setAttribute('id', 'progress-bar');
progressBar.src = "/webgl/template/fullbar.png";
progressBarLoader.appendChild(progressBar);
this.progressBar = progressBar;
var messageArea = document.createElement("p");
messageArea.setAttribute('id', 'message-area');
infobar.appendChild(messageArea);
this.messageArea = messageArea;
this.SetProgress = function (progress) {
if (this.progress < progress) {
this.progress = progress;
}
if (progress == 1) {
this.SetMessage('preparing...');
}
this.progressFrame.style.visibility = "visible";
this.progressBar.style.display = "inline";
this.Update();
}
this.SetMessage = function (message) {
if (message == "Downloading (0.0/1)" || message === "Loading, please wait.") {
message += "
"
} else if ((m = message.match(/^Downloading data... \(([0-9]+)\/([0-9]+)\)/)) !== null) {
message = this.RewriteMessage(m);
}
this.message = message;
this.background.style.display = "inline";
this.progressFrame.style.visibility = "hidden";
this.progressBar.style.display = "none";
this.Update();
}
this.RewriteMessage = function (m) {
var downloaded = this.FormatBytes(parseInt(m[1]), 2);
var total = this.FormatBytes(parseInt(m[2]), 2);
var message = m[0].replace(m[1], downloaded);
return message.replace(m[2], total);
}
this.FormatBytes = function(bytes,decimals) {
if(bytes == 0) { return '0 Byte'; }
var k = 1000;
var dm = decimals + 1 || 3;
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
var i = Math.floor(Math.log(bytes) / Math.log(k));
return (bytes / Math.pow(k, i)).toPrecision(dm) + ' ' + sizes[i];
}
this.Clear = function() {
this.background.style.display = "none";
this.progressFrame.style.display = "none";
this.progressBar.style.display = "none";
this.screenbox.style.display = "none";
this.infobar.style.display = "none";
document.getElementsByClassName("fullscreen")[0].style.display = "block";
clearInterval(thumbnailInterval);
}
this.Update = function() {
this.background.style.top = this.dom.offsetTop + 'px';
this.background.style.left = this.dom.offsetLeft + 'px';
this.background.style.width = this.dom.offsetWidth + 'px';
this.background.style.height = this.dom.offsetHeight + 'px';
var progressFrameImg = new Image();
progressFrameImg.src = this.progressFrame.src;
this.progressBar.style.top = this.progressFrame.style.top;
this.progressBar.style.left = this.progressFrame.style.left;
this.progressBar.width = progressFrameImg.width * Math.min(this.progress, 1);
this.messageArea.innerHTML = this.message;
}
this.Update ();
document.getElementById('logo').addEventListener("click", function(){
if(document.referrer.substring(0, 28).indexOf("pacogames.com")){
window.location.replace(pacoLink);
};
});
config(2);
}
function config(cfType){
var url = document.referrer.substring(0, 30),
gameTitle = "Pixel Warfare 5",
pacoThumbnail = "http://www.pacogames.com/games/images/thumbnails/230x172/pixel-warfare-5.jpg",
gameFolder = "pixel-warfare-5",
pacoLink = "http://www.pacogames.com/links/" + "pixel-warfare-5.php?game",
ptm = parseInt("12"),
lType = 1,
gList = ["pacogames.com","cdn.gameplayer.io","a10.com","poki","paisdelosjuegos","agame.com"], gListL = gList.length,
indexes = [];
if(cfType === 1){
return [gameTitle, pacoThumbnail, gameFolder, pacoLink];
} else if (cfType === 2){
if((lType === 1 || lType === 2) && url !== ""){
for(i = 0; i < gListL; i++){
if (url.indexOf(gList[i])>-1){
indexes.push(i);
break;
}
};
if((lType === 1 && indexes.length === 0) || (lType === 2 && indexes.length !== 0)){
worker(ptm, gameTitle, pacoLink, gameFolder);
};
};
};
};
function worker(ptm, gameTitle, pacoLink, gameFolder){
var s = document.createElement('script');
s.type = 'text/javascript';
s.src = 'http://www.pacogames.com/static/scripts/libraries/jquery.js';
document.getElementsByTagName('head')[0].appendChild(s);
s.onload = function(){
var time = ptm * 60 * 1000;
var userLang = navigator.language || navigator.userLanguage;
setTimeout(function(args){
if (document.cancelFullScreen) {
document.cancelFullScreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
var body = document.getElementsByClassName('template-wrap clear')[0];
$(body).append('