DIO-TOOLS

DIO-Tools is a small extension for the browser game Grepolis. (counter, displays, smilies, trade options, changes to the layout)

当前为 2015-06-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name DIO-TOOLS
  3. // @namespace DIO
  4. // @version 2.32
  5. // @author Diony
  6. // @description DIO-Tools is a small extension for the browser game Grepolis. (counter, displays, smilies, trade options, changes to the layout)
  7. // @include https://de.grepolis.com/game*
  8. // @include http://*.grepolis.com/game*
  9. // @include https://*.grepolis.com/game*
  10. // @include https://*forum.*.grepolis.com/*.php*
  11. // @include http://diotools.pf-control.de/*
  12. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
  13. // @icon http://s7.directupload.net/images/140128/vqchpigi.gif
  14. // @icon64 http://diotools.pf-control.de/images/icon_dio_64x64.png
  15. // @copyright 2013+, DIONY
  16. // @grant GM_info
  17. // @grant GM_setValue
  18. // @grant GM_getValue
  19. // @grant GM_deleteValue
  20. // @grant GM_xmlhttpRequest
  21. // ==/UserScript==
  22.  
  23. var version = '2.32';
  24.  
  25. //if(unsafeWindow.DM) console.dir(unsafeWindow.DM.status('l10n'));
  26. //console.dir(DM.status('templates'));
  27.  
  28. //http://s7.directupload.net/images/140128/vqchpigi.gif - DIO-Tools-Smiley
  29.  
  30. //http://de44.grepolis.com/cache/js/libs/jquery-1.10.2.min.js
  31.  
  32.  
  33. //console.log(JSON.stringify(DM.getl10n()));
  34.  
  35. /*******************************************************************************************************************************
  36. * Changes
  37. * ----------------------------------------------------------------------------------------------------------------------------
  38. * | ● ...
  39. * | ● ...
  40. * | ● ...
  41. * | ● ...
  42. * ----------------------------------------------------------------------------------------------------------------------------
  43. *******************************************************************************************************************************/
  44.  
  45. /*******************************************************************************************************************************
  46. * Bugs / TODOs
  47. * ----------------------------------------------------------------------------------------------------------------------------
  48. * | ● Aktivitätsbox für Angriffe blendet nicht aus
  49. * | ● Smileys verschwinden manchmal? -> bisher nicht reproduzierbar
  50. * | ● Performanceeinbruch nach dem Switchen des WW-Fensters
  51. * | ● keine Smileys im Grepoforum mit Safari (fehlendes jQuery)
  52. * ----------------------------------------------------------------------------------------------------------------------------
  53. *******************************************************************************************************************************/
  54.  
  55. /*******************************************************************************************************************************
  56. * Global stuff
  57. *******************************************************************************************************************************/
  58. var uw = unsafeWindow || window, $ = uw.jQuery || jQuery, DATA, GM;
  59.  
  60. // GM-API?
  61. GM = (typeof GM_info === 'object') ? true : false;
  62.  
  63. // LOAD DATA
  64. if(GM && (uw.location.pathname === "/game/index")){
  65. var WID = uw.Game.world_id, MID = uw.Game.market_id, AID = uw.Game.alliance_id;
  66.  
  67. DATA = {
  68. // GLOBAL
  69. options : JSON.parse(GM_getValue("options", "{}")),
  70.  
  71. user : JSON.parse(GM_getValue("dio_user", "{}")),
  72. count: JSON.parse(GM_getValue("dio_count", "[]")),
  73.  
  74. notification : GM_getValue('notification', 0),
  75.  
  76. error: JSON.parse(GM_getValue('error', '{}')),
  77.  
  78. spellbox : JSON.parse(GM_getValue("spellbox", '{ "top":"23%", "left": "-150%", "show": false }')),
  79. commandbox: JSON.parse(GM_getValue("commandbox" , '{ "top":55, "left": 250 }')),
  80. tradebox : JSON.parse(GM_getValue("tradebox", '{ "top":55, "left": 450 }')),
  81.  
  82. // WORLD
  83. townTypes : JSON.parse(GM_getValue(WID + "_townTypes", GM_getValue("town_types", "{}"))),
  84. sentUnits : JSON.parse(GM_getValue(WID + "_sentUnits", GM_getValue(WID + "_sentUnitsArray", '{ "attack": {}, "support": {} }'))),
  85. biremes : JSON.parse(GM_getValue(WID + "_biremes", GM_getValue(WID + "_biri_data", "{}"))),
  86.  
  87. worldWonder : JSON.parse(GM_getValue(WID + "_wonder", '{ "ratio": {}, "storage": {}, "map": {} }')),
  88.  
  89. // MARKET
  90. worldWonderTypes : JSON.parse(GM_getValue(MID + "_wonderTypes", '{}'))
  91. };
  92.  
  93. if(!DATA.worldWonder.map) {
  94. DATA.worldWonder.map = {};
  95. }
  96.  
  97. // Temporary:
  98. if(GM_getValue(WID + "_ww_res")){
  99. DATA.worldWonder.ratio[AID] = parseInt(GM_getValue(WID + "_ratio", -1), 10);
  100. DATA.worldWonder.storage[AID] = JSON.parse(GM_getValue(WID + "_ww_res", "{}"));
  101.  
  102. GM_deleteValue(WID + "_ratio");
  103. GM_deleteValue(WID + "_ww_res");
  104. }
  105. //console.log(DATA.worldWonder);
  106.  
  107. GM_deleteValue("movebox");
  108. GM_deleteValue(WID + "_sentUnitsArray");
  109. GM_deleteValue(WID + "_biri_data");
  110. GM_deleteValue("town_types");
  111. GM_deleteValue('DIO-Notification');
  112. }
  113.  
  114. // GM: EXPORT FUNCTIONS
  115. uw.saveValueGM = function(name, val){
  116. setTimeout(function(){
  117. GM_setValue(name, val);
  118.  
  119. // Reload after saving settings
  120. if(name == "options") {
  121. window.location.reload();
  122. }
  123. }, 0);
  124. };
  125.  
  126. uw.deleteValueGM = function(name){
  127. setTimeout(function(){
  128. GM_deleteValue(name);
  129. },0, name);
  130. };
  131.  
  132. uw.chatUserRequest = function(){
  133. setTimeout(function(){
  134. GM_xmlhttpRequest({
  135. method: "GET",
  136. url: "http://api.relay-chat.de/compteur_js.php?chan="+ (uw.Game.market_id === "de" ? "Grepolis" + uw.Game.market_id.toUpperCase() : "GREPO"),
  137. onload: function(text){
  138. $('.nui_main_menu .chat .indicator').get(0).innerHTML = text.response.split("'")[1];
  139. $('.nui_main_menu .chat .indicator').get(0).style.display = 'block';
  140. },
  141. onerror: function(){
  142. $('.nui_main_menu .chat .indicator').get(0).style.display = 'none';
  143. }
  144. });
  145. }, 0);
  146. };
  147.  
  148. if(typeof exportFunction == 'function'){
  149. // Firefox > 30
  150. uw.DATA = cloneInto(DATA, unsafeWindow);
  151. exportFunction(uw.saveValueGM, unsafeWindow, {defineAs: "saveValueGM"});
  152. exportFunction(uw.deleteValueGM, unsafeWindow, {defineAs: "deleteValueGM"});
  153. exportFunction(uw.chatUserRequest, unsafeWindow, {defineAs: "chatUserRequest"});
  154. } else {
  155. // Firefox < 30, Chrome, Opera, ...
  156. uw.DATA = DATA;
  157. }
  158.  
  159. var time_a, time_b;
  160.  
  161. // APPEND SCRIPT
  162. function appendScript(){
  163. //console.log("GM-API: " + gm_bool);
  164. if(document.getElementsByTagName('body')[0]){
  165. var dioscript = document.createElement('script');
  166. dioscript.type ='text/javascript';
  167. dioscript.id = 'diotools';
  168.  
  169. time_a = uw.Timestamp.client();
  170. dioscript.textContent = DIO_GAME.toString().replace(/uw\./g, "") + "\n DIO_GAME("+ version +", "+ GM +", "+ time_a +");";
  171. document.body.appendChild(dioscript);
  172. } else {
  173. setTimeout(function(){
  174. appendScript();
  175. }, 500);
  176. }
  177. }
  178.  
  179. if(location.host === "diotools.pf-control.de"){
  180. // PAGE
  181. DIO_PAGE();
  182. } else {
  183. if((location.pathname !== "/game/index") && GM){
  184. // FORUM
  185. DIO_GAME(version);
  186. } else {
  187. // GAME
  188. appendScript();
  189. }
  190. }
  191.  
  192. function DIO_PAGE(){
  193. if(typeof GM_info == 'object') {
  194. setTimeout(function() {
  195. dio_user = JSON.parse(GM_getValue("dio_user", ""));
  196. console.log(dio_user);
  197. uw.dio_version = parseFloat(version);
  198. }, 0);
  199. } else {
  200. dio_user = localStorage.getItem("dio_user") || "";
  201.  
  202. dio_version = parseFloat(version);
  203. }
  204. }
  205. function DIO_FORUM(){
  206. if($(".editor_textbox_container").get(0)){
  207. loadSmileys();
  208. changeForumEditorLayout();
  209. addSmileyBoxForum();
  210. }
  211. }
  212. function DIO_GAME(version, gm, time_a){
  213. var MutationObserver = uw.MutationObserver || window.MutationObserver,
  214.  
  215. WID, MID, AID, PID, LID,
  216.  
  217. dio_sprite = "http://abload.de/img/dio_spritejmqxp.png"; // http://img1.myimg.de/DIOSPRITEe9708.png -> Forbidden!?
  218.  
  219. if(uw.location.pathname === "/game/index"){
  220. WID = uw.Game.world_id;
  221. MID = uw.Game.market_id;
  222. AID = uw.Game.alliance_id;
  223. PID = uw.Game.player_id;
  224. LID = uw.Game.locale_lang.split("_")[0]; // LID ="es";
  225.  
  226. // World with Artemis ??
  227. Game.hasArtemis = Game.constants.gods.length == 6;
  228. }
  229.  
  230. $.prototype.reverseList = [].reverse;
  231.  
  232. // LOAD DATA for Safari:
  233. if((typeof DATA === 'undefined') && (uw.location.pathname === "/game/index")){
  234.  
  235. DATA = {
  236. //GLOBAL
  237. options : JSON.parse(localStorage.getItem("options") || "{}"),
  238.  
  239. user : JSON.parse(localStorage.getItem("dio_user") || "{}"),
  240. count: JSON.parse(localStorage.getItem("dio_count") || "[]"),
  241.  
  242. notification : localStorage.getItem('notification') || localStorage.getItem('DIO-Notification') || 0,
  243.  
  244. error: JSON.parse(localStorage.getItem('error') || '{}'),
  245.  
  246. spellbox : JSON.parse(localStorage.getItem("spellbox") || '{ "top":"23%", "left": "-150%", "show": false }' ),
  247. commandbox: JSON.parse(localStorage.getItem("commandbox") || '{ "top":55, "left": 250 }' ),
  248. tradebox : JSON.parse(localStorage.getItem("tradebox") || '{ "top":55, "left": 450 }' ),
  249.  
  250. //WORLD
  251. townTypes : JSON.parse(localStorage.getItem(WID + "_townTypes") || localStorage.getItem("town_types") || "{}" ),
  252. sentUnits : JSON.parse(localStorage.getItem(WID + "_sentUnits") || localStorage.getItem(WID + "_sentUnitsArray") || '{ "attack": {}, "support": {} }' ),
  253. biremes : JSON.parse(localStorage.getItem(WID + "_biremes") || localStorage.getItem(WID + "_biri_data") || "{}" ),
  254.  
  255. worldWonder : JSON.parse(localStorage.getItem(WID + "_wonder") || '{ "ratio": {}, "storage": {}, "map": {} }'),
  256.  
  257. // MARKET
  258. worldWonderTypes : JSON.parse(localStorage.getItem(MID + "_wonderTypes") || '{}')
  259. };
  260.  
  261. if(!DATA.worldWonder.map) {
  262. DATA.worldWonder.map = {};
  263. }
  264.  
  265. // Temporary:
  266. if(GM_getValue(WID + "_ww_res")){
  267. DATA.worldWonder.ratio[AID] = parseInt((localStorage.getItem(WID + "_ratio") || -1), 10);
  268. DATA.worldWonder.storage[AID] = JSON.parse(localStorage.getItem(WID + "_ww_res") || "{}");
  269.  
  270. localStorage.removeItem(WID + "_ratio");
  271. localStorage.removeItem(WID + "_ww_res");
  272. }
  273.  
  274. }
  275.  
  276. function saveValue(name, val){
  277. if(gm){
  278. saveValueGM(name, val);
  279. } else {
  280. localStorage.setItem(name, val);
  281. }
  282. }
  283.  
  284. function deleteValue(name){
  285. if(gm){
  286. deleteValueGM(name);
  287. } else {
  288. localStorage.removeItem(name);
  289. }
  290. }
  291.  
  292. /*******************************************************************************************************************************
  293. * Graphic filters
  294. *******************************************************************************************************************************/
  295. if(uw.location.pathname === "/game/index"){
  296. $('<svg width="0%" height="0%">'+
  297. '<filter id="GrayScale">'+
  298. '<feColorMatrix type="matrix" values="0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0">'+
  299. '</filter>'+
  300. '<filter id="Sepia">'+
  301. '<feColorMatrix type="matrix" values="0.343 0.669 0.119 0 0 0.249 0.626 0.130 0 0 0.172 0.334 0.111 0 0 0.000 0.000 0.000 1 0">'+
  302. '</filter>'+
  303. '<filter id="Saturation"><feColorMatrix type="saturate" values="0.2"></filter>'+
  304. '<filter id="Saturation1"><feColorMatrix type="saturate" values="1"></filter>'+
  305. '<filter id="Saturation2"><feColorMatrix type="saturate" values="2"></filter>'+
  306. '<filter id="Hue1"><feColorMatrix type="hueRotate" values= "65"></filter>'+
  307. '<filter id="Hue2"><feColorMatrix type="hueRotate" values="150"></filter>'+
  308. '<filter id="Hue3"><feColorMatrix type="hueRotate" values="-65"></filter>'+
  309. '<filter id="Brightness15">'+
  310. '<feComponentTransfer>'+
  311. '<feFuncR type="linear" slope="1.5"/><feFuncG type="linear" slope="1.5"/><feFuncB type="linear" slope="1.5"/>'+
  312. '</feComponentTransfer>'+
  313. '</filter>'+
  314. '<filter id="Brightness12">'+
  315. '<feComponentTransfer>'+
  316. '<feFuncR type="linear" slope="1.2"/><feFuncG type="linear" slope="1.2"/><feFuncB type="linear" slope="1.2"/>'+
  317. '</feComponentTransfer>'+
  318. '</filter>'+
  319. '<filter id="Brightness11">'+
  320. '<feComponentTransfer>'+
  321. '<feFuncR type="linear" slope="1.1"/><feFuncG type="linear" slope="1.1"/><feFuncB type="linear" slope="1.1"/>'+
  322. '</feComponentTransfer>'+
  323. '</filter>'+
  324. '<filter id="Brightness10">'+
  325. '<feComponentTransfer>'+
  326. '<feFuncR type="linear" slope="1.0"/><feFuncG type="linear" slope="1.0"/><feFuncB type="linear" slope="1.0"/>'+
  327. '</feComponentTransfer>'+
  328. '</filter>'+
  329. '</svg>').appendTo('#ui_box');
  330. }
  331.  
  332. /*******************************************************************************************************************************
  333. * Language versions: german, english, french, russian, polish, spanish
  334. *******************************************************************************************************************************/
  335. var LANG = {
  336. de : {
  337. settings : {
  338. dsc: "DIO-Tools bietet unter anderem einige Anzeigen, eine Smileyauswahlbox,<br>Handelsoptionen und einige Veränderungen des Layouts.",
  339. act: "Funktionen der Toolsammlung aktivieren/deaktivieren:",
  340. prv: "Vorschau einzelner Funktionen:"
  341. },
  342. options : {
  343. bir: [ "Biremenzähler", "Zählt die jeweiligen Biremen einer Stadt und summiert diese. (Anzeige im Minimap-Bullauge links oben)" ],
  344. sml: [ "Smileys", "Erweitert die BBCode-Leiste um eine Smileybox" ],
  345. str: [ "Einheitenstärke", "Fügt mehrere Einheitenstärketabellen in verschiedenen Bereichen hinzu" ],
  346. trd: [ "Handel", "Erweitert das Handelsfenster um einen Prozentualer Handel, einen Rekrutierungshandel und Limitmarker für Stadtfeste" ],
  347. cnt: [ "EO-Zähler", "Zählt die ATT/UT-Anzahl im EO-Fenster (bisher nur bei eigenen Eroberungen)" ],
  348. way: [ "Laufzeit", "Zeigt im ATT/UT-Fenster die Laufzeit bei Verbesserter Truppenbewegung an" ],
  349. wwc: [ "Weltwunder", "Anteilsrechner & Rohstoffzähler + Vor- & Zurück-Buttons bei fertiggestellten WW's (momentan nicht deaktivierbar!)" ],
  350. sim: [ "Simulator", "Anpassung des Simulatorlayouts & permanente Anzeige der Erweiterten Modifikatorbox" ],
  351. spl: [ "Zauberbox", "Komprimierte verschiebbare & magnetische Zauberbox (Positionsspeicherung)" ],
  352. mov: [ "Aktivitätsboxen", "Verbesserte Anzeige der Handels- und Truppenaktivitätsboxen (Positionsspeicherung)" ],
  353. pop: [ "Popup", 'Ändert Gunst-Popup' ],
  354. tsk: [ "Taskleiste", 'Vergrößert die Taskleiste und minimiert das "Tägliche Belohnung"-Fenster beim Start' ],
  355. irc: [ "Chat", "Ersetzt den Allianzchat durch einen IRC-Chat" ],
  356. bbc: [ "DEF-Formular", "Erweitert die BBCode-Leiste um ein automatisches DEF-Formular" ],
  357. com: [ "Einheitenvergleich","Fügt Einheitenvergleichstabellen hinzu" ],
  358. twn: [ "Stadticons", "Fügt Stadttyp-Icons zur Stadtliste hinzu" ],
  359. con: [ "Kontextmenu", 'Vertauscht "Stadt selektieren" und "Stadtübersicht" im Kontextmenu'],
  360. sen: [ "Abgeschickte Einheiten", 'Zeigt im Angriffs-/Unterstützungsfenster abgeschickte Einheiten an'],
  361. tov: [ "Stadtübersicht", 'Ersetzt die neue Stadtansicht mit der alten Fensteransicht'],
  362. scr: [ "Mausrad", 'Man kann mit dem Mausrad die Übersichten wechseln'],
  363.  
  364. err: [ "Automatische Fehlerberichte senden", "Wenn du diese Option aktivierst, kannst du dabei helfen Fehler zu identifizieren." ],
  365. her: [ "Eventkarte", "Verkleinerung von Eventkarten (50%)." ]
  366. },
  367. labels: {
  368. uni : "Verfügbare Einheiten",
  369. con : "Selektieren",
  370. // Smileys
  371. std: "Standard", gre: "Grepolis", nat: "Natur", ppl: "Leute", oth: "Sonstige",
  372. // Defense form
  373. ttl: "Übersicht: Stadtverteidigung", inf: "Informationen zur Stadt:", dev: "Abweichung",
  374. det: "Detailierte Landeinheiten", prm: "Premiumboni", sil: "Silberstand", mov: "Truppenbewegungen:",
  375. // WW
  376. leg: "WW-Anteil", stg: "Stufe", tot: "Gesamt",
  377. // Simulator
  378. str: "Einheitenstärke", los: "Verluste", mod: "ohne Modifikatoreinfluss",
  379. // Comparison box
  380. dsc: "Einheitenvergleich", hck: "Schlag", prc: "Stich", dst: "Distanz", sea: "See", att: "Angriff", def: "Verteidigung", spd: "Geschwindigkeit",
  381. bty: "Beute (Rohstoffe)", cap: "Transportkapazität", res: "Baukosten (Rohstoffe)", fav: "Gunst", tim: "Bauzeit (s)",
  382. // Trade
  383. rat: "Ressourcenverhältnis eines Einheitentyps", shr: "Anteil an der Lagerkapazität der Zielstadt", per: "Prozentualer Handel",
  384. // Sent units box
  385. lab: "Abgeschickt",
  386. improved_movement: "Verbesserte Truppenbewegung"
  387. },
  388. buttons: {
  389. sav: "Speichern", ins: "Einfügen", res: "Zurücksetzen"
  390. },
  391. },
  392. en : {
  393. settings : {
  394. dsc: "DIO-Tools offers, among other things, some displays, a smiley box,<br>trade options and some changes to the layout.",
  395. act: "Activate/deactivate features of the toolset:",
  396. prv: "Preview of several features:"
  397. },
  398. options : {
  399. bir: [ "Bireme counter", "Counts the biremes of a city and sums these" ],
  400. sml: [ "Smilies", "Extends the bbcode bar by a smiley box" ],
  401. str: [ "Unit strength", "Adds unit strength tables in various areas" ],
  402. trd: [ "Trade", "Extends the trade window by a percentage trade, a recruitment trade and limit markers for city festivals" ],
  403. cnt: [ "Conquests", "Counts the attacks/supports in the conquest window (only own conquests yet)" ],
  404. way: [ "Troop speed", "Displays improved troop speed in the attack/support window" ],
  405. wwc: [ "World wonder", "Share calculation & resources counter + previous & next buttons on finished world wonders (currently not deactivatable!)" ],
  406. sim: [ "Simulator", "Adaptation of the simulator layout & permanent display of the extended modifier box" ],
  407. spl: [ "Spell box", "Compressed movable & magnetic spell box (position memory)" ],
  408. mov: [ "Activity boxes", "Improved display of trade and troop activity boxes (position memory)" ],
  409. pop: [ "Popup", "Changes the favor popup" ],
  410. tsk: [ "Taskbar", "Increases the taskbar and minimizes the daily reward window on startup" ],
  411. irc: [ "Chat", 'Replaced the alliance chat by an irc chat. (FlashPlayer required)' ],
  412. bbc: [ "Defense form", "Extends the bbcode bar by an automatic defense form" ],
  413. com: [ "Unit Comparison", "Adds unit comparison tables" ],
  414. twn: [ "Town icons", "Adds town type icons to the town list" ],
  415. con: [ "Context menu", 'Swaps "Select town" and "City overview" in the context menu'],
  416. sen: [ "Sent units", 'Shows sent units in the attack/support window'],
  417. tov: [ "Town overview", 'Replaces the new town overview with the old window style'],
  418. scr: [ "Mouse wheel", 'You can change the views with the mouse wheel'],
  419.  
  420. err: [ "Send bug reports automatically", "If you activate this option, you can help identify bugs." ],
  421. her: [ "Event map", "Downsizing of event maps (50%)." ]
  422. },
  423. labels: {
  424. uni : "Available Units",
  425. con : "Select town",
  426. // Smileys
  427. std: "Standard", gre: "Grepolis", nat: "Nature", ppl: "People", oth: "Other",
  428. // Defense form
  429. ttl: "Overview: Town defense", inf: "Town information:", dev: "Deviation",
  430. det: "Detailed land units", prm: "Premium bonuses", sil: "Silver volume", mov: "Troop movements:",
  431. // WW
  432. leg: "WW Share", stg: "Stage", tot: "Total",
  433. // Simulator
  434. str: "Unit strength", los: "Loss", mod: "without modificator influence",
  435. // Comparison box
  436. dsc: "Unit comparison",
  437. hck: "Blunt", prc: "Sharp", dst: "Distance", sea: "Sea",
  438. att: "Offensive", def: "Defensive", spd: "Speed", bty: "Booty (resources)",
  439. cap: "Transport capacity", res: "Costs (resources)", fav: "Favor", tim: "Recruiting time (s)",
  440. // Trade
  441. rat: "Resource ratio of an unit type", shr: "Share of the storage capacity of the target city", per: "Percentage trade",
  442. // Sent units box
  443. lab: "Sent units",
  444. improved_movement: "Improved troop movement"
  445. },
  446. buttons: {
  447. sav: "Save", ins: "Insert", res: "Reset"
  448. },
  449. },
  450. ///////////////////////////////////
  451. // French Translation by eclat49 //
  452. ///////////////////////////////////
  453. fr : {
  454. settings: {
  455. dsc: "DIO-Tools offres certains écrans, une boîte de smiley, les options <br>commerciales, des changements à la mise en page et d'autres choses.",
  456. act: "Activation/Désactivation des fonctions:",
  457. prv: "Aperçu des fonctions séparées:"
  458. },
  459. options : {
  460. bir: [ "Compteur de birèmes ", "Totalise l'ensemble des birèmes présentent en villes et les résume. (Remplace la mini carte dans le cadran)" ],
  461. sml: [ "Smileys", "Rajoutes une boite de smilies à la boite de bbcode" ],
  462. str: [ "Force unitaire", "Ajoutes des tableaux de force unitaire dans les différentes armes" ],
  463. trd: [ "Commerce", "Ajout d'une option par pourcentage, par troupes pour le commerce, ainsi qu'un affichage des limites pour les festivals" ],
  464. cnt: [ "Compteur conquête", "Comptabilise le nombre d'attaque et de soutien dans la fenêtre de conquête (valable que pour ses propre conquêtes)" ],
  465. way: [ "Vitesse des troupes ", "Rajoutes le temps de trajet avec le bonus accélération" ],
  466. wwc: [ "Merveille du monde", "Compteur de ressource et calcul d'envoi + bouton précédent et suivant sur les merveilles finies(ne peut être désactivé pour le moment)" ],
  467. sim: [ "Simulateur", "Modification de la présentation du simulateur et affichage permanent des options premium" ],
  468. spl: [ "Boîte de magie", "Boîte de sort cliquable et positionnable" ],
  469. mov: [ "Boîte d'activité", "Présentation améliorée du commerce et des mouvement de troupes (mémoire de position)" ],
  470. pop: [ "Popup", 'Change la popup de faveur' ],
  471. tsk: [ "Barre de tâches ", "La barre de tâches augmente et minimise le fenêtre de bonus journalier" ],
  472. irc: [ "Chat", "Remplace le chat de l'alliance à travers un chat IRC. (FlashPlayer requis)" ],
  473. bbc: [ "Formulaire de défense", "Ajout d'un bouton dans la barre BBCode pour un formulaire de défense automatique" ],
  474. com: [ "Comparaison des unités","Ajoutes des tableaux de comparaison des unités" ],
  475. twn: [ "Icônes des villes", "Ajoutes desicônes de type de ville à la liste de ville" ],
  476. con: [ "Menu contextuel", 'Swaps "Sélectionner ville" et "Aperçu de la ville" dans le menu contextuel'],
  477. sen: [ "Unités envoyées", 'Affiche unités envoyées dans la fenêtre attaque/support'],
  478. tov: [ "Aperçu de ville", "Remplace la nouvelle aperçu de la ville avec l'ancien style de fenêtre"],
  479. scr: [ "Molette de la souris", 'Avec la molette de la souris vous pouvez changer les vues'],
  480.  
  481. err: [ "Envoyer des rapports de bogues automatiquement", "Si vous activez cette option, vous pouvez aider à identifier les bugs." ]
  482. },
  483. labels: {
  484. uni : "Unités disponibles",
  485. con : "Sélectionner",
  486. // Smileys
  487. std: "Standard", gre: "Grepolis", nat: "Nature", ppl: "Gens", oth: "Autres",
  488. // Defense form
  489. ttl: "Aperçu: Défense de ville", inf: "Renseignements sur la ville:", dev: "Différence",
  490. det: "Unités terrestres détaillées", prm: "Bonus premium", sil: "Remplissage de la grotte", mov: "Mouvements de troupes:",
  491. // WW
  492. leg: "Participation", stg: "Niveau", tot: "Total",
  493. // Simulator
  494. str: "Force unitaire", los: "Pertes", mod: "sans influence de modificateur",
  495. // Comparison box
  496. dsc: "Comparaison des unités", hck: "Contond.", prc: "Blanche", dst: "Jet", sea: "Navale", att: "Attaque", def: "Défense", spd: "Vitesse",
  497. bty: "Butin", cap: "Capacité de transport", res: "Coût de construction", fav: "Faveur", tim: "Temps de construction (s)",
  498. // Trade
  499. rat: "Ratio des ressources d'un type d'unité", shr: "Part de la capacité de stockage de la ville cible", per: "Commerce de pourcentage",
  500. // Sent units box
  501. lab: "Envoyée",
  502. improved_movement: "Mouvement des troupes amélioré"
  503. },
  504. buttons: {
  505. sav: "Sauver", ins: "Insertion", res: "Remettre"
  506. },
  507. },
  508. ///////////////////////////////////
  509. // Russian Translation by MrBobr //
  510. ///////////////////////////////////
  511. ru : {
  512. settings : {
  513. dsc: "DIO-Tools изменяет некоторые окна, добавляет новые смайлы, отчёты,<br>улучшеные варианты торговли и другие функции.",
  514. act: "Включение/выключение функций:",
  515. prv: "Примеры внесённых изменений:"
  516. },
  517. options : {
  518. bir: [ "Счётчик бирем", "Показывает число бирем во всех городах" ],
  519. sml: [ "Смайлы", "Добавляет кнопку для вставки смайлов в сообщения" ],
  520. str: [ "Сила отряда", "Добавляет таблицу общей силы отряда в некоторых окнах" ],
  521. trd: [ "Торговля", "Добавляет маркеры и отправку недостающих ресурсов, необходимых для фестиваля. Инструменты для долевой торговли" ],
  522. cnt: [ "Завоевания", "Отображение общего числа атак/подкреплений в окне завоевания города (only own conquests yet)" ],
  523. way: [ "30% ускорение", "Отображает примерное время движения отряда с 30% бонусом" ],
  524. wwc: [ "Чудо света", "Share calculation & resources counter + previous & next buttons on finished world wonders (currently not deactivatable!)" ],
  525. sim: [ "Симулятор", "Изменение интерфейса симулятора, добавление новых функций" ],
  526. spl: [ "Заклинания", "Изменяет положение окна заклинаний" ],
  527. mov: [ "Перемещения", "Показывает окна пересылки ресурсов и перемещения войск" ],
  528. pop: [ "Благосклонность", "Отображение окна с уровнем благосклонности богов" ],
  529. tsk: [ "Таскбар", "Увеличение ширины таскбара и сворачивание окна ежедневной награды при входе в игру" ],
  530. irc: [ "Чат", 'Замена чата игры на irc-чат' ],
  531. bbc: [ "Форма обороны", "Добавляет кнопку для вставки в сообщение отчёта о городе" ], // Beschreibung passt nicht ganz
  532. com: [ "Сравнение юнитов", "Добавляет окно сравнения юнитов" ],
  533. twn: [ "Типы городов", "Добавляет иконку к городу в списке" ],
  534. //con: [ "Context menu", 'Swaps "Select town" and "City overview" in the context menu'],
  535. //sen: [ "Sent units", 'Shows sent units in the attack/support window'],
  536. tov: [ "Обзор Город", 'Заменяет новый обзор города с старом стиле окна'], // ?
  537. scr: [ "Колесо мыши", 'С помощью колеса мыши вы можете изменить взгляды'], // ?
  538.  
  539. err: [ "Отправить сообщения об ошибках автоматически", "Если вы включите эту опцию, вы можете помочь идентифицировать ошибки"]
  540. },
  541.  
  542. labels: {
  543. uni : "Доступные войска",
  544. con : "выбирать",
  545. // Smileys
  546. std: "", gre: "", nat: "", ppl: "", oth: "",
  547. // Defense form
  548. ttl: "Обзор: Отчёт о городе", inf: "Информация о войсках и постройках:", dev: "Отклонение",
  549. det: "Детальный отчёт", prm: "Премиум-бонусы", sil: "Серебро в пещере", mov: "Перемещения",
  550. // WW
  551. leg: "", stg: "", tot: "",
  552. // Simulator
  553. str: "Сила войск", los: "Потери", mod: "без учёта заклинаний, бонусов, исследований",
  554. // Comparison box
  555. dsc: "Сравнение юнитов", hck: "Ударное", prc: "Колющее", dst: "Дальнего боя", sea: "Морские", att: "Атака", def: "Защита", spd: "Скорость",
  556. bty: "Добыча (ресурсы)", cap: "Вместимость транспортов", res: "Стоимость (ресурсы)", fav: "Благосклонность", tim: "Время найма (с)",
  557. // Trade
  558. rat: "", shr: "", per: "",
  559. // Sent units box
  560. lab: "Отправлено",
  561. improved_movement: "Улучшенная перемещение войск"
  562. },
  563.  
  564. buttons: {
  565. sav: "Сохраниить", ins: "Вставка", res: "Сброс"
  566. },
  567. },
  568. ////////////////////////////////
  569. // Polish Translation by anpu //
  570. ////////////////////////////////
  571. pl : {
  572. settings: {
  573. dsc: "DIO-Tools oferuje (między innymi) poprawione widoki, nowe uśmieszki,<br>opcje handlu i zmiany w wyglądzie.",
  574. act: "Włącz/wyłącz funkcje skryptu:",
  575. prv: "podgląd poszczególnych opcji:"
  576. },
  577. options : {
  578. bir: [ "Licznik birem", "Zlicza i sumuje biremy z miast" ],
  579. sml: [ "Emotki", "Dodaje dodatkowe (zielone) emotikonki" ],
  580. str: [ "Siła jednostek", "dodaje tabelki z siłą jednostek w różnych miejscach gry" ],
  581. trd: [ "Handel", "Rozszerza okno handlu o handel procentowy, proporcje surowców wg jednostek, dodaje znaczniki dla festynów" ],
  582. cnt: [ "Podboje", "Zlicza wsparcia/ataki w oknie podboju (tylko własne podboje)" ],
  583. way: [ "Prędkość wojsk", "Wyświetla dodatkowo czas jednostek dla bonusu przyspieszone ruchy wojsk" ],
  584. wwc: [ "Cuda Świata", "Liczy udział w budowie oraz ilość wysłanych surowców na budowę Cudu Świata oraz dodaje przyciski do szybkiego przełączania między cudami (obecnie nie możliwe do wyłączenia)" ],
  585. sim: [ "Symulator", "Dostosowanie wyglądu symulatora oraz dodanie szybkich pól wyboru" ],
  586. spl: [ "Ramka czarów", "Kompaktowa pływająca ramka z czarami (można umieścić w dowolnym miejscu ekranu. Zapamiętuje położenie.)" ],
  587. mov: [ "Ramki aktywności", "Ulepszony podgląd ruchów wojsk i handlu (można umieścić w dowolnym miejscu ekranu. Zapamiętuje położenie.)" ],
  588. pop: [ "Łaski", "Zmienia wygląd ramki informacyjnej o ilości produkowanych łask" ],
  589. tsk: [ "Pasek skrótów", "Powiększa pasek skrótów i minimalizuje okienko z bonusem dziennym" ],
  590. irc: [ "Czat", 'Zastępuje standardowy Chat chatem IRC (wymagany FlashPlayer)' ],
  591. bbc: [ "Raportów obronnych","Rozszerza pasek skrótów BBcode o generator raportów obronnych" ],
  592. com: [ "Porównianie", "Dodaje tabelki z porównaniem jednostek" ],
  593. twn: [ "Oznaczanie miast", "Możliwość oznaczania ikonami miast na liście" ],
  594. con: [ "menu kontekstowe", 'Zamiemia miejcami przycisk "wybierz miasto" z przyciskiem "podgląd miasta" po kliknięciu miasta na mapie'],
  595. sen: [ "Wysłane jednostki", 'Pokaż wysłane jednostki w oknie wysyłania ataków/wsparć'],
  596. tov: [ "Podgląd miasta", 'Zastępuje nowy podgląd miasta starym'],
  597. scr: [ "Zoom", 'Możesz zmienić poziom przybliżenia mapy kółkiem myszy'],
  598.  
  599. err: [ "Automatycznie wysyłać raporty o błędach", "Jeśli włączysz tę opcję, możesz pomóc zidentyfikować błędy"]
  600.  
  601. },
  602. labels: {
  603. uni : "Dostępne jednostki",
  604. con : "Wybierz miasto",
  605. // Smileys
  606. std: "Standard" /* "Standardowe" */, gre: "Grepolis", nat: "Przyroda", ppl: "Ludzie", oth: "Inne",
  607. // Defense form
  608. ttl: "Podgląd: Obrona miasta", inf: "Informacje o mieście:", dev: "Ochyłka",
  609. det: "jednostki lądowe", prm: "opcje Premium", sil: "Ilość srebra", mov: "Ruchy wojsk",
  610. // WW
  611. leg: "Udział w Cudzie", stg: "Poziom", tot: "Łącznie",
  612. // Simulator
  613. str: "Siła jednostek", los: "Straty", mod: "bez modyfikatorów",
  614. // Comparison box
  615. dsc: "Porównianie jednostek", hck: "Obuchowa", prc: "Tnąca", dst: "Dystansowa", sea: "Morskie", att: "Offensywne", def: "Defensywne", spd: "Prędkość",
  616. bty: "Łup (surowce)", cap: "Pojemność transportu", res: "Koszta (surowce)", fav: "Łaski", tim: "Czas rekrutacji (s)",
  617. // Trade
  618. rat: "Stosunek surowców dla wybranej jednostki", shr: "procent zapełnienia magazynu w docelowym mieście", per: "Handel procentowy",
  619. // Sent units box
  620. lab: "Wysłane jednostki",
  621. improved_movement: "Przyspieszone ruchy wojsk‎"
  622. },
  623. buttons: {
  624. sav: "Zapisz", ins: "Wstaw", res: "Anuluj"
  625. },
  626. },
  627. ////////////////////////////////////
  628. // Dutch Translation by MusicVibe //
  629. ////////////////////////////////////
  630. nl : {
  631. settings : {
  632. dsc: "DIO-Tools bied onder andere een aantal displays, een smiley box, uitgebreide handels optiesen veranderingen aan de layout.",
  633. act: "Activeer/Deavtiveer functies van de toolset:",
  634. prv: "voorbeeld van een aantal functies:"
  635. },
  636. options : {
  637. bir: [ "Bireem teller", "Telt het aantal biremen van een stad en telt ze bij elkaar op" ],
  638. sml: [ "smileys", "Voegt een extra BBvode knop toe die een aantal smileys" ],
  639. str: [ "Eenheden sterkte", "voegt een aantal tabellen toe die eenheden sterkte weergeven" ],
  640. trd: [ "Handel", "Breid het handel scherm uit met een percentage trade, recruitment trade en markers voor stad feesten" ],
  641. cnt: [ "Veroveringen", "Telt het aantal inkomende aanvallen/ondersteuningen in het veroveringsscherm" ],
  642. way: [ "Eenheden snelheid", "Laat de versnelde eenheden snelheid zien in het aanval/ondersteuning scherm" ],
  643. wwc: [ "Wereld wonder", "Aandeel berekening, grondstoffen teller, Vorige en Volgende knoppen bij voltooide wereld wonderen" ],
  644. sim: [ "Simulator", "Aanpassing van de simulator layout en permanent uitgeklapte gevechtsbonussen" ],
  645. spl: [ "Spreuken scherm", "Ingekorte, verplaatsbare spreuken scherm" ],
  646. mov: [ "Activiteiten scherm", "Verbeterde weergave van handel en troepen bewegingen" ],
  647. pop: [ "Popup", "Verandert de gunsten popup" ],
  648. tsk: [ "Taakbalk", "Breid de taakbalk uit en minimaliseerd het dagelijkse beloning scherm als je inlogt" ],
  649. irc: [ "Chat", 'Vervang the alliantie chat met een irc chat. (FlashPlayer vereist)' ],
  650. bbc: [ "Verdedigings formulier","Een extra BBcode knop die een overzicht genereert van de verdediging van je stad" ],
  651. com: [ "Eenheden vergelijking", "Voegt eenheden vergelijking schermen toe" ],
  652. twn: [ "Stad iconen", "Voegt stad iconen toe aan de stedenlijst" ],
  653. con: [ "Context menu", 'Ruilt "Selecteer stad" en "Stadsoverzicht" in het context menu'],
  654. sen: [ "Verstuurde eenheden", 'Weergeeft verstuurde eenheden in de aanval/ondersteuning schermen'],
  655. tov: [ "Stadsoverzicht", 'verruild het nieuwe stadsoverzicht met het stadsoverzicht uit de oude stijl'],
  656. scr: [ "Muis wiel", 'Je kunt de weergave veranderen door met je muis wiel te scrollen'],
  657. err: [ "Verstuur bug reports automatisch", "Hiermee help je het identificeren van bugs." ],
  658. her: [ "Trojaanse verovering", "verkleining van de Trojaanse veroveringen kaart." ]
  659. },
  660. labels: {
  661. uni : "Beschikbare eenheden",
  662. con : "Selecteer stad",
  663. // Smileys
  664. std: "Standaard", gre: "Grepolis", nat: "Natuur", ppl: "Mensen", oth: "Overig",
  665. // Defense form
  666. ttl: "Overzicht: Stad verdediging", inf: "Stad informatie:", dev: "Afwijking",
  667. det: "Gedetaileerde land eenheden", prm: "Premium bonussen", sil: "Hoeveelheid zilver", mov: "Troepen verplaatsingen:",
  668. // WW
  669. leg: "WW Aandeel", stg: "Level", tot: "Totaal",
  670. // Simulator
  671. str: "Eenheden sterkte", los: "Verlies", mod: "Zonder modificatie invloed",
  672. // Comparison box
  673. dsc: "Eenheden vergelijking",
  674. hck: "Slag", prc: "Steek", dst: "Afstand", sea: "Zee",
  675. att: "Offensief", def: "Defensief", spd: "Snelheid", bty: "Buit (grondstoffen)",
  676. cap: "Transport capaceit", res: "Kosten (grondstoffen)", fav: "Gunst", tim: "Bouwtijd (s)",
  677. // Trade
  678. rat: "Grondstoffen ratio van een bepaalde eenheid", shr: "Gedeelte van de opslag capaciteit van de ontvangende stad", per: "Percentage handel",
  679. // Sent units box
  680. lab: "Verstuurde eenheden",
  681. improved_movement: "Versnelde troepen beweging"
  682. },
  683. buttons: {
  684. sav: "Opslaan", ins: "Invoegen", res: "Reset"
  685. },
  686. },
  687. //////////////////////////////////////////////
  688. // Spanish Translation by Juana de Castilla //
  689. //////////////////////////////////////////////
  690. es : {
  691. settings : {
  692. dsc: "DIO-Tools ofrece, entre otras cosas, varias pantallas, ventana de <br>emoticones, opciones de comercio y algunos cambios en el diseño.",
  693. act: "Activar/desactivar características de las herramientas:",
  694. prv: "Vista previa de varias características:"
  695. },
  696. options : {
  697. bir: [ "Contador de birremes", "Cuenta los birremes de una ciudad y los suma" ],
  698. sml: [ "Emoticones", "Código BB para emoticones" ],
  699. str: [ "Fortaleza de la Unidad", "Añade tabla de fortalezas de cada unidad en varias zonas" ],
  700. trd: [ "Comercio", "Añade en la pestaña de comercio un porcentaje de comercio y reclutamiento y limitadores de Mercado por cada ciudad" ],
  701. cnt: [ "Conquistas", "contador de ataques y refuerzos en la pestaña de conquista" ],
  702. way: [ "Velocidad de tropas", "Muestra movimiento de tropas mejorado en la ventana de ataque/refuerzo" ],
  703. wwc: [ "Maravillas", "Calcula participación & contador de recursos + antes y después teclas de maravillas terminadas (no desactibable ahora!)" ],
  704. sim: [ "Simulador", "Adaptación de la ventana del simulador incluyendo recuadro de modificadores" ],
  705. spl: [ "Ventana de hechizos", "Ventana deslizante y comprimida de los hechizos (memoria posicional)"],
  706. mov: [ "Ventana de actividad", "Mejora las ventanas de comercio y movimiento de tropas (memoria posicional)" ],
  707. pop: [ "Popup", "Cambia el popup de favores" ],
  708. tsk: [ "Barra de tareas", "aumenta la barra de tareas y minimice la recompensa al aparecer" ],
  709. irc: [ "Chat", 'Sustituye el chat de la alianza con un irc chat. (require FlashPlayer)' ],
  710. bbc: [ "Formulario de defensa", "Añade en la barra de códigos bb un formulario de defensa" ],
  711. com: [ "Comparación", "añade ventana de comparación de unidades" ],
  712. twn: [ "Iconos de la ciudad", "Añade iconos de tipo de ciudad en el listado de ciudades" ],
  713. con: [ "menú contextual", 'Cambia "Elegir ciudad" y "vista de la ciudad" en el menú contextual '],
  714. sen: [ "Unidades enviadas", 'Muestra las unidades enviadas en la ventana de ataque/refuerzos'],
  715. tov: [ "Información de la ciudad", 'sustituye la vista nueva de ciudad por la ventana antigua'],
  716. scr: [ "Rueda raton", 'Puede cambiar las vistas con la rueda del raton'],
  717.  
  718. err: [ "Enviar informes de errores automáticamente", "Si se activa esta opción, puede ayudar a identificar errores." ]
  719. },
  720. labels: {
  721. uni : "Unidades disponibles",
  722. con : "Escoger ciudad",
  723. // Smileys
  724. std: "Standard", gre: "Grepolis", nat: "Natura", ppl: "Gente", oth: "Otros",
  725. // Defense form
  726. ttl: "Vista general: Defensa de la ciudad", inf: "Información de la ciudad:", dev: "Desviación",
  727. det: "Unidades de tierra detalladas", prm: "Bonos Premium", sil: "Volumen de plata", mov: "Movimientos de tropas:",
  728. // WW
  729. leg: "WW cuota", stg: "Nivel", tot: "Total",
  730. // Simulator
  731. str: "Fortaleza de la Unidad", los: "Perdida", mod: "sin influencia del modificador",
  732. // Comparison box
  733. dsc: "Comparación de Unidades",
  734. hck: "Contundente", prc: "Punzante", dst: "Distancia", sea: "Mar",
  735. att: "Ataque", def: "Defensa", spd: "Velocidad", bty: "Botín (recursos)",
  736. cap: "Capacidad de transporte", res: "Costes (recursos)", fav: "Favor", tim: "Tiempo de reclutamiento (s)",
  737. // Trade
  738. rat: "Proporción de recursos de un tipo de unidad", shr: "Porcentaje de la capacidad de almacenamiento de la ciudad destino", per: "Porcentaje de comercio",
  739. // Sent units box
  740. lab: "Unidades enviadas",
  741. improved_movement: "Movimiento de tropas mejorados"
  742. },
  743. buttons: {
  744. sav: "Guardar", ins: "Insertar", res: "Reinicio"
  745. }
  746. },
  747. ar : {}
  748. };
  749.  
  750. LANG.ar = LANG.es;
  751.  
  752. // Create JSON
  753. // console.log(JSON.stringify(LANG.en));
  754.  
  755. /*******************************************************************************************************************************
  756. * Settings
  757. *******************************************************************************************************************************/
  758.  
  759. // (De)activation of the features
  760. var options_def = {
  761. bir : true, // Biremes counter
  762. sml : true, // Smileys
  763. str : true, // Unit strength
  764. trd : true, // Trade options
  765. way : true, // Troop speed
  766. cnt : true, // Attack/support counter
  767. sim : true, // Simulator
  768. spl : true, // Spell box
  769. mov : false,// Activity boxes
  770. tsk : true, // Task bar
  771. irc : true, // IRC-Chat
  772. pop : true, // Favor popup
  773. wwc : true, // World wonder
  774. bbc : true, // BBCode bar
  775. com : true, // Unit comparison
  776. twn : true, // Town icons
  777. con : true, // Context menu
  778. sen : true, // Sent units
  779. tov : false,// Town overview
  780. scr : true, // Mausrad,
  781.  
  782. err : false,
  783. her : true // Thrakische Eroberung
  784. };
  785. if(uw.location.pathname === "/game/index"){
  786. for(var opt in options_def){
  787. if(options_def.hasOwnProperty(opt)){
  788. if(DATA.options[opt] == undefined) {
  789. DATA.options[opt] = options_def[opt];
  790. }
  791. }
  792. }
  793. }
  794.  
  795. // Add DIO-Tools to grepo settings
  796. function settings() {
  797. var wid = $(".settings-menu").get(0).parentNode.id;
  798.  
  799. if(!$("#dio_tools").get(0)){
  800. $(".settings-menu ul:last").append('<li id="dio_li"><img id="dio_icon" src="http://www.greensmilies.com/smile/smiley_emoticons_smile.gif"></div> <a id="dio_tools" href="#"> DIO-Tools</a></li>');
  801. }
  802.  
  803. $(".settings-link").click(function () {
  804. $('.section').each(function(){
  805. $(this).get(0).style.display = "block";
  806. });
  807. $('.settings-container').removeClass("dio_overflow");
  808.  
  809. $('#dio_bg_medusa').css({ display: "none" });
  810.  
  811. if($('#dio_settings').get(0)) { $('#dio_settings').get(0).style.display = "none"; }
  812. });
  813.  
  814. $("#dio_tools").click(function () {
  815. if($('.email').get(0)) { $('.settings-container').removeClass("email"); }
  816.  
  817. $('.settings-container').addClass("dio_overflow");
  818.  
  819. $('#dio_bg_medusa').css({ display: "block" });
  820.  
  821. if(!$('#dio_settings').get(0)){
  822. $('.settings-container').append(
  823. '<div id="dio_settings" class="player_settings section"><div id="dio_bg_medusa"></div>'+
  824. '<div class="game_header bold"><a href="#" target="_blank" style="color:white">DIO-Tools (v'+ version +')</a></div>'+
  825. '<p>' + getText("settings", "dsc") + '</p>'+
  826. '<p class="bold"><u>'+ getText("settings", "act") + '</u></p>'+
  827. '<table width="100%" style=" font-size: 0.8em;"><tr><td width="24%">'+
  828. '<div id="bir" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "bir")[0] +'</div></div><br><br>'+
  829. '<div id="sml" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "sml")[0] +'</div></div><br><br>'+
  830. '<div id="str" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "str")[0] +'</div></div><br><br>'+
  831. '<div id="bbc" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "bbc")[0] +'</div></div><br><br>'+
  832. '<div id="con" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "con")[0] +'</div></div><br><br>'+
  833. '</td><td width="21%">'+
  834. '<div id="trd" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "trd")[0] +'</div></div><br><br>'+
  835. '<div id="cnt" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "cnt")[0] +'</div></div><br><br>'+
  836. '<div id="way" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "way")[0] +'</div></div><br><br>'+
  837. '<div id="wwc" class="checkbox_new disabled"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "wwc")[0] +'</div></div><br><br>'+
  838. '<div id="sen" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "sen")[0] +'</div></div><br><br>'+
  839. '</td><td width="20%">'+
  840. '<div id="sim" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "sim")[0] +'</div></div><br><br>'+
  841. '<div id="spl" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "spl")[0] +'</div></div><br><br>'+
  842. '<div id="tsk" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "tsk")[0] +'</div></div><br><br>'+
  843. '<div id="twn" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "twn")[0] +'</div></div><br><br>'+
  844. '<div id="tov" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "tov")[0] +'</div></div><br><br>'+
  845. '</td><td>'+
  846. '<div id="com" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "com")[0] +'</div></div><br><br>'+
  847. '<div id="mov" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "mov")[0] +'</div></div><br><br>'+
  848. '<div id="pop" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "pop")[0] +'</div></div><br><br>'+
  849. '<div id="irc" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "irc")[0] +'</div></div><br><br>'+
  850. '<div id="scr" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "scr")[0] +'</div></div><br><br>'+
  851. '</td></tr><tr><td colspan="4">'+
  852. '<div id="err" class="checkbox_new" style="float:left"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "err")[0] +'</div></div>'+
  853. '<div id="her" class="checkbox_new" style="float:left"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "her")[0] +'</div></div><br><br>'+
  854. '</td></tr>'+
  855. '</table>'+
  856. '<div><a class="button" id="dio_save" href="#">'+
  857. '<span class="left"><span class="right"><span class="middle"><small>' + getText("buttons", "sav") + '</small></span></span></span><span></span>'+
  858. '</a></div>'+
  859. '<div style="position:absolute; left: 495px;top: 40px;"><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3EWUQUTMC5VKS" target="_blank">'+
  860. '<img alt="Donate" src="' + (LID === "de" ? "http://s7.directupload.net/images/140131/ctahnu2q.png" : "https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif") + '"></a></div>'+
  861. //'<p class="bold"><u>'+ getText("settings", "prv") + '</u></p>'+
  862. '<br /><table><tr>'+
  863. '<td><img id="bi_img" src="http://i.imgur.com/94m7Gg8.png"></td>'+
  864. '<td><img id="sm_img" src="http://i.imgur.com/Y3BsENb.png"></td>'+
  865. '<td><img id="un_img" src="http://i.imgur.com/LXkSxsS.png"></td>'+
  866. '</tr></table></div></div>');
  867.  
  868. $('.checkbox_new .cbx_caption').css({
  869. whiteSpace: 'nowrap',
  870. marginRight: '10px'
  871. });
  872.  
  873. // Thrakische Eroberung
  874. if(!$('#happening_large_icon.hercules2014').get(0)){
  875. $('#her').css({ display: "none" });
  876. }
  877.  
  878. $("#bi_img").tooltip(getText("options", "bir")[0]); $("#sm_img").tooltip(getText("options", "sml")[0]); $("#un_img").tooltip(getText("options", "str")[0]);
  879.  
  880. $("#bir").tooltip(getText("options", "bir")[1]); $("#sml").tooltip(getText("options", "sml")[1] + "<br><br><img src='http://666kb.com/i/ckajscggscw4s2u60.gif'>");
  881. $("#str").tooltip(getText("options", "str")[1]); $("#bbc").tooltip(getText("options", "bbc")[1]);
  882. $("#con").tooltip(getText("options", "con")[1]);
  883.  
  884. $("#trd").tooltip(getText("options", "trd")[1]); $("#cnt").tooltip(getText("options", "cnt")[1]); $("#way").tooltip(getText("options", "way")[1]);
  885. $("#wwc").tooltip(getText("options", "wwc")[1]); $("#sen").tooltip(getText("options", "sen")[1]);
  886.  
  887. $("#sim").tooltip(getText("options", "sim")[1]); $("#spl").tooltip(getText("options", "spl")[1]); $("#mov").tooltip(getText("options", "mov")[1]);
  888. $("#com").tooltip(getText("options", "com")[1]); $("#tov").tooltip(getText("options", "tov")[1]);
  889.  
  890. $("#pop").tooltip(getText("options", "pop")[1]); $("#tsk").tooltip(getText("options", "tsk")[1]); $("#irc").tooltip(getText("options", "irc")[1]);
  891. $("#twn").tooltip(getText("options", "twn")[1]); $("#scr").tooltip(getText("options", "scr")[1]);
  892.  
  893. $("#err").tooltip(getText("options", "err")[1]); $("#her").tooltip(getText("options", "her")[1]);
  894.  
  895. if(!uw.Layout.wnd.TYPE_TOWNINDEX){
  896. $('#tov').addClass("disabled");
  897. $('#tov .cbx_caption').get(0).style.color = "red";
  898. $("#tov").tooltip('<span style="color:red">This feature was unfortunately prevented by the Grepolis developers on purpose. They call it "code cleanup". Sorry...</span>');
  899. }
  900.  
  901. $("#dio_settings .checkbox_new").click(function () {
  902. $(this).toggleClass("checked");
  903. });
  904. for(var e in DATA.options) {
  905. if(DATA.options.hasOwnProperty(e)){
  906. if (DATA.options[e] == true) {
  907. $("#" + e).addClass("checked");
  908. }
  909. }
  910. }
  911.  
  912. $('#dio_save').click(function(){
  913. $('#dio_settings .checkbox_new').each(function(){
  914. var act = false;
  915. if ($("#" + this.id).hasClass("checked")) {
  916. act = true;
  917. }
  918. DATA.options[this.id] = act;
  919. });
  920. saveValue("options", JSON.stringify(DATA.options));
  921. });
  922. }
  923. $('.section').each(function(){
  924. $(this).get(0).style.display = "none";
  925. });
  926. $('#dio_settings').get(0).style.display = "block";
  927. });
  928. }
  929.  
  930.  
  931. function addSettingsButton(){
  932. $('<div class="btn_settings circle_button dio_settings"><div class="dio_icon js-caption"></div></div>').appendTo(".gods_area");
  933. $('.dio_settings').css({
  934. top: '95px',
  935. right: '103px',
  936. zIndex: '10'
  937. });
  938. $('.dio_settings .dio_icon').css({
  939. margin: '7px 0px 0px 4px', width: '24px', height: '24px',
  940. background: 'url(http://666kb.com/i/cifvfsu3e2sdiipn0.gif) no-repeat 0px 0px',
  941. backgroundSize: "100%"
  942. });
  943. $('.dio_settings').on('mouseup', function(){
  944. $('.dio_icon').get(0).style.marginTop = "7px";
  945. });
  946. $('.dio_settings').on('mousedown', function(){
  947. $('.dio_icon').get(0).style.marginTop = "8px";
  948. });
  949. $('.dio_settings').tooltip("DIO-Tools: " + DM.getl10n("layout", "config_buttons").settings);
  950.  
  951. $('.dio_settings').click(function(){
  952. clickDioSettings();
  953. });
  954. }
  955.  
  956. var diosettings = false;
  957. function clickDioSettings(){
  958. if(!uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_PLAYER_SETTINGS)){
  959. diosettings = true;
  960. }
  961. uw.Layout.wnd.Create(uw.GPWindowMgr.TYPE_PLAYER_SETTINGS,'Settings');
  962. }
  963.  
  964.  
  965. // Forum: Choose language
  966. if(!(uw.location.pathname === "/game/index")){
  967. LID = uw.location.host.split(".")[1];
  968. }
  969.  
  970. // Translation GET
  971. function getText(category, name){
  972. var txt = "???";
  973. if(LANG[LID]){
  974. if(LANG[LID][category]){
  975. if(LANG[LID][category][name]){
  976. txt = LANG[LID][category][name];
  977. } else { if(LANG.en[category]){ if(LANG.en[category][name]){
  978. txt = LANG.en[category][name];
  979. }}}
  980. } else {
  981. if(LANG.en[category]){ if(LANG.en[category][name]){
  982. txt = LANG.en[category][name];
  983. }}
  984. }
  985. } else {
  986. if(LANG.en[category]){ if(LANG.en[category][name]){
  987. txt = LANG.en[category][name];
  988. }}
  989. }
  990. return txt;
  991. }
  992.  
  993. var exc = false, sum = 0, ch = ["FBADAF", "IGCCJB"], alpha = 'ABCDEFGHIJ';
  994.  
  995. function a(){
  996. var pA = PID.toString(), pB = "";
  997.  
  998. for(var c in pA){ if(pA.hasOwnProperty(c)){ pB += alpha[pA[parseInt(c, 10)]];}}
  999.  
  1000. sum = 0;
  1001. for(var b in ch){
  1002. if(ch.hasOwnProperty(b)){
  1003. if(!(pB === ch[b])){exc = true;} else {exc = false; return;}
  1004. for(var s in ch[b]){if(ch[b].hasOwnProperty(s)){sum += alpha.indexOf(ch[b][s]); }}
  1005. }
  1006. }
  1007. }
  1008.  
  1009. var autoTownTypes, manuTownTypes, population, sentUnitsArray, biriArray, spellbox, commandbox, tradebox, wonder, wonderTypes;
  1010.  
  1011.  
  1012. function setStyle(){
  1013. // Settings
  1014. $('<style type="text/css">'+
  1015. '#dio_bg_medusa { background:url('+ dio_sprite +') -160px -43px no-repeat; height: 510px; width: 260px; right: -10px; z-index: -1; position: absolute;} '+
  1016. '.dio_overflow { overflow: hidden; } '+
  1017. '#dio_icon { width:15px; vertical-align:middle; margin-top:-2px; } '+
  1018. '#quackicon { width:15px !important; vertical-align:middle !important; margin-top:-2px; height:12px !important; } '+
  1019. '</style>').appendTo('head');
  1020.  
  1021. // Tutorial-Quest Container
  1022. $('<style type="text/css"> #tutorial_quest_container { top: 130px } </style>').appendTo('head');
  1023.  
  1024. // Ranking
  1025. $('<style type="text/css"> .wonder_ranking { display: none; } </style>').appendTo('head');
  1026.  
  1027. // Velerios
  1028. $('<style id="dio_velerios" type="text/css"> #ph_trader_image { background-image: url(http://s14.directupload.net/images/140826/mh8k8nyw.jpg); } </style>').appendTo('head');
  1029. // http://s7.directupload.net/images/140826/bgqlsdrf.jpg
  1030.  
  1031. // Specific player wishes
  1032. if(PID == 1212083){
  1033. $('<style id="dio_whishes" type="text/css"> #world_end_info { display: none; } </style>').appendTo('head');
  1034. }
  1035.  
  1036. }
  1037. if(uw.location.pathname === "/game/index"){
  1038. setStyle();
  1039. }
  1040.  
  1041. function loadFeatures(){
  1042. if(typeof(ITowns) !== "undefined"){
  1043.  
  1044. autoTownTypes = {}; manuTownTypes = DATA.townTypes; population = {};
  1045.  
  1046. sentUnitsArray = DATA.sentUnits; biriArray = DATA.biremes;
  1047.  
  1048. spellbox = DATA.spellbox; commandbox = DATA.commandbox; tradebox = DATA.tradebox;
  1049.  
  1050. wonder = DATA.worldWonder; wonderTypes = DATA.worldWonderTypes;
  1051.  
  1052.  
  1053. var DIO_USER = { 'name': uw.Game.player_name, 'market': MID };
  1054. saveValue("dio_user", JSON.stringify(DIO_USER));
  1055.  
  1056. $.Observer(uw.GameEvents.game.load).subscribe('DIO_START', function(e,data){
  1057. // check if city overview window exists
  1058. if(!uw.Layout.wnd.TYPE_TOWNINDEX){
  1059. DATA.options.tov = false;
  1060. }
  1061. // replace start city overview with the window style
  1062. if(DATA.options.tov){
  1063. if($('#ui_box').hasClass("city-overview-enabled") && uw.Layout.wnd.TYPE_TOWNINDEX) {
  1064. $.Observer(uw.GameEvents.ui.bull_eye.radiobutton.island_view.click).publish({});
  1065. uw.GPWindowMgr.Create(uw.Layout.wnd.TYPE_TOWNINDEX, uw.DM.getl10n('town_index').window_title +" - "+ uw.ITowns.getTown(uw.Game.townId).name);
  1066. }
  1067. }
  1068. minimizeDailyReward();
  1069.  
  1070. a();
  1071.  
  1072. // English => default language
  1073. if(!LANG[LID]){ LID = "en"; }
  1074.  
  1075. if((ch.length == 2) && exc && (sum == 42)){
  1076. addFunctionToITowns();
  1077.  
  1078. if(DATA.options.tsk) {scaleTaskbar(); hideNavElements();}
  1079.  
  1080. if(DATA.options.com) {addComparisonButton();}
  1081. addSettingsButton();
  1082. addAvailableUnitsBox();
  1083. addAvailableUnitsButton();
  1084.  
  1085. //addStatsButton();
  1086.  
  1087. fixUnitValues();
  1088. if(DATA.options.bir) {initBiri();}
  1089.  
  1090. getAllUnits();
  1091. setInterval(function(){
  1092. getAllUnits();
  1093. },1800000);
  1094.  
  1095. if(DATA.options.pop) {unbindFavorPopup();}
  1096. if(DATA.options.spl) {catchSpellBox(); initSpellBox();}
  1097. imageSelectionProtection();
  1098.  
  1099. if(DATA.options.con) {changeContextMenu();}
  1100.  
  1101. /*
  1102. $.Observer(uw.GameEvents.menu.click).subscribe('DIO_MENU', function(e,data){
  1103. //console.log(data.option_id);
  1104. });
  1105. $.Observer(uw.GameEvents.attack.incoming).subscribe('DIO_ATTACK', function(e,data){
  1106. //console.log(data.count);
  1107. });
  1108. $.Observer(uw.GameEvents.town.units.change).subscribe('DIO_UNITCHANGE', function(e,data){
  1109. //console.log(data.count);
  1110. });
  1111. */
  1112.  
  1113. //Notification
  1114. uw.NotificationType.DIO_TOOLS = "diotools";
  1115. $('<style type="text/css"> #notification_area .diotools .icon { background: url(http://666kb.com/i/cifvfsu3e2sdiipn0.gif) 4px 7px no-repeat !important; -webkit-filter: hue-rotate(100deg);filter: url(#Hue3); } </style>').appendTo('head');
  1116.  
  1117. var notif = DATA.notification;
  1118. if(notif <= 10){
  1119. //newFeatureNotification(1, 'Swap context menu buttons ("Select town" and "City overview")');
  1120. //newFeatureNotification(2, 'Town overview (old window mode)');
  1121. //newFeatureNotification(3, 'Mouse wheel: You can change the views with the mouse wheel');
  1122. //newFeatureNotification(4, 'Town icons on the strategic map');
  1123. //newFeatureNotification(5, 'Percentual unit population in the town list');
  1124. //newFeatureNotification(6, 'New world wonder ranking');
  1125. //newFeatureNotification(7, 'World wonder icons on the strategic map');
  1126. petitionNotification(8);
  1127. $('.diotools .icon').each(function(){
  1128. $(this).click(function(){
  1129. clickDioSettings();
  1130. $(this).parent().find(".close").click();
  1131. });
  1132. });
  1133. $('.diotools').css({
  1134. cursor: "pointer"
  1135. });
  1136. saveValue('notification', ++notif);
  1137. }
  1138.  
  1139. if(DATA.options.mov){showActivityBoxes();}
  1140. if(DATA.options.str){addStrengthMenu(); setStrengthMenu();}
  1141.  
  1142. if(DATA.options.twn){setTownList(); addTownIcon(); setTownIconsOnMap();}
  1143.  
  1144. if(DATA.options.com){addComparisonBox();}
  1145. if(DATA.options.sml){loadSmileys();}
  1146. if(DATA.options.irc){initChatUser();}
  1147.  
  1148. if(DATA.options.tov){setCityWindowButton();}
  1149.  
  1150. if(DATA.options.scr){scrollViews();}
  1151. if(DATA.options.sen){getSentUnits();}
  1152.  
  1153.  
  1154. setTimeout(function(){
  1155. counter(uw.Timestamp.server());
  1156. setInterval(function(){
  1157. counter(uw.Timestamp.server());
  1158. }, 21600000);
  1159. }, 60000);
  1160.  
  1161. // AJAX-EVENTS
  1162. ajaxObserver();
  1163.  
  1164. // Execute once to get the world wonder types and coordinates
  1165. setTimeout(function(){
  1166. if(!wonderTypes.great_pyramid_of_giza){
  1167. getWorldWonderTypes();
  1168. }
  1169. if(wonderTypes.great_pyramid_of_giza){
  1170. setTimeout(function(){
  1171. if(!wonder.map.mausoleum_of_halicarnassus){
  1172. getWorldWonders();
  1173. } else {
  1174. setWonderIconsOnMap();
  1175. }
  1176. }, 2000);
  1177. }
  1178. }, 3000);
  1179.  
  1180. // Execute once to get alliance ratio
  1181. if (wonder.ratio[AID] == -1 || !$.isNumeric(wonder.ratio[AID])){
  1182. setTimeout(function(){
  1183. getPointRatioFromAllianceProfile();
  1184. }, 5000);
  1185. }
  1186.  
  1187. }
  1188. time_b = uw.Timestamp.client();
  1189. //console.log("Gebrauchte Zeit:" + (time_b - time_a));
  1190. });
  1191. } else {
  1192. setTimeout(function(){
  1193. loadFeatures();
  1194. }, 100);
  1195. }
  1196. }
  1197. if(uw.location.pathname === "/game/index"){
  1198. loadFeatures();
  1199. }
  1200.  
  1201. /*******************************************************************************************************************************
  1202. * HTTP-Requests
  1203. * *****************************************************************************************************************************/
  1204. function ajaxObserver(){
  1205. $(document).ajaxComplete(function (e, xhr, opt) {
  1206. var url = opt.url.split("?"),
  1207. action = url[0].substr(5) + "/" + url[1].split(/&/)[1].substr(7);
  1208. if(PID == 84367 || PID == 104769){
  1209. console.log(action);
  1210. console.log((JSON.parse(xhr.responseText).json));
  1211. }
  1212. setTimeout(function(){
  1213. switch (action) {
  1214. case "/frontend_bridge/fetch": // Daily Reward
  1215.  
  1216. // Event map
  1217. if(DATA.options.her){
  1218. var el = $('.js-hercules2014-dragdrop.dragdrop').get(0);
  1219. console.debug("HALLO", el);
  1220. if(el){
  1221. var map_left = parseInt(el.style.left.split("p")[0], 10);
  1222. var map_top = parseInt(el.style.top.split("p")[0], 10);
  1223.  
  1224. if((map_top < -216) || (map_left < -143)){
  1225. $('.js-hercules2014-dragdrop.dragdrop').css({
  1226. top: '-40px',
  1227. left: '-40px'
  1228. });
  1229. }
  1230. }
  1231. if(!$('#dio_hercules').get(0) && $('.hercules_map').get(0)){
  1232. var map_width = parseInt(getComputedStyle($('.hercules_map').get(0)).width, 10) / 2;
  1233. var map_height = parseInt(getComputedStyle($('.hercules_map').get(0)).height, 10) / 2;
  1234.  
  1235. $('<style id="dio_hercules" type="text/css"> .hercules_map .stages { -webkit-transform: scale(0.5); transform: scale(0.5); margin-left: -33%; } '+
  1236. '.hercules2014_map .dragdrop, .hercules2014_map .hercules_map { width: '+ map_width +'px !important; height: '+ map_height +'px !important; } '+
  1237. '.hercules_map { background-size: 100% !important; } '+
  1238. '</style>').appendTo('head');
  1239. }
  1240. }
  1241.  
  1242. //console.log("done");
  1243. //$('.daily_login').find(".minimize").click();
  1244. break;
  1245. case "/player/index":
  1246. settings();
  1247. if(diosettings){ $('#dio_tools').click(); diosettings = false; }
  1248. break;
  1249. case "/index/switch_town":
  1250.  
  1251. if(DATA.options.str) {setStrengthMenu();}
  1252. if(DATA.options.bir) {getBiri();}
  1253. if(DATA.options.twn) {changeTownIcon();}
  1254.  
  1255. // Update city window
  1256. if(uw.Layout.wnd.TYPE_TOWNINDEX){ // check if the window type exists
  1257. if(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX)){
  1258. uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).setTitle(uw.DM.getl10n('town_index').window_title +" - "+ uw.ITowns.getTown(uw.Game.townId).name);
  1259. uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).reloadContent();
  1260. }
  1261. }
  1262. break;
  1263. case "/building_docks/index":
  1264. if(DATA.options.bir) {getBiriDocks();}
  1265. break;
  1266. case "/building_place/units_beyond":
  1267. if(DATA.options.bir) {getBiriAgora();}
  1268. //addTransporterBackButtons();
  1269. break;
  1270. case "/building_place/simulator":
  1271. if(DATA.options.sim) {changeSimulatorLayout(); }
  1272. break;
  1273. case "/building_place/simulate":
  1274. if(DATA.options.sim) {afterSimulation(); }
  1275. break;
  1276.  
  1277. case "/alliance_forum/forum": case "/message/new": case "/message/forward": case "/message/view": case "/player_memo/load_memo_content":
  1278. if(DATA.options.sml){addSmileyBox(action); }
  1279. if(DATA.options.bbc){addForm(action); }
  1280. break;
  1281. case "/wonders/index":
  1282. if(DATA.options.trd){WWTradeHandler(); }
  1283. getResWW();
  1284. break;
  1285. case "/wonders/send_resources":
  1286. getResWW();
  1287. break;
  1288. case "/ranking/alliance":
  1289. getPointRatioFromAllianceRanking();
  1290. break;
  1291. case "/ranking/wonder_alliance":
  1292. getPointRatioFromAllianceRanking();
  1293. changeWWRanking(JSON.parse(xhr.responseText).plain.html);
  1294. setWonderIconsOnMap();
  1295. break;
  1296. case "/alliance/members_show":
  1297. getPointRatioFromAllianceMembers();
  1298. break;
  1299. case "/town_info/trading":
  1300. if(DATA.options.trd){addTradeMarks(15, 18, 15, "red"); TownTabHandler(action.split("/")[2]); }
  1301. break;
  1302. case "/farm_town_overviews/get_farm_towns_for_town":
  1303. changeResColor();
  1304. break;
  1305. case "/command_info/conquest_info":
  1306. if(DATA.options.str) {addStrengthConquest();}
  1307. break;
  1308. case "/command_info/conquest_movements": case "/conquest_info/getinfo":
  1309. if(DATA.options.cnt) {countMovements();}
  1310. break;
  1311. case "/building_barracks/index": case "/building_barracks/build":
  1312. if(DATA.options.str) {setStrengthBarracks();}
  1313. break;
  1314. case "/town_info/attack": case "/town_info/support":
  1315. TownTabHandler(action.split("/")[2]);
  1316. break;
  1317. case "/report/index":
  1318. changeDropDownButton();
  1319. loadFilter();
  1320. saveFilter();
  1321. //removeReports();
  1322. break;
  1323. case "/message/default": case "/message/index":
  1324. break;
  1325. case "/chat/init":
  1326. if(DATA.options.irc) {modifyChat();}
  1327. break;
  1328. case "/town_info/go_to_town":
  1329. /*
  1330. //console.log(uw.Layout.wnd);
  1331. var windo = uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).getID();
  1332. //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX));
  1333. uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).setPosition([100,400]);
  1334. //console.log(windo);
  1335. //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).getPosition());
  1336. */
  1337.  
  1338. break;
  1339. }
  1340. },0);
  1341.  
  1342. });
  1343. }
  1344.  
  1345. function test(){
  1346. //http://gpde.innogamescdn.com/images/game/temp/island.png
  1347.  
  1348. //console.log(uw.WMap);
  1349. //console.log(uw.WMap.getSea(uw.WMap.getXCoord(), uw.WMap.getYCoord()));
  1350.  
  1351. //console.log(uw.GameControllers.LayoutToolbarActivitiesController().prototype.getActivityTypes());
  1352. //console.log(uw.GameViews);
  1353. //console.log(uw.GameViews.BarracksUnitDetails());
  1354.  
  1355. //console.log(uw.ITowns.getTown(uw.Game.townId).unitsOuter().sword);
  1356. //console.log(uw.ITowns.getCurrentTown().unitsOuter().sword);
  1357.  
  1358. //console.log(uw.ITowns.getTown(uw.Game.townId).researches().attributes);
  1359. //console.log(uw.ITowns.getTown(uw.Game.townId).hasConqueror());
  1360. //console.log(uw.ITowns.getTown(uw.Game.townId).allUnits());
  1361. //console.log(uw.ITowns.all_units.fragments[uw.Game.townId]._byId);
  1362. //console.log("Zeus: " + uw.ITowns.player_gods.zeus_favor_delta_property.lastTriggeredVirtualPropertyValue);
  1363. //console.log(uw.ITowns.player_gods.attributes);
  1364.  
  1365. //console.log(uw.ITowns.getTown('5813').createTownLink());
  1366. //console.log(uw.ITowns.getTown(5813).unitsOuterTown);
  1367.  
  1368. //console.log(uw.ITowns.getTown(uw.Game.townId).getLinkFragment());
  1369.  
  1370. //console.log(uw.ITowns.getTown(uw.Game.townId).allGodsFavors());
  1371. }
  1372.  
  1373. /*******************************************************************************************************************************
  1374. * Helping functions
  1375. * ----------------------------------------------------------------------------------------------------------------------------
  1376. * | ● fixUnitValues: Get unit values and overwrite some wrong values
  1377. * | ● getMaxZIndex: Get the highest z-index of "ui-dialog"-class elements
  1378. * ----------------------------------------------------------------------------------------------------------------------------
  1379. *******************************************************************************************************************************/
  1380.  
  1381. // Fix buggy grepolis values
  1382. function fixUnitValues(){
  1383. uw.GameData.units.small_transporter.attack = uw.GameData.units.big_transporter.attack = uw.GameData.units.demolition_ship.attack = uw.GameData.units.militia.attack = 0;
  1384. uw.GameData.units.small_transporter.defense = uw.GameData.units.big_transporter.defense = uw.GameData.units.demolition_ship.defense = uw.GameData.units.colonize_ship.defense = 0;
  1385. uw.GameData.units.militia.resources = { wood: 0, stone: 0, iron: 0 };
  1386. }
  1387.  
  1388. function getMaxZIndex(){
  1389. var maxZ = Math.max.apply(null,$.map($("div[class^='ui-dialog']"), function(e,n){
  1390. if($(e).css('position')=='absolute'){
  1391. return parseInt($(e).css('z-index'), 10) || 1000;
  1392. }
  1393. }));
  1394. return (maxZ !== -Infinity)? maxZ + 1 : 1000;
  1395. }
  1396.  
  1397. function getBrowser(){
  1398. var ua = navigator.userAgent, tem,
  1399. M = ua.match(/(opera|maxthon|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
  1400. if(/trident/i.test(M[1])){
  1401. tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
  1402. M[1] = 'IE';
  1403. M[2] = tem[1] || '';
  1404. }
  1405. if(M[1] === 'Chrome'){
  1406. tem = ua.match(/\bOPR\/(\d+)/);
  1407. if(tem != null){
  1408. M[1] = 'Opera';
  1409. M[2] = tem[1];
  1410. }
  1411. }
  1412. M = M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
  1413. if((tem = ua.match(/version\/(\d+)/i))!= null) M.splice(1, 1, tem[1]);
  1414.  
  1415. return M.join(' ');
  1416. }
  1417.  
  1418. // Error Handling / Remote diagnosis / Automatic bug reports
  1419. function errorHandling(e, fn){
  1420. if(PID == 84367 || PID == 104769){
  1421. HumanMessage.error("DIO-TOOLS("+ version +")-ERROR: " + e.message);
  1422. console.log(e.stack);
  1423. } else {
  1424. if(!DATA.error[version]){
  1425. DATA.error[version] = {};
  1426. }
  1427.  
  1428. if(DATA.options.err && !DATA.error[version][fn]){
  1429. $.ajax({
  1430. type: "POST",
  1431. url: "https://diotools.pf-control.de/game/error.php",
  1432. data: { error: e.stack.replace(/'/g,'"') , "function": fn, browser: getBrowser(), version: version },
  1433. success: function (text) {
  1434. DATA.error[version][fn] = true;
  1435. saveValue("error", JSON.stringify(DATA.error));
  1436. }
  1437. });
  1438. }
  1439. }
  1440. }
  1441.  
  1442. // Notification
  1443. function newFeatureNotification(nid, feature){
  1444. var Notification = new NotificationHandler();
  1445. Notification.notify($('#notification_area>.notification').length+1, uw.NotificationType.DIO_TOOLS,
  1446. "<span style='color:rgb(8, 207, 0)'><b><u>New Feature!</u></b></span>"+ feature + "<span class='small notification_date'>DIO-Tools: v"+ version +"</span>");
  1447. }
  1448. // Petition notification
  1449. function petitionNotification(nid){
  1450. var Notification = new NotificationHandler();
  1451. var link = "", headline = "";
  1452. switch(LID){
  1453. case "de":
  1454. headline = 'Petition gegen "Warfare Packages"';
  1455. link = "http://forum.de.grepolis.com/showthread.php?32155";
  1456. break;
  1457. case "nl":
  1458. headline = 'Petitie tegen "Warfare Packages"';
  1459. link = "http://forum.nl.grepolis.com/showthread.php?32350";
  1460. break;
  1461. case "us":
  1462. headline = 'Petition to Stop "Warfare Packages"';
  1463. link = "http://forum.us.grepolis.com/showthread.php?9082";
  1464. default:
  1465. headline = 'Petition to Stop "Warfare Packages"';
  1466. link = "http://forum.en.grepolis.com/showthread.php?55775";
  1467. break;
  1468. }
  1469. Notification.notify($('#notification_area>.notification').length+1, uw.NotificationType.DIO_TOOLS,
  1470. '<span style="color:rgb(8, 207, 0)"><b><u>'+ headline +'</u></b></span><a href="'+ link +'" target="_blank">'+ link +'</a><span class="small notification_date">DIO-Tools: v'+ version +'</span>');
  1471. }
  1472.  
  1473. /*******************************************************************************************************************************
  1474. * Mousewheel Zoom
  1475. *******************************************************************************************************************************/
  1476.  
  1477. // Scroll trough the 2-3 views
  1478. function scrollViews(){
  1479. try {
  1480. var scroll = 2;
  1481. $('#main_area, .ui_city_overview').bind('mousewheel', function(e){
  1482. if($('.island_view').hasClass('checked')){
  1483. scroll = 2;
  1484. } else if($('.strategic_map').hasClass('checked')){
  1485. scroll = 1;
  1486. } else {
  1487. scroll = 3;
  1488. }
  1489. var delta = 0;
  1490. if (e.originalEvent.wheelDelta) {
  1491. if(e.originalEvent.wheelDelta < 0) { delta = -1;} else { delta = 1; }
  1492. }
  1493. if (e.originalEvent.detail) {
  1494. if(e.originalEvent.detail < 0) { delta = 1;} else { delta = -1; }
  1495. }
  1496.  
  1497. if(delta < 0) {
  1498. scroll -= 1;
  1499. if(scroll < 1) { scroll = 1; }
  1500. }else {
  1501. scroll += 1;
  1502. if(scroll > 2 && DATA.options.tov) { scroll = 2; }
  1503. if(scroll > 3) { scroll = 3; }
  1504. }
  1505.  
  1506. switch(scroll){
  1507. case 1: $('.strategic_map').click(); $('#popup_div').css('display', 'none'); break;
  1508. case 2: $('.island_view').click(); break;
  1509. case 3: $('.city_overview').click(); break;
  1510. }
  1511. //prevent page from scrolling
  1512. return false;
  1513. });
  1514. } catch(error){
  1515. errorHandling(error, "scrollViews");
  1516. }
  1517. }
  1518.  
  1519.  
  1520. /*******************************************************************************************************************************
  1521. * Statistics
  1522. * ----------------------------------------------------------------------------------------------------------------------------
  1523. * | ● Expansion of towns?
  1524. * | ● Occupancy of the farms?
  1525. * | ● Mouseclick-Counter?
  1526. * | ● Resource distribution (%)?
  1527. * | ● Building level counter ?
  1528. * ----------------------------------------------------------------------------------------------------------------------------
  1529. *******************************************************************************************************************************/
  1530.  
  1531. function addStatsButton(){
  1532. $('<div class="btn_statistics circle_button"><div class="ico_statistics js-caption"></div></div>').appendTo(".gods_area");
  1533. $('.btn_statistics').css({
  1534. top: '56px',
  1535. left: '-4px',
  1536. zIndex: '10',
  1537. position: 'absolute'
  1538. });
  1539. $('.btn_statistics .ico_statistics').css({
  1540. margin: '7px 0px 0px 8px', width: '17px', height: '17px',
  1541. background: 'url(http://s1.directupload.net/images/140408/pltgqlaw.png) no-repeat 0px 0px', // http://s14.directupload.net/images/140408/k4wikrlq.png // http://s7.directupload.net/images/140408/ahfr8227.png
  1542. backgroundSize: "100%",
  1543. //WebkitFilter: 'hue-rotate(100deg)',
  1544. //filter: 'url(#Hue3)'
  1545. });
  1546.  
  1547. mouseclickCounter();
  1548.  
  1549. $('.btn_statistics').on('mousedown', function(){
  1550. $('.ico_statistics').get(0).style.marginTop = "8px";
  1551. });
  1552. $('.btn_statistics').toggle(function(){
  1553. $('.btn_statistics').addClass("checked");
  1554. $('.ico_statistics').get(0).style.marginTop = "8px";
  1555. //console.log(click_cnt);
  1556. $('#statistics_box').get(0).style.display = "block";
  1557. $('#statistics_box').get(0).style.zIndex = getMaxZIndex() + 1;
  1558. }, function(){
  1559. $('.btn_statistics').removeClass("checked");
  1560. $('.ico_statistics').get(0).style.marginTop = "7px";
  1561. $('#statistics_box').get(0).style.display = "none";
  1562. });
  1563. $('.btn_statistics').tooltip(getText("labels", "uni"));
  1564. }
  1565.  
  1566. var click_cnt = 0;
  1567. function mouseclickCounter(){
  1568. // TODO: start date and reset button
  1569. $('body').click(function(){
  1570. click_cnt++;
  1571. });
  1572. }
  1573.  
  1574. /*******************************************************************************************************************************
  1575. * Body Handler
  1576. * ----------------------------------------------------------------------------------------------------------------------------
  1577. * | ● Town icon
  1578. * | ● Town list: Adds town type to the town list
  1579. * | ● Swap Context Icons
  1580. * | ● City overview
  1581. * ----------------------------------------------------------------------------------------------------------------------------
  1582. *******************************************************************************************************************************/
  1583.  
  1584. var townTypeIcon = {
  1585. // Automatic Icons
  1586. lo: 0, ld: 3, so: 6, sd: 7, fo: 10, fd: 9, bu: 14, /* Building */ po: 22, no: 12,
  1587.  
  1588. // Manual Icons
  1589. fa: 20, /* Favor */ re: 15, /* Resources */ di: 2, /* Distance */ sh: 1, /* Pierce */ lu: 13, /* ?? */ dp: 11, /* Diplomacy */ ha: 15, /* ? */ si: 18, /* Silber */ ra: 17, ch: 19, /* Research */ ti: 23, /* Time */ un: 5,
  1590. wd: 16, /* Wood */ wo: 24, /* World */ bo: 13, /* Booty */ gr: 21, /* Lorbeer */ st: 17, /* Stone */ is: 26, /* ?? */ he: 4, /* Helmet */ ko: 8 /* Kolo */
  1591. },
  1592. townTypeIcon2 = {
  1593. lo: "http://s14.directupload.net/images/140129/gvctb3i5.png", // red: http://s7.directupload.net/images/140129/mn4m2vhx.png kreuz: http://s1.directupload.net/images/140129/rdvuhlmc.png
  1594. ld: "http://s7.directupload.net/images/140129/zwts6zz8.png", // blue: http://s1.directupload.net/images/140129/oua87w9q.png
  1595. so: "http://s7.directupload.net/images/140129/674supp9.png", // smaller: http://s14.directupload.net/images/140129/x7jv2kc9.png
  1596. sd: "http://s14.directupload.net/images/140129/aseivxpl.png",
  1597. fo: "http://s14.directupload.net/images/140129/j9mwfuu4.png", // bright: http://s1.directupload.net/images/140129/7ueia7ja.png
  1598. fd: "http://s7.directupload.net/images/140129/lwtlj9ej.png", // bright: http://s1.directupload.net/images/140129/4an4dhr7.png
  1599.  
  1600. bu: "http://s1.directupload.net/images/140129/y3d6znpg.png", // http://s14.directupload.net/images/140129/wb9w9odq.png, // build2: http://s1.directupload.net/images/140129/qzj2vem6.png bbcode: http://s7.directupload.net/images/140129/d39yg9zj.png
  1601. po: "http://gpde.innogamescdn.com/images/game/res/pop.png",
  1602. no: "http://s7.directupload.net/images/140129/t8tjs543.png", // green: http://s7.directupload.net/images/140129/zneb6f3m.png
  1603. // brown: http://s14.directupload.net/images/140129/fhlanrua.png http://s14.directupload.net/images/140129/9m4xtmys.png http://s7.directupload.net/images/140129/9hflkab3.png
  1604.  
  1605. // Manual Icons
  1606. fa: "http://s7.directupload.net/images/140404/xt839us6.png", // "http://s7.directupload.net/images/140404/xifwkdqy.png",
  1607. re: "http://s14.directupload.net/images/140404/b4n3tyjh.png",
  1608. di: "http://s14.directupload.net/images/140404/nvqxx5j7.png",
  1609. sh: "http://s1.directupload.net/images/140404/mbvpptpg.png",
  1610. lu: "http://s1.directupload.net/images/140404/38n97lp5.png",
  1611. // ro: "http://s14.directupload.net/images/140404/9o22obra.png",
  1612. dp: "http://s1.directupload.net/images/140404/95cgvzcp.png",
  1613. ha: "http://s1.directupload.net/images/140404/9om7bf4m.png",
  1614. si: "http://s1.directupload.net/images/140404/b5eumrw7.png",
  1615. ra: "http://s14.directupload.net/images/140404/3qofe863.png",
  1616. ch: "http://s7.directupload.net/images/140404/jrthehnw.png",
  1617. ti: "http://s7.directupload.net/images/140404/u2a5x7as.png", // "http://s1.directupload.net/images/140404/ceubhq4f.png",
  1618. un: "http://s1.directupload.net/images/140404/x3um2uvt.png", //"http://s14.directupload.net/images/140404/ib4w63he.png", //"http://s7.directupload.net/images/140404/ltegir8t.png", //"http://s1.directupload.net/images/140404/88ljrpvt.png",
  1619.  
  1620. wd: "http://s7.directupload.net/images/140404/te9zldjx.png",
  1621. wo: "http://s1.directupload.net/images/140404/cxbjhapw.png",
  1622. bo: "http://s14.directupload.net/images/140404/ki4gwd7x.png",
  1623. gr: "http://s14.directupload.net/images/140404/n7bq4ixc.png",
  1624. st: "http://s1.directupload.net/images/140404/zwc8ctqh.png",
  1625. is: "http://s1.directupload.net/images/140404/48nlm7xd.png",
  1626. he: "http://s7.directupload.net/images/140404/uldko8rb.png",
  1627.  
  1628.  
  1629. ko: "http://s7.directupload.net/images/140404/r8kikv5d.png", // "http://s7.directupload.net/images/140404/qpawnrwd.png" // "http://s1.directupload.net/images/140404/icuao2mf.png" //
  1630. },
  1631. worldWonderIcon = {
  1632. colossus_of_rhodes: "url(http://gpde.innogamescdn.com/images/game/map/wonder_colossus_of_rhodes.png) 38px -1px;",
  1633. great_pyramid_of_giza: "url(http://gpde.innogamescdn.com/images/game/map/wonder_great_pyramid_of_giza.png) 34px -6px;",
  1634. hanging_gardens_of_babylon: "url(http://gpde.innogamescdn.com/images/game/map/wonder_hanging_gardens_of_babylon.png) 34px -5px;",
  1635. lighthouse_of_alexandria: "url(http://gpde.innogamescdn.com/images/game/map/wonder_lighthouse_of_alexandria.png) 37px -1px;",
  1636. mausoleum_of_halicarnassus: "url(http://gpde.innogamescdn.com/images/game/map/wonder_mausoleum_of_halicarnassus.png) 37px -4px;",
  1637. statue_of_zeus_at_olympia: "url(http://gpde.innogamescdn.com/images/game/map/wonder_statue_of_zeus_at_olympia.png) 36px -3px;",
  1638. temple_of_artemis_at_ephesus: "url(http://gpde.innogamescdn.com/images/game/map/wonder_temple_of_artemis_at_ephesus.png) 34px -5px;"
  1639. };
  1640.  
  1641. function setWonderIconsOnMap(){
  1642. try {
  1643. if(!$('#wondericons_map').get(0)){
  1644. var color = "orange";
  1645.  
  1646. // style for world wonder icons
  1647. var style_str = "<style id='wondericons_map' type='text/css'>";
  1648. for(var ww_type in wonder.map){
  1649. if(wonder.map.hasOwnProperty(ww_type)){
  1650. for(var ww in wonder.map[ww_type]){
  1651. if(wonder.map[ww_type].hasOwnProperty(ww)){
  1652. /*
  1653. if(wonder.map[ww_type][ww] !== AID){
  1654. color = "rgb(192, 109, 54)";
  1655. } else {
  1656. color = "orange";
  1657. }
  1658. */
  1659. style_str += "#mini_i" + ww + ":before {"+
  1660. "content: '';"+
  1661. "background:"+ color + " " + worldWonderIcon[ww_type] +
  1662. "background-size: auto 97%;"+
  1663. "padding: 8px 16px;"+
  1664. "top: 50px;"+
  1665. "position: relative;"+
  1666. "border-radius: 40px;"+
  1667. "z-index: 200;"+
  1668. "cursor: pointer;"+
  1669. "box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5);"+
  1670. "border: 2px solid green; } "+
  1671. "#mini_i" + ww + ":hover:before { z-index: 201; "+
  1672. "filter: url(#Brightness12);"+
  1673. "-webkit-filter: brightness(1.2);} ";
  1674. }
  1675. }
  1676. }
  1677. }
  1678. $(style_str + "</style>").appendTo('head');
  1679.  
  1680. // Context menu on mouseclick
  1681. $('#minimap_islands_layer').on('click', '.m_island', function(e){
  1682. var ww_coords = this.id.split("i")[3].split("_");
  1683. uw.Layout.contextMenu(e, 'wonder', {ix: ww_coords[0], iy: ww_coords[1]});
  1684. });
  1685.  
  1686.  
  1687. }
  1688. } catch(error) {
  1689. errorHandling(error, "setWonderIconsOnMap");
  1690. }
  1691. }
  1692.  
  1693. function setTownIconsOnMap(){
  1694. try {
  1695. // if town icon changed
  1696. if($('#townicons_map').get(0)){ $('#townicons_map').remove(); }
  1697.  
  1698. // style for own towns (town icons)
  1699. var start = (new Date()).getTime(), end, style_str = "<style id='townicons_map' type='text/css'>";
  1700. for(var e in autoTownTypes){
  1701. if(autoTownTypes.hasOwnProperty(e)){
  1702. style_str += "#mini_t"+ e +" { height: 19px;"+
  1703. "width:19px;"+
  1704. "border-radius: 11px;"+
  1705. "border: 2px solid rgb(16, 133, 0);"+
  1706. "margin: -4px;"+
  1707. //"background: rgb(255, 187, 0) url(http://s7.directupload.net/images/140404/xt839us6.png) repeat;"+
  1708. "background: rgb(255, 187, 0) url("+ dio_sprite +") "+ (townTypeIcon[(manuTownTypes[e] || autoTownTypes[e])]*-25) +"px -27px repeat;"+
  1709. "z-index: 100;"+
  1710. "font-size: 0em;"+
  1711. "cursor: pointer;"+
  1712. "box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5);} "+
  1713. "#mini_t"+ e +":hover { z-index: 101; "+
  1714. "filter: url(#Brightness12);" +
  1715. "-webkit-filter: brightness(1.2);} ";
  1716. }
  1717. }
  1718.  
  1719. // Context menu on mouseclick
  1720. $('#minimap_islands_layer').on('click', '.m_town', function(z){
  1721. var id = parseInt($(this).get(0).id.substring(6), 10);
  1722. uw.Layout.contextMenu(z, 'determine', {"id": id, "name": uw.ITowns.getTown(id).name });
  1723.  
  1724. z.stopPropagation(); // prevent parent world wonder event
  1725. });
  1726.  
  1727. // Style for foreign cities (shadow)
  1728. style_str += ".m_town { text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.7); } ";
  1729.  
  1730. style_str += "</style>";
  1731. $(style_str).appendTo('head');
  1732. /*
  1733. setTimeout(function(){
  1734. uw.MapTiles.createTownDiv_old = uw.MapTiles.createTownDiv;
  1735.  
  1736. uw.MapTiles.createTownDiv = function(town, player_current_town) {
  1737. var ret = uw.MapTiles.createTownDiv_old(town, player_current_town);
  1738.  
  1739. if(!isNaN(town.id) && town.player_id == PID) {
  1740.  
  1741. //setIconMap(town.id);
  1742. console.log(town.id);
  1743. console.log(player_current_town);
  1744. }
  1745. return ret;
  1746. };
  1747. },2000);
  1748. */
  1749. } catch(error) {
  1750. errorHandling(error, "setTownIconsOnMap");
  1751. }
  1752. }
  1753.  
  1754. // Style for town icons
  1755. var style_str = '<style id="townicons" type="text/css">';
  1756. for(var s in townTypeIcon){
  1757. if(townTypeIcon.hasOwnProperty(s)){
  1758. style_str += '.townicon_'+ s +' { background:url('+ dio_sprite +') '+ (townTypeIcon[s]*-25) +'px -26px repeat;float:left;} ';
  1759. }
  1760. }
  1761. style_str += '</style>';
  1762. $(style_str).appendTo('head');
  1763.  
  1764.  
  1765. // City overview
  1766. function setCityWindowContext(){
  1767. // $.each($("#goToTown").data("events"), function(i, e) { //console.log(i); });
  1768. if(uw.Layout.wnd.TYPE_TOWNINDEX){
  1769. $('#goToTown').unbind("mousedown");
  1770. $('#goToTown').on("mousedown", function(){
  1771. uw.GPWindowMgr.Create(uw.Layout.wnd.TYPE_TOWNINDEX, uw.DM.getl10n('town_index').window_title +" - "+ uw.ITowns.getTown(uw.Game.townId).name);
  1772. if($('#select_town').get(0)) {$('#select_town').mousedown(); }
  1773. var town = setInterval(function(){
  1774. if($('#town_background').get(0)){
  1775. document.getSelection().removeAllRanges();
  1776. clearInterval(town);
  1777. }
  1778. }, 50);
  1779. });
  1780. }
  1781. }
  1782. function setCityWindowButton(){
  1783. $("#ui_box .bull_eye_buttons .city_overview").appendTo('#ui_box .bull_eye_buttons');
  1784. $("#ui_box .bull_eye_buttons .city_overview").css({
  1785. left: '18px',
  1786. top: '3px'
  1787. });
  1788. if(uw.Layout.wnd.TYPE_TOWNINDEX){
  1789. $('.bull_eye_buttons .city_overview').on("click", function(){
  1790. uw.GPWindowMgr.Create(uw.Layout.wnd.TYPE_TOWNINDEX, uw.DM.getl10n('town_index').window_title +" - "+ uw.ITowns.getTown(uw.Game.townId).name);
  1791. });
  1792. }
  1793. }
  1794.  
  1795. function changeContextMenu(){
  1796. // Set context menu event handler
  1797. $.Observer(uw.GameEvents.map.context_menu.click).subscribe('DIO_CONTEXT', function(e,data){
  1798. if(DATA.options.con && $('#context_menu').children().length == 4){
  1799. // Clear animation
  1800. $('#context_menu div#goToTown').css({
  1801. left: '0px',
  1802. top: '0px',
  1803. WebkitAnimation: 'none', //'A 0s linear',
  1804. animation: 'none' //'B 0s linear'
  1805. });
  1806. }
  1807. // Set 'goToTown' button
  1808. if(DATA.options.tov && $('#goToTown').get(0)){
  1809. setCityWindowContext();
  1810. }
  1811. // Replace german label of 'select town' button
  1812. if(LID === "de" && $('#select_town').get(0)){
  1813. $("#select_town .caption").get(0).innerHTML = "Selektieren";
  1814. }
  1815. });
  1816.  
  1817. // Set context menu animation
  1818. if(!$('#select_town').get(0) && !$('#espionage').get(0)){
  1819. var ani_duration = 0;
  1820. // set fixed position of 'select town' button
  1821. $('<style type="text/css"> #select_town { left: 0px !important; top: 0px !important; z-index: 6} </style>').appendTo('head'); //-webkit-filter: hue-rotate(65deg);filter: url(#Hue1);
  1822.  
  1823. // set animation of 'goToTown' button
  1824. $('<style id="dio_context" type="text/css"> #context_menu div#goToTown { left: 30px; top: -51px; '+
  1825. '-webkit-animation: A 0.115s linear; animation: B 0.2s;} '+
  1826. '@-webkit-keyframes A { from {left: 0px; top: 0px;} to {left: 30px; top: -51px;} }'+
  1827. '@keyframes B { from {left: 0px; top: 0px;} to {left: 30px; top: -51px;} }'+
  1828. '</style>').appendTo('head');
  1829. }
  1830. }
  1831.  
  1832. function imageSelectionProtection(){
  1833. $('<style type="text/css"> img { -moz-user-select: -moz-none; -khtml-user-select: none; -webkit-user-select: none;} </style>').appendTo('head');
  1834. }
  1835.  
  1836. function setTownList(){
  1837. // TODO: rewrite in one style tag
  1838.  
  1839. // Town list
  1840. $('<style type="text/css"> #town_groups_list .item { text-align: left; padding-left:35px;} </style>').appendTo('head');
  1841. //$('<style type="text/css"> #town_groups_list .inner_column { width: 172px !important; float:left; margin-bottom:20px; position:relative !important; left:0px !important; top:0px !important} </style>').appendTo('head');
  1842. $('<style type="text/css"> #town_groups_list .inner_column { border: 1px solid rgba(100, 100, 0, 0.3);margin: -2px 0px 0px 2px;} </style>').appendTo('head');
  1843. $('<style type="text/css"> .town_groups_list .island_quest_icon { background-size: 90%; position: absolute; right: 37px; top: 4px;} </style>').appendTo('head');
  1844.  
  1845. // Quacks Zentrier-Button verschieben
  1846. $('<style type="text/css"> #town_groups_list .jump_town { right: 37px !important;} </style>').appendTo('head');
  1847.  
  1848. // Population percentage
  1849. $('<style type="text/css"> #town_groups_list .pop_percent { position: absolute; right: 7px; font-size: 0.7em;} '+
  1850. '#town_groups_list .full { color: green; }'+
  1851. '#town_groups_list .threequarter { color: darkgoldenrod; }'+
  1852. '#town_groups_list .half { color: darkred; }'+
  1853. '#town_groups_list .quarter { color: red; }'+
  1854. '</style>').appendTo('head');
  1855.  
  1856. // Town Icons
  1857. $('<style type="text/css"> .icon_small { height:20px;padding-left:25px;margin-left:-25px; background-clip:padding-box;} </style>').appendTo('head');
  1858.  
  1859.  
  1860. // Open town list: hook to grepolis function render()
  1861. if(DATA.options.twn){
  1862. var i = 0;
  1863. while(uw.layout_main_controller.sub_controllers[i].name != 'town_name_area'){ i++; }
  1864.  
  1865. uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render_old = uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render;
  1866.  
  1867. uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render = function() {
  1868. uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render_old();
  1869. changeTownList();
  1870. };
  1871. }
  1872. }
  1873.  
  1874. function changeTownList(){
  1875. $("#town_groups_list .town_group_town").each(function() {
  1876. try {
  1877. var town_id = $(this).attr('name'), str = $(this).get(0).innerHTML, townicon_str, percent_str = "", percent = -1,
  1878. space = "full";
  1879.  
  1880. if(population[town_id]){
  1881. percent = population[town_id].percent;
  1882. }
  1883.  
  1884. if(percent < 75){ space = "threequarter"; }
  1885. if(percent < 50){ space = "half"; }
  1886. if(percent < 25){ space = "quarter"; }
  1887.  
  1888. if (!(str.indexOf("townicon") >= 0)){
  1889. townicon_str= '<div class="icon_small townicon_'+ (manuTownTypes[town_id] || autoTownTypes[town_id] || "no") +'"></div>';
  1890. // TODO: Notlösung...
  1891. if(percent != -1){
  1892. percent_str = '<div class="pop_percent '+ space +'">' + percent + '%</div>';
  1893. }
  1894.  
  1895. $(this).get(0).innerHTML = townicon_str + percent_str + str;
  1896. }
  1897.  
  1898. // opening context menu
  1899. /*
  1900. $(this).click(function(e){
  1901. console.log(e);
  1902. uw.Layout.contextMenu(e, 'determine', {"id": town_id,"name": uw.ITowns[town_id].getName()});
  1903. });
  1904. */
  1905.  
  1906. } catch(error){
  1907. errorHandling(error, "changeTownList");
  1908. }
  1909. });
  1910.  
  1911. $("#town_groups_list .town_group_town").hover(function(){
  1912. $(this).find('.island_quest_icon').css({
  1913. display: "none"
  1914. });
  1915. }, function(){
  1916. $(this).find('.island_quest_icon').css({
  1917. display: "block"
  1918. });
  1919. });
  1920.  
  1921. // Add change town list event handler
  1922. $.Observer(uw.GameEvents.town.town_switch).unsubscribe('DIO_SWITCH_TOWN');
  1923. $.Observer(uw.GameEvents.town.town_switch).subscribe('DIO_SWITCH_TOWN', function () {
  1924. changeTownList();
  1925. });
  1926. }
  1927.  
  1928. function addTownIcon(){
  1929. try {
  1930. // Quickbar modification
  1931. $('.ui_quickbar .left, .ui_quickbar .right').css({ width: '46%' });
  1932.  
  1933. $('<div id="town_icon"><div class="town_icon_bg"><div class="icon_big townicon_'+
  1934. (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no") + " auto")) + '"></div></div></div>').appendTo('.town_name_area');
  1935.  
  1936.  
  1937. $('.town_name_area').css({ zIndex: 11, left: '52%' }); // because of Kapsonfires Script and Beta Worlds bug report bar
  1938. $('.town_name_area .left').css({
  1939. zIndex: 20,
  1940. left: '-39px'
  1941. });
  1942.  
  1943. // Town Icon Style
  1944. $('#town_icon .icon_big').css({
  1945. backgroundPosition: townTypeIcon[(manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")))]*-25 + 'px 0px'
  1946. });
  1947.  
  1948. $('<style type="text/css">'+
  1949. '#town_icon { background:url('+ dio_sprite +') 0 -125px no-repeat; position:absolute; width:69px; height:61px; left:-47px; top:0px; z-index: 10; } '+
  1950. '#town_icon .town_icon_bg { background:url('+ dio_sprite +') -76px -129px no-repeat; width:43px; height:43px; left:25px; top:4px; cursor:pointer; position: relative; } '+
  1951. '#town_icon .town_icon_bg:hover { filter:url(#Brightness11); -webkit-filter:brightness(1.1); box-shadow: 0px 0px 15px rgb(1, 197, 33); } '+
  1952. '#town_icon .icon_big { position:absolute; left:9px; top:9px; height:25px; width:25px; } '+
  1953. '</style>').appendTo('head');
  1954.  
  1955.  
  1956. var icoArray = ['ld', 'lo', 'sh', 'di', 'un',
  1957. 'sd', 'so', 'ko', 'ti', 'gr',
  1958. 'fd', 'fo', 'dp', 'no', 'po',
  1959. 're', 'wd', 'st', 'si', 'bu',
  1960. 'he', 'ch', 'bo', 'fa', 'wo'];
  1961.  
  1962. // Fill select box with town icons
  1963. $('<div class="select_town_icon dropdown-list default active"><div class="item-list"></div></div>').appendTo("#town_icon");
  1964. for(var i in icoArray){
  1965. if(icoArray.hasOwnProperty(i)){
  1966. $('.select_town_icon .item-list').append('<div class="option_s icon_small townicon_'+ icoArray[i] +'" name="'+ icoArray[i] +'"></div>');
  1967. }
  1968. }
  1969. $('<hr><div class="option_s auto_s" name="auto"><b>Auto</b></div>').appendTo('.select_town_icon .item-list');
  1970.  
  1971. // Styles
  1972. $('#town_icon .select_town_icon').css({
  1973. position: 'absolute',
  1974. top: '47px',
  1975. left: '23px',
  1976. width: '145px',
  1977. display: "none",
  1978. padding: '2px',
  1979. border: '3px inset rgb(7, 99, 12)',
  1980. boxShadow: 'rgba(0, 0, 0, 0.5) 4px 4px 6px',
  1981. borderRadius: '0px 10px 10px 10px',
  1982. background: "url(https://gpde.innogamescdn.com/images/game/popup/middle_middle.png)"
  1983. });
  1984. $('#town_icon .item-list').css({ maxHeight: '400px', maxWidth: '200px', align: "right", overflowX: 'hidden' });
  1985.  
  1986. $('<style type="text/css">'+
  1987. '#town_icon .option_s { cursor:pointer; width:20px; height:20px; margin:0px; padding:2px 2px 3px 3px; border:2px solid rgba(0,0,0,0); border-radius:5px; background-origin:content-box; background-clip:content-box;} '+
  1988. '#town_icon .option_s:hover { border: 2px solid rgb(59, 121, 81) !important;-webkit-filter: brightness(1.3); } '+
  1989. '#town_icon .sel { border: 2px solid rgb(202, 176, 109); } '+
  1990. '#town_icon hr { width:145px; margin:0px 0px 7px 0px; position:relative; top:3px; border:0px; border-top:2px dotted #000; float:left} '+
  1991. '#town_icon .auto_s { width:136px; height:16px; float:left} '+
  1992. '</style>').appendTo('head');
  1993.  
  1994. $('#town_icon .option_s').click(function(){
  1995. $("#town_icon .sel").removeClass("sel"); $(this).addClass("sel");
  1996.  
  1997. if($(this).attr("name") === "auto"){
  1998. delete manuTownTypes[uw.Game.townId];
  1999. } else {
  2000. manuTownTypes[uw.Game.townId] = $(this).attr("name");
  2001. }
  2002. changeTownIcon();
  2003. saveValue(WID + "_townTypes", JSON.stringify(manuTownTypes));
  2004. });
  2005.  
  2006. // Show & hide drop menus on click
  2007. $('#town_icon .town_icon_bg').click(function(){
  2008. var el = $('#town_icon .select_town_icon').get(0);
  2009. if( el.style.display === "none"){
  2010. el.style.display = "block";
  2011. } else {
  2012. el.style.display = "none";
  2013. }
  2014. });
  2015.  
  2016. $('#town_icon .select_town_icon [name="'+ (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" :"" )) +'"]').addClass("sel");
  2017.  
  2018. } catch(error){
  2019. errorHandling(error, "addTownIcon");
  2020. }
  2021. }
  2022.  
  2023. function changeTownIcon(){
  2024. var townType = (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")));
  2025. $('#town_icon .icon_big').removeClass().addClass('icon_big townicon_'+ townType + " auto");
  2026. $('#town_icon .sel').removeClass("sel");
  2027. $('#town_icon .select_town_icon [name="'+ (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" :"" )) +'"]').addClass("sel");
  2028.  
  2029. $('#town_icon .icon_big').css({
  2030. backgroundPosition: townTypeIcon[townType]*-25 + 'px 0px'
  2031. });
  2032.  
  2033. $('#town_icon .select_town_icon').get(0).style.display = "none";
  2034.  
  2035. // update town icons on the map
  2036. setTownIconsOnMap();
  2037. }
  2038.  
  2039. /*******************************************************************************************************************************
  2040. * Available units
  2041. * ----------------------------------------------------------------------------------------------------------------------------
  2042. * | ● Shows all available units
  2043. * ----------------------------------------------------------------------------------------------------------------------------
  2044. *******************************************************************************************************************************/
  2045. function addAvailableUnitsButton(){
  2046. var default_title = DM.getl10n("place", "support_overview").options.troop_count + " ("+ DM.getl10n("hercules2014", "available")+")";
  2047.  
  2048. $('<div class="btn_available_units circle_button"><div class="ico_available_units js-caption"></div></div>').appendTo(".bull_eye_buttons");
  2049. $('.btn_available_units').css({
  2050. top: '86px',
  2051. left: '119px',
  2052. zIndex: '10',
  2053. position: 'absolute'
  2054. });
  2055. $('.btn_available_units .ico_available_units').css({
  2056. margin: '5px 0px 0px 4px', width: '24px', height: '24px',
  2057. background: 'url(http://s1.directupload.net/images/140323/w4ekrw8b.png) no-repeat 0px 0px', //http://gpde.innogamescdn.com/images/game/res/unit.png
  2058. backgroundSize: "100%",
  2059. filter: 'url(#Hue1)',
  2060. WebkitFilter: 'hue-rotate(100deg)'
  2061.  
  2062. });
  2063. $('.btn_available_units').on('mousedown', function(){
  2064. $('.ico_available_units').get(0).style.marginTop = "6px";
  2065. });
  2066. $('.btn_available_units').toggle(function(){
  2067. $('#available_units_box').get(0).style.display = "block";
  2068. $('#available_units_box').get(0).style.zIndex = getMaxZIndex() + 1;
  2069. $('.btn_available_units').addClass("checked");
  2070. $('.ico_available_units').get(0).style.marginTop = "6px";
  2071. }, function(){
  2072. $('#available_units_box').get(0).style.display = "none";
  2073. $('.btn_available_units').removeClass("checked");
  2074. $('.ico_available_units').get(0).style.marginTop = "5px";
  2075. });
  2076. $('.btn_available_units').tooltip(LANG.hasOwnProperty(LID) ? getText("labels", "uni") : default_title);
  2077. }
  2078.  
  2079. /*******************************************************************************************************************************
  2080. * Comparison
  2081. * ----------------------------------------------------------------------------------------------------------------------------
  2082. * | ● Compares the units of each unit type
  2083. * ----------------------------------------------------------------------------------------------------------------------------
  2084. *******************************************************************************************************************************/
  2085. function addComparisonButton(){
  2086. $('<div class="btn_comparison circle_button"><div class="ico_comparison js-caption"></div></div>').appendTo(".bull_eye_buttons");
  2087. $('.btn_comparison').css({
  2088. top: '51px',
  2089. left: '120px',
  2090. zIndex: '10',
  2091. position: 'absolute'
  2092. });
  2093. $('.btn_comparison .ico_comparison').css({
  2094. margin: '5px 0px 0px 4px', width: '24px', height: '24px',
  2095. background: 'url(http://666kb.com/i/cjq6cxia4ms8mn95r.png) no-repeat 0px 0px',
  2096. backgroundSize: "100%",
  2097. filter: 'url(#Hue1)',
  2098. WebkitFilter: 'hue-rotate(60deg)'
  2099. });
  2100. $('.btn_comparison').on('mousedown', function(){
  2101. $('.ico_comparison').get(0).style.marginTop = "6px";
  2102. });
  2103. $('.btn_comparison').toggle(function(){
  2104. $('#unit_box').get(0).style.display = "block";
  2105. $('#unit_box').get(0).style.zIndex = getMaxZIndex() + 1;
  2106. $('.btn_comparison').addClass("checked");
  2107. $('.ico_comparison').get(0).style.marginTop = "6px";
  2108. }, function(){
  2109. $('#unit_box').get(0).style.display = "none";
  2110. $('.btn_comparison').removeClass("checked");
  2111. $('.ico_comparison').get(0).style.marginTop = "5px";
  2112. });
  2113. $('.btn_comparison').tooltip(getText("labels", "dsc"));
  2114. }
  2115.  
  2116. function addComparisonBox(){
  2117. var pos = {
  2118. att: { hack: "36%", pierce: "27%", distance: "45.5%", ship: "72.5%" },
  2119. def: { hack: "18%", pierce: "18%", distance: "18%", ship: "81.5%" }
  2120. };
  2121.  
  2122. var unitIMG = "https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png";
  2123. $('<div id="unit_box" class="ui-dialog">'+
  2124. '<div class="bbcode_box middle_center"><div class="bbcode_box middle_right"></div><div class="bbcode_box middle_left"></div>'+
  2125. '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div><div class="bbcode_box top_center"></div>'+
  2126. '<div class="bbcode_box bottom_center"></div><div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>'+
  2127. '<div style="height:20px; margin-left:35px;">'+
  2128. '<a class="hack" href="#" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att.hack +';">'+
  2129. '<span style="margin-left:20px">'+ getText("labels", "hck") +'</span></a>'+
  2130. '<a class="pierce" href="#" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att.pierce +';">'+
  2131. '<span style="margin-left:20px">'+ getText("labels", "prc") +'</span></a>'+
  2132. '<a class="distance" href="#" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att.distance +';">'+
  2133. '<span style="margin-left:20px">'+ getText("labels", "dst") +'</span></a>'+
  2134. '<a class="ship" href="#" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att.ship +';">'+
  2135. '<span style="margin-left:20px">'+ getText("labels", "sea") +'</span></a>'+
  2136. '</div><hr>'+
  2137. '<div class="box_content"></div></div>').appendTo('body');
  2138.  
  2139. $('#unit_box a').css({
  2140. float: 'left',
  2141. backgroundRepeat: 'no-repeat',
  2142. backgroundSize: '25px',
  2143. lineHeight: '2',
  2144. marginRight:'10px'
  2145. });
  2146. $('#unit_box span').css({
  2147. marginLeft: '27px',
  2148. });
  2149. $('#unit_box').draggable({
  2150. containment: "body",
  2151. snap: "body",
  2152. });
  2153. $('#unit_box').css({
  2154. position: 'absolute',
  2155. top: '100px',
  2156. left: '200px',
  2157. zIndex: getMaxZIndex() + 1,
  2158. display: 'none'
  2159. });
  2160. $('#unit_box .box_content').css({
  2161. background: 'url(http://s1.directupload.net/images/140206/8jd9d3ec.png) 94% 94% no-repeat',
  2162. backgroundSize: '140px'
  2163. });
  2164.  
  2165. $('#unit_box').bind("mousedown",function(){
  2166. $(this).get(0).style.zIndex = getMaxZIndex() + 1;
  2167. });
  2168.  
  2169. addComparisonTable("hack");
  2170. addComparisonTable("pierce");
  2171. addComparisonTable("distance");
  2172. addComparisonTable("ship");
  2173.  
  2174. $('#unit_box .t_hack').get(0).style.display = "block";
  2175.  
  2176. // Tooltips
  2177. /*
  2178. var labelArray = DM.getl10n("common", "barracks_and_docs"),
  2179. labelAttack = DM.getl10n("context_menu", "titles").attack,
  2180. labelDefense = DM.getl10n("place", "tabs")[0];
  2181.  
  2182. $('.tr_att').tooltip(labelAttack);
  2183. $('.tr_def').tooltip(labelDefense + " (Ø)");
  2184. $('.tr_def_ship').tooltip(labelDefense);
  2185. $('.tr_spd').tooltip(labelArray.tooltips.speed);
  2186. $('.tr_bty').tooltip(labelArray.tooltips.booty.title);
  2187. $('.tr_bty_ship').tooltip(labelArray.tooltips.ship_transport.title);
  2188. $('.tr_res').tooltip(labelArray.costs + " (" +
  2189. labelArray.cost_details.wood + " + " +
  2190. labelArray.cost_details.stone + " + " +
  2191. labelArray.cost_details.iron + ")"
  2192. );
  2193. $('.tr_fav').tooltip(labelArray.costs + " (" + labelArray.cost_details.favor + ")");
  2194. $('.tr_tim').tooltip(labelArray.cost_details.buildtime_barracks + " (s)");
  2195. $('.tr_tim_ship').tooltip(labelArray.cost_details.buildtime_docks + " (s)");
  2196. */
  2197. switchComparisonTables();
  2198.  
  2199. $('#unit_box hr').css({ border: '1px solid', color: '#804000', float:'none' });
  2200. }
  2201.  
  2202. function switchComparisonTables(){
  2203. $('#unit_box .hack, #unit_box .pierce, #unit_box .distance, #unit_box .ship').click(function(){
  2204. $('#unit_box [class^="t_"]').css({ display : "none" });
  2205. $('#unit_box .t_'+this.className).get(0).style.display = "block";
  2206. });
  2207. }
  2208.  
  2209. var ttpArray = [], t = 0;
  2210. function addComparisonTable(type){
  2211. var pos = {
  2212. att: { hack: "36%", pierce: "27%", distance: "45.5%", ship: "72.5%" },
  2213. def: { hack: "18%", pierce: "18%", distance: "18%", ship: "81.5%" }
  2214. };
  2215. var unitIMG = "https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png";
  2216. var strArray = [
  2217. "<td></td>",
  2218. '<td><div class="bla" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att[type] +';"></div></td>',
  2219. '<td><div class="bla" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.def[type] +';"></div></td>',
  2220. '<td><div class="bla" style="background: url('+ unitIMG +'); background-position: 0% 63%;"></div></td>',
  2221. (type !== "ship") ? '<td><div class="booty"></div></td>' : '<td><div class="bla" style="background-image: url('+ unitIMG +'); background-position: 0% 91%;"></div></td>',
  2222. '<td><div class="bla" style="background: url('+ unitIMG +'); background-position: 0% 54%;"></div></td>',
  2223. '<td><div class="bla" style="background: url(https://gpall.innogamescdn.com/images/game/res/favor.png)"></div></td>',
  2224. '<td><div class="bla" style="background: url(https://gpall.innogamescdn.com/images/game/res/time.png);"></div></td>'
  2225. ];
  2226.  
  2227. for(var e in uw.GameData.units){
  2228. if(uw.GameData.units.hasOwnProperty(e)){
  2229. var valArray = [];
  2230.  
  2231. if(type === (uw.GameData.units[e].attack_type || "ship") && (e !== "militia")) {
  2232. valArray.att = Math.round(uw.GameData.units[e].attack*10 / uw.GameData.units[e].population) / 10;
  2233. valArray.def = Math.round(((uw.GameData.units[e].def_hack + uw.GameData.units[e].def_pierce + uw.GameData.units[e].def_distance)*10)/(3*uw.GameData.units[e].population)) / 10;
  2234. valArray.def = valArray.def || Math.round(uw.GameData.units[e].defense*10/uw.GameData.units[e].population) / 10;
  2235. valArray.speed = uw.GameData.units[e].speed;
  2236. valArray.booty = Math.round(((uw.GameData.units[e].booty)*10) / uw.GameData.units[e].population) / 10;
  2237. valArray.booty = valArray.booty || Math.round(((uw.GameData.units[e].capacity ? uw.GameData.units[e].capacity + 6 : 0)*10) / uw.GameData.units[e].population) / 10;
  2238. valArray.favor = Math.round((uw.GameData.units[e].favor *10)/ uw.GameData.units[e].population) / 10;
  2239. valArray.res = Math.round((uw.GameData.units[e].resources.wood + uw.GameData.units[e].resources.stone + uw.GameData.units[e].resources.iron)/(uw.GameData.units[e].population));
  2240. valArray.time = Math.round(uw.GameData.units[e].build_time / uw.GameData.units[e].population);
  2241.  
  2242. valArray.heroStyle = ""; valArray.heroStyleIMG = "";
  2243.  
  2244. // World without Artemis? -> grey griffin and boar
  2245. if(!uw.Game.hasArtemis && ((e === "griffin") || (e === "calydonian_boar"))){
  2246. valArray.heroStyle = "color:black;opacity: 0.4;";
  2247. valArray.heroStyleIMG = "filter: url(#GrayScale); -webkit-filter:grayscale(100%); ";
  2248. }
  2249.  
  2250. strArray[0] += '<td class="un'+ (t) +'"><div class="unit index_unit unit_icon40x40 ' + e + '" style="'+ valArray.heroStyle + valArray.heroStyleIMG +'"></div></td>';
  2251. strArray[1] += '<td class="bold" style="color:'+ ((valArray.att>19)?'green;':((valArray.att<10 && valArray.att!=0 )?'red;':'black;')) + valArray.heroStyle +';">'+ valArray.att +'</td>';
  2252. strArray[2] += '<td class="bold" style="color:'+ ((valArray.def>19)?'green;':((valArray.def<10 && valArray.def!=0 )?'red;':'black;')) + valArray.heroStyle +';">'+ valArray.def +'</td>';
  2253. strArray[3] += '<td class="bold" style="'+ valArray.heroStyle +'">'+ valArray.speed +'</td>';
  2254. strArray[4] += '<td class="bold" style="'+ valArray.heroStyle +'">'+ valArray.booty +'</td>';
  2255. strArray[5] += '<td class="bold" style="'+ valArray.heroStyle +'">'+ valArray.res +'</td>';
  2256. strArray[6] += '<td class="bold" style="color:'+ ((valArray.favor>0)?'rgb(0, 0, 214);':'black;') + valArray.heroStyle +';">'+ valArray.favor +'</td>';
  2257. strArray[7] += '<td class="bold" style="'+ valArray.heroStyle +'">'+ valArray.time +'</td>';
  2258.  
  2259. ttpArray[t] = uw.GameData.units[e].name; t++;
  2260. }
  2261. }
  2262. }
  2263.  
  2264. $('<table class="t_'+ type +'" cellpadding="1px" style="display:none">'+
  2265. '<tr>'+ strArray[0] +'</tr>'+
  2266. '<tr class="tr_att">'+ strArray[1] +'</tr><tr class="tr_def'+ (type == "ship" ? "_ship" : "") +'">'+ strArray[2] +'</tr>'+
  2267. '<tr class="tr_spd">'+ strArray[3] +'</tr><tr class="tr_bty'+ (type == "ship" ? "_ship" : "") +'">'+ strArray[4] +'</tr>'+
  2268. '<tr class="tr_res">'+ strArray[5] +'</tr><tr class="tr_fav">'+ strArray[6] +'</tr><tr class="tr_tim'+ (type == "ship" ? "_ship" : "") +'">'+ strArray[7] +'</tr>'+
  2269. '</table>').appendTo('#unit_box .box_content');
  2270.  
  2271. for(var i = 0; i <= t; i++){
  2272. $('.un'+i).tooltip(ttpArray[i]);
  2273. }
  2274.  
  2275.  
  2276. //$('#unit_box .box_content').css({ position: 'relative' });
  2277. $('#unit_box .bla').css({
  2278. height: '25px',
  2279. width: '25px',
  2280. backgroundSize: '100%',
  2281. float: 'left'
  2282. });
  2283. $('#unit_box .booty').css({
  2284. width: '26px',
  2285. height: '25px',
  2286. background: 'url(http://s14.directupload.net/images/140404/ki4gwd7x.png)',
  2287. backgroundSize: '95%'
  2288. });
  2289. }
  2290.  
  2291. /*******************************************************************************************************************************
  2292. * Reports and Messages
  2293. * ----------------------------------------------------------------------------------------------------------------------------
  2294. * | ● Storage of the selected filter (only in German Grepolis yet)
  2295. * ----------------------------------------------------------------------------------------------------------------------------
  2296. *******************************************************************************************************************************/
  2297.  
  2298. var filter = "all";
  2299. function saveFilter(){
  2300. $('#dd_filter_type_list .item-list div').each(function(){
  2301. $(this).click(function(){
  2302. filter = $(this).attr("name");
  2303. });
  2304. });
  2305. /*
  2306. var i = 0;
  2307. $("#report_list a").each(function () {
  2308. //console.log((i++) +" = " + $(this).attr('data-reportid'));
  2309. });
  2310. */
  2311. }
  2312.  
  2313. function loadFilter(){
  2314. if(!($('#dd_filter_type_list .selected').attr("name") === filter)){
  2315. $('#dd_filter_type .caption').click();
  2316. $('#dd_filter_type_list .item-list div[name='+ filter +']').click();
  2317. }
  2318. }
  2319.  
  2320. function removeReports(){
  2321. $("#report_list li:contains('spioniert')").each(function () {
  2322. //$(this).remove();
  2323. });
  2324. }
  2325.  
  2326. var zut = 0;
  2327. var messageArray = {};
  2328. function filterPlayer(){
  2329. if(!$('#message_filter_list').get(0)) {
  2330. $('<div id="message_filter_list" style="height:300px;overflow-y:scroll; width: 790px;"></div>').appendTo('#folder_container');
  2331. $("#message_list").get(0).style.display = "none";
  2332. }
  2333. if(zut < parseInt($('.es_last_page').get(0).value, 10)-1){
  2334. $('.es_page_input').get(0).value = zut++;
  2335. $('.jump_button').click();
  2336. $("#message_list li:contains('')").each(function () {
  2337. $(this).appendTo('#message_filter_list');
  2338. });
  2339. } else {
  2340. zut = 1;
  2341. }
  2342. }
  2343.  
  2344.  
  2345. /*******************************************************************************************************************************
  2346. * World Wonder Ranking - Change
  2347. *******************************************************************************************************************************/
  2348.  
  2349. function getWorldWonderTypes(){
  2350. $.ajax({
  2351. type: "GET",
  2352. url:
  2353. "/game/alliance?town_id="+ uw.Game.town_id + "&action=world_wonders&h="+ uw.Game.csrfToken + "&json=%7B%22town_id%22%3A"+ uw.Game.town_id +"%2C%22nlreq_id%22%3A"+ uw.Game.notification_last_requested_id +
  2354. "%7D&_="+ uw.Game.server_time,
  2355. success: function(text) {
  2356. try {
  2357. //console.log(JSON.parse(text));
  2358. temp = JSON.parse(text).json.data.world_wonders;
  2359. for(var t in temp){
  2360. if(temp.hasOwnProperty(t)){
  2361. wonderTypes[temp[t].wonder_type] = temp[t].full_name;
  2362. }
  2363. }
  2364. temp = JSON.parse(text).json.data.buildable_wonders;
  2365. for(var x in temp){
  2366. if(temp.hasOwnProperty(x)){
  2367. wonderTypes[x] = temp[x].name;
  2368. }
  2369. }
  2370. saveValue(MID + "_wonderTypes", JSON.stringify(wonderTypes));
  2371. } catch(error){
  2372. errorHandling(error, "getWorldWonderTypes");
  2373. }
  2374. }
  2375. });
  2376. }
  2377.  
  2378. function getWorldWonders(){
  2379. $.ajax({
  2380. type: "GET",
  2381. url: "/game/ranking?town_id="+ uw.Game.town_id +"&action=wonder_alliance&h="+ uw.Game.csrfToken + "&json=%7B%22type%22%3A%22all%22%2C%22town_id%22%3A"+ uw.Game.town_id +"%2C%22nlreq_id%22%3A3"+ uw.Game.notification_last_requested_id +
  2382. "%7D&_="+ uw.Game.server_time
  2383. });
  2384. }
  2385.  
  2386.  
  2387. function changeWWRanking(html){
  2388. if($('#ranking_inner tr', html)[0].children.length !== 1){ // world wonders existing?
  2389. try {
  2390. var ranking = {}, temp_ally, temp_ally_id, temp_ally_link;
  2391.  
  2392. // Save world wonder ranking into array
  2393. $('#ranking_inner tr', html).each(function(){
  2394. try {
  2395. if(this.children[0].innerHTML){
  2396. temp_ally = this.children[1].children[0].innerHTML; // das hier
  2397.  
  2398. temp_ally_id = this.children[1].children[0].onclick.toString();
  2399. temp_ally_id = temp_ally_id.substring(temp_ally_id.indexOf(",") + 1);
  2400. temp_ally_id = temp_ally_id.substring(0, temp_ally_id.indexOf(")"));
  2401.  
  2402. temp_ally_link = this.children[1].innerHTML;
  2403.  
  2404. } else {
  2405. //World wonder name
  2406. var wonder_name = this.children[3].children[0].innerHTML;
  2407.  
  2408. for(var w in wonderTypes){
  2409. if(wonderTypes.hasOwnProperty(w)){
  2410. if(wonder_name == wonderTypes[w]){
  2411. var level = this.children[4].innerHTML, // world wonder level
  2412. ww_data = JSON.parse(atob(this.children[3].children[0].href.split("#")[1])), wonder_link;
  2413. //console.log(ww_data);
  2414.  
  2415. if(!ranking.hasOwnProperty(level)) {
  2416. // add wonder types
  2417. ranking[level] = {
  2418. colossus_of_rhodes : {},
  2419. great_pyramid_of_giza : {},
  2420. hanging_gardens_of_babylon : {},
  2421. lighthouse_of_alexandria : {},
  2422. mausoleum_of_halicarnassus : {},
  2423. statue_of_zeus_at_olympia : {},
  2424. temple_of_artemis_at_ephesus : {}
  2425. };
  2426. }
  2427.  
  2428. if(!ranking[level][w].hasOwnProperty(temp_ally_id)) {
  2429. ranking[level][w][temp_ally_id] = {}; // add alliance array
  2430. }
  2431. // island coordinates of the world wonder:
  2432. ranking[level][w][temp_ally_id].ix = ww_data.ix;
  2433. ranking[level][w][temp_ally_id].iy = ww_data.iy;
  2434. ranking[level][w][temp_ally_id].sea = this.children[5].innerHTML; // world wonder sea
  2435.  
  2436. wonder_link = this.children[3].innerHTML;
  2437. if(temp_ally.length > 15){
  2438. temp_ally = temp_ally.substring(0,15) + '.';
  2439. }
  2440. wonder_link = wonder_link.substr(0, wonder_link.indexOf(">")+1) + temp_ally +'</a>';
  2441.  
  2442. ranking[level][w][temp_ally_id].ww_link = wonder_link;
  2443.  
  2444. // other data of the world wonder
  2445. ranking[level][w][temp_ally_id].ally_link = temp_ally_link;
  2446. ranking[level][w][temp_ally_id].ally_name = temp_ally; // alliance name
  2447. ranking[level][w][temp_ally_id].name = wonder_name; // world wonder name
  2448.  
  2449. // Save wonder coordinates for wonder icons on map
  2450. if(!wonder.map[w]){
  2451. wonder.map[w] = {};
  2452. }
  2453. wonder.map[w][ww_data.ix + "_" + ww_data.iy] = level;
  2454. saveValue(WID + "_wonder", JSON.stringify(wonder));
  2455.  
  2456. }
  2457. }
  2458. }
  2459. }
  2460. } catch(error){
  2461. errorHandling(error, "changeWWRankingEachFunction");
  2462. }
  2463. });
  2464. //console.log(wonder.map);
  2465. //console.log(ranking);
  2466. if($('#ranking_table_wrapper').get(0)){
  2467. $('#ranking_fixed_table_header').get(0).innerHTML = '<tr>'+
  2468. '<td style="width:10px">#</td>'+
  2469. '<td>Colossus</td>'+
  2470. '<td>Pyramid</td>'+
  2471. '<td>Garden</td>'+
  2472. '<td>Lighthouse</td>'+
  2473. '<td>Mausoleum</td>'+
  2474. '<td>Statue</td>'+
  2475. '<td>Temple</td>'+
  2476. '</tr>';
  2477.  
  2478. $('#ranking_fixed_table_header').css({
  2479. tableLayout: 'fixed',
  2480. width: '100%',
  2481. //paddingLeft: '0px',
  2482. paddingRight: '15px'
  2483. });
  2484.  
  2485. var ranking_substr = '', z = 0;
  2486. for(var level = 10; level >= 1; level--){
  2487. if(ranking.hasOwnProperty(level)){
  2488. var complete = "";
  2489. if(level == 10) { complete = "background: rgba(255, 236, 108, 0.36);"; }
  2490.  
  2491. // Alternate table background color
  2492. if(z == 0){
  2493. ranking_substr += '<tr class="game_table_odd" style="'+ complete +'"><td style="border-right: 1px solid #d0be97;">'+ level +'</td>'; z = 1;
  2494. } else {
  2495. ranking_substr += '<tr class="game_table_even" style="'+ complete +'"><td style="border-right: 1px solid #d0be97;">'+ level +'</td>'; z = 0;
  2496. }
  2497. for(var w in ranking[level]){
  2498. if(ranking[level].hasOwnProperty(w)){
  2499. ranking_substr += '<td>';
  2500.  
  2501. for(var a in ranking[level][w]){
  2502. if(ranking[level][w].hasOwnProperty(a)){
  2503. ranking_substr += '<nobr>' + ranking[level][w][a].ww_link + '</nobr><br />'; // ww link
  2504. }
  2505. }
  2506. ranking_substr += '</td>';
  2507. }
  2508. }
  2509. ranking_substr += '</tr>';
  2510. }
  2511. }
  2512.  
  2513. var ranking_str = '<table id="ranking_endless_scroll" class="game_table" cellspacing="0"><tr>'+
  2514. '<td style="width:10px;border-right: 1px solid #d0be97;"></td>'+
  2515. '<td><div class="dio_wonder" style="background:'+ worldWonderIcon.colossus_of_rhodes +';margin-left:26px"></div></td>'+ // Colossus
  2516. '<td><div class="dio_wonder" style="background:'+ worldWonderIcon.great_pyramid_of_giza +';margin-left:19px"></div></td>'+ // Pyramid
  2517. '<td><div class="dio_wonder" style="background:'+ worldWonderIcon.hanging_gardens_of_babylon +';margin-left:19px"></div></td>'+ // Garden
  2518. '<td><div class="dio_wonder" style="background:'+ worldWonderIcon.lighthouse_of_alexandria +';margin-left:24px"></div></td>'+ // Lighthouse
  2519. '<td><div class="dio_wonder" style="background:'+ worldWonderIcon.mausoleum_of_halicarnassus +';margin-left:25px"></div></td>'+ // Mausoleum
  2520. '<td><div class="dio_wonder" style="background:'+ worldWonderIcon.statue_of_zeus_at_olympia +';margin-left:25px"></div></td>'+ // Statue
  2521. '<td><div class="dio_wonder" style="background:'+ worldWonderIcon.temple_of_artemis_at_ephesus +';margin-left:22px"></div></td>'+ // Temple
  2522. '</tr>'+ ranking_substr + '</table>';
  2523.  
  2524. $('#ranking_table_wrapper').get(0).innerHTML = ranking_str;
  2525.  
  2526. $('#ranking_endless_scroll .dio_wonder').css({
  2527. width: "65px", height: "60px",
  2528. backgroundSize: "auto 100%",
  2529. backgroundPosition: "64px 0px"
  2530. });
  2531.  
  2532. $('#ranking_endless_scroll').css({
  2533. tableLayout: 'fixed',
  2534. width: '100%',
  2535. overflowY: 'auto',
  2536. overflowX: 'hidden',
  2537. fontSize: '0.7em',
  2538. lineHeight: '2'
  2539. });
  2540. $('#ranking_endless_scroll tbody').css({
  2541. verticalAlign: 'text-top'
  2542. });
  2543.  
  2544. $('#ranking_table_wrapper img').css({
  2545. width: "60px"
  2546. });
  2547. $('#ranking_table_wrapper').css({
  2548. overflowY: 'scroll'
  2549. });
  2550. }
  2551. } catch(error){
  2552. errorHandling(error, "changeWWRanking");
  2553. }
  2554. }
  2555. if($('.wonder_ranking').get(0)) {
  2556. $('.wonder_ranking').get(0).style.display = "block";
  2557. }
  2558. }
  2559.  
  2560.  
  2561. /*******************************************************************************************************************************
  2562. * World Wonder
  2563. * ----------------------------------------------------------------------------------------------------------------------------
  2564. * | ● click adjustment
  2565. * | ● Share calculation (= ratio of player points to alliance points)
  2566. * | ● Resources calculation & counter (stores amount)
  2567. * | ● Adds missing previous & next buttons on finished world wonders (better browsing through world wonders)
  2568. * ----------------------------------------------------------------------------------------------------------------------------
  2569. *******************************************************************************************************************************/
  2570.  
  2571. // getPointRatio: Default
  2572. function getPointRatioFromAllianceProfile(){
  2573. if(AID){
  2574. $.ajax({
  2575. type: "GET",
  2576. url: '/game/alliance?town_id='+ uw.Game.townId + '&action=profile&h='+ uw.Game.csrfToken + '&json=%7B%22alliance_id%22%3A'+ AID + '%2C%22town_id%22%3A'+ uw.Game.townId +
  2577. '%2C%22nlreq_id%22%3A'+ uw.Game.notification_last_requested_id + '%7D&_='+ uw.Game.server_time,
  2578. success: function(text) {
  2579. try {
  2580. text = text.substr(text.indexOf("/li")+14).substr(0, text.indexOf("\ "));
  2581. var AP = parseInt(text, 10);
  2582. wonder.ratio[AID] = 100 / AP * uw.Game.player_points;
  2583. saveValue(WID + "_wonder", JSON.stringify(wonder));
  2584. } catch(error){
  2585. errorHandling(error, "getPointRatioFromAllianceProfile");
  2586. }
  2587. }
  2588. });
  2589. } else {
  2590. wonder.ratio[AID] = -1;
  2591. saveValue(WID + "_wonder", JSON.stringify(wonder));
  2592. }
  2593. }
  2594.  
  2595. function getPointRatioFromAllianceRanking(){
  2596. try {
  2597. if(AID && $('.current_player .r_points').get(0)){
  2598. wonder.ratio[AID] = 100 / parseInt($('.current_player .r_points').get(0).innerHTML, 10) * uw.Game.player_points;
  2599. saveValue(WID + "_wonder", JSON.stringify(wonder));
  2600. }
  2601. } catch(error){
  2602. errorHandling(error, "getPointRatioFromAllianceRaking");
  2603. }
  2604. }
  2605.  
  2606. function getPointRatioFromAllianceMembers(){
  2607. try {
  2608. var ally_points = 0;
  2609. $('#ally_members_body tr').each(function(){
  2610. ally_points += parseInt($(this).children().eq(2).text(), 10) || 0;
  2611. });
  2612. wonder.ratio[AID] = 100 / ally_points * uw.Game.player_points;
  2613. saveValue(WID + "_wonder", JSON.stringify(wonder));
  2614. } catch(error){
  2615. errorHandling(error, "getPointRatioFromAllianceMembers");
  2616. }
  2617. }
  2618.  
  2619. // TODO: Split function...
  2620. function getResWW(){
  2621. try {
  2622. var wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_WONDERS);
  2623.  
  2624. for(var e in wndArray){
  2625. if(wndArray.hasOwnProperty(e)){
  2626. var wndID = "#gpwnd_" + wndArray[e].getID() + " ";
  2627.  
  2628. if($(wndID + '.wonder_progress').get(0)){
  2629. var res = 0,
  2630. ww_share = {total: {share:0, sum:0}, stage: {share:0, sum:0}},
  2631. ww_type = $(wndID + '.finished_image_small').attr('src').split("/")[6].split("_")[0], // Which world wonder?
  2632. res_stages = [ 2, 4, 6, 10, 16, 28, 48, 82, 140, 238], // Rohstoffmenge pro Rohstofftyp in 100.000 Einheiten
  2633. stage = parseInt($(wndID + '.wonder_expansion_stage span').get(0).innerHTML.split("/")[0], 10) + 1, // Derzeitige Füllstufe
  2634. speed = uw.Game.game_speed;
  2635.  
  2636. wonder.storage[AID] = wonder.storage[AID] || {};
  2637.  
  2638. wonder.storage[AID][ww_type] = wonder.storage[AID][ww_type] || {};
  2639.  
  2640. wonder.storage[AID][ww_type][stage] = wonder.storage[AID][ww_type][stage] || 0;
  2641.  
  2642. if(!$(wndID + '.ww_ratio').get(0)) {
  2643. $('<fieldset class="ww_ratio"></fieldset>').appendTo(wndID + '.wonder_res_container .trade');
  2644. $(wndID + '.wonder_header').prependTo(wndID + '.wonder_progress');
  2645. $(wndID + '.wonder_res_container .send_res').insertBefore(wndID + '.wonder_res_container .next_level_res');
  2646. }
  2647.  
  2648. $(wndID + '.wonder_progress').css({
  2649. margin: '0 auto 5px'
  2650. });
  2651. $(wndID + '.wonder_header').css({
  2652. textAlign: 'left',
  2653. margin: '10px -8px 12px 3px'
  2654. });
  2655. $(wndID + '.build_wonder_icon').css({
  2656. top: '25px',
  2657. });
  2658. $(wndID + '.wonder_progress_bar').css({
  2659. top: '54px',
  2660. });
  2661. $(wndID + '.wonder_controls').css({
  2662. height: '380px',
  2663. });
  2664.  
  2665. $(wndID + '.trade fieldset').css({
  2666. float: 'right',
  2667. });
  2668.  
  2669. $(wndID + '.wonder_res_container').css({
  2670. right: '29px'
  2671. });
  2672.  
  2673. $(wndID + '.ww_ratio').css({
  2674. position: 'relative',
  2675. height: 'auto'
  2676. });
  2677. $(wndID + 'fieldset').css({
  2678. height: 'auto'
  2679. });
  2680. $(wndID + '.town-capacity-indicator').css({
  2681. marginTop: '0px'
  2682. });
  2683.  
  2684. for(var d in res_stages){
  2685. if(res_stages.hasOwnProperty(d)){
  2686. ww_share.total.sum += res_stages[d];
  2687. }
  2688. }
  2689.  
  2690. ww_share.total.sum *= speed * 300000;
  2691.  
  2692. ww_share.total.share = parseInt(wonder.ratio[AID] * (ww_share.total.sum / 100), 10);
  2693.  
  2694. ww_share.stage.sum = speed * res_stages[stage-1] * 300000;
  2695.  
  2696. ww_share.stage.share = parseInt(wonder.ratio[AID] * (ww_share.stage.sum / 100), 10); // ( 3000 = 3 Rohstofftypen * 100000 Rohstoffe / 100 Prozent)
  2697. setResWW(stage, ww_type, ww_share, wndID);
  2698.  
  2699.  
  2700. $(wndID + '.wonder_res_container .send_resources_btn').click(function(e){
  2701. try {
  2702. wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_wood input:text').get(0).value, 10);
  2703. wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_stone input:text').get(0).value, 10);
  2704. wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_iron input:text').get(0).value, 10);
  2705.  
  2706. setResWW(stage, ww_type, ww_share, wndID);
  2707. saveValue(WID + "_wonder", JSON.stringify(wonder));
  2708. } catch(error){
  2709. errorHandling(error, "getResWW_Click");
  2710. }
  2711. });
  2712.  
  2713. } else {
  2714. $('<div class="prev_ww pos_Y"></div><div class="next_ww pos_Y"></div>').appendTo(wndID + '.wonder_controls');
  2715.  
  2716. $(wndID + '.wonder_finished').css({ width: '100%' });
  2717.  
  2718. $(wndID + '.pos_Y').css({
  2719. top: '-266px',
  2720. });
  2721.  
  2722. }
  2723. }
  2724. }
  2725. } catch(error){
  2726. errorHandling(error, "getResWW");
  2727. }
  2728. }
  2729.  
  2730. function setResWW(stage, ww_type, ww_share, wndID){
  2731. try {
  2732. var width_stage, width_total, res_total = 0, disp_stage = "none", disp_total = "none";
  2733.  
  2734. for(var z in wonder.storage[AID][ww_type]){
  2735. if(wonder.storage[AID][ww_type].hasOwnProperty(z)){
  2736. res_total += wonder.storage[AID][ww_type][z];
  2737. }
  2738. }
  2739.  
  2740. if(ww_share.stage.share > wonder.storage[AID][ww_type][stage]){
  2741. width_stage = (242 / ww_share.stage.share) * wonder.storage[AID][ww_type][stage];
  2742. } else {
  2743. width_stage = 0;
  2744. disp_stage = "block";
  2745. }
  2746. if(ww_share.total.share > res_total){
  2747. width_total = (242 / ww_share.total.share) * res_total;
  2748. } else {
  2749. width_total = 0;
  2750. disp_total = "block";
  2751. }
  2752.  
  2753. $(wndID + '.ww_ratio').get(0).innerHTML = "";
  2754. $(wndID + '.ww_ratio').append('<legend>'+ getText("labels", "leg") +' (<span style="color:#090">'+ (Math.round(wonder.ratio[AID] * 100) / 100) +'%</span>):</legend>'+
  2755. '<div class="town-capacity-indicator">'+
  2756. '<div class="icon all_res"></div>'+
  2757. '<div id="ww_town_capacity_stadium" class="tripple-progress-progressbar">'+
  2758. '<div class="border_l"></div><div class="border_r"></div><div class="body"></div>'+
  2759. '<div class="progress overloaded">'+
  2760. '<div class="indicator3" style="left: 0px; width:'+ width_stage +'px"></div>'+
  2761. '<span class="ww_perc">' + Math.round(wonder.storage[AID][ww_type][stage]/ww_share.stage.share*100) + '%</span>'+
  2762. '<div class="indicator4" style="left: 0px; display:'+ disp_stage +'"></div>'+
  2763. '</div>'+
  2764. '<div class="amounts">'+ getText("labels", "stg") +': <span class="curr">'+ pointNumber(wonder.storage[AID][ww_type][stage]) +'</span> / '+
  2765. '<span class="max">'+ pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) +'</span></div>'+
  2766. '</div></div>'+
  2767. '<div class="town-capacity-indicator">'+
  2768. '<div class="icon all_res"></div>'+
  2769. '<div id="ww_town_capacity_total" class="tripple-progress-progressbar">'+
  2770. '<div class="border_l"></div><div class="border_r"></div><div class="body"></div>'+
  2771. '<div class="progress overloaded">'+
  2772. '<div class="indicator3" style="left: 0px; width:'+ width_total +'px;"></div>'+
  2773. '<span class="ww_perc">'+ Math.round(res_total/ww_share.total.share*100) +'%</span>'+
  2774. '<div class="indicator4" style="left: 0px; display:'+ disp_total +'"></div>'+
  2775. '</div>'+
  2776. '<div class="amounts">'+ getText("labels", "tot") +': <span class="curr">'+ pointNumber(res_total) +'</span> / '+
  2777. '<span class="max">'+ pointNumber((Math.round(ww_share.total.share / 1000) * 1000)) +'</span></div>'+
  2778. '</div></div>');
  2779.  
  2780. $('.ww_ratio .progress').css({
  2781. lineHeight: '1',
  2782. color: 'white',
  2783. fontSize: '0.8em'
  2784. });
  2785.  
  2786. $(wndID + '.ww_perc').css({
  2787. position:'absolute',
  2788. width:'242px',
  2789. textAlign: 'center'
  2790. });
  2791.  
  2792. $(wndID + '.indicator4').css({
  2793. background: 'url(https://gpall.innogamescdn.com/images/game/layout/progressbars-sprite_2.70_compressed.png) no-repeat 0 0',
  2794. backgroundPosition: '0px -355px',
  2795. height: '10px',
  2796. zIndex: '13000',
  2797. width: '242px'
  2798. });
  2799. $(wndID + '.all_res').css({
  2800. background: 'url(https://gpall.innogamescdn.com/images/game/layout/resources.png) no-repeat 0 -90px',
  2801. width: '30px',
  2802. height: '30px',
  2803. margin: '0 auto',
  2804. marginLeft: '5px'
  2805. });
  2806. $(wndID + '.town-capacity-indicator').css({
  2807. marginTop: '0px'
  2808. });
  2809.  
  2810. $(wndID + '.ww_ratio').tooltip("<table style='border-spacing:0px; text-align:right' cellpadding='5px'><tr>"+
  2811. "<td align='right' style='border-right: 1px solid;border-bottom: 1px solid'></td>"+
  2812. "<td style='border-right: 1px solid; border-bottom: 1px solid'><span class='bbcodes_player bold'>("+ (Math.round((wonder.ratio[AID]) * 100) / 100) +"%)</span></td>"+
  2813. "<td style='border-bottom: 1px solid'><span class='bbcodes_ally bold'>(100%)</span></td></tr>"+
  2814. "<tr><td class='bold' style='border-right:1px solid;text-align:center'>"+ getText("labels", "stg") + "&nbsp;" + stage +"</td>"+
  2815. "<td style='border-right: 1px solid'>"+ pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) +"</td>"+
  2816. "<td>" + pointNumber(Math.round(ww_share.stage.sum / 1000) * 1000) + "</td></tr>"+
  2817. "<tr><td class='bold' style='border-right:1px solid;text-align:center'>"+ getText("labels", "tot") +"</td>"+
  2818. "<td style='border-right: 1px solid'>"+ pointNumber(Math.round(ww_share.total.share / 1000) * 1000) +"</td>"+
  2819. "<td>"+ pointNumber(Math.round(ww_share.total.sum / 1000) * 1000) +"</td>"+
  2820. "</tr></table>");
  2821. } catch(error){
  2822. errorHandling(error, "setResWW");
  2823. }
  2824. }
  2825.  
  2826. // Adds points to numbers
  2827. function pointNumber(number) {
  2828. var sep; if(LID === "de"){ sep = "."; } else { sep = ",";}
  2829.  
  2830. number = number.toString();
  2831. if (number.length > 3) {
  2832. var mod = number.length % 3;
  2833. var output = (mod > 0 ? (number.substring(0,mod)) : '');
  2834.  
  2835. for (var i=0 ; i < Math.floor(number.length / 3); i++) {
  2836. if ((mod == 0) && (i == 0)) {
  2837. output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
  2838. } else {
  2839. output+= sep + number.substring(mod + 3 * i, mod + 3 * i + 3);
  2840. }
  2841. }
  2842. number = output;
  2843. }
  2844. return number;
  2845. }
  2846.  
  2847. /*******************************************************************************************************************************
  2848. * Farming Village Overview
  2849. * ----------------------------------------------------------------------------------------------------------------------------
  2850. * | ● Color change on possibility of city festivals
  2851. * ----------------------------------------------------------------------------------------------------------------------------
  2852. * *****************************************************************************************************************************/
  2853.  
  2854. function changeResColor(){
  2855. var res, res_min, i = 0;
  2856. $('#fto_town_list .fto_resource_count :last-child').reverseList().each(function(){
  2857. if($(this).parent().hasClass("stone")){
  2858. res_min = 18000;
  2859. } else {
  2860. res_min = 15000;
  2861. }
  2862. res = parseInt($(this).get(0).innerHTML, 10);
  2863. if((res >= res_min) && !($(this).hasClass("town_storage_full"))){
  2864. $(this).get(0).style.color = '#0A0';
  2865. }
  2866. if(res < res_min){
  2867. $(this).get(0).style.color = '#000';
  2868. }
  2869. });
  2870. }
  2871.  
  2872. /********************************************************************************************************************************
  2873. * Conquest Info
  2874. * -----------------------------------------------------------------------------------------------------------------------------
  2875. * | ● Amount of supports und attacks in the conquest window
  2876. * | ● Layout adjustment (for reasons of clarity)
  2877. * | - TODO: conquest window of own cities
  2878. * -----------------------------------------------------------------------------------------------------------------------------
  2879. * ******************************************************************************************************************************/
  2880.  
  2881. function countMovements(){
  2882. var i = 0, a = 0;
  2883. $('#unit_movements .support').each(function(){
  2884. i++;
  2885. });
  2886. $('#unit_movements .attack_land, #unit_movements .attack_sea, #unit_movements .attack_takeover').each(function(){
  2887. a++;
  2888. });
  2889.  
  2890. var str = "<div style='position: absolute;width: 100px;margin-top: -16px;left: 40%;'><div style='float:left;margin-right:5px;'></div>"+
  2891. "<div class='troops' id='count_def'></div>"+
  2892. "<div class='troops' style='color:green;'> " + i + "</div>"+
  2893. "<div class='troops' id='count_off'> </div>"+
  2894. "<div style='color:red;'> " + a + "</div></div>"+
  2895. "<hr class='move_hr'>";
  2896.  
  2897. if($('.gpwindow_content .tab_content .bold').get(0)){
  2898. $('.gpwindow_content .tab_content .bold').append(str);
  2899. } else {
  2900. $('.gpwindow_content h4:eq(1)').append(str);
  2901.  
  2902. // TODO: set player link ?
  2903. /*
  2904. $('#unit_movements li div').each(function(){
  2905.  
  2906. //console.log($(this).get(0).innerHTML);
  2907. });
  2908. */
  2909. }
  2910. $('.move_hr').css({
  2911. margin: '7px 0px 0px 0px',
  2912. backgroundColor: '#5F5242',
  2913. height: '2px',
  2914. border: '0px solid'
  2915. });
  2916.  
  2917. // smaller movements
  2918. $('#unit_movements').css({
  2919. fontSize: '0.80em'
  2920. });
  2921. $('.incoming').css({
  2922. width: '150px',
  2923. height: '45px',
  2924. float: 'left'
  2925. });
  2926. $('#unit_movements div').each(function(){
  2927. if($(this).attr('class') === "unit_movements_arrow"){
  2928. // delete placeholder for arrow of outgoing movements (there are no outgoing movements)
  2929. if(!$(this).get(0).style.background) { $(this).get(0).remove(); }
  2930. } else {
  2931. // realign texts
  2932. $(this).css({
  2933. margin: '3px',
  2934. paddingLeft: '3px'
  2935. });
  2936. }
  2937. });
  2938.  
  2939. $('.troops').css({
  2940. float: 'left',
  2941. margin: '0px 5px 0px 0px',
  2942. height:'18px',
  2943. width:'18px',
  2944. position: 'relative'
  2945. });
  2946. $('#count_def').css({
  2947. background: 'url(https://gpall.innogamescdn.com/images/game/place/losts.png)',
  2948. backgroundPosition: '0 -36px'
  2949. });
  2950. $('#count_off').css({
  2951. background: 'url(https://gpall.innogamescdn.com/images/game/place/losts.png)',
  2952. backgroundPosition: '0 0px'
  2953. });
  2954. }
  2955.  
  2956. /*******************************************************************************************************************************
  2957. * Town window
  2958. * ----------------------------------------------------------------------------------------------------------------------------
  2959. * | ● TownTabHandler (trade, attack, support,...)
  2960. * | ● Sent units box
  2961. * | ● Short duration: Display of 30% troop speed improvement in attack/support tab
  2962. * | ● Trade options:
  2963. * | - Ressource marks on possibility of city festivals
  2964. * | - Percentual Trade: Trade button
  2965. * | - Recruiting Trade: Selection boxes (ressource ratio of unit type + share of the warehouse capacity of the target town)
  2966. * ----------------------------------------------------------------------------------------------------------------------------
  2967. *******************************************************************************************************************************/
  2968. var arrival_interval = {};
  2969. // TODO: Change both functions in MultipleWindowHandler()
  2970. function TownTabHandler(action){
  2971. var wndArray, wndID, wndA;
  2972. wndArray = Layout.wnd.getOpen(uw.Layout.wnd.TYPE_TOWN);
  2973. //console.log(wndArray);
  2974. for(var e in wndArray){
  2975. if(wndArray.hasOwnProperty(e)){
  2976. //console.log(wndArray[e].getHandler());
  2977. wndA = wndArray[e].getAction(); wndID = "#gpwnd_" + wndArray[e].getID() + " ";
  2978. if(!$(wndID).get(0)) {
  2979. wndID = "#gpwnd_" + (wndArray[e].getID() + 1) + " ";
  2980.  
  2981. }
  2982. //console.log(wndID);
  2983. if(wndA === action){
  2984. switch(action){
  2985. case "trading":
  2986. if($(wndID + '#trade_tab').get(0)){
  2987. if(!$(wndID + '.rec_trade').get(0)){
  2988. addRecTrade(wndID);
  2989. }
  2990. if(!($(wndID + '.btn_trade').get(0))){
  2991. addPercentTrade(wndID, false);
  2992. }
  2993. }
  2994. //addTradeMarks(wndID, 15, 18, 15, "red"); // town festival
  2995. break;
  2996. case "support": case "attack":
  2997. //if(!arrival_interval[wndID]){
  2998. if(DATA.options.way && !($('.js-casted-powers-viewport .unit_movement_boost').get(0) || $(wndID + '.short_duration').get(0))){
  2999. //if(arrival_interval[wndID]) console.log("add " + wndID);
  3000. addShortDuration(wndID);
  3001. }
  3002. if(DATA.options.sen){
  3003. addSentUnitsBox(wndID, action);
  3004. }
  3005. //}
  3006. break;
  3007. case "rec_mark":
  3008. //addTradeMarks(wndID, 15, 18, 15, "lime");
  3009. break;
  3010. }
  3011. }
  3012. }
  3013. }
  3014. }
  3015.  
  3016. function WWTradeHandler(){
  3017. var wndArray, wndID, wndA;
  3018. wndArray = uw.GPWindowMgr.getOpen(uw.GPWindowMgr.TYPE_WONDERS);
  3019. for(var e in wndArray){
  3020. if(wndArray.hasOwnProperty(e)){
  3021. wndID = "#gpwnd_" + wndArray[e].getID() + " ";
  3022. if(!($(wndID + '.btn_trade').get(0) || $(wndID +'.next_building_phase').get(0) || $(wndID +'#ww_time_progressbar').get(0))){
  3023. addPercentTrade(wndID, true);
  3024. }
  3025. }
  3026. }
  3027. }
  3028.  
  3029. /*******************************************************************************************************************************
  3030. * ● Sent units box
  3031. *******************************************************************************************************************************/
  3032. function addSentUnitsBox(wndID, action){
  3033. if(!$(wndID + '.sent_units_box').get(0)){
  3034. $('<div class="game_inner_box sent_units_box '+ action +'"><div class="game_border ">'+
  3035. '<div class="game_border_top"></div><div class="game_border_bottom"></div><div class="game_border_left"></div><div class="game_border_right"></div>'+
  3036. '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div><div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>'+
  3037. '<div class="game_header bold">'+
  3038. '<div class="icon_sent townicon_'+ (action == "attack" ? "lo" : "ld") +'"></div><span>'+ getText("labels", "lab") +' ('+ (action == "attack" ? "OFF" : "DEF") +')</span>'+
  3039. '</div>'+
  3040. '<div class="troops"><div class="units_list"></div><hr style="width: 172px;border: 1px solid rgb(185, 142, 93);margin: 3px 0px 2px -1px;">'+
  3041. '<div id="btn_sent_units_reset" class="button_new">'+
  3042. '<div class="left"></div>'+
  3043. '<div class="right"></div>'+
  3044. '<div class="caption js-caption">'+ getText("buttons", "res") +'<div class="effect js-effect"></div></div>'+
  3045. '</div>'+
  3046. '</div></div>').appendTo(wndID + '.attack_support_window');
  3047.  
  3048. updateSentUnitsBox(action);
  3049.  
  3050. $(wndID + '.icon_sent').css({
  3051. height: '20px',
  3052. marginTop: '-2px',
  3053. width: '20px',
  3054. backgroundPositionY: '-26px',
  3055. paddingLeft: '0px',
  3056. marginLeft: '0px'
  3057. });
  3058.  
  3059. $(wndID + '.sent_units_box').css({
  3060. position: 'absolute',
  3061. right: '0px',
  3062. bottom: '16px',
  3063. width: '192px',
  3064. //border: '2px solid green',
  3065. //borderRadius: '5px',
  3066. //padding: '5px'
  3067. });
  3068. $(wndID + '.troops').css({ padding: '6px 0px 6px 6px' });
  3069.  
  3070. $(wndID + '#btn_sent_units_reset').click(function(){
  3071. // Overwrite old array
  3072. sentUnitsArray[action] = {}; updateSentUnitsBox(action);
  3073. });
  3074. }
  3075. }
  3076.  
  3077. function getSentUnits(){
  3078. $.Observer(uw.GameEvents.command.send_unit).subscribe('DIO_SEND_UNITS', function(e,data){
  3079. try {
  3080. for(var z in data.params){
  3081. if(data.params.hasOwnProperty(z) && (data.sending_type !== "")){
  3082. if(uw.GameData.units[z]){
  3083. sentUnitsArray[data.sending_type][z] = (sentUnitsArray[data.sending_type][z] == undefined ? 0 : sentUnitsArray[data.sending_type][z]);
  3084. sentUnitsArray[data.sending_type][z] += data.params[z];
  3085. }
  3086. }
  3087. }
  3088. //updateSentUnitsBox(data.sending_type);
  3089. } catch(error){
  3090. errorHandling(error, "getSentUnits");
  3091. }
  3092. });
  3093. }
  3094.  
  3095. function updateSentUnitsBox(action){
  3096. try {
  3097. // Remove old unit list
  3098. $('.sent_units_box.'+ action +' .units_list').each(function(){
  3099. $(this).get(0).innerHTML = "";
  3100. });
  3101.  
  3102. // Add new unit list
  3103. for(var x in sentUnitsArray[action]){
  3104. if(sentUnitsArray[action].hasOwnProperty(x)){
  3105. if((sentUnitsArray[action][x] || 0) > 0){
  3106. $('.sent_units_box.'+ action +' .units_list').each(function(){
  3107. $(this).append('<div class="unit_icon25x25 '+ x +
  3108. (sentUnitsArray[action][x] >= 1000 ? (sentUnitsArray[action][x] >= 10000 ? " five_digit_number" : " four_digit_number") : "") +'">'+
  3109. '<span class="count text_shadow">'+ sentUnitsArray[action][x] +'</span>'+
  3110. '</div>');
  3111. });
  3112. }
  3113. }
  3114. }
  3115. saveValue(WID +"_sentUnits", JSON.stringify(sentUnitsArray));
  3116. } catch(error){
  3117. errorHandling(error, "updateSentUnitsBox");
  3118. }
  3119. }
  3120.  
  3121. /*******************************************************************************************************************************
  3122. * ● Short duration
  3123. *******************************************************************************************************************************/
  3124.  
  3125. function addShortDuration(wndID){
  3126. //console.log($(wndID + ".duration_container").get(0));
  3127. try {
  3128. //var tooltip = (LANG.hasOwnProperty(LID) ? getText("labels", "improved_movement") : "") + " (+30% "+ DM.getl10n("common", "barracks_and_docs").tooltips.speed.trim() + ")";
  3129. var tooltip = (LANG.hasOwnProperty(LID) ? getText("labels", "improved_movement") : "") + " (+30%)";
  3130.  
  3131. $('<table class="dio_duration">'+
  3132. '<tr><td class="way_icon"></td><td class="dio_way"></td><td class="arrival_icon"></td><td class="dio_arrival"></td><td colspan="2" class="dio_night"></td></tr>'+
  3133. '<tr class="short_duration_row" style="color:darkgreen">'+
  3134. '<td>&nbsp;╚&gt;&nbsp;</td><td><span class="short_duration">~0:00:00</span></td>'+
  3135. '<td>&nbsp;&nbsp;&nbsp;╚&gt;</td><td><span class="short_arrival">~00:00:00</span></td>'+
  3136. '<td class="short_icon"></td><td></td></tr>'+
  3137. '</table>').prependTo(wndID + ".duration_container");
  3138.  
  3139.  
  3140. $(wndID + ".nightbonus").appendTo(wndID + ".dio_night");
  3141. $(wndID + '.way_duration').appendTo(wndID + ".dio_way");
  3142. $(wndID + ".arrival_time").appendTo(wndID + ".dio_arrival");
  3143.  
  3144.  
  3145. // Style
  3146. $(wndID + '.duration_container').css({
  3147. width:'auto'
  3148. });
  3149. $(wndID + '.dio_duration').css({
  3150. borderSpacing: '0px',
  3151. marginBottom: '2px',
  3152. textAlign: 'right'
  3153. });
  3154. $(wndID + '.dio_way span,'+ wndID + '.dio_arrival span').css({
  3155. padding: '0px 0px 0px 0px',
  3156. background: 'none'
  3157. });
  3158. $(wndID + '.short_icon').css({
  3159. padding: '20px 0px 0px 30px',
  3160. background: 'url(http://666kb.com/i/ck2c7eohpyfa3yczt.png) 11px -1px / 21px no-repeat',
  3161. WebkitFilter: 'hue-rotate(50deg)'
  3162. });
  3163. $(wndID + '.way_icon').css({
  3164. padding: '30px 0px 0px 30px',
  3165. background: 'transparent url(https://gpall.innogamescdn.com/images/game/towninfo/traveltime.png) no-repeat 0 0'
  3166. });
  3167. $(wndID + '.arrival_icon').css({
  3168. padding: '30px 0px 0px 30px',
  3169. background: 'transparent url(https://gpall.innogamescdn.com/images/game/towninfo/arrival.png) no-repeat 0 0'
  3170. });
  3171. $(wndID + '.max_booty').css({
  3172. padding: '0px 0px 0px 30px',
  3173. margin: '3px 0 4px 4px',
  3174. width: 'auto'
  3175. });
  3176. $(wndID + '.fast_boats_needed').css({
  3177. background: 'transparent url(http://s7.directupload.net/images/140724/4pvfuch8.png) no-repeat 0 0',
  3178. padding: '2px 10px 7px 24px',
  3179. margin: '0px 0px 0px 6px'
  3180. });
  3181. $(wndID + '.slow_boats_needed').css({
  3182. background: 'transparent url(http://s1.directupload.net/images/140724/b5xl8nmj.png) no-repeat 0 0',
  3183. padding: '2px 10px 7px 24px',
  3184. margin: '0px 0px 0px 6px'
  3185. });
  3186.  
  3187. // Tooltip
  3188. $(wndID + '.short_duration_row').tooltip(tooltip);
  3189.  
  3190. // Detection of changes
  3191. changeShortDuration(wndID);
  3192. /*
  3193. $(wndID + '.way_duration').bind('DOMSubtreeModified', function(e) { console.log(e); }); // Alternative
  3194. */
  3195.  
  3196.  
  3197.  
  3198. } catch(error){
  3199. errorHandling(error, "addShortDuration");
  3200. }
  3201. }
  3202.  
  3203. function changeShortDuration(wndID){
  3204. var duration = new MutationObserver(function(mutations) {
  3205. mutations.forEach(function(mutation) {
  3206. if(mutation.addedNodes[0]){
  3207. //console.log(mutation);
  3208. calcShortDuration(wndID);
  3209. }
  3210. });
  3211. });
  3212. if($(wndID + '.way_duration').get(0)){
  3213. duration.observe($(wndID + '.way_duration').get(0), { attributes: false, childList: true, characterData: false});
  3214. }
  3215. }
  3216.  
  3217. //$('<style> .duration_container { display: block !important } </style>').appendTo("head");
  3218.  
  3219. function calcShortDuration(wndID){
  3220. //console.log(wndID);
  3221. //console.log($(wndID + '.duration_container .way_duration').get(0));
  3222. try {
  3223. var setup_time = 900/uw.Game.game_speed,
  3224. duration_time = $(wndID + '.duration_container .way_duration').get(0).innerHTML.replace("~","").split(":"),
  3225. // TODO: hier tritt manchmal Fehler auf TypeError: Cannot read property "innerHTML" of undefined at calcShortDuration (<anonymous>:3073:86)
  3226. arrival_time,
  3227. h,m,s,
  3228. atalanta_factor = 0;
  3229.  
  3230. // Atalanta aktiviert?
  3231. if($(wndID + '.unit_container.heroes_pickup .atalanta').get(0)){
  3232. if($(wndID + '.cbx_include_hero').hasClass("checked")) {
  3233. // Beschleunigung hängt vom Level ab, Level 1 = 11%, Level 20 = 30%
  3234. var atalanta_level = MM.getCollections().PlayerHero[0].models[1].attributes.level;
  3235.  
  3236. atalanta_factor = (atalanta_level + 10) / 100;
  3237. }
  3238. }
  3239.  
  3240. // Sekunden, Minuten und Stunden zusammenrechnen (-> in Sekunden)
  3241. duration_time = ((parseInt(duration_time[0], 10)*60 + parseInt(duration_time[1], 10))*60 + parseInt(duration_time[2], 10));
  3242.  
  3243. // Verkürzte Laufzeit berechnen
  3244. duration_time = ((duration_time - setup_time) * (1 + atalanta_factor)) / (1 + 0.3 + atalanta_factor) + setup_time;
  3245.  
  3246. h = Math.floor(duration_time/3600);
  3247. m = Math.floor((duration_time - h*3600)/60);
  3248. s = Math.floor(duration_time - h*3600 - m*60);
  3249.  
  3250. if(m < 10) { m = "0" + m; }
  3251. if(s < 10) { s = "0" + s; }
  3252.  
  3253. $(wndID + '.short_duration').get(0).innerHTML = "~"+ h +":" + m + ":" + s;
  3254.  
  3255. arrival_time = Math.round((Timestamp.server() + Game.server_gmt_offset)) + duration_time;
  3256.  
  3257. h = Math.floor(arrival_time/3600);
  3258. m = Math.floor((arrival_time - h*3600)/60);
  3259. s = Math.floor(arrival_time - h*3600 - m*60);
  3260.  
  3261. h %= 24;
  3262.  
  3263. if(m < 10) { m = "0" + m; }
  3264. if(s < 10) { s = "0" + s; }
  3265.  
  3266. $(wndID + '.short_arrival').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
  3267.  
  3268. clearInterval(arrival_interval[wndID]);
  3269. arrival_interval[wndID] = setInterval(function(){
  3270. arrival_time += 1;
  3271.  
  3272. h = Math.floor(arrival_time/3600);
  3273. m = Math.floor((arrival_time - h*3600)/60);
  3274. s = Math.floor(arrival_time - h*3600 - m*60);
  3275.  
  3276. h %= 24;
  3277.  
  3278. if(m < 10) { m = "0" + m; }
  3279. if(s < 10) { s = "0" + s; }
  3280.  
  3281. if($(wndID + '.short_arrival').get(0)){
  3282. $(wndID + '.short_arrival').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
  3283. } else {
  3284. clearInterval(arrival_interval[wndID]);
  3285. }
  3286. }, 1000);
  3287.  
  3288. } catch(error){
  3289. errorHandling(error, "calcShortDuration");
  3290. }
  3291. }
  3292.  
  3293. /*******************************************************************************************************************************
  3294. * ● Dropdown menu
  3295. *******************************************************************************************************************************/
  3296.  
  3297. // Preload images for drop down arrow buttons
  3298. var drop_over = new Image(); drop_over.src = "http://s7.directupload.net/images/140107/hna95u8a.png";
  3299. var drop_out = new Image(); drop_out.src = "http://s14.directupload.net/images/140107/ppsz5mxk.png";
  3300.  
  3301. function changeDropDownButton(){
  3302. /*
  3303. $('<style type="text/css">' +
  3304. '#dd_filter_type .arrow, .select_rec_unit .arrow {' +
  3305. 'width: 18px !important; height: 17px !important; background: url("http://s14.directupload.net/images/140107/ppsz5mxk.png") no-repeat 0px -1px !important;' +
  3306. 'position: absolute; top: 2px !important; right: 3px;' +
  3307. '</style>').appendTo('head');
  3308. */
  3309.  
  3310.  
  3311. $('.arrow').css({
  3312. width: '18px',
  3313. height: '17px',
  3314. background: 'url('+ drop_out.src +') no-repeat -1px -1px',
  3315. position: 'absolute',
  3316. top: '2px',
  3317. right: '3px'
  3318. });
  3319. }
  3320.  
  3321. var o = 1; // ????????????????????????????
  3322.  
  3323. /*******************************************************************************************************************************
  3324. * ● Recruiting Trade
  3325. * *****************************************************************************************************************************/
  3326. var trade_count = 0, unit = "FS", percent = "0.0"; // Recruiting Trade
  3327.  
  3328. function addRecTrade(wndID){
  3329. var max_amount;
  3330.  
  3331. $('<div class="rec_trade">'+
  3332. // DropDown-Button for unit
  3333. '<div class="drop_rec_unit dropdown default">'+
  3334. '<div class="border-left"></div>'+
  3335. '<div class="border-right"></div>'+
  3336. '<div class="caption" name="'+ unit +'">'+ unit +'</div>'+
  3337. '<div class="arrow"></div>'+
  3338. '</div>'+
  3339. '<div class="drop_rec_perc dropdown default">'+
  3340. // DropDown-Button for ratio
  3341. '<div class="border-left"></div>'+
  3342. '<div class="border-right"></div>'+
  3343. '<div class="caption" name="'+ percent +'">'+ Math.round(percent * 100)+'%</div>'+
  3344. '<div class="arrow"></div>'+
  3345. '</div></div><span class="rec_count" style="top:30px">('+ trade_count +')</span>').appendTo(wndID + ".content");
  3346.  
  3347. // Select boxes for unit and ratio
  3348. $('<div class="select_rec_unit dropdown-list default active">'+
  3349. '<div class="item-list">'+
  3350. '<div class="option_s unit index_unit unit_icon40x40 attack_ship" name="FS"></div>'+
  3351. '<div class="option_s unit index_unit unit_icon40x40 bireme" name="BI"></div>'+
  3352. '<div class="option_s unit index_unit unit_icon40x40 sword" name="SK"></div>'+
  3353. '<div class="option_s unit index_unit unit_icon40x40 slinger" name="SL"></div>'+
  3354. '<div class="option_s unit index_unit unit_icon40x40 archer" name="BS"></div>'+
  3355. '<div class="option_s unit index_unit unit_icon40x40 hoplite" name="HO"></div>'+
  3356. '<div class="option_s unit index_unit unit_icon40x40 rider" name="RE"></div>'+
  3357. '<div class="option_s unit index_unit unit_icon40x40 chariot" name="SW"></div>'+
  3358. '</div></div>').appendTo(wndID + ".rec_trade");
  3359. $('<div class="select_rec_perc dropdown-list default inactive">'+
  3360. '<div class="item-list">'+
  3361. '<div class="option sel" name="0.0">&nbsp;&nbsp;0%</div>'+
  3362. '<div class="option" name="0.05">&nbsp;&nbsp;5%</div>'+
  3363. '<div class="option" name="0.1">10%</div>'+
  3364. '<div class="option" name="0.16666">17%</div>'+
  3365. '<div class="option" name="0.2">20%</div>'+
  3366. '<div class="option" name="0.25">25%</div>'+
  3367. '<div class="option" name="0.33">33%</div>'+
  3368. '<div class="option" name="0.5">50%</div>'+
  3369. '</div></div>').appendTo(wndID + ".rec_trade");
  3370.  
  3371. $(wndID + ".rec_trade [name='"+ unit +"']").toggleClass("sel");
  3372.  
  3373. // Styles
  3374. $(wndID + '.rec_trade').css({ position: 'absolute', left: '30px', top: '70px' });
  3375. $(wndID + '.select_rec_unit').css({
  3376. position: 'absolute',
  3377. top: '20px',
  3378. width: '84px',
  3379. display: "none"
  3380. });
  3381. $(wndID + '.select_rec_perc').css({
  3382. position: 'absolute',
  3383. left: '50px',
  3384. top: '20px',
  3385. width: '50px',
  3386. display: "none"
  3387. });
  3388. $(wndID + '.item-list').css({ maxHeight: '400px', maxWidth: '200px', align: "right" });
  3389.  
  3390. $(wndID + '.arrow').css({
  3391. width: '18px',
  3392. height: '18px',
  3393. background: 'url('+ drop_out.src +') no-repeat -1px -1px',
  3394. position: 'absolute',
  3395. });
  3396.  
  3397. $(wndID + '.option_s').css({
  3398. filter: "url(#GrayScale)",
  3399. WebkitFilter: "grayscale(100%)",
  3400. cursor: 'pointer',
  3401. color: 'black',
  3402. lineHeight: '14px',
  3403. float: 'left',
  3404.  
  3405. position: 'relative',
  3406. width: '40px',
  3407. margin: '0px',
  3408. padding: '0px'
  3409. });
  3410.  
  3411. $('.select_rec_unit .sel').css({"filter": "url(#Sepia)", "-webkit-filter" : "sepia(100%)"});
  3412.  
  3413. // hover effects of the elements in the drop menus
  3414. $(wndID + '.option_s').hover(
  3415. function(){
  3416. //console.log(this.className);
  3417. $(this).css({ "filter": "none", "-webkit-filter" : "grayscale(0%) sepia(0%)"});
  3418. if(!($(this).hasClass("sel"))){
  3419. $('.option_s .sel').css({"filter": "url(#Sepia)", "-webkit-filter" : "grayscale(0%) sepia(100%)" });
  3420. }
  3421. },
  3422. function(){
  3423. $('.select_rec_unit .option_s').css({ "filter": "url(#GrayScale)", "-webkit-filter" : "grayscale(100%) sepia(0%)" });
  3424. $('.select_rec_unit .sel').css({ "filter": "url(#Sepia)", "-webkit-filter" : "grayscale(0%) sepia(100%)" });
  3425. }
  3426. );
  3427. $(wndID + '.option').hover(
  3428. function(){ $(this).css({color: '#fff', background: "#328BF1"}); },
  3429. function(){ $(this).css({color: '#000', background: "#FFEEC7"}); }
  3430. );
  3431.  
  3432. // click events of the drop menu
  3433. $(wndID + ' .select_rec_unit .option_s').each(function(){
  3434. $(this).click(function(e){
  3435. $(".select_rec_unit .sel").toggleClass("sel");
  3436. $("." + this.className.split(" ")[4]).toggleClass("sel");
  3437.  
  3438. unit = $(this).attr("name");
  3439. $('.drop_rec_unit .caption').attr("name", unit);
  3440. $('.drop_rec_unit .caption').each(function(){
  3441. $(this).get(0).innerHTML = unit;
  3442. });
  3443. $(this).parent().parent().get(0).style.display = "none";
  3444. $('.drop_rec_unit .caption').change();
  3445. });
  3446. });
  3447. $(wndID + ' .select_rec_perc .option').each(function(){
  3448. $(this).click(function(e){
  3449. $(this).parent().find(".sel").toggleClass("sel");
  3450. $(this).toggleClass("sel");
  3451.  
  3452. percent = $(this).attr("name");
  3453. $('.drop_rec_perc .caption').attr("name", percent);
  3454. $('.drop_rec_perc .caption').each(function(){
  3455. $(this).get(0).innerHTML = Math.round(percent * 100)+"%";
  3456. });
  3457. $(this).parent().parent().get(0).style.display = "none";
  3458. $('.drop_rec_perc .caption').change();
  3459. });
  3460. });
  3461.  
  3462. // show & hide drop menus on click
  3463. $(wndID + '.drop_rec_perc').click(function(e){
  3464. if($(e.target)[0].parentNode.parentNode.childNodes[3].style.display === "none"){
  3465. $(e.target)[0].parentNode.parentNode.childNodes[3].style.display = "block";
  3466. $(e.target)[0].parentNode.parentNode.childNodes[2].style.display = "none";
  3467. } else {
  3468. $(e.target)[0].parentNode.parentNode.childNodes[3].style.display = "none";
  3469. }
  3470. });
  3471. $(wndID + '.drop_rec_unit').click(function(e){
  3472. if($(e.target)[0].parentNode.parentNode.childNodes[2].style.display === "none"){
  3473. $(e.target)[0].parentNode.parentNode.childNodes[2].style.display = "block";
  3474. $(e.target)[0].parentNode.parentNode.childNodes[3].style.display = "none";
  3475. } else {
  3476. $(e.target)[0].parentNode.parentNode.childNodes[2].style.display = "none";
  3477. }
  3478. });
  3479.  
  3480. $(wndID).click(function(e){
  3481. var clicked = $(e.target), element = $('#' + this.id + ' .select_rec_unit').get(0);
  3482. if(!(clicked[0].parentNode.className.split(" ")[1] === "dropdown") && element){
  3483. element.style.display = "none";
  3484. }
  3485. });
  3486.  
  3487. // hover arrow change
  3488. $(wndID + '.dropdown').hover(function(e){
  3489. $(e.target)[0].parentNode.childNodes[3].style.background = "url('"+ drop_over.src +"') no-repeat -1px -1px";
  3490. }, function(e){
  3491. $(e.target)[0].parentNode.childNodes[3].style.background = "url('"+ drop_out.src +"') no-repeat -1px -1px";
  3492. });
  3493.  
  3494. $(wndID + ".drop_rec_unit .caption").attr("name", unit);
  3495. $(wndID + ".drop_rec_perc .caption").attr("name",percent);
  3496.  
  3497. $(wndID + '.drop_rec_unit').tooltip(getText("labels", "rat"));
  3498. $(wndID + '.drop_rec_perc').tooltip(getText("labels", "shr"));
  3499.  
  3500. var ratio = {NO: {w:0, s: 0, i: 0 },
  3501. FS: {w:1, s: 0.2308, i: 0.6154 },
  3502. BI: {w:1, s: 0.8750, i: 0.2250 },
  3503. SL: {w:0.55, s: 1, i: 0.4 },
  3504. RE: {w:0.6666, s: 0.3333, i: 1 },
  3505. SK: {w:1, s: 0, i: 0.8947 },
  3506. HO: {w:0, s: 0.5, i: 1 },
  3507. BS: {w:1, s: 0, i: 0.6250 },
  3508. SW: {w:0.4545, s: 1, i: 0.7273 }
  3509. };
  3510.  
  3511.  
  3512. if($('#town_capacity_wood .max').get(0)){
  3513. max_amount = parseInt($('#town_capacity_wood .max').get(0).innerHTML, 10);
  3514. } else {
  3515. max_amount = 25500;
  3516. }
  3517.  
  3518. $(wndID + '.caption').change(function(e){
  3519. //console.log($(this).attr('name') + ", " + unit + "; " + percent);
  3520. if(!(($(this).attr('name') === unit) || ($(this).attr('name') === percent))){
  3521. //trade_count = 0;
  3522. $('.rec_count').get(0).innerHTML = "(" + trade_count + ")";
  3523. }
  3524.  
  3525. var tmp = $(this).attr('name');
  3526.  
  3527. if($(this).parent().attr('class').split(" ")[0] === "drop_rec_unit"){
  3528. unit = tmp;
  3529. } else {
  3530. percent = tmp;
  3531. }
  3532. var max = (max_amount - 100)/1000;
  3533. addTradeMarks(max * ratio[unit].w, max * ratio[unit].s, max * ratio[unit].i, "lime");
  3534.  
  3535. var part = (max_amount - 1000) * parseFloat(percent); // -1000 als Puffer (sonst Überlauf wegen Restressies, die nicht eingesetzt werden können, vorallem bei FS und Biremen)
  3536. var rArray = uw.ITowns.getTown(uw.Game.townId).getCurrentResources();
  3537. var tradeCapacity = uw.ITowns.getTown(uw.Game.townId).getAvailableTradeCapacity();
  3538.  
  3539. var wood = ratio[unit].w * part;
  3540. var stone= ratio[unit].s * part;
  3541. var iron = ratio[unit].i * part;
  3542.  
  3543. if((wood > rArray.wood) || (stone > rArray.stone) || (iron > rArray.iron) || ( (wood + stone + iron) > tradeCapacity)) {
  3544. wood = stone = iron = 0;
  3545. $('.drop_rec_perc .caption').css({color:'#f00'});
  3546. //$('.' + e.target.parentNode.parentNode.className + ' .select_rec_perc .sel').css({color:'#f00'});
  3547. //$('.select_rec_perc .sel').css({color:'#f00'});
  3548. } else {
  3549. $('.' + e.target.parentNode.parentNode.className + ' .drop_rec_perc .caption').css({color:'#000'});
  3550. }
  3551. $("#trade_type_wood [type='text']").select().val(wood).blur();
  3552. $("#trade_type_stone [type='text']").select().val(stone).blur();
  3553. $("#trade_type_iron [type='text']").select().val(iron).blur();
  3554. });
  3555.  
  3556. $('#trade_button').click(function(){
  3557. trade_count++;
  3558. $('.rec_count').get(0).innerHTML = "(" + trade_count + ")";
  3559.  
  3560. });
  3561.  
  3562. $(wndID + '.rec_count').css({
  3563. position: 'absolute',
  3564. display: 'block',
  3565. left: '33px',
  3566. top: '95px',
  3567. width: '20px'
  3568. });
  3569. $(wndID + '.drop_rec_unit').css({
  3570. position: 'absolute',
  3571. display: 'block',
  3572. width: '50px',
  3573. overflow: 'visible'
  3574. });
  3575. $(wndID + '.drop_rec_perc').css({
  3576. position: 'absolute',
  3577. display: 'block',
  3578. left: '49px',
  3579. width: '55px',
  3580. color:'#000'
  3581. });
  3582. $(wndID + '.drop_rec_perc .caption').change();
  3583. }
  3584. /*******************************************************************************************************************************
  3585. * ● Ressources marks
  3586. *******************************************************************************************************************************/
  3587. function addTradeMarks(woodmark, stonemark, ironmark, color){
  3588. var max_amount, limit, wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_TOWN), wndID;
  3589. for(var e in wndArray){
  3590. if(wndArray.hasOwnProperty(e)){
  3591. wndID = "#gpwnd_" + wndArray[e].getID() + " ";
  3592. if($(wndID + '.town-capacity-indicator').get(0)){
  3593.  
  3594. max_amount = $(wndID + '.amounts .max').get(0).innerHTML;
  3595.  
  3596. $('#trade_tab .c_'+ color).each(function(){
  3597. $(this).get(0).remove();
  3598. });
  3599. $('#trade_tab .progress').each(function(){
  3600. if($("p", this).length < 3) {
  3601. if($(this).parent().get(0).id != "big_progressbar"){
  3602. limit = 1000 * (242 / parseInt(max_amount, 10));
  3603.  
  3604. switch($(this).parent().get(0).id.split("_")[2]){
  3605. case "wood": limit = limit * woodmark; break;
  3606. case "stone": limit = limit * stonemark; break;
  3607. case "iron": limit = limit * ironmark; break;
  3608. }
  3609. $('<p class="c_'+ color +'"style="position:absolute;left: '+ limit +'px; background:'+ color +';width:2px;height:100%;margin:0px"></p>').appendTo(this);
  3610. }
  3611. }
  3612. });
  3613. }
  3614. }
  3615. }
  3616. }
  3617.  
  3618. /*******************************************************************************************************************************
  3619. * ● Percentual Trade
  3620. *******************************************************************************************************************************/
  3621. var rest_count = 0;
  3622.  
  3623. function addPercentTrade(wndID, ww){
  3624.  
  3625. var a = ""; var content = wndID + ".content";
  3626. if(ww) {
  3627. a = "ww_";
  3628. content = wndID + '.trade .send_res';
  3629. }
  3630. $('<div class="btn btn_trade"><a class="button" href="#">'+
  3631. '<span class="left"><span class="right">'+
  3632. '<span class="middle mid">'+
  3633. '<span class="img_trade"></span></span></span></span>'+
  3634. '<span style="clear:both;"></span>'+
  3635. '</a></div>').prependTo(content);
  3636.  
  3637. $(wndID + '.btn_trade').tooltip(getText("labels", "per"));
  3638.  
  3639. setPercentTrade(wndID, ww);
  3640.  
  3641. // Style
  3642. $(wndID + '.btn').css({ width: '20px', overflow: 'visible', position: 'absolute', display: 'block' });
  3643.  
  3644. if(!ww){ $(wndID + '.content').css({ height: '320px' }); }
  3645.  
  3646. if(ww){
  3647. $(wndID + '.btn_trade').css({ left: '678px', top: '154px' });
  3648. } else {
  3649. $(wndID + '.btn_trade').css({ left: '336px', top: '135px' });
  3650. }
  3651.  
  3652. $(wndID + '.mid').css({ minWidth: '26px' });
  3653.  
  3654. $(wndID + '.img_trade').css({
  3655. width: '27px',
  3656. height: '27px',
  3657. top: '-3px',
  3658. float: 'left',
  3659. position: 'relative',
  3660. background: 'url("http://666kb.com/i/cjq6d72qk521ig1zz.png") no-repeat'
  3661. });
  3662.  
  3663. }
  3664.  
  3665. var res = {};
  3666. function setPercentTrade(wndID, ww){
  3667. var a = ww ? "ww_" : "", own_town = $(wndID + '.town_info').get(0) ? true : false;
  3668.  
  3669. $(wndID + '.btn_trade').toggle(
  3670. function(){
  3671. res.wood = {}; res.stone = {}; res.iron = {}; res.sum = {};
  3672.  
  3673. res.sum.amount = 0;
  3674. // Set amount of resources to 0
  3675. setAmount(true, a, wndID);
  3676. // Total amount of resources // TODO: ITowns.getTown(Game.townId).getCurrentResources(); ?
  3677. for(var e in res){
  3678. if(res.hasOwnProperty(e) && e != "sum") {
  3679. res[e].rest = false;
  3680. res[e].amount = parseInt($('.ui_resources_bar .'+ e +' .amount').get(0).innerHTML, 10);
  3681. res.sum.amount += res[e].amount;
  3682. }
  3683. }
  3684. // Percentage of total resources
  3685. res.wood.percent = 100/res.sum.amount * res.wood.amount;
  3686. res.stone.percent = 100/res.sum.amount * res.stone.amount;
  3687. res.iron.percent = 100/res.sum.amount * res.iron.amount;
  3688.  
  3689. // Total trading capacity
  3690. res.sum.cur = parseInt($(wndID + '#' + a + 'big_progressbar .caption .curr').get(0).innerHTML, 10);
  3691. //res.sum.max = parseInt($(wndID + '#' + a + 'big_progressbar .caption .max').get(0).innerHTML, 10) - res.sum.cur;
  3692.  
  3693. // Amount of resources on the percentage of trading capacity (%)
  3694. res.wood.part = parseInt(res.sum.cur/100 * res.wood.percent, 10);
  3695. res.stone.part = parseInt(res.sum.cur/100 * res.stone.percent, 10);
  3696. res.iron.part = parseInt(res.sum.cur/100 * res.iron.percent, 10);
  3697.  
  3698. // Get rest warehouse capacity of each resource type
  3699. for(var f in res){
  3700. if(res.hasOwnProperty(f) && f != "sum") {
  3701. if(!ww && own_town){ // Own town
  3702. var curr = parseInt($(wndID + '#town_capacity_'+ f +' .amounts .curr').get(0).innerHTML.replace('+', '').trim(), 10) || 0,
  3703. curr2 = parseInt($(wndID + '#town_capacity_'+ f +' .amounts .curr2').get(0).innerHTML.replace('+', '').trim(), 10) || 0,
  3704. max = parseInt($(wndID + '#town_capacity_'+ f +' .amounts .max').get(0).innerHTML.replace('+', '').trim(), 10) || 0;
  3705.  
  3706. res[f].cur = curr + curr2;
  3707. res[f].max = max - res[f].cur;
  3708.  
  3709. if(res[f].max < 0) { res[f].max = 0; }
  3710.  
  3711. } else { // World wonder or foreign town
  3712. res[f].max = 30000;
  3713. }
  3714. }
  3715. }
  3716. // Rest of fraction (0-2 units) add to stone amount
  3717. res.stone.part += res.sum.cur - (res.wood.part + res.stone.part + res.iron.part);
  3718.  
  3719. res.sum.rest = 0;
  3720. rest_count = 0;
  3721. calcRestAmount();
  3722. setAmount(false, a, wndID);
  3723. },
  3724. function(){
  3725. setAmount(true, a, wndID);
  3726. }
  3727. );
  3728. }
  3729.  
  3730. function calcRestAmount(){
  3731. // Subdivide rest
  3732. if(res.sum.rest > 0){
  3733. for(var e in res){
  3734. if(res.hasOwnProperty(e) && e != "sum" && res[e].rest != true) {
  3735. res[e].part += res.sum.rest/(3 - rest_count);
  3736. }
  3737. }
  3738. res.sum.rest = 0;
  3739. }
  3740. // Calculate new rest
  3741. for(var f in res){
  3742. if(res.hasOwnProperty(f) && f != "sum" && res[f].rest != true) {
  3743. if(res[f].max <= res[f].part) {
  3744. res[f].rest = true;
  3745. res.sum.rest += res[f].part - res[f].max;
  3746. rest_count += 1;
  3747. res[f].part = res[f].max;
  3748. }
  3749. }
  3750. }
  3751. // Recursion
  3752. if(res.sum.rest > 0 && rest_count < 3){
  3753. calcRestAmount();
  3754. }
  3755. }
  3756.  
  3757. function setAmount(clear, a, wndID){
  3758. for(var e in res){
  3759. if(res.hasOwnProperty(e) && e !== "sum") {
  3760. if(clear == true) { res[e].part = 0; }
  3761. $(wndID + "#" + a + "trade_type_" + e + ' [type="text"]').select().val(res[e].part).blur();
  3762. }
  3763. }
  3764. }
  3765.  
  3766. /* ******************************************************************************************************************************
  3767. * Unit strength (blunt/sharp/distance) and Transport Capacity
  3768. * ----------------------------------------------------------------------------------------------------------------------------
  3769. * | ● Unit strength: Unit menu
  3770. * | - Switching of def/off display with buttons
  3771. * | - Possible Selection of certain unit types
  3772. * | ● Unit strength: Siege
  3773. * | ● Unit strength: Barracks
  3774. * | ● Transport capacity: Unit menu
  3775. * | - Switching of transporter speed (+/- big transporter)
  3776. * ----------------------------------------------------------------------------------------------------------------------------
  3777. * ******************************************************************************************************************************/
  3778.  
  3779. var def = true, blunt = 0, sharp = 0, dist = 0, shipsize = false;
  3780.  
  3781. function getSelectedUnitsMenu(){
  3782. var units = [];
  3783. if($(".units_land .units_wrapper .selected").length > 0){
  3784. $(".units_land .units_wrapper .selected").each(function(){
  3785. units[$(this).get(0).className.split(" ")[1]] = $(this).get(0).children[0].innerHTML;
  3786. });
  3787. } else {
  3788. $(".units_land .units_wrapper .unit").each(function(){
  3789. units[$(this).get(0).className.split(" ")[1]] = $(this).get(0).children[0].innerHTML;
  3790. });
  3791. }
  3792. return units;
  3793. }
  3794.  
  3795. // Calculate defensive strength
  3796. function calcDef(units){
  3797. var e; blunt = sharp = dist = 0;
  3798. for(e in units) {
  3799. if(units.hasOwnProperty(e)) {
  3800. blunt += units[e] * uw.GameData.units[e].def_hack;
  3801. sharp += units[e] * uw.GameData.units[e].def_pierce;
  3802. dist += units[e] * uw.GameData.units[e].def_distance;
  3803. }
  3804. }
  3805. }
  3806. // Calculate offensive strength
  3807. function calcOff(units, selectedUnits){
  3808. var e; blunt = sharp = dist = 0;
  3809. for(e in selectedUnits) {
  3810. if(selectedUnits.hasOwnProperty(e)) {
  3811. var attack = (units[e] || 0) * uw.GameData.units[e].attack;
  3812. switch(uw.GameData.units[e].attack_type){
  3813. case 'hack': blunt += attack; break;
  3814. case 'pierce': sharp += attack; break;
  3815. case 'distance':dist += attack; break;
  3816. }
  3817. }
  3818. }
  3819. }
  3820.  
  3821. /*******************************************************************************************************************************
  3822. * ● Unit strength: Unit menu
  3823. *******************************************************************************************************************************/
  3824. function setStrengthMenu() {
  3825. try{
  3826. var unitsIn = uw.ITowns.getTown(uw.Game.townId).units(),
  3827. e, units = getSelectedUnitsMenu();
  3828.  
  3829. // Calculation
  3830. if(def==true){
  3831. calcDef(units);
  3832. } else {
  3833. calcOff(unitsIn, units);
  3834. }
  3835. $('#blunt').get(0).innerHTML = blunt;
  3836. $('#sharp').get(0).innerHTML = sharp;
  3837. $('#dist').get(0).innerHTML = dist;
  3838.  
  3839. setTransportCapacity(units);
  3840. }catch(e){
  3841. handleError(e, "setStrengthMenu");
  3842. }
  3843. }
  3844.  
  3845.  
  3846. function addStrengthMenu(){
  3847. $('<hr><div id="strength" class="cont_left"><span id="str_font" class="bold text_shadow" style="color:#FFCC66;font-size: 0.8em;">'+
  3848. '<table style="margin:0px;">'+
  3849. '<tr><td><div class="ico units_info_sprite img_hack"></td><td id="blunt">0</td></tr>'+
  3850. '<tr><td><div class="ico units_info_sprite img_pierce"></td><td id="sharp">0</td></tr>'+
  3851. '<tr><td><div class="ico units_info_sprite img_dist"></td><td id="dist">0</td></tr>'+
  3852. '</table>'+
  3853. '</span></div>'+
  3854. '<div class="cont_right">'+
  3855. '<img id="def" class="img" src="https://gpall.innogamescdn.com/images/game/unit_overview/support.png">'+
  3856. '<img id="off" class="img" src="https://gpall.innogamescdn.com/images/game/unit_overview/attack.png">'+
  3857. '</div>').appendTo('.units_land .content');
  3858.  
  3859. // transporter display
  3860. $('<div id="transporter" class="cont" style="height:25px;">'+
  3861. '<table style=" margin:0px;"><tr align="center" >'+
  3862. '<td><img id="ship_img" class="ico" src="http://s7.directupload.net/images/140724/4pvfuch8.png"></td>'+
  3863. '<td><span id="ship" class="bold text_shadow" style="color:#FFCC66;font-size: 10px;"></span></td>'+
  3864. '</tr></table>'+
  3865. '</div>').appendTo('.units_naval .content');
  3866.  
  3867. // Styles
  3868. $('.ico').css({
  3869. height: '20px',
  3870. width: '20px'
  3871. });
  3872. $('.units_info_sprite').css({
  3873. background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
  3874. backgroundSize: '100%'
  3875. });
  3876. $('.img_pierce').css({ backgroundPosition: '0px -20px' });
  3877. $('.img_dist').css({ backgroundPosition: '0px -40px' });
  3878. $('hr').css({
  3879. margin: '0px',
  3880. backgroundColor: '#5F5242',
  3881. height: '2px',
  3882. border: '0px solid'
  3883. });
  3884. $('.cont_left').css({
  3885. background: 'url(https://gpall.innogamescdn.com/images/game/layout/layout_units_nav_bg.png)',
  3886. width:'65%',
  3887. display: 'table-cell'
  3888. });
  3889. $('.cont').css({
  3890. background: 'url(https://gpall.innogamescdn.com/images/game/layout/layout_units_nav_bg.png)'
  3891. });
  3892. $('.cont_right').css({
  3893. background:'url(https://gpall.innogamescdn.com/images/game/layout/layout_units_nav_bg.png)',
  3894. width:'30%',
  3895. display: 'table-cell',
  3896. verticalAlign:'middle'
  3897. });
  3898. $('.img').css({
  3899. float:'right',
  3900. background:'none',
  3901. margin:'2px 8px 2px 0px'
  3902. });
  3903.  
  3904. $('.units_land .units_wrapper, .btn_gods_spells .checked').click(function(){
  3905. setTimeout(function(){
  3906. setStrengthMenu();
  3907. }, 100);
  3908. });
  3909.  
  3910. $('#off').css({"filter": "url(#GrayScale)", "-webkit-filter" : "grayscale(80%)" });
  3911.  
  3912. // Buttons
  3913. $('#off').click(function(){
  3914. $('#strength .img_hack').get(0).style.backgroundPosition = '0% 36%';
  3915. $('#strength .img_pierce').get(0).style.backgroundPosition = '0% 27%';
  3916. $('#strength .img_dist').get(0).style.backgroundPosition = '0% 45%';
  3917.  
  3918. $('#str_font').get(0).style.color = "#edb";
  3919.  
  3920. // TODO: doesn't work in FF yet
  3921. $(this).css({ "filter": "none", "-webkit-filter" : "grayscale(0%)" });
  3922.  
  3923. $('#def').css({"filter": "url(#GrayScale)", "-webkit-filter" : "grayscale(80%)" });
  3924. def = false;
  3925. setStrengthMenu();
  3926. });
  3927. $('#def').click(function(){
  3928. $('#strength .img_hack').get(0).style.backgroundPosition = '0% 0%';
  3929. $('#strength .img_pierce').get(0).style.backgroundPosition = '0% 9%';
  3930. $('#strength .img_dist').get(0).style.backgroundPosition = '0% 18%';
  3931.  
  3932. $('#str_font').get(0).style.color = "#fc6";
  3933.  
  3934. $(this).css({"filter": "none", "-webkit-filter" : "grayscale(0%)" });
  3935. $('#off').css({"filter": "url(#GrayScale)", "-webkit-filter" : "grayscale(80%)" });
  3936. def = true;
  3937. setStrengthMenu();
  3938. });
  3939. $('#def,#off,#transporter').hover(function() {
  3940. $(this).css('cursor','pointer');
  3941. });
  3942. $('#transporter').toggle(
  3943. function(){
  3944. $('#ship_img').get(0).src = "http://s1.directupload.net/images/140724/b5xl8nmj.png";
  3945. shipsize = !shipsize;
  3946. setStrengthMenu();
  3947. },
  3948. function(){
  3949. $('#ship_img').get(0).src = "http://s7.directupload.net/images/140724/4pvfuch8.png";
  3950. shipsize = !shipsize;
  3951. setStrengthMenu();
  3952. }
  3953. );
  3954. }
  3955.  
  3956. /*******************************************************************************************************************************
  3957. * ● Unit strength: Siege
  3958. *******************************************************************************************************************************/
  3959. function addStrengthConquest(){
  3960. var units = [], str;
  3961.  
  3962. // units of the siege
  3963. $('#conqueror_units_in_town .unit').each(function(){
  3964. str = $(this).attr("class").split(" ")[4];
  3965. if(!uw.GameData.units[str].is_naval){
  3966. units[str] = parseInt($(this).get(0).children[0].innerHTML, 10);
  3967. //console.log($(this).attr("class").split(" ")[4]);
  3968. }
  3969. });
  3970. // calculation
  3971. calcDef(units);
  3972.  
  3973. $('<div id="strength_eo" class="game_border" style="width:90px; margin: 20px; align:center;">'+
  3974. '<div class="game_border_top"></div><div class="game_border_bottom"></div>'+
  3975. '<div class="game_border_left"></div><div class="game_border_right"></div>'+
  3976. '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>'+
  3977. '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>'+
  3978. '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">'+
  3979. '<tr><td width="1%"><div class="ico units_info_sprite img_hack"></div></td><td id="bl" align="center" width="100%">0</td></tr>'+
  3980. '<tr><td><div class="ico units_info_sprite img_pierce"></div></td><td id="sh" align="center">0</td></tr>'+
  3981. '<tr><td><div class="ico units_info_sprite img_dist"></div></td><td id="di" align="center">0</td></tr>'+
  3982. '</table></span>'+
  3983. '</div>').appendTo('#conqueror_units_in_town');
  3984.  
  3985. $('#strength_eo').tooltip('Gesamteinheitenstärke der Belagerungstruppen');
  3986.  
  3987. $('#strength_eo .ico').css({
  3988. height: '20px',
  3989. width: '20px'
  3990. });
  3991. $('#strength_eo .units_info_sprite').css({
  3992. background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
  3993. backgroundSize: '100%'
  3994. });
  3995. $('#strength_eo .img_pierce').css({ backgroundPosition: '0% 9%' });
  3996. $('#strength_eo .img_dist').css({ backgroundPosition: '0% 18%' });
  3997.  
  3998.  
  3999. $('#bl').get(0).innerHTML = blunt;
  4000. $('#sh').get(0).innerHTML = sharp;
  4001. $('#di').get(0).innerHTML = dist;
  4002. }
  4003.  
  4004. /*******************************************************************************************************************************
  4005. * ● Unit strength: Barracks
  4006. *******************************************************************************************************************************/
  4007. function setStrengthBarracks(){
  4008. if(!$('#strength_baracks').get(0)){
  4009. var units = [], pop = 0;
  4010.  
  4011. // whole units of the town
  4012. $('#units .unit_order_total').each(function(){
  4013. units[$(this).parent().parent().attr("id")] = $(this).get(0).innerHTML;
  4014. });
  4015. // calculation
  4016. calcDef(units);
  4017.  
  4018. // population space of the units
  4019. for(var e in units) {
  4020. if(units.hasOwnProperty(e)) {
  4021. pop += units[e] * uw.GameData.units[e].population;
  4022. }
  4023. }
  4024. $('<div id="strength_baracks" class="game_border" style="float:right; width:70px; align:center;">'+
  4025. '<div class="game_border_top"></div><div class="game_border_bottom"></div>'+
  4026. '<div class="game_border_left"></div><div class="game_border_right"></div>'+
  4027. '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>'+
  4028. '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>'+
  4029. '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">'+
  4030. '<tr><td width="1%"><div class="ico units_info_sprite img_hack"></div></td><td id="b" align="center" width="100%">0</td></tr>'+
  4031. '<tr><td><div class="ico units_info_sprite img_pierce"></div></td><td id="s" align="center">0</td></tr>'+
  4032. '<tr><td><div class="ico units_info_sprite img_dist"></div></td><td id="d" align="center">0</td></tr>'+
  4033. '</table></span>'+
  4034. '</div>').appendTo('.ui-dialog #units');
  4035.  
  4036. $('<div id="pop_baracks" class="game_border" style="float:right; width:60px; align:center;">'+
  4037. '<div class="game_border_top"></div><div class="game_border_bottom"></div>'+
  4038. '<div class="game_border_left"></div><div class="game_border_right"></div>'+
  4039. '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>'+
  4040. '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>'+
  4041. '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">'+
  4042. '<tr><td width="1%"><img class="ico" src="https://gpall.innogamescdn.com/images/game/res/pop.png"></td><td id="p" align="center" width="100%">0</td></tr>'+
  4043. '</table></span>'+
  4044. '</div>').appendTo('.ui-dialog #units');
  4045.  
  4046. $('.ui-dialog #units .ico').css({
  4047. height: '20px',
  4048. width: '20px'
  4049. });
  4050. $('.ui-dialog #units .units_info_sprite').css({
  4051. background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
  4052. backgroundSize: '100%'
  4053. });
  4054. $('.ui-dialog #units .img_pierce').css({ backgroundPosition: '0% 9%' });
  4055. $('.ui-dialog #units .img_dist').css({ backgroundPosition: '0% 18%' });
  4056.  
  4057. //$('#pop_baracks').tooltip('Bevölkerungszahl aller Landeinheiten der Stadt');
  4058. //$('#strength_baracks').tooltip('Gesamteinheitenstärke stadteigener Truppen');
  4059.  
  4060. $('#b').get(0).innerHTML = blunt;
  4061. $('#s').get(0).innerHTML = sharp;
  4062. $('#d').get(0).innerHTML = dist;
  4063. $('#p').get(0).innerHTML = pop;
  4064. }
  4065. }
  4066.  
  4067. /*******************************************************************************************************************************
  4068. * ● Transporter capacity
  4069. *******************************************************************************************************************************/
  4070. function setTransportCapacity(){
  4071. var bigTransp = 0, smallTransp = 0, pop = 0, ship = 0, unit, berth, units = [];
  4072. // Ship space (available)
  4073. smallTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().small_transporter, 10);
  4074. if(isNaN(smallTransp)) smallTransp = 0;
  4075. if(shipsize){
  4076. bigTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().big_transporter, 10);
  4077. if(isNaN(bigTransp)) bigTransp = 0;
  4078. }
  4079.  
  4080. // Checking: Research berth
  4081. berth = 0;
  4082. if(uw.ITowns.getTown(uw.Game.townId).researches().hasBerth()){
  4083. berth = 6;
  4084. }
  4085. ship = bigTransp*(20 + berth) + smallTransp*(10 + berth);
  4086.  
  4087. units = uw.ITowns.getTown(uw.Game.townId).units();
  4088.  
  4089. // Ship space (required)
  4090. for(var e in units) {
  4091. if(units.hasOwnProperty(e)) {
  4092. if(uw.GameData.units[e]){ // without Heroes
  4093. if(!(uw.GameData.units[e].is_naval || uw.GameData.units[e].flying)){
  4094. pop += units[e] * uw.GameData.units[e].population;
  4095. }
  4096. }
  4097. }
  4098. }
  4099. $('#ship').get(0).innerHTML = pop + "/" + ship;
  4100. }
  4101.  
  4102.  
  4103. /*******************************************************************************************************************************
  4104. * Simulator
  4105. * ----------------------------------------------------------------------------------------------------------------------------
  4106. * | ● Layout adjustment
  4107. * | ● Permanent display of the extended modifier box
  4108. * | ● Unit strength for entered units (without modificator influence yet)
  4109. * ----------------------------------------------------------------------------------------------------------------------------
  4110. *******************************************************************************************************************************/
  4111.  
  4112. function changeSimulatorLayoutNew(){
  4113. if(!$('#dio_simulator').get(0)){
  4114. $('<style id="dio_simulator" type="text/css">'+
  4115.  
  4116. '#place_simulator { overflow: hidden !important} '+
  4117. '#place_simulator .game_body { height: 457px !important} '+
  4118.  
  4119. // Bonus container
  4120. '.place_sim_wrap_mods {position: absolute !important; right: -17px !important} '+
  4121. '.place_sim_wrap_mods .place_simulator_table :eq(1) { width: 300px;} '+ ////////////// genauer!
  4122. '.place_sim_wrap_mods > .place_simulator_table { width: 272px;} '+ ////////////// genauer!
  4123.  
  4124.  
  4125.  
  4126. // Extended modifier box
  4127. '.place_sim_wrap_mods_extended { display: table !important; position: relative !important; width: 272px !important; padding-top: 3px !important; opacity: 1 !important; left: 0px; top: 0px} '+
  4128. '.place_sim_wrap_mods_extended table { table-layout: fixed !important; width: 100% !important} '+
  4129. '.place_sim_wrap_mods_extended table tr td:eq(0) { width: 18px !important } '+
  4130. '.place_image { width: 20px !important; height:20px !important; background-size: 100% !important; margin: auto !important} '+
  4131. '.place_cross { height: 19px !important}'+
  4132.  
  4133. '.top_border td { border-top: 2px solid #BFA978 !important; padding-top: 3px !important} '+
  4134.  
  4135. // Unit container
  4136. '#simulator_body .unit_container { height: 50px !important; width: 50px !important; margin: 0px 3px 0px 1px !important} '+
  4137. '.place_simulator_odd, .place_simulator_even { text-align: center !important} '+
  4138. '.place_insert_field { margin: 0px !important} '+
  4139.  
  4140. // Sea unit box
  4141. '.place_sim_sea_wrap h4 { float: left !important} '+
  4142. '.place_sim_select_strategies select { width: 95px !important} '+
  4143. '.place_sim_select_strategies { margin-left: 99px !important} '+
  4144.  
  4145. // Land unit box
  4146. '#place_sim_wrap_units { position: absolute !important; bottom: 35px !important} '+
  4147. '#place_sim_wrap_units h4 { float: left !important} '+
  4148.  
  4149. // Select boxes
  4150. '.place_sim_select_gods { width: 105px !important} '+
  4151. '.place_sim_select_gods select { width: 80px !important} '+
  4152. '.place_sim_select_gods_wrap { padding: 0px !important} '+
  4153. '#select_insert_units { width: 130px !important} '+
  4154.  
  4155. '.place_sim_select_gods_wrap .place_symbol, .place_sim_select_strategies .place_symbol { margin: 0px 2px 0px 5px !important} '+
  4156. '.place_sim_insert_units .place_symbol { background: url(https://gpall.innogamescdn.com/images/game/towninfo/traveltime.png) !important; background-size: 140% !important; background-position-y: -4px !important} '+
  4157. '.place_attack { float: left !important} '+
  4158. '#simulator_body .att { margin-left: 19px !important} '+
  4159.  
  4160. // Hero box
  4161. '.place_sim_heroes_container { position: absolute !important; right: 26px !important; padding-top: 3px !important; z-index: 1 !important} '+
  4162. '.place_sim_hero_container { width: 45px !important; height: 25px !important} '+
  4163. // - Hero container
  4164. '.place_sim_hero_choose, .place_sim_hero_unit_container { height: 26px !important; width: 30px !important} '+
  4165. '#hero_defense_icon, #hero_attack_icon { height: 25px !important; width: 25px !important; margin: 0px !important} '+
  4166. '#hero_defense_dd, #hero_attack_dd { height: 25px !important; width: 25px !important; margin: 1px !important} '+
  4167. '.place_sim_hero_attack, .place_sim_hero_defense { margin-left: 3px !important} '+
  4168. '#hero_attack_text, #hero_defense_text { font-size: 11px !important; bottom: 0px !important} '+
  4169. '.place_sim_heroes_container .plus { left: 2px; top: 2px !important} '+
  4170. // - Hero spinner
  4171. '.place_sim_hero_spinner { height: 25px !important; width: 40px !important } '+
  4172. '.place_sim_heroes_container td:eq(0) { height: 30px !important} '+
  4173. '.hero_spinner { height: 24px !important;position:absolute !important; width:12px !important; left:29px !important, background:url(https://gpall.innogamescdn.com/images/game/border/odd.png) repeat !important; border: 1px solid rgb(107, 107, 107) !important} '+
  4174. '.place_sim_hero_spinner .button_down, .place_sim_hero_spinner .button_up { bottom: 2px !important; cursor: pointer !important} '+
  4175.  
  4176. // Quack
  4177. '#q_place_sim_lost_res { display: none; } '+
  4178. '</style>').appendTo('head');
  4179. }
  4180.  
  4181. /////////////////////////////////////
  4182.  
  4183.  
  4184. $('.place_sim_bonuses_heroes h4').prependTo('.place_sim_wrap_mods');
  4185.  
  4186. $('.place_sim_bonuses_more_confirm').parent().get(0).style.display = "none";
  4187. $('.place_sim_showhide').remove();
  4188.  
  4189. // Wall loss
  4190. $('.place_sim_wrap_mods tr:eq(1) td:eq(5)').html('<span id="building_place_def_losses_wall_level" class="place_losses bold"></span');
  4191. $('.place_sim_wrap_mods tr:last-child').remove();
  4192. // AutoFillIn
  4193. $('.place_insert_field[name="sim[mods][att][luck]"]').get(0).value = 0;
  4194.  
  4195. // Extended modificator box
  4196. //$('.place_sim_wrap_mods_extended').removeClass().addClass("place_sim_wrap_mods_extend");
  4197. $('.place_sim_wrap_mods_extended').appendTo('.place_sim_wrap_mods');
  4198. $('.place_sim_wrap_mods_extended .place_simulator_table').appendTo('.place_sim_wrap_mods_extended');
  4199. if($('.place_sim_wrap_mods_extended .game_border').get(0)) { $('.place_sim_wrap_mods_extended .game_border').remove(); } // TODO: css!
  4200.  
  4201. $('.place_sim_wrap_mods_extended .place_image').each(function(){
  4202. var s = parseInt($(this).css('backgroundPosition').replace("px", "").split(" ")[1], 10)/2;
  4203. $(this).get(0).style.backgroundPosition = '0px '+s+'px';
  4204. });
  4205. $('.place_sim_wrap_mods_extended .power').each(function(){
  4206. $(this).removeClass("power_icon45x45").addClass("power_icon16x16");
  4207. });
  4208. $('.place_sim_wrap_mods_extended td:nth-child(even)').each(function(){
  4209. $(this).addClass("left_border place_simulator_odd");
  4210. });
  4211. $('.place_sim_wrap_mods_extended td:nth-child(odd)').each(function(){
  4212. $(this).addClass("left_border place_simulator_even");
  4213. });
  4214.  
  4215. // Beta only yet
  4216. //if($('.place_sim_wrap_mods_extend tr').length == 5){
  4217. $('.place_sim_wrap_mods_extended tr:eq(2)').each(function(){
  4218. $(this).addClass("top_border");
  4219. });
  4220. $('.place_sim_wrap_mods_extended tr:last-child').remove();
  4221. //}
  4222.  
  4223. $('.place_sim_wrap_mods_extend td:first-child').each(function(){
  4224. $(this).removeClass("left_border");
  4225. });
  4226. // -> update percentage each time
  4227. $('.place_checkbox_field').each(function(){
  4228. $(this).click(function(){
  4229. uw.FightSimulator.closeModsExtended();
  4230. //$('.place_sim_bonuses_more_confirm').get(0).click();
  4231. });
  4232. });
  4233.  
  4234.  
  4235. // Sea unit box
  4236.  
  4237. $('.place_sim_select_strategies').prependTo('.place_sim_sea_wrap');
  4238. $('.place_sim_sea_wrap h4').prependTo('.place_sim_sea_wrap');
  4239.  
  4240. // Land unit box
  4241. $('<div id="place_sim_wrap_units"></div>').appendTo('#simulator_body');
  4242.  
  4243. $('#place_simulator h4:last, .place_sim_select_gods_wrap').appendTo('#place_sim_wrap_units');
  4244. $('#place_sim_ground_units').appendTo('#place_sim_wrap_units');
  4245. $('#place_sim_wrap_units h4').prependTo('.place_sim_select_gods_wrap');
  4246.  
  4247.  
  4248. // Hero world ?
  4249. if(uw.Game.hasArtemis){
  4250. $('.place_sim_wrap_mods_extend tr').each(function(){
  4251. $(this).get(0).children[1].style.borderLeft = "none";
  4252. $(this).get(0).children[0].remove();
  4253. });
  4254. }
  4255.  
  4256. // Hero box ?
  4257. if($('.place_sim_heroes_container').get(0)){
  4258. $('.place_sim_heroes_container').appendTo(".place_sim_wrap_mods");
  4259.  
  4260. $('#place_simulator h4:eq(2)').remove(); // Delete heroes title
  4261.  
  4262. $('.hero_unit').each(function(){
  4263. $(this).removeClass('unit_icon40x40').addClass('unit_icon25x25');
  4264. });
  4265.  
  4266. // hero spinner
  4267. $('.place_sim_hero_spinner').each(function(){
  4268. $(this).removeClass('place_sim_hero_spinner').addClass('hero_spinner');
  4269. });
  4270. $('.hero_spinner .border_l').remove();
  4271. $('.hero_spinner .border_r').remove();
  4272. $('.hero_spinner .body').remove();
  4273. }
  4274.  
  4275. setStrengthSimulator();
  4276. }
  4277.  
  4278. function changeSimulatorLayout(){
  4279. $('#place_simulator').css({
  4280. overflow: 'hidden'
  4281. });
  4282. $('#place_simulator .game_body').css({
  4283. height: '457px'
  4284. });
  4285.  
  4286. // Bonus container
  4287. $('.place_sim_bonuses_heroes h4').prependTo('.place_sim_wrap_mods');
  4288. $('.place_sim_wrap_mods').css({
  4289. position: 'absolute',
  4290. right: '-17px'
  4291. });
  4292. $('.place_sim_wrap_mods .place_simulator_table .left_border').css({
  4293. width: '47px'
  4294. });
  4295. // Wall loss
  4296. $('.place_sim_wrap_mods tr:eq(1) td:eq(5)').html('<span id="building_place_def_losses_wall_level" class="place_losses bold"></span');
  4297. $('.place_sim_wrap_mods tr:last-child').remove();
  4298. // AutoFillIn
  4299. $('.place_insert_field[name="sim[mods][att][luck]"]').get(0).value = 0;
  4300. //$('.place_insert_field[name="sim[mods][att][morale]"]').get(0).value = 100;
  4301.  
  4302.  
  4303. // Extended modificator box
  4304. $('.place_sim_wrap_mods_extended').removeClass().addClass("place_sim_wrap_mods_extend");
  4305. $('.place_sim_wrap_mods_extend').appendTo('.place_sim_wrap_mods');
  4306. $('.place_sim_wrap_mods_extend .place_simulator_table').appendTo('.place_sim_wrap_mods_extend');
  4307. if($('.place_sim_wrap_mods_extend .game_border').get(0)) { $('.place_sim_wrap_mods_extend .game_border').remove(); }
  4308. $('.place_sim_wrap_mods_extend').css({
  4309. display: 'table',
  4310. position: 'relative',
  4311. width: '272px',
  4312. paddingTop: '3px'
  4313. });
  4314. $('.place_sim_wrap_mods_extend table').css({
  4315. tableLayout: 'fixed',
  4316. width: '100%'
  4317. });
  4318. $('.place_sim_wrap_mods_extend table tr td:eq(0)').css({
  4319. width: '18px'
  4320. });
  4321. $('.place_sim_bonuses_more_confirm').parent().get(0).style.display = "none";
  4322. $('.place_sim_showhide').remove();
  4323. $('.place_image').css({
  4324. width: '20px',
  4325. height:'20px',
  4326. backgroundSize: '100%',
  4327. margin: 'auto'
  4328. });
  4329. $('.place_cross').css({
  4330. height: '19px'
  4331. });
  4332. $('.place_sim_wrap_mods_extend .place_image').each(function(){
  4333. var s = parseInt($(this).css('backgroundPosition').replace("px", "").split(" ")[1], 10)/2;
  4334. $(this).get(0).style.backgroundPosition = '0px '+s+'px';
  4335. });
  4336. $('.place_sim_wrap_mods_extend .power').each(function(){
  4337. $(this).removeClass("power_icon45x45").addClass("power_icon16x16");
  4338. });
  4339. $('.place_sim_wrap_mods_extend td:nth-child(even)').each(function(){
  4340. $(this).addClass("left_border place_simulator_odd");
  4341. });
  4342. $('.place_sim_wrap_mods_extend td:nth-child(odd)').each(function(){
  4343. $(this).addClass("left_border place_simulator_even");
  4344. });
  4345.  
  4346. // Beta only yet
  4347. if($('.place_sim_wrap_mods_extend tr').length == 5){
  4348. $('.place_sim_wrap_mods_extend tr:eq(2)').each(function(){
  4349. $(this).addClass("top_border");
  4350. });
  4351. $('.place_sim_wrap_mods_extend tr:last-child').remove();
  4352. }
  4353. $('.top_border td').css({
  4354. borderTop: '2px solid #BFA978',
  4355. paddingTop: '3px'
  4356. });
  4357. $('.place_sim_wrap_mods_extend td:first-child').each(function(){
  4358. $(this).removeClass("left_border");
  4359. });
  4360. // -> update percentage each time
  4361. $('.place_checkbox_field').each(function(){
  4362. $(this).click(function(){
  4363. uw.FightSimulator.closeModsExtended();
  4364. //$('.place_sim_bonuses_more_confirm').get(0).click();
  4365. });
  4366. });
  4367.  
  4368.  
  4369. // unit container
  4370. $('#simulator_body .unit_container').css({
  4371. height: '50px',
  4372. width: '50px',
  4373. margin: '0px 3px 0px 1px'
  4374. });
  4375. $('.place_simulator_odd, .place_simulator_even').css({
  4376. textAlign: 'center'
  4377. });
  4378. $('.place_insert_field').css({
  4379. margin: '0px'
  4380. });
  4381.  
  4382. // Sea unit box
  4383. $('.place_sim_sea_wrap h4').css({
  4384. float: 'left'
  4385. });
  4386. $('.place_sim_select_strategies').prependTo('.place_sim_sea_wrap');
  4387. $('.place_sim_select_strategies select').css({
  4388. width: '95px'
  4389. });
  4390. $('.place_sim_sea_wrap h4').prependTo('.place_sim_sea_wrap');
  4391. $('.place_sim_select_strategies').css({
  4392. marginLeft: '99px'
  4393. });
  4394.  
  4395. // Land unit box
  4396. $('<div id="place_sim_wrap_units"></div>').appendTo('#simulator_body');
  4397. $('#place_sim_wrap_units').css({
  4398. position: 'absolute',
  4399. bottom: '35px'
  4400. });
  4401. $('#place_simulator h4:last, .place_sim_select_gods_wrap').appendTo('#place_sim_wrap_units');
  4402. $('#place_sim_ground_units').appendTo('#place_sim_wrap_units');
  4403. $('#place_sim_wrap_units h4').prependTo('.place_sim_select_gods_wrap');
  4404. $('#place_sim_wrap_units h4').css({
  4405. float: 'left'
  4406. });
  4407.  
  4408. // Select boxes
  4409. $('.place_sim_select_gods').css({
  4410. width: '105px'
  4411. });
  4412. $('.place_sim_select_gods select').css({
  4413. width: '80px'
  4414. });
  4415. $('.place_sim_select_gods_wrap').css({
  4416. padding: '0px'
  4417. });
  4418. $('#select_insert_units').css({
  4419. width: '130px'
  4420. });
  4421.  
  4422. $('.place_sim_select_gods_wrap .place_symbol, .place_sim_select_strategies .place_symbol').css({
  4423. margin: '0px 2px 0px 5px'
  4424. });
  4425. $('.place_sim_insert_units .place_symbol').css({
  4426. background: 'url(https://gpall.innogamescdn.com/images/game/towninfo/traveltime.png)',
  4427. backgroundSize: '140%',
  4428. backgroundPositionY: '-4px'
  4429. });
  4430. $('.place_attack').css({
  4431. float: 'left'
  4432. });
  4433. $('#simulator_body .att').css({
  4434. marginLeft: '19px'
  4435. });
  4436.  
  4437.  
  4438. // Hero world ?
  4439. if(uw.Game.hasArtemis){
  4440. $('.place_sim_wrap_mods_extend tr').each(function(){
  4441. $(this).get(0).children[1].style.borderLeft = "none";
  4442. $(this).get(0).children[0].remove();
  4443. });
  4444. }
  4445.  
  4446.  
  4447. // Hero box ?
  4448. if($('.place_sim_heroes_container').get(0)){
  4449. $('.place_sim_heroes_container').appendTo(".place_sim_wrap_mods");
  4450.  
  4451. $('#place_simulator h4:eq(2)').remove(); // Delete heroes title
  4452.  
  4453. $('.place_sim_heroes_container').css({
  4454. position: 'absolute',
  4455. right: '26px',
  4456. paddingTop: '3px',
  4457. zIndex: '1'
  4458. });
  4459.  
  4460. $('.place_sim_hero_container').css({
  4461. width: '45px', height: '25px'
  4462. });
  4463.  
  4464. // hero container
  4465. $('.place_sim_hero_choose, .place_sim_hero_unit_container').css({
  4466. height: '26px',
  4467. width: '30px'
  4468. });
  4469.  
  4470. $('#hero_defense_icon, #hero_attack_icon').css({
  4471. height: '25px',
  4472. width: '25px',
  4473. margin: '0px'
  4474. });
  4475. $('#hero_defense_dd, #hero_attack_dd').css({
  4476. height: '25px',
  4477. width: '25px',
  4478. margin: '1px'
  4479. });
  4480.  
  4481. $('.place_sim_hero_attack, .place_sim_hero_defense').css({
  4482. marginLeft: '3px'
  4483. });
  4484. $('#hero_attack_text, #hero_defense_text').css({
  4485. fontSize: '11px',
  4486. bottom: '0px'
  4487. });
  4488. $('.place_sim_heroes_container .plus').css({
  4489. left: '2px', top: '2px'
  4490. });
  4491.  
  4492. $('.hero_unit').each(function(){
  4493. $(this).removeClass('unit_icon40x40').addClass('unit_icon25x25');
  4494. });
  4495.  
  4496.  
  4497.  
  4498. // hero spinner
  4499. $('.place_sim_hero_spinner').css({
  4500. height: '25px', width: '40px'
  4501. });
  4502. $('.place_sim_hero_spinner').each(function(){
  4503. $(this).removeClass('place_sim_hero_spinner').addClass('hero_spinner');
  4504. });
  4505. $('.hero_spinner .border_l').remove();
  4506. $('.hero_spinner .border_r').remove();
  4507. $('.hero_spinner .body').remove();
  4508.  
  4509. $('.place_sim_heroes_container td:eq(0)').css({ height: '30px' });
  4510.  
  4511. $('.hero_spinner').css({
  4512. height: '24px',
  4513. position: 'absolute',
  4514. width: '12px',
  4515. left: '29px',
  4516. background: 'url(https://gpall.innogamescdn.com/images/game/border/odd.png) repeat',
  4517. border: '1px solid rgb(107, 107, 107)'
  4518. });
  4519. $('.place_sim_hero_spinner .button_down, .place_sim_hero_spinner .button_up').css({
  4520. bottom: '2px',
  4521. cursor: 'pointer'
  4522. });
  4523. }
  4524.  
  4525. $('<style type="text/css"> #q_place_sim_lost_res { display: none; } </style>').appendTo('head');
  4526.  
  4527. setStrengthSimulator();
  4528. }
  4529.  
  4530. function afterSimulation(){
  4531. var lossArray = { att : { res: 0, fav: 0, pop: 0 }, def : { res: 0, fav: 0, pop: 0 } },
  4532. wall_level = parseInt($('.place_sim_wrap_mods .place_insert_field[name="sim[mods][def][wall_level]"]').val(), 10),
  4533. wall_damage = parseInt($('#building_place_def_losses_wall_level').get(0).innerHTML, 10),
  4534. wall_iron = [ 0, 200, 429, 670, 919, 1175, 1435, 1701, 1970, 2242, 2518, 2796, 3077, 3360, 3646, 3933, 4222, 4514, 4807, 5101, 5397, 5695, 5994, 6294, 6596, 6899 ];
  4535.  
  4536. // Calculate unit losses
  4537. $('#place_sim_wrap_units .place_losses, #place_sim_naval_units .place_losses').each(function(){
  4538. var loss = parseInt($(this).get(0).innerHTML, 10) || 0;
  4539. if(loss > 0){
  4540. var unit = this.id.substring(26);
  4541. var side = this.id.split("_")[2]; // att / def
  4542. lossArray[side].res += loss *(uw.GameData.units[unit].resources.wood + uw.GameData.units[unit].resources.stone + uw.GameData.units[unit].resources.iron);
  4543. lossArray[side].fav += loss * uw.GameData.units[unit].favor;
  4544. lossArray[side].pop += loss * uw.GameData.units[unit].population;
  4545. }
  4546. });
  4547. // Calculate wall resource losses
  4548. for(var w = wall_level; w > wall_level - wall_damage; w--){
  4549. lossArray.def.res += 400 + w * 350 + wall_iron[w]; // wood amount is constant, stone amount is multiplicative and iron amount is irregular for wall levels
  4550. }
  4551.  
  4552. // Insert losses into table
  4553. for(var x in lossArray){
  4554. if(lossArray.hasOwnProperty(x)){
  4555. for(var z in lossArray[x]){
  4556. if(lossArray[x].hasOwnProperty(z)){
  4557. $("#"+ x +"_"+ z).get(0).innerHTML = ((z === "res") && (lossArray[x][z] > 10000))? (Math.round(lossArray[x][z]/1000)+"k"):lossArray[x][z];
  4558. }
  4559. }
  4560. }
  4561. }
  4562. }
  4563.  
  4564. // Stärkeanzeige: Simulator
  4565. var unitsGround = { att: {}, def: {} }, unitsNaval = { att: {}, def: {} }, name ="";
  4566.  
  4567. function setStrengthSimulator() {
  4568. $('<div id="simu_table" style="position:relative; align:center;font-size: 0.8em; margin-top:6px; margin-right:39%;">'+
  4569. '<div style="float:left; margin-right:12px;"><h4>'+ getText("labels", "str") +'</h4>'+
  4570. '<table class="place_simulator_table strength" cellpadding="0px" cellspacing="0px" style="align:center;">'+
  4571. '<tr>'+
  4572. '<td class="place_simulator_even"></td>'+
  4573. '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_hack"></div></td>'+
  4574. '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_pierce"></div></td>'+
  4575. '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_dist"></div></td>'+
  4576. '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_ship"></div></td>'+
  4577. '</tr><tr>'+
  4578. '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>'+
  4579. '<td class="left_border place_simulator_odd" id="att_b">0</td>'+
  4580. '<td class="left_border place_simulator_even" id="att_s">0</td>'+
  4581. '<td class="left_border place_simulator_odd" id="att_d">0</td>'+
  4582. '<td class="left_border place_simulator_even" id="att_ship">0</td>'+
  4583. '</tr><tr>'+
  4584. '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>'+
  4585. '<td class="left_border place_simulator_odd" id="def_b">0</td>'+
  4586. '<td class="left_border place_simulator_even" id="def_s">0</td>'+
  4587. '<td class="left_border place_simulator_odd" id="def_d">0</td>'+
  4588. '<td class="left_border place_simulator_even" id="def_ship">0</td>'+
  4589. '</tr>'+
  4590. '</table>'+
  4591. '</div><div><h4>'+ getText("labels", "los") +'</h4>'+
  4592. '<table class="place_simulator_table loss" cellpadding="0px" cellspacing="0px" style="align:center;">'+
  4593. '<tr>'+
  4594. '<td class="place_simulator_even"></td>'+
  4595. '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_res"></div></td>'+
  4596. '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_fav"></div></td>'+
  4597. '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_pop"></div></td>'+
  4598. '</tr><tr>'+
  4599. '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>'+
  4600. '<td class="left_border place_simulator_odd" id="att_res">0</td>'+
  4601. '<td class="left_border place_simulator_even" id="att_fav">0</td>'+
  4602. '<td class="left_border place_simulator_odd" id="att_pop">0</td>'+
  4603. '</tr><tr>'+
  4604. '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>'+
  4605. '<td class="left_border place_simulator_odd" id="def_res">0</td>'+
  4606. '<td class="left_border place_simulator_even" id="def_fav">0</td>'+
  4607. '<td class="left_border place_simulator_odd" id="def_pop">0</td>'+
  4608. '</tr>'+
  4609. '</table>'+
  4610. '</div></div>').appendTo('#simulator_body');
  4611.  
  4612. $('#simu_table .ico').css({
  4613. height: '20px',
  4614. width: '20px'
  4615. });
  4616. $('#simu_table .units_info_sprite').css({
  4617. background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
  4618. backgroundSize: '100%'
  4619. });
  4620. $('#simu_table .img_hack').css({ backgroundPosition: '0% 36%' });
  4621. $('#simu_table .img_pierce').css({ backgroundPosition: '0% 27%' });
  4622. $('#simu_table .img_dist').css({ backgroundPosition: '0% 45%' });
  4623. $('#simu_table .img_ship').css({ backgroundPosition: '0% 72%' });
  4624.  
  4625. $('#simu_table .img_fav').css({ background: 'url(https://gpall.innogamescdn.com/images/game/res/favor.png)', backgroundSize: '100%' });
  4626. $('#simu_table .img_res').css({ background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png) 0% 54%', backgroundSize: '100%' });
  4627. $('#simu_table .img_pop').css({ background: 'url(https://gpall.innogamescdn.com/images/game/res/pop.png)', backgroundSize: '100%' });
  4628.  
  4629. $('#simu_table .left_border').css({
  4630. width: '54px'
  4631. });
  4632. $('#simu_table .left_border').each(function(){
  4633. $(this)[0].align = 'center';
  4634. });
  4635.  
  4636. $('#simu_table .strength').tooltip(getText("labels", "str") + " (" + getText("labels", "mod") +")");
  4637. $('#simu_table .loss').tooltip(getText("labels", "los"));
  4638.  
  4639. // Klick auf Einheitenbild
  4640. $('.index_unit').click(function(){
  4641. var type = $(this).attr('class').split(" ")[4];
  4642. $('.place_insert_field[name="sim[units][att]['+type+']"]').change();
  4643. });
  4644.  
  4645. $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').on('input change', function(){
  4646. name = $(this).attr("name").replace(/\]/g, "").split("[");
  4647. var str = this;
  4648. //console.log(str);
  4649. setTimeout(function(){
  4650. var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2],
  4651. val, e;
  4652.  
  4653. val = parseInt($(str).val(), 10);
  4654. val = val || 0;
  4655.  
  4656. if(unit_type == "ground"){
  4657. unitsGround[name[2]][name[3]] = val;
  4658.  
  4659. if(name[2] == "def"){
  4660. calcDef(unitsGround.def);
  4661. } else {
  4662. calcOff(unitsGround.att, unitsGround.att);
  4663. }
  4664. $('#' + name[2] + '_b').get(0).innerHTML = blunt;
  4665. $('#' + name[2] + '_s').get(0).innerHTML = sharp;
  4666. $('#' + name[2] + '_d').get(0).innerHTML = dist;
  4667.  
  4668. } else {
  4669. var att = 0, def = 0;
  4670. unitsNaval[name[2]][name[3]] = val;
  4671.  
  4672. if(name[2] == "def"){
  4673. for(e in unitsNaval.def) {
  4674. if(unitsNaval.def.hasOwnProperty(e)) {
  4675. def += unitsNaval.def[e] * uw.GameData.units[e].defense;
  4676. }
  4677. }
  4678. $('#def_ship').get(0).innerHTML = def;
  4679. } else {
  4680. for(e in unitsNaval.att) {
  4681. if(unitsNaval.att.hasOwnProperty(e)) {
  4682. att += unitsNaval.att[e] * uw.GameData.units[e].attack;
  4683. }
  4684. }
  4685. $('#att_ship').get(0).innerHTML = att;
  4686. }
  4687. }
  4688. }, 100);
  4689. });
  4690.  
  4691. // Abfrage wegen eventueller Spionageweiterleitung
  4692. getUnitInputs();
  4693. setTimeout(function(){
  4694. setChangeUnitInputs("def");
  4695. }, 100);
  4696.  
  4697. $('#select_insert_units').change(function(){
  4698. var side = $(this).find('option:selected').val();
  4699. setTimeout(function(){
  4700. getUnitInputs();
  4701. if(side === "att" || side === "def"){
  4702. setChangeUnitInputs(side);
  4703. }
  4704. }, 200);
  4705. });
  4706. }
  4707.  
  4708. function getUnitInputs(){
  4709. $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').each(function(){
  4710. name = $(this).attr("name").replace(/\]/g, "").split("[");
  4711. var str = this;
  4712. var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2],
  4713. val, e;
  4714. val = parseInt($(str).val(), 10);
  4715. val = val || 0;
  4716. if(unit_type === "ground"){
  4717. unitsGround[name[2]][name[3]] = val;
  4718. } else {
  4719. var att = 0, def = 0;
  4720. unitsNaval[name[2]][name[3]] = val;
  4721. }
  4722. });
  4723. }
  4724.  
  4725. function setChangeUnitInputs(side){
  4726. $('.place_insert_field[name="sim[units][' + side + '][godsent]"]').change();
  4727. setTimeout(function(){
  4728. $('.place_insert_field[name="sim[units][' + side + '][colonize_ship]"]').change();
  4729. }, 100);
  4730. }
  4731.  
  4732. /*******************************************************************************************************************************
  4733. * Defense form
  4734. * ----------------------------------------------------------------------------------------------------------------------------
  4735. * | ● Adds a defense form to the bbcode bar
  4736. * ----------------------------------------------------------------------------------------------------------------------------
  4737. *******************************************************************************************************************************/
  4738.  
  4739. // Funktion aufteilen...
  4740. function addForm(e){
  4741. var textareaId = "", bbcodeBarId = "";
  4742.  
  4743. switch (e) {
  4744. case "/alliance_forum/forum":
  4745. textareaId = "#forum_post_textarea";
  4746. bbcodeBarId = "#forum";
  4747. break;
  4748. case "/message/forward":
  4749. textareaId = "#message_message";
  4750. bbcodeBarId = "#message_bbcodes";
  4751. break;
  4752. case "/message/new":
  4753. textareaId = "#message_new_message";
  4754. bbcodeBarId = "#message_bbcodes";
  4755. break;
  4756. case "/message/view":
  4757. textareaId = "#message_reply_message";
  4758. bbcodeBarId = "#message_bbcodes";
  4759. break;
  4760. case "/player_memo/load_memo_content":
  4761. textareaId = "#memo_text_area";
  4762. bbcodeBarId = "#memo_edit";
  4763. break;
  4764. }
  4765.  
  4766. $('<a title="Verteidigungsformular" href="#" class="dio_bbcode_option def_form" name="def_form"></a>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
  4767.  
  4768. $('.def_form_button').css({
  4769. cursor: 'pointer',
  4770. marginTop:'3px'
  4771. });
  4772.  
  4773. $(bbcodeBarId + ' .dio_bbcode_option').css({
  4774. background: 'url("http://s14.directupload.net/images/140126/lt3hyb8j.png")',
  4775. display: 'block',
  4776. float: 'left',
  4777. width: '22px',
  4778. height: '23px',
  4779. margin: '0 3px 0 0',
  4780. position: 'relative',
  4781. });
  4782. $(bbcodeBarId + ' .def_form').css({
  4783. backgroundPosition: '-89px 0px'
  4784. });
  4785. var imgArray = {
  4786. wall: 'https://gpall.innogamescdn.com/images/game/main/wall.png',
  4787. tower: 'https://gpall.innogamescdn.com/images/game/main/tower.png',
  4788. hide: 'https://gpall.innogamescdn.com/images/game/main/hide.png',
  4789.  
  4790. spy: 'http://s7.directupload.net/images/140114/yr993xwc.png',
  4791. pop: 'http://s7.directupload.net/images/140114/4d6xktxm.png',
  4792.  
  4793. rev1: 'http://s7.directupload.net/images/140115/9cv6otiu.png',
  4794. rev0: 'http://s7.directupload.net/images/140115/aue4rg6i.png',
  4795. eo1: 'http://s1.directupload.net/images/140115/fkzlipyh.png',
  4796. eo0: 'http://s1.directupload.net/images/140115/hs2kg59c.png',
  4797. att: 'http://s1.directupload.net/images/140115/3t6uy4te.png',
  4798. sup: 'http://s7.directupload.net/images/140115/ty6szerx.png',
  4799.  
  4800. zeus: 'http://s1.directupload.net/images/140114/cdxecrpu.png',
  4801. hera: 'http://s1.directupload.net/images/140114/mve54v2o.png',
  4802. athena: 'http://s14.directupload.net/images/140114/kyqyedhe.png',
  4803. poseidon: 'http://s7.directupload.net/images/140114/tusr9oyi.png',
  4804. hades: 'http://s7.directupload.net/images/140114/huins2gn.png',
  4805. artemis: 'http://s7.directupload.net/images/140114/kghjhko8.png',
  4806. nogod: 'http://s1.directupload.net/images/140114/e7vmvfap.png',
  4807.  
  4808. captain: 'http://s14.directupload.net/images/140114/88gg75rc.png',
  4809. commander: 'http://s14.directupload.net/images/140114/slbst52o.png',
  4810. priest: 'http://s1.directupload.net/images/140114/glptekkx.png',
  4811.  
  4812. phalanx: 'http://s7.directupload.net/images/140114/e97wby6z.png',
  4813. ram: 'http://s7.directupload.net/images/140114/s854ds3w.png',
  4814.  
  4815. militia: 'http://wiki.en.grepolis.com/images/9/9b/Militia_40x40.png',
  4816. sword: 'http://wiki.en.grepolis.com/images/9/9c/Sword_40x40.png',
  4817. slinger: 'http://wiki.en.grepolis.com/images/d/dc/Slinger_40x40.png',
  4818. archer: 'http://wiki.en.grepolis.com/images/1/1a/Archer_40x40.png',
  4819. hoplite: 'http://wiki.en.grepolis.com/images/b/bd/Hoplite_40x40.png',
  4820. rider: 'http://wiki.en.grepolis.com/images/e/e9/Rider_40x40.png',
  4821. chariot: 'http://wiki.en.grepolis.com/images/b/b8/Chariot_40x40.png',
  4822. catapult: 'http://wiki.en.grepolis.com/images/f/f0/Catapult_40x40.png',
  4823. godsent: 'http://wiki.de.grepolis.com/images/6/6e/Grepolis_Wiki_225.png',
  4824.  
  4825. def_sum: 'http://s14.directupload.net/images/140127/6cxnis9r.png',
  4826.  
  4827. minotaur: 'http://wiki.de.grepolis.com/images/7/70/Minotaur_40x40.png',
  4828. manticore: 'http://wiki.de.grepolis.com/images/5/5e/Manticore_40x40.png',
  4829. zyclop: 'http://wiki.de.grepolis.com/images/6/66/Zyklop_40x40.png',
  4830. sea_monster:'http://wiki.de.grepolis.com/images/7/70/Sea_monster_40x40.png',
  4831. harpy: 'http://wiki.de.grepolis.com/images/8/80/Harpy_40x40.png',
  4832. medusa: 'http://wiki.de.grepolis.com/images/d/db/Medusa_40x40.png',
  4833. centaur: 'http://wiki.de.grepolis.com/images/5/53/Centaur_40x40.png',
  4834. pegasus: 'http://wiki.de.grepolis.com/images/5/54/Pegasus_40x40.png',
  4835. cerberus: 'http://wiki.de.grepolis.com/images/6/67/Zerberus_40x40.png',
  4836. fury: 'http://wiki.de.grepolis.com/images/6/67/Erinys_40x40.png',
  4837. griffin: 'http://wiki.de.grepolis.com/images/d/d1/Unit_greif.png',
  4838. calydonian_boar: 'http://wiki.de.grepolis.com/images/9/93/Unit_eber.png',
  4839.  
  4840. big_transporter: 'http://wiki.en.grepolis.com/images/0/04/Big_transporter_40x40.png',
  4841. bireme: 'http://wiki.en.grepolis.com/images/4/44/Bireme_40x40.png',
  4842. attack_ship: 'http://wiki.en.grepolis.com/images/e/e6/Attack_ship_40x40.png',
  4843. demolition_ship: 'http://wiki.en.grepolis.com/images/e/ec/Demolition_ship_40x40.png',
  4844. small_transporter: 'http://wiki.en.grepolis.com/images/8/85/Small_transporter_40x40.png',
  4845. trireme: 'http://wiki.en.grepolis.com/images/a/ad/Trireme_40x40.png',
  4846. colonize_ship: 'http://wiki.en.grepolis.com/images/d/d1/Colonize_ship_40x40.png',
  4847.  
  4848. move_icon: 'http://de.cdn.grepolis.com/images/game/unit_overview/',
  4849.  
  4850. bordure: 'http://s1.directupload.net/images/140126/8y6pmetk.png'
  4851. };
  4852.  
  4853. $('<div class="bb_def_chooser">'+
  4854. '<div class="bbcode_box middle_center">'+
  4855. '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div>'+
  4856. '<div class="bbcode_box top_center"></div><div class="bbcode_box bottom_center"></div>'+
  4857. '<div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>'+
  4858. '<div class="bbcode_box middle_left"></div><div class="bbcode_box middle_right"></div>'+
  4859. '<div class="bbcode_box content clearfix" style="padding:5px">'+
  4860. '<div id="f_uni" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("labels", "det") +'</div></div><br><br>'+
  4861. '<div id="f_prm" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("labels", "prm") +'</div></div><br><br>'+
  4862. '<div id="f_sil" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("labels", "sil") +'</div></div><br><br>'+
  4863. '<div id="f_mov" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("labels", "mov") +'</div></div><br><br>'+
  4864. '<div><a class="button" id="dio_insert" href="#"><span class="left"><span class="right"><span class="middle"><small>'+ getText("buttons", "ins") +'</small></span></span></span><span></span></a></div>'+
  4865. '</div></div></div>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
  4866.  
  4867. $('.bb_def_chooser').css({
  4868. display: 'none',
  4869. top: '38px',
  4870. left: '510px',
  4871. position: 'absolute',
  4872. width: '190px',
  4873. zIndex: 10000
  4874. });
  4875.  
  4876. $(bbcodeBarId + " .bb_def_chooser .checkbox_new").click(function () {
  4877. $(this).toggleClass("checked");
  4878. });
  4879.  
  4880. $(bbcodeBarId + ' .def_form').toggle(function(){
  4881. $(this).parent().find(".bb_def_chooser").get(0).style.display = "block";
  4882. }, function(){
  4883. $(this).parent().find(".bb_def_chooser").get(0).style.display = "none";
  4884. });
  4885.  
  4886. $(bbcodeBarId + ' #dio_insert').click(function(){
  4887. var textarea = $(textareaId).get(0), text = $(textarea).val(), troop_table = "", troop_img = "", troop_count = "", separator = "", move_table = "", landunit_sum = 0;
  4888.  
  4889. $('.def_form').click();
  4890.  
  4891. if($('#f_uni').hasClass("checked")){
  4892. $('.units_land .unit, .units_naval .unit').each(function(){
  4893. troop_img += separator + '[img]' + imgArray[this.className.split(" ")[1]] + '[/img]';
  4894. troop_count += separator + '[center]' + $(this).find(".value").get(0).innerHTML + '[/center]';
  4895. separator = "[||]";
  4896. });
  4897. } else {
  4898. $('.units_land .unit').each(function(){
  4899. var a = this.className.split(" ")[1], def = (uw.GameData.units[a].def_hack + uw.GameData.units[a].def_pierce + uw.GameData.units[a].def_distance)/(3 * uw.GameData.units[a].population);
  4900. if(def > 10){
  4901. landunit_sum += parseInt($(this).find(".value").get(0).innerHTML, 10) * uw.GameData.units[a].population * ((def > 20) ? 2 : 1);
  4902. }
  4903. });
  4904. landunit_sum = (landunit_sum > 10000) ? ((Math.round(landunit_sum / 100))/10) + "k" : landunit_sum;
  4905.  
  4906. troop_img += '[img]'+ imgArray.def_sum +'[/img]';
  4907. troop_count += '[center]'+ landunit_sum +'[/center]';
  4908. separator = "[||]";
  4909. $('.units_naval .unit').each(function(){
  4910. troop_img += separator + '[img]' + imgArray[this.className.split(" ")[1]] + '[/img]';
  4911. troop_count += separator + '[center]' + $(this).find(".value").get(0).innerHTML + '[/center]';
  4912. });
  4913. }
  4914. if(troop_img !== ""){ troop_table = "\n[table][**]" + troop_img + "[/**][**]" + troop_count + "[/**][/table]\n"; }
  4915.  
  4916. var str = '[img]'+ imgArray.bordure + '[/img]'+
  4917. '\n\n[color=#006B00][size=12][u][b]'+ getText("labels", "ttl") +' ([url="http://adf.ly/eDM1y"]©DIO-Tools[/url])[/b][/u][/size][/color]\n\n'+
  4918. //'[table][**][img]'+ imgArray.sup +'[/img][||]'+
  4919. '[size=12][town]' + uw.ITowns.getTown(uw.Game.townId).getId() + '[/town] ([player]'+ uw.Game.player_name +'[/player])[/size]'+
  4920. //'[||][img]'+ imgArray['rev' + (uw.ITowns.getTown(uw.Game.townId).hasConqueror()?1:0)] +'[/img][/**][/table]'+
  4921. '\n\n[i][b]'+ getText("labels", "inf") +'[/b][/i]' + troop_table +
  4922. '[table][*]'+
  4923. '[img]'+ imgArray.wall +'[/img][|]\n'+
  4924. '[img]'+ imgArray.tower +'[/img][|]\n'+
  4925. '[img]'+ imgArray.phalanx +'[/img][|]\n'+
  4926. '[img]'+ imgArray.ram +'[/img][|]\n'+
  4927. ($('#f_prm').hasClass("checked") ? '[img]'+ imgArray.commander +'[/img][|]\n' : ' ')+
  4928. ($('#f_prm').hasClass("checked") ? '[img]'+ imgArray.captain +'[/img][|]\n' : ' ')+
  4929. ($('#f_prm').hasClass("checked") ? '[img]'+ imgArray.priest +'[/img][|]\n' : ' ')+
  4930. ($('#f_sil').hasClass("checked") ? '[center][img]'+imgArray.spy+'[/img][/center][|]\n' : ' ')+
  4931. '[img]'+ imgArray.pop +'[/img][|]\n'+
  4932. '[img]'+ imgArray[(uw.ITowns.getTown(uw.Game.townId).god() || "nogod")] +'[/img][/*]\n'+
  4933. '[**][center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("wall")+ '[/center][||]'+
  4934. '[center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("tower")+ '[/center][||]'+
  4935. '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.phalanx? '+' : '-') + '[/center][||]'+
  4936. '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.ram? '+' : '-')+ '[/center][||]'+
  4937. ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.commander >= uw.Timestamp.now())? '+' : '-') + '[/center][||]' : ' ')+
  4938. ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.captain >= uw.Timestamp.now())? '+' : '-')+ '[/center][||]' : ' ')+
  4939. ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.priest >= uw.Timestamp.now())? '+' : '-') + '[/center][||]' : ' ')+
  4940. ($('#f_sil').hasClass("checked") ? '[center]' + Math.round(uw.ITowns.getTown(uw.Game.townId).getEspionageStorage()/1000) + 'k[/center][||]': ' ')+
  4941. '[center]' + uw.ITowns.getTown(uw.Game.townId).getAvailablePopulation() + '[/center][||]'+
  4942. '[center]' + $('.gods_favor_amount').get(0).innerHTML + '[/center]'+
  4943. '[/**][/table]';
  4944.  
  4945. var bb_count_str = parseInt(str.match(/\[/g).length, 10), bb_count_move = 0;
  4946.  
  4947. var i = 0;
  4948. if($('#f_mov').hasClass("checked")){
  4949. move_table += '\n[i][b]'+ getText("labels", "mov") +'[/b][/i]\n[table]';
  4950.  
  4951. $('#toolbar_activity_commands').mouseover();
  4952.  
  4953. $('#toolbar_activity_commands_list .content .command').each(function(){
  4954. var cl = $(this).children()[0].className.split(" ");
  4955. if((cl[cl.length-1] === "returning" || cl[cl.length-1] === "revolt_arising" || cl[cl.length-1] === "revolt_running") && ((bb_count_str + bb_count_move) < 480)) {
  4956. move_table += (i%1) ? "" : "[**]";
  4957. i++;
  4958. move_table += "[img]" + imgArray.move_icon + cl[2] + ".png[/img][||]";
  4959. move_table += getArrivalTime($(this).children()[1].innerHTML) + (uw.Game.market_id === "de" ? " Uhr[||]" : " [||]");
  4960. move_table += "[town]" + JSON.parse(atob($(this).children()[2].firstChild.href.split("#")[1])).id + "[/town]";
  4961. move_table += (i%1) ? "[||]" : "[/**]";
  4962. }
  4963. bb_count_move = parseInt(move_table.match(/\[/g).length, 10);
  4964. });
  4965. if((bb_count_str + bb_count_move) > 480){
  4966. move_table += '[**]...[/**]';
  4967. }
  4968.  
  4969. $('#toolbar_activity_commands').mouseout();
  4970.  
  4971. //console.log((bb_count_str + bb_count_move));
  4972. move_table += (i%1) ? "[/**]" : "";
  4973. move_table += "[*][|][color=#800000][size=6][i] ("+ getText("labels", "dev") +": ±1s)[/i][/size][/color][/*][/table]\n";
  4974. }
  4975.  
  4976. str += move_table + '[img]'+ imgArray.bordure + '[/img]';
  4977.  
  4978.  
  4979.  
  4980. $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + str + text.substring($(textarea).get(0).selectionEnd));
  4981. });
  4982. }
  4983.  
  4984. function getArrivalTime(duration_time){
  4985. /*
  4986. var server_time = new Date((uw.Timestamp.server() + 7200) * 1000);
  4987.  
  4988. duration_time = duration_time.split(":");
  4989.  
  4990. s = server_time.getUTCSeconds() + parseInt(duration_time[2], 10);
  4991. m = server_time.getUTCMinutes() + parseInt(duration_time[1], 10) + ((s>=60)? 1 : 0);
  4992. h = server_time.getUTCHours() + parseInt(duration_time[0], 10) + ((m>=60)? 1 : 0);
  4993. */
  4994.  
  4995. var server_time = $('.server_time_area').get(0).innerHTML.split(" ")[0].split(":"), arrival_time, s, m, h;
  4996. duration_time = duration_time.split(":");
  4997.  
  4998. s = parseInt(server_time[2], 10) + parseInt(duration_time[2], 10);
  4999. m = parseInt(server_time[1], 10) + parseInt(duration_time[1], 10) + ((s>=60)? 1 : 0);
  5000. h = parseInt(server_time[0], 10) + parseInt(duration_time[0], 10) + ((m>=60)? 1 : 0);
  5001.  
  5002. s = s%60; m = m%60; h = h%24;
  5003.  
  5004. s = ((s<10) ? "0" : "") + s;
  5005. m = ((m<10) ? "0" : "") + m;
  5006. h = ((h<10) ? "0" : "") + h;
  5007.  
  5008. arrival_time = h + ":" + m + ":" + s;
  5009.  
  5010. return arrival_time;
  5011. }
  5012.  
  5013.  
  5014. /*******************************************************************************************************************************
  5015. * Smiley box
  5016. * ----------------------------------------------------------------------------------------------------------------------------
  5017. * | ● Display of a smiley selection box for text input fields (forum, messages, notes):
  5018. * | ● Used smileys: http://www.greensmilies.com/smilie-album/
  5019. * | + Own Grepolis smileys
  5020. * ----------------------------------------------------------------------------------------------------------------------------
  5021. *******************************************************************************************************************************/
  5022.  
  5023. var smileyArray = { "standard": {}, "nature": {}, "grepolis": {}, "people": {}, "other":{} };
  5024.  
  5025. // smiley categories
  5026. smileyArray.button = [ "rollsmiliey", "smile" ];
  5027.  
  5028. smileyArray.standard = [
  5029. "smilenew", "i/cnfy7elqh8dotnsdp", "lol", "neutral_new", "afraid", "freddus_pacman", "auslachen2", "kolobok-sanduhr", "bussi2", "winken4", "flucht2", "panik4", "ins-auge-stechen",
  5030. "seb_zunge", "fluch4_GREEN", "baby_junge2", "blush-reloaded6", "frown", "verlegen", "blush-pfeif", "stevieh_rolleyes", "daumendreh2", "baby_taptap",
  5031. "sadnew", "hust", "confusednew", "idea2", "irre", "irre4", "sleep", "candle", "nicken", "no_sad",
  5032. "thumbs-up_new", "thumbs-down_new", "bravo2", "oh-no2", "kaffee2", "drunk", "saufen", "freu-dance", "hecheln", "headstand", "rollsmiliey", "eazy_cool01", "motz", "cuinlove", "biggrin"
  5033. ];
  5034. smileyArray.nature = [
  5035. "dinosaurier07", "flu-super-gau", "ben_cat", "schwein", "hundeleine01", "blume", "ben_sharky", "ben_cow", "charly_bissig", "gehirnschnecke_confused", "mttao_fische", "mttao_angler",
  5036. "insel", "fliegeschnappen", "i/cifohy0y1cl7nckzw", /* Spinne */ "i/cifogx34asrswrcjw", /* Schiffbrüchiger */ "plapperhase", "ben_dumbo"
  5037. ];
  5038. smileyArray.grepolis = [
  5039. "mttao_wassermann", "i/cigrmpfofys5xtiks", /* Hera */ "i/cifvfsu3e2sdiipn0", /* Medusa */ "i/cigmv8wnffb3v0ifg", /* Mantikor */ "i/cigrqlp2odi2kqo24", /* Zyklop */
  5040. "i/cj1l9gndtu3nduyvi", /* Minotaurus */ "i/cj2byjendffymp88t", /* Pegasus */ "i/cj2ccmi2x8mhcoikd", /* Hydra */
  5041. "silvester_cuinlove", "mttao_schuetze", "kleeblatt2", "wallbash", /* "glaskugel4", */ "musketiere_fechtend", /* "krone-hoch",*/ "i/cifojb85jytq5h07g", // Wikinger
  5042. "mttao_waage2", "steckenpferd", /* "kinggrin_anbeten2", */ "i/cifohielywpedbyh8", /* Grepo Love */ "skullhaufen", "pferdehaufen" // "i/ckajscggscw4s2u60"
  5043. ];
  5044. smileyArray.people = [
  5045. "seb_hut5", "opa_boese2", "star-wars-yoda1-gruen", "hexefliegend", "snob", "seb_detektiv_ani", "seb_cowboy", "devil", "segen", "pirat5", "borg", "hexe3b",
  5046. "i/cifoqe3geok0jco5o", // Ägypter
  5047. "i/ciforgs313z0ae1cc", // Hippie
  5048. "eazy_polizei", "stars_elvis", "mttao_chefkoch", "nikolaus", "pirate3_biggrin", "batman_skeptisch", "tubbie1", "tubbie2", "tubbie3", "tubbie4"
  5049. ];
  5050. smileyArray.other = [
  5051. "steinwerfen", "herzen02", "scream-if-you-can", "kolobok", "headbash", "liebeskummer", "bussi", "brautpaar-reis", "grab-schaufler2", "boxen2", "aufsmaul",
  5052. "sauf", "mttao_kehren", "sm", "weckruf", "klugscheisser2", "karte2_rot", "dagegen", "party","dafuer", "outofthebox", "pokal_gold", "koepfler", "transformer"
  5053. ];
  5054.  
  5055. // Forum: extra smiley
  5056. if($(".editor_textbox_container").get(0)){
  5057. smileyArray.grepolis.push("i/ckajscggscw4s2u60"); // Pacman
  5058. smileyArray.grepolis.push("i/cowqyl57t5o255zli"); // Bugpolis
  5059. smileyArray.grepolis.push("i/cowquq2foog1qrbee"); // Inno
  5060. }
  5061.  
  5062. var id = 0, error_count = 0;
  5063.  
  5064. var er = false;
  5065. // preload images
  5066. function loadSmileys(){
  5067. // Replace german sign smilies
  5068. if(LID !== "de"){
  5069. smileyArray.other[17] = "dagegen2";
  5070. smileyArray.other[19] = "dafuer2";
  5071. }
  5072.  
  5073. for(var e in smileyArray){
  5074. if(smileyArray.hasOwnProperty(e)) {
  5075. for(var f in smileyArray[e]){
  5076. if(smileyArray[e].hasOwnProperty(f)) {
  5077. var src = smileyArray[e][f];
  5078. smileyArray[e][f] = new Image();
  5079. smileyArray[e][f].className = "smiley" + (id++);
  5080. smileyArray[e][f].style.margin = '3px';
  5081. smileyArray[e][f].style.maxHeight = '35px';
  5082. smileyArray[e][f].style.cursor = 'pointer';
  5083. if(src.substring(0,2) == "i/" ) {
  5084. smileyArray[e][f].src = "http://666kb.com/" + src + ".gif";
  5085. } else {
  5086. if(er == false){
  5087. smileyArray[e][f].src = "http://www.greensmilies.com/smile/smiley_emoticons_" + src + ".gif";
  5088. } else {
  5089. smileyArray[e][f].src = 'http://s1.directupload.net/images/140128/93x3p4co.gif';
  5090. }
  5091. }
  5092. smileyArray[e][f].onerror = function () {
  5093. this.src = 'http://s1.directupload.net/images/140128/93x3p4co.gif';
  5094. };
  5095. }
  5096. }
  5097. }
  5098. }
  5099. }
  5100.  
  5101. // Forum smilies
  5102.  
  5103.  
  5104. function changeForumEditorLayout(){
  5105. $('.blockrow').css({ border: "none" });
  5106.  
  5107. // Subject/Title
  5108. $($('.section div label[for="title"]').parent()).css({ float:"left", width:"36%", marginRight: "20px"});
  5109. $($('.section div label[for="subject"]').parent()).css({ float:"left", width:"36%", marginRight: "20px"});
  5110.  
  5111. $('.section div input').eq(0).css({ marginBottom: "-10px", marginTop: "10px"});
  5112. $('#display_posticon').remove();
  5113.  
  5114. // Posticons
  5115. $('.posticons table').css({ width: "50%", /*marginTop: "-16px"*/});
  5116. $('.posticons').css({ marginBottom: "-16px" });
  5117. $('.posticons').insertAfter($('.section div label[for="title"]').parent());
  5118. $('.posticons').insertAfter($('.section div label[for="subject"]').parent());
  5119. // Posticons hint
  5120. $('.posticons p').remove();
  5121. // Posticons: No Icon - radio button
  5122. $(".posticons [colspan='14']").parent().replaceWith($(".posticons [colspan='14']"));
  5123. $(".posticons [colspan='14']").children().wrap("<nobr></nobr>");
  5124. $(".posticons [colspan='14']").appendTo('.posticons tr:eq(0)');
  5125. $(".posticons [colspan='4']").remove();
  5126. }
  5127.  
  5128. function addSmileyBoxForum(){
  5129. $('<div class="smiley_box"><div>'+
  5130. '<div align="center" style="float:left">'+
  5131. '<a class="group" name="standard">'+ getText("labels", "std") +' </a>'+
  5132. '<a class="group" name="grepolis">'+ getText("labels", "gre") +' </a>'+
  5133. '<a class="group" name="nature">'+ getText("labels", "nat") +' </a>'+
  5134. '<a class="group" name="people">'+ getText("labels", "ppl") +' </a>'+
  5135. '<a class="group" name="other">'+ getText("labels", "oth") +' </a>'+
  5136. '</div><div align="right" style="margin-top:2px;"><a class="smiley_link" href="http://adf.ly/eDbBl" target="_blank">WWW.GREENSMILIES.COM</a></div>'+
  5137. '<hr class="smiley_hr">'+
  5138. '<div class="smiley_box_cont" style="overflow: hidden;"><hr class="smiley_hr"></div>'+
  5139. '</div></div><br>').insertAfter(".texteditor");
  5140.  
  5141. addSmileys("standard", "");
  5142.  
  5143. $('.smiley_hr').css({ margin: '3px 0px 0px 0px', color: '#086b18', border: '1px solid' });
  5144. $('.smiley_link').css({ color: '#0c450c' });
  5145. $('.smiley_link').hover(
  5146. function(){$(this).css({ color: '#14999E' });},
  5147. function(){$(this).css({ color: '#0c450c' });}
  5148. );
  5149. $('.smiley_box').css({ maxHeight: '90px', marginLeft: "5px", width: "99%", minHeight:"10px" });
  5150. $('.smiley_box_cont').css({ overflow: 'overlay', minHeight: '70px', marginBottom: '10px' });
  5151.  
  5152. $('.group').css({ color:'#0c450c', marginRight: '10px', cursor:"pointer"}); $('.group[name="standard"]').css({ color:'#089421' });
  5153.  
  5154. $('.group').click(function(){
  5155. $('.group').each(function(){
  5156. $(this).get(0).style.color = '#0c450c';
  5157. });
  5158. $(this).get(0).style.color = '#089421';
  5159. // change smiley group
  5160. addSmileys($(this).get(0).name, "");
  5161. });
  5162. }
  5163.  
  5164. // add smiley box
  5165. function addSmileyBox(e){
  5166. var bbcodeBarId = "";
  5167. switch (e) {
  5168. case "/alliance_forum/forum": bbcodeBarId = "#forum";
  5169. break;
  5170. case "/message/forward": bbcodeBarId = "#message_bbcodes";
  5171. break;
  5172. case "/message/new": bbcodeBarId = "#message_bbcodes";
  5173. break;
  5174. case "/message/view": bbcodeBarId = "#message_bbcodes";
  5175. break;
  5176. case "/player_memo/load_memo_content": bbcodeBarId = "#memo_edit";
  5177. break;
  5178. }
  5179. if(($(bbcodeBarId + ' #emots_popup_7').get(0) || $(bbcodeBarId + ' #emots_popup_15').get(0)) && PID == 84367){
  5180. $(bbcodeBarId + " .bb_button_wrapper").get(0).lastChild.remove();
  5181. }
  5182. $('<img class="smiley_button" src="http://www.greensmilies.com/smile/smiley_emoticons_smile.gif">').appendTo(bbcodeBarId + ' .bb_button_wrapper');
  5183.  
  5184. $('<div class="smiley_box">'+
  5185. '<div class="bbcode_box middle_center"><div class="bbcode_box middle_right"></div><div class="bbcode_box middle_left"></div>'+
  5186. '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div><div class="bbcode_box top_center"></div>'+
  5187. '<div class="bbcode_box bottom_center"></div><div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>'+
  5188. '<div align="center" style="width:100%;">'+
  5189. '<a class="group" name="standard" href="">'+ getText("labels", "std") +' </a>'+
  5190. '<a class="group" name="grepolis" href="">'+ getText("labels", "gre") +' </a>'+
  5191. '<a class="group" name="nature" href="">'+ getText("labels", "nat") +' </a>'+
  5192. '<a class="group" name="people" href="">'+ getText("labels", "ppl") +' </a>'+
  5193. '<a class="group" name="other" href="">'+ getText("labels", "oth") +' </a>'+
  5194. '</div>'+
  5195. '<hr class="smiley_hr">'+
  5196. '<div class="smiley_box_cont" style="overflow: hidden;"></div>'+
  5197. '<hr class="smiley_hr">'+
  5198. '<div align="center" style="margin-top:2px;"><a href="http://www.greensmilies.com/smilie-album/" target="_blank"><span class="smiley_link">WWW.GREENSMILIES.COM</span></a></div>'+
  5199. '</div>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
  5200.  
  5201. $(bbcodeBarId + ' .smiley_button').css({
  5202. cursor: 'pointer',
  5203. margin:'3px 2px 2px 2px'
  5204. });
  5205. $(bbcodeBarId + ' .smiley_box').css({
  5206. zIndex: '5000',
  5207. position: 'absolute',
  5208. top: '27px',
  5209. left: '430px',
  5210. width: '300px',
  5211. display: 'none'
  5212. });
  5213. $(bbcodeBarId + ' .smiley_link').css({
  5214. color: '#086b18',
  5215. fontSize: '0.6em'
  5216. });
  5217. $(bbcodeBarId + ' .smiley_hr').css({
  5218. margin: '3px 0px 0px 0px',
  5219. color: '#086b18',
  5220. border: '1px solid'
  5221. });
  5222. $(bbcodeBarId + ' .group').css({
  5223. color:'#0c450c'
  5224. });
  5225. $(bbcodeBarId + ' .group[name="standard"]').css({
  5226. color:'#089421'
  5227. });
  5228. $(bbcodeBarId + ' .group').click(function(){
  5229. $("#"+ $(this).closest('.bb_button_wrapper').parent().get(0).id +' .group').each(function(){
  5230. $(this).get(0).style.color = '#0c450c';
  5231. });
  5232. $(this).get(0).style.color = '#089421';
  5233. // change smiley group
  5234. addSmileys($(this).get(0).name, "#"+ $(this).closest('.bb_button_wrapper').parent().get(0).id);
  5235. });
  5236.  
  5237. addSmileys("standard", bbcodeBarId);
  5238.  
  5239. // smiley box toggle
  5240. $(bbcodeBarId + " .smiley_button").toggle(
  5241. function(){
  5242. $(this).get(0).src = smileyArray.button[0].src;
  5243. $(this).closest('.bb_button_wrapper').find(".smiley_box").get(0).style.display = "block";
  5244. },
  5245. function(){
  5246. $(this).get(0).src = smileyArray.button[1].src;
  5247. $(this).closest('.bb_button_wrapper').find(".smiley_box").get(0).style.display = "none";
  5248. }
  5249. );
  5250. }
  5251.  
  5252. if($(".editor_textbox_container").get(0)){
  5253. loadSmileys();
  5254. changeForumEditorLayout();
  5255. addSmileyBoxForum();
  5256. }
  5257.  
  5258.  
  5259. // insert smileys from arrays into smiley box
  5260. function addSmileys(type, bbcodeBarId){
  5261. // reset smilies
  5262. if($(bbcodeBarId + " .smiley_box_cont").get(0)) {$(bbcodeBarId + " .smiley_box_cont").get(0).innerHTML='';}
  5263. // add smilies
  5264. for(var e in smileyArray[type]){
  5265. if(smileyArray[type].hasOwnProperty(e)) {
  5266. //$(smileyArray[type][e]).clone();
  5267. $('<img src="' + smileyArray[type][e].src + '" class="smiley">').appendTo(bbcodeBarId + " .smiley_box_cont");
  5268. }
  5269. }
  5270. $('.smiley').css({ margin:'3px', maxHeight:'35px', cursor:'pointer' });
  5271.  
  5272. $(bbcodeBarId + " .smiley_box_cont .smiley").click(function(){
  5273. var textarea;
  5274. if(uw.location.pathname === "/game/index"){
  5275. // hide smiley box
  5276. $(this).closest('.bb_button_wrapper').find(".smiley_button").click();
  5277. // find textarea
  5278. textarea = $(this).closest('.gpwindow_content').find("textarea").get(0);
  5279. } else {
  5280.  
  5281. if($('.editor_textbox_container').get(0)) {
  5282. textarea = $('.editor_textbox_container .cke_contents textarea').get(0);
  5283. } else {
  5284. $(this).appendTo('iframe .forum');
  5285. }
  5286. //$(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + "[img]"+ $(this).get(0).src + "[/img]" + text.substring($(textarea).get(0).selectionEnd));
  5287. }
  5288. var text = $(textarea).val();
  5289. $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + "[img]"+ $(this).get(0).src + "[/img]" + text.substring($(textarea).get(0).selectionEnd));
  5290. });
  5291. }
  5292.  
  5293.  
  5294. /*******************************************************************************************************************************
  5295. * Biremes counter
  5296. * ----------------------------------------------------------------------------------------------------------------------------
  5297. * | ● Incremental update when calling a city (experimental, especially intended for siege worlds)
  5298. * ----------------------------------------------------------------------------------------------------------------------------
  5299. * *****************************************************************************************************************************/
  5300. var count, townId;
  5301.  
  5302. function updateBiriCount(){
  5303. var sum =0, e;
  5304. for(e in biriArray) {
  5305. if(biriArray.hasOwnProperty(e)) {
  5306. if(!uw.ITowns.getTown(e)) { // town is no longer in possession of user
  5307. delete biriArray[e];
  5308. saveBiri();
  5309. } else {
  5310. sum += parseInt(biriArray[e], 10);
  5311. }
  5312. }
  5313. }
  5314. if(DATA.options.bir){
  5315. sum = sum.toString();
  5316. var str ="", fsize = ['1.4em', '1.2em', '1.15em', '1.1em', '1.0em'], i;
  5317.  
  5318. for(i = 0; i<sum.length; i++){
  5319. str += "<span style='font-size:" + fsize[i] + "'>" + sum[i] + "</span>";
  5320. }
  5321. $('#bi_count').get(0).innerHTML = "<b>" + str + "</b>";
  5322. }
  5323. }
  5324.  
  5325. function getBiri(){
  5326. var biremeIn = parseInt(uw.ITowns.getTown(uw.Game.townId).units().bireme, 10),
  5327. biremeOut = parseInt(uw.ITowns.getTown(uw.Game.townId).unitsOuter().bireme, 10);
  5328. if(isNaN(biremeIn)) biremeIn = 0;
  5329. if(isNaN(biremeOut)) biremeOut = 0;
  5330. if(!biriArray[uw.Game.townId] || biriArray[uw.Game.townId] < (biremeIn + biremeOut)) {
  5331. biriArray[uw.Game.townId] = biremeIn;
  5332. }
  5333. updateBiriCount();
  5334. saveBiri();
  5335. }
  5336.  
  5337. function getBiriDocks(){
  5338. var windowID = uw.BuildingWindowFactory.getWnd().getID(),
  5339. biremeTotal = parseInt($('#gpwnd_' + windowID + ' #unit_order_tab_bireme .unit_order_total').get(0).innerHTML, 10);
  5340.  
  5341. if(!isNaN(biremeTotal)) biriArray[uw.Game.townId] = biremeTotal;
  5342. updateBiriCount();
  5343. saveBiri();
  5344. }
  5345.  
  5346. function getBiriAgora(){
  5347. var biremeTotal = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().bireme, 10);
  5348. if(isNaN(biremeTotal)) biremeTotal = 0;
  5349.  
  5350. $('#units_beyond_list .bireme').each(function(){
  5351. biremeTotal += parseInt($(this).get(0).children[0].innerHTML, 10);
  5352. });
  5353. biriArray[uw.Game.townId] = biremeTotal;
  5354. updateBiriCount();
  5355. saveBiri();
  5356. }
  5357.  
  5358. function saveBiri(){
  5359. saveValue(WID + "_biremes", JSON.stringify(biriArray));
  5360. }
  5361.  
  5362. function initBiri() {
  5363. $(".picomap_container").prepend("<div id='unit_count'><div id='bi_count'></div></div>");
  5364.  
  5365. updateBiriCount();
  5366.  
  5367. $('#unit_count').css({
  5368. background: 'url(https://gpall.innogamescdn.com/images/game/units/units_sprite_90x90_compressed.jpg)',
  5369. height: '90px',
  5370. width: '90px',
  5371. position: 'relative',
  5372. margin: '5px 28px 0px 28px',
  5373. backgroundPosition: '-270px 0px'
  5374. });
  5375. $('#bi_count').css({
  5376. color: '#826021',
  5377. position: 'relative',
  5378. top: '28px',
  5379. fontStyle: 'italic',
  5380. width: '79px'
  5381. });
  5382. $('.picomap_overlayer').tooltip(getText("options", "bir")[0]);
  5383.  
  5384. // Set Sea-ID beside the bull eye
  5385. $('#sea_id').prependTo('#ui_box');
  5386. $('#sea_id').css({
  5387. background: 'none',
  5388. fontSize: '25px',
  5389. cursor: 'default',
  5390. height: '50px',
  5391. width: '50px',
  5392. position: 'absolute',
  5393. top: '70px',
  5394. left: '157px',
  5395. zIndex: 30
  5396. });
  5397.  
  5398. }
  5399.  
  5400. /*******************************************************************************************************************************
  5401. * Popups
  5402. * ----------------------------------------------------------------------------------------------------------------------------
  5403. * | ● Available units (no supporting or outer units)
  5404. * | ● Improved favor
  5405. * | ● getTownTypes
  5406. * ----------------------------------------------------------------------------------------------------------------------------
  5407. *******************************************************************************************************************************/
  5408. var groupUnitArray = {};
  5409. // TODO: split Function (getUnits, calcUnitsSum, availableUnits, countBiremes, getTownTypes)?
  5410. function getAllUnits(){
  5411. try {
  5412. var townArray = uw.ITowns.getTowns(), groupArray = uw.ITowns.townGroups.getGroupsDIO(),
  5413.  
  5414. unitArray = {"sword":0, "archer":0, "hoplite":0, "chariot":0, "godsent":0, "rider":0, "slinger":0, "catapult":0, "small_transporter":0, "big_transporter":0,
  5415. "manticore":0, "harpy":0, "pegasus":0, "cerberus":0, "minotaur":0, "medusa":0, "zyklop":0, "centaur":0, "fury":0, "sea_monster":0 },
  5416.  
  5417. unitArraySea = {"bireme":0, "trireme":0, "attack_ship":0, "demolition_ship":0, "colonize_ship":0 };
  5418.  
  5419. if(uw.Game.hasArtemis){
  5420. unitArray = $.extend(unitArray, {"griffin":0, "calydonian_boar":0});
  5421. }
  5422. unitArray = $.extend(unitArray, unitArraySea);
  5423.  
  5424. for(var group in groupArray){
  5425. if(groupArray.hasOwnProperty(group)){
  5426. // clone Object "unitArray"
  5427. groupUnitArray[group] = Object.create(unitArray);
  5428.  
  5429. for(var town in groupArray[group].towns){
  5430. if(groupArray[group].towns.hasOwnProperty(town)){
  5431. var type = { lo: 0, ld: 0, so: 0, sd: 0, fo: 0, fd: 0 }; // Type for TownList
  5432.  
  5433. for(var unit in unitArray){
  5434. if(unitArray.hasOwnProperty(unit)){
  5435. // All Groups: Available units
  5436. var tmp = parseInt(uw.ITowns.getTown(town).units()[unit], 10);
  5437. groupUnitArray[group][unit] += tmp || 0;
  5438. // Only for group "All"
  5439. if(group == -1){
  5440. //Bireme counter
  5441. if( unit === "bireme" && ((biriArray[townArray[town].id] || 0) < (tmp || 0))) {
  5442. biriArray[townArray[town].id] = tmp;
  5443. }
  5444. //TownTypes
  5445. if(!uw.GameData.units[unit].is_naval){
  5446. if(uw.GameData.units[unit].flying){
  5447. type.fd += ((uw.GameData.units[unit].def_hack + uw.GameData.units[unit].def_pierce + uw.GameData.units[unit].def_distance)/3 * (tmp || 0));
  5448. type.fo += (uw.GameData.units[unit].attack * (tmp || 0));
  5449. } else {
  5450. type.ld += ((uw.GameData.units[unit].def_hack + uw.GameData.units[unit].def_pierce + uw.GameData.units[unit].def_distance)/3 * (tmp || 0));
  5451. type.lo += (uw.GameData.units[unit].attack * (tmp || 0));
  5452. }
  5453. } else {
  5454. type.sd += (uw.GameData.units[unit].defense * (tmp || 0));
  5455. type.so += (uw.GameData.units[unit].attack * (tmp || 0));
  5456. }
  5457. }
  5458. }
  5459. }
  5460. // Only for group "All"
  5461. if(group == -1){
  5462. // Icon: DEF or OFF?
  5463. var z = ((type.sd + type.ld + type.fd) <= (type.so + type.lo + type.fo)) ? "o" : "d",
  5464. temp = 0;
  5465.  
  5466. for(var t in type){
  5467. if(type.hasOwnProperty(t)){
  5468. // Icon: Land/Sea/Fly (t[0]) + OFF/DEF (z)
  5469. if(temp < type[t]){
  5470. autoTownTypes[townArray[town].id] = t[0] + z;
  5471. temp = type[t];
  5472. }
  5473. // Icon: Troops Outside (overwrite)
  5474. if(temp < 1000){
  5475. autoTownTypes[townArray[town].id] = "no";
  5476. }
  5477. }
  5478. }
  5479. // Icon: Empty Town (overwrite)
  5480. var popBuilding = 0, buildVal = uw.GameData.buildings, buildingLevelArray = townArray[town].buildings().getLevels(),
  5481. popMax = Math.floor(buildVal.farm.farm_factor * Math.pow(townArray[town].buildings().getBuildingLevel("farm"), buildVal.farm.farm_pow)), // Population from farm level
  5482. popPlow = townArray[town].researches().attributes.plow ? 200 : 0,
  5483. popFactor = townArray[town].buildings().getBuildingLevel("thermal") ? 1.1 : 1.0, // Thermal
  5484. popExtra = townArray[town].getPopulationExtra();
  5485.  
  5486. for(var b in buildingLevelArray){
  5487. if(buildingLevelArray.hasOwnProperty(b)){
  5488. popBuilding += Math.round(buildVal[b].pop * Math.pow(buildingLevelArray[b], buildVal[b].pop_factor));
  5489. }
  5490. }
  5491. population[town] = {};
  5492.  
  5493. population[town].max = popMax * popFactor + popPlow + popExtra;
  5494. population[town].buildings = popBuilding;
  5495. population[town].units = parseInt((population[town].max - (popBuilding + townArray[town].getAvailablePopulation()) ), 10);
  5496.  
  5497. if(population[town].units < 300){
  5498. autoTownTypes[townArray[town].id] = "po";
  5499. }
  5500.  
  5501. population[town].percent = Math.round(100/(population[town].max - popBuilding) * population[town].units);
  5502. }
  5503. }
  5504. }
  5505. }
  5506. }
  5507. updateBiriCount();
  5508. saveBiri();
  5509. updateAvailableUnitsBox(groupUnitArray[-1]);
  5510. } catch(error){
  5511. errorHandling(error, "getAllUnits"); // TODO: Eventueller Fehler in Funktion
  5512. }
  5513. }
  5514.  
  5515. function addFunctionToITowns(){
  5516. // Copy function and prevent an error
  5517. uw.ITowns.townGroups.getGroupsDIO = function(){
  5518. var town_groups_towns, town_groups, groups = {};
  5519.  
  5520. // #Grepolis-Fix: 2.75 -> 2.76
  5521. if(MM.collections){
  5522. town_groups_towns = MM.collections.TownGroupTown[0];
  5523. town_groups = MM.collections.TownGroup[0];
  5524. } else {
  5525. town_groups_towns = MM.getCollections().TownGroupTown[0];
  5526. town_groups = MM.getCollections().TownGroup[0];
  5527. }
  5528.  
  5529. town_groups_towns.each(function(town_group_town){
  5530. var gid=town_group_town.getGroupId(),
  5531. group=groups[gid],
  5532. town_id=town_group_town.getTownId();
  5533.  
  5534. if(!group){
  5535. groups[gid] = group = {
  5536. id:gid,
  5537. //name: town_groups.get(gid).getName(), // hier tritt manchmal ein Fehler auf: TypeError: Cannot read property "getName" of undefined at http://_.grepolis.com/cache/js/merged/game.js?1407322916:8298:525
  5538. towns:{}
  5539. };
  5540. }
  5541.  
  5542. group.towns[town_id]={id:town_id};
  5543. //groups[gid].towns[town_id]={id:town_id};
  5544. });
  5545. //console.log(groups);
  5546. return groups;
  5547. };
  5548. }
  5549.  
  5550.  
  5551. function addAvailableUnitsBox(){
  5552. try {
  5553. var groupArray = uw.ITowns.townGroups.getGroupsDIO(),
  5554. default_title = DM.getl10n("place", "support_overview").options.troop_count + " ("+ DM.getl10n("hercules2014", "available")+")";
  5555.  
  5556. if(default_title.length >= 20){
  5557. default_title = default_title.substr(0, default_title.indexOf("("));
  5558. }
  5559.  
  5560. $('<div id="available_units_box" class="ui-dialog">'+
  5561. '<div class="bbcode_box middle_center"><div class="bbcode_box middle_right"></div><div class="bbcode_box middle_left"></div>'+
  5562. '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div><div class="bbcode_box top_center"></div>'+
  5563. '<div class="bbcode_box bottom_center"></div><div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>'+
  5564. '<h4><nobr>'+ (LANG.hasOwnProperty(LID) ? getText("labels", "uni") : default_title) + '</nobr></h4>'+
  5565. '<div class="drop_box">'+
  5566. '<div class="drop_group dropdown default">'+
  5567. '<div class="border-left"></div><div class="border-right"></div>'+
  5568. '<div class="caption" name="'+ groupArray[-1].id +'">'+ ITowns.town_groups._byId[groupArray[-1].id].attributes.name +'</div>'+
  5569. '<div class="arrow"></div>'+
  5570. '</div>'+
  5571. '<div class="select_group dropdown-list default active"><div class="item-list"></div></div>'+
  5572. '</div><hr>'+
  5573. '<div class="box_content"></div>'+
  5574. '</div>').appendTo('body');
  5575.  
  5576. for(var group in groupArray){
  5577. if(groupArray.hasOwnProperty(group)){
  5578. var group_name = ITowns.town_groups._byId[group].attributes.name;
  5579. $('<div class="option'+ (group == -1 ? " sel" : "") +'" name="'+ group +'">'+ group_name +'</div>').appendTo('#available_units_box .item-list');
  5580. }
  5581. }
  5582.  
  5583. // Styles
  5584. $('#available_units_box .drop_box').css({
  5585. float: 'left',
  5586. position: 'absolute',
  5587. top: '1px',
  5588. right: '0px',
  5589. width: '90px',
  5590. zIndex: '1'
  5591. });
  5592. $('#available_units_box h4').css({
  5593. color: 'rgb(128, 64, 0)',
  5594. width: '10px',
  5595. height: '25px',
  5596. marginLeft: '4px',
  5597. lineHeight: '1.9'
  5598. });
  5599. $('#available_units_box .drop_group').css({
  5600. width: '84px'
  5601. });
  5602. $('#available_units_box .select_group').css({
  5603. position: 'absolute',
  5604. width: '80px',
  5605. display: "none",
  5606. right: '3px'
  5607. });
  5608. //$('#available_units_box .item-list').css({ maxHeight: '400px', maxWidth: '200px', align: "right" });
  5609.  
  5610. $('#available_units_box .arrow').css({
  5611. width: '18px',
  5612. height: '18px',
  5613. background: 'url('+ drop_out.src +') no-repeat -1px -1px',
  5614. position: 'absolute'
  5615. });
  5616.  
  5617. // hover effects of the elements in the drop menu
  5618. $('#available_units_box .option').hover(
  5619. function(){ $(this).css({color: '#fff', background: "#328BF1"}); },
  5620. function(){ $(this).css({color: '#000', background: "#FFEEC7"}); }
  5621. );
  5622.  
  5623. // click events of the drop menu
  5624. $('#available_units_box .select_group .option').each(function(){
  5625. $(this).click(function(e){
  5626. $(this).parent().find(".sel").toggleClass("sel");
  5627. $(this).toggleClass("sel");
  5628.  
  5629. $('#available_units_box .drop_group .caption').attr("name", $(this).attr("name"));
  5630. $('#available_units_box .drop_group .caption').get(0).innerHTML = $(this).get(0).innerHTML;
  5631. $('#available_units_box .select_group')[0].style.display = "none";
  5632.  
  5633. updateAvailableUnitsBox(groupUnitArray[$(this).attr("name")]);
  5634. //$('#available_units_box .drop_group .caption').change();
  5635. });
  5636. });
  5637. // show & hide drop menu on click
  5638. $('#available_units_box .drop_group').click(function(){
  5639. if($('#available_units_box .select_group')[0].style.display === "none"){
  5640. $('#available_units_box .select_group')[0].style.display = "block";
  5641. } else {
  5642. $('#available_units_box .select_group')[0].style.display = "none";
  5643. }
  5644. });
  5645.  
  5646. $('#available_units_box').click(function(e){
  5647. var clicked = $(e.target);
  5648. if(!(clicked[0].parentNode.className.split(" ")[1] === "dropdown")){
  5649. $('#available_units_box .select_group').get(0).style.display = "none";
  5650. }
  5651. });
  5652.  
  5653. // hover arrow change
  5654. $('#available_units_box .dropdown').hover(function(e){
  5655. $(e.target)[0].parentNode.childNodes[3].style.background = "url('"+ drop_over.src +"') no-repeat -1px -1px";
  5656. }, function(e){
  5657. $(e.target)[0].parentNode.childNodes[3].style.background = "url('"+ drop_out.src +"') no-repeat -1px -1px";
  5658. });
  5659.  
  5660. //$("#available_units_box .drop_group .caption").attr("name", "All");
  5661. //$('#available_units_box .drop_group').tooltip();
  5662.  
  5663. $('#available_units_box').draggable({
  5664. containment: "body",
  5665. snap: "body",
  5666. });
  5667. $('#available_units_box').css({
  5668. color: 'rgb(12, 69, 12)',
  5669. position: 'absolute',
  5670. top: '100px',
  5671. left: '200px',
  5672. zIndex: getMaxZIndex() + 1,
  5673. display: 'none'
  5674. });
  5675. $('#available_units_box .box_content').css({
  5676. background: 'url(http://s1.directupload.net/images/140206/8jd9d3ec.png) 94% 94% no-repeat',
  5677. backgroundSize: '140px'
  5678. });
  5679.  
  5680. $('#available_units_box').bind("mousedown",function(){
  5681. $(this).get(0).style.zIndex = getMaxZIndex() + 1;
  5682. });
  5683.  
  5684. $('#available_units_box hr').css({ margin: '3px 0px 0px', border: '1px solid', color: 'rgb(128, 64, 0)'});
  5685. } catch(error){
  5686. errorHandling(error, "addAvailableUnitsBox");
  5687. }
  5688. }
  5689.  
  5690. function updateAvailableUnitsBox(unitArray){
  5691. var i = 0, content = '<table><tr><td>', ttpArray = {};
  5692. for(var u in unitArray){
  5693. if(unitArray.hasOwnProperty(u)){
  5694. if(((i%5 == 0) && (i!== 25)) || u == "bireme") {
  5695. content += "</td></tr><tr><td>";
  5696. }
  5697. content += '<div class="unit index_unit bold unit_icon40x40 ' + u + ' " ><span style="font-size:0.9em">' + unitArray[u] + '</span></div> ';
  5698. ttpArray[u] = GameData.units[u].name;
  5699. i++;
  5700. }
  5701. }
  5702. content += '</td></tr></table>';
  5703. $('#available_units_box .box_content').get(0).innerHTML = "";
  5704. $('#available_units_box .box_content').append(content);
  5705.  
  5706.  
  5707. // Unit name tooltips
  5708. for(var o in ttpArray){
  5709. if(ttpArray.hasOwnProperty(o)){
  5710. $("#available_units_box ."+ o).tooltip(ttpArray[o]);
  5711. }
  5712. }
  5713. }
  5714.  
  5715. function unbindFavorPopup(){
  5716. //$('.gods_favor_button_area, #favor_circular_progress').mouseover();
  5717. //$('.gods_favor_button_area, #favor_circular_progress').mouseout();
  5718.  
  5719. $('.gods_favor_button_area, #favor_circular_progress').bind('mouseover mouseout', function(){
  5720. return false;
  5721. });
  5722. $('.gods_area').bind('mouseover', function(){
  5723. setFavorPopup();
  5724. });
  5725. }
  5726.  
  5727. var godArray = {
  5728. zeus: ' 0px', //'http://s1.directupload.net/images/140116/mkhzwush.png',
  5729. hera: '-152px', //'http://s1.directupload.net/images/140116/58ob8z82.png',
  5730. poseidon: '-101px', //'http://s1.directupload.net/images/140116/dkfxrw2f.png',
  5731. athena: ' -50px', //'http://s14.directupload.net/images/140116/iprgopak.png',
  5732. hades: '-203px', //'http://s14.directupload.net/images/140116/c9juk95y.png',
  5733. artemis: '-305px', //'http://s14.directupload.net/images/140116/pdc8vxe2.png'
  5734. };
  5735.  
  5736. var godImg = new Image(); godImg.src = "https://diotools.pf-control.de/images/game/gods.png";
  5737.  
  5738. function setFavorPopup(){
  5739. var pic_row = "",
  5740. fav_row = "",
  5741. prod_row = "";
  5742.  
  5743. for(var g in godArray){
  5744. if(godArray.hasOwnProperty(g)){
  5745. if(uw.ITowns.player_gods.attributes.temples_for_gods[g]){
  5746. pic_row += '<td><div style="width:50px;height:51px;background:url('+ godImg.src +');background-position: 0px '+ godArray[g] +';"></td>';
  5747. fav_row += '<td class="bold" style="color:blue">'+ uw.ITowns.player_gods.attributes[g + "_favor"] +'</td>';
  5748. prod_row += '<td class="bold">'+ uw.ITowns.player_gods.attributes.production_overview[g].production +'</td>';
  5749. }
  5750. }
  5751. }
  5752. var tool_element = $('<table><tr><td></td>'+ pic_row +'</tr>'+
  5753. '<tr align="center"><td><img src="https://gpall.innogamescdn.com/images/game/res/favor.png"></td>'+ fav_row +'</tr>'+
  5754. '<tr align="center"><td>+</td>'+ prod_row +'</tr>'+
  5755. '</table>');
  5756.  
  5757. $('.gods_favor_button_area, #favor_circular_progress').tooltip(tool_element);
  5758. }
  5759.  
  5760.  
  5761. /*******************************************************************************************************************************
  5762. * GUI Optimization
  5763. * ----------------------------------------------------------------------------------------------------------------------------
  5764. * | ● Modified spell box (smaller, moveable & position memory)
  5765. * | ● Larger taskbar and minimize daily reward-window on startup
  5766. * | ● Modify chat
  5767. * | ● Improved display of troops and trade activity boxes (movable with position memory on startup)
  5768. * ----------------------------------------------------------------------------------------------------------------------------
  5769. *******************************************************************************************************************************/
  5770.  
  5771. // Spell box
  5772. function catchSpellBox(){
  5773. $.Observer(uw.GameEvents.ui.layout_gods_spells.rendered).subscribe('DIO_SPELLBOX_CHANGE_OPEN', function () {
  5774. if(spellbox.show == false) {
  5775. spellbox.show = true;
  5776. saveValue("spellbox", JSON.stringify(spellbox));
  5777. }
  5778.  
  5779. changeSpellBox();
  5780. });
  5781. $.Observer(uw.GameEvents.ui.layout_gods_spells.state_changed).subscribe('DIO_SPELLBOX_CLOSE', function () {
  5782. spellbox.show = false;
  5783. saveValue("spellbox", JSON.stringify(spellbox));
  5784. });
  5785. }
  5786.  
  5787. function initSpellBox(){
  5788. try {
  5789. $('<style type="text/css">'+
  5790. '.gods_spells_active .nui_right_box {'+
  5791. 'overflow: visible !important;'+
  5792. '</style>').appendTo('head');
  5793.  
  5794. $(".gods_spells_menu").css({
  5795. width: "134px"
  5796. });
  5797.  
  5798. $("#ui_box .gods_area .gods_spells_menu .content").css({
  5799. background: "url(https://gpall.innogamescdn.com/images/game/layout/power_tile.png) 1px 4px",
  5800. overflow: "auto",
  5801. margin: "0 0 0px 0px",
  5802. border: "3px inset rgb(16, 87, 19)",
  5803. borderRadius: "10px"
  5804. });
  5805.  
  5806. $('.nui_units_box').css({
  5807. display: 'block',
  5808. marginTop: '-8px',
  5809. position: 'relative'
  5810. });
  5811. $('.nui_units_box .bottom_ornament').css({
  5812. marginTop: '-28px',
  5813. position: 'relative'
  5814. });
  5815.  
  5816. $('.gods_area').css({
  5817. height: '150px'
  5818. });
  5819.  
  5820. if($(".gods_spells_menu .left").get(0)){
  5821. $(".gods_spells_menu .left").remove(); $(".gods_spells_menu .right").remove();
  5822. $(".gods_spells_menu .top").remove(); $(".gods_spells_menu .bottom").remove();
  5823. }
  5824.  
  5825. $(".gods_spells_menu").draggable({
  5826. containment: "body",
  5827. distance: 10 ,
  5828. snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, #island_quests_overview",
  5829. opacity: 0.7,
  5830. stop : function(){
  5831. spellbox.top = this.style.top;
  5832. spellbox.left = this.style.left;
  5833.  
  5834. saveValue("spellbox", JSON.stringify(spellbox));
  5835. }
  5836. });
  5837. $(".gods_area .gods_spells_menu").before($('.nui_units_box'));
  5838.  
  5839.  
  5840. // Position
  5841. $('.gods_spells_menu').css({
  5842. position: 'absolute',
  5843. left: spellbox.left,
  5844. top: spellbox.top,
  5845. zIndex: '5000',
  5846. padding: '30px 0px 0px -4px'
  5847. });
  5848.  
  5849. // Active at game start?
  5850. if(spellbox.show) {
  5851. $('.btn_gods_spells').click();
  5852. }
  5853. } catch(error){
  5854. errorHandling(error, "initSpellBox");
  5855. }
  5856.  
  5857. }
  5858.  
  5859. function changeSpellBox(){
  5860. try {
  5861. $(".gods_spells_menu").css({
  5862. //height: "300px"
  5863. //height: $(".nui_units_box").height() + "px"
  5864. });
  5865. //console.log($(".nui_units_box").height());
  5866.  
  5867. $('.god_container[data-god_id="zeus"]').css({
  5868. //float: 'left'
  5869. });
  5870. $('.powers_container').css({
  5871. background: 'none'
  5872. });
  5873. $('.god_container').css({
  5874. float: 'left'
  5875. });
  5876. $('.god_container[data-god_id="zeus"], .god_container[data-god_id="athena"]').css({
  5877. float: 'none'
  5878. });
  5879. $('.content .title').each(function(){
  5880. $(this).get(0).style.display = "none";
  5881. });
  5882.  
  5883. $('.god_container[data-god_id="poseidon"]').prependTo('.gods_spells_menu .content');
  5884. $('.god_container[data-god_id="athena"]').appendTo('.gods_spells_menu .content');
  5885. $('.god_container[data-god_id="artemis"]').appendTo('.gods_spells_menu .content');
  5886.  
  5887. if($('.bolt').get(0)) { $('.bolt').remove(); }
  5888. if($('.earthquake').get(0)) { $('.earthquake').remove(); }
  5889. if($('.pest').get(0)) { $('.pest').remove(); }
  5890. } catch(error){
  5891. errorHandling(error, "changeSpellBox");
  5892. }
  5893. }
  5894.  
  5895. // Minimize Daily reward window on startup
  5896. function minimizeDailyReward(){
  5897. /*
  5898. $.Observer(uw.GameEvents.window.open).subscribe('DIO_WINDOW', function(u,dato){});
  5899. $.Observer(uw.GameEvents.window.reload).subscribe('DIO_WINDOW2', function(f){});
  5900. */
  5901. if(MutationObserver) {
  5902. var startup = new MutationObserver(function(mutations) {
  5903. mutations.forEach(function(mutation) {
  5904. if(mutation.addedNodes[0]){
  5905. if($('.daily_login').get(0)){ // && !uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).isMinimized()
  5906. $('.daily_login').find(".minimize").click();
  5907. //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).minimize();
  5908. }
  5909. }
  5910. });
  5911. });
  5912. startup.observe($('body').get(0), { attributes: false, childList: true, characterData: false});
  5913.  
  5914. setTimeout(function(){ startup.disconnect();}, 3000);
  5915. }
  5916. }
  5917.  
  5918. // Larger taskbar
  5919. function scaleTaskbar(){
  5920. $('.minimized_windows_area').get(0).style.width= "150%";
  5921. $('.minimized_windows_area').get(0).style.left= "-25%";
  5922. }
  5923. // hide fade out buttons => only for myself
  5924. function hideNavElements() {
  5925. if(uw.Game.premium_features.curator<=uw.Timestamp.now()){
  5926. $('.nav').each(function() {
  5927. $(this).get(0).style.display = "none";
  5928. });
  5929. }
  5930. }
  5931.  
  5932. /*******************************************************************************************************************************
  5933. * Modify Chat
  5934. *******************************************************************************************************************************/
  5935. function popupChatUser(){ // not used yet
  5936. setTimeout(function(){
  5937. GM_xmlhttpRequest({
  5938. method: "POST",
  5939. url: "http://wwwapi.iz-smart.net/modules.php?name=Chaninfo&file=nicks&chan=Grepolis"+ uw.Game.market_id.toUpperCase(),
  5940. onload: function(response) {
  5941. //$('.nui_main_menu .chat .indicator').get(0).innerHTML =
  5942. //console.log(response.responseText);
  5943. //$('.nui_main_menu .chat .indicator').get(0).style.display = 'inline';
  5944. }
  5945. });
  5946. }, 0);
  5947. }
  5948.  
  5949. function initChatUser(){
  5950. $('.nui_main_menu .chat .button, .nui_main_menu .chat .name_wrapper').css({
  5951. filter: 'url(#Hue1)',
  5952. WebkitFilter: 'hue-rotate(65deg)'
  5953. });
  5954. updateChatUser();
  5955. setInterval(function(){ updateChatUser(); }, 300000);
  5956. $('.nui_main_menu .chat').mouseover(function(){
  5957. //popupChatUser();
  5958. });
  5959. if($('.nui_main_menu .chat').hasClass('disabled')){ $('.nui_main_menu .chat').removeClass('disabled');}
  5960. }
  5961.  
  5962. function updateChatUser(){
  5963. var market = uw.Game.market_id;
  5964. if(gm){
  5965. // GM-BROWSER:
  5966. chatUserRequest();
  5967. } else {
  5968. // SAFARI:
  5969. $.ajax({
  5970. url:"https://diotools.pf-control.de/game/chatuser_count.php?chan=Grepo"+ (market === "de" ? "lisDE" : ""),
  5971. dataType : 'text',
  5972. success: function(text) {
  5973. $('.nui_main_menu .chat .indicator').get(0).innerHTML = text;
  5974. $('.nui_main_menu .chat .indicator').get(0).style.display = 'block';
  5975. },
  5976. error: function (xhr, ajaxOptions, thrownError) {
  5977. $('.nui_main_menu .chat .indicator').get(0).style.display = 'none';
  5978. }
  5979. });
  5980. }
  5981. }
  5982.  
  5983.  
  5984. $('<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>').appendTo('head');
  5985.  
  5986. // Modify chat window
  5987. function modifyChat() {
  5988. var host = { fr: 'irc.quakenet.org', def: 'flash.afterworkchat.de'},
  5989. market = uw.Game.market_id, select_nick = false, chatwnd_id,
  5990. nickname = uw.Game.player_name;
  5991.  
  5992. setTimeout(function(){ updateChatUser(); }, 10000); setTimeout(function(){ updateChatUser(); }, 30000);
  5993.  
  5994. //uw.GPWindowMgr.Create(uw.Layout.wnd.TYPE_CHAT);
  5995.  
  5996. //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).setWidth(600);
  5997. //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).setHeight(300);
  5998. //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).setPosition([0,'bottom']);
  5999.  
  6000. //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT));
  6001.  
  6002. chatwnd_id = '#gpwnd_' + uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).getID();
  6003.  
  6004. $('#chat').get(0).innerHTML = "";
  6005. //$(chatwnd_id).parent().children('.gpwindow_left').remove();
  6006. //$(chatwnd_id).parent().children('.gpwindow_right').remove();
  6007. //$(chatwnd_id).parent().children('.gpwindow_top').remove();
  6008. //$(chatwnd_id).parent().children('.gpwindow_bottom').remove();
  6009. //$(chatwnd_id).parent().parent().children('.ui-dialog-titlebar').remove();
  6010.  
  6011. var replaceArray = {
  6012. // Russian:
  6013. "Ё":"YO","Й":"I","Ц":"TS","У":"U","К":"K","Е":"E","Н":"N","Г":"G","Ш":"SH","Щ":"SCH","З":"Z","Х":"H","Ъ":"'",
  6014. "ё":"yo","й":"i","ц":"ts","у":"u","к":"k","е":"e","н":"n","г":"g","ш":"sh","щ":"sch","з":"z","х":"h","ъ":"'",
  6015. "Ф":"F","Ы":"I","В":"V","А":"a","П":"P","Р":"R","О":"O","Л":"L","Д":"D","Ж":"ZH","Э":"E",
  6016. "ф":"f","ы":"i","в":"v","а":"a","п":"p","р":"r","о":"o","л":"l","д":"d","ж":"zh","э":"e",
  6017. "Я":"Ya","Ч":"CH","С":"S","М":"M","И":"I","Т":"T","Ь":"'","Б":"B","Ю":"YU",
  6018. "я":"ya","ч":"ch","с":"s","м":"m","и":"i","т":"t","ь":"'","б":"b","ю":"yu",
  6019.  
  6020. // Greek:
  6021. 'Α':'A','Β':'B','Γ':'G','Δ':'D','Ε':'E','Ζ':'Z','Η':'H','Θ':'Th','Ι':'I','Κ':'K','Λ':'L','Μ':'M','Ν':'N','Ξ':'J','Ο':'O','Π':'P','Ρ':'R','Σ':'S',
  6022. 'Τ':'T','Υ':'U','Φ':'F','Χ':'Ch','Ψ':'Ps','Ω':'W','Ά':'A','Έ':'E','Ή':'H','Ί':'I','Ό':'O','Ύ':'U','Ώ':'W','Ϊ':'I',
  6023. 'α':'a','β':'b','γ':'g','δ':'d','ε':'e','ζ':'z','η':'h','θ':'th','ι':'i','κ':'k','λ':'l','μ':'m','ν':'n','ξ':'j','ο':'o','π':'p','ρ':'r','ς':'s',
  6024. 'σ':'s','τ':'t','υ':'u','φ':'f','χ':'ch','ψ':'ps','ω':'w','ά':'a','έ':'e','ή':'h','ί':'i','ό':'o','ύ':'u','ώ':'w','ϊ':'i','ΐ':'i'
  6025. };
  6026.  
  6027. function replaceNick(word){
  6028. var temp = "", temp2 = "";
  6029. // Step 1: Replace Special and some german chars
  6030. word = word.replace(/[.,:,+,*]/g,"").replace(/[=,\ ,\-]/g,"_").replace(/ö/gi,"oe").replace(/ä/gi,"ae").replace(/ü/gi,"ue").replace(/ß/g,"ss");
  6031. // Step 2: Replace russian and greek chars
  6032. if(!word.match(/^[a-zA-Z0-9_]+$/)){
  6033. temp = word.split('').map(function (char) {
  6034. var ch = "";
  6035. ch = replaceArray[char] || char;
  6036. return ch;
  6037. }).join("");
  6038. // Step 3: Delete all other special chars
  6039. if(!temp.match(/^[a-zA-Z0-9_]+$/)){
  6040. for(var c = 0; c < temp.length; c++){
  6041. if(temp[c].match(/^[a-zA-Z0-9_]+$/)){
  6042. temp2 += temp[c];
  6043. }
  6044. }
  6045. select_nick = true;
  6046. temp = temp2;
  6047. }
  6048. word = temp;
  6049. }
  6050. return word;
  6051. }
  6052. //nickname = "kνnmδενεί-ναισυνδεδ*εμένος_Ιππέας"; // greek test nickname
  6053. nickname = replaceNick(nickname);
  6054.  
  6055. if(PID == 84367){ nickname = "DionY_"; }
  6056.  
  6057. $('<iframe src="https://diotools.pf-control.de/chat/lightIRC.swf'+ //'+ //http://flash.afterworkchat.de/1.0/FlashChat.swf
  6058. '?host=irc.todochat.org'+//irc.lightirc.com'+ //flash.afterworkchat.de'+
  6059. //'?languagePath=http://flash.afterworkchat.de/1.0/language/'+
  6060. '&port=6667'+
  6061. '&ssl=true'+
  6062. '&policyPort=8002'+
  6063. '&styleURL=https://diotools.pf-control.de/css/green3.css'+
  6064. '&emoticonPath=https://diotools.pf-control.de/chat/emoticons/'+
  6065. '&emoticonList='+
  6066. ':)->smile.png,:(->sad.png,:O->baby.swf,:D->biggrin.png,~D->coffee.swf,:P->tongue.swf,8)->cool.png,:|->neutral.png,X)->drunk.swf,%5e%5e->grins.png,:{->cry.swf,:S->verlegen.png,'+
  6067. ':$->blush.swf,:]->lol.swf,:*->bussi.swf,:[->fluch.swf'+
  6068. //'&accessKey=54a2846a460ae1703ac690d21551b997'+
  6069. '&nick='+ nickname +
  6070. '&nickAlternate='+ nickname +'_'+
  6071. '&autojoin=%23GREPO,%23Grepolis'+ market.toUpperCase() +
  6072. '&showNickSelection='+ select_nick +
  6073. '&showNavigation=true'+
  6074. '&navigationPosition=top'+
  6075. '&showNickSelection=false'+
  6076. '&showIdentifySelection=false'+
  6077. '&language='+ LID +
  6078. '&quitMessage=CYA'+
  6079. '&showChannelHeader=false'+
  6080. //'&useUserListIcons=true'+
  6081. '&userListWidth=100'+
  6082. '&soundAlerts=true'+
  6083. '&soundOnNewChannelMessage=true'+
  6084. '&showServerWindow=false'+
  6085. '&fontSize=9'+
  6086. '&showJoinPartMessages=false'+
  6087. '&showMenuButton=false'+
  6088. '&showTranslationButton=false'+
  6089. '&showTimestamps=true'+
  6090. //'&showInfoMessages=false'+
  6091. '&showRegisterNicknameButton=false'+
  6092. '&showRichTextControls=false'+
  6093. //'&useUserListIcons=true'+
  6094. '&showUserListInformationPopup=false'+
  6095. '&showNickChangeButton=false'+
  6096. '&showChannelCentral=false'+
  6097. '&showOptionsButton=false'+
  6098. '&showEmoticonsButton=true'+
  6099. '&rememberNickname=false'+
  6100. '" style="width:518px; height:357px; border:0px;"></iframe>').appendTo("#chat");
  6101.  
  6102. /*
  6103. $('<html><body><div id="lightIRC"><p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p></div>'+
  6104. '<script type="text/javascript">'+
  6105. 'var params = {};'+
  6106. 'params.languagePath = "http://flash.afterworkchat.de/1.0/language/";'+
  6107. 'params.host = "flash.afterworkchat.de";'+
  6108. 'params.port = 6667;'+
  6109. 'params.policyPort = 9000;'+
  6110. //'params.accessKey = "54a2846a460ae1703ac690d21551b997";'+
  6111. 'params.styleURL = "http://diotools.pf-control.de/css/green2.css";'+
  6112. 'params.emoticonPath = "http://diotools.pf-control.de/chat/emoticons/";'+
  6113. 'params.emoticonList = ":)->smile.png,:(->sad.png,:O->baby.swf,:D->biggrin.png,~D->coffee.swf,:P->tongue.swf,8)->cool.png,:|->neutral.png,X)->drunk.swf,%5e%5e->grins.png,:{->cry.swf,:S->verlegen.png,'+
  6114. ':$->blush.swf,:]->lol.swf,:*->bussi.swf,:[->fluch.swf";'+
  6115. 'params.nick = "'+ nickname + '";' +
  6116. 'params.autojoin = "%23GREPO,%23Grepolis'+ market.toUpperCase() + '";' +
  6117. 'params.showNickSelection = ' + select_nick + ';'+
  6118. 'params.showIdentifySelection = false;'+
  6119. 'params.language = "'+ LID +'";'+
  6120. 'params.soundAlerts = true;'+
  6121. 'params.fontSize = "10";'+
  6122. 'params.navigationPosition = "top";'+
  6123. 'params.showJoinPartMessages = false;'+
  6124. 'params.showTimestamps = true;'+
  6125. 'params.showRegisterNicknameButton = false;'+
  6126. 'params.showNickChangeButton = true;'+
  6127. 'params.showOptionsButton = true;'+
  6128. 'params.showServerWindow = false;'+
  6129. 'params.showOptionsButton = false;'+
  6130. 'params.showMenuButton = false;'+
  6131. 'params.showTranslationButton = false;'+
  6132. 'params.showRichTextControls = false;'+
  6133. 'params.showChannelHeader = false;'+
  6134. 'params.rememberNickname = false;'+
  6135. 'params.userListWidth = 100;' +
  6136. 'params.soundAlerts = true;'+
  6137. 'params.soundOnNewChannelMessage = false;'+
  6138. 'swfobject.embedSWF("http://flash.afterworkchat.de/1.0/FlashChat.swf", "lightIRC", "100%", "100%", "10.0.0", "http://flash.afterworkchat.de/expressinstall.swf", params, {wmode:"transparent"});'+
  6139. '</script></body></html>').appendTo("#chat");
  6140. */
  6141. }
  6142.  
  6143. /*******************************************************************************************************************************
  6144. * Activity boxes
  6145. * ----------------------------------------------------------------------------------------------------------------------------
  6146. * | ● Show troops and trade activity boxes
  6147. * | ● Boxes are magnetic & movable (position memory)
  6148. * ----------------------------------------------------------------------------------------------------------------------------
  6149. *******************************************************************************************************************************/
  6150. var mut_toolbar, mut_command, mut_trade;
  6151. function checkToolbarAtStart(){
  6152. if(parseInt($('.toolbar_activities .commands .count').get(0).innerHTML, 10) > 0){
  6153. $('#toolbar_activity_commands_list').get(0).style.display = "block";
  6154. } else {
  6155. $('#toolbar_activity_commands_list').get(0).style.display = "none";
  6156. }
  6157. if(parseInt($('.toolbar_activities .trades .count').get(0).innerHTML, 10) > 0){
  6158. $('#toolbar_activity_trades_list').get(0).style.display = "block";
  6159. } else {
  6160. $('#toolbar_activity_trades_list').get(0).style.display = "none";
  6161. }
  6162. }
  6163.  
  6164. function catchToolbarEvents(){
  6165. mut_toolbar = new MutationObserver(function(mutations) {
  6166. mutations.forEach(function(mutation) {
  6167. if(mutation.addedNodes[0]){
  6168. //console.log(mutation);
  6169. if(mutation.target.id === "toolbar_activity_trades_list"){
  6170. draggableTradeBox();
  6171. } else {
  6172. draggableCommandBox();
  6173. }
  6174. mutation.addedNodes[0].remove();
  6175. }
  6176. });
  6177. });
  6178. mut_command = new MutationObserver(function(mutations) {
  6179. mutations.forEach(function(mutation) {
  6180. if(mutation.addedNodes[0]){
  6181. if(mutation.addedNodes[0].nodeValue > 0){
  6182. $('#toolbar_activity_commands_list').get(0).style.display = "block";
  6183. } else {
  6184. $('#toolbar_activity_commands_list').get(0).style.display = "none";
  6185. }
  6186. }
  6187. });
  6188. });
  6189. mut_trade = new MutationObserver(function(mutations) {
  6190. mutations.forEach(function(mutation) {
  6191. if(mutation.addedNodes[0]){
  6192. if(mutation.addedNodes[0].nodeValue > 0){
  6193. $('#toolbar_activity_trades_list').get(0).style.display = "block";
  6194. } else {
  6195. $('#toolbar_activity_trades_list').get(0).style.display = "none";
  6196. }
  6197. }
  6198. });
  6199. });
  6200. }
  6201. // moveable boxes
  6202. function draggableTradeBox(){
  6203. $("#toolbar_activity_trades_list").draggable({
  6204. containment: "body",
  6205. distance: 20,
  6206. snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, .nui_left_box",
  6207. opacity: 0.7,
  6208. start : function () {
  6209. $("#fix_trade").remove();
  6210. },
  6211. stop : function () {
  6212. var pos = $('#toolbar_activity_trades_list').position();
  6213. tradebox.left = pos.left;
  6214.  
  6215. saveValue("tradebox", JSON.stringify(tradebox));
  6216.  
  6217.  
  6218. $('<style id="fix_trade" type="text/css">'+
  6219. '#toolbar_activity_trades_list {'+
  6220. 'left:' + tradebox.left + 'px !important;'+
  6221. 'top: ' + tradebox.top + 'px !important}'+
  6222. '</style>').appendTo('head');
  6223. }
  6224. });
  6225. }
  6226.  
  6227. function draggableCommandBox(){
  6228. $("#toolbar_activity_commands_list").draggable({
  6229. containment: "body",
  6230. distance: 20,
  6231. snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, .nui_left_box",
  6232. opacity: 0.7,
  6233. stop : function () {
  6234. var pos = $('#toolbar_activity_commands_list').position();
  6235. commandbox.left = pos.left;
  6236. commandbox.top = pos.top;
  6237.  
  6238. saveValue("commandbox", JSON.stringify(commandbox));
  6239. }
  6240. });
  6241. }
  6242.  
  6243. function showActivityBoxes(){
  6244. var observe_options = { attributes: false, childList: true, characterData: false};
  6245.  
  6246. catchToolbarEvents();
  6247.  
  6248. mut_toolbar.observe($('#toolbar_activity_commands_list').get(0), observe_options );
  6249. mut_toolbar.observe($('#toolbar_activity_trades_list').get(0), observe_options );
  6250.  
  6251. mut_command.observe($('.toolbar_activities .commands .count').get(0), observe_options );
  6252. mut_trade.observe($('.toolbar_activities .trades .count').get(0), observe_options );
  6253.  
  6254. $('#toolbar_activity_commands').mouseover();
  6255. $('#toolbar_activity_trades').mouseover();
  6256. $('#toolbar_activity_commands, #toolbar_activity_trades').unbind("mouseover");
  6257. $('#toolbar_activity_commands, #toolbar_activity_commands_list, #toolbar_activity_trades, #toolbar_activity_trades_list').unbind("mouseout");
  6258. $('#toolbar_activity_trades_list').unbind("click");
  6259.  
  6260. checkToolbarAtStart();
  6261.  
  6262. $('#toolbar_activity_commands_list').css({
  6263. left: commandbox.left + "px",
  6264. top: commandbox.top + "px"
  6265. });
  6266.  
  6267. $('<style id="fix_lists" type="text/css">'+
  6268. '#toolbar_activity_commands_list, #toolbar_activity_trades_list { width: 160px}'+
  6269. '.dropdown-list .content { max-height: 329px}'+
  6270. '</style>'+
  6271. '<style id="fix_trade" type="text/css">'+
  6272. '#toolbar_activity_trades_list {'+
  6273. 'left:' + tradebox.left + 'px !important;'+
  6274. 'top: ' + tradebox.top + 'px !important}'+
  6275. '</style>').appendTo('head');
  6276.  
  6277. draggableCommandBox();
  6278. draggableTradeBox();
  6279.  
  6280. $('.toolbar_activities .commands').mouseover(function(){
  6281. $('#toolbar_activity_commands_list').get(0).style.display = "block";
  6282. });
  6283. $('.toolbar_activities .trades').mouseover(function(){
  6284. $('#toolbar_activity_trades_list').get(0).style.display = "block";
  6285. });
  6286. }
  6287.  
  6288. /*******************************************************************************************************************************
  6289. * Other stuff
  6290. *******************************************************************************************************************************/
  6291.  
  6292. function counter(time){
  6293. var type = "", today, counted, year, month, day;
  6294. if(uw.Game.market_id !== "zz"){
  6295. counted = DATA.count;
  6296. today = new Date((time + 7200) * 1000);
  6297. year = today.getUTCFullYear();
  6298. month = ((today.getUTCMonth()+1) < 10 ? "0" : "") + (today.getUTCMonth()+1);
  6299. day = (today.getUTCDate() < 10 ? "0" : "") + today.getUTCDate();
  6300. today = year + month + day;
  6301. //console.log(today);
  6302. if(counted[0] !== today){type += "d"; }
  6303. if(counted[1] == false){ type += "t"; }
  6304. if((counted[2] == undefined) || (counted[2] == false)){ type += "b"; }
  6305. if(type !== ""){
  6306. $.ajax({
  6307. type: "GET",
  6308. url: "https://diotools.pf-control.de/game/count.php?type="+ type + "&market="+ uw.Game.market_id + "&date="+ today + "&browser="+ getBrowser(),
  6309. dataType : 'text',
  6310. success: function (text) {
  6311. if(text.indexOf("dly") > -1){
  6312. counted[0] = today;
  6313. }
  6314. if(text.indexOf("tot") > -1){
  6315. counted[1] = true;
  6316. }
  6317. if(text.indexOf("bro") > -1){
  6318. counted[2] = true;
  6319. }
  6320. saveValue("dio_count", JSON.stringify(counted));
  6321. }
  6322. });
  6323. }
  6324.  
  6325. }
  6326. }
  6327.  
  6328. /*
  6329. function xmas(){
  6330. $('<a href="http://www.greensmilies.com/smilie-album/" target="_blank"><div id="xmas"></div></a>').appendTo('#ui_box');
  6331. $('#xmas').css({
  6332. background: 'url("http://www.greensmilies.com/smile/smiley_emoticons_weihnachtsmann_nordpol.gif") no-repeat',
  6333. height: '51px',
  6334. width: '61px',
  6335. position:'absolute',
  6336. bottom:'10px',
  6337. left:'60px',
  6338. zIndex:'2000'
  6339. });
  6340. $('#xmas').tooltip("HO HO HO, Frohe Weihnachten!");
  6341. }
  6342.  
  6343. function silvester(){
  6344. $('<a href="http://www.greensmilies.com/smilie-album/" target="_blank"><div id="silv">'+
  6345. '<img src="http://www.greensmilies.com/smile/sign2_2.gif">'+
  6346. '<img src="http://www.greensmilies.com/smile/sign2_0.gif">'+
  6347. '<img src="http://www.greensmilies.com/smile/sign2_1.gif">'+
  6348. '<img src="http://www.greensmilies.com/smile/sign2_4.gif">'+
  6349. '</div></a>').appendTo('#ui_box');
  6350. $('#silv').css({
  6351. //background: 'url("http://www.greensmilies.com/smile/buchstaben_0.gif") no-repeat',
  6352. //height: '57px',
  6353. //width: '34px',
  6354. position:'absolute',
  6355. bottom:'10px',
  6356. left:'70px',
  6357. zIndex:'10'
  6358. });
  6359. $('#silv').tooltip("Frohes Neues!");
  6360. }
  6361.  
  6362. function joke(){
  6363. setTimeout(function(){
  6364. if($('#grcgrc').get(0)){
  6365. $('<a href="http://www.greensmilies.com/smilie-album/" target="_blank"><div id="fight"></div></a>').appendTo('#ui_box');
  6366. $('#fight').css({
  6367. background: 'url("http://www.greensmilies.com/smile/smiley_emoticons_hoplit_speer4.gif") no-repeat',
  6368. height: '51px',
  6369. width: '61px',
  6370. position:'absolute',
  6371. bottom:'10px',
  6372. left:'39px',
  6373. zIndex:'2000'
  6374. });
  6375. $('#fight').tooltip("WWW.GREENSMILIES.COM");
  6376. }
  6377. }, 5000);
  6378. }
  6379. */
  6380.  
  6381. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址