mrgenis / OGame 5: Imperium

// ==UserScript==
// @version     2.0.1
// @name        OGame 5: Imperium
// @autor       Sergio Flores Genis (MrGenis)
// @oujs:autor  mrgenis
// @date        2016-04-16
// @namespace   OGame
// @downloadURL https://openuserjs.org/install/mrgenis/OGame_5_Imperium.user.js
// @description Generates summary of resources on planets, moons and flights.
// @include     *.ogame.gameforge.*/game/*
// @icon        https://i.imgur.com/UVCIYlt.png
// @grant       none
// ==/UserScript==
var VERSION = '2.0.1';
var UPDATE = '2016-04-14';

/**
 * changelog : 2.0.1 (2016-06-14)
 * New code for new format
 * 
 * changelog : 1.1.9.6 (2016-02-11)
 * Fix for the style of the moons recusos table.
 * Add the column to see the number of large cargo ships to move resources.
 * 
 * changelog : 1.1.9.5bis (2016-02-08)
 * Page detection was resolved to include in OGAME
 * 
 * changelog : 1.1.9.5 (2016-01-26)
 * Correction of the size of icons on planets and moons.
 * 
 * changelog : 1.1.9.4 (2016-01-19)
 * Now the planets are ordered based on the coordinates
 * 
 * changelog : 1.1.9.3 (2015-09-23)
 * Fixed error recognition "Tampermonkey" (Chrome)
 * Correction to detect flights not target own planets.
 */

function initUi(e,t){ui.inline.costructionAssistant(),ui.inline.shortcodes(e),function(e){function r(e){n.classList.contains("selected")?(t.hide(),n.classList.remove("selected")):(t.show(),n.classList.add("selected"))}var n=utils.createElement("a",{href:"javascript:void(0);","class":"menubutton"});n.innerHTML='<span class="textLabel">Imperium</span>';var i=utils.createElement("ul",{id:"menuTableImperium","class":"leftmenu"},utils.createElement("li",null,utils.createElement("span",{"class":"menu_icon"},utils.createElement("div",{"class":"menuImage ogi2"})),n)),s=utils.createElement("div",{style:"float:left"},i);e.parentElement.insertBefore(s,e.nextSibling),n.onclick=function(e){r(e),e.preventDefault()}}(document.getElementById("menuTable"));var r=new ui.clazz.ResourcesProduction(e),n=new ui.clazz.ResourcesProductionDetails(e),i=new ui.clazz.ResourcesStellars(e),s=utils.createElement("div",{"class":"credit"},utils.format("Ogame: Imperium - {0} ",__VERSION__),utils.createElement("span",null,"by MrGenis"));t.container.appendChild(s),t.container.appendChild(r.table),t.container.appendChild(n.table),t.container.appendChild(i.container),document.head.appendChild(ui.css.style())}var utils;!function(e){function t(e,t,r){return void 0===r&&(r=0),e.indexOf(t,r)===r}function r(e,t){var r=new RegExp("(\\d+\\.\\d{"+t+"})(\\d)"),n=e.toString().match(r);return n?parseFloat(n[1]):parseFloat(e.toString())}function n(e){return e&&c(e)?(e.jquery||(e=jQuery(e)),""!=e.attr("title")?e.attr("title"):e.data("tipped_restore_title")):""}function i(e,t,r){void 0===t&&(t="innerHTML"),void 0===r&&(r=null);var n=document.querySelector(e);if(!n)return null;for(var i=t.split("."),s=0;s<i.length-1;s++){if(!n[i[s]])return null;n=n[i[s]]}return a(n[i[s]],r)}function s(e){return e?parseInt(e.replace(/[^\d\-]/g,"")):null}function a(e,t,r){if(void 0===t&&(t=null),void 0===r&&(r=0),!e)return null;if(e=e.toString(),null==t)return s(e);var n=e.match(t);return n?s(n[r]):null}function o(e,t){void 0===t&&(t={});for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var i=document.createElement(e);for(var s in t)i.setAttribute(s,t[s]);1==r.length&&Array.isArray(r[0])&&(r=r[0]);for(var a=0;a<r.length;a++){var o=r[a];c(o)||(o=document.createTextNode(o)),i.appendChild(o)}return i}function l(){for(var e=[],t=0;t<arguments.length;t++)e[t-0]=arguments[t];var r=o("div");return 1==e.length&&Array.isArray(e[0])&&(e=e[0]),e.forEach(function(e){c(e)||(e=document.createTextNode(e)),r.appendChild(e)}),r.innerHTML}function u(e){return e&&"[object Function]"==f.toString.call(e)}function c(e){return"object"==typeof Node?e instanceof Node:e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName}function d(e){return"object"==typeof HTMLElement?e instanceof HTMLElement:e&&"object"==typeof e&&null!==e&&1===e.nodeType&&"string"==typeof e.nodeName}function p(e,t,r){if(void 0!==t&&null!==t){for(var n=Object.keys(t),i=0;i<n.length;i++)e[n[i]]=t[n[i]];return r?e:void 0}}function h(e,t,r,n,i){void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===i&&(i=!1),Object.defineProperty(e,t,{enumerable:r,writable:n,configurable:i})}function m(t,r,n,i){void 0===r&&(r="_blank"),void 0===n&&(n={}),void 0===i&&(i=!0);for(var s="",a=Object.keys(n),o=0;o<a.length;o++){var l=a[o],u=n[l];s+=e.format("{0}={1},",l,u)}return e._window.open(t,r,s,i)}var f={};e.gmEnable="function"==typeof GM_getResourceURL,e._window="undefined"!=typeof unsafeWindow?unsafeWindow:window,e.startWith=t,e.trunc=r,e.getTitle=n,e.getIntByQuery=i,e.parseInteger=s,e.parseIntRx=a,e.createElement=o,e.node2HTMLText=l,e.isFunction=u,e.isNode=c,e.isElement=d,e.joinMaps=p,e.define=h,e.winOpen=m}(utils||(utils={}));var utils;!function(e){function t(e,t,r){if(void 0===t&&(t=null),void 0===r&&(r=null),!isFinite(this))return"NaN";var n=this;if("o"==e)n=parseInt(this).toString(8);else if("x"==e)n=parseInt(this).toString(16).toLowerCase();else if("X"==e)n=parseInt(this).toString(16).toUpperCase();else if("d"==e||!e){var i=new RegExp("(\\-)?(\\d+)(?:\\.(\\d+))?"),a=this.toString().match(i),o=a[1]||"",l=parseInt(a[2]),u=parseInt(a[3]);if(null!=r&&r>=0&&!isNaN(u)&&(0==r?u=NaN:(u=u.toString().substring(0,r),u+=Array(r-u.length+1).join("0"))),t){if(t.indexOf(",")>-1&&l.toString().length>3){for(var c="",d=l.toString().split(""),p=1;d.length>0;p++)c=d.pop()+c,3==p&&(p=0,c=s.strformat.cThousand+c);l=c}t.indexOf("+")>-1?this>0&&(o="+"):t.indexOf("#")>-1&&this>0&&(o=" ")}n=o+l+(isNaN(u)?"":s.strformat.cDecimal+u)}return n}function r(e,r){var n=/{(\d+)(\$(\-)?('.)?(\d*)(s|n)([^\s\/]+)?(\/[\.\w]*)?)?}/gm;return e.replace(n,function(e,n,i){for(var s=[],a=3;a<arguments.length;a++)s[a-3]=arguments[a];if(void 0===r[n])return e;if(void 0===i)return r[n].toString();s.pop();var o=r[n],l={isleft:"-"==s[0],fillchar:(s[1]||"  ").charAt(1),filln:parseInt(s[2])||0,conversion:(s[3]||"s").toLowerCase(),conversion_data:s[4],from_objet:s[5]||!1};try{var u=Array(l.filln+1).join(l.fillchar);if(l.from_objet)for(var c=l.from_objet.substring(1).split(".");c.length>0;)o=o[c.shift()];if("n"==l.conversion)if(l.conversion_data){var d=l.conversion_data.match(/(d|o|x|X)?([\+#,)]+)?(?:\.(\d+))?/);d.shift(),o=t.apply(o,d)}else o=o.toString();else o=o.toString();var p=o.length;return u=u.substring(p),l.isleft?o+=u:o=u+o,o}catch(h){console.error("format(): ",e,", val: ",r[n]," \nparams: ",l," \n",h)}return e})}function n(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return r(e,t)}var i=1000.1.toLocaleString(),s={strformat:{cThousand:LocalizationStrings.thousandSeperator,cDecimal:i.charAt(i.length-2)}};e.format=n}(utils||(utils={}));var utils;!function(e){function t(e,t,r,n){if(void 0===n&&(n=null),!e.__observable__[t]){var s=e[t];delete e[t]&&(e.__observable__[t]=i(e,t,s))}return e.__observable__[t].listeners.push(r),e.__observable__[t].root.push(n),e.__observable__[t].listeners.length}function r(e,t,r){if(!e.__observable__[t])return!1;for(var n=e.__observable__[t],i=0;i<n.listeners.length;i++)if(n.listeners[i]===r){var s=delete n.listeners[i],a=delete n.root[i];return s&&a}return!1}function n(t,r,n,i){var s=r.value;if(s!==n)for(var a=0;a<r.listeners.length;a++){var o=r.root[a]||i;setTimeout(function(t,r,i){try{r.call(i,t,s,n)}catch(a){var o=e.tracing(a);console.error("ERROR! => Observable#callback",".\n	callback: ",r,".\n	root: ",i,".\n	property: ",t,".\n	values: old: ",s," -> new: ",n,".\n",o.toString())}},1,t,r.listeners[a],o),r.value=n}}function i(e,t,r){var i={value:r,listeners:[],root:[]};return Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:function(){return i.value},set:function(e){n(t,i,e,this)}}),i}function s(n,i){if(!n.__observable__){var s={};n.__observable__=s,n.observableHash=i||(new Date).getTime().toString(),n.observablesOn=!0,n.listen=function(e,r,n){return void 0===n&&(n=null),t(this,e,r,n)},n.remove=function(e,t){return r(this,e,t)},e.define(n,"observablesOn",!1,!0,!1),e.define(n,"observableHash",!1),e.define(n,"__observable__"),e.define(n,"listen"),e.define(n,"remove")}return n}e.observable=s}(utils||(utils={}));var utils;!function(e){function t(e){return new r(e)}var r=function(){function t(e){this.trace=[];try{this.message=e.message;var t=e.stack.split("\n");for(var r in t){if(r==t.length-1)break;var n=t[r].split("@"),i=n[0];0==i.length&&(i="root");var s=n[1];s=s.match(/([\d]+:[\d]+)$/g)[0],this.trace.push({fnc:i,line:s})}}catch(a){console.error("ErrorTracing : ",e.message,e.stack.split("\n"),"\n.",a)}}return t.prototype.toString=function(){for(var t="Message: "+this.message+"\n",r=0;r<this.trace.length;r++)t+=e.format("{0$-10s} # {1}\n",this.trace[r].line,this.trace[r].fnc);return t},t}();e.tracing=t}(utils||(utils={}));var __extends=this&&this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)},utils;!function(e){function t(e){return void 0===e&&(e=0),new a(e)}function r(e){return void 0===e&&(e=0),new o(e)}function n(t,r){return void 0===t&&(t=0),void 0===r&&(r=null),e.observable(new l(t),r)}function i(t,r){return void 0===t&&(t=0),void 0===r&&(r=null),e.observable(new u(t),r)}function s(t,r){return void 0===t&&(t=0),void 0===r&&(r=null),e.observable(new c(t),r)}var a=function(){function e(e){void 0===e&&(e=0),this.metal=e,this.crystal=e,this.deuterium=e}return e}(),o=function(){function e(e){void 0===e&&(e=0),this.metal=e,this.crystal=e,this.deuterium=e,this.energy=e}return e}(),l=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.reset=function(){this.metal=0,this.crystal=0,this.deuterium=0},t}(a),u=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.reset=function(){this.metal=0,this.crystal=0,this.deuterium=0,this.energy=0},t}(o),c=function(){function e(e){void 0===e&&(e=0),this.metal=e,this.crystal=e,this.deuterium=e,this.energy_using=e,this.energy_generate=e,this.energy=e}return e.prototype.reset=function(){this.metal=0,this.crystal=0,this.deuterium=0,this.energy_using=0,this.energy_generate=0,this.energy=0},e}();e.resources3=t,e.resources4=r,e.resources3Observable=n,e.resources4Observable=i,e.resourcesProduction=s}(utils||(utils={}));var utils;!function(e){var t;!function(e){function t(e,t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(var r,n=Object(e),i=n.length>>>0,s=arguments[1],a=0;i>a;a++)if(r=n[a],t.call(s,r,a,n))return r;return null}e.find=t}(t=e.array||(e.array={}))}(utils||(utils={}));var game;!function(e){var t;!function(t){function r(e){var t=document.getElementsByName("ogame-"+e).item(0);return t.getAttribute("content")}t.keys={AccountOverviewImage:"OverviewImage",AccountFlightSound:"FlightSound",AccountResearchers:"researchers",StellarTechnologies:"technologies",StellarProduction:"production",ServerLocalization:"ServerLocalization"},Object.freeze(e.db.keys),utils.define(e.db,"keys",!0);var n=function(){function e(e){this.mask="",this.mask="OGI_"+e,utils.define(this,"mask")}return e.prototype.get=function(e,t){void 0===t&&(t=0);var r=localStorage.getItem(this.mask+e)||t;return JSON.parse(r)},e.prototype.set=function(e,t){var r=JSON.stringify(t);localStorage.setItem(this.mask+e,r)},e.prototype.has=function(e){return null!=this.get(e,null)},e.prototype.remove=function(e){localStorage.removeItem(this.mask+e)},e.prototype.getMapKey=function(e,t,r){void 0===r&&(r=null);var n=this.get(e,"{}");return n[t]||r},e.prototype.setMapKey=function(e,t,r){var n=this.get(e,"{}");n[t]=r,this.set(e,n)},e.prototype.hasMapKey=function(e,t){return null!=this.getMapKey(e,t,null)},e.prototype.removeMapKey=function(e,t){var r=this.get(e,"{}");delete r[t],this.set(e,r)},e}(),i=function(e){function t(){var t=r("universe"),n=r("player-id");t=t.split(".",1)[0].replace("-","")+"_",t+=n+"_",e.call(this,t.toUpperCase())}return __extends(t,e),t}(n),s=function(e){function t(){var t=r("universe");t=t.split(".",1)[0].replace("-","")+"_",e.call(this,t.toUpperCase())}return __extends(t,e),t}(n);t.universe=new s,t.player=new i,utils.define(e.db,"universe"),utils.define(e.db,"player")}(t=e.db||(e.db={}))}(game||(game={}));var game;!function(e){var t;!function(e){function t(e){return 5e3*utils.trunc(2.5*Math.pow(Math.E,20*e/33),0)}e.storageResource=t;var r;!function(e){function t(e,t){return Math.ceil(t*e*10*Math.pow(1.1,e))}function r(e,t){return Math.ceil(10*t*e*Math.pow(1.1,e))}function n(e,t){return Math.floor(20*t*e*Math.pow(1.1,e))}function i(e,t,r){return Math.floor(t*r*(20*e*Math.pow(1.1,e)))}function s(e,t,r,n){return Math.floor(t*r*(30*e*Math.pow(1.05+.01*n,e)))}function a(e,t,r,n){var i=Math.floor(e*t*r*Math.floor((n+140)/6));return 0>i?0:i}e.metal=t,e.crystal=r,e.deuterium=n,e.solar=i,e.fusion=s,e.satellite=a}(r=e.energy||(e.energy={}))}(t=e.fn||(e.fn={}))}(game||(game={}));var game;!function(e){var t;!function(t){function r(e,t){void 0===t&&(t=!1);var r=[];e.replace(/[\[\]]/g,"").split(":").forEach(function(e){r.push(parseInt(e))});var n=new a;return n.galaxy=r[0],n.system=r[1],n.planet=r[2],n.ismoon=t,Object.seal(n),n}function n(){var e=utils.resourcesProduction(0);e.metal=utils.getIntByQuery("#resources_metal"),e.crystal=utils.getIntByQuery("#resources_crystal"),e.deuterium=utils.getIntByQuery("#resources_deuterium"),e.energy=utils.getIntByQuery("#resources_energy");var t=utils.getTitle(document.getElementById("energy_box")).split(/td/g);return e.energy_generate=utils.parseInteger(t[3]),e.energy_generate=utils.parseInteger(t[5]),e}function i(e){var t=document.getElementsByName("ogame-"+e).item(0);return t.getAttribute("content")}function s(){if(!e.isCurrentPage("resources,station,shipyard,defense,research,fleet1"))return null;var t={};try{if(e.isCurrentPage("fleet1")){for(var r=0;r<e.ships.IDs.length;r++)t[e.ships.IDs[r]]=0;var n=document.getElementById("shipsChosen");if(n)for(var i=n.querySelectorAll("li[id^=button]"),r=0;r<i.length;r++){var s=i.item(r),a=utils.parseInteger(s.id),o=utils.parseInteger(s.querySelector(".level").innerText);t[a]=o}}else for(var i=document.getElementById("buttonz").querySelectorAll("[id^=details]"),r=0;r<i.length;r++){var l=i.item(r),a=utils.parseInteger(l.getAttribute("ref")),o=utils.parseInteger(l.querySelector(".level").innerText);t[a]=o}}catch(u){t=null;var c=utils.tracing(u);console.error("ERROR! game.tools.fn#readTechs: ",c.toString())}return t}var a=function(){function e(){this.ismoon=!1}return e.prototype.toString=function(){return utils.format("[{0}:{1}:{2}]",this.galaxy,this.system,this.planet)},Object.defineProperty(e.prototype,"inarray",{get:function(){return[this.galaxy,this.system,this.planet]},enumerable:!0,configurable:!0}),e.prototype.compareTo=function(e){var t=this.galaxy-e.galaxy;return 0===t&&(t=this.system-e.system),0===t&&(t=this.planet-e.planet),0===t&&(t=this.ismoon?1:-1),t},e.prototype.equalsTo=function(e){return this.galaxy==e.galaxy&&this.system==e.system&&this.planet==e.planet&&this.ismoon==e.ismoon},e}();t.parseCoords=r,t.currentResources=n,t.meta=i,t.readTechs=s,t.ResearchersID=[113,120,121,114,122,115,117,118,106,108,124,123,199,109,110,111],function(e){e[e.METAL=0]="METAL",e[e.CRYSTAL=1]="CRYSTAL",e[e.DEUTERIUM=2]="DEUTERIUM"}(t.Resources3Enum||(t.Resources3Enum={}));t.Resources3Enum;!function(e){e[e.METAL=0]="METAL",e[e.CRYSTAL=1]="CRYSTAL",e[e.DEUTERIUM=2]="DEUTERIUM",e[e.ENERGY=3]="ENERGY"}(t.Resources4Enum||(t.Resources4Enum={}));t.Resources4Enum;!function(){utils.define(e.utilities,"ResearchersID",!0),utils.define(e.utilities,"Resources3Enum",!0),utils.define(e.utilities,"Resources4Enum",!0),Object.freeze(e.utilities.ResearchersID),Object.freeze(e.utilities.Resources3Enum),Object.freeze(e.utilities.Resources4Enum)}()}(t=e.utilities||(e.utilities={}))}(game||(game={}));var game;!function(e){e.lang={};var t=function(){function t(){this.current=e.utilities.meta("language"),e.lang[this.current]||(this.current="en")}return t.prototype.t=function(t){var r=e.lang[this.current],n=t;if(r)try{var i=[t];for(n=r[i.shift()];i.length>0;)n=n[i.shift()]}catch(s){var a=utils.tracing(s);console.error("Imperium (Lang): ",a.toString()),n=t}return n||(n=t),n},t}();e.language=new t}(game||(game={}));var game;!function(e){var t;!function(t){function r(){var e;if(u.has(a)){var t=jQuery.Deferred();t.resolve(u.get(a)),e=t.promise()}else e=jQuery.ajax({method:"get",url:"/api/localization.xml",cache:!0,dataType:"json",global:!1,dataFilter:function(e){var t={techs:{},missions:{}};try{for(var r=jQuery.parseXML(e),n=r.firstChild,i=n.childNodes,s=i.item(0),o=i.item(1),l=0;l<s.childElementCount;l++){var c=s.children.item(l);t.techs[c.id]=c.innerHTML}for(var l=0;l<o.childElementCount;l++){var c=o.children.item(l);t.missions[c.id]=c.innerHTML}u.set(a,t)}catch(d){var p=utils.tracing(d);console.error("ERROR! (game.localization) promise => ",p.toString())}return JSON.stringify(t)}});return e.done(function(e){o=e.techs,l=e.missions}),e}function n(e){return void 0===e&&(e=!1),e&&(u.remove(a),o=null,l=null),r()}function i(e){return o[e]?o[e]:"TH"+e}function s(e){return l[e]?l[e]:"M"+e}var a=e.db.keys.ServerLocalization,o={},l={},u=e.db.universe;t.load=n,t.technology=i,t.mision=s,t.firstPromise=n()}(t=e.localization||(e.localization={}))}(game||(game={}));var game;!function(e){var t;!function(t){function r(){return jQuery.ajax({cache:!1,dataType:"json",global:!1,method:"post",url:"/game/index.php?page=traderOverview",data:{ajax:1,show:"importexport"},dataFilter:function(e){for(var t=e.match(/<script\b[^>]*>([\s\S]*?)<\/script>/gm),r=t[0].match(/planetResources=({[\s\S]*?});/gm),n=JSON.parse(r[0].slice(16,-1)),i={},s=Object.keys(n),a=0;a<s.length;a++){var o=s[a];i[o]=n[o].input}return JSON.stringify(i)}})}function n(){return r()}function i(){var e=jQuery.Deferred(function(){return jQuery.ajax({cache:!1,dataType:"json",global:!1,method:"get",url:"/game/index.php?page=fetchResources",dataFilter:function(e){var t=null;try{var r=JSON.parse(e),n=utils.resourcesProduction(0);n.metal=r.metal.resources.production,n.crystal=r.crystal.resources.production,n.deuterium=r.deuterium.resources.production,n.energy=r.energy.resources.actual;var i=r.energy.tooltip.replace(/\n/,"").split(/<\s*tr/);return n.energy_generate=utils.parseInteger(i[2]),n.energy_using=utils.parseInteger(i[3]),JSON.stringify(n)}catch(s){utils.tracing(s);console.error("ERROR! game.resources.production: ",s.toString())}return t}}).done(function(t){e.resolve(t)})});return e.promise()}function s(){return i()}function a(){var t=jQuery.Deferred(function(){jQuery.ajax({method:"get",global:!1,dataType:"json",url:"/game/index.php?page=fetchTechs&ajax=1"}).done(function(r){var n={};e.utilities.ResearchersID.forEach(function(e){n[e]=r[e],delete r[e]}),t.resolve(r,n)})});return t.promise()}function o(){return a()}t.resources=n,t.production=s,t.technologies=o}(t=e.request||(e.request={}))}(game||(game={}));var game;!function(e){var t;!function(t){function r(e,t,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=0);var n=utils.resources3(0);return n.metal=e,n.crystal=t,n.deuterium=r,Object.freeze(n),n}function n(e){var t=u[e];return void 0===t?null:t}function i(t){var r=utils.array.find(e.ships.IDs,function(e){return t==u[e].name});return null==r?null:u[r]}t.IDs=[204,205,206,207,215,211,213,214,202,203,208,209,210,212],function(e){e[e.Military=1]="Military",e[e.Civil=2]="Civil"}(t.Type||(t.Type={}));t.Type;!function(e){e[e.Attack=1]="Attack",e[e.ACSAttack=2]="ACSAttack",e[e.Transport=3]="Transport",e[e.Deployment=4]="Deployment",e[e.ACSDefend=5]="ACSDefend",e[e.Espionage=6]="Espionage",e[e.Colonisation=7]="Colonisation",e[e.Recycle=8]="Recycle",e[e.MoonDestruction=9]="MoonDestruction",e[e.Expedition=15]="Expedition"}(t.MissionType||(t.MissionType={}));t.MissionType;!function(){utils.define(e.ships,"IDs",!0),utils.define(e.ships,"Type",!0),utils.define(e.ships,"MissionType",!0),Object.freeze(e.ships.IDs),Object.freeze(e.ships.Type),Object.freeze(e.ships.MissionType)}();var s={204:r(3e3,1e3),205:r(6e3,4e3),206:r(2e4,7e3,2e3),207:r(45e3,15e3),215:r(3e4,4e4,15e3),211:r(5e4,25e3,15e3),213:r(6e4,5e4,15e3),214:r(5e6,4e6,1e6),202:r(2e3,2e3),203:r(6e3,6e3),208:r(1e4,2e4,1e4),209:r(1e4,6e3,2e3),210:r(0,1e3),212:r(0,2e3,500)},a={204:50,205:100,206:800,207:1500,215:750,211:500,213:2e3,214:1e6,202:5e3,203:25e3,208:7500,209:2e4,210:0,212:0},o={204:20,205:75,206:300,207:500,215:250,211:1e3,213:1e3,214:1,202:20,203:50,208:1e3,209:300,210:1,212:0},l={204:12500,205:1e4,206:15e3,207:1e4,215:1e4,211:5e3,213:5e3,214:100,202:1e4,203:7500,208:2500,209:2e3,210:1e8,212:0},u={},c=function(){function e(e,t){this.id=e,this.name=t,utils.define(this,"id",!0)}return Object.defineProperty(e.prototype,"cargo",{get:function(){return a[this.id]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cost",{get:function(){return s[this.id]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"intake",{get:function(){return o[this.id]},enumerable:!0,configurable:!0}),e.prototype.speed=function(e,t,r){var n=l[this.id];return 202==this.id?n+n*(t>=5?.2*t:.1*e):211==this.id?n+n*(r>=8?.3*r:.2*t):209==this.id?n+n*(r>=15?.3*r:t>=17?.2*t:.1*e):[210,203,204].indexOf(this.id)>-1?n+.1*n*e:[206,205,208].indexOf(this.id)>-1?n+.2*n*t:[207,215,213,214].indexOf(this.id)>-1?n+.3*n*t:n},e}();jQuery.when(e.localization.firstPromise).then(function(t){e.ships.IDs.forEach(function(e){u[e]=new c(e,t.techs[e])})}),t.getById=n,t.getByName=i}(t=e.ships||(e.ships={}))}(game||(game={}));var game;!function(e){function t(e){var t=document.querySelector("meta[name=ogame-"+e+"]");return t?t.getAttribute("content"):null}function r(e){for(var t=e.split(","),r=!1,n=0;n<t.length&&!r;n++)r=t[n].trim()==currentPage;return r}e.ajax=jQuery.when(e.localization.firstPromise),e.meta=t,e.playerID=parseInt(t("player-id")),e.currentPlanetID=parseInt(t("planet-id")),e.currentPlanetType=t("planet-type"),e.isCurrentPage=r,function(){utils.define(e,"playerID",!0),utils.define(e,"currentPlanetID",!0),utils.define(e,"currentPlanetType",!0)}()}(game||(game={}));var account;!function(e){var t;!function(e){function t(e,t){void 0===t&&(t=!1),t&&game.db.player.remove(e.id);var r=game.utilities.readTechs(),n=e.id,i=game.db.player.has(n),s=null,a=null;game.isCurrentPage("research")&&(s=r,r=null);var o=!1,l=null,u=null;return i?(a=r,game.isCurrentPage("resources")?o=e.tech(1)!==a[1]||e.tech(2)!==a[2]||e.tech(3)!==a[3]||e.tech(4)!==a[4]||e.tech(12)!==a[12]||e.tech(212)!==a[212]:game.isCurrentPage("shipyard")&&(o=e.tech(212)!==a[212]),l=jQuery.Deferred(function(e){return e.resolve(a,s)}).promise()):(o=!0,l=game.request.technologies()),u=!o&&game.db.player.hasMapKey(n,game.db.keys.StellarProduction)?jQuery.Deferred(function(e){return e.resolve(null)}).promise():game.request.production(),jQuery.when(l,u).always(function(t,r){console.info("account.inline.updateStellar#always: ",e.name," \n","@ stella     	:",null!==t[0]," \n","@ researchers	:",null!==t[1]," \n","@ production 	:",null!==r)})}!function(e){if(game.isCurrentPage("resourceSettings")){var t=document.getElementsByTagName("form")[0];t.addEventListener("submit",function(){game.db.player.removeMapKey(e,game.db.keys.StellarProduction)})}}(game.currentPlanetID),e.updateStellar=t}(t=e.inline||(e.inline={}))}(account||(account={}));var account;!function(e){function t(e){var t=game.db.player.get(e.id,!1);t&&(utils.joinMaps(e.production,t.production||{}),utils.joinMaps(e.technologies,t.technologies||{}),e.storage.metal=game.fn.storageResource(e.tech(22,NaN)),e.storage.crystal=game.fn.storageResource(e.tech(23,NaN)),e.storage.deuterium=game.fn.storageResource(e.tech(24,NaN)))}function r(e){var t={};t[game.db.keys.StellarTechnologies]=e.technologies,t[game.db.keys.StellarProduction]=e.production,game.db.player.set(e.id,t)}function n(e){var t=game.request.resources();t.done(function(t){for(var r=0;r<e.all.length;r++){var n=e.all[r].id;utils.joinMaps(e.all[r].resources,t[n])}})}var i=function(){function e(e){this.id=NaN,this.name="",this.coords=null,this.isMoon=!1,this.moonID=null,this.tempMin=null,this.technologies={},this.id=e,utils.define(this,"id",!0),this.storage=utils.resources3Observable(NaN,this.id+"/Storage"),this.resources=utils.resources3Observable(0,this.id+"/Resources"),this.production=utils.resourcesProduction(NaN,this.id+"/Production")}return e.prototype.tech=function(e,t){return void 0===t&&(t=0),"undefined"==typeof this.technologies[e]?t:this.technologies[e]},e.prototype.init=function(){t(this)},e.prototype.save=function(){r(this)},e}();e.Stellar=i;var s=function(){function e(){this._stellars=[],this.resources=utils.resources3Observable(0,"StellarResources"),this.resourcesInPlanets=utils.resources3Observable(0,"StellarResourcesPlanets"),this.resourcesInMoons=utils.resources3Observable(0,"StellarResourcesMoons"),this.production=utils.resources4Observable(0,"Production");var t=function(e,t,r){isNaN(t)&&(t=0),isNaN(r)&&(r=0),this[e]+=r-t};this.resourcesInPlanets.listen("metal",t,this.resources),this.resourcesInPlanets.listen("crystal",t,this.resources),this.resourcesInPlanets.listen("deuterium",t,this.resources),this.resourcesInMoons.listen("metal",t,this.resources),this.resourcesInMoons.listen("crystal",t,this.resources),this.resourcesInMoons.listen("deuterium",t,this.resources);for(var r=document.getElementById("planetList"),n=r.getElementsByClassName("planetlink"),s=0;s<n.length;s++){var a=n.item(s),o=utils.getTitle(a).split(/<br/gi),l=a.querySelector(".planet-koords").textContent,u=utils.parseIntRx(a.href,/cp=(\d+)$/gi),c=new i(u);if(c.name=a.querySelector(".planet-name").textContent,c.coords=game.utilities.parseCoords(l,!1),c.image=a.querySelector("img").src,c.tempMin=utils.parseIntRx(o[2],/(-?\d+)/g,0),c.resources.listen("metal",t,this.resourcesInPlanets),c.resources.listen("crystal",t,this.resourcesInPlanets),c.resources.listen("deuterium",t,this.resourcesInPlanets),c.production.listen("metal",t,this.production),c.production.listen("crystal",t,this.production),c.production.listen("deuterium",t,this.production),c.production.listen("energy",t,this.production),c.init(),this._stellars.push(c),a=a.parentNode.querySelector(".moonlink")){o=utils.getTitle(a).split(/<br/gi);var d=utils.parseIntRx(a.href,/cp=(\d+)$/gi),p=new i(d);p.isMoon=!0,p.name=o[0].match(/(.*) \[/gi)[0].slice(3,-1).trim(),p.coords=game.utilities.parseCoords(l,!0),p.image=a.querySelector("img").src,c.moonID=p.id,p.resources.listen("metal",t,this.resourcesInMoons),p.resources.listen("crystal",t,this.resourcesInMoons),p.resources.listen("deuterium",t,this.resourcesInMoons),p.init(),this._stellars.push(p)}}e.sort(this._stellars),this.loadResources()}return Object.defineProperty(e.prototype,"planets",{get:function(){var e=[];for(var t in this._stellars)this._stellars[t].isMoon||e.push(this._stellars[t]);return e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"moons",{get:function(){var e=[];for(var t in this._stellars)this._stellars[t].isMoon&&e.push(this._stellars[t]);return e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"all",{get:function(){return this._stellars},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._stellars.length},enumerable:!0,configurable:!0}),e.prototype.byId=function(e){var t=null;for(var r in this._stellars)if(this._stellars[r].id===e){t=this._stellars[r];break}return t},e.prototype.byCoords=function(e,t){void 0===t&&(t=!1);var r=game.utilities.parseCoords(e,t),n=t?this.moons:this.planets,i=null;for(var s in n)if(n[s].coords.equalsTo(r)){i=n[s];break}return i},e.prototype.loadResources=function(){n(this)},e.sort=function(e,t){return void 0===t&&(t=!1),e.sort(function(e,r){if(t){var n=e.name.toLocaleLowerCase(),i=r.name.toLocaleLowerCase();return n.localeCompare(i)}return e.coords.compareTo(r.coords)}),e},e}();e.StellarCollection=s}(account||(account={}));var account;!function(e){var t=game.db.keys.AccountFlightSound,r=game.db.player,n=function(){function e(e){this.resources=utils.resources3(0),this.ships={},this.originMoon=!1,this.destMoon=!1,this.id=utils.parseIntRx(e.id,/(\d+)/g),this.mission=parseInt(e.dataset.missionType),this.timeArrival=parseInt(e.dataset.arrivalTime),this.endTime=new Date(1e3*this.timeArrival),this.isDeploy=this.mission==game.ships.MissionType.Deployment,this.isReturn="true"==e.dataset.returnFlight;var t=e.querySelector("td[class*='icon_movement'] > span"),r=utils.getTitle(t);this.analyzeDetails(r);var n=e.querySelector(".missionFleet > img");this.icon=n.src;var i=e.querySelector(".coordsOrigin > a").textContent.trim();this.originMoon=null!==e.querySelector(".originFleet .moon"),this.originCoords=game.utilities.parseCoords(i,this.originMoon);var s=e.querySelector(".destCoords > a").textContent;this.destMoon=null!==e.querySelector(".destFleet .moon"),this.destCoords=game.utilities.parseCoords(s,this.destMoon)}return e.prototype.analyzeDetails=function(e){var t=e.replace(/[\n]/g,"").split("<th");if(t[1]){for(var r=t[1].split("<td"),n=1;n<r.length-2;n+=2){var i=r[n].trim().slice(1,-6),s=game.ships.getByName(i).id,a=utils.parseInteger(r[n+1]);this.ships[s]=a}t[2]&&(r=t[2].split("<td"),this.resources.metal=utils.parseInteger(r[2]),this.resources.crystal=utils.parseInteger(r[4]),this.resources.deuterium=utils.parseInteger(r[6]))}},e}(),i=function(){function e(){var e=this;this._flight=[],this.resources=utils.resources3Observable(0);var t=document.getElementById("eventboxContent");t.addEventListener("DOMNodeInserted",function(t){if(t&&t.target){var r=t.target;"eventListWrap"===r.id&&setTimeout(function(){return e.loadFlights()},0)}},!1);var r=document.getElementById("eventContent");r&&setTimeout(function(){return e.loadFlights()},0)}return Object.defineProperty(e.prototype,"all",{get:function(){return this._flight},enumerable:!0,configurable:!0}),e.prototype.loadFlights=function(){this.resources.reset();for(var e=document.getElementById("eventContent"),i=e.getElementsByClassName("eventFleet"),s=[],a=[],o=0;o<i.length;o++)try{var l=i.item(o),u=new n(l);this._flight.push(u),s.push(u.id+""),a.push(u.id+1),u.mission==game.ships.MissionType.Expedition&&a.push(u.id+2),-1==a.indexOf(u.id)&&(this.resources.metal+=u.resources.metal,this.resources.crystal+=u.resources.crystal,this.resources.deuterium+=u.resources.deuterium)}catch(c){var d=utils.tracing(c);console.error("Imperium ERROR!! account.FlightCollection : ",d.toString())}var p=Object.keys(r.get(t,"{}"));p.forEach(function(e){-1==s.indexOf(e)&&r.removeMapKey(t,e)})},e}();e.FlightCollection=i}(account||(account={}));var Stellar=account.Stellar,GameAccount=function(){function e(){this.researchers={},this.resources=utils.resources3Observable(0),this.stellars=new account.StellarCollection,this.fligths=new account.FlightCollection,this.researchers=game.db.player.get(game.db.keys.AccountResearchers,"{}");var e=function(e,t,r){t=t||0,r=r||0,this[e]+=r-t};this.stellars.resources.listen("metal",e,this.resources),this.stellars.resources.listen("crystal",e,this.resources),this.stellars.resources.listen("deuterium",e,this.resources),this.fligths.resources.listen("metal",e,this.resources),this.fligths.resources.listen("crystal",e,this.resources),this.fligths.resources.listen("deuterium",e,this.resources),this.startCurrentStellar()}return Object.defineProperty(e.prototype,"currentStellar",{get:function(){return this.stellars.byId(game.currentPlanetID)},enumerable:!0,configurable:!0}),e.prototype.startCurrentStellar=function(e){var t=this;void 0===e&&(e=!1);var r=account.inline.updateStellar(this.currentStellar,e);return r.done(function(e,r){null!==e[1]&&(utils.joinMaps(t.researchers,e[1]),game.db.player.set(game.db.keys.AccountResearchers,e[1])),null!==e[0]&&utils.joinMaps(t.currentStellar.technologies,e[0]),null!==r&&utils.joinMaps(t.currentStellar.production,r),t.currentStellar.save(),t.currentStellar.init()}),r},e}(),ui;!function(e){var t="ogi_implements",r=function(){function e(){this._container={},this._keyframes={},document.body.classList.add(t),["https://gist.githubusercontent.com/SergioFloresG/1ce6e2427cf5db4dbd7a416706eab876/raw/6f28353ca5f16f47f1620c745627961050d6ee15/ogimperium.flat.css","https://gist.githubusercontent.com/SergioFloresG/1ce6e2427cf5db4dbd7a416706eab876/raw/6f28353ca5f16f47f1620c745627961050d6ee15/ogimperium.technology-x40.css"].forEach(function(e,t){jQuery.get(e,function(e){var r=utils.createElement("style",{media:"screen",type:"text/css",rel:"stylesheet",name:utils.format("ogi.css-ref{0$'02n}",t)});r.innerHTML=e,document.head.appendChild(r)})})}return e.prototype.add=function(e,t){return this._container[e]=t,this},e.prototype.addGroup=function(){for(var e=[],t=0;t<arguments.length;t++)e[t-0]=arguments[t];for(var r=0;r<e.length;r++)for(var n in e[r])this.add(n,e[r][n]);return this},e.prototype.keyframe=function(e,t){return this._keyframes[e]=t,this},e.prototype.style=function(){var e=document.createElement("style");e.type="text/css",e.setAttribute("name","ogi.css-injection");for(var r=Object.keys(this._container);r.length>0;){for(var n=r.shift(),i=this._container[n],s=n.split(","),a=0;a<s.length;a++)s[a]=utils.format(".{0} {1}",t,s[a]);
var o=document.createTextNode(s.join(",\n")+"{\n");for(var l in i)o.appendData("	"+l+": "+i[l]+";\n");o.appendData("}\n"),e.appendChild(o)}for(var u=Object.keys(this._keyframes);u.length>0;){for(var c=u.shift(),d=this._keyframes[c],o=document.createTextNode(utils.format("{0}{\n",c)),p=Object.keys(d);p.length>0;){var h=p.shift(),m=d[h];o.appendData(utils.format("	{0} {\n",h));for(var f=Object.keys(m);f.length>0;){var g=f.shift(),b=m[g];o.appendData(utils.format("		{0}: {1};\n",g,b))}o.appendData("	}\n")}o.appendData("}\n"),e.appendChild(o)}return e},e}();e.css=new r,e.css.addGroup({"#planet h2 a":{width:"auto !important"},".credit":{"text-align":"center","font-size":"0.9em"},".credit > span":{color:"#fd8a1c !important"}},{".ogicon":{display:"inline-block"},".alert-default":{"background-color":"#59595a",color:"#eaecf6",border:"1px solid #e3e6f3"},".alert-success":{"background-color":"#3c763d",color:"#dff0d8",border:"1px solid #d6e9c6"},".alert-info":{"background-color":"#31708f",color:"#d9edf7",border:"1px solid #bce8f1"},".alert-warning":{"background-color":"#8a6d3b",color:"#fcf8e3",border:"1px solid #faebcc"},".alert-danger":{"background-color":"#a94442",color:"#f2dede",border:"1px solid #ebccd1"},".align-left":{"text-align":"left"},".align-center":{"text-align":"center"},".align-right":{"text-align":"right"},".bold":{"font-weight":"600"},".bold-hard":{"font-weight":"800"},".float-right":{"float":"right"},".float-left":{"float":"left"},".metal":{color:"#c6556c"},".crystal":{color:"deepskyblue"},".deuterium":{color:"cornflowerblue"},".color-blood":{color:"#8A0707"},".title":{color:"yellow"},".blur":{"-webkit-filter":"blur(4px)","-moz-filter":"blur(4px)","-ms-filter":"blur(4px)","-o-filter":"blur(4px)",filter:"blur(4px)"},".technology":{"border-color":"rgba(47,79,79,1)","border-radius":"5px","-moz-border-radius":"5px","-webkit-border-radius":"5px","border-style":"solid","border-width":"1px",position:"relative",margin:"2px",cursor:"default","font-size":"8px"},".technology span":{display:"block",position:"absolute",left:"0",width:"40px",bottom:"0","text-align":"center","background-color":"rgba(47,79,79,0.75)","font-weight":"bold","border-radius":"0 0 4px 4px","-moz-border-radius":"0 0 4px 4px","-webkit-border-radius":"0 0 4px 4px"},"table.ogi th":{"font-size":"1.2em","font-weight":"bold","text-align":"right"},".ul-vertical":{},".ul-vertical > li":{"float":"left",display:"block",width:"100%"}},{".resource16":{background:'url("https://i.imgur.com/fY04Uqv.png") no-repeat',display:"block",width:"24px",height:"16px",margin:"0 5px 0 !important"},".resource16.metal":{"background-position":"0 0"},".resource16.crystal":{"background-position":"-24px 0"},".resource16.deuterium":{"background-position":"-48px 0"},".resource16.energy":{"background-position":"-72px 0"},".resource16.mo":{"background-position":"-96px 0"}},{".animation-rotate360":{"-webkit-animation":"spin 2s linear infinite","-moz-animation":"spin 2s linear infinite",animation:"spin 2s linear infinite"}}),e.css.keyframe("@-webkit-keyframes spin",{"100% ":{"-webkit-transform":"rotate(360deg)"}}),e.css.keyframe("@keyframes spin",{"100% ":{"-webkit-transform":"rotate(360deg)",transform:"rotate(360deg)"}}),e.css.keyframe("@-moz-keyframes spin",{"100% ":{"-moz-transform":"rotate(360deg)"}})}(ui||(ui={})),ui.css.addGroup({"#menuTableImperium":{margin:"5px 0"},"#menuTableImperium > li":{"float":"none"},"#menuTableImperium .menuImage.ogi2":{background:"url(https://i.imgur.com/142a5YN.png) no-repeat"}},{".current-stellar img.icon-planet":{"border-radius":"15px","box-shadow":"0 0 6px 1px #ff9600, 0 0 3px 4px #ff9600 inset"},".current-stellar img.icon-moon":{"border-radius":"8px","box-shadow":"0 0 6px 1px #ff9600, 0 0 3px 4px #ff9600 inset"},".current-stellar .koords-stellar, .current-stellar .name-stellar":{"text-shadow":"0 0 3px rgb(153,204,0)",color:"silver !important"}},{"#ogimperium-view":{"float":"left",position:"relative",width:"670px",overflow:"visible",display:"none"},"#ogimperium-view .panel":{"background-color":"#0d1014",border:"1px solid #2b3848","border-top-width":"4px",padding:"6px",margin:"10px 6px 20px"},"#ogimperium-view table td, #ogimperium-view table th":{padding:"4px"},"#ogimperium-view table tr.summary td, #ogimperium-view table tr.summary th":{"border-top":"1px dotted #848484"},"#ogimperium-view table td.label":{color:"grey","text-align":"left"},"#ogimperium-view table tr:hover > td, #ogimperium-view table tr.hover > td":{"background-color":"#23282d"}},{".resources00-icon, .resources01-icon, .resources02-icon, .defence-icon, .station-icon,.shipyard-icon ":{width:"30px !important",height:"30px !important"},".resources00-icon":{"background-repeat":"no-repeat","background-image":" url('https://i.imgur.com/2Klisqo.png')"},".resources01-icon":{"background-repeat":"no-repeat","background-image":" url('https://i.imgur.com/Ij3fpwv.png')"},".resources02-icon":{"background-repeat":"no-repeat","background-image":" url('https://i.imgur.com/7Mavk31.jpg')"},".station-icon ":{"background-repeat":"no-repeat","background-image":" url('https://i.imgur.com/kbgzBaR.png')"},".research-icon":{"background-repeat":"no-repeat","background-image":" url('https://i.imgur.com/RBgBQKX.png')",width:"50px",height:"50px"},".shipyard-icon":{"background-repeat":"no-repeat","background-image":" url('https://i.imgur.com/OB38ylT.png')"},".defence-icon":{"background-repeat":"no-repeat","background-image":"url('https://i.imgur.com/k5dUBS9.png')"},".menu-icon32":{background:" url('https://i.imgur.com/WuayUF0.png') no-repeat",width:"24px",height:"24px",display:"inline-block"},".menu-icon32[ref=construction]":{"background-position":" 0 0"},".menu-icon32[ref=production]":{"background-position":" -24px 0"},".research-icon[ref=106]":{"background-position":" 0 0"},".research-icon[ref=108]":{"background-position":" -50px 0"},".research-icon[ref=109]":{"background-position":" -100px 0"},".research-icon[ref=110]":{"background-position":" -150px 0"},".research-icon[ref=111]":{"background-position":" -200px 0"},".research-icon[ref=113]":{"background-position":" -250px 0"},".research-icon[ref=114]":{"background-position":" -300px 0"},".research-icon[ref=115]":{"background-position":" -350px 0"},".research-icon[ref=117]":{"background-position":" -400px 0"},".research-icon[ref=118]":{"background-position":" -450px 0"},".research-icon[ref=120]":{"background-position":" -500px 0"},".research-icon[ref=121]":{"background-position":" -550px 0"},".research-icon[ref=122]":{"background-position":" -600px 0"},".research-icon[ref=123]":{"background-position":" -650px 0"},".research-icon[ref=199]":{"background-position":" -700px 0"},".research-icon[ref=124]":{"background-position":" -750px 0"},".resources01-icon[ref=12]":{"background-position":" 0px 0 "},".resources01-icon[ref=1]":{"background-position":" -30px 0 "},".resources01-icon[ref=4]":{"background-position":" -60px 0 "},".resources01-icon[ref=3]":{"background-position":" -90px 0 "},".resources01-icon[ref=2]":{"background-position":" -120px 0 "},".resources01-icon[ref=212]":{"background-position":" -150px 0 "},".resources02-icon[ref=22]":{"background-position":" 0 0 "},".resources02-icon[ref=23]":{"background-position":" -30px 0 "},".resources02-icon[ref=24]":{"background-position":" -60px 0 "},".resources02-icon[ref=25]":{"background-position":" -90px 0 "},".resources02-icon[ref=26]":{"background-position":" -120px 0 "},".resources02-icon[ref=27]":{"background-position":" -150px 0 "},".station-icon[ref=14]":{"background-position":" 0 0 "},".station-icon[ref=31]":{"background-position":" -30px 0 "},".station-icon[ref=34]":{"background-position":" -60px 0 "},".station-icon[ref=21]":{"background-position":" -90px 0 "},".station-icon[ref=15]":{"background-position":" -120px 0 "},".station-icon[ref=33]":{"background-position":" -150px 0 "},".station-icon[ref=44]":{"background-position":" -180px 0 "},".station-icon[ref=41]":{"background-position":" -210px 0 "},".station-icon[ref=42]":{"background-position":" -240px 0 "},".station-icon[ref=43]":{"background-position":" -270px 0 "}},{".techtree_link":{height:"auto","min-width":0},".techtree_link .label":{display:"none"},".costs_wrap":{"float":"none",position:"absolute"},".costs_wrap .costs_info":{height:"auto"},".production_info":{position:"absolute",height:"90px","max-width":"290px","min-width":"265px",top:"110px"},".demolish_link":{top:"162px"},".demolish_link .label":{display:"none",left:0,position:"absolute",right:0,top:"2px"},".production_info .time":{display:"inline-block","float":"right","text-align":"right"},".enter":{width:"auto",height:"auto",top:"144px",right:"10px"},".enter .amount":{margin:"0 0 2px 3px",display:"flex"},"#costs":{width:"235px",color:"white"},"#costs > li":{"float":"none",width:"235px",height:"17px",display:"inline-block","text-align":"right",padding:0,"margin-bottom":"3px"},"#costs > li .cost":{width:"100px","float":"left"},"#costs > li .need":{width:"100px","float":"left"}},{"#header_text a.ogireset-data":{right:"16px",top:"6px",position:"absolute"}},{".uibar_container, .uibar_filllevel":{"background-image":"url(//gf3.geo.gfsrv.net/cdn52/fbe2638880f7c292a43439c0f328ad.png)","background-repeat":"repeat-x"},".uibar_container":{"background-position":"0 -24px","box-shadow":"0 0 3px #000",width:"auto",height:"2px"},".uibar_filllevel":{"box-shadow":"0 0 3px #000","float":"left",height:"100%"},".uibar_fillunder":{"background-position":"0 -16px"},".uibar_fillmiddle":{"background-position":"0 -8px"},".uibar_fillover":{"background-position":"0 0"}},{".uitechnology":{}},{"#resources-summary":{},"#resources-summary .resourceIcon":{"float":"right"}},{"#resources-planets table img.icon-planet":{display:"inline-block","float":"left","margin-right":"8px",width:"30px"},"#resources-planets table img.icon-moon":{display:"inline-block","float":"left",margin:"0 8px 14px 8px",width:"16px"},"#resources-planets table .label > b":{display:"flex"},"#resources-planets table .label .ships":{"float":"right"},"#resources-planets table .label .koords-stellar":{"font-size":"0.8em"},"#resources-planets table em.em-storage":{"font-size":"0.75em",color:"dimgray"},"#resources-planets .btn-details":{background:'url("//gf2.geo.gfsrv.net/cdn71/fc7a8ede3499a0b19ea17613ff0cb1.gif") no-repeat left top',height:"18px",width:"20px",display:"block"},"#resources-planets .btn-details.open":{"background-position":"0 -18px"}},{".production-details span.tech-lvl":{"font-size":"0.75em",color:"dimgray"},".production-details span.tech-lvl::before":{content:'"["'},".production-details span.tech-lvl::after":{content:'"]"'}},{".details-stellar":{"background-color":"#22313B","background-repeat":"no-repeat",margin:"0",padding:"0",height:"300px","font-size":"0.8em"},".details-stellar.no-data":{height:"auto","text-align":"center"},".details-stellar .ul-production":{width:"200px"}});var ui;!function(e){var t;!function(e){function t(e){utils.isNode(e)?this.appendChild(e):this.innerHTML=e.toString()}!function(e){e[e.HEAD=0]="HEAD",e[e.BODY=1]="BODY",e[e.FOOT=2]="FOOT"}(e.UiTableIn||(e.UiTableIn={}));var r=e.UiTableIn,n=function(){function e(){this.table=utils.createElement("table",{width:"100%","class":"ogi"}),this.thead=this.table.createTHead(),this.tbody=this.table.createTBody(),this.tfoot=this.table.createTFoot()}return e.prototype.addRowIn=function(e,n){var i=null;if(r.HEAD==e)i=this.thead;else if(r.BODY==e)i=this.tbody;else{if(r.FOOT!=e)throw new ReferenceError("Need a valid inkey (head, body or foot)");i=this.tfoot}var s=i.insertRow();return n.forEach(function(e){var r=utils.joinMaps({type:"td",attributes:{},fnRender:t},e,!0);Array.isArray(r.data)||(r.data=[r.data]);var n=utils.createElement(r.type,r.attributes);r.fnRender.apply(n,r.data),s.appendChild(n)}),s},e.prototype.addRow=function(e,t,r){for(var n=[],i=3;i<arguments.length;i++)n[i-3]=arguments[i];var s=this.tbody.insertRow();return e.forEach(function(e,r){var n=s.insertCell();if(t&&t[r]){var i=t[r];if(i)for(var a in i)n.setAttribute(a,i[a])}utils.isNode(e)?n.appendChild(e):utils.isFunction(e)?e.apply(n):n.innerHTML=e}),r&&(n.unshift(s.childNodes),r.apply(e,n)),s},e.prototype.addRows=function(){for(var e=[],t=0;t<arguments.length;t++)e[t-0]=arguments[t];for(var r=0;r<e.length;r++){var n=n[r],i=Array.prototype.concat.call([n.items,n.cellsAttrs,n.callback],n.args);this.addRow.apply(this,i)}return this},e}();e.UiTable=n}(t=e.clazz||(e.clazz={}))}(ui||(ui={}));var ui;!function(e){var t;!function(e){function t(e,t){return new i(t,e.tech(t))}var r=utils.createElement,n="uitechnology technology tooltipRight tooltipHTML",i=function(){function e(e,t){this.box=r("div",{"class":n}),this._level=0,this.spanlvl=r("span"),this.box.setAttribute("ref",e.toString()),this.box.appendChild(this.spanlvl),this.level=t,this.box.setAttribute("title",utils.format('{0}|<p align="center">{1$nd,}</p>',game.localization.technology(e),t))}return Object.defineProperty(e.prototype,"level",{get:function(){return this._level},set:function(e){this._level=e,this.spanlvl.innerHTML=gfNumberGetHumanReadable(e,3),0>=e?(this.spanlvl.style.display="none",this.box.classList.add("off")):(this.spanlvl.style.display="block",this.box.classList.remove("off"))},enumerable:!0,configurable:!0}),e}();e.makeIcon=t}(t=e.clazz||(e.clazz={}))}(ui||(ui={}));var ui;!function(e){var t;!function(e){var t=utils.createElement,r=function(){function e(e,r){void 0===e&&(e=0),void 0===r&&(r=1),this._container=t("div",{"class":"uibar_container","data-amount":"0","data-capacity":"1"}),this._fill=t("div",{"class":"uibar_filllevel"}),this._container.appendChild(this._fill),this.amount=e,this.capacity=r}return e.prototype.paint=function(){var e=this.amount/this.capacity*100;e>=100&&(e=100),this._fill.style.width=e+"%",this._fill.classList.remove("uibar_fillunder","uibar_fillmiddle","uibar_fillover"),e>=90&&100>e?this._fill.classList.add("uibar_fillmiddle"):e>=100?this._fill.classList.add("uibar_fillover"):this._fill.classList.add("uibar_fillunder")},Object.defineProperty(e.prototype,"amount",{get:function(){return parseInt(this._container.dataset.amount)},set:function(e){this._container.dataset.amount=""+e,this.paint()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"capacity",{get:function(){return parseInt(this._container.dataset.capacity)},set:function(e){this._container.dataset.capacity=""+e,this.paint()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"container",{get:function(){return this._container},enumerable:!0,configurable:!0}),e}();e.UiBar=r}(t=e.clazz||(e.clazz={}))}(ui||(ui={}));var ui;!function(e){var t;!function(t){var r=utils.createElement,n=function(){function t(e){this._stellar=e,this.container=utils.createElement("div",{"class":"details-stellar"});var t=game.db.player.getMapKey(game.db.keys.AccountOverviewImage,e.id);if(t&&(this.container.style.backgroundImage=utils.format("url({0})",t)),Object.keys(this._stellar.technologies).length){var n=this.makeUlResources();this.container.appendChild(n)}else this.container.appendChild(utils.createElement("p",null,game.language.t("Visit the body to read their information"))),this.container.classList.add("no-data");this.container.appendChild(r("br",{"class":"clearfloat"}))}return t.prototype.makeUlResources=function(){var t=r("ul",{"class":"ul-vertical ul-production"});return this._stellar.isMoon||this.buildLiProduction(t),t.appendChild(r("li",null,e.clazz.makeIcon(this._stellar,22).box)),t.appendChild(r("li",null,e.clazz.makeIcon(this._stellar,23).box)),t.appendChild(r("li",null,e.clazz.makeIcon(this._stellar,24).box)),t.appendChild(r("li",null,e.clazz.makeIcon(this._stellar,4).box)),t.appendChild(r("li",null,e.clazz.makeIcon(this._stellar,12).box)),t.appendChild(r("li",null,e.clazz.makeIcon(this._stellar,212).box)),t},t.prototype.buildLiProduction=function(t){var n=this,i=function(t,i){var s=e.clazz.makeIcon(n._stellar,1),a=Math.round(3600*n._stellar.production[i]),o=r("div",{"class":"undermark bold"},utils.format("+{0$n}",number_format(a))),l=(n._stellar.storage[i]-n._stellar.resources[i])/n._stellar.production[i],u=new Date(startServerTime+Math.ceil(1e3*l)+timeDiff),c=r("div",null,u.toISOString());return s.box.classList.add("float-right"),r("li",null,s.box,o,c)};t.appendChild(i(1,"metal")),t.appendChild(i(2,"crystal")),t.appendChild(i(3,"deuterium"))},t}();t.DetailsStellar=n}(t=e.clazz||(e.clazz={}))}(ui||(ui={}));var ui;!function(e){var t;!function(e){var t=utils.createElement,r=function(){function r(e){this.metal_hour=t("span",{"class":"undermark hour"}),this.crystal_hour=t("span",{"class":"undermark hour"}),this.deuterium_hour=t("span",{"class":"undermark hour"}),this.metal_total=t("span",{"class":"metal total"}),this.crystal_total=t("span",{"class":"crystal total"}),this.deuterium_total=t("span",{"class":"deuterium total"}),this.metal_planet=t("span"),this.crystal_planet=t("span"),this.deuterium_planet=t("span"),this.metal_moon=t("span"),this.crystal_moon=t("span"),this.deuterium_moon=t("span"),this.metal_flying=t("span"),this.crystal_flying=t("span"),this.deuterium_flying=t("span"),this.energy_total=t("span",{"class":"energy total"}),this.main=null,this.account=e}return r.prototype.row=function(e,r,n){for(var i=[],s=3;s<arguments.length;s++)i[s-3]=arguments[s];for(var a=t("tr"),o=[],l=0;l<e.length;l++){var u=jQuery("<td/>",r[l]);u.append(e[l]),a.appendChild(u.get(0)),o.push(u.get(0))}return i.unshift(o),n.apply(e,i),a},r.prototype.makeTable=function(){var r=this;this.main=t("div",{"class":"panel",id:"resources-summary"});var n=new e.UiTable,i=n.table;this.main.appendChild(i);var s=this;n.addRowIn(e.UiTableIn.HEAD,[{type:"th",data:"&nbsp;"},{type:"th",attributes:{width:120},data:t("div",{"class":"resourceIcon metal"})},{type:"th",attributes:{width:120},data:t("div",{"class":"resourceIcon crystal"})},{type:"th",attributes:{width:120},data:t("div",{"class":"resourceIcon deuterium"})},{type:"th",attributes:{width:1},data:""}]);var a=n.addRow([game.language.t("Production /h"),this.metal_hour,this.crystal_hour,this.deuterium_hour,""],[{"class":"label bold-hard"},{"class":"bold"},{"class":"bold"},{"class":"bold"},{"class":"bold"}],function(e,t){var r=this;t.listen("metal",function(e,t,n){r[1].innerHTML="+ "+number_format(Math.round(3600*n))}),t.listen("crystal",function(e,t,n){r[2].innerHTML="+ "+number_format(Math.round(3600*n))}),t.listen("deuterium",function(e,t,n){r[3].innerHTML="+ "+number_format(Math.round(3600*n))})},this.account.stellars.production);a.className="align-right alt",a=n.addRow(["&#931; "+game.language.t("Total"),this.metal_total,this.crystal_total,this.deuterium_total,""],[{"class":"label bold-hard"},{"class":"bold"},{"class":"bold"},{"class":"bold"},{"class":"bold"}],function(e,t){var r=this;t.listen("metal",function(e,t,n){r[1].innerHTML=number_format(n)}),t.listen("crystal",function(e,t,n){r[2].innerHTML=number_format(n)}),t.listen("deuterium",function(e,t,n){r[3].innerHTML=number_format(n)})},this.account.resources),a.className="align-right",function(){var e=function(e,t){for(var r=s.account.stellars.planets,n=!1,i=0,a=0;a<r.length;a++){var o=r[a].storage[e];isNaN(o)?n=!0:i+=o}var l=utils.createElement("i",{style:"font-size:0.75em;color:dimgray;"},utils.format("/ {0}{1} ",n?"~":"",number_format(i)));this.appendChild(t),this.appendChild(utils.createElement("br")),this.appendChild(l)};a=n.addRow([game.language.t("Planets"),function(){e.apply(this,["metal",s.metal_planet])},function(){e.apply(this,["crystal",s.crystal_planet])},function(){e.apply(this,["deuterium",s.deuterium_planet])},""],[{"class":"label"}],function(e,t){t.listen("metal",function(e,t,r){s.metal_planet.innerHTML=number_format(r)}),t.listen("crystal",function(e,t,r){s.crystal_planet.innerHTML=number_format(r)}),t.listen("deuterium",function(e,t,r){s.deuterium_planet.innerHTML=number_format(r)})},r.account.stellars.resourcesInPlanets),a.className="summary align-right alt"}(),a=n.addRow([game.language.t("Moons"),this.metal_moon,this.crystal_moon,this.deuterium_moon,""],[{"class":"label"}],function(e,t){var r=this;t.listen("metal",function(e,t,n){r[1].innerHTML=number_format(n)}),t.listen("crystal",function(e,t,n){r[2].innerHTML=number_format(n)}),t.listen("deuterium",function(e,t,n){r[3].innerHTML=number_format(n)})},this.account.stellars.resourcesInMoons),a.className="align-right",a=n.addRow([game.language.t("Flights"),this.metal_flying,this.crystal_flying,this.deuterium_flying,""],[{"class":"label"}],function(e,t){var r=this;t.listen("metal",function(e,t,n){r[1].innerHTML=number_format(n)}),t.listen("crystal",function(e,t,n){r[2].innerHTML=number_format(n)}),t.listen("deuterium",function(e,t,n){r[3].innerHTML=number_format(n)})},this.account.fligths.resources),a.className="align-right alt"},Object.defineProperty(r.prototype,"table",{get:function(){return this.main||this.makeTable(),this.main},enumerable:!0,configurable:!0}),r}();e.ResourcesProduction=r}(t=e.clazz||(e.clazz={}))}(ui||(ui={}));var ui;!function(e){var t;!function(e){function t(e,t){var r=utils.createElement("span");r.innerHTML=number_format(Math.round(3600*e.production[t])),e.production.listen(t,function(e,t,n){r.innerHTML=number_format(Math.round(3600*n))}),this.appendChild(r)}var r=function(){function r(e){this.main=null,this.account=e}return Object.defineProperty(r.prototype,"table",{get:function(){if(!this.main){var e=this.makeTable();this.main=utils.createElement("div",{"class":"panel production-details"},e)}return this.main},enumerable:!0,configurable:!0}),r.prototype.makeTable=function(){var r=new e.UiTable;r.addRowIn(e.UiTableIn.HEAD,[{type:"th",data:"&nbsp;"},{type:"th",data:game.language.t("METAL"),attributes:{colspan:2,width:120}},{type:"th",data:game.language.t("CRYSTAL"),attributes:{colspan:2,width:120}},{type:"th",data:game.language.t("DEUTERIUM"),attributes:{colspan:2,width:120}},{type:"th",attributes:{width:1},data:""}]);var n=!0,i=utils.resources3Observable(0);this.account.stellars.planets.forEach(function(s){i.metal+=s.production.metal,i.crystal+=s.production.crystal,i.deuterium+=s.production.deuterium;var a=r.addRowIn(e.UiTableIn.BODY,[{data:s.name,attributes:{"class":"label name-stellar bold"}},{data:[s,"metal"],fnRender:t,attributes:{width:90}},{data:utils.createElement("span",{"class":"tech-lvl"},s.tech(1)),attributes:{width:20}},{data:[s,"crystal"],fnRender:t,attributes:{width:90}},{data:utils.createElement("span",{"class":"tech-lvl"},s.tech(2)),attributes:{width:20}},{data:[s,"deuterium"],fnRender:t,attributes:{width:90}},{data:utils.createElement("span",{"class":"tech-lvl"},s.tech(3)),attributes:{width:20}},{data:""}]);a.classList.add("align-right"),n&&a.classList.add("alt"),s.id==game.currentPlanetID&&a.classList.add("current-stellar"),n=!n});var s=function(e,t,r){var n=utils.createElement("span",{"class":"undermark"});n.innerHTML=number_format(Math.round(e[t]*r)),e.listen(t,function(e,t,i){n.innerHTML=number_format(Math.round(i*r))}),this.appendChild(n)};return[{time:3600,text:"Production per hour:"},{time:86400,text:"Daily production:"},{time:604800,text:"Weekly production:"}].forEach(function(t){r.addRowIn(e.UiTableIn.FOOT,[{data:game.language.t(t.text),attributes:{"class":"label"}},{data:[i,"metal",t.time],fnRender:s},{data:""},{data:[i,"crystal",t.time],fnRender:s},{data:""},{data:[i,"deuterium",t.time],fnRender:s},{data:"",attributes:{colspan:2}}]).classList.add("align-right")}),r.tfoot.firstElementChild.classList.add("summary"),r.table},r}();e.ResourcesProductionDetails=r}(t=e.clazz||(e.clazz={}))}(ui||(ui={}));var ui;!function(e){var t;!function(t){var r=utils.createElement,n=function(){function n(e){this._container=null,this._account=e}return Object.defineProperty(n.prototype,"container",{get:function(){return this._container||this.initContainer(),this._container},enumerable:!0,configurable:!0}),n.prototype.initContainer=function(){var e=this;this._container=r("div",{id:"resources-planets","class":"panel"});var n=new t.UiTable;this._container.appendChild(n.table),n.addRow(["&nbsp;",game.language.t("METAL"),game.language.t("CRYSTAL"),game.language.t("DEUTERIUM"),"&nbsp;"],[null,{width:"120"},{width:"120"},{width:"120"},{width:"1"}]);var i=!0;this._account.stellars.planets.forEach(function(t,r){var s=e.makeRowPlanet(n,t);if(s.classList.add("align-right"),i&&s.classList.add("alt"),game.currentPlanetID==t.id&&s.classList.add("current-stellar"),t.moonID){var a=e._account.stellars.byId(t.moonID);s=e.makeRowMoon(n,a),s.classList.add("align-right"),i&&s.classList.add("alt"),game.currentPlanetID==a.id&&s.classList.add("current-stellar")}i=!i}),initTooltips(this.container),jQuery(this.container).on("click",".btn-details",function(e){var t=e.target,r=t.href,n=utils.format("stellar-{0}-details",utils.parseInteger(r)),i=document.getElementById(n);console.info("show details",t,i),t.classList.contains("open")?(i.style.display="none",t.classList.remove("open"),changeTooltip(t,game.language.t("more details"))):(i.style.display="table-row",t.classList.add("open"),changeTooltip(t,game.language.t("less details")))})},n.prototype.makeRowPlanet=function(e,n){var i=r("img",{"class":"icon-planet",src:n.image}),s=r("span",{"class":"koords-stellar"}),a=r("b",{"class":"name-stellar"});r("a",{"class":"btn-details tooltipRight",href:"javascript:void("+n.id+");",title:game.language.t("more details")});s.innerHTML=n.coords.toString(),a.innerHTML=n.name;var o={metal:r("b"),crystal:r("b"),deuterium:r("b")},l={metal:r("em",{"class":"em-storage"}),crystal:r("em",{"class":"em-storage"}),deuterium:r("em",{"class":"em-storage"})},u={metal:new t.UiBar,crystal:new t.UiBar,deuterium:new t.UiBar},c=function(e,t,r){var n=parseInt(l[e].dataset.max),i=r/n*100;o[e].innerHTML=number_format(r),o[e].classList.remove("overmark","middlemark"),l[e].classList.remove("overmark","middlemark"),i>=90&&100>i?(o[e].classList.add("middlemark"),l[e].classList.add("middlemark")):i>=100&&(o[e].classList.add("overmark"),l[e].classList.add("overmark")),u[e].amount=r},d=function(e){var t=r("div"),i=n.storage[e];return isNaN(i)?(u[e].capacity=-1,l[e].dataset.max="-1",l[e].innerHTML=" /~"):(u[e].capacity=i,l[e].dataset.max=""+i,l[e].innerHTML=" /"+gfNumberGetHumanReadable(i,3)),t.appendChild(o[e]),t.appendChild(l[e]),t.appendChild(u[e].container),t};return n.resources.listen("metal",c),n.resources.listen("crystal",c),n.resources.listen("deuterium",c),e.addRow([function(){this.appendChild(i),this.appendChild(a),this.appendChild(s)},d("metal"),d("crystal"),d("deuterium")],[{"class":"label"}])},n.prototype.makeRowMoon=function(e,t){var n=r("img",{"class":"icon-moon",src:t.image}),i=r("b",{"class":"name-stellar"});r("a",{"class":"btn-details tooltipRight",href:"javascript:void("+t.id+");",title:game.language.t("more details")});i.innerHTML=t.name;var s={metal:r("span"),crystal:r("span"),deuterium:r("span")},a=function(e,t,r){s[e].innerHTML=number_format(r)};return t.resources.listen("metal",a),t.resources.listen("crystal",a),t.resources.listen("deuterium",a),e.addRow([utils.node2HTMLText(n,i),s.metal,s.crystal,s.deuterium],[{"class":"label"}])},n.prototype.makeRowDetails=function(t,r){var n=new e.clazz.DetailsStellar(r),i=t.addRow([n.container],[{colspan:"6",style:"padding:0"}]);return i.id=utils.format("stellar-{0}-details",r.id),i.style.display="none",i},n}();t.ResourcesStellars=n}(t=e.clazz||(e.clazz={}))}(ui||(ui={}));var ui;!function(e){var t;!function(e){function t(e){!function(e,t){if(e){var r=t.style.backgroundImage.match(/(http.*[\.jpg|\.png|\.gif])/g)[0],n=game.db.player.get(game.db.keys.AccountOverviewImage,"{}");n[game.currentPlanetID]||(n[game.currentPlanetID]=r,game.db.player.set(game.db.keys.AccountOverviewImage,n))}}(game.isCurrentPage("overview"),document.getElementById("planet")),function(t){if(t){var r=utils.createElement("span",{"class":"flat24 sign-sync"}),n=utils.createElement("a",{"class":"ogireset-data tooltipLeft",href:"javascript:void(0);",title:game.language.t("Refresh data stored of this planet/moon")},r);t.insertBefore(n,t.firstChild),initTooltips(n);var i=!1;n.onclick=function(t){i||(i=!0,r.classList.add("animation-rotate360"),setTimeout(function(){var t=e.startCurrentStellar(!0);t.fail(function(){r.classList.add("sign-error"),fadeBox(game.language.t("Failed to refresh data of the planet/moon."),!0)}).done(function(){r.classList.add("sign-check"),fadeBox(game.language.t("Data of the planet/moon updated successfully."),!1)}).always(function(){r.classList.remove("animation-rotate360","sign-sync"),setTimeout(function(){r.classList.remove("sign-check","sign-error"),r.classList.add("sign-sync"),i=!1},4e3)})},1500))}}}(document.getElementById("header_text")),function(){setInterval(function(){jQuery.ajax({url:"/game/index.php?page=fetchEventbox&ajax=1",global:!1,dataType:"text"}).done(reloadEventbox)},3e4)}()}e.shortcodes=t}(t=e.inline||(e.inline={}))}(ui||(ui={}));var ui;!function(e){var t;!function(t){function r(e,t,r){var n=this.need_nodes[e];n.innerHTML=number_format(r),n.classList.remove("undermark","overmark","middlemark","bold"),0>r?n.classList.add("overmark","bold"):n.classList.add("undermark");var i=this.cost_nodes[e];if(i){var s=this.count*this.cost_base[e];i.innerHTML=number_format(s),i.classList.remove("overmark"),0>r&&i.classList.add("overmark")}}function n(){var e=document.getElementById("planet");e&&(l||(e.addEventListener("DOMNodeInserted",function(e){setTimeout(function(){try{if(!r||!r.target)return;if("content"!==r.target.id)return;var e=r.target,t=utils.getIntByQuery("[name-type]","value");o.show(e,t)}catch(r){var n=utils.tracing(r);console.error("Error => Buildings.run()#timeout @ ",n.toString())}},0)},!1),l=!0))}var i=game.utilities.currentResources,s=utils.format,a=function(){function t(){this.need_nodes={},this.need_nodes.metal=utils.createElement("div",{"class":"need metal"}),this.need_nodes.crystal=utils.createElement("div",{"class":"need crystal"}),this.need_nodes.deuterium=utils.createElement("div",{"class":"need deuterium"}),this.need_nodes.energy=utils.createElement("div",{"class":"need energy"}),this.bold_maxbuild=utils.createElement("b"),this.cost_base=utils.resources4(0),this.cost_diff=utils.resources4Observable(0),this.cost_diff.listen("metal",r,this),this.cost_diff.listen("crystal",r,this),this.cost_diff.listen("deuterium",r,this),this.cost_diff.listen("energy",r,this),this.cost_n=utils.createElement("i",{style:"color: white;"})}return t.prototype.updateCost=function(){var e=i();this.cost_n.innerHTML=s(" ( x{0} )",number_format(this.count)),this.cost_diff.metal=e.metal-this.cost_base.metal*this.count,this.cost_diff.crystal=e.crystal-this.cost_base.crystal*this.count,this.cost_diff.deuterium=e.deuterium-this.cost_base.deuterium*this.count,this.cost_diff.energy=e.energy-this.cost_base.energy*this.count;var t=Math.min.apply(null,[Math.abs(e.metal/this.cost_base.metal),Math.abs(e.crystal/this.cost_base.crystal),Math.abs(e.deuterium/this.cost_base.deuterium),Math.abs(e.energy_generate/this.cost_base.energy)]);this.bold_maxbuild.innerHTML=number_format(Math.floor(t))},t.prototype.show=function(t,r){var n=this;this.container=t,this.id=r,this.count=1,this.cost_base.metal=this.cost_base.crystal=0,this.cost_base.deuterium=this.cost_base.energy=0,this.cost_nodes={},this.input_number=document.getElementById("number");for(var i=t.querySelectorAll("#costs > li"),s=new e.clazz.UiTable,a=0;a<i.length;a++){var o=i.item(a),l=o.querySelector(".resourceIcon"),u=o.querySelector(".cost"),c=null;l.classList.add("resource16"),removeTooltip(o);var d=utils.getTitle(o);o.classList.remove("tooltip"),o.removeAttribute("title");var p=utils.parseInteger(d);initTooltips(o),l.classList.contains("metal")?(c=this.need_nodes.metal,this.cost_nodes.metal=u,this.cost_base.metal=p):l.classList.contains("crystal")?(c=this.need_nodes.crystal,this.cost_nodes.crystal=u,this.cost_base.crystal=p):l.classList.contains("deuterium")?(c=this.need_nodes.deuterium,this.cost_nodes.deuterium=u,this.cost_base.deuterium=p):l.classList.contains("energy")&&(c=this.need_nodes.energy,this.cost_nodes.energy=u,this.cost_base.energy=p,
o.removeChild(o.querySelector("br"))),c&&(c.innerHTML="0",o.appendChild(c),s.addRow(d.split(" "),[{"class":"align-right"},{"class":"align-left",style:"padding-left: 5px"}]))}var h=t.querySelector("#costs");if(h.classList.add("tooltipLeft"),changeTooltip(h,utils.node2HTMLText(s.table)),t.querySelector(".costs_info").appendChild(this.cost_n),this.input_number){var m=this.input_number.parentElement.querySelector(".amount");m.textContent="max: ",m.appendChild(this.bold_maxbuild),jQuery(this.input_number).on("keyup",function(e){var t=utils.parseInteger(n.input_number.value);n.count=t||1,n.updateCost()}).on("focus",function(e){n.count=1,n.updateCost()}),this.input_number.setAttribute("autocomplete","off"),this.count=utils.parseInteger(this.input_number.value)||1}this.updateCost()},t}(),o=new a,l=!1;t.costructionAssistant=n}(t=e.inline||(e.inline={}))}(ui||(ui={}));var GameUi=function(){function e(e){this.isrun=!1,this._account=e,utils.define(this,"_account"),utils.define(this,"isrun",!1,!0,!0),this.container=utils.createElement("div",{id:"ogimperium-view"})}return e.prototype.show=function(e){void 0===e&&(e=null),document.getElementById("inhalt").style.display="none",this.container.style.display="block",e&&e.preventDefault()},e.prototype.hide=function(e){void 0===e&&(e=null),document.getElementById("inhalt").style.display="block",this.container.style.display="none",e&&e.preventDefault()},e.prototype.run=function(){if(!this.isrun){initUi(this._account,this);var e=document.getElementById("contentWrapper");e.insertBefore(this.container,e.firstChild),this.isrun=!0,utils.define(this,"isrun")}},e}();void 0==currentPage&&(currentPage=document.location.href.match(/page=(\w+)/gi)[0]);var __VERSION__="2.0.1";game.ajax.then(function(){return setTimeout(function(){utils._window.imperium=__VERSION__;try{var e=new GameAccount,t=new GameUi(e);t.run()}catch(r){var n=utils.tracing(r);console.error("ERROR! (Imperium "+__VERSION__+" ): ",n.toString())}},10)});