DIO-TOOLS

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

当前为 2014-10-05 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name DIO-TOOLS
  3. // @namespace DIO
  4. // @version 2.25
  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 http://de.grepolis.com/game*
  8. // @include http://*.grepolis.com/game*
  9. // @include http://*forum.*.grepolis.com/*.php*
  10. // @include http://diotools.pf-control.de/*
  11. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
  12. // @icon http://s7.directupload.net/images/140128/vqchpigi.gif
  13. // @icon64 http://diotools.pf-control.de/images/icon_dio_64x64.png
  14. // @copyright 2013+, DIONY
  15. // @grant GM_info
  16. // @grant GM_setValue
  17. // @grant GM_getValue
  18. // @grant GM_deleteValue
  19. // @grant GM_xmlhttpRequest
  20. // ==/UserScript==
  21.  
  22. var version = '2.25';
  23.  
  24. //if(unsafeWindow.DM) console.dir(unsafeWindow.DM.status('l10n'));
  25. //console.dir(DM.status('templates'));
  26.  
  27. //http://s7.directupload.net/images/140128/vqchpigi.gif - DIO-Tools-Smiley
  28.  
  29. //http://de44.grepolis.com/cache/js/libs/jquery-1.10.2.min.js
  30.  
  31.  
  32. //console.log(JSON.stringify(DM.getl10n()));
  33.  
  34. /*******************************************************************************************************************************
  35. * Changes
  36. * ----------------------------------------------------------------------------------------------------------------------------
  37. * | ● ...
  38. * | ● ...
  39. * | ● ...
  40. * | ● ...
  41. * ----------------------------------------------------------------------------------------------------------------------------
  42. *******************************************************************************************************************************/
  43.  
  44. /*******************************************************************************************************************************
  45. * Bugs / TODOs
  46. * ----------------------------------------------------------------------------------------------------------------------------
  47. * | ● Aktivitätsbox für Angriffe blendet nicht aus
  48. * | ● Smileys verschwinden manchmal? -> bisher nicht reproduzierbar
  49. * | ● Performanceeinbruch nach dem Switchen des WW-Fensters
  50. * | ● keine Smileys im Grepoforum mit Safari (fehlendes jQuery)
  51. * ----------------------------------------------------------------------------------------------------------------------------
  52. *******************************************************************************************************************************/
  53.  
  54. /*******************************************************************************************************************************
  55. * Global stuff
  56. *******************************************************************************************************************************/
  57. var uw = unsafeWindow || window, $ = uw.jQuery || jQuery, DATA, GM;
  58.  
  59. // GM-API?
  60. GM = (typeof GM_info === 'object') ? true : false;
  61.  
  62. // LOAD DATA
  63. if(GM && (uw.location.pathname === "/game/index")){
  64. var WID = uw.Game.world_id, MID = uw.Game.market_id, AID = uw.Game.alliance_id;
  65. DATA = {
  66. // GLOBAL
  67. options : JSON.parse(GM_getValue("options", "{}")),
  68. user : JSON.parse(GM_getValue("dio_user", "{}")),
  69. count: JSON.parse(GM_getValue("dio_count", "[]")),
  70. notification : GM_getValue('notification', 0),
  71. error: JSON.parse(GM_getValue('error', '{}')),
  72. spellbox : JSON.parse(GM_getValue("spellbox", '{ "top":"23%", "left": "-150%", "show": false }')),
  73. commandbox: JSON.parse(GM_getValue("commandbox" , '{ "top":55, "left": 250 }')),
  74. tradebox : JSON.parse(GM_getValue("tradebox", '{ "top":55, "left": 450 }')),
  75. // WORLD
  76. townTypes : JSON.parse(GM_getValue(WID + "_townTypes", GM_getValue("town_types", "{}"))),
  77. sentUnits : JSON.parse(GM_getValue(WID + "_sentUnits", GM_getValue(WID + "_sentUnitsArray", '{ "attack": {}, "support": {} }'))),
  78. biremes : JSON.parse(GM_getValue(WID + "_biremes", GM_getValue(WID + "_biri_data", "{}"))),
  79. worldWonder : JSON.parse(GM_getValue(WID + "_wonder", '{ "ratio": {}, "storage": {}, "map": {} }')),
  80. // MARKET
  81. worldWonderTypes : JSON.parse(GM_getValue(MID + "_wonderTypes", '{}'))
  82. };
  83. if(!DATA.worldWonder.map) {
  84. DATA.worldWonder.map = {};
  85. }
  86. // Temporary:
  87. if(GM_getValue(WID + "_ww_res")){
  88. DATA.worldWonder.ratio[AID] = parseInt(GM_getValue(WID + "_ratio", -1), 10);
  89. DATA.worldWonder.storage[AID] = JSON.parse(GM_getValue(WID + "_ww_res", "{}"));
  90. GM_deleteValue(WID + "_ratio");
  91. GM_deleteValue(WID + "_ww_res");
  92. }
  93. //console.log(DATA.worldWonder);
  94. GM_deleteValue("movebox");
  95. GM_deleteValue(WID + "_sentUnitsArray");
  96. GM_deleteValue(WID + "_biri_data");
  97. GM_deleteValue("town_types");
  98. GM_deleteValue('DIO-Notification');
  99. }
  100.  
  101. // GM: EXPORT FUNCTIONS
  102. uw.saveValueGM = function(name, val){
  103. setTimeout(function(){
  104. GM_setValue(name, val);
  105. // Reload after saving settings
  106. if(name == "options") {
  107. window.location.reload();
  108. }
  109. }, 0);
  110. };
  111.  
  112. uw.deleteValueGM = function(name){
  113. setTimeout(function(){
  114. GM_deleteValue(name);
  115. },0, name);
  116. };
  117.  
  118. uw.chatUserRequest = function(){
  119. setTimeout(function(){
  120. GM_xmlhttpRequest({
  121. method: "GET",
  122. url: "http://api.relay-chat.de/compteur_js.php?chan="+ (uw.Game.market_id === "de" ? "Grepolis" + uw.Game.market_id.toUpperCase() : "GREPO"),
  123. onload: function(text){
  124. $('.nui_main_menu .chat .indicator').get(0).innerHTML = text.response.split("'")[1];
  125. $('.nui_main_menu .chat .indicator').get(0).style.display = 'block';
  126. },
  127. onerror: function(){
  128. $('.nui_main_menu .chat .indicator').get(0).style.display = 'none';
  129. }
  130. });
  131. }, 0);
  132. };
  133.  
  134. if(typeof exportFunction == 'function'){
  135. // Firefox > 30
  136. uw.DATA = cloneInto(DATA, unsafeWindow);
  137. exportFunction(uw.saveValueGM, unsafeWindow, {defineAs: "saveValueGM"});
  138. exportFunction(uw.deleteValueGM, unsafeWindow, {defineAs: "deleteValueGM"});
  139. exportFunction(uw.chatUserRequest, unsafeWindow, {defineAs: "chatUserRequest"});
  140. } else {
  141. // Firefox < 30, Chrome, Opera, ...
  142. uw.DATA = DATA;
  143. }
  144.  
  145. var time_a, time_b;
  146.  
  147. // APPEND SCRIPT
  148. function appendScript(){
  149. //console.log("GM-API: " + gm_bool);
  150. if(document.getElementsByTagName('body')[0]){
  151. var dioscript = document.createElement('script');
  152. dioscript.type ='text/javascript';
  153. dioscript.id = 'diotools';
  154. time_a = uw.Timestamp.client();
  155. dioscript.textContent = DIO_GAME.toString().replace(/uw\./g, "") + "\n DIO_GAME("+ version +", "+ GM +", "+ time_a +");";
  156. document.body.appendChild(dioscript);
  157. } else {
  158. setTimeout(function(){
  159. appendScript();
  160. }, 500);
  161. }
  162. }
  163.  
  164. if(location.host === "diotools.pf-control.de"){
  165. // PAGE
  166. DIO_PAGE();
  167. } else {
  168. if((location.pathname !== "/game/index") && GM){
  169. // FORUM
  170. DIO_GAME(version);
  171. } else {
  172. // GAME
  173. appendScript();
  174. }
  175. }
  176.  
  177. function DIO_PAGE(){
  178. if(typeof GM_info == 'object') {
  179. setTimeout(function() {
  180. dio_user = JSON.parse(GM_getValue("dio_user", ""));
  181. console.log(dio_user);
  182. uw.dio_version = parseFloat(version);
  183. }, 0);
  184. } else {
  185. dio_user = localStorage.getItem("dio_user") || "";
  186. dio_version = parseFloat(version);
  187. }
  188. }
  189. function DIO_FORUM(){
  190. if($(".editor_textbox_container").get(0)){
  191. loadSmileys();
  192. changeForumEditorLayout();
  193. addSmileyBoxForum();
  194. }
  195. }
  196. function DIO_GAME(version, gm, time_a){
  197. var MutationObserver = uw.MutationObserver || window.MutationObserver,
  198. WID, MID, AID, PID, LID,
  199. dio_sprite = "http://abload.de/img/dio_spritejmqxp.png"; // http://img1.myimg.de/DIOSPRITEe9708.png -> Forbidden!?
  200. if(uw.location.pathname === "/game/index"){
  201. WID = uw.Game.world_id;
  202. MID = uw.Game.market_id;
  203. AID = uw.Game.alliance_id;
  204. PID = uw.Game.player_id;
  205. LID = uw.Game.locale_lang.split("_")[0]; // LID ="es";
  206. // World with Artemis ??
  207. Game.hasArtemis = Game.constants.gods.length == 6;
  208. }
  209. $.prototype.reverseList = [].reverse;
  210. // LOAD DATA for Safari:
  211. if((typeof DATA === 'undefined') && (uw.location.pathname === "/game/index")){
  212. DATA = {
  213. //GLOBAL
  214. options : JSON.parse(localStorage.getItem("options") || "{}"),
  215. user : JSON.parse(localStorage.getItem("dio_user") || "{}"),
  216. count: JSON.parse(localStorage.getItem("dio_count") || "[]"),
  217. notification : localStorage.getItem('notification') || localStorage.getItem('DIO-Notification') || 0,
  218. error: JSON.parse(localStorage.getItem('error') || '{}'),
  219. spellbox : JSON.parse(localStorage.getItem("spellbox") || '{ "top":"23%", "left": "-150%", "show": false }' ),
  220. commandbox: JSON.parse(localStorage.getItem("commandbox") || '{ "top":55, "left": 250 }' ),
  221. tradebox : JSON.parse(localStorage.getItem("tradebox") || '{ "top":55, "left": 450 }' ),
  222. //WORLD
  223. townTypes : JSON.parse(localStorage.getItem(WID + "_townTypes") || localStorage.getItem("town_types") || "{}" ),
  224. sentUnits : JSON.parse(localStorage.getItem(WID + "_sentUnits") || localStorage.getItem(WID + "_sentUnitsArray") || '{ "attack": {}, "support": {} }' ),
  225. biremes : JSON.parse(localStorage.getItem(WID + "_biremes") || localStorage.getItem(WID + "_biri_data") || "{}" ),
  226. worldWonder : JSON.parse(localStorage.getItem(WID + "_wonder") || '{ "ratio": {}, "storage": {}, "map": {} }'),
  227. // MARKET
  228. worldWonderTypes : JSON.parse(localStorage.getItem(MID + "_wonderTypes") || '{}')
  229. };
  230. if(!DATA.worldWonder.map) {
  231. DATA.worldWonder.map = {};
  232. }
  233. // Temporary:
  234. if(GM_getValue(WID + "_ww_res")){
  235. DATA.worldWonder.ratio[AID] = parseInt((localStorage.getItem(WID + "_ratio") || -1), 10);
  236. DATA.worldWonder.storage[AID] = JSON.parse(localStorage.getItem(WID + "_ww_res") || "{}");
  237. localStorage.removeItem(WID + "_ratio");
  238. localStorage.removeItem(WID + "_ww_res");
  239. }
  240. }
  241. function saveValue(name, val){
  242. if(gm){
  243. saveValueGM(name, val);
  244. } else {
  245. localStorage.setItem(name, val);
  246. }
  247. }
  248. function deleteValue(name){
  249. if(gm){
  250. deleteValueGM(name);
  251. } else {
  252. localStorage.removeItem(name);
  253. }
  254. }
  255. /*******************************************************************************************************************************
  256. * Graphic filters
  257. *******************************************************************************************************************************/
  258. if(uw.location.pathname === "/game/index"){
  259. $('<svg width="0%" height="0%">'+
  260. '<filter id="GrayScale">'+
  261. '<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">'+
  262. '</filter>'+
  263. '<filter id="Sepia">'+
  264. '<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">'+
  265. '</filter>'+
  266. '<filter id="Saturation"><feColorMatrix type="saturate" values="0.2"></filter>'+
  267. '<filter id="Saturation1"><feColorMatrix type="saturate" values="1"></filter>'+
  268. '<filter id="Saturation2"><feColorMatrix type="saturate" values="2"></filter>'+
  269. '<filter id="Hue1"><feColorMatrix type="hueRotate" values= "65"></filter>'+
  270. '<filter id="Hue2"><feColorMatrix type="hueRotate" values="150"></filter>'+
  271. '<filter id="Hue3"><feColorMatrix type="hueRotate" values="-65"></filter>'+
  272. '<filter id="Brightness15">'+
  273. '<feComponentTransfer>'+
  274. '<feFuncR type="linear" slope="1.5"/><feFuncG type="linear" slope="1.5"/><feFuncB type="linear" slope="1.5"/>'+
  275. '</feComponentTransfer>'+
  276. '</filter>'+
  277. '<filter id="Brightness12">'+
  278. '<feComponentTransfer>'+
  279. '<feFuncR type="linear" slope="1.2"/><feFuncG type="linear" slope="1.2"/><feFuncB type="linear" slope="1.2"/>'+
  280. '</feComponentTransfer>'+
  281. '</filter>'+
  282. '<filter id="Brightness11">'+
  283. '<feComponentTransfer>'+
  284. '<feFuncR type="linear" slope="1.1"/><feFuncG type="linear" slope="1.1"/><feFuncB type="linear" slope="1.1"/>'+
  285. '</feComponentTransfer>'+
  286. '</filter>'+
  287. '<filter id="Brightness10">'+
  288. '<feComponentTransfer>'+
  289. '<feFuncR type="linear" slope="1.0"/><feFuncG type="linear" slope="1.0"/><feFuncB type="linear" slope="1.0"/>'+
  290. '</feComponentTransfer>'+
  291. '</filter>'+
  292. '</svg>').appendTo('#ui_box');
  293. }
  294. /*******************************************************************************************************************************
  295. * Language versions: german, english, french, russian, polish, spanish
  296. *******************************************************************************************************************************/
  297. var LANG = {
  298. de : {
  299. settings : {
  300. dsc: "DIO-Tools bietet unter anderem einige Anzeigen, eine Smileyauswahlbox,<br>Handelsoptionen und einige Veränderungen des Layouts.",
  301. act: "Funktionen der Toolsammlung aktivieren/deaktivieren:",
  302. prv: "Vorschau einzelner Funktionen:"
  303. },
  304. options : {
  305. bir: [ "Biremenzähler", "Zählt die jeweiligen Biremen einer Stadt und summiert diese. (Anzeige im Minimap-Bullauge links oben)" ],
  306. sml: [ "Smileys", "Erweitert die BBCode-Leiste um eine Smileybox" ],
  307. str: [ "Einheitenstärke", "Fügt mehrere Einheitenstärketabellen in verschiedenen Bereichen hinzu" ],
  308. trd: [ "Handel", "Erweitert das Handelsfenster um einen Prozentualer Handel, einen Rekrutierungshandel und Limitmarker für Stadtfeste" ],
  309. cnt: [ "EO-Zähler", "Zählt die ATT/UT-Anzahl im EO-Fenster (bisher nur bei eigenen Eroberungen)" ],
  310. way: [ "Laufzeit", "Zeigt im ATT/UT-Fenster die Laufzeit bei Verbesserter Truppenbewegung an" ],
  311. wwc: [ "Weltwunder", "Anteilsrechner & Rohstoffzähler + Vor- & Zurück-Buttons bei fertiggestellten WW's (momentan nicht deaktivierbar!)" ],
  312. sim: [ "Simulator", "Anpassung des Simulatorlayouts & permanente Anzeige der Erweiterten Modifikatorbox" ],
  313. spl: [ "Zauberbox", "Komprimierte verschiebbare & magnetische Zauberbox (Positionsspeicherung)" ],
  314. mov: [ "Aktivitätsboxen", "Verbesserte Anzeige der Handels- und Truppenaktivitätsboxen (Positionsspeicherung)" ],
  315. pop: [ "Popup", 'Ändert Gunst-Popup' ],
  316. tsk: [ "Taskleiste", 'Vergrößert die Taskleiste und minimiert das "Tägliche Belohnung"-Fenster beim Start' ],
  317. irc: [ "Chat", "Ersetzt den Allianzchat durch einen IRC-Chat" ],
  318. bbc: [ "DEF-Formular", "Erweitert die BBCode-Leiste um ein automatisches DEF-Formular" ],
  319. com: [ "Einheitenvergleich","Fügt Einheitenvergleichstabellen hinzu" ],
  320. twn: [ "Stadticons", "Fügt Stadttyp-Icons zur Stadtliste hinzu" ],
  321. con: [ "Kontextmenu", 'Vertauscht "Stadt selektieren" und "Stadtübersicht" im Kontextmenu'],
  322. sen: [ "Abgeschickte Einheiten", 'Zeigt im Angriffs-/Unterstützungsfenster abgeschickte Einheiten an'],
  323. tov: [ "Stadtübersicht", 'Ersetzt die neue Stadtansicht mit der alten Fensteransicht'],
  324. scr: [ "Mausrad", 'Man kann mit dem Mausrad die Übersichten wechseln'],
  325. err: [ "Automatische Fehlerberichte senden", "Wenn du diese Option aktivierst, kannst du dabei helfen Fehler zu identifizieren." ],
  326. her: [ "Thrakische Eroberung", "Verkleinerung der Karte der Thrakischen Eroberung." ]
  327. },
  328. labels: {
  329. uni : "Verfügbare Einheiten",
  330. con : "Selektieren",
  331. // Smileys
  332. std: "Standard", gre: "Grepolis", nat: "Natur", ppl: "Leute", oth: "Sonstige",
  333. // Defense form
  334. ttl: "Übersicht: Stadtverteidigung", inf: "Informationen zur Stadt:", dev: "Abweichung",
  335. det: "Detailierte Landeinheiten", prm: "Premiumboni", sil: "Silberstand", mov: "Truppenbewegungen:",
  336. // WW
  337. leg: "WW-Anteil", stg: "Stufe", tot: "Gesamt",
  338. // Simulator
  339. str: "Einheitenstärke", los: "Verluste", mod: "ohne Modifikatoreinfluss",
  340. // Comparison box
  341. dsc: "Einheitenvergleich", hck: "Schlag", prc: "Stich", dst: "Distanz", sea: "See", att: "Angriff", def: "Verteidigung", spd: "Geschwindigkeit",
  342. bty: "Beute (Rohstoffe)", cap: "Transportkapazität", res: "Baukosten (Rohstoffe)", fav: "Gunst", tim: "Bauzeit (s)",
  343. // Trade
  344. rat: "Ressourcenverhältnis eines Einheitentyps", shr: "Anteil an der Lagerkapazität der Zielstadt", per: "Prozentualer Handel",
  345. // Sent units box
  346. lab: "Abgeschickt",
  347. improved_movement: "Verbesserte Truppenbewegung"
  348. },
  349. buttons: {
  350. sav: "Speichern", ins: "Einfügen", res: "Zurücksetzen"
  351. },
  352. },
  353. en : {
  354. settings : {
  355. dsc: "DIO-Tools offers, among other things, some displays, a smiley box,<br>trade options and some changes to the layout.",
  356. act: "Activate/deactivate features of the toolset:",
  357. prv: "Preview of several features:"
  358. },
  359. options : {
  360. bir: [ "Bireme counter", "Counts the biremes of a city and sums these" ],
  361. sml: [ "Smilies", "Extends the bbcode bar by a smiley box" ],
  362. str: [ "Unit strength", "Adds unit strength tables in various areas" ],
  363. trd: [ "Trade", "Extends the trade window by a percentage trade, a recruitment trade and limit markers for city festivals" ],
  364. cnt: [ "Conquests", "Counts the attacks/supports in the conquest window (only own conquests yet)" ],
  365. way: [ "Troop speed", "Displays improved troop speed in the attack/support window" ],
  366. wwc: [ "World wonder", "Share calculation & resources counter + previous & next buttons on finished world wonders (currently not deactivatable!)" ],
  367. sim: [ "Simulator", "Adaptation of the simulator layout & permanent display of the extended modifier box" ],
  368. spl: [ "Spell box", "Compressed movable & magnetic spell box (position memory)" ],
  369. mov: [ "Activity boxes", "Improved display of trade and troop activity boxes (position memory)" ],
  370. pop: [ "Popup", "Changes the favor popup" ],
  371. tsk: [ "Taskbar", "Increases the taskbar and minimizes the daily reward window on startup" ],
  372. irc: [ "Chat", 'Replaced the alliance chat by an irc chat. (FlashPlayer required)' ],
  373. bbc: [ "Defense form", "Extends the bbcode bar by an automatic defense form" ],
  374. com: [ "Unit Comparison", "Adds unit comparison tables" ],
  375. twn: [ "Town icons", "Adds town type icons to the town list" ],
  376. con: [ "Context menu", 'Swaps "Select town" and "City overview" in the context menu'],
  377. sen: [ "Sent units", 'Shows sent units in the attack/support window'],
  378. tov: [ "Town overview", 'Replaces the new town overview with the old window style'],
  379. scr: [ "Mouse wheel", 'You can change the views with the mouse wheel'],
  380. err: [ "Send bug reports automatically", "If you activate this option, you can help identify bugs." ],
  381. her: [ "Thracian Conquest", "Downsizing of the map of the Thracian conquest." ]
  382. },
  383. labels: {
  384. uni : "Available Units",
  385. con : "Select town",
  386. // Smileys
  387. std: "Standard", gre: "Grepolis", nat: "Nature", ppl: "People", oth: "Other",
  388. // Defense form
  389. ttl: "Overview: Town defense", inf: "Town information:", dev: "Deviation",
  390. det: "Detailed land units", prm: "Premium bonuses", sil: "Silver volume", mov: "Troop movements:",
  391. // WW
  392. leg: "WW Share", stg: "Stage", tot: "Total",
  393. // Simulator
  394. str: "Unit strength", los: "Loss", mod: "without modificator influence",
  395. // Comparison box
  396. dsc: "Unit comparison",
  397. hck: "Blunt", prc: "Sharp", dst: "Distance", sea: "Sea",
  398. att: "Offensive", def: "Defensive", spd: "Speed", bty: "Booty (resources)",
  399. cap: "Transport capacity", res: "Costs (resources)", fav: "Favor", tim: "Recruiting time (s)",
  400. // Trade
  401. rat: "Resource ratio of an unit type", shr: "Share of the storage capacity of the target city", per: "Percentage trade",
  402. // Sent units box
  403. lab: "Sent units",
  404. improved_movement: "Improved troop movement"
  405. },
  406. buttons: {
  407. sav: "Save", ins: "Insert", res: "Reset"
  408. },
  409. },
  410. ///////////////////////////////////
  411. // French Translation by eclat49 //
  412. ///////////////////////////////////
  413. fr : {
  414. settings: {
  415. 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.",
  416. act: "Activation/Désactivation des fonctions:",
  417. prv: "Aperçu des fonctions séparées:"
  418. },
  419. options : {
  420. 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)" ],
  421. sml: [ "Smileys", "Rajoutes une boite de smilies à la boite de bbcode" ],
  422. str: [ "Force unitaire", "Ajoutes des tableaux de force unitaire dans les différentes armes" ],
  423. trd: [ "Commerce", "Ajout d'une option par pourcentage, par troupes pour le commerce, ainsi qu'un affichage des limites pour les festivals" ],
  424. 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)" ],
  425. way: [ "Vitesse des troupes ", "Rajoutes le temps de trajet avec le bonus accélération" ],
  426. 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)" ],
  427. sim: [ "Simulateur", "Modification de la présentation du simulateur et affichage permanent des options premium" ],
  428. spl: [ "Boîte de magie", "Boîte de sort cliquable et positionnable" ],
  429. mov: [ "Boîte d'activité", "Présentation améliorée du commerce et des mouvement de troupes (mémoire de position)" ],
  430. pop: [ "Popup", 'Change la popup de faveur' ],
  431. tsk: [ "Barre de tâches ", "La barre de tâches augmente et minimise le fenêtre de bonus journalier" ],
  432. irc: [ "Chat", "Remplace le chat de l'alliance à travers un chat IRC. (FlashPlayer requis)" ],
  433. bbc: [ "Formulaire de défense", "Ajout d'un bouton dans la barre BBCode pour un formulaire de défense automatique" ],
  434. com: [ "Comparaison des unités","Ajoutes des tableaux de comparaison des unités" ],
  435. twn: [ "Icônes des villes", "Ajoutes desicônes de type de ville à la liste de ville" ],
  436. con: [ "Menu contextuel", 'Swaps "Sélectionner ville" et "Aperçu de la ville" dans le menu contextuel'],
  437. sen: [ "Unités envoyées", 'Affiche unités envoyées dans la fenêtre attaque/support'],
  438. tov: [ "Aperçu de ville", "Remplace la nouvelle aperçu de la ville avec l'ancien style de fenêtre"],
  439. scr: [ "Molette de la souris", 'Avec la molette de la souris vous pouvez changer les vues'],
  440. err: [ "Envoyer des rapports de bogues automatiquement", "Si vous activez cette option, vous pouvez aider à identifier les bugs." ]
  441. },
  442. labels: {
  443. uni : "Unités disponibles",
  444. con : "Sélectionner",
  445. // Smileys
  446. std: "Standard", gre: "Grepolis", nat: "Nature", ppl: "Gens", oth: "Autres",
  447. // Defense form
  448. ttl: "Aperçu: Défense de ville", inf: "Renseignements sur la ville:", dev: "Différence",
  449. det: "Unités terrestres détaillées", prm: "Bonus premium", sil: "Remplissage de la grotte", mov: "Mouvements de troupes:",
  450. // WW
  451. leg: "Participation", stg: "Niveau", tot: "Total",
  452. // Simulator
  453. str: "Force unitaire", los: "Pertes", mod: "sans influence de modificateur",
  454. // Comparison box
  455. dsc: "Comparaison des unités", hck: "Contond.", prc: "Blanche", dst: "Jet", sea: "Navale", att: "Attaque", def: "Défense", spd: "Vitesse",
  456. bty: "Butin", cap: "Capacité de transport", res: "Coût de construction", fav: "Faveur", tim: "Temps de construction (s)",
  457. // Trade
  458. rat: "Ratio des ressources d'un type d'unité", shr: "Part de la capacité de stockage de la ville cible", per: "Commerce de pourcentage",
  459. // Sent units box
  460. lab: "Envoyée",
  461. improved_movement: "Mouvement des troupes amélioré"
  462. },
  463. buttons: {
  464. sav: "Sauver", ins: "Insertion", res: "Remettre"
  465. },
  466. },
  467. ///////////////////////////////////
  468. // Russian Translation by MrBobr //
  469. ///////////////////////////////////
  470. ru : {
  471. settings : {
  472. dsc: "DIO-Tools изменяет некоторые окна, добавляет новые смайлы, отчёты,<br>улучшеные варианты торговли и другие функции.",
  473. act: "Включение/выключение функций:",
  474. prv: "Примеры внесённых изменений:"
  475. },
  476. options : {
  477. bir: [ "Счётчик бирем", "Показывает число бирем во всех городах" ],
  478. sml: [ "Смайлы", "Добавляет кнопку для вставки смайлов в сообщения" ],
  479. str: [ "Сила отряда", "Добавляет таблицу общей силы отряда в некоторых окнах" ],
  480. trd: [ "Торговля", "Добавляет маркеры и отправку недостающих ресурсов, необходимых для фестиваля. Инструменты для долевой торговли" ],
  481. cnt: [ "Завоевания", "Отображение общего числа атак/подкреплений в окне завоевания города (only own conquests yet)" ],
  482. way: [ "30% ускорение", "Отображает примерное время движения отряда с 30% бонусом" ],
  483. wwc: [ "Чудо света", "Share calculation & resources counter + previous & next buttons on finished world wonders (currently not deactivatable!)" ],
  484. sim: [ "Симулятор", "Изменение интерфейса симулятора, добавление новых функций" ],
  485. spl: [ "Заклинания", "Изменяет положение окна заклинаний" ],
  486. mov: [ "Перемещения", "Показывает окна пересылки ресурсов и перемещения войск" ],
  487. pop: [ "Благосклонность", "Отображение окна с уровнем благосклонности богов" ],
  488. tsk: [ "Таскбар", "Увеличение ширины таскбара и сворачивание окна ежедневной награды при входе в игру" ],
  489. irc: [ "Чат", 'Замена чата игры на irc-чат' ],
  490. bbc: [ "Форма обороны", "Добавляет кнопку для вставки в сообщение отчёта о городе" ], // Beschreibung passt nicht ganz
  491. com: [ "Сравнение юнитов", "Добавляет окно сравнения юнитов" ],
  492. twn: [ "Типы городов", "Добавляет иконку к городу в списке" ],
  493. //con: [ "Context menu", 'Swaps "Select town" and "City overview" in the context menu'],
  494. //sen: [ "Sent units", 'Shows sent units in the attack/support window'],
  495. tov: [ "Обзор Город", 'Заменяет новый обзор города с старом стиле окна'], // ?
  496. scr: [ "Колесо мыши", 'С помощью колеса мыши вы можете изменить взгляды'], // ?
  497. err: [ "Отправить сообщения об ошибках автоматически", "Если вы включите эту опцию, вы можете помочь идентифицировать ошибки"]
  498. },
  499. labels: {
  500. uni : "Доступные войска",
  501. con : "выбирать",
  502. // Smileys
  503. std: "", gre: "", nat: "", ppl: "", oth: "",
  504. // Defense form
  505. ttl: "Обзор: Отчёт о городе", inf: "Информация о войсках и постройках:", dev: "Отклонение",
  506. det: "Детальный отчёт", prm: "Премиум-бонусы", sil: "Серебро в пещере", mov: "Перемещения",
  507. // WW
  508. leg: "", stg: "", tot: "",
  509. // Simulator
  510. str: "Сила войск", los: "Потери", mod: "без учёта заклинаний, бонусов, исследований",
  511. // Comparison box
  512. dsc: "Сравнение юнитов", hck: "Ударное", prc: "Колющее", dst: "Дальнего боя", sea: "Морские", att: "Атака", def: "Защита", spd: "Скорость",
  513. bty: "Добыча (ресурсы)", cap: "Вместимость транспортов", res: "Стоимость (ресурсы)", fav: "Благосклонность", tim: "Время найма (с)",
  514. // Trade
  515. rat: "", shr: "", per: "",
  516. // Sent units box
  517. lab: "Отправлено",
  518. improved_movement: "Улучшенная перемещение войск"
  519. },
  520. buttons: {
  521. sav: "Сохраниить", ins: "Вставка", res: "Сброс"
  522. },
  523. },
  524. ////////////////////////////////
  525. // Polish Translation by anpu //
  526. ////////////////////////////////
  527. pl : {
  528. settings: {
  529. dsc: "DIO-Tools oferuje (między innymi) poprawione widoki, nowe uśmieszki,<br>opcje handlu i zmiany w wyglądzie.",
  530. act: "Włącz/wyłącz funkcje skryptu:",
  531. prv: "podgląd poszczególnych opcji:"
  532. },
  533. options : {
  534. bir: [ "Licznik birem", "Zlicza i sumuje biremy z miast" ],
  535. sml: [ "Emotki", "Dodaje dodatkowe (zielone) emotikonki" ],
  536. str: [ "Siła jednostek", "dodaje tabelki z siłą jednostek w różnych miejscach gry" ],
  537. trd: [ "Handel", "Rozszerza okno handlu o handel procentowy, proporcje surowców wg jednostek, dodaje znaczniki dla festynów" ],
  538. cnt: [ "Podboje", "Zlicza wsparcia/ataki w oknie podboju (tylko własne podboje)" ],
  539. way: [ "Prędkość wojsk", "Wyświetla dodatkowo czas jednostek dla bonusu przyspieszone ruchy wojsk" ],
  540. 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)" ],
  541. sim: [ "Symulator", "Dostosowanie wyglądu symulatora oraz dodanie szybkich pól wyboru" ],
  542. spl: [ "Ramka czarów", "Kompaktowa pływająca ramka z czarami (można umieścić w dowolnym miejscu ekranu. Zapamiętuje położenie.)" ],
  543. 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.)" ],
  544. pop: [ "Łaski", "Zmienia wygląd ramki informacyjnej o ilości produkowanych łask" ],
  545. tsk: [ "Pasek skrótów", "Powiększa pasek skrótów i minimalizuje okienko z bonusem dziennym" ],
  546. irc: [ "Czat", 'Zastępuje standardowy Chat chatem IRC (wymagany FlashPlayer)' ],
  547. bbc: [ "Raportów obronnych","Rozszerza pasek skrótów BBcode o generator raportów obronnych" ],
  548. com: [ "Porównianie", "Dodaje tabelki z porównaniem jednostek" ],
  549. twn: [ "Oznaczanie miast", "Możliwość oznaczania ikonami miast na liście" ],
  550. con: [ "menu kontekstowe", 'Zamiemia miejcami przycisk "wybierz miasto" z przyciskiem "podgląd miasta" po kliknięciu miasta na mapie'],
  551. sen: [ "Wysłane jednostki", 'Pokaż wysłane jednostki w oknie wysyłania ataków/wsparć'],
  552. tov: [ "Podgląd miasta", 'Zastępuje nowy podgląd miasta starym'],
  553. scr: [ "Zoom", 'Możesz zmienić poziom przybliżenia mapy kółkiem myszy'],
  554. err: [ "Automatycznie wysyłać raporty o błędach", "Jeśli włączysz tę opcję, możesz pomóc zidentyfikować błędy"]
  555. },
  556. labels: {
  557. uni : "Dostępne jednostki",
  558. con : "Wybierz miasto",
  559. // Smileys
  560. std: "Standard" /* "Standardowe" */, gre: "Grepolis", nat: "Przyroda", ppl: "Ludzie", oth: "Inne",
  561. // Defense form
  562. ttl: "Podgląd: Obrona miasta", inf: "Informacje o mieście:", dev: "Ochyłka",
  563. det: "jednostki lądowe", prm: "opcje Premium", sil: "Ilość srebra", mov: "Ruchy wojsk",
  564. // WW
  565. leg: "Udział w Cudzie", stg: "Poziom", tot: "Łącznie",
  566. // Simulator
  567. str: "Siła jednostek", los: "Straty", mod: "bez modyfikatorów",
  568. // Comparison box
  569. dsc: "Porównianie jednostek", hck: "Obuchowa", prc: "Tnąca", dst: "Dystansowa", sea: "Morskie", att: "Offensywne", def: "Defensywne", spd: "Prędkość",
  570. bty: "Łup (surowce)", cap: "Pojemność transportu", res: "Koszta (surowce)", fav: "Łaski", tim: "Czas rekrutacji (s)",
  571. // Trade
  572. rat: "Stosunek surowców dla wybranej jednostki", shr: "procent zapełnienia magazynu w docelowym mieście", per: "Handel procentowy",
  573. // Sent units box
  574. lab: "Wysłane jednostki",
  575. improved_movement: "Przyspieszone ruchy wojsk‎"
  576. },
  577. buttons: {
  578. sav: "Zapisz", ins: "Wstaw", res: "Anuluj"
  579. },
  580. },
  581. //////////////////////////////////////////////
  582. // Spanish Translation by Juana de Castilla //
  583. //////////////////////////////////////////////
  584. es : {
  585. settings : {
  586. dsc: "DIO-Tools ofrece, entre otras cosas, varias pantallas, ventana de <br>emoticones, opciones de comercio y algunos cambios en el diseño.",
  587. act: "Activar/desactivar características de las herramientas:",
  588. prv: "Vista previa de varias características:"
  589. },
  590. options : {
  591. bir: [ "Contador de birremes", "Cuenta los birremes de una ciudad y los suma" ],
  592. sml: [ "Emoticones", "Código BB para emoticones" ],
  593. str: [ "Fortaleza de la Unidad", "Añade tabla de fortalezas de cada unidad en varias zonas" ],
  594. trd: [ "Comercio", "Añade en la pestaña de comercio un porcentaje de comercio y reclutamiento y limitadores de Mercado por cada ciudad" ],
  595. cnt: [ "Conquistas", "contador de ataques y refuerzos en la pestaña de conquista" ],
  596. way: [ "Velocidad de tropas", "Muestra movimiento de tropas mejorado en la ventana de ataque/refuerzo" ],
  597. wwc: [ "Maravillas", "Calcula participación & contador de recursos + antes y después teclas de maravillas terminadas (no desactibable ahora!)" ],
  598. sim: [ "Simulador", "Adaptación de la ventana del simulador incluyendo recuadro de modificadores" ],
  599. spl: [ "Ventana de hechizos", "Ventana deslizante y comprimida de los hechizos (memoria posicional)"],
  600. mov: [ "Ventana de actividad", "Mejora las ventanas de comercio y movimiento de tropas (memoria posicional)" ],
  601. pop: [ "Popup", "Cambia el popup de favores" ],
  602. tsk: [ "Barra de tareas", "aumenta la barra de tareas y minimice la recompensa al aparecer" ],
  603. irc: [ "Chat", 'Sustituye el chat de la alianza con un irc chat. (require FlashPlayer)' ],
  604. bbc: [ "Formulario de defensa", "Añade en la barra de códigos bb un formulario de defensa" ],
  605. com: [ "Comparación", "añade ventana de comparación de unidades" ],
  606. twn: [ "Iconos de la ciudad", "Añade iconos de tipo de ciudad en el listado de ciudades" ],
  607. con: [ "menú contextual", 'Cambia "Elegir ciudad" y "vista de la ciudad" en el menú contextual '],
  608. sen: [ "Unidades enviadas", 'Muestra las unidades enviadas en la ventana de ataque/refuerzos'],
  609. tov: [ "Información de la ciudad", 'sustituye la vista nueva de ciudad por la ventana antigua'],
  610. scr: [ "Rueda raton", 'Puede cambiar las vistas con la rueda del raton'],
  611. err: [ "Enviar informes de errores automáticamente", "Si se activa esta opción, puede ayudar a identificar errores." ]
  612. },
  613. labels: {
  614. uni : "Unidades disponibles",
  615. con : "Escoger ciudad",
  616. // Smileys
  617. std: "Standard", gre: "Grepolis", nat: "Natura", ppl: "Gente", oth: "Otros",
  618. // Defense form
  619. ttl: "Vista general: Defensa de la ciudad", inf: "Información de la ciudad:", dev: "Desviación",
  620. det: "Unidades de tierra detalladas", prm: "Bonos Premium", sil: "Volumen de plata", mov: "Movimientos de tropas:",
  621. // WW
  622. leg: "WW cuota", stg: "Nivel", tot: "Total",
  623. // Simulator
  624. str: "Fortaleza de la Unidad", los: "Perdida", mod: "sin influencia del modificador",
  625. // Comparison box
  626. dsc: "Comparación de Unidades",
  627. hck: "Contundente", prc: "Punzante", dst: "Distancia", sea: "Mar",
  628. att: "Ataque", def: "Defensa", spd: "Velocidad", bty: "Botín (recursos)",
  629. cap: "Capacidad de transporte", res: "Costes (recursos)", fav: "Favor", tim: "Tiempo de reclutamiento (s)",
  630. // Trade
  631. 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",
  632. // Sent units box
  633. lab: "Unidades enviadas",
  634. improved_movement: "Movimiento de tropas mejorados"
  635. },
  636. buttons: {
  637. sav: "Guardar", ins: "Insertar", res: "Reinicio"
  638. }
  639. },
  640. ar : {}
  641. };
  642. LANG.ar = LANG.es;
  643. // Create JSON
  644. // console.log(JSON.stringify(LANG.en));
  645. /*******************************************************************************************************************************
  646. * Settings
  647. *******************************************************************************************************************************/
  648. // (De)activation of the features
  649. var options_def = {
  650. bir : true, // Biremes counter
  651. sml : true, // Smileys
  652. str : true, // Unit strength
  653. trd : true, // Trade options
  654. way : true, // Troop speed
  655. cnt : true, // Attack/support counter
  656. sim : true, // Simulator
  657. spl : true, // Spell box
  658. mov : false,// Activity boxes
  659. tsk : true, // Task bar
  660. irc : true, // IRC-Chat
  661. pop : true, // Favor popup
  662. wwc : true, // World wonder
  663. bbc : true, // BBCode bar
  664. com : true, // Unit comparison
  665. twn : true, // Town icons
  666. con : true, // Context menu
  667. sen : true, // Sent units
  668. tov : false,// Town overview
  669. scr : true, // Mausrad,
  670. err : false,
  671. her : true // Thrakische Eroberung
  672. };
  673. if(uw.location.pathname === "/game/index"){
  674. for(var opt in options_def){
  675. if(options_def.hasOwnProperty(opt)){
  676. if(DATA.options[opt] == undefined) {
  677. DATA.options[opt] = options_def[opt];
  678. }
  679. }
  680. }
  681. }
  682. // Add DIO-Tools to grepo settings
  683. function settings() {
  684. var wid = $(".settings-menu").get(0).parentNode.id;
  685. if(!$("#dio_tools").get(0)){
  686. $(".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>');
  687. }
  688. $(".settings-link").click(function () {
  689. $('.section').each(function(){
  690. $(this).get(0).style.display = "block";
  691. });
  692. $('.settings-container').removeClass("dio_overflow");
  693. $('#dio_bg_medusa').css({ display: "none" });
  694. if($('#dio_settings').get(0)) { $('#dio_settings').get(0).style.display = "none"; }
  695. });
  696. $("#dio_tools").click(function () {
  697. if($('.email').get(0)) { $('.settings-container').removeClass("email"); }
  698. $('.settings-container').addClass("dio_overflow");
  699. $('#dio_bg_medusa').css({ display: "block" });
  700. if(!$('#dio_settings').get(0)){
  701. $('.settings-container').append(
  702. '<div id="dio_settings" class="player_settings section"><div id="dio_bg_medusa"></div>'+
  703. '<div class="game_header bold"><a href="#" target="_blank" style="color:white">DIO-Tools (v'+ version +')</a></div>'+
  704. '<p>' + getText("settings", "dsc") + '</p>'+
  705. '<p class="bold"><u>'+ getText("settings", "act") + '</u></p>'+
  706. '<table width="100%" style=" font-size: 0.8em;"><tr><td width="24%">'+
  707. '<div id="bir" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "bir")[0] +'</div></div><br><br>'+
  708. '<div id="sml" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "sml")[0] +'</div></div><br><br>'+
  709. '<div id="str" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "str")[0] +'</div></div><br><br>'+
  710. '<div id="bbc" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "bbc")[0] +'</div></div><br><br>'+
  711. '<div id="con" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "con")[0] +'</div></div><br><br>'+
  712. '</td><td width="21%">'+
  713. '<div id="trd" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "trd")[0] +'</div></div><br><br>'+
  714. '<div id="cnt" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "cnt")[0] +'</div></div><br><br>'+
  715. '<div id="way" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "way")[0] +'</div></div><br><br>'+
  716. '<div id="wwc" class="checkbox_new disabled"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "wwc")[0] +'</div></div><br><br>'+
  717. '<div id="sen" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "sen")[0] +'</div></div><br><br>'+
  718. '</td><td width="20%">'+
  719. '<div id="sim" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "sim")[0] +'</div></div><br><br>'+
  720. '<div id="spl" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "spl")[0] +'</div></div><br><br>'+
  721. '<div id="tsk" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "tsk")[0] +'</div></div><br><br>'+
  722. '<div id="twn" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "twn")[0] +'</div></div><br><br>'+
  723. '<div id="tov" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "tov")[0] +'</div></div><br><br>'+
  724. '</td><td>'+
  725. '<div id="com" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "com")[0] +'</div></div><br><br>'+
  726. '<div id="mov" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "mov")[0] +'</div></div><br><br>'+
  727. '<div id="pop" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "pop")[0] +'</div></div><br><br>'+
  728. '<div id="irc" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "irc")[0] +'</div></div><br><br>'+
  729. '<div id="scr" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "scr")[0] +'</div></div><br><br>'+
  730. '</td></tr><tr><td colspan="4">'+
  731. '<div id="err" class="checkbox_new" style="float:left"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "err")[0] +'</div></div>'+
  732. '<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>'+
  733. '</td></tr>'+
  734. '</table>'+
  735. '<div><a class="button" id="dio_save" href="#">'+
  736. '<span class="left"><span class="right"><span class="middle"><small>' + getText("buttons", "sav") + '</small></span></span></span><span></span>'+
  737. '</a></div>'+
  738. '<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">'+
  739. '<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>'+
  740. //'<p class="bold"><u>'+ getText("settings", "prv") + '</u></p>'+
  741. '<br /><table><tr>'+
  742. '<td><img id="bi_img" src="http://i.imgur.com/94m7Gg8.png"></td>'+
  743. '<td><img id="sm_img" src="http://i.imgur.com/Y3BsENb.png"></td>'+
  744. '<td><img id="un_img" src="http://i.imgur.com/LXkSxsS.png"></td>'+
  745. '</tr></table></div></div>');
  746. $('.checkbox_new .cbx_caption').css({
  747. whiteSpace: 'nowrap',
  748. marginRight: '10px'
  749. });
  750. // Thrakische Eroberung
  751. if(!$('#happening_large_icon.hercules2014').get(0)){
  752. $('#her').css({ display: "none" });
  753. }
  754. $("#bi_img").tooltip(getText("options", "bir")[0]); $("#sm_img").tooltip(getText("options", "sml")[0]); $("#un_img").tooltip(getText("options", "str")[0]);
  755. $("#bir").tooltip(getText("options", "bir")[1]); $("#sml").tooltip(getText("options", "sml")[1] + "<br><br><img src='http://666kb.com/i/ckajscggscw4s2u60.gif'>");
  756. $("#str").tooltip(getText("options", "str")[1]); $("#bbc").tooltip(getText("options", "bbc")[1]);
  757. $("#con").tooltip(getText("options", "con")[1]);
  758. $("#trd").tooltip(getText("options", "trd")[1]); $("#cnt").tooltip(getText("options", "cnt")[1]); $("#way").tooltip(getText("options", "way")[1]);
  759. $("#wwc").tooltip(getText("options", "wwc")[1]); $("#sen").tooltip(getText("options", "sen")[1]);
  760. $("#sim").tooltip(getText("options", "sim")[1]); $("#spl").tooltip(getText("options", "spl")[1]); $("#mov").tooltip(getText("options", "mov")[1]);
  761. $("#com").tooltip(getText("options", "com")[1]); $("#tov").tooltip(getText("options", "tov")[1]);
  762. $("#pop").tooltip(getText("options", "pop")[1]); $("#tsk").tooltip(getText("options", "tsk")[1]); $("#irc").tooltip(getText("options", "irc")[1]);
  763. $("#twn").tooltip(getText("options", "twn")[1]); $("#scr").tooltip(getText("options", "scr")[1]);
  764. $("#err").tooltip(getText("options", "err")[1]); $("#her").tooltip(getText("options", "her")[1]);
  765. if(!uw.Layout.wnd.TYPE_TOWNINDEX){
  766. $('#tov').addClass("disabled");
  767. $('#tov .cbx_caption').get(0).style.color = "red";
  768. $("#tov").tooltip('<span style="color:red">This feature was unfortunately prevented by the Grepolis developers on purpose. They call it "code cleanup". Sorry...</span>');
  769. }
  770. $("#dio_settings .checkbox_new").click(function () {
  771. $(this).toggleClass("checked");
  772. });
  773. for(var e in DATA.options) {
  774. if(DATA.options.hasOwnProperty(e)){
  775. if (DATA.options[e] == true) {
  776. $("#" + e).addClass("checked");
  777. }
  778. }
  779. }
  780. $('#dio_save').click(function(){
  781. $('#dio_settings .checkbox_new').each(function(){
  782. var act = false;
  783. if ($("#" + this.id).hasClass("checked")) {
  784. act = true;
  785. }
  786. DATA.options[this.id] = act;
  787. });
  788. saveValue("options", JSON.stringify(DATA.options));
  789. });
  790. }
  791. $('.section').each(function(){
  792. $(this).get(0).style.display = "none";
  793. });
  794. $('#dio_settings').get(0).style.display = "block";
  795. });
  796. }
  797. function addSettingsButton(){
  798. $('<div class="btn_settings circle_button dio_settings"><div class="dio_icon js-caption"></div></div>').appendTo(".gods_area");
  799. $('.dio_settings').css({
  800. top: '95px',
  801. right: '103px',
  802. zIndex: '10'
  803. });
  804. $('.dio_settings .dio_icon').css({
  805. margin: '7px 0px 0px 4px', width: '24px', height: '24px',
  806. background: 'url(http://666kb.com/i/cifvfsu3e2sdiipn0.gif) no-repeat 0px 0px',
  807. backgroundSize: "100%"
  808. });
  809. $('.dio_settings').on('mouseup', function(){
  810. $('.dio_icon').get(0).style.marginTop = "7px";
  811. });
  812. $('.dio_settings').on('mousedown', function(){
  813. $('.dio_icon').get(0).style.marginTop = "8px";
  814. });
  815. $('.dio_settings').tooltip("DIO-Tools: " + DM.getl10n("layout", "config_buttons").settings);
  816. $('.dio_settings').click(function(){
  817. clickDioSettings();
  818. });
  819. }
  820. var diosettings = false;
  821. function clickDioSettings(){
  822. if(!uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_PLAYER_SETTINGS)){
  823. diosettings = true;
  824. }
  825. uw.Layout.wnd.Create(uw.GPWindowMgr.TYPE_PLAYER_SETTINGS,'Settings');
  826. }
  827. // Forum: Choose language
  828. if(!(uw.location.pathname === "/game/index")){
  829. LID = uw.location.host.split(".")[1];
  830. }
  831. // Translation GET
  832. function getText(category, name){
  833. var txt = "???";
  834. if(LANG[LID]){
  835. if(LANG[LID][category]){
  836. if(LANG[LID][category][name]){
  837. txt = LANG[LID][category][name];
  838. } else { if(LANG.en[category]){ if(LANG.en[category][name]){
  839. txt = LANG.en[category][name];
  840. }}}
  841. } else {
  842. if(LANG.en[category]){ if(LANG.en[category][name]){
  843. txt = LANG.en[category][name];
  844. }}
  845. }
  846. } else {
  847. if(LANG.en[category]){ if(LANG.en[category][name]){
  848. txt = LANG.en[category][name];
  849. }}
  850. }
  851. return txt;
  852. }
  853. var exc = false, sum = 0, ch = ["FBADAF", "IGCCJB"], alpha = 'ABCDEFGHIJ';
  854. function a(){
  855. var pA = PID.toString(), pB = "";
  856. for(var c in pA){ if(pA.hasOwnProperty(c)){ pB += alpha[pA[parseInt(c, 10)]];}}
  857. sum = 0;
  858. for(var b in ch){
  859. if(ch.hasOwnProperty(b)){
  860. if(!(pB === ch[b])){exc = true;} else {exc = false; return;}
  861. for(var s in ch[b]){if(ch[b].hasOwnProperty(s)){sum += alpha.indexOf(ch[b][s]); }}
  862. }
  863. }
  864. }
  865. var autoTownTypes, manuTownTypes, population, sentUnitsArray, biriArray, spellbox, commandbox, tradebox, wonder, wonderTypes;
  866. function setStyle(){
  867. // Settings
  868. $('<style type="text/css">'+
  869. '#dio_bg_medusa { background:url('+ dio_sprite +') -160px -43px no-repeat; height: 510px; width: 260px; right: -10px; z-index: -1; position: absolute;} '+
  870. '.dio_overflow { overflow: hidden; } '+
  871. '#dio_icon { width:15px; vertical-align:middle; margin-top:-2px; } '+
  872. '#quackicon { width:15px !important; vertical-align:middle !important; margin-top:-2px; height:12px !important; } '+
  873. '</style>').appendTo('head');
  874. // Tutorial-Quest Container
  875. $('<style type="text/css"> #tutorial_quest_container { top: 130px } </style>').appendTo('head');
  876. // Ranking
  877. $('<style type="text/css"> .wonder_ranking { display: none; } </style>').appendTo('head');
  878. // Velerios
  879. $('<style id="dio_velerios" type="text/css"> #ph_trader_image { background-image: url(http://s14.directupload.net/images/140826/mh8k8nyw.jpg); } </style>').appendTo('head');
  880. // http://s7.directupload.net/images/140826/bgqlsdrf.jpg
  881. // Specific player wishes
  882. if(PID == 1212083){
  883. $('<style id="dio_whishes" type="text/css"> #world_end_info { display: none; } </style>').appendTo('head');
  884. }
  885. //Thracian Event Map
  886. if(DATA.options.her){
  887. $('<style id="dio_hercules" type="text/css"> .hercules_map .stages { -webkit-transform: scale(0.5); transform: scale(0.5); margin-left: -33%; } '+
  888. '.hercules2014_map .dragdrop, .hercules2014_map .hercules_map { width: 900px !important; height: 640px !important; } '+
  889. '.hercules_map { background-size: 100% !important; } '+
  890. '</style>').appendTo('head');
  891. }
  892. }
  893. if(uw.location.pathname === "/game/index"){
  894. setStyle();
  895. }
  896. function loadFeatures(){
  897. if(typeof(ITowns) !== "undefined"){
  898. autoTownTypes = {}; manuTownTypes = DATA.townTypes; population = {};
  899. sentUnitsArray = DATA.sentUnits; biriArray = DATA.biremes;
  900. spellbox = DATA.spellbox; commandbox = DATA.commandbox; tradebox = DATA.tradebox;
  901. wonder = DATA.worldWonder; wonderTypes = DATA.worldWonderTypes;
  902. var DIO_USER = { 'name': uw.Game.player_name, 'market': MID };
  903. saveValue("dio_user", JSON.stringify(DIO_USER));
  904. $.Observer(uw.GameEvents.game.load).subscribe('DIO_START', function(e,data){
  905. // check if city overview window exists
  906. if(!uw.Layout.wnd.TYPE_TOWNINDEX){
  907. DATA.options.tov = false;
  908. }
  909. // replace start city overview with the window style
  910. if(DATA.options.tov){
  911. if($('#ui_box').hasClass("city-overview-enabled") && uw.Layout.wnd.TYPE_TOWNINDEX) {
  912. $.Observer(uw.GameEvents.ui.bull_eye.radiobutton.island_view.click).publish({});
  913. uw.GPWindowMgr.Create(uw.Layout.wnd.TYPE_TOWNINDEX, uw.DM.getl10n('town_index').window_title +" - "+ uw.ITowns.getTown(uw.Game.townId).name);
  914. }
  915. }
  916. minimizeDailyReward();
  917. a();
  918. // English => default language
  919. if(!LANG[LID]){ LID = "en"; }
  920. if((ch.length == 2) && exc && (sum == 42)){
  921. addFunctionToITowns();
  922. if(DATA.options.tsk) {scaleTaskbar(); hideNavElements();}
  923. if(DATA.options.com) {addComparisonButton();}
  924. addSettingsButton();
  925. addAvailableUnitsBox();
  926. addAvailableUnitsButton();
  927. //addStatsButton();
  928. fixUnitValues();
  929. if(DATA.options.bir) {initBiri();}
  930. getAllUnits();
  931. setInterval(function(){
  932. getAllUnits();
  933. },1800000);
  934. if(DATA.options.pop) {unbindFavorPopup();}
  935. if(DATA.options.spl) {catchSpellBox(); initSpellBox();}
  936. imageSelectionProtection();
  937. if(DATA.options.con) {changeContextMenu();}
  938. /*
  939. $.Observer(uw.GameEvents.menu.click).subscribe('DIO_MENU', function(e,data){
  940. //console.log(data.option_id);
  941. });
  942. $.Observer(uw.GameEvents.attack.incoming).subscribe('DIO_ATTACK', function(e,data){
  943. //console.log(data.count);
  944. });
  945. $.Observer(uw.GameEvents.town.units.change).subscribe('DIO_UNITCHANGE', function(e,data){
  946. //console.log(data.count);
  947. });
  948. */
  949. //Notification
  950. uw.NotificationType.DIO_TOOLS = "diotools";
  951. $('<style type="text/css"> #notification_area .diotools .icon { background: url(http://666kb.com/i/cifvfsu3e2sdiipn0.gif) 4px 7px no-repeat !important;} </style>').appendTo('head');
  952. var notif = DATA.notification;
  953. if(notif <= 7){
  954. //newFeatureNotification(1, 'Swap context menu buttons ("Select town" and "City overview")');
  955. //newFeatureNotification(2, 'Town overview (old window mode)');
  956. //newFeatureNotification(3, 'Mouse wheel: You can change the views with the mouse wheel');
  957. //newFeatureNotification(4, 'Town icons on the strategic map');
  958. //newFeatureNotification(5, 'Percentual unit population in the town list');
  959. //newFeatureNotification(6, 'New world wonder ranking');
  960. newFeatureNotification(7, 'World wonder icons on the strategic map');
  961. $('.diotools .icon').each(function(){
  962. $(this).click(function(){
  963. clickDioSettings();
  964. $(this).parent().find(".close").click();
  965. });
  966. });
  967. $('.diotools').css({
  968. cursor: "pointer"
  969. });
  970. saveValue('notification', 8);
  971. }
  972. if(DATA.options.mov){showActivityBoxes();}
  973. if(DATA.options.str){addStrengthMenu(); setStrengthMenu();}
  974. if(DATA.options.twn){setTownList(); addTownIcon(); setTownIconsOnMap();}
  975. if(DATA.options.com){addComparisonBox();}
  976. if(DATA.options.sml){loadSmileys();}
  977. if(DATA.options.irc){initChatUser();}
  978. if(DATA.options.tov){setCityWindowButton();}
  979. if(DATA.options.scr){scrollViews();}
  980. if(DATA.options.sen){getSentUnits();}
  981. setTimeout(function(){
  982. counter(uw.Timestamp.server());
  983. setInterval(function(){
  984. counter(uw.Timestamp.server());
  985. }, 21600000);
  986. }, 60000);
  987. // AJAX-EVENTS
  988. ajaxObserver();
  989. // Execute once to get the world wonder types and coordinates
  990. setTimeout(function(){
  991. if(!wonderTypes.great_pyramid_of_giza){
  992. getWorldWonderTypes();
  993. }
  994. if(wonderTypes.great_pyramid_of_giza){
  995. setTimeout(function(){
  996. if(!wonder.map.mausoleum_of_halicarnassus){
  997. getWorldWonders();
  998. } else {
  999. setWonderIconsOnMap();
  1000. }
  1001. }, 2000);
  1002. }
  1003. }, 3000);
  1004. // Execute once to get alliance ratio
  1005. if (wonder.ratio[AID] == -1 || !$.isNumeric(wonder.ratio[AID])){
  1006. setTimeout(function(){
  1007. getPointRatioFromAllianceProfile();
  1008. }, 5000);
  1009. }
  1010. }
  1011. time_b = uw.Timestamp.client();
  1012. //console.log("Gebrauchte Zeit:" + (time_b - time_a));
  1013. });
  1014. } else {
  1015. setTimeout(function(){
  1016. loadFeatures();
  1017. }, 100);
  1018. }
  1019. }
  1020. if(uw.location.pathname === "/game/index"){
  1021. loadFeatures();
  1022. }
  1023. /*******************************************************************************************************************************
  1024. * HTTP-Requests
  1025. * *****************************************************************************************************************************/
  1026. function ajaxObserver(){
  1027. $(document).ajaxComplete(function (e, xhr, opt) {
  1028. var url = opt.url.split("?"),
  1029. action = url[0].substr(5) + "/" + url[1].split(/&/)[1].substr(7);
  1030. if(PID == 84367 || PID == 104769){
  1031. console.log(action);
  1032. console.log((JSON.parse(xhr.responseText).json));
  1033. }
  1034. setTimeout(function(){
  1035. switch (action) {
  1036. case "/frontend_bridge/fetch": // Daily Reward
  1037. // Thracian Event
  1038. var el = $('.js-hercules2014-dragdrop.dragdrop').get(0);
  1039. if(el){
  1040. var map_left = parseInt(el.style.left.split("p")[0], 10);
  1041. var map_top = parseInt(el.style.top.split("p")[0], 10);
  1042. if((map_top < -216) || (map_left < -143)){
  1043. $('.js-hercules2014-dragdrop.dragdrop').css({
  1044. top: '-40px',
  1045. left: '-40px'
  1046. });
  1047. }
  1048. }
  1049. //console.log("done");
  1050. //$('.daily_login').find(".minimize").click();
  1051. break;
  1052. case "/player/index":
  1053. settings();
  1054. if(diosettings){ $('#dio_tools').click(); diosettings = false; }
  1055. break;
  1056. case "/index/switch_town":
  1057. if(DATA.options.str) {setStrengthMenu();}
  1058. if(DATA.options.bir) {getBiri();}
  1059. if(DATA.options.twn) {changeTownIcon();}
  1060. // Update city window
  1061. if(uw.Layout.wnd.TYPE_TOWNINDEX){ // check if the window type exists
  1062. if(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX)){
  1063. uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).setTitle(uw.DM.getl10n('town_index').window_title +" - "+ uw.ITowns.getTown(uw.Game.townId).name);
  1064. uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).reloadContent();
  1065. }
  1066. }
  1067. break;
  1068. case "/building_docks/index":
  1069. if(DATA.options.bir) {getBiriDocks();}
  1070. break;
  1071. case "/building_place/units_beyond":
  1072. if(DATA.options.bir) {getBiriAgora();}
  1073. //addTransporterBackButtons();
  1074. break;
  1075. case "/building_place/simulator":
  1076. if(DATA.options.sim) {changeSimulatorLayout(); }
  1077. break;
  1078. case "/building_place/simulate":
  1079. if(DATA.options.sim) {afterSimulation(); }
  1080. break;
  1081. case "/alliance_forum/forum": case "/message/new": case "/message/forward": case "/message/view": case "/player_memo/load_memo_content":
  1082. if(DATA.options.sml){addSmileyBox(action); }
  1083. if(DATA.options.bbc){addForm(action); }
  1084. break;
  1085. case "/wonders/index":
  1086. if(DATA.options.trd){WWTradeHandler(); }
  1087. getResWW();
  1088. break;
  1089. case "/wonders/send_resources":
  1090. getResWW();
  1091. break;
  1092. case "/ranking/alliance":
  1093. getPointRatioFromAllianceRanking();
  1094. break;
  1095. case "/ranking/wonder_alliance":
  1096. getPointRatioFromAllianceRanking();
  1097. changeWWRanking(JSON.parse(xhr.responseText).plain.html);
  1098. setWonderIconsOnMap();
  1099. break;
  1100. case "/alliance/members_show":
  1101. getPointRatioFromAllianceMembers();
  1102. break;
  1103. case "/town_info/trading":
  1104. if(DATA.options.trd){addTradeMarks(15, 18, 15, "red"); TownTabHandler(action.split("/")[2]); }
  1105. break;
  1106. case "/farm_town_overviews/get_farm_towns_for_town":
  1107. changeResColor();
  1108. break;
  1109. case "/command_info/conquest_info":
  1110. if(DATA.options.str) {addStrengthConquest();}
  1111. break;
  1112. case "/command_info/conquest_movements": case "/conquest_info/getinfo":
  1113. if(DATA.options.cnt) {countMovements();}
  1114. break;
  1115. case "/building_barracks/index": case "/building_barracks/build":
  1116. if(DATA.options.str) {setStrengthBarracks();}
  1117. break;
  1118. case "/town_info/attack": case "/town_info/support":
  1119. TownTabHandler(action.split("/")[2]);
  1120. break;
  1121. case "/report/index":
  1122. changeDropDownButton();
  1123. loadFilter();
  1124. saveFilter();
  1125. //removeReports();
  1126. break;
  1127. case "/message/default": case "/message/index":
  1128. break;
  1129. case "/chat/init":
  1130. if(DATA.options.irc) {modifyChat();}
  1131. break;
  1132. case "/town_info/go_to_town":
  1133. /*
  1134. //console.log(uw.Layout.wnd);
  1135. var windo = uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).getID();
  1136. //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX));
  1137. uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).setPosition([100,400]);
  1138. //console.log(windo);
  1139. //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).getPosition());
  1140. */
  1141. break;
  1142. }
  1143. },0);
  1144. });
  1145. }
  1146. function test(){
  1147. //http://gpde.innogamescdn.com/images/game/temp/island.png
  1148. //console.log(uw.WMap);
  1149. //console.log(uw.WMap.getSea(uw.WMap.getXCoord(), uw.WMap.getYCoord()));
  1150. //console.log(uw.GameControllers.LayoutToolbarActivitiesController().prototype.getActivityTypes());
  1151. //console.log(uw.GameViews);
  1152. //console.log(uw.GameViews.BarracksUnitDetails());
  1153. //console.log(uw.ITowns.getTown(uw.Game.townId).unitsOuter().sword);
  1154. //console.log(uw.ITowns.getCurrentTown().unitsOuter().sword);
  1155. //console.log(uw.ITowns.getTown(uw.Game.townId).researches().attributes);
  1156. //console.log(uw.ITowns.getTown(uw.Game.townId).hasConqueror());
  1157. //console.log(uw.ITowns.getTown(uw.Game.townId).allUnits());
  1158. //console.log(uw.ITowns.all_units.fragments[uw.Game.townId]._byId);
  1159. //console.log("Zeus: " + uw.ITowns.player_gods.zeus_favor_delta_property.lastTriggeredVirtualPropertyValue);
  1160. //console.log(uw.ITowns.player_gods.attributes);
  1161. //console.log(uw.ITowns.getTown('5813').createTownLink());
  1162. //console.log(uw.ITowns.getTown(5813).unitsOuterTown);
  1163. //console.log(uw.ITowns.getTown(uw.Game.townId).getLinkFragment());
  1164. //console.log(uw.ITowns.getTown(uw.Game.townId).allGodsFavors());
  1165. }
  1166. /*******************************************************************************************************************************
  1167. * Helping functions
  1168. * ----------------------------------------------------------------------------------------------------------------------------
  1169. * | ● fixUnitValues: Get unit values and overwrite some wrong values
  1170. * | ● getMaxZIndex: Get the highest z-index of "ui-dialog"-class elements
  1171. * ----------------------------------------------------------------------------------------------------------------------------
  1172. *******************************************************************************************************************************/
  1173. // Fix buggy grepolis values
  1174. function fixUnitValues(){
  1175. uw.GameData.units.small_transporter.attack = uw.GameData.units.big_transporter.attack = uw.GameData.units.demolition_ship.attack = uw.GameData.units.militia.attack = 0;
  1176. 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;
  1177. uw.GameData.units.militia.resources = { wood: 0, stone: 0, iron: 0 };
  1178. }
  1179. function getMaxZIndex(){
  1180. var maxZ = Math.max.apply(null,$.map($("div[class^='ui-dialog']"), function(e,n){
  1181. if($(e).css('position')=='absolute'){
  1182. return parseInt($(e).css('z-index'), 10) || 1000;
  1183. }
  1184. }));
  1185. return (maxZ !== -Infinity)? maxZ + 1 : 1000;
  1186. }
  1187. function getBrowser(){
  1188. var ua = navigator.userAgent, tem,
  1189. M = ua.match(/(opera|maxthon|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
  1190. if(/trident/i.test(M[1])){
  1191. tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
  1192. M[1] = 'IE';
  1193. M[2] = tem[1] || '';
  1194. }
  1195. if(M[1] === 'Chrome'){
  1196. tem = ua.match(/\bOPR\/(\d+)/);
  1197. if(tem != null){
  1198. M[1] = 'Opera';
  1199. M[2] = tem[1];
  1200. }
  1201. }
  1202. M = M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
  1203. if((tem = ua.match(/version\/(\d+)/i))!= null) M.splice(1, 1, tem[1]);
  1204. return M.join(' ');
  1205. }
  1206. // Error Handling / Remote diagnosis / Automatic bug reports
  1207. function errorHandling(e, fn){
  1208. if(PID == 84367 || PID == 104769){
  1209. HumanMessage.error("DIO-TOOLS("+ version +")-ERROR: " + e.message);
  1210. console.log(e.stack);
  1211. } else {
  1212. if(!DATA.error[version]){
  1213. DATA.error[version] = {};
  1214. }
  1215. if(DATA.options.err && !DATA.error[version][fn]){
  1216. $.ajax({
  1217. type: "POST",
  1218. url: "http://diotools.pf-control.de/game/error.php",
  1219. data: { error: e.stack.replace(/'/g,'"') , "function": fn, browser: getBrowser(), version: version },
  1220. success: function (text) {
  1221. DATA.error[version][fn] = true;
  1222. saveValue("error", JSON.stringify(DATA.error));
  1223. }
  1224. });
  1225. }
  1226. }
  1227. }
  1228. // Notification
  1229. function newFeatureNotification(nid, feature){
  1230. var Notification = new NotificationHandler();
  1231. Notification.notify($('#notification_area>.notification').length+1, uw.NotificationType.DIO_TOOLS,
  1232. "<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>");
  1233. }
  1234. /*******************************************************************************************************************************
  1235. * Mousewheel Zoom
  1236. *******************************************************************************************************************************/
  1237. // Scroll trough the 2-3 views
  1238. function scrollViews(){
  1239. try {
  1240. var scroll = 2;
  1241. $('#main_area, .ui_city_overview').bind('mousewheel', function(e){
  1242. if($('.island_view').hasClass('checked')){
  1243. scroll = 2;
  1244. } else if($('.strategic_map').hasClass('checked')){
  1245. scroll = 1;
  1246. } else {
  1247. scroll = 3;
  1248. }
  1249. var delta = 0;
  1250. if (e.originalEvent.wheelDelta) {
  1251. if(e.originalEvent.wheelDelta < 0) { delta = -1;} else { delta = 1; }
  1252. }
  1253. if (e.originalEvent.detail) {
  1254. if(e.originalEvent.detail < 0) { delta = 1;} else { delta = -1; }
  1255. }
  1256. if(delta < 0) {
  1257. scroll -= 1;
  1258. if(scroll < 1) { scroll = 1; }
  1259. }else {
  1260. scroll += 1;
  1261. if(scroll > 2 && DATA.options.tov) { scroll = 2; }
  1262. if(scroll > 3) { scroll = 3; }
  1263. }
  1264. switch(scroll){
  1265. case 1: $('.strategic_map').click(); $('#popup_div').css('display', 'none'); break;
  1266. case 2: $('.island_view').click(); break;
  1267. case 3: $('.city_overview').click(); break;
  1268. }
  1269. //prevent page from scrolling
  1270. return false;
  1271. });
  1272. } catch(error){
  1273. errorHandling(error, "scrollViews");
  1274. }
  1275. }
  1276. /*******************************************************************************************************************************
  1277. * Statistics
  1278. * ----------------------------------------------------------------------------------------------------------------------------
  1279. * | ● Expansion of towns?
  1280. * | ● Occupancy of the farms?
  1281. * | ● Mouseclick-Counter?
  1282. * | ● Resource distribution (%)?
  1283. * | ● Building level counter ?
  1284. * ----------------------------------------------------------------------------------------------------------------------------
  1285. *******************************************************************************************************************************/
  1286. function addStatsButton(){
  1287. $('<div class="btn_statistics circle_button"><div class="ico_statistics js-caption"></div></div>').appendTo(".gods_area");
  1288. $('.btn_statistics').css({
  1289. top: '56px',
  1290. left: '-4px',
  1291. zIndex: '10',
  1292. position: 'absolute'
  1293. });
  1294. $('.btn_statistics .ico_statistics').css({
  1295. margin: '7px 0px 0px 8px', width: '17px', height: '17px',
  1296. 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
  1297. backgroundSize: "100%",
  1298. //WebkitFilter: 'hue-rotate(100deg)',
  1299. //filter: 'url(#Hue3)'
  1300. });
  1301. mouseclickCounter();
  1302. $('.btn_statistics').on('mousedown', function(){
  1303. $('.ico_statistics').get(0).style.marginTop = "8px";
  1304. });
  1305. $('.btn_statistics').toggle(function(){
  1306. $('.btn_statistics').addClass("checked");
  1307. $('.ico_statistics').get(0).style.marginTop = "8px";
  1308. //console.log(click_cnt);
  1309. $('#statistics_box').get(0).style.display = "block";
  1310. $('#statistics_box').get(0).style.zIndex = getMaxZIndex() + 1;
  1311. }, function(){
  1312. $('.btn_statistics').removeClass("checked");
  1313. $('.ico_statistics').get(0).style.marginTop = "7px";
  1314. $('#statistics_box').get(0).style.display = "none";
  1315. });
  1316. $('.btn_statistics').tooltip(getText("labels", "uni"));
  1317. }
  1318. var click_cnt = 0;
  1319. function mouseclickCounter(){
  1320. // TODO: start date and reset button
  1321. $('body').click(function(){
  1322. click_cnt++;
  1323. });
  1324. }
  1325. /*******************************************************************************************************************************
  1326. * Body Handler
  1327. * ----------------------------------------------------------------------------------------------------------------------------
  1328. * | ● Town icon
  1329. * | ● Town list: Adds town type to the town list
  1330. * | ● Swap Context Icons
  1331. * | ● City overview
  1332. * ----------------------------------------------------------------------------------------------------------------------------
  1333. *******************************************************************************************************************************/
  1334. var townTypeIcon = {
  1335. // Automatic Icons
  1336. lo: 0, ld: 3, so: 6, sd: 7, fo: 10, fd: 9, bu: 14, /* Building */ po: 22, no: 12,
  1337. // Manual Icons
  1338. 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,
  1339. wd: 16, /* Wood */ wo: 24, /* World */ bo: 13, /* Booty */ gr: 21, /* Lorbeer */ st: 17, /* Stone */ is: 26, /* ?? */ he: 4, /* Helmet */ ko: 8 /* Kolo */
  1340. },
  1341. townTypeIcon2 = {
  1342. 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
  1343. ld: "http://s7.directupload.net/images/140129/zwts6zz8.png", // blue: http://s1.directupload.net/images/140129/oua87w9q.png
  1344. so: "http://s7.directupload.net/images/140129/674supp9.png", // smaller: http://s14.directupload.net/images/140129/x7jv2kc9.png
  1345. sd: "http://s14.directupload.net/images/140129/aseivxpl.png",
  1346. fo: "http://s14.directupload.net/images/140129/j9mwfuu4.png", // bright: http://s1.directupload.net/images/140129/7ueia7ja.png
  1347. fd: "http://s7.directupload.net/images/140129/lwtlj9ej.png", // bright: http://s1.directupload.net/images/140129/4an4dhr7.png
  1348. 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
  1349. po: "http://gpde.innogamescdn.com/images/game/res/pop.png",
  1350. no: "http://s7.directupload.net/images/140129/t8tjs543.png", // green: http://s7.directupload.net/images/140129/zneb6f3m.png
  1351. // 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
  1352. // Manual Icons
  1353. fa: "http://s7.directupload.net/images/140404/xt839us6.png", // "http://s7.directupload.net/images/140404/xifwkdqy.png",
  1354. re: "http://s14.directupload.net/images/140404/b4n3tyjh.png",
  1355. di: "http://s14.directupload.net/images/140404/nvqxx5j7.png",
  1356. sh: "http://s1.directupload.net/images/140404/mbvpptpg.png",
  1357. lu: "http://s1.directupload.net/images/140404/38n97lp5.png",
  1358. // ro: "http://s14.directupload.net/images/140404/9o22obra.png",
  1359. dp: "http://s1.directupload.net/images/140404/95cgvzcp.png",
  1360. ha: "http://s1.directupload.net/images/140404/9om7bf4m.png",
  1361. si: "http://s1.directupload.net/images/140404/b5eumrw7.png",
  1362. ra: "http://s14.directupload.net/images/140404/3qofe863.png",
  1363. ch: "http://s7.directupload.net/images/140404/jrthehnw.png",
  1364. ti: "http://s7.directupload.net/images/140404/u2a5x7as.png", // "http://s1.directupload.net/images/140404/ceubhq4f.png",
  1365. 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",
  1366. wd: "http://s7.directupload.net/images/140404/te9zldjx.png",
  1367. wo: "http://s1.directupload.net/images/140404/cxbjhapw.png",
  1368. bo: "http://s14.directupload.net/images/140404/ki4gwd7x.png",
  1369. gr: "http://s14.directupload.net/images/140404/n7bq4ixc.png",
  1370. st: "http://s1.directupload.net/images/140404/zwc8ctqh.png",
  1371. is: "http://s1.directupload.net/images/140404/48nlm7xd.png",
  1372. he: "http://s7.directupload.net/images/140404/uldko8rb.png",
  1373. 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" //
  1374. },
  1375. worldWonderIcon = {
  1376. colossus_of_rhodes: "url(http://gpde.innogamescdn.com/images/game/map/wonder_colossus_of_rhodes.png) 38px -1px;",
  1377. great_pyramid_of_giza: "url(http://gpde.innogamescdn.com/images/game/map/wonder_great_pyramid_of_giza.png) 34px -6px;",
  1378. hanging_gardens_of_babylon: "url(http://gpde.innogamescdn.com/images/game/map/wonder_hanging_gardens_of_babylon.png) 34px -5px;",
  1379. lighthouse_of_alexandria: "url(http://gpde.innogamescdn.com/images/game/map/wonder_lighthouse_of_alexandria.png) 37px -1px;",
  1380. mausoleum_of_halicarnassus: "url(http://gpde.innogamescdn.com/images/game/map/wonder_mausoleum_of_halicarnassus.png) 37px -4px;",
  1381. statue_of_zeus_at_olympia: "url(http://gpde.innogamescdn.com/images/game/map/wonder_statue_of_zeus_at_olympia.png) 36px -3px;",
  1382. temple_of_artemis_at_ephesus: "url(http://gpde.innogamescdn.com/images/game/map/wonder_temple_of_artemis_at_ephesus.png) 34px -5px;"
  1383. };
  1384. function setWonderIconsOnMap(){
  1385. try {
  1386. if(!$('#wondericons_map').get(0)){
  1387. var color = "orange";
  1388. // style for world wonder icons
  1389. var style_str = "<style id='wondericons_map' type='text/css'>";
  1390. for(var ww_type in wonder.map){
  1391. if(wonder.map.hasOwnProperty(ww_type)){
  1392. for(var ww in wonder.map[ww_type]){
  1393. if(wonder.map[ww_type].hasOwnProperty(ww)){
  1394. /*
  1395. if(wonder.map[ww_type][ww] !== AID){
  1396. color = "rgb(192, 109, 54)";
  1397. } else {
  1398. color = "orange";
  1399. }
  1400. */
  1401. style_str += "#mini_i" + ww + ":before {"+
  1402. "content: '';"+
  1403. "background:"+ color + " " + worldWonderIcon[ww_type] +
  1404. "background-size: auto 97%;"+
  1405. "padding: 8px 16px;"+
  1406. "top: 50px;"+
  1407. "position: relative;"+
  1408. "border-radius: 40px;"+
  1409. "z-index: 200;"+
  1410. "cursor: pointer;"+
  1411. "box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5);"+
  1412. "border: 2px solid green; } "+
  1413. "#mini_i" + ww + ":hover:before { z-index: 201; "+
  1414. "-webkit-filter: brightness(1.2);"+
  1415. "filter: url(#Brightness12);} ";
  1416. }
  1417. }
  1418. }
  1419. }
  1420. $(style_str + "</style>").appendTo('head');
  1421. // Context menu on mouseclick
  1422. $('#minimap_islands_layer').on('click', '.m_island', function(e){
  1423. var ww_coords = this.id.split("i")[3].split("_");
  1424. uw.Layout.contextMenu(e, 'wonder', {ix: ww_coords[0], iy: ww_coords[1]});
  1425. });
  1426. }
  1427. } catch(error) {
  1428. errorHandling(error, "setWonderIconsOnMap");
  1429. }
  1430. }
  1431. function setTownIconsOnMap(){
  1432. try {
  1433. // if town icon changed
  1434. if($('#townicons_map').get(0)){ $('#townicons_map').remove(); }
  1435. // style for own towns (town icons)
  1436. var start = (new Date()).getTime(), end, style_str = "<style id='townicons_map' type='text/css'>";
  1437. for(var e in autoTownTypes){
  1438. if(autoTownTypes.hasOwnProperty(e)){
  1439. style_str += "#mini_t"+ e +" { height: 19px;"+
  1440. "width:19px;"+
  1441. "border-radius: 11px;"+
  1442. "border: 2px solid rgb(16, 133, 0);"+
  1443. "margin: -4px;"+
  1444. //"background: rgb(255, 187, 0) url(http://s7.directupload.net/images/140404/xt839us6.png) repeat;"+
  1445. "background: rgb(255, 187, 0) url("+ dio_sprite +") "+ (townTypeIcon[(manuTownTypes[e] || autoTownTypes[e])]*-25) +"px -27px repeat;"+
  1446. "z-index: 100;"+
  1447. "font-size: 0em;"+
  1448. "cursor: pointer;"+
  1449. "box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5);} "+
  1450. "#mini_t"+ e +":hover { z-index: 101; "+
  1451. "-webkit-filter: brightness(1.2);" +
  1452. "filter: url(#Brightness12);} ";
  1453. }
  1454. }
  1455. // Context menu on mouseclick
  1456. $('#minimap_islands_layer').on('click', '.m_town', function(z){
  1457. var id = parseInt($(this).get(0).id.substring(6), 10);
  1458. uw.Layout.contextMenu(z, 'determine', {"id": id, "name": uw.ITowns.getTown(id).name });
  1459. z.stopPropagation(); // prevent parent world wonder event
  1460. });
  1461. // Style for foreign cities (shadow)
  1462. style_str += ".m_town { text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.7); } ";
  1463. style_str += "</style>";
  1464. $(style_str).appendTo('head');
  1465. /*
  1466. setTimeout(function(){
  1467. uw.MapTiles.createTownDiv_old = uw.MapTiles.createTownDiv;
  1468. uw.MapTiles.createTownDiv = function(town, player_current_town) {
  1469. var ret = uw.MapTiles.createTownDiv_old(town, player_current_town);
  1470. if(!isNaN(town.id) && town.player_id == PID) {
  1471. //setIconMap(town.id);
  1472. console.log(town.id);
  1473. console.log(player_current_town);
  1474. }
  1475. return ret;
  1476. };
  1477. },2000);
  1478. */
  1479. } catch(error) {
  1480. errorHandling(error, "setTownIconsOnMap");
  1481. }
  1482. }
  1483. // Style for town icons
  1484. var style_str = '<style id="townicons" type="text/css">';
  1485. for(var s in townTypeIcon){
  1486. if(townTypeIcon.hasOwnProperty(s)){
  1487. style_str += '.townicon_'+ s +' { background:url('+ dio_sprite +') '+ (townTypeIcon[s]*-25) +'px -26px repeat;float:left;} ';
  1488. }
  1489. }
  1490. style_str += '</style>';
  1491. $(style_str).appendTo('head');
  1492. // City overview
  1493. function setCityWindowContext(){
  1494. // $.each($("#goToTown").data("events"), function(i, e) { //console.log(i); });
  1495. if(uw.Layout.wnd.TYPE_TOWNINDEX){
  1496. $('#goToTown').unbind("mousedown");
  1497. $('#goToTown').on("mousedown", function(){
  1498. uw.GPWindowMgr.Create(uw.Layout.wnd.TYPE_TOWNINDEX, uw.DM.getl10n('town_index').window_title +" - "+ uw.ITowns.getTown(uw.Game.townId).name);
  1499. if($('#select_town').get(0)) {$('#select_town').mousedown(); }
  1500. var town = setInterval(function(){
  1501. if($('#town_background').get(0)){
  1502. document.getSelection().removeAllRanges();
  1503. clearInterval(town);
  1504. }
  1505. }, 50);
  1506. });
  1507. }
  1508. }
  1509. function setCityWindowButton(){
  1510. $("#ui_box .bull_eye_buttons .city_overview").appendTo('#ui_box .bull_eye_buttons');
  1511. $("#ui_box .bull_eye_buttons .city_overview").css({
  1512. left: '18px',
  1513. top: '3px'
  1514. });
  1515. if(uw.Layout.wnd.TYPE_TOWNINDEX){
  1516. $('.bull_eye_buttons .city_overview').on("click", function(){
  1517. uw.GPWindowMgr.Create(uw.Layout.wnd.TYPE_TOWNINDEX, uw.DM.getl10n('town_index').window_title +" - "+ uw.ITowns.getTown(uw.Game.townId).name);
  1518. });
  1519. }
  1520. }
  1521. function changeContextMenu(){
  1522. // Set context menu event handler
  1523. $.Observer(uw.GameEvents.map.context_menu.click).subscribe('DIO_CONTEXT', function(e,data){
  1524. if(DATA.options.con && $('#context_menu').children().length == 4){
  1525. // Clear animation
  1526. $('#context_menu div#goToTown').css({
  1527. left: '0px',
  1528. top: '0px',
  1529. WebkitAnimation: 'none', //'A 0s linear',
  1530. animation: 'none' //'B 0s linear'
  1531. });
  1532. }
  1533. // Set 'goToTown' button
  1534. if(DATA.options.tov && $('#goToTown').get(0)){
  1535. setCityWindowContext();
  1536. }
  1537. // Replace german label of 'select town' button
  1538. if(LID === "de" && $('#select_town').get(0)){
  1539. $("#select_town .caption").get(0).innerHTML = "Selektieren";
  1540. }
  1541. });
  1542. // Set context menu animation
  1543. if(!$('#select_town').get(0) && !$('#espionage').get(0)){
  1544. var ani_duration = 0;
  1545. // set fixed position of 'select town' button
  1546. $('<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);
  1547. // set animation of 'goToTown' button
  1548. $('<style id="dio_context" type="text/css"> #context_menu div#goToTown { left: 30px; top: -51px; '+
  1549. '-webkit-animation: A 0.115s linear; animation: B 0.2s;} '+
  1550. '@-webkit-keyframes A { from {left: 0px; top: 0px;} to {left: 30px; top: -51px;} }'+
  1551. '@keyframes B { from {left: 0px; top: 0px;} to {left: 30px; top: -51px;} }'+
  1552. '</style>').appendTo('head');
  1553. }
  1554. }
  1555. function imageSelectionProtection(){
  1556. $('<style type="text/css"> img { -moz-user-select: -moz-none; -khtml-user-select: none; -webkit-user-select: none;} </style>').appendTo('head');
  1557. }
  1558. function setTownList(){
  1559. // TODO: rewrite in one style tag
  1560. // Town list
  1561. $('<style type="text/css"> #town_groups_list .item { text-align: left; padding-left:35px;} </style>').appendTo('head');
  1562. //$('<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');
  1563. $('<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');
  1564. $('<style type="text/css"> .town_groups_list .island_quest_icon { background-size: 90%; position: absolute; right: 37px; top: 4px;} </style>').appendTo('head');
  1565. // Quacks Zentrier-Button verschieben
  1566. $('<style type="text/css"> #town_groups_list .jump_town { right: 37px !important;} </style>').appendTo('head');
  1567. // Population percentage
  1568. $('<style type="text/css"> #town_groups_list .pop_percent { position: absolute; right: 7px; font-size: 0.7em;} '+
  1569. '#town_groups_list .full { color: green; }'+
  1570. '#town_groups_list .threequarter { color: darkgoldenrod; }'+
  1571. '#town_groups_list .half { color: darkred; }'+
  1572. '#town_groups_list .quarter { color: red; }'+
  1573. '</style>').appendTo('head');
  1574. // Town Icons
  1575. $('<style type="text/css"> .icon_small { height:20px;padding-left:25px;margin-left:-25px; background-clip:padding-box;} </style>').appendTo('head');
  1576. // Open town list: hook to grepolis function render()
  1577. if(DATA.options.twn){
  1578. var i = 0;
  1579. while(uw.layout_main_controller.sub_controllers[i].name != 'town_name_area'){ i++; }
  1580. 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;
  1581. uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render = function() {
  1582. uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render_old();
  1583. changeTownList();
  1584. };
  1585. }
  1586. }
  1587. function changeTownList(){
  1588. $("#town_groups_list .town_group_town").each(function() {
  1589. try {
  1590. var town_id = $(this).attr('name'), str = $(this).get(0).innerHTML, townicon_str, percent_str = "", percent = -1,
  1591. space = "full";
  1592. if(population[town_id]){
  1593. percent = population[town_id].percent;
  1594. }
  1595. if(percent < 75){ space = "threequarter"; }
  1596. if(percent < 50){ space = "half"; }
  1597. if(percent < 25){ space = "quarter"; }
  1598. if (!(str.indexOf("townicon") >= 0)){
  1599. townicon_str= '<div class="icon_small townicon_'+ (manuTownTypes[town_id] || autoTownTypes[town_id] || "no") +'"></div>';
  1600. // TODO: Notlösung...
  1601. if(percent != -1){
  1602. percent_str = '<div class="pop_percent '+ space +'">' + percent + '%</div>';
  1603. }
  1604. $(this).get(0).innerHTML = townicon_str + percent_str + str;
  1605. }
  1606. // opening context menu
  1607. /*
  1608. $(this).click(function(e){
  1609. console.log(e);
  1610. uw.Layout.contextMenu(e, 'determine', {"id": town_id,"name": uw.ITowns[town_id].getName()});
  1611. });
  1612. */
  1613. } catch(error){
  1614. errorHandling(error, "changeTownList");
  1615. }
  1616. });
  1617. $("#town_groups_list .town_group_town").hover(function(){
  1618. $(this).find('.island_quest_icon').css({
  1619. display: "none"
  1620. });
  1621. }, function(){
  1622. $(this).find('.island_quest_icon').css({
  1623. display: "block"
  1624. });
  1625. });
  1626. // Add change town list event handler
  1627. $.Observer(uw.GameEvents.town.town_switch).unsubscribe('DIO_SWITCH_TOWN');
  1628. $.Observer(uw.GameEvents.town.town_switch).subscribe('DIO_SWITCH_TOWN', function () {
  1629. changeTownList();
  1630. });
  1631. }
  1632. function addTownIcon(){
  1633. try {
  1634. // Quickbar modification
  1635. $('.ui_quickbar .left, .ui_quickbar .right').css({ width: '46%' });
  1636. $('<div id="town_icon"><div class="town_icon_bg"><div class="icon_big townicon_'+
  1637. (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no") + " auto")) + '"></div></div></div>').appendTo('.town_name_area');
  1638. $('.town_name_area').css({ zIndex: 11, left: '52%' }); // because of Kapsonfires Script and Beta Worlds bug report bar
  1639. $('.town_name_area .left').css({
  1640. zIndex: 20,
  1641. left: '-39px'
  1642. });
  1643. // Town Icon Style
  1644. $('#town_icon .icon_big').css({
  1645. backgroundPosition: townTypeIcon[(manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")))]*-25 + 'px 0px'
  1646. });
  1647. $('<style type="text/css">'+
  1648. '#town_icon { background:url('+ dio_sprite +') 0 -125px no-repeat; position:absolute; width:69px; height:61px; left:-47px; top:0px; z-index: 10; } '+
  1649. '#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; } '+
  1650. '#town_icon .town_icon_bg:hover { -webkit-filter:brightness(1.1); filter:url(#Brightness11); box-shadow: 0px 0px 15px rgb(1, 197, 33); } '+
  1651. '#town_icon .icon_big { position:absolute; left:9px; top:9px; height:25px; width:25px; } '+
  1652. '</style>').appendTo('head');
  1653. var icoArray = ['ld', 'lo', 'sh', 'di', 'un',
  1654. 'sd', 'so', 'ko', 'ti', 'gr',
  1655. 'fd', 'fo', 'dp', 'no', 'po',
  1656. 're', 'wd', 'st', 'si', 'bu',
  1657. 'he', 'ch', 'bo', 'fa', 'wo'];
  1658. // Fill select box with town icons
  1659. $('<div class="select_town_icon dropdown-list default active"><div class="item-list"></div></div>').appendTo("#town_icon");
  1660. for(var i in icoArray){
  1661. if(icoArray.hasOwnProperty(i)){
  1662. $('.select_town_icon .item-list').append('<div class="option_s icon_small townicon_'+ icoArray[i] +'" name="'+ icoArray[i] +'"></div>');
  1663. }
  1664. }
  1665. $('<hr><div class="option_s auto_s" name="auto"><b>Auto</b></div>').appendTo('.select_town_icon .item-list');
  1666. // Styles
  1667. $('#town_icon .select_town_icon').css({
  1668. position: 'absolute',
  1669. top: '47px',
  1670. left: '23px',
  1671. width: '145px',
  1672. display: "none",
  1673. padding: '2px',
  1674. border: '3px inset rgb(7, 99, 12)',
  1675. boxShadow: 'rgba(0, 0, 0, 0.5) 4px 4px 6px',
  1676. borderRadius: '0px 10px 10px 10px',
  1677. background: "url(http://gpde.innogamescdn.com/images/game/popup/middle_middle.png)"
  1678. });
  1679. $('#town_icon .item-list').css({ maxHeight: '400px', maxWidth: '200px', align: "right", overflowX: 'hidden' });
  1680. $('<style type="text/css">'+
  1681. '#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;} '+
  1682. '#town_icon .option_s:hover { border: 2px solid rgb(59, 121, 81) !important;-webkit-filter: brightness(1.3); } '+
  1683. '#town_icon .sel { border: 2px solid rgb(202, 176, 109); } '+
  1684. '#town_icon hr { width:145px; margin:0px 0px 7px 0px; position:relative; top:3px; border:0px; border-top:2px dotted #000; float:left} '+
  1685. '#town_icon .auto_s { width:136px; height:16px; float:left} '+
  1686. '</style>').appendTo('head');
  1687. $('#town_icon .option_s').click(function(){
  1688. $("#town_icon .sel").removeClass("sel"); $(this).addClass("sel");
  1689. if($(this).attr("name") === "auto"){
  1690. delete manuTownTypes[uw.Game.townId];
  1691. } else {
  1692. manuTownTypes[uw.Game.townId] = $(this).attr("name");
  1693. }
  1694. changeTownIcon();
  1695. saveValue(WID + "_townTypes", JSON.stringify(manuTownTypes));
  1696. });
  1697. // Show & hide drop menus on click
  1698. $('#town_icon .town_icon_bg').click(function(){
  1699. var el = $('#town_icon .select_town_icon').get(0);
  1700. if( el.style.display === "none"){
  1701. el.style.display = "block";
  1702. } else {
  1703. el.style.display = "none";
  1704. }
  1705. });
  1706. $('#town_icon .select_town_icon [name="'+ (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" :"" )) +'"]').addClass("sel");
  1707. } catch(error){
  1708. errorHandling(error, "addTownIcon");
  1709. }
  1710. }
  1711. function changeTownIcon(){
  1712. var townType = (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")));
  1713. $('#town_icon .icon_big').removeClass().addClass('icon_big townicon_'+ townType + " auto");
  1714. $('#town_icon .sel').removeClass("sel");
  1715. $('#town_icon .select_town_icon [name="'+ (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" :"" )) +'"]').addClass("sel");
  1716. $('#town_icon .icon_big').css({
  1717. backgroundPosition: townTypeIcon[townType]*-25 + 'px 0px'
  1718. });
  1719. $('#town_icon .select_town_icon').get(0).style.display = "none";
  1720. // update town icons on the map
  1721. setTownIconsOnMap();
  1722. }
  1723. /*******************************************************************************************************************************
  1724. * Available units
  1725. * ----------------------------------------------------------------------------------------------------------------------------
  1726. * | ● Shows all available units
  1727. * ----------------------------------------------------------------------------------------------------------------------------
  1728. *******************************************************************************************************************************/
  1729. function addAvailableUnitsButton(){
  1730. var default_title = DM.getl10n("place", "support_overview").options.troop_count + " ("+ DM.getl10n("hercules2014", "available")+")";
  1731. $('<div class="btn_available_units circle_button"><div class="ico_available_units js-caption"></div></div>').appendTo(".bull_eye_buttons");
  1732. $('.btn_available_units').css({
  1733. top: '86px',
  1734. left: '119px',
  1735. zIndex: '10',
  1736. position: 'absolute'
  1737. });
  1738. $('.btn_available_units .ico_available_units').css({
  1739. margin: '5px 0px 0px 4px', width: '24px', height: '24px',
  1740. background: 'url(http://s1.directupload.net/images/140323/w4ekrw8b.png) no-repeat 0px 0px', //http://gpde.innogamescdn.com/images/game/res/unit.png
  1741. backgroundSize: "100%",
  1742. WebkitFilter: 'hue-rotate(100deg)',
  1743. filter: 'url(#Hue1)'
  1744. });
  1745. $('.btn_available_units').on('mousedown', function(){
  1746. $('.ico_available_units').get(0).style.marginTop = "6px";
  1747. });
  1748. $('.btn_available_units').toggle(function(){
  1749. $('#available_units_box').get(0).style.display = "block";
  1750. $('#available_units_box').get(0).style.zIndex = getMaxZIndex() + 1;
  1751. $('.btn_available_units').addClass("checked");
  1752. $('.ico_available_units').get(0).style.marginTop = "6px";
  1753. }, function(){
  1754. $('#available_units_box').get(0).style.display = "none";
  1755. $('.btn_available_units').removeClass("checked");
  1756. $('.ico_available_units').get(0).style.marginTop = "5px";
  1757. });
  1758. $('.btn_available_units').tooltip(LANG.hasOwnProperty(LID) ? getText("labels", "uni") : default_title);
  1759. }
  1760. /*******************************************************************************************************************************
  1761. * Comparison
  1762. * ----------------------------------------------------------------------------------------------------------------------------
  1763. * | ● Compares the units of each unit type
  1764. * ----------------------------------------------------------------------------------------------------------------------------
  1765. *******************************************************************************************************************************/
  1766. function addComparisonButton(){
  1767. $('<div class="btn_comparison circle_button"><div class="ico_comparison js-caption"></div></div>').appendTo(".bull_eye_buttons");
  1768. $('.btn_comparison').css({
  1769. top: '51px',
  1770. left: '120px',
  1771. zIndex: '10',
  1772. position: 'absolute'
  1773. });
  1774. $('.btn_comparison .ico_comparison').css({
  1775. margin: '5px 0px 0px 4px', width: '24px', height: '24px',
  1776. background: 'url(http://666kb.com/i/cjq6cxia4ms8mn95r.png) no-repeat 0px 0px',
  1777. backgroundSize: "100%",
  1778. WebkitFilter: 'hue-rotate(60deg)',
  1779. filter: 'url(#Hue1)'
  1780. });
  1781. $('.btn_comparison').on('mousedown', function(){
  1782. $('.ico_comparison').get(0).style.marginTop = "6px";
  1783. });
  1784. $('.btn_comparison').toggle(function(){
  1785. $('#unit_box').get(0).style.display = "block";
  1786. $('#unit_box').get(0).style.zIndex = getMaxZIndex() + 1;
  1787. $('.btn_comparison').addClass("checked");
  1788. $('.ico_comparison').get(0).style.marginTop = "6px";
  1789. }, function(){
  1790. $('#unit_box').get(0).style.display = "none";
  1791. $('.btn_comparison').removeClass("checked");
  1792. $('.ico_comparison').get(0).style.marginTop = "5px";
  1793. });
  1794. $('.btn_comparison').tooltip(getText("labels", "dsc"));
  1795. }
  1796. function addComparisonBox(){
  1797. var pos = {
  1798. att: { hack: "36%", pierce: "27%", distance: "45.5%", ship: "72.5%" },
  1799. def: { hack: "18%", pierce: "18%", distance: "18%", ship: "81.5%" }
  1800. };
  1801. var unitIMG = "http://de.cdn.grepolis.com/images/game/units/units_info_sprite2.51.png";
  1802. $('<div id="unit_box" class="ui-dialog">'+
  1803. '<div class="bbcode_box middle_center"><div class="bbcode_box middle_right"></div><div class="bbcode_box middle_left"></div>'+
  1804. '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div><div class="bbcode_box top_center"></div>'+
  1805. '<div class="bbcode_box bottom_center"></div><div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>'+
  1806. '<div style="height:20px; margin-left:35px;">'+
  1807. '<a class="hack" href="#" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att.hack +';">'+
  1808. '<span style="margin-left:20px">'+ getText("labels", "hck") +'</span></a>'+
  1809. '<a class="pierce" href="#" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att.pierce +';">'+
  1810. '<span style="margin-left:20px">'+ getText("labels", "prc") +'</span></a>'+
  1811. '<a class="distance" href="#" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att.distance +';">'+
  1812. '<span style="margin-left:20px">'+ getText("labels", "dst") +'</span></a>'+
  1813. '<a class="ship" href="#" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att.ship +';">'+
  1814. '<span style="margin-left:20px">'+ getText("labels", "sea") +'</span></a>'+
  1815. '</div><hr>'+
  1816. '<div class="box_content"></div></div>').appendTo('body');
  1817. $('#unit_box a').css({
  1818. float: 'left',
  1819. backgroundRepeat: 'no-repeat',
  1820. backgroundSize: '25px',
  1821. lineHeight: '2',
  1822. marginRight:'10px'
  1823. });
  1824. $('#unit_box span').css({
  1825. marginLeft: '27px',
  1826. });
  1827. $('#unit_box').draggable({
  1828. containment: "body",
  1829. snap: "body",
  1830. });
  1831. $('#unit_box').css({
  1832. position: 'absolute',
  1833. top: '100px',
  1834. left: '200px',
  1835. zIndex: getMaxZIndex() + 1,
  1836. display: 'none'
  1837. });
  1838. $('#unit_box .box_content').css({
  1839. background: 'url(http://s1.directupload.net/images/140206/8jd9d3ec.png) 94% 94% no-repeat',
  1840. backgroundSize: '140px'
  1841. });
  1842. $('#unit_box').bind("mousedown",function(){
  1843. $(this).get(0).style.zIndex = getMaxZIndex() + 1;
  1844. });
  1845. addComparisonTable("hack");
  1846. addComparisonTable("pierce");
  1847. addComparisonTable("distance");
  1848. addComparisonTable("ship");
  1849. $('#unit_box .t_hack').get(0).style.display = "block";
  1850. // Tooltips
  1851. /*
  1852. var labelArray = DM.getl10n("common", "barracks_and_docs"),
  1853. labelAttack = DM.getl10n("context_menu", "titles").attack,
  1854. labelDefense = DM.getl10n("place", "tabs")[0];
  1855. $('.tr_att').tooltip(labelAttack);
  1856. $('.tr_def').tooltip(labelDefense + " (Ø)");
  1857. $('.tr_def_ship').tooltip(labelDefense);
  1858. $('.tr_spd').tooltip(labelArray.tooltips.speed);
  1859. $('.tr_bty').tooltip(labelArray.tooltips.booty.title);
  1860. $('.tr_bty_ship').tooltip(labelArray.tooltips.ship_transport.title);
  1861. $('.tr_res').tooltip(labelArray.costs + " (" +
  1862. labelArray.cost_details.wood + " + " +
  1863. labelArray.cost_details.stone + " + " +
  1864. labelArray.cost_details.iron + ")"
  1865. );
  1866. $('.tr_fav').tooltip(labelArray.costs + " (" + labelArray.cost_details.favor + ")");
  1867. $('.tr_tim').tooltip(labelArray.cost_details.buildtime_barracks + " (s)");
  1868. $('.tr_tim_ship').tooltip(labelArray.cost_details.buildtime_docks + " (s)");
  1869. */
  1870. switchComparisonTables();
  1871. $('#unit_box hr').css({ border: '1px solid', color: '#804000', float:'none' });
  1872. }
  1873. function switchComparisonTables(){
  1874. $('#unit_box .hack, #unit_box .pierce, #unit_box .distance, #unit_box .ship').click(function(){
  1875. $('#unit_box [class^="t_"]').css({ display : "none" });
  1876. $('#unit_box .t_'+this.className).get(0).style.display = "block";
  1877. });
  1878. }
  1879. var ttpArray = [], t = 0;
  1880. function addComparisonTable(type){
  1881. var pos = {
  1882. att: { hack: "36%", pierce: "27%", distance: "45.5%", ship: "72.5%" },
  1883. def: { hack: "18%", pierce: "18%", distance: "18%", ship: "81.5%" }
  1884. };
  1885. var unitIMG = "http://de.cdn.grepolis.com/images/game/units/units_info_sprite2.51.png";
  1886. var strArray = [
  1887. "<td></td>",
  1888. '<td><div class="bla" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att[type] +';"></div></td>',
  1889. '<td><div class="bla" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.def[type] +';"></div></td>',
  1890. '<td><div class="bla" style="background: url('+ unitIMG +'); background-position: 0% 63%;"></div></td>',
  1891. (type !== "ship") ? '<td><div class="booty"></div></td>' : '<td><div class="bla" style="background-image: url('+ unitIMG +'); background-position: 0% 91%;"></div></td>',
  1892. '<td><div class="bla" style="background: url('+ unitIMG +'); background-position: 0% 54%;"></div></td>',
  1893. '<td><div class="bla" style="background: url(http://de.cdn.grepolis.com/images/game/res/favor.png)"></div></td>',
  1894. '<td><div class="bla" style="background: url(http://de.cdn.grepolis.com/images/game/res/time.png);"></div></td>'
  1895. ];
  1896. for(var e in uw.GameData.units){
  1897. if(uw.GameData.units.hasOwnProperty(e)){
  1898. var valArray = [];
  1899. if(type === (uw.GameData.units[e].attack_type || "ship") && (e !== "militia")) {
  1900. valArray.att = Math.round(uw.GameData.units[e].attack*10 / uw.GameData.units[e].population) / 10;
  1901. 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;
  1902. valArray.def = valArray.def || Math.round(uw.GameData.units[e].defense*10/uw.GameData.units[e].population) / 10;
  1903. valArray.speed = uw.GameData.units[e].speed;
  1904. valArray.booty = Math.round(((uw.GameData.units[e].booty)*10) / uw.GameData.units[e].population) / 10;
  1905. 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;
  1906. valArray.favor = Math.round((uw.GameData.units[e].favor *10)/ uw.GameData.units[e].population) / 10;
  1907. 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));
  1908. valArray.time = Math.round(uw.GameData.units[e].build_time / uw.GameData.units[e].population);
  1909. valArray.heroStyle = ""; valArray.heroStyleIMG = "";
  1910. // World without Artemis? -> grey griffin and boar
  1911. if(!uw.Game.hasArtemis && ((e === "griffin") || (e === "calydonian_boar"))){
  1912. valArray.heroStyle = "color:black;opacity: 0.4;";
  1913. valArray.heroStyleIMG = "-webkit-filter:grayscale(100%); filter: url(#GrayScale);";
  1914. }
  1915. strArray[0] += '<td class="un'+ (t) +'"><div class="unit index_unit unit_icon40x40 ' + e + '" style="'+ valArray.heroStyle + valArray.heroStyleIMG +'"></div></td>';
  1916. strArray[1] += '<td class="bold" style="color:'+ ((valArray.att>19)?'green;':((valArray.att<10 && valArray.att!=0 )?'red;':'black;')) + valArray.heroStyle +';">'+ valArray.att +'</td>';
  1917. strArray[2] += '<td class="bold" style="color:'+ ((valArray.def>19)?'green;':((valArray.def<10 && valArray.def!=0 )?'red;':'black;')) + valArray.heroStyle +';">'+ valArray.def +'</td>';
  1918. strArray[3] += '<td class="bold" style="'+ valArray.heroStyle +'">'+ valArray.speed +'</td>';
  1919. strArray[4] += '<td class="bold" style="'+ valArray.heroStyle +'">'+ valArray.booty +'</td>';
  1920. strArray[5] += '<td class="bold" style="'+ valArray.heroStyle +'">'+ valArray.res +'</td>';
  1921. strArray[6] += '<td class="bold" style="color:'+ ((valArray.favor>0)?'rgb(0, 0, 214);':'black;') + valArray.heroStyle +';">'+ valArray.favor +'</td>';
  1922. strArray[7] += '<td class="bold" style="'+ valArray.heroStyle +'">'+ valArray.time +'</td>';
  1923. ttpArray[t] = uw.GameData.units[e].name; t++;
  1924. }
  1925. }
  1926. }
  1927. $('<table class="t_'+ type +'" cellpadding="1px" style="display:none">'+
  1928. '<tr>'+ strArray[0] +'</tr>'+
  1929. '<tr class="tr_att">'+ strArray[1] +'</tr><tr class="tr_def'+ (type == "ship" ? "_ship" : "") +'">'+ strArray[2] +'</tr>'+
  1930. '<tr class="tr_spd">'+ strArray[3] +'</tr><tr class="tr_bty'+ (type == "ship" ? "_ship" : "") +'">'+ strArray[4] +'</tr>'+
  1931. '<tr class="tr_res">'+ strArray[5] +'</tr><tr class="tr_fav">'+ strArray[6] +'</tr><tr class="tr_tim'+ (type == "ship" ? "_ship" : "") +'">'+ strArray[7] +'</tr>'+
  1932. '</table>').appendTo('#unit_box .box_content');
  1933. for(var i = 0; i <= t; i++){
  1934. $('.un'+i).tooltip(ttpArray[i]);
  1935. }
  1936. //$('#unit_box .box_content').css({ position: 'relative' });
  1937. $('#unit_box .bla').css({
  1938. height: '25px',
  1939. width: '25px',
  1940. backgroundSize: '100%',
  1941. float: 'left'
  1942. });
  1943. $('#unit_box .booty').css({
  1944. width: '26px',
  1945. height: '25px',
  1946. background: 'url(http://s14.directupload.net/images/140404/ki4gwd7x.png)',
  1947. backgroundSize: '95%'
  1948. });
  1949. }
  1950. /*******************************************************************************************************************************
  1951. * Reports and Messages
  1952. * ----------------------------------------------------------------------------------------------------------------------------
  1953. * | ● Storage of the selected filter (only in German Grepolis yet)
  1954. * ----------------------------------------------------------------------------------------------------------------------------
  1955. *******************************************************************************************************************************/
  1956. var filter = "all";
  1957. function saveFilter(){
  1958. $('#dd_filter_type_list .item-list div').each(function(){
  1959. $(this).click(function(){
  1960. filter = $(this).attr("name");
  1961. });
  1962. });
  1963. /*
  1964. var i = 0;
  1965. $("#report_list a").each(function () {
  1966. //console.log((i++) +" = " + $(this).attr('data-reportid'));
  1967. });
  1968. */
  1969. }
  1970. function loadFilter(){
  1971. if(!($('#dd_filter_type_list .selected').attr("name") === filter)){
  1972. $('#dd_filter_type .caption').click();
  1973. $('#dd_filter_type_list .item-list div[name='+ filter +']').click();
  1974. }
  1975. }
  1976. function removeReports(){
  1977. $("#report_list li:contains('spioniert')").each(function () {
  1978. //$(this).remove();
  1979. });
  1980. }
  1981. var zut = 0;
  1982. var messageArray = {};
  1983. function filterPlayer(){
  1984. if(!$('#message_filter_list').get(0)) {
  1985. $('<div id="message_filter_list" style="height:300px;overflow-y:scroll; width: 790px;"></div>').appendTo('#folder_container');
  1986. $("#message_list").get(0).style.display = "none";
  1987. }
  1988. if(zut < parseInt($('.es_last_page').get(0).value, 10)-1){
  1989. $('.es_page_input').get(0).value = zut++;
  1990. $('.jump_button').click();
  1991. $("#message_list li:contains('')").each(function () {
  1992. $(this).appendTo('#message_filter_list');
  1993. });
  1994. } else {
  1995. zut = 1;
  1996. }
  1997. }
  1998. /*******************************************************************************************************************************
  1999. * World Wonder Ranking - Change
  2000. *******************************************************************************************************************************/
  2001. function getWorldWonderTypes(){
  2002. $.ajax({
  2003. type: "GET",
  2004. url:
  2005. "/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 +
  2006. "%7D&_="+ uw.Game.server_time,
  2007. success: function(text) {
  2008. try {
  2009. //console.log(JSON.parse(text));
  2010. temp = JSON.parse(text).json.data.world_wonders;
  2011. for(var t in temp){
  2012. if(temp.hasOwnProperty(t)){
  2013. wonderTypes[temp[t].wonder_type] = temp[t].full_name;
  2014. }
  2015. }
  2016. temp = JSON.parse(text).json.data.buildable_wonders;
  2017. for(var x in temp){
  2018. if(temp.hasOwnProperty(x)){
  2019. wonderTypes[x] = temp[x].name;
  2020. }
  2021. }
  2022. saveValue(MID + "_wonderTypes", JSON.stringify(wonderTypes));
  2023. } catch(error){
  2024. errorHandling(error, "getWorldWonderTypes");
  2025. }
  2026. }
  2027. });
  2028. }
  2029. function getWorldWonders(){
  2030. $.ajax({
  2031. type: "GET",
  2032. 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 +
  2033. "%7D&_="+ uw.Game.server_time
  2034. });
  2035. }
  2036. function changeWWRanking(html){
  2037. if($('#ranking_inner tr', html)[0].children.length !== 1){ // world wonders existing?
  2038. try {
  2039. var ranking = {}, temp_ally, temp_ally_id, temp_ally_link;
  2040. // Save world wonder ranking into array
  2041. $('#ranking_inner tr', html).each(function(){
  2042. try {
  2043. if(this.children[0].innerHTML){
  2044. temp_ally = this.children[1].children[0].innerHTML; // das hier
  2045. temp_ally_id = this.children[1].children[0].onclick.toString();
  2046. temp_ally_id = temp_ally_id.substring(temp_ally_id.indexOf(",") + 1);
  2047. temp_ally_id = temp_ally_id.substring(0, temp_ally_id.indexOf(")"));
  2048. temp_ally_link = this.children[1].innerHTML;
  2049. } else {
  2050. //World wonder name
  2051. var wonder_name = this.children[3].children[0].innerHTML;
  2052. for(var w in wonderTypes){
  2053. if(wonderTypes.hasOwnProperty(w)){
  2054. if(wonder_name == wonderTypes[w]){
  2055. var level = this.children[4].innerHTML, // world wonder level
  2056. ww_data = JSON.parse(atob(this.children[3].children[0].href.split("#")[1])), wonder_link;
  2057. //console.log(ww_data);
  2058. if(!ranking.hasOwnProperty(level)) {
  2059. // add wonder types
  2060. ranking[level] = {
  2061. colossus_of_rhodes : {},
  2062. great_pyramid_of_giza : {},
  2063. hanging_gardens_of_babylon : {},
  2064. lighthouse_of_alexandria : {},
  2065. mausoleum_of_halicarnassus : {},
  2066. statue_of_zeus_at_olympia : {},
  2067. temple_of_artemis_at_ephesus : {}
  2068. };
  2069. }
  2070. if(!ranking[level][w].hasOwnProperty(temp_ally_id)) {
  2071. ranking[level][w][temp_ally_id] = {}; // add alliance array
  2072. }
  2073. // island coordinates of the world wonder:
  2074. ranking[level][w][temp_ally_id].ix = ww_data.ix;
  2075. ranking[level][w][temp_ally_id].iy = ww_data.iy;
  2076. ranking[level][w][temp_ally_id].sea = this.children[5].innerHTML; // world wonder sea
  2077. wonder_link = this.children[3].innerHTML;
  2078. if(temp_ally.length > 15){
  2079. temp_ally = temp_ally.substring(0,15) + '.';
  2080. }
  2081. wonder_link = wonder_link.substr(0, wonder_link.indexOf(">")+1) + temp_ally +'</a>';
  2082. ranking[level][w][temp_ally_id].ww_link = wonder_link;
  2083. // other data of the world wonder
  2084. ranking[level][w][temp_ally_id].ally_link = temp_ally_link;
  2085. ranking[level][w][temp_ally_id].ally_name = temp_ally; // alliance name
  2086. ranking[level][w][temp_ally_id].name = wonder_name; // world wonder name
  2087. // Save wonder coordinates for wonder icons on map
  2088. if(!wonder.map[w]){
  2089. wonder.map[w] = {};
  2090. }
  2091. wonder.map[w][ww_data.ix + "_" + ww_data.iy] = level;
  2092. saveValue(WID + "_wonder", JSON.stringify(wonder));
  2093. }
  2094. }
  2095. }
  2096. }
  2097. } catch(error){
  2098. errorHandling(error, "changeWWRankingEachFunction");
  2099. }
  2100. });
  2101. //console.log(wonder.map);
  2102. //console.log(ranking);
  2103. if($('#ranking_table_wrapper').get(0)){
  2104. $('#ranking_fixed_table_header').get(0).innerHTML = '<tr>'+
  2105. '<td style="width:10px">#</td>'+
  2106. '<td>Colossus</td>'+
  2107. '<td>Pyramid</td>'+
  2108. '<td>Garden</td>'+
  2109. '<td>Lighthouse</td>'+
  2110. '<td>Mausoleum</td>'+
  2111. '<td>Statue</td>'+
  2112. '<td>Temple</td>'+
  2113. '</tr>';
  2114. $('#ranking_fixed_table_header').css({
  2115. tableLayout: 'fixed',
  2116. width: '100%',
  2117. //paddingLeft: '0px',
  2118. paddingRight: '15px'
  2119. });
  2120. var ranking_substr = '', z = 0;
  2121. for(var level = 10; level >= 1; level--){
  2122. if(ranking.hasOwnProperty(level)){
  2123. var complete = "";
  2124. if(level == 10) { complete = "background: rgba(255, 236, 108, 0.36);"; }
  2125. // Alternate table background color
  2126. if(z == 0){
  2127. ranking_substr += '<tr class="game_table_odd" style="'+ complete +'"><td style="border-right: 1px solid #d0be97;">'+ level +'</td>'; z = 1;
  2128. } else {
  2129. ranking_substr += '<tr class="game_table_even" style="'+ complete +'"><td style="border-right: 1px solid #d0be97;">'+ level +'</td>'; z = 0;
  2130. }
  2131. for(var w in ranking[level]){
  2132. if(ranking[level].hasOwnProperty(w)){
  2133. ranking_substr += '<td>';
  2134. for(var a in ranking[level][w]){
  2135. if(ranking[level][w].hasOwnProperty(a)){
  2136. ranking_substr += '<nobr>' + ranking[level][w][a].ww_link + '</nobr><br />'; // ww link
  2137. }
  2138. }
  2139. ranking_substr += '</td>';
  2140. }
  2141. }
  2142. ranking_substr += '</tr>';
  2143. }
  2144. }
  2145. var ranking_str = '<table id="ranking_endless_scroll" class="game_table" cellspacing="0"><tr>'+
  2146. '<td style="width:10px;border-right: 1px solid #d0be97;"></td>'+
  2147. '<td><div class="dio_wonder" style="background:'+ worldWonderIcon.colossus_of_rhodes +';margin-left:26px"></div></td>'+ // Colossus
  2148. '<td><div class="dio_wonder" style="background:'+ worldWonderIcon.great_pyramid_of_giza +';margin-left:19px"></div></td>'+ // Pyramid
  2149. '<td><div class="dio_wonder" style="background:'+ worldWonderIcon.hanging_gardens_of_babylon +';margin-left:19px"></div></td>'+ // Garden
  2150. '<td><div class="dio_wonder" style="background:'+ worldWonderIcon.lighthouse_of_alexandria +';margin-left:24px"></div></td>'+ // Lighthouse
  2151. '<td><div class="dio_wonder" style="background:'+ worldWonderIcon.mausoleum_of_halicarnassus +';margin-left:25px"></div></td>'+ // Mausoleum
  2152. '<td><div class="dio_wonder" style="background:'+ worldWonderIcon.statue_of_zeus_at_olympia +';margin-left:25px"></div></td>'+ // Statue
  2153. '<td><div class="dio_wonder" style="background:'+ worldWonderIcon.temple_of_artemis_at_ephesus +';margin-left:22px"></div></td>'+ // Temple
  2154. '</tr>'+ ranking_substr + '</table>';
  2155. $('#ranking_table_wrapper').get(0).innerHTML = ranking_str;
  2156. $('#ranking_endless_scroll .dio_wonder').css({
  2157. width: "65px", height: "60px",
  2158. backgroundSize: "auto 100%",
  2159. backgroundPosition: "64px 0px"
  2160. });
  2161. $('#ranking_endless_scroll').css({
  2162. tableLayout: 'fixed',
  2163. width: '100%',
  2164. overflowY: 'auto',
  2165. overflowX: 'hidden',
  2166. fontSize: '0.7em',
  2167. lineHeight: '2'
  2168. });
  2169. $('#ranking_endless_scroll tbody').css({
  2170. verticalAlign: 'text-top'
  2171. });
  2172. $('#ranking_table_wrapper img').css({
  2173. width: "60px"
  2174. });
  2175. $('#ranking_table_wrapper').css({
  2176. overflowY: 'scroll'
  2177. });
  2178. }
  2179. } catch(error){
  2180. errorHandling(error, "changeWWRanking");
  2181. }
  2182. }
  2183. if($('.wonder_ranking').get(0)) {
  2184. $('.wonder_ranking').get(0).style.display = "block";
  2185. }
  2186. }
  2187. /*******************************************************************************************************************************
  2188. * World Wonder
  2189. * ----------------------------------------------------------------------------------------------------------------------------
  2190. * | ● click adjustment
  2191. * | ● Share calculation (= ratio of player points to alliance points)
  2192. * | ● Resources calculation & counter (stores amount)
  2193. * | ● Adds missing previous & next buttons on finished world wonders (better browsing through world wonders)
  2194. * ----------------------------------------------------------------------------------------------------------------------------
  2195. *******************************************************************************************************************************/
  2196. // getPointRatio: Default
  2197. function getPointRatioFromAllianceProfile(){
  2198. if(AID){
  2199. $.ajax({
  2200. type: "GET",
  2201. 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 +
  2202. '%2C%22nlreq_id%22%3A'+ uw.Game.notification_last_requested_id + '%7D&_='+ uw.Game.server_time,
  2203. success: function(text) {
  2204. try {
  2205. text = text.substr(text.indexOf("/li")+14).substr(0, text.indexOf("\ "));
  2206. var AP = parseInt(text, 10);
  2207. wonder.ratio[AID] = 100 / AP * uw.Game.player_points;
  2208. saveValue(WID + "_wonder", JSON.stringify(wonder));
  2209. } catch(error){
  2210. errorHandling(error, "getPointRatioFromAllianceProfile");
  2211. }
  2212. }
  2213. });
  2214. } else {
  2215. wonder.ratio[AID] = -1;
  2216. saveValue(WID + "_wonder", JSON.stringify(wonder));
  2217. }
  2218. }
  2219. function getPointRatioFromAllianceRanking(){
  2220. try {
  2221. if(AID && $('.current_player .r_points').get(0)){
  2222. wonder.ratio[AID] = 100 / parseInt($('.current_player .r_points').get(0).innerHTML, 10) * uw.Game.player_points;
  2223. saveValue(WID + "_wonder", JSON.stringify(wonder));
  2224. }
  2225. } catch(error){
  2226. errorHandling(error, "getPointRatioFromAllianceRaking");
  2227. }
  2228. }
  2229. function getPointRatioFromAllianceMembers(){
  2230. try {
  2231. var ally_points = 0;
  2232. $('#ally_members_body tr').each(function(){
  2233. ally_points += parseInt($(this).children().eq(2).text(), 10) || 0;
  2234. });
  2235. wonder.ratio[AID] = 100 / ally_points * uw.Game.player_points;
  2236. saveValue(WID + "_wonder", JSON.stringify(wonder));
  2237. } catch(error){
  2238. errorHandling(error, "getPointRatioFromAllianceMembers");
  2239. }
  2240. }
  2241. // TODO: Split function...
  2242. function getResWW(){
  2243. try {
  2244. var wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_WONDERS);
  2245. for(var e in wndArray){
  2246. if(wndArray.hasOwnProperty(e)){
  2247. var wndID = "#gpwnd_" + wndArray[e].getID() + " ";
  2248. if($(wndID + '.wonder_progress').get(0)){
  2249. var res = 0,
  2250. ww_share = {total: {share:0, sum:0}, stage: {share:0, sum:0}},
  2251. ww_type = $(wndID + '.finished_image_small').attr('src').split("/")[6].split("_")[0], // Which world wonder?
  2252. res_stages = [ 2, 4, 6, 10, 16, 28, 48, 82, 140, 238], // Rohstoffmenge pro Rohstofftyp in 100.000 Einheiten
  2253. stage = parseInt($(wndID + '.wonder_expansion_stage span').get(0).innerHTML.split("/")[0], 10) + 1, // Derzeitige Füllstufe
  2254. speed = uw.Game.game_speed;
  2255. wonder.storage[AID] = wonder.storage[AID] || {};
  2256. wonder.storage[AID][ww_type] = wonder.storage[AID][ww_type] || {};
  2257. wonder.storage[AID][ww_type][stage] = wonder.storage[AID][ww_type][stage] || 0;
  2258. if(!$(wndID + '.ww_ratio').get(0)) {
  2259. $('<fieldset class="ww_ratio"></fieldset>').appendTo(wndID + '.wonder_res_container .trade');
  2260. $(wndID + '.wonder_header').prependTo(wndID + '.wonder_progress');
  2261. $(wndID + '.wonder_res_container .send_res').insertBefore(wndID + '.wonder_res_container .next_level_res');
  2262. }
  2263. $(wndID + '.wonder_progress').css({
  2264. margin: '0 auto 5px'
  2265. });
  2266. $(wndID + '.wonder_header').css({
  2267. textAlign: 'left',
  2268. margin: '10px -8px 12px 3px'
  2269. });
  2270. $(wndID + '.build_wonder_icon').css({
  2271. top: '25px',
  2272. });
  2273. $(wndID + '.wonder_progress_bar').css({
  2274. top: '54px',
  2275. });
  2276. $(wndID + '.wonder_controls').css({
  2277. height: '380px',
  2278. });
  2279. $(wndID + '.trade fieldset').css({
  2280. float: 'right',
  2281. });
  2282. $(wndID + '.wonder_res_container').css({
  2283. right: '29px'
  2284. });
  2285. $(wndID + '.ww_ratio').css({
  2286. position: 'relative',
  2287. height: 'auto'
  2288. });
  2289. $(wndID + 'fieldset').css({
  2290. height: 'auto'
  2291. });
  2292. $(wndID + '.town-capacity-indicator').css({
  2293. marginTop: '0px'
  2294. });
  2295. for(var d in res_stages){
  2296. if(res_stages.hasOwnProperty(d)){
  2297. ww_share.total.sum += res_stages[d];
  2298. }
  2299. }
  2300. ww_share.total.sum *= speed * 300000;
  2301. ww_share.total.share = parseInt(wonder.ratio[AID] * (ww_share.total.sum / 100), 10);
  2302. ww_share.stage.sum = speed * res_stages[stage-1] * 300000;
  2303. ww_share.stage.share = parseInt(wonder.ratio[AID] * (ww_share.stage.sum / 100), 10); // ( 3000 = 3 Rohstofftypen * 100000 Rohstoffe / 100 Prozent)
  2304. setResWW(stage, ww_type, ww_share, wndID);
  2305. $(wndID + '.wonder_res_container .send_resources_btn').click(function(e){
  2306. try {
  2307. wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_wood input:text').get(0).value, 10);
  2308. wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_stone input:text').get(0).value, 10);
  2309. wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_iron input:text').get(0).value, 10);
  2310. setResWW(stage, ww_type, ww_share, wndID);
  2311. saveValue(WID + "_wonder", JSON.stringify(wonder));
  2312. } catch(error){
  2313. errorHandling(error, "getResWW_Click");
  2314. }
  2315. });
  2316. } else {
  2317. $('<div class="prev_ww pos_Y"></div><div class="next_ww pos_Y"></div>').appendTo(wndID + '.wonder_controls');
  2318. $(wndID + '.wonder_finished').css({ width: '100%' });
  2319. $(wndID + '.pos_Y').css({
  2320. top: '-266px',
  2321. });
  2322. }
  2323. }
  2324. }
  2325. } catch(error){
  2326. errorHandling(error, "getResWW");
  2327. }
  2328. }
  2329. function setResWW(stage, ww_type, ww_share, wndID){
  2330. try {
  2331. var width_stage, width_total, res_total = 0, disp_stage = "none", disp_total = "none";
  2332. for(var z in wonder.storage[AID][ww_type]){
  2333. if(wonder.storage[AID][ww_type].hasOwnProperty(z)){
  2334. res_total += wonder.storage[AID][ww_type][z];
  2335. }
  2336. }
  2337. if(ww_share.stage.share > wonder.storage[AID][ww_type][stage]){
  2338. width_stage = (242 / ww_share.stage.share) * wonder.storage[AID][ww_type][stage];
  2339. } else {
  2340. width_stage = 0;
  2341. disp_stage = "block";
  2342. }
  2343. if(ww_share.total.share > res_total){
  2344. width_total = (242 / ww_share.total.share) * res_total;
  2345. } else {
  2346. width_total = 0;
  2347. disp_total = "block";
  2348. }
  2349. $(wndID + '.ww_ratio').get(0).innerHTML = "";
  2350. $(wndID + '.ww_ratio').append('<legend>'+ getText("labels", "leg") +' (<span style="color:#090">'+ (Math.round(wonder.ratio[AID] * 100) / 100) +'%</span>):</legend>'+
  2351. '<div class="town-capacity-indicator">'+
  2352. '<div class="icon all_res"></div>'+
  2353. '<div id="ww_town_capacity_stadium" class="tripple-progress-progressbar">'+
  2354. '<div class="border_l"></div><div class="border_r"></div><div class="body"></div>'+
  2355. '<div class="progress overloaded">'+
  2356. '<div class="indicator3" style="left: 0px; width:'+ width_stage +'px"></div>'+
  2357. '<span class="ww_perc">' + Math.round(wonder.storage[AID][ww_type][stage]/ww_share.stage.share*100) + '%</span>'+
  2358. '<div class="indicator4" style="left: 0px; display:'+ disp_stage +'"></div>'+
  2359. '</div>'+
  2360. '<div class="amounts">'+ getText("labels", "stg") +': <span class="curr">'+ pointNumber(wonder.storage[AID][ww_type][stage]) +'</span> / '+
  2361. '<span class="max">'+ pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) +'</span></div>'+
  2362. '</div></div>'+
  2363. '<div class="town-capacity-indicator">'+
  2364. '<div class="icon all_res"></div>'+
  2365. '<div id="ww_town_capacity_total" class="tripple-progress-progressbar">'+
  2366. '<div class="border_l"></div><div class="border_r"></div><div class="body"></div>'+
  2367. '<div class="progress overloaded">'+
  2368. '<div class="indicator3" style="left: 0px; width:'+ width_total +'px;"></div>'+
  2369. '<span class="ww_perc">'+ Math.round(res_total/ww_share.total.share*100) +'%</span>'+
  2370. '<div class="indicator4" style="left: 0px; display:'+ disp_total +'"></div>'+
  2371. '</div>'+
  2372. '<div class="amounts">'+ getText("labels", "tot") +': <span class="curr">'+ pointNumber(res_total) +'</span> / '+
  2373. '<span class="max">'+ pointNumber((Math.round(ww_share.total.share / 1000) * 1000)) +'</span></div>'+
  2374. '</div></div>');
  2375. $('.ww_ratio .progress').css({
  2376. lineHeight: '1',
  2377. color: 'white',
  2378. fontSize: '0.8em'
  2379. });
  2380. $(wndID + '.ww_perc').css({
  2381. position:'absolute',
  2382. width:'242px',
  2383. textAlign: 'center'
  2384. });
  2385. $(wndID + '.indicator4').css({
  2386. background: 'url(http://gpde.innogamescdn.com/images/game/layout/progressbars-sprite_2.53.png) no-repeat 0 0',
  2387. backgroundPosition: '0px -355px',
  2388. height: '10px',
  2389. zIndex: '13000',
  2390. width: '242px'
  2391. });
  2392. $(wndID + '.all_res').css({
  2393. background: 'url(http://de.cdn.grepolis.com/images/game/layout/resources_2.32.png) no-repeat 0 -90px',
  2394. width: '30px',
  2395. height: '30px',
  2396. margin: '0 auto',
  2397. marginLeft: '5px'
  2398. });
  2399. $(wndID + '.town-capacity-indicator').css({
  2400. marginTop: '0px'
  2401. });
  2402. $(wndID + '.ww_ratio').tooltip("<table style='border-spacing:0px; text-align:right' cellpadding='5px'><tr>"+
  2403. "<td align='right' style='border-right: 1px solid;border-bottom: 1px solid'></td>"+
  2404. "<td style='border-right: 1px solid; border-bottom: 1px solid'><span class='bbcodes_player bold'>("+ (Math.round((wonder.ratio[AID]) * 100) / 100) +"%)</span></td>"+
  2405. "<td style='border-bottom: 1px solid'><span class='bbcodes_ally bold'>(100%)</span></td></tr>"+
  2406. "<tr><td class='bold' style='border-right:1px solid;text-align:center'>"+ getText("labels", "stg") + "&nbsp;" + stage +"</td>"+
  2407. "<td style='border-right: 1px solid'>"+ pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) +"</td>"+
  2408. "<td>" + pointNumber(Math.round(ww_share.stage.sum / 1000) * 1000) + "</td></tr>"+
  2409. "<tr><td class='bold' style='border-right:1px solid;text-align:center'>"+ getText("labels", "tot") +"</td>"+
  2410. "<td style='border-right: 1px solid'>"+ pointNumber(Math.round(ww_share.total.share / 1000) * 1000) +"</td>"+
  2411. "<td>"+ pointNumber(Math.round(ww_share.total.sum / 1000) * 1000) +"</td>"+
  2412. "</tr></table>");
  2413. } catch(error){
  2414. errorHandling(error, "setResWW");
  2415. }
  2416. }
  2417. // Adds points to numbers
  2418. function pointNumber(number) {
  2419. var sep; if(LID === "de"){ sep = "."; } else { sep = ",";}
  2420. number = number.toString();
  2421. if (number.length > 3) {
  2422. var mod = number.length % 3;
  2423. var output = (mod > 0 ? (number.substring(0,mod)) : '');
  2424. for (var i=0 ; i < Math.floor(number.length / 3); i++) {
  2425. if ((mod == 0) && (i == 0)) {
  2426. output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
  2427. } else {
  2428. output+= sep + number.substring(mod + 3 * i, mod + 3 * i + 3);
  2429. }
  2430. }
  2431. number = output;
  2432. }
  2433. return number;
  2434. }
  2435. /*******************************************************************************************************************************
  2436. * Farming Village Overview
  2437. * ----------------------------------------------------------------------------------------------------------------------------
  2438. * | ● Color change on possibility of city festivals
  2439. * ----------------------------------------------------------------------------------------------------------------------------
  2440. * *****************************************************************************************************************************/
  2441. function changeResColor(){
  2442. var res, res_min, i = 0;
  2443. $('#fto_town_list .fto_resource_count :last-child').reverseList().each(function(){
  2444. if($(this).parent().hasClass("stone")){
  2445. res_min = 18000;
  2446. } else {
  2447. res_min = 15000;
  2448. }
  2449. res = parseInt($(this).get(0).innerHTML, 10);
  2450. if((res >= res_min) && !($(this).hasClass("town_storage_full"))){
  2451. $(this).get(0).style.color = '#0A0';
  2452. }
  2453. if(res < res_min){
  2454. $(this).get(0).style.color = '#000';
  2455. }
  2456. });
  2457. }
  2458. /********************************************************************************************************************************
  2459. * Conquest Info
  2460. * -----------------------------------------------------------------------------------------------------------------------------
  2461. * | ● Amount of supports und attacks in the conquest window
  2462. * | ● Layout adjustment (for reasons of clarity)
  2463. * | - TODO: conquest window of own cities
  2464. * -----------------------------------------------------------------------------------------------------------------------------
  2465. * ******************************************************************************************************************************/
  2466. function countMovements(){
  2467. var i = 0, a = 0;
  2468. $('#unit_movements .support').each(function(){
  2469. i++;
  2470. });
  2471. $('#unit_movements .attack_land, #unit_movements .attack_sea, #unit_movements .attack_takeover').each(function(){
  2472. a++;
  2473. });
  2474. var str = "<div style='position: absolute;width: 100px;margin-top: -16px;left: 40%;'><div style='float:left;margin-right:5px;'></div>"+
  2475. "<div class='troops' id='count_def'></div>"+
  2476. "<div class='troops' style='color:green;'> " + i + "</div>"+
  2477. "<div class='troops' id='count_off'> </div>"+
  2478. "<div style='color:red;'> " + a + "</div></div>"+
  2479. "<hr class='move_hr'>";
  2480. if($('.gpwindow_content .tab_content .bold').get(0)){
  2481. $('.gpwindow_content .tab_content .bold').append(str);
  2482. } else {
  2483. $('.gpwindow_content h4:eq(1)').append(str);
  2484. // TODO: set player link ?
  2485. /*
  2486. $('#unit_movements li div').each(function(){
  2487. //console.log($(this).get(0).innerHTML);
  2488. });
  2489. */
  2490. }
  2491. $('.move_hr').css({
  2492. margin: '7px 0px 0px 0px',
  2493. backgroundColor: '#5F5242',
  2494. height: '2px',
  2495. border: '0px solid'
  2496. });
  2497. // smaller movements
  2498. $('#unit_movements').css({
  2499. fontSize: '0.80em'
  2500. });
  2501. $('.incoming').css({
  2502. width: '150px',
  2503. height: '45px',
  2504. float: 'left'
  2505. });
  2506. $('#unit_movements div').each(function(){
  2507. if($(this).attr('class') === "unit_movements_arrow"){
  2508. // delete placeholder for arrow of outgoing movements (there are no outgoing movements)
  2509. if(!$(this).get(0).style.background) { $(this).get(0).remove(); }
  2510. } else {
  2511. // realign texts
  2512. $(this).css({
  2513. margin: '3px',
  2514. paddingLeft: '3px'
  2515. });
  2516. }
  2517. });
  2518. $('.troops').css({
  2519. float: 'left',
  2520. margin: '0px 5px 0px 0px',
  2521. height:'18px',
  2522. width:'18px',
  2523. position: 'relative'
  2524. });
  2525. $('#count_def').css({
  2526. background: 'url(http://de.cdn.grepolis.com/images/game/place/losts.png)',
  2527. backgroundPosition: '0 -36px'
  2528. });
  2529. $('#count_off').css({
  2530. background: 'url(http://de.cdn.grepolis.com/images/game/place/losts.png)',
  2531. backgroundPosition: '0 0px'
  2532. });
  2533. }
  2534. /*******************************************************************************************************************************
  2535. * Town window
  2536. * ----------------------------------------------------------------------------------------------------------------------------
  2537. * | ● TownTabHandler (trade, attack, support,...)
  2538. * | ● Sent units box
  2539. * | ● Short duration: Display of 30% troop speed improvement in attack/support tab
  2540. * | ● Trade options:
  2541. * | - Ressource marks on possibility of city festivals
  2542. * | - Percentual Trade: Trade button
  2543. * | - Recruiting Trade: Selection boxes (ressource ratio of unit type + share of the warehouse capacity of the target town)
  2544. * ----------------------------------------------------------------------------------------------------------------------------
  2545. *******************************************************************************************************************************/
  2546. var arrival_interval = {};
  2547. // TODO: Change both functions in MultipleWindowHandler()
  2548. function TownTabHandler(action){
  2549. var wndArray, wndID, wndA;
  2550. wndArray = Layout.wnd.getOpen(uw.Layout.wnd.TYPE_TOWN);
  2551. //console.log(wndArray);
  2552. for(var e in wndArray){
  2553. if(wndArray.hasOwnProperty(e)){
  2554. //console.log(wndArray[e].getHandler());
  2555. wndA = wndArray[e].getAction(); wndID = "#gpwnd_" + wndArray[e].getID() + " ";
  2556. if(!$(wndID).get(0)) {
  2557. wndID = "#gpwnd_" + (wndArray[e].getID() + 1) + " ";
  2558. }
  2559. //console.log(wndID);
  2560. if(wndA === action){
  2561. switch(action){
  2562. case "trading":
  2563. if($(wndID + '#trade_tab').get(0)){
  2564. if(!$(wndID + '.rec_trade').get(0)){
  2565. addRecTrade(wndID);
  2566. }
  2567. if(!($(wndID + '.btn_trade').get(0))){
  2568. addPercentTrade(wndID, false);
  2569. }
  2570. }
  2571. //addTradeMarks(wndID, 15, 18, 15, "red"); // town festival
  2572. break;
  2573. case "support": case "attack":
  2574. //if(!arrival_interval[wndID]){
  2575. if(DATA.options.way && !($('.js-casted-powers-viewport .unit_movement_boost').get(0) || $(wndID + '.short_duration').get(0))){
  2576. //if(arrival_interval[wndID]) console.log("add " + wndID);
  2577. addShortDuration(wndID);
  2578. }
  2579. if(DATA.options.sen){
  2580. addSentUnitsBox(wndID, action);
  2581. }
  2582. //}
  2583. break;
  2584. case "rec_mark":
  2585. //addTradeMarks(wndID, 15, 18, 15, "lime");
  2586. break;
  2587. }
  2588. }
  2589. }
  2590. }
  2591. }
  2592. function WWTradeHandler(){
  2593. var wndArray, wndID, wndA;
  2594. wndArray = uw.GPWindowMgr.getOpen(uw.GPWindowMgr.TYPE_WONDERS);
  2595. for(var e in wndArray){
  2596. if(wndArray.hasOwnProperty(e)){
  2597. wndID = "#gpwnd_" + wndArray[e].getID() + " ";
  2598. if(!($(wndID + '.btn_trade').get(0) || $(wndID +'.next_building_phase').get(0) || $(wndID +'#ww_time_progressbar').get(0))){
  2599. addPercentTrade(wndID, true);
  2600. }
  2601. }
  2602. }
  2603. }
  2604. /*******************************************************************************************************************************
  2605. * ● Sent units box
  2606. *******************************************************************************************************************************/
  2607. function addSentUnitsBox(wndID, action){
  2608. if(!$(wndID + '.sent_units_box').get(0)){
  2609. $('<div class="game_inner_box sent_units_box '+ action +'"><div class="game_border ">'+
  2610. '<div class="game_border_top"></div><div class="game_border_bottom"></div><div class="game_border_left"></div><div class="game_border_right"></div>'+
  2611. '<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>'+
  2612. '<div class="game_header bold">'+
  2613. '<div class="icon_sent townicon_'+ (action == "attack" ? "lo" : "ld") +'"></div><span>'+ getText("labels", "lab") +' ('+ (action == "attack" ? "OFF" : "DEF") +')</span>'+
  2614. '</div>'+
  2615. '<div class="troops"><div class="units_list"></div><hr style="width: 172px;border: 1px solid rgb(185, 142, 93);margin: 3px 0px 2px -1px;">'+
  2616. '<div id="btn_sent_units_reset" class="button_new">'+
  2617. '<div class="left"></div>'+
  2618. '<div class="right"></div>'+
  2619. '<div class="caption js-caption">'+ getText("buttons", "res") +'<div class="effect js-effect"></div></div>'+
  2620. '</div>'+
  2621. '</div></div>').appendTo(wndID + '.attack_support_window');
  2622. updateSentUnitsBox(action);
  2623. $(wndID + '.icon_sent').css({
  2624. height: '20px',
  2625. marginTop: '-2px',
  2626. width: '20px',
  2627. backgroundPositionY: '-26px',
  2628. paddingLeft: '0px',
  2629. marginLeft: '0px'
  2630. });
  2631. $(wndID + '.sent_units_box').css({
  2632. position: 'absolute',
  2633. right: '0px',
  2634. bottom: '16px',
  2635. width: '192px',
  2636. //border: '2px solid green',
  2637. //borderRadius: '5px',
  2638. //padding: '5px'
  2639. });
  2640. $(wndID + '.troops').css({ padding: '6px 0px 6px 6px' });
  2641. $(wndID + '#btn_sent_units_reset').click(function(){
  2642. // Overwrite old array
  2643. sentUnitsArray[action] = {}; updateSentUnitsBox(action);
  2644. });
  2645. }
  2646. }
  2647. function getSentUnits(){
  2648. $.Observer(uw.GameEvents.command.send_unit).subscribe('DIO_SEND_UNITS', function(e,data){
  2649. try {
  2650. for(var z in data.params){
  2651. if(data.params.hasOwnProperty(z) && (data.sending_type !== "")){
  2652. if(uw.GameData.units[z]){
  2653. sentUnitsArray[data.sending_type][z] = (sentUnitsArray[data.sending_type][z] == undefined ? 0 : sentUnitsArray[data.sending_type][z]);
  2654. sentUnitsArray[data.sending_type][z] += data.params[z];
  2655. }
  2656. }
  2657. }
  2658. //updateSentUnitsBox(data.sending_type);
  2659. } catch(error){
  2660. errorHandling(error, "getSentUnits");
  2661. }
  2662. });
  2663. }
  2664. function updateSentUnitsBox(action){
  2665. try {
  2666. // Remove old unit list
  2667. $('.sent_units_box.'+ action +' .units_list').each(function(){
  2668. $(this).get(0).innerHTML = "";
  2669. });
  2670. // Add new unit list
  2671. for(var x in sentUnitsArray[action]){
  2672. if(sentUnitsArray[action].hasOwnProperty(x)){
  2673. if((sentUnitsArray[action][x] || 0) > 0){
  2674. $('.sent_units_box.'+ action +' .units_list').each(function(){
  2675. $(this).append('<div class="unit_icon25x25 '+ x +
  2676. (sentUnitsArray[action][x] >= 1000 ? (sentUnitsArray[action][x] >= 10000 ? " five_digit_number" : " four_digit_number") : "") +'">'+
  2677. '<span class="count text_shadow">'+ sentUnitsArray[action][x] +'</span>'+
  2678. '</div>');
  2679. });
  2680. }
  2681. }
  2682. }
  2683. saveValue(WID +"_sentUnits", JSON.stringify(sentUnitsArray));
  2684. } catch(error){
  2685. errorHandling(error, "updateSentUnitsBox");
  2686. }
  2687. }
  2688. /*******************************************************************************************************************************
  2689. * ● Short duration
  2690. *******************************************************************************************************************************/
  2691. function addShortDuration(wndID){
  2692. //console.log($(wndID + ".duration_container").get(0));
  2693. try {
  2694. //var tooltip = (LANG.hasOwnProperty(LID) ? getText("labels", "improved_movement") : "") + " (+30% "+ DM.getl10n("common", "barracks_and_docs").tooltips.speed.trim() + ")";
  2695. var tooltip = (LANG.hasOwnProperty(LID) ? getText("labels", "improved_movement") : "") + " (+30%)";
  2696. $('<table class="dio_duration">'+
  2697. '<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>'+
  2698. '<tr class="short_duration_row" style="color:darkgreen">'+
  2699. '<td>&nbsp;╚&gt;&nbsp;</td><td><span class="short_duration">~0:00:00</span></td>'+
  2700. '<td>&nbsp;&nbsp;&nbsp;╚&gt;</td><td><span class="short_arrival">~00:00:00</span></td>'+
  2701. '<td class="short_icon"></td><td></td></tr>'+
  2702. '</table>').prependTo(wndID + ".duration_container");
  2703. $(wndID + ".nightbonus").appendTo(wndID + ".dio_night");
  2704. $(wndID + '.way_duration').appendTo(wndID + ".dio_way");
  2705. $(wndID + ".arrival_time").appendTo(wndID + ".dio_arrival");
  2706. // Style
  2707. $(wndID + '.duration_container').css({
  2708. width:'auto'
  2709. });
  2710. $(wndID + '.dio_duration').css({
  2711. borderSpacing: '0px',
  2712. marginBottom: '2px',
  2713. textAlign: 'right'
  2714. });
  2715. $(wndID + '.dio_way span,'+ wndID + '.dio_arrival span').css({
  2716. padding: '0px 0px 0px 0px',
  2717. background: 'none'
  2718. });
  2719. $(wndID + '.short_icon').css({
  2720. padding: '20px 0px 0px 30px',
  2721. background: 'url(http://666kb.com/i/ck2c7eohpyfa3yczt.png) 11px -1px / 21px no-repeat',
  2722. WebkitFilter: 'hue-rotate(50deg)'
  2723. });
  2724. $(wndID + '.way_icon').css({
  2725. padding: '30px 0px 0px 30px',
  2726. background: 'transparent url(http://gpde.innogamescdn.com/images/game/towninfo/traveltime.png) no-repeat 0 0'
  2727. });
  2728. $(wndID + '.arrival_icon').css({
  2729. padding: '30px 0px 0px 30px',
  2730. background: 'transparent url(http://gpde.innogamescdn.com/images/game/towninfo/arrival.png) no-repeat 0 0'
  2731. });
  2732. $(wndID + '.max_booty').css({
  2733. padding: '0px 0px 0px 30px',
  2734. margin: '3px 0 4px 4px',
  2735. width: 'auto'
  2736. });
  2737. $(wndID + '.fast_boats_needed').css({
  2738. background: 'transparent url(http://s7.directupload.net/images/140724/4pvfuch8.png) no-repeat 0 0',
  2739. padding: '2px 10px 7px 24px',
  2740. margin: '0px 0px 0px 6px'
  2741. });
  2742. $(wndID + '.slow_boats_needed').css({
  2743. background: 'transparent url(http://s1.directupload.net/images/140724/b5xl8nmj.png) no-repeat 0 0',
  2744. padding: '2px 10px 7px 24px',
  2745. margin: '0px 0px 0px 6px'
  2746. });
  2747. // Tooltip
  2748. $(wndID + '.short_duration_row').tooltip(tooltip);
  2749. // Detection of changes
  2750. changeShortDuration(wndID);
  2751. /*
  2752. $(wndID + '.way_duration').bind('DOMSubtreeModified', function(e) { console.log(e); }); // Alternative
  2753. */
  2754. } catch(error){
  2755. errorHandling(error, "addShortDuration");
  2756. }
  2757. }
  2758. function changeShortDuration(wndID){
  2759. var duration = new MutationObserver(function(mutations) {
  2760. mutations.forEach(function(mutation) {
  2761. if(mutation.addedNodes[0]){
  2762. //console.log(mutation);
  2763. calcShortDuration(wndID);
  2764. }
  2765. });
  2766. });
  2767. if($(wndID + '.way_duration').get(0)){
  2768. duration.observe($(wndID + '.way_duration').get(0), { attributes: false, childList: true, characterData: false});
  2769. }
  2770. }
  2771. //$('<style> .duration_container { display: block !important } </style>').appendTo("head");
  2772. function calcShortDuration(wndID){
  2773. //console.log(wndID);
  2774. //console.log($(wndID + '.duration_container .way_duration').get(0));
  2775. try {
  2776. var setup_time = 900/uw.Game.game_speed,
  2777. duration_time = $(wndID + '.duration_container .way_duration').get(0).innerHTML.replace("~","").split(":"),
  2778. // TODO: hier tritt manchmal Fehler auf TypeError: Cannot read property "innerHTML" of undefined at calcShortDuration (<anonymous>:3073:86)
  2779. arrival_time,
  2780. h,m,s;
  2781. duration_time = (((parseInt(duration_time[0], 10)*60 + parseInt(duration_time[1], 10))*60 + parseInt(duration_time[2], 10) - setup_time) / 1.3) + setup_time;
  2782. h = Math.floor(duration_time/3600);
  2783. m = Math.floor((duration_time - h*3600)/60);
  2784. s = Math.floor(duration_time - h*3600 - m*60);
  2785. if(m < 10) { m = "0" + m; }
  2786. if(s < 10) { s = "0" + s; }
  2787. $(wndID + '.short_duration').get(0).innerHTML = "~"+ h +":" + m + ":" + s;
  2788. arrival_time = Math.round((Timestamp.server() + Game.server_gmt_offset)) + duration_time;
  2789. h = Math.floor(arrival_time/3600);
  2790. m = Math.floor((arrival_time - h*3600)/60);
  2791. s = Math.floor(arrival_time - h*3600 - m*60);
  2792. h %= 24;
  2793. if(m < 10) { m = "0" + m; }
  2794. if(s < 10) { s = "0" + s; }
  2795. $(wndID + '.short_arrival').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
  2796. clearInterval(arrival_interval[wndID]);
  2797. arrival_interval[wndID] = setInterval(function(){
  2798. arrival_time += 1;
  2799. h = Math.floor(arrival_time/3600);
  2800. m = Math.floor((arrival_time - h*3600)/60);
  2801. s = Math.floor(arrival_time - h*3600 - m*60);
  2802. h %= 24;
  2803. if(m < 10) { m = "0" + m; }
  2804. if(s < 10) { s = "0" + s; }
  2805. if($(wndID + '.short_arrival').get(0)){
  2806. $(wndID + '.short_arrival').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
  2807. } else {
  2808. clearInterval(arrival_interval[wndID]);
  2809. }
  2810. }, 1000);
  2811. } catch(error){
  2812. errorHandling(error, "calcShortDuration");
  2813. }
  2814. }
  2815. /*******************************************************************************************************************************
  2816. * ● Dropdown menu
  2817. *******************************************************************************************************************************/
  2818. // Preload images for drop down arrow buttons
  2819. var drop_over = new Image(); drop_over.src = "http://s7.directupload.net/images/140107/hna95u8a.png";
  2820. var drop_out = new Image(); drop_out.src = "http://s14.directupload.net/images/140107/ppsz5mxk.png";
  2821. function changeDropDownButton(){
  2822. /*
  2823. $('<style type="text/css">' +
  2824. '#dd_filter_type .arrow, .select_rec_unit .arrow {' +
  2825. 'width: 18px !important; height: 17px !important; background: url("http://s14.directupload.net/images/140107/ppsz5mxk.png") no-repeat 0px -1px !important;' +
  2826. 'position: absolute; top: 2px !important; right: 3px;' +
  2827. '</style>').appendTo('head');
  2828. */
  2829. $('.arrow').css({
  2830. width: '18px',
  2831. height: '17px',
  2832. background: 'url('+ drop_out.src +') no-repeat -1px -1px',
  2833. position: 'absolute',
  2834. top: '2px',
  2835. right: '3px'
  2836. });
  2837. }
  2838. var o = 1; // ????????????????????????????
  2839. /*******************************************************************************************************************************
  2840. * ● Recruiting Trade
  2841. * *****************************************************************************************************************************/
  2842. var trade_count = 0, unit = "FS", percent = "0.0"; // Recruiting Trade
  2843. function addRecTrade(wndID){
  2844. var max_amount;
  2845. $('<div class="rec_trade">'+
  2846. // DropDown-Button for unit
  2847. '<div class="drop_rec_unit dropdown default">'+
  2848. '<div class="border-left"></div>'+
  2849. '<div class="border-right"></div>'+
  2850. '<div class="caption" name="'+ unit +'">'+ unit +'</div>'+
  2851. '<div class="arrow"></div>'+
  2852. '</div>'+
  2853. '<div class="drop_rec_perc dropdown default">'+
  2854. // DropDown-Button for ratio
  2855. '<div class="border-left"></div>'+
  2856. '<div class="border-right"></div>'+
  2857. '<div class="caption" name="'+ percent +'">'+ Math.round(percent * 100)+'%</div>'+
  2858. '<div class="arrow"></div>'+
  2859. '</div></div><span class="rec_count" style="top:30px">('+ trade_count +')</span>').appendTo(wndID + ".content");
  2860. // Select boxes for unit and ratio
  2861. $('<div class="select_rec_unit dropdown-list default active">'+
  2862. '<div class="item-list">'+
  2863. '<div class="option_s unit index_unit unit_icon40x40 attack_ship" name="FS"></div>'+
  2864. '<div class="option_s unit index_unit unit_icon40x40 bireme" name="BI"></div>'+
  2865. '<div class="option_s unit index_unit unit_icon40x40 sword" name="SK"></div>'+
  2866. '<div class="option_s unit index_unit unit_icon40x40 slinger" name="SL"></div>'+
  2867. '<div class="option_s unit index_unit unit_icon40x40 archer" name="BS"></div>'+
  2868. '<div class="option_s unit index_unit unit_icon40x40 hoplite" name="HO"></div>'+
  2869. '<div class="option_s unit index_unit unit_icon40x40 rider" name="RE"></div>'+
  2870. '<div class="option_s unit index_unit unit_icon40x40 chariot" name="SW"></div>'+
  2871. '</div></div>').appendTo(wndID + ".rec_trade");
  2872. $('<div class="select_rec_perc dropdown-list default inactive">'+
  2873. '<div class="item-list">'+
  2874. '<div class="option sel" name="0.0">&nbsp;&nbsp;0%</div>'+
  2875. '<div class="option" name="0.05">&nbsp;&nbsp;5%</div>'+
  2876. '<div class="option" name="0.1">10%</div>'+
  2877. '<div class="option" name="0.16666">17%</div>'+
  2878. '<div class="option" name="0.2">20%</div>'+
  2879. '<div class="option" name="0.25">25%</div>'+
  2880. '<div class="option" name="0.33">33%</div>'+
  2881. '<div class="option" name="0.5">50%</div>'+
  2882. '</div></div>').appendTo(wndID + ".rec_trade");
  2883. $(wndID + ".rec_trade [name='"+ unit +"']").toggleClass("sel");
  2884. // Styles
  2885. $(wndID + '.rec_trade').css({ position: 'absolute', left: '30px', top: '70px' });
  2886. $(wndID + '.select_rec_unit').css({
  2887. position: 'absolute',
  2888. top: '20px',
  2889. width: '84px',
  2890. display: "none"
  2891. });
  2892. $(wndID + '.select_rec_perc').css({
  2893. position: 'absolute',
  2894. left: '50px',
  2895. top: '20px',
  2896. width: '50px',
  2897. display: "none"
  2898. });
  2899. $(wndID + '.item-list').css({ maxHeight: '400px', maxWidth: '200px', align: "right" });
  2900. $(wndID + '.arrow').css({
  2901. width: '18px',
  2902. height: '18px',
  2903. background: 'url('+ drop_out.src +') no-repeat -1px -1px',
  2904. position: 'absolute',
  2905. });
  2906. $(wndID + '.option_s').css({
  2907. WebkitFilter: "grayscale(100%)",
  2908. filter: "url(#GrayScale)",
  2909. cursor: 'pointer',
  2910. color: 'black',
  2911. lineHeight: '14px',
  2912. float: 'left',
  2913. position: 'relative',
  2914. width: '40px',
  2915. margin: '0px',
  2916. padding: '0px'
  2917. });
  2918. $('.select_rec_unit .sel').css({"-webkit-filter" : "sepia(100%)", "filter": "url(#Sepia)"});
  2919. // hover effects of the elements in the drop menus
  2920. $(wndID + '.option_s').hover(
  2921. function(){
  2922. //console.log(this.className);
  2923. $(this).css({"-webkit-filter" : "grayscale(0%) sepia(0%)", "filter": "none"});
  2924. if(!($(this).hasClass("sel"))){
  2925. $('.option_s .sel').css({"-webkit-filter" : "grayscale(0%) sepia(100%)", "filter": "url(#Sepia)"});
  2926. }
  2927. },
  2928. function(){
  2929. $('.select_rec_unit .option_s').css({"-webkit-filter" : "grayscale(100%) sepia(0%)", "filter": "url(#GrayScale)"});
  2930. $('.select_rec_unit .sel').css({"-webkit-filter" : "grayscale(0%) sepia(100%)", "filter": "url(#Sepia)"});
  2931. }
  2932. );
  2933. $(wndID + '.option').hover(
  2934. function(){ $(this).css({color: '#fff', background: "#328BF1"}); },
  2935. function(){ $(this).css({color: '#000', background: "#FFEEC7"}); }
  2936. );
  2937. // click events of the drop menu
  2938. $(wndID + ' .select_rec_unit .option_s').each(function(){
  2939. $(this).click(function(e){
  2940. $(".select_rec_unit .sel").toggleClass("sel");
  2941. $("." + this.className.split(" ")[4]).toggleClass("sel");
  2942. unit = $(this).attr("name");
  2943. $('.drop_rec_unit .caption').attr("name", unit);
  2944. $('.drop_rec_unit .caption').each(function(){
  2945. $(this).get(0).innerHTML = unit;
  2946. });
  2947. $(this).parent().parent().get(0).style.display = "none";
  2948. $('.drop_rec_unit .caption').change();
  2949. });
  2950. });
  2951. $(wndID + ' .select_rec_perc .option').each(function(){
  2952. $(this).click(function(e){
  2953. $(this).parent().find(".sel").toggleClass("sel");
  2954. $(this).toggleClass("sel");
  2955. percent = $(this).attr("name");
  2956. $('.drop_rec_perc .caption').attr("name", percent);
  2957. $('.drop_rec_perc .caption').each(function(){
  2958. $(this).get(0).innerHTML = Math.round(percent * 100)+"%";
  2959. });
  2960. $(this).parent().parent().get(0).style.display = "none";
  2961. $('.drop_rec_perc .caption').change();
  2962. });
  2963. });
  2964. // show & hide drop menus on click
  2965. $(wndID + '.drop_rec_perc').click(function(e){
  2966. if($(e.target)[0].parentNode.parentNode.childNodes[3].style.display === "none"){
  2967. $(e.target)[0].parentNode.parentNode.childNodes[3].style.display = "block";
  2968. $(e.target)[0].parentNode.parentNode.childNodes[2].style.display = "none";
  2969. } else {
  2970. $(e.target)[0].parentNode.parentNode.childNodes[3].style.display = "none";
  2971. }
  2972. });
  2973. $(wndID + '.drop_rec_unit').click(function(e){
  2974. if($(e.target)[0].parentNode.parentNode.childNodes[2].style.display === "none"){
  2975. $(e.target)[0].parentNode.parentNode.childNodes[2].style.display = "block";
  2976. $(e.target)[0].parentNode.parentNode.childNodes[3].style.display = "none";
  2977. } else {
  2978. $(e.target)[0].parentNode.parentNode.childNodes[2].style.display = "none";
  2979. }
  2980. });
  2981. $(wndID).click(function(e){
  2982. var clicked = $(e.target), element = $('#' + this.id + ' .select_rec_unit').get(0);
  2983. if(!(clicked[0].parentNode.className.split(" ")[1] === "dropdown") && element){
  2984. element.style.display = "none";
  2985. }
  2986. });
  2987. // hover arrow change
  2988. $(wndID + '.dropdown').hover(function(e){
  2989. $(e.target)[0].parentNode.childNodes[3].style.background = "url('"+ drop_over.src +"') no-repeat -1px -1px";
  2990. }, function(e){
  2991. $(e.target)[0].parentNode.childNodes[3].style.background = "url('"+ drop_out.src +"') no-repeat -1px -1px";
  2992. });
  2993. $(wndID + ".drop_rec_unit .caption").attr("name", unit);
  2994. $(wndID + ".drop_rec_perc .caption").attr("name",percent);
  2995. $(wndID + '.drop_rec_unit').tooltip(getText("labels", "rat"));
  2996. $(wndID + '.drop_rec_perc').tooltip(getText("labels", "shr"));
  2997. var ratio = {NO: {w:0, s: 0, i: 0 },
  2998. FS: {w:1, s: 0.2308, i: 0.6154 },
  2999. BI: {w:1, s: 0.8750, i: 0.2250 },
  3000. SL: {w:0.55, s: 1, i: 0.4 },
  3001. RE: {w:0.6666, s: 0.3333, i: 1 },
  3002. SK: {w:1, s: 0, i: 0.8947 },
  3003. HO: {w:0, s: 0.5, i: 1 },
  3004. BS: {w:1, s: 0, i: 0.6250 },
  3005. SW: {w:0.4545, s: 1, i: 0.7273 }
  3006. };
  3007. if($('#town_capacity_wood .max').get(0)){
  3008. max_amount = parseInt($('#town_capacity_wood .max').get(0).innerHTML, 10);
  3009. } else {
  3010. max_amount = 25500;
  3011. }
  3012. $(wndID + '.caption').change(function(e){
  3013. //console.log($(this).attr('name') + ", " + unit + "; " + percent);
  3014. if(!(($(this).attr('name') === unit) || ($(this).attr('name') === percent))){
  3015. //trade_count = 0;
  3016. $('.rec_count').get(0).innerHTML = "(" + trade_count + ")";
  3017. }
  3018. var tmp = $(this).attr('name');
  3019. if($(this).parent().attr('class').split(" ")[0] === "drop_rec_unit"){
  3020. unit = tmp;
  3021. } else {
  3022. percent = tmp;
  3023. }
  3024. var max = (max_amount - 100)/1000;
  3025. addTradeMarks(max * ratio[unit].w, max * ratio[unit].s, max * ratio[unit].i, "lime");
  3026. 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)
  3027. var rArray = uw.ITowns.getTown(uw.Game.townId).getCurrentResources();
  3028. var tradeCapacity = uw.ITowns.getTown(uw.Game.townId).getAvailableTradeCapacity();
  3029. var wood = ratio[unit].w * part;
  3030. var stone= ratio[unit].s * part;
  3031. var iron = ratio[unit].i * part;
  3032. if((wood > rArray.wood) || (stone > rArray.stone) || (iron > rArray.iron) || ( (wood + stone + iron) > tradeCapacity)) {
  3033. wood = stone = iron = 0;
  3034. $('.drop_rec_perc .caption').css({color:'#f00'});
  3035. //$('.' + e.target.parentNode.parentNode.className + ' .select_rec_perc .sel').css({color:'#f00'});
  3036. //$('.select_rec_perc .sel').css({color:'#f00'});
  3037. } else {
  3038. $('.' + e.target.parentNode.parentNode.className + ' .drop_rec_perc .caption').css({color:'#000'});
  3039. }
  3040. $("#trade_type_wood [type='text']").select().val(wood).blur();
  3041. $("#trade_type_stone [type='text']").select().val(stone).blur();
  3042. $("#trade_type_iron [type='text']").select().val(iron).blur();
  3043. });
  3044. $('#trade_button').click(function(){
  3045. trade_count++;
  3046. $('.rec_count').get(0).innerHTML = "(" + trade_count + ")";
  3047. });
  3048. $(wndID + '.rec_count').css({
  3049. position: 'absolute',
  3050. display: 'block',
  3051. left: '33px',
  3052. top: '95px',
  3053. width: '20px'
  3054. });
  3055. $(wndID + '.drop_rec_unit').css({
  3056. position: 'absolute',
  3057. display: 'block',
  3058. width: '50px',
  3059. overflow: 'visible'
  3060. });
  3061. $(wndID + '.drop_rec_perc').css({
  3062. position: 'absolute',
  3063. display: 'block',
  3064. left: '49px',
  3065. width: '55px',
  3066. color:'#000'
  3067. });
  3068. $(wndID + '.drop_rec_perc .caption').change();
  3069. }
  3070. /*******************************************************************************************************************************
  3071. * ● Ressources marks
  3072. *******************************************************************************************************************************/
  3073. function addTradeMarks(woodmark, stonemark, ironmark, color){
  3074. var max_amount, limit, wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_TOWN), wndID;
  3075. for(var e in wndArray){
  3076. if(wndArray.hasOwnProperty(e)){
  3077. wndID = "#gpwnd_" + wndArray[e].getID() + " ";
  3078. if($(wndID + '.town-capacity-indicator').get(0)){
  3079. max_amount = $(wndID + '.amounts .max').get(0).innerHTML;
  3080. $('#trade_tab .c_'+ color).each(function(){
  3081. $(this).get(0).remove();
  3082. });
  3083. $('#trade_tab .progress').each(function(){
  3084. if($("p", this).length < 3) {
  3085. if($(this).parent().get(0).id != "big_progressbar"){
  3086. limit = 1000 * (242 / parseInt(max_amount, 10));
  3087. switch($(this).parent().get(0).id.split("_")[2]){
  3088. case "wood": limit = limit * woodmark; break;
  3089. case "stone": limit = limit * stonemark; break;
  3090. case "iron": limit = limit * ironmark; break;
  3091. }
  3092. $('<p class="c_'+ color +'"style="position:absolute;left: '+ limit +'px; background:'+ color +';width:2px;height:100%;margin:0px"></p>').appendTo(this);
  3093. }
  3094. }
  3095. });
  3096. }
  3097. }
  3098. }
  3099. }
  3100. /*******************************************************************************************************************************
  3101. * ● Percentual Trade
  3102. *******************************************************************************************************************************/
  3103. var rest_count = 0;
  3104. function addPercentTrade(wndID, ww){
  3105. var a = ""; var content = wndID + ".content";
  3106. if(ww) {
  3107. a = "ww_";
  3108. content = wndID + '.trade .send_res';
  3109. }
  3110. $('<div class="btn btn_trade"><a class="button" href="#">'+
  3111. '<span class="left"><span class="right">'+
  3112. '<span class="middle mid">'+
  3113. '<span class="img_trade"></span></span></span></span>'+
  3114. '<span style="clear:both;"></span>'+
  3115. '</a></div>').prependTo(content);
  3116. $(wndID + '.btn_trade').tooltip(getText("labels", "per"));
  3117. setPercentTrade(wndID, ww);
  3118. // Style
  3119. $(wndID + '.btn').css({ width: '20px', overflow: 'visible', position: 'absolute', display: 'block' });
  3120. if(!ww){ $(wndID + '.content').css({ height: '320px' }); }
  3121. if(ww){
  3122. $(wndID + '.btn_trade').css({ left: '678px', top: '154px' });
  3123. } else {
  3124. $(wndID + '.btn_trade').css({ left: '336px', top: '135px' });
  3125. }
  3126. $(wndID + '.mid').css({ minWidth: '26px' });
  3127. $(wndID + '.img_trade').css({
  3128. width: '27px',
  3129. height: '27px',
  3130. top: '-3px',
  3131. float: 'left',
  3132. position: 'relative',
  3133. background: 'url("http://666kb.com/i/cjq6d72qk521ig1zz.png") no-repeat'
  3134. });
  3135. }
  3136. var res = {};
  3137. function setPercentTrade(wndID, ww){
  3138. var a = ww ? "ww_" : "", own_town = $(wndID + '.town_info').get(0) ? true : false;
  3139. $(wndID + '.btn_trade').toggle(function(){
  3140. res.wood = {}; res.stone = {}; res.iron = {}; res.sum = {};
  3141. res.sum.amount = 0;
  3142. // Set amount of resources to 0
  3143. setAmount(true, a, wndID);
  3144. // Total amount of resources // TODO: ITowns.getTown(Game.townId).getCurrentResources(); ?
  3145. for(var e in res){
  3146. if(res.hasOwnProperty(e) && e != "sum") {
  3147. res[e].rest = false;
  3148. res[e].amount = parseInt($('.ui_resources_bar .'+ e +' .amount').get(0).innerHTML, 10);
  3149. res.sum.amount += res[e].amount;
  3150. }
  3151. }
  3152. // Percentage of total resources
  3153. res.wood.percent = 100/res.sum.amount * res.wood.amount;
  3154. res.stone.percent = 100/res.sum.amount * res.stone.amount;
  3155. res.iron.percent = 100/res.sum.amount * res.iron.amount;
  3156. // Total trading capacity
  3157. res.sum.cur = parseInt($(wndID + '#' + a + 'big_progressbar .caption .curr').get(0).innerHTML, 10);
  3158. res.sum.max = parseInt($(wndID + '#' + a + 'big_progressbar .caption .max').get(0).innerHTML, 10) - res.sum.cur;
  3159. // Amount of resources on the percentage of trading capacity (%)
  3160. res.wood.part = parseInt(res.sum.max/100 * res.wood.percent, 10);
  3161. res.stone.part = parseInt(res.sum.max/100 * res.stone.percent, 10);
  3162. res.iron.part = parseInt(res.sum.max/100 * res.iron.percent, 10);
  3163. // Get rest warehouse capacity of each resource type
  3164. for(var f in res){
  3165. if(res.hasOwnProperty(f) && f != "sum") {
  3166. if(!ww && own_town){ // Own town
  3167. var curr = parseInt($(wndID + '#town_capacity_'+ f +' .amounts .curr').get(0).innerHTML.replace('+', '').trim(), 10) || 0,
  3168. curr2 = parseInt($(wndID + '#town_capacity_'+ f +' .amounts .curr2').get(0).innerHTML.replace('+', '').trim(), 10) || 0,
  3169. max = parseInt($(wndID + '#town_capacity_'+ f +' .amounts .max').get(0).innerHTML.replace('+', '').trim(), 10) || 0;
  3170. res[f].cur = curr + curr2;
  3171. res[f].max = max - res[f].cur;
  3172. if(res[f].max < 0) { res[f].max = 0; }
  3173. } else { // World wonder or foreign town
  3174. res[f].max = 30000;
  3175. }
  3176. }
  3177. }
  3178. // Rest of fraction (0-2 units) add to stone amount
  3179. res.stone.part += res.sum.max - (res.wood.part + res.stone.part + res.iron.part);
  3180. res.sum.rest = 0;
  3181. rest_count = 0;
  3182. calcRestAmount();
  3183. setAmount(false, a, wndID);
  3184. }, function(){
  3185. setAmount(true, a, wndID);
  3186. });
  3187. }
  3188. function calcRestAmount(){
  3189. // Subdivide rest
  3190. if(res.sum.rest > 0){
  3191. for(var e in res){
  3192. if(res.hasOwnProperty(e) && e != "sum" && res[e].rest != true) {
  3193. res[e].part += res.sum.rest/(3 - rest_count);
  3194. }
  3195. }
  3196. res.sum.rest = 0;
  3197. }
  3198. // Calculate new rest
  3199. for(var f in res){
  3200. if(res.hasOwnProperty(f) && f != "sum" && res[f].rest != true) {
  3201. if(res[f].max <= res[f].part) {
  3202. res[f].rest = true;
  3203. res.sum.rest += res[f].part - res[f].max;
  3204. rest_count += 1;
  3205. res[f].part = res[f].max;
  3206. }
  3207. }
  3208. }
  3209. // Recursion
  3210. if(res.sum.rest > 0 && rest_count < 3){
  3211. calcRestAmount();
  3212. }
  3213. }
  3214. function setAmount(clear, a, wndID){
  3215. for(var e in res){
  3216. if(res.hasOwnProperty(e) && e != "sum") {
  3217. if(clear == true) { res[e].part = 0; }
  3218. $(wndID + "#" + a + "trade_type_" + e + ' [type="text"]').select().val(res[e].part).blur();
  3219. }
  3220. }
  3221. }
  3222. /* ******************************************************************************************************************************
  3223. * Unit strength (blunt/sharp/distance) and Transport Capacity
  3224. * ----------------------------------------------------------------------------------------------------------------------------
  3225. * | ● Unit strength: Unit menu
  3226. * | - Switching of def/off display with buttons
  3227. * | - Possible Selection of certain unit types
  3228. * | ● Unit strength: Siege
  3229. * | ● Unit strength: Barracks
  3230. * | ● Transport capacity: Unit menu
  3231. * | - Switching of transporter speed (+/- big transporter)
  3232. * ----------------------------------------------------------------------------------------------------------------------------
  3233. * ******************************************************************************************************************************/
  3234. var def = true, blunt = 0, sharp = 0, dist = 0, shipsize = false;
  3235. function getSelectedUnitsMenu(){
  3236. var units = [];
  3237. if($(".units_land .units_wrapper .selected").length > 0){
  3238. $(".units_land .units_wrapper .selected").each(function(){
  3239. units[$(this).get(0).className.split(" ")[1]] = $(this).get(0).children[0].innerHTML;
  3240. });
  3241. } else {
  3242. $(".units_land .units_wrapper .unit").each(function(){
  3243. units[$(this).get(0).className.split(" ")[1]] = $(this).get(0).children[0].innerHTML;
  3244. });
  3245. }
  3246. return units;
  3247. }
  3248. // Calculate defensive strength
  3249. function calcDef(units){
  3250. var e; blunt = sharp = dist = 0;
  3251. for(e in units) {
  3252. if(units.hasOwnProperty(e)) {
  3253. blunt += units[e] * uw.GameData.units[e].def_hack;
  3254. sharp += units[e] * uw.GameData.units[e].def_pierce;
  3255. dist += units[e] * uw.GameData.units[e].def_distance;
  3256. }
  3257. }
  3258. }
  3259. // Calculate offensive strength
  3260. function calcOff(units, selectedUnits){
  3261. var e; blunt = sharp = dist = 0;
  3262. for(e in selectedUnits) {
  3263. if(selectedUnits.hasOwnProperty(e)) {
  3264. var attack = (units[e] || 0) * uw.GameData.units[e].attack;
  3265. switch(uw.GameData.units[e].attack_type){
  3266. case 'hack': blunt += attack; break;
  3267. case 'pierce': sharp += attack; break;
  3268. case 'distance':dist += attack; break;
  3269. }
  3270. }
  3271. }
  3272. }
  3273. /*******************************************************************************************************************************
  3274. * ● Unit strength: Unit menu
  3275. *******************************************************************************************************************************/
  3276. function setStrengthMenu() {
  3277. try{
  3278. var unitsIn = uw.ITowns.getTown(uw.Game.townId).units(),
  3279. e, units = getSelectedUnitsMenu();
  3280. // Calculation
  3281. if(def==true){
  3282. calcDef(units);
  3283. } else {
  3284. calcOff(unitsIn, units);
  3285. }
  3286. $('#blunt').get(0).innerHTML = blunt;
  3287. $('#sharp').get(0).innerHTML = sharp;
  3288. $('#dist').get(0).innerHTML = dist;
  3289. setTransportCapacity(units);
  3290. }catch(e){
  3291. handleError(e, "setStrengthMenu");
  3292. }
  3293. }
  3294. function addStrengthMenu(){
  3295. $('<hr><div id="strength" class="cont_left"><span id="str_font" class="bold text_shadow" style="color:#FFCC66;font-size: 0.8em;">'+
  3296. '<table style="margin:0px;">'+
  3297. '<tr><td><div class="ico units_info_sprite img_hack"></td><td id="blunt">0</td></tr>'+
  3298. '<tr><td><div class="ico units_info_sprite img_pierce"></td><td id="sharp">0</td></tr>'+
  3299. '<tr><td><div class="ico units_info_sprite img_dist"></td><td id="dist">0</td></tr>'+
  3300. '</table>'+
  3301. '</span></div>'+
  3302. '<div class="cont_right">'+
  3303. '<img id="def" class="img" src="http://de.cdn.grepolis.com/images/game/unit_overview/support.png">'+
  3304. '<img id="off" class="img" src="http://de.cdn.grepolis.com/images/game/unit_overview/attack.png">'+
  3305. '</div>').appendTo('.units_land .content');
  3306. // transporter display
  3307. $('<div id="transporter" class="cont" style="height:25px;">'+
  3308. '<table style=" margin:0px;"><tr align="center" >'+
  3309. '<td><img id="ship_img" class="ico" src="http://s7.directupload.net/images/140724/4pvfuch8.png"></td>'+
  3310. '<td><span id="ship" class="bold text_shadow" style="color:#FFCC66;font-size: 10px;"></span></td>'+
  3311. '</tr></table>'+
  3312. '</div>').appendTo('.units_naval .content');
  3313. // Styles
  3314. $('.ico').css({
  3315. height: '20px',
  3316. width: '20px'
  3317. });
  3318. $('.units_info_sprite').css({
  3319. background: 'url(http://de.cdn.grepolis.com/images/game/units/units_info_sprite2.51.png)',
  3320. backgroundSize: '100%'
  3321. });
  3322. $('.img_pierce').css({ backgroundPosition: '0px -20px' });
  3323. $('.img_dist').css({ backgroundPosition: '0px -40px' });
  3324. $('hr').css({
  3325. margin: '0px',
  3326. backgroundColor: '#5F5242',
  3327. height: '2px',
  3328. border: '0px solid'
  3329. });
  3330. $('.cont_left').css({
  3331. background: 'url(http://de.cdn.grepolis.com/images/game/layout/layout_units_nav_border.png)',
  3332. width:'65%',
  3333. display: 'table-cell'
  3334. });
  3335. $('.cont').css({
  3336. background: 'url(http://gpall.innogamescdn.com/images/game/layout/layout_units_nav_border.png)'
  3337. //background:'url("http://gpde.innogamescdn.com/images/game/layout/layout_2.56_compressed.png") no-repeat -270px -354px'
  3338. });
  3339. $('.cont_right').css({
  3340. background:'url(http://de.cdn.grepolis.com/images/game/layout/layout_units_nav_border.png)',
  3341. width:'30%',
  3342. display: 'table-cell',
  3343. verticalAlign:'middle'
  3344. });
  3345. $('.img').css({
  3346. float:'right',
  3347. background:'none',
  3348. margin:'2px 8px 2px 0px'
  3349. });
  3350. $('.units_land .units_wrapper, .btn_gods_spells .checked').click(function(){
  3351. setTimeout(function(){
  3352. setStrengthMenu();
  3353. }, 100);
  3354. });
  3355. $('#off').css({"-webkit-filter" : "grayscale(80%)",
  3356. "filter": "url(#GrayScale)"});
  3357. // Buttons
  3358. $('#off').click(function(){
  3359. $('#strength .img_hack').get(0).style.backgroundPosition = '0% 36%';
  3360. $('#strength .img_pierce').get(0).style.backgroundPosition = '0% 27%';
  3361. $('#strength .img_dist').get(0).style.backgroundPosition = '0% 45%';
  3362. $('#str_font').get(0).style.color = "#edb";
  3363. // TODO: doesn't work in FF yet
  3364. $(this).css({"-webkit-filter" : "grayscale(0%)",
  3365. "filter": "none",
  3366. });
  3367. $('#def').css({"-webkit-filter" : "grayscale(80%)",
  3368. "filter": "url(#GrayScale)",
  3369. });
  3370. def = false;
  3371. setStrengthMenu();
  3372. });
  3373. $('#def').click(function(){
  3374. $('#strength .img_hack').get(0).style.backgroundPosition = '0% 0%';
  3375. $('#strength .img_pierce').get(0).style.backgroundPosition = '0% 9%';
  3376. $('#strength .img_dist').get(0).style.backgroundPosition = '0% 18%';
  3377. $('#str_font').get(0).style.color = "#fc6";
  3378. $(this).css({"-webkit-filter" : "grayscale(0%)",
  3379. "filter": "none"
  3380. });
  3381. $('#off').css({"-webkit-filter" : "grayscale(80%)",
  3382. "filter": "url(#GrayScale)",
  3383. });
  3384. def = true;
  3385. setStrengthMenu();
  3386. });
  3387. $('#def,#off,#transporter').hover(function() {
  3388. $(this).css('cursor','pointer');
  3389. });
  3390. $('#transporter').toggle(
  3391. function(){
  3392. $('#ship_img').get(0).src = "http://s1.directupload.net/images/140724/b5xl8nmj.png";
  3393. shipsize = !shipsize;
  3394. setStrengthMenu();
  3395. },
  3396. function(){
  3397. $('#ship_img').get(0).src = "http://s7.directupload.net/images/140724/4pvfuch8.png";
  3398. shipsize = !shipsize;
  3399. setStrengthMenu();
  3400. }
  3401. );
  3402. }
  3403. /*******************************************************************************************************************************
  3404. * ● Unit strength: Siege
  3405. *******************************************************************************************************************************/
  3406. function addStrengthConquest(){
  3407. var units = [], str;
  3408. // units of the siege
  3409. $('#conqueror_units_in_town .unit').each(function(){
  3410. str = $(this).attr("class").split(" ")[4];
  3411. if(!uw.GameData.units[str].is_naval){
  3412. units[str] = parseInt($(this).get(0).children[0].innerHTML, 10);
  3413. //console.log($(this).attr("class").split(" ")[4]);
  3414. }
  3415. });
  3416. // calculation
  3417. calcDef(units);
  3418. $('<div id="strength_eo" class="game_border" style="width:90px; margin: 20px; align:center;">'+
  3419. '<div class="game_border_top"></div><div class="game_border_bottom"></div>'+
  3420. '<div class="game_border_left"></div><div class="game_border_right"></div>'+
  3421. '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>'+
  3422. '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>'+
  3423. '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">'+
  3424. '<tr><td width="1%"><div class="ico units_info_sprite img_hack"></div></td><td id="bl" align="center" width="100%">0</td></tr>'+
  3425. '<tr><td><div class="ico units_info_sprite img_pierce"></div></td><td id="sh" align="center">0</td></tr>'+
  3426. '<tr><td><div class="ico units_info_sprite img_dist"></div></td><td id="di" align="center">0</td></tr>'+
  3427. '</table></span>'+
  3428. '</div>').appendTo('#conqueror_units_in_town');
  3429. $('#strength_eo').tooltip('Gesamteinheitenstärke der Belagerungstruppen');
  3430. $('#strength_eo .ico').css({
  3431. height: '20px',
  3432. width: '20px'
  3433. });
  3434. $('#strength_eo .units_info_sprite').css({
  3435. background: 'url(http://de.cdn.grepolis.com/images/game/units/units_info_sprite2.51.png)',
  3436. backgroundSize: '100%'
  3437. });
  3438. $('#strength_eo .img_pierce').css({ backgroundPosition: '0% 9%' });
  3439. $('#strength_eo .img_dist').css({ backgroundPosition: '0% 18%' });
  3440. $('#bl').get(0).innerHTML = blunt;
  3441. $('#sh').get(0).innerHTML = sharp;
  3442. $('#di').get(0).innerHTML = dist;
  3443. }
  3444. /*******************************************************************************************************************************
  3445. * ● Unit strength: Barracks
  3446. *******************************************************************************************************************************/
  3447. function setStrengthBarracks(){
  3448. if(!$('#strength_baracks').get(0)){
  3449. var units = [], pop = 0;
  3450. // whole units of the town
  3451. $('#units .unit_order_total').each(function(){
  3452. units[$(this).parent().parent().attr("id")] = $(this).get(0).innerHTML;
  3453. });
  3454. // calculation
  3455. calcDef(units);
  3456. // population space of the units
  3457. for(var e in units) {
  3458. if(units.hasOwnProperty(e)) {
  3459. pop += units[e] * uw.GameData.units[e].population;
  3460. }
  3461. }
  3462. $('<div id="strength_baracks" class="game_border" style="float:right; width:70px; align:center;">'+
  3463. '<div class="game_border_top"></div><div class="game_border_bottom"></div>'+
  3464. '<div class="game_border_left"></div><div class="game_border_right"></div>'+
  3465. '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>'+
  3466. '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>'+
  3467. '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">'+
  3468. '<tr><td width="1%"><div class="ico units_info_sprite img_hack"></div></td><td id="b" align="center" width="100%">0</td></tr>'+
  3469. '<tr><td><div class="ico units_info_sprite img_pierce"></div></td><td id="s" align="center">0</td></tr>'+
  3470. '<tr><td><div class="ico units_info_sprite img_dist"></div></td><td id="d" align="center">0</td></tr>'+
  3471. '</table></span>'+
  3472. '</div>').appendTo('.ui-dialog #units');
  3473. $('<div id="pop_baracks" class="game_border" style="float:right; width:60px; align:center;">'+
  3474. '<div class="game_border_top"></div><div class="game_border_bottom"></div>'+
  3475. '<div class="game_border_left"></div><div class="game_border_right"></div>'+
  3476. '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>'+
  3477. '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>'+
  3478. '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">'+
  3479. '<tr><td width="1%"><img class="ico" src="http://de.cdn.grepolis.com/images/game/res/pop.png"></td><td id="p" align="center" width="100%">0</td></tr>'+
  3480. '</table></span>'+
  3481. '</div>').appendTo('.ui-dialog #units');
  3482. $('.ui-dialog #units .ico').css({
  3483. height: '20px',
  3484. width: '20px'
  3485. });
  3486. $('.ui-dialog #units .units_info_sprite').css({
  3487. background: 'url(http://de.cdn.grepolis.com/images/game/units/units_info_sprite2.51.png)',
  3488. backgroundSize: '100%'
  3489. });
  3490. $('.ui-dialog #units .img_pierce').css({ backgroundPosition: '0% 9%' });
  3491. $('.ui-dialog #units .img_dist').css({ backgroundPosition: '0% 18%' });
  3492. //$('#pop_baracks').tooltip('Bevölkerungszahl aller Landeinheiten der Stadt');
  3493. //$('#strength_baracks').tooltip('Gesamteinheitenstärke stadteigener Truppen');
  3494. $('#b').get(0).innerHTML = blunt;
  3495. $('#s').get(0).innerHTML = sharp;
  3496. $('#d').get(0).innerHTML = dist;
  3497. $('#p').get(0).innerHTML = pop;
  3498. }
  3499. }
  3500. /*******************************************************************************************************************************
  3501. * ● Transporter capacity
  3502. *******************************************************************************************************************************/
  3503. function setTransportCapacity(){
  3504. var bigTransp = 0, smallTransp = 0, pop = 0, ship = 0, unit, berth, units = [];
  3505. // Ship space (available)
  3506. smallTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().small_transporter, 10);
  3507. if(isNaN(smallTransp)) smallTransp = 0;
  3508. if(shipsize){
  3509. bigTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().big_transporter, 10);
  3510. if(isNaN(bigTransp)) bigTransp = 0;
  3511. }
  3512. // Checking: Research berth
  3513. berth = 0;
  3514. if(uw.ITowns.getTown(uw.Game.townId).researches().hasBerth()){
  3515. berth = 6;
  3516. }
  3517. ship = bigTransp*(20 + berth) + smallTransp*(10 + berth);
  3518. units = uw.ITowns.getTown(uw.Game.townId).units();
  3519. // Ship space (required)
  3520. for(var e in units) {
  3521. if(units.hasOwnProperty(e)) {
  3522. if(uw.GameData.units[e]){ // without Heroes
  3523. if(!(uw.GameData.units[e].is_naval || uw.GameData.units[e].flying)){
  3524. pop += units[e] * uw.GameData.units[e].population;
  3525. }
  3526. }
  3527. }
  3528. }
  3529. $('#ship').get(0).innerHTML = pop + "/" + ship;
  3530. }
  3531. /*******************************************************************************************************************************
  3532. * Simulator
  3533. * ----------------------------------------------------------------------------------------------------------------------------
  3534. * | ● Layout adjustment
  3535. * | ● Permanent display of the extended modifier box
  3536. * | ● Unit strength for entered units (without modificator influence yet)
  3537. * ----------------------------------------------------------------------------------------------------------------------------
  3538. *******************************************************************************************************************************/
  3539. function changeSimulatorLayoutNew(){
  3540. if(!$('#dio_simulator').get(0)){
  3541. $('<style id="dio_simulator" type="text/css">'+
  3542. '#place_simulator { overflow: hidden !important} '+
  3543. '#place_simulator .game_body { height: 457px !important} '+
  3544. // Bonus container
  3545. '.place_sim_wrap_mods {position: absolute !important; right: -17px !important} '+
  3546. '.place_sim_wrap_mods .place_simulator_table :eq(1) { width: 300px;} '+ ////////////// genauer!
  3547. '.place_sim_wrap_mods > .place_simulator_table { width: 272px;} '+ ////////////// genauer!
  3548. // Extended modifier box
  3549. '.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} '+
  3550. '.place_sim_wrap_mods_extended table { table-layout: fixed !important; width: 100% !important} '+
  3551. '.place_sim_wrap_mods_extended table tr td:eq(0) { width: 18px !important } '+
  3552. '.place_image { width: 20px !important; height:20px !important; background-size: 100% !important; margin: auto !important} '+
  3553. '.place_cross { height: 19px !important}'+
  3554. '.top_border td { border-top: 2px solid #BFA978 !important; padding-top: 3px !important} '+
  3555. // Unit container
  3556. '#simulator_body .unit_container { height: 50px !important; width: 50px !important; margin: 0px 3px 0px 1px !important} '+
  3557. '.place_simulator_odd, .place_simulator_even { text-align: center !important} '+
  3558. '.place_insert_field { margin: 0px !important} '+
  3559. // Sea unit box
  3560. '.place_sim_sea_wrap h4 { float: left !important} '+
  3561. '.place_sim_select_strategies select { width: 95px !important} '+
  3562. '.place_sim_select_strategies { margin-left: 99px !important} '+
  3563. // Land unit box
  3564. '#place_sim_wrap_units { position: absolute !important; bottom: 35px !important} '+
  3565. '#place_sim_wrap_units h4 { float: left !important} '+
  3566. // Select boxes
  3567. '.place_sim_select_gods { width: 105px !important} '+
  3568. '.place_sim_select_gods select { width: 80px !important} '+
  3569. '.place_sim_select_gods_wrap { padding: 0px !important} '+
  3570. '#select_insert_units { width: 130px !important} '+
  3571. '.place_sim_select_gods_wrap .place_symbol, .place_sim_select_strategies .place_symbol { margin: 0px 2px 0px 5px !important} '+
  3572. '.place_sim_insert_units .place_symbol { background: url(http://de.cdn.grepolis.com/images/game/towninfo/traveltime.png) !important; background-size: 140% !important; background-position-y: -4px !important} '+
  3573. '.place_attack { float: left !important} '+
  3574. '#simulator_body .att { margin-left: 19px !important} '+
  3575. // Hero box
  3576. '.place_sim_heroes_container { position: absolute !important; right: 26px !important; padding-top: 3px !important; z-index: 1 !important} '+
  3577. '.place_sim_hero_container { width: 45px !important; height: 25px !important} '+
  3578. // - Hero container
  3579. '.place_sim_hero_choose, .place_sim_hero_unit_container { height: 26px !important; width: 30px !important} '+
  3580. '#hero_defense_icon, #hero_attack_icon { height: 25px !important; width: 25px !important; margin: 0px !important} '+
  3581. '#hero_defense_dd, #hero_attack_dd { height: 25px !important; width: 25px !important; margin: 1px !important} '+
  3582. '.place_sim_hero_attack, .place_sim_hero_defense { margin-left: 3px !important} '+
  3583. '#hero_attack_text, #hero_defense_text { font-size: 11px !important; bottom: 0px !important} '+
  3584. '.place_sim_heroes_container .plus { left: 2px; top: 2px !important} '+
  3585. // - Hero spinner
  3586. '.place_sim_hero_spinner { height: 25px !important; width: 40px !important } '+
  3587. '.place_sim_heroes_container td:eq(0) { height: 30px !important} '+
  3588. '.hero_spinner { height: 24px !important;position:absolute !important; width:12px !important; left:29px !important, background:url(http://gpzz.innogamescdn.com/images/game/border/odd.png) repeat !important; border: 1px solid rgb(107, 107, 107) !important} '+
  3589. '.place_sim_hero_spinner .button_down, .place_sim_hero_spinner .button_up { bottom: 2px !important; cursor: pointer !important} '+
  3590. // Quack
  3591. '#q_place_sim_lost_res { display: none; } '+
  3592. '</style>').appendTo('head');
  3593. }
  3594. /////////////////////////////////////
  3595. $('.place_sim_bonuses_heroes h4').prependTo('.place_sim_wrap_mods');
  3596. $('.place_sim_bonuses_more_confirm').parent().get(0).style.display = "none";
  3597. $('.place_sim_showhide').remove();
  3598. // Wall loss
  3599. $('.place_sim_wrap_mods tr:eq(1) td:eq(5)').html('<span id="building_place_def_losses_wall_level" class="place_losses bold"></span');
  3600. $('.place_sim_wrap_mods tr:last-child').remove();
  3601. // AutoFillIn
  3602. $('.place_insert_field[name="sim[mods][att][luck]"]').get(0).value = 0;
  3603. // Extended modificator box
  3604. //$('.place_sim_wrap_mods_extended').removeClass().addClass("place_sim_wrap_mods_extend");
  3605. $('.place_sim_wrap_mods_extended').appendTo('.place_sim_wrap_mods');
  3606. $('.place_sim_wrap_mods_extended .place_simulator_table').appendTo('.place_sim_wrap_mods_extended');
  3607. if($('.place_sim_wrap_mods_extended .game_border').get(0)) { $('.place_sim_wrap_mods_extended .game_border').remove(); } // TODO: css!
  3608. $('.place_sim_wrap_mods_extended .place_image').each(function(){
  3609. var s = parseInt($(this).css('backgroundPosition').replace("px", "").split(" ")[1], 10)/2;
  3610. $(this).get(0).style.backgroundPosition = '0px '+s+'px';
  3611. });
  3612. $('.place_sim_wrap_mods_extended .power').each(function(){
  3613. $(this).removeClass("power_icon45x45").addClass("power_icon16x16");
  3614. });
  3615. $('.place_sim_wrap_mods_extended td:nth-child(even)').each(function(){
  3616. $(this).addClass("left_border place_simulator_odd");
  3617. });
  3618. $('.place_sim_wrap_mods_extended td:nth-child(odd)').each(function(){
  3619. $(this).addClass("left_border place_simulator_even");
  3620. });
  3621. // Beta only yet
  3622. //if($('.place_sim_wrap_mods_extend tr').length == 5){
  3623. $('.place_sim_wrap_mods_extended tr:eq(2)').each(function(){
  3624. $(this).addClass("top_border");
  3625. });
  3626. $('.place_sim_wrap_mods_extended tr:last-child').remove();
  3627. //}
  3628. $('.place_sim_wrap_mods_extend td:first-child').each(function(){
  3629. $(this).removeClass("left_border");
  3630. });
  3631. // -> update percentage each time
  3632. $('.place_checkbox_field').each(function(){
  3633. $(this).click(function(){
  3634. uw.FightSimulator.closeModsExtended();
  3635. //$('.place_sim_bonuses_more_confirm').get(0).click();
  3636. });
  3637. });
  3638. // Sea unit box
  3639. $('.place_sim_select_strategies').prependTo('.place_sim_sea_wrap');
  3640. $('.place_sim_sea_wrap h4').prependTo('.place_sim_sea_wrap');
  3641. // Land unit box
  3642. $('<div id="place_sim_wrap_units"></div>').appendTo('#simulator_body');
  3643. $('#place_simulator h4:last, .place_sim_select_gods_wrap').appendTo('#place_sim_wrap_units');
  3644. $('#place_sim_ground_units').appendTo('#place_sim_wrap_units');
  3645. $('#place_sim_wrap_units h4').prependTo('.place_sim_select_gods_wrap');
  3646. // Hero world ?
  3647. if(uw.Game.hasArtemis){
  3648. $('.place_sim_wrap_mods_extend tr').each(function(){
  3649. $(this).get(0).children[1].style.borderLeft = "none";
  3650. $(this).get(0).children[0].remove();
  3651. });
  3652. }
  3653. // Hero box ?
  3654. if($('.place_sim_heroes_container').get(0)){
  3655. $('.place_sim_heroes_container').appendTo(".place_sim_wrap_mods");
  3656. $('#place_simulator h4:eq(2)').remove(); // Delete heroes title
  3657. $('.hero_unit').each(function(){
  3658. $(this).removeClass('unit_icon40x40').addClass('unit_icon25x25');
  3659. });
  3660. // hero spinner
  3661. $('.place_sim_hero_spinner').each(function(){
  3662. $(this).removeClass('place_sim_hero_spinner').addClass('hero_spinner');
  3663. });
  3664. $('.hero_spinner .border_l').remove();
  3665. $('.hero_spinner .border_r').remove();
  3666. $('.hero_spinner .body').remove();
  3667. }
  3668. setStrengthSimulator();
  3669. }
  3670. function changeSimulatorLayout(){
  3671. $('#place_simulator').css({
  3672. overflow: 'hidden'
  3673. });
  3674. $('#place_simulator .game_body').css({
  3675. height: '457px'
  3676. });
  3677. // Bonus container
  3678. $('.place_sim_bonuses_heroes h4').prependTo('.place_sim_wrap_mods');
  3679. $('.place_sim_wrap_mods').css({
  3680. position: 'absolute',
  3681. right: '-17px'
  3682. });
  3683. $('.place_sim_wrap_mods .place_simulator_table .left_border').css({
  3684. width: '47px'
  3685. });
  3686. // Wall loss
  3687. $('.place_sim_wrap_mods tr:eq(1) td:eq(5)').html('<span id="building_place_def_losses_wall_level" class="place_losses bold"></span');
  3688. $('.place_sim_wrap_mods tr:last-child').remove();
  3689. // AutoFillIn
  3690. $('.place_insert_field[name="sim[mods][att][luck]"]').get(0).value = 0;
  3691. //$('.place_insert_field[name="sim[mods][att][morale]"]').get(0).value = 100;
  3692. // Extended modificator box
  3693. $('.place_sim_wrap_mods_extended').removeClass().addClass("place_sim_wrap_mods_extend");
  3694. $('.place_sim_wrap_mods_extend').appendTo('.place_sim_wrap_mods');
  3695. $('.place_sim_wrap_mods_extend .place_simulator_table').appendTo('.place_sim_wrap_mods_extend');
  3696. if($('.place_sim_wrap_mods_extend .game_border').get(0)) { $('.place_sim_wrap_mods_extend .game_border').remove(); }
  3697. $('.place_sim_wrap_mods_extend').css({
  3698. display: 'table',
  3699. position: 'relative',
  3700. width: '272px',
  3701. paddingTop: '3px'
  3702. });
  3703. $('.place_sim_wrap_mods_extend table').css({
  3704. tableLayout: 'fixed',
  3705. width: '100%'
  3706. });
  3707. $('.place_sim_wrap_mods_extend table tr td:eq(0)').css({
  3708. width: '18px'
  3709. });
  3710. $('.place_sim_bonuses_more_confirm').parent().get(0).style.display = "none";
  3711. $('.place_sim_showhide').remove();
  3712. $('.place_image').css({
  3713. width: '20px',
  3714. height:'20px',
  3715. backgroundSize: '100%',
  3716. margin: 'auto'
  3717. });
  3718. $('.place_cross').css({
  3719. height: '19px'
  3720. });
  3721. $('.place_sim_wrap_mods_extend .place_image').each(function(){
  3722. var s = parseInt($(this).css('backgroundPosition').replace("px", "").split(" ")[1], 10)/2;
  3723. $(this).get(0).style.backgroundPosition = '0px '+s+'px';
  3724. });
  3725. $('.place_sim_wrap_mods_extend .power').each(function(){
  3726. $(this).removeClass("power_icon45x45").addClass("power_icon16x16");
  3727. });
  3728. $('.place_sim_wrap_mods_extend td:nth-child(even)').each(function(){
  3729. $(this).addClass("left_border place_simulator_odd");
  3730. });
  3731. $('.place_sim_wrap_mods_extend td:nth-child(odd)').each(function(){
  3732. $(this).addClass("left_border place_simulator_even");
  3733. });
  3734. // Beta only yet
  3735. if($('.place_sim_wrap_mods_extend tr').length == 5){
  3736. $('.place_sim_wrap_mods_extend tr:eq(2)').each(function(){
  3737. $(this).addClass("top_border");
  3738. });
  3739. $('.place_sim_wrap_mods_extend tr:last-child').remove();
  3740. }
  3741. $('.top_border td').css({
  3742. borderTop: '2px solid #BFA978',
  3743. paddingTop: '3px'
  3744. });
  3745. $('.place_sim_wrap_mods_extend td:first-child').each(function(){
  3746. $(this).removeClass("left_border");
  3747. });
  3748. // -> update percentage each time
  3749. $('.place_checkbox_field').each(function(){
  3750. $(this).click(function(){
  3751. uw.FightSimulator.closeModsExtended();
  3752. //$('.place_sim_bonuses_more_confirm').get(0).click();
  3753. });
  3754. });
  3755. // unit container
  3756. $('#simulator_body .unit_container').css({
  3757. height: '50px',
  3758. width: '50px',
  3759. margin: '0px 3px 0px 1px'
  3760. });
  3761. $('.place_simulator_odd, .place_simulator_even').css({
  3762. textAlign: 'center'
  3763. });
  3764. $('.place_insert_field').css({
  3765. margin: '0px'
  3766. });
  3767. // Sea unit box
  3768. $('.place_sim_sea_wrap h4').css({
  3769. float: 'left'
  3770. });
  3771. $('.place_sim_select_strategies').prependTo('.place_sim_sea_wrap');
  3772. $('.place_sim_select_strategies select').css({
  3773. width: '95px'
  3774. });
  3775. $('.place_sim_sea_wrap h4').prependTo('.place_sim_sea_wrap');
  3776. $('.place_sim_select_strategies').css({
  3777. marginLeft: '99px'
  3778. });
  3779. // Land unit box
  3780. $('<div id="place_sim_wrap_units"></div>').appendTo('#simulator_body');
  3781. $('#place_sim_wrap_units').css({
  3782. position: 'absolute',
  3783. bottom: '35px'
  3784. });
  3785. $('#place_simulator h4:last, .place_sim_select_gods_wrap').appendTo('#place_sim_wrap_units');
  3786. $('#place_sim_ground_units').appendTo('#place_sim_wrap_units');
  3787. $('#place_sim_wrap_units h4').prependTo('.place_sim_select_gods_wrap');
  3788. $('#place_sim_wrap_units h4').css({
  3789. float: 'left'
  3790. });
  3791. // Select boxes
  3792. $('.place_sim_select_gods').css({
  3793. width: '105px'
  3794. });
  3795. $('.place_sim_select_gods select').css({
  3796. width: '80px'
  3797. });
  3798. $('.place_sim_select_gods_wrap').css({
  3799. padding: '0px'
  3800. });
  3801. $('#select_insert_units').css({
  3802. width: '130px'
  3803. });
  3804. $('.place_sim_select_gods_wrap .place_symbol, .place_sim_select_strategies .place_symbol').css({
  3805. margin: '0px 2px 0px 5px'
  3806. });
  3807. $('.place_sim_insert_units .place_symbol').css({
  3808. background: 'url(http://de.cdn.grepolis.com/images/game/towninfo/traveltime.png)',
  3809. backgroundSize: '140%',
  3810. backgroundPositionY: '-4px'
  3811. });
  3812. $('.place_attack').css({
  3813. float: 'left'
  3814. });
  3815. $('#simulator_body .att').css({
  3816. marginLeft: '19px'
  3817. });
  3818. // Hero world ?
  3819. if(uw.Game.hasArtemis){
  3820. $('.place_sim_wrap_mods_extend tr').each(function(){
  3821. $(this).get(0).children[1].style.borderLeft = "none";
  3822. $(this).get(0).children[0].remove();
  3823. });
  3824. }
  3825. // Hero box ?
  3826. if($('.place_sim_heroes_container').get(0)){
  3827. $('.place_sim_heroes_container').appendTo(".place_sim_wrap_mods");
  3828. $('#place_simulator h4:eq(2)').remove(); // Delete heroes title
  3829. $('.place_sim_heroes_container').css({
  3830. position: 'absolute',
  3831. right: '26px',
  3832. paddingTop: '3px',
  3833. zIndex: '1'
  3834. });
  3835. $('.place_sim_hero_container').css({
  3836. width: '45px', height: '25px'
  3837. });
  3838. // hero container
  3839. $('.place_sim_hero_choose, .place_sim_hero_unit_container').css({
  3840. height: '26px',
  3841. width: '30px'
  3842. });
  3843. $('#hero_defense_icon, #hero_attack_icon').css({
  3844. height: '25px',
  3845. width: '25px',
  3846. margin: '0px'
  3847. });
  3848. $('#hero_defense_dd, #hero_attack_dd').css({
  3849. height: '25px',
  3850. width: '25px',
  3851. margin: '1px'
  3852. });
  3853. $('.place_sim_hero_attack, .place_sim_hero_defense').css({
  3854. marginLeft: '3px'
  3855. });
  3856. $('#hero_attack_text, #hero_defense_text').css({
  3857. fontSize: '11px',
  3858. bottom: '0px'
  3859. });
  3860. $('.place_sim_heroes_container .plus').css({
  3861. left: '2px', top: '2px'
  3862. });
  3863. $('.hero_unit').each(function(){
  3864. $(this).removeClass('unit_icon40x40').addClass('unit_icon25x25');
  3865. });
  3866. // hero spinner
  3867. $('.place_sim_hero_spinner').css({
  3868. height: '25px', width: '40px'
  3869. });
  3870. $('.place_sim_hero_spinner').each(function(){
  3871. $(this).removeClass('place_sim_hero_spinner').addClass('hero_spinner');
  3872. });
  3873. $('.hero_spinner .border_l').remove();
  3874. $('.hero_spinner .border_r').remove();
  3875. $('.hero_spinner .body').remove();
  3876. $('.place_sim_heroes_container td:eq(0)').css({ height: '30px' });
  3877. $('.hero_spinner').css({
  3878. height: '24px',
  3879. position: 'absolute',
  3880. width: '12px',
  3881. left: '29px',
  3882. background: 'url(http://gpzz.innogamescdn.com/images/game/border/odd.png) repeat',
  3883. border: '1px solid rgb(107, 107, 107)'
  3884. });
  3885. $('.place_sim_hero_spinner .button_down, .place_sim_hero_spinner .button_up').css({
  3886. bottom: '2px',
  3887. cursor: 'pointer'
  3888. });
  3889. }
  3890. $('<style type="text/css"> #q_place_sim_lost_res { display: none; } </style>').appendTo('head');
  3891. setStrengthSimulator();
  3892. }
  3893. function afterSimulation(){
  3894. var lossArray = { att : { res: 0, fav: 0, pop: 0 }, def : { res: 0, fav: 0, pop: 0 } },
  3895. wall_level = parseInt($('.place_sim_wrap_mods .place_insert_field[name="sim[mods][def][wall_level]"]').val(), 10),
  3896. wall_damage = parseInt($('#building_place_def_losses_wall_level').get(0).innerHTML, 10),
  3897. 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 ];
  3898. // Calculate unit losses
  3899. $('#place_sim_wrap_units .place_losses, #place_sim_naval_units .place_losses').each(function(){
  3900. var loss = parseInt($(this).get(0).innerHTML, 10) || 0;
  3901. if(loss > 0){
  3902. var unit = this.id.substring(26);
  3903. var side = this.id.split("_")[2]; // att / def
  3904. lossArray[side].res += loss *(uw.GameData.units[unit].resources.wood + uw.GameData.units[unit].resources.stone + uw.GameData.units[unit].resources.iron);
  3905. lossArray[side].fav += loss * uw.GameData.units[unit].favor;
  3906. lossArray[side].pop += loss * uw.GameData.units[unit].population;
  3907. }
  3908. });
  3909. // Calculate wall resource losses
  3910. for(var w = wall_level; w > wall_level - wall_damage; w--){
  3911. 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
  3912. }
  3913. // Insert losses into table
  3914. for(var x in lossArray){
  3915. if(lossArray.hasOwnProperty(x)){
  3916. for(var z in lossArray[x]){
  3917. if(lossArray[x].hasOwnProperty(z)){
  3918. $("#"+ x +"_"+ z).get(0).innerHTML = ((z === "res") && (lossArray[x][z] > 10000))? (Math.round(lossArray[x][z]/1000)+"k"):lossArray[x][z];
  3919. }
  3920. }
  3921. }
  3922. }
  3923. }
  3924. // Stärkeanzeige: Simulator
  3925. var unitsGround = { att: {}, def: {} }, unitsNaval = { att: {}, def: {} }, name ="";
  3926. function setStrengthSimulator() {
  3927. $('<div id="simu_table" style="position:relative; align:center;font-size: 0.8em; margin-top:6px; margin-right:39%;">'+
  3928. '<div style="float:left; margin-right:12px;"><h4>'+ getText("labels", "str") +'</h4>'+
  3929. '<table class="place_simulator_table strength" cellpadding="0px" cellspacing="0px" style="align:center;">'+
  3930. '<tr>'+
  3931. '<td class="place_simulator_even"></td>'+
  3932. '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_hack"></div></td>'+
  3933. '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_pierce"></div></td>'+
  3934. '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_dist"></div></td>'+
  3935. '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_ship"></div></td>'+
  3936. '</tr><tr>'+
  3937. '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>'+
  3938. '<td class="left_border place_simulator_odd" id="att_b">0</td>'+
  3939. '<td class="left_border place_simulator_even" id="att_s">0</td>'+
  3940. '<td class="left_border place_simulator_odd" id="att_d">0</td>'+
  3941. '<td class="left_border place_simulator_even" id="att_ship">0</td>'+
  3942. '</tr><tr>'+
  3943. '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>'+
  3944. '<td class="left_border place_simulator_odd" id="def_b">0</td>'+
  3945. '<td class="left_border place_simulator_even" id="def_s">0</td>'+
  3946. '<td class="left_border place_simulator_odd" id="def_d">0</td>'+
  3947. '<td class="left_border place_simulator_even" id="def_ship">0</td>'+
  3948. '</tr>'+
  3949. '</table>'+
  3950. '</div><div><h4>'+ getText("labels", "los") +'</h4>'+
  3951. '<table class="place_simulator_table loss" cellpadding="0px" cellspacing="0px" style="align:center;">'+
  3952. '<tr>'+
  3953. '<td class="place_simulator_even"></td>'+
  3954. '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_res"></div></td>'+
  3955. '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_fav"></div></td>'+
  3956. '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_pop"></div></td>'+
  3957. '</tr><tr>'+
  3958. '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>'+
  3959. '<td class="left_border place_simulator_odd" id="att_res">0</td>'+
  3960. '<td class="left_border place_simulator_even" id="att_fav">0</td>'+
  3961. '<td class="left_border place_simulator_odd" id="att_pop">0</td>'+
  3962. '</tr><tr>'+
  3963. '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>'+
  3964. '<td class="left_border place_simulator_odd" id="def_res">0</td>'+
  3965. '<td class="left_border place_simulator_even" id="def_fav">0</td>'+
  3966. '<td class="left_border place_simulator_odd" id="def_pop">0</td>'+
  3967. '</tr>'+
  3968. '</table>'+
  3969. '</div></div>').appendTo('#simulator_body');
  3970. $('#simu_table .ico').css({
  3971. height: '20px',
  3972. width: '20px'
  3973. });
  3974. $('#simu_table .units_info_sprite').css({
  3975. background: 'url(http://de.cdn.grepolis.com/images/game/units/units_info_sprite2.51.png)',
  3976. backgroundSize: '100%'
  3977. });
  3978. $('#simu_table .img_hack').css({ backgroundPosition: '0% 36%' });
  3979. $('#simu_table .img_pierce').css({ backgroundPosition: '0% 27%' });
  3980. $('#simu_table .img_dist').css({ backgroundPosition: '0% 45%' });
  3981. $('#simu_table .img_ship').css({ backgroundPosition: '0% 72%' });
  3982. $('#simu_table .img_fav').css({ background: 'url(http://gpde.innogamescdn.com/images/game/res/favor.png)', backgroundSize: '100%' });
  3983. $('#simu_table .img_res').css({ background: 'url(http://de.cdn.grepolis.com/images/game/units/units_info_sprite2.51.png) 0% 54%', backgroundSize: '100%' });
  3984. $('#simu_table .img_pop').css({ background: 'url(http://gpde.innogamescdn.com/images/game/res/pop.png)', backgroundSize: '100%' });
  3985. $('#simu_table .left_border').css({
  3986. width: '54px'
  3987. });
  3988. $('#simu_table .left_border').each(function(){
  3989. $(this)[0].align = 'center';
  3990. });
  3991. $('#simu_table .strength').tooltip(getText("labels", "str") + " (" + getText("labels", "mod") +")");
  3992. $('#simu_table .loss').tooltip(getText("labels", "los"));
  3993. // Klick auf Einheitenbild
  3994. $('.index_unit').click(function(){
  3995. var type = $(this).attr('class').split(" ")[4];
  3996. $('.place_insert_field[name="sim[units][att]['+type+']"]').change();
  3997. });
  3998. $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').on('input change', function(){
  3999. name = $(this).attr("name").replace(/\]/g, "").split("[");
  4000. var str = this;
  4001. //console.log(str);
  4002. setTimeout(function(){
  4003. var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2],
  4004. val, e;
  4005. val = parseInt($(str).val(), 10);
  4006. val = val || 0;
  4007. if(unit_type == "ground"){
  4008. unitsGround[name[2]][name[3]] = val;
  4009. if(name[2] == "def"){
  4010. calcDef(unitsGround.def);
  4011. } else {
  4012. calcOff(unitsGround.att, unitsGround.att);
  4013. }
  4014. $('#' + name[2] + '_b').get(0).innerHTML = blunt;
  4015. $('#' + name[2] + '_s').get(0).innerHTML = sharp;
  4016. $('#' + name[2] + '_d').get(0).innerHTML = dist;
  4017. } else {
  4018. var att = 0, def = 0;
  4019. unitsNaval[name[2]][name[3]] = val;
  4020. if(name[2] == "def"){
  4021. for(e in unitsNaval.def) {
  4022. if(unitsNaval.def.hasOwnProperty(e)) {
  4023. def += unitsNaval.def[e] * uw.GameData.units[e].defense;
  4024. }
  4025. }
  4026. $('#def_ship').get(0).innerHTML = def;
  4027. } else {
  4028. for(e in unitsNaval.att) {
  4029. if(unitsNaval.att.hasOwnProperty(e)) {
  4030. att += unitsNaval.att[e] * uw.GameData.units[e].attack;
  4031. }
  4032. }
  4033. $('#att_ship').get(0).innerHTML = att;
  4034. }
  4035. }
  4036. }, 100);
  4037. });
  4038. // Abfrage wegen eventueller Spionageweiterleitung
  4039. getUnitInputs();
  4040. setTimeout(function(){
  4041. setChangeUnitInputs("def");
  4042. }, 100);
  4043. $('#select_insert_units').change(function(){
  4044. var side = $(this).find('option:selected').val();
  4045. setTimeout(function(){
  4046. getUnitInputs();
  4047. if(side === "att" || side === "def"){
  4048. setChangeUnitInputs(side);
  4049. }
  4050. }, 200);
  4051. });
  4052. }
  4053. function getUnitInputs(){
  4054. $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').each(function(){
  4055. name = $(this).attr("name").replace(/\]/g, "").split("[");
  4056. var str = this;
  4057. var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2],
  4058. val, e;
  4059. val = parseInt($(str).val(), 10);
  4060. val = val || 0;
  4061. if(unit_type === "ground"){
  4062. unitsGround[name[2]][name[3]] = val;
  4063. } else {
  4064. var att = 0, def = 0;
  4065. unitsNaval[name[2]][name[3]] = val;
  4066. }
  4067. });
  4068. }
  4069. function setChangeUnitInputs(side){
  4070. $('.place_insert_field[name="sim[units][' + side + '][godsent]"]').change();
  4071. setTimeout(function(){
  4072. $('.place_insert_field[name="sim[units][' + side + '][colonize_ship]"]').change();
  4073. }, 100);
  4074. }
  4075. /*******************************************************************************************************************************
  4076. * Defense form
  4077. * ----------------------------------------------------------------------------------------------------------------------------
  4078. * | ● Adds a defense form to the bbcode bar
  4079. * ----------------------------------------------------------------------------------------------------------------------------
  4080. *******************************************************************************************************************************/
  4081. // Funktion aufteilen...
  4082. function addForm(e){
  4083. var textareaId = "", bbcodeBarId = "";
  4084. switch (e) {
  4085. case "/alliance_forum/forum":
  4086. textareaId = "#forum_post_textarea";
  4087. bbcodeBarId = "#forum";
  4088. break;
  4089. case "/message/forward":
  4090. textareaId = "#message_message";
  4091. bbcodeBarId = "#message_bbcodes";
  4092. break;
  4093. case "/message/new":
  4094. textareaId = "#message_new_message";
  4095. bbcodeBarId = "#message_bbcodes";
  4096. break;
  4097. case "/message/view":
  4098. textareaId = "#message_reply_message";
  4099. bbcodeBarId = "#message_bbcodes";
  4100. break;
  4101. case "/player_memo/load_memo_content":
  4102. textareaId = "#memo_text_area";
  4103. bbcodeBarId = "#memo_edit";
  4104. break;
  4105. }
  4106. $('<a title="Verteidigungsformular" href="#" class="dio_bbcode_option def_form" name="def_form"></a>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
  4107. $('.def_form_button').css({
  4108. cursor: 'pointer',
  4109. marginTop:'3px'
  4110. });
  4111. $(bbcodeBarId + ' .dio_bbcode_option').css({
  4112. background: 'url("http://s14.directupload.net/images/140126/lt3hyb8j.png")',
  4113. display: 'block',
  4114. float: 'left',
  4115. width: '22px',
  4116. height: '23px',
  4117. margin: '0 3px 0 0',
  4118. position: 'relative',
  4119. });
  4120. $(bbcodeBarId + ' .def_form').css({
  4121. backgroundPosition: '-89px 0px'
  4122. });
  4123. var imgArray = {
  4124. wall: 'http://de.cdn.grepolis.com/images/game/main/wall.png',
  4125. tower: 'http://de.cdn.grepolis.com/images/game/main/tower.png',
  4126. hide: 'http://de.cdn.grepolis.com/images/game/main/hide.png',
  4127. spy: 'http://s7.directupload.net/images/140114/yr993xwc.png',
  4128. pop: 'http://s7.directupload.net/images/140114/4d6xktxm.png',
  4129. rev1: 'http://s7.directupload.net/images/140115/9cv6otiu.png',
  4130. rev0: 'http://s7.directupload.net/images/140115/aue4rg6i.png',
  4131. eo1: 'http://s1.directupload.net/images/140115/fkzlipyh.png',
  4132. eo0: 'http://s1.directupload.net/images/140115/hs2kg59c.png',
  4133. att: 'http://s1.directupload.net/images/140115/3t6uy4te.png',
  4134. sup: 'http://s7.directupload.net/images/140115/ty6szerx.png',
  4135. zeus: 'http://s1.directupload.net/images/140114/cdxecrpu.png',
  4136. hera: 'http://s1.directupload.net/images/140114/mve54v2o.png',
  4137. athena: 'http://s14.directupload.net/images/140114/kyqyedhe.png',
  4138. poseidon: 'http://s7.directupload.net/images/140114/tusr9oyi.png',
  4139. hades: 'http://s7.directupload.net/images/140114/huins2gn.png',
  4140. artemis: 'http://s7.directupload.net/images/140114/kghjhko8.png',
  4141. nogod: 'http://s1.directupload.net/images/140114/e7vmvfap.png',
  4142. captain: 'http://s14.directupload.net/images/140114/88gg75rc.png',
  4143. commander: 'http://s14.directupload.net/images/140114/slbst52o.png',
  4144. priest: 'http://s1.directupload.net/images/140114/glptekkx.png',
  4145. phalanx: 'http://s7.directupload.net/images/140114/e97wby6z.png',
  4146. ram: 'http://s7.directupload.net/images/140114/s854ds3w.png',
  4147. militia: 'http://wiki.en.grepolis.com/images/9/9b/Militia_40x40.png',
  4148. sword: 'http://wiki.en.grepolis.com/images/9/9c/Sword_40x40.png',
  4149. slinger: 'http://wiki.en.grepolis.com/images/d/dc/Slinger_40x40.png',
  4150. archer: 'http://wiki.en.grepolis.com/images/1/1a/Archer_40x40.png',
  4151. hoplite: 'http://wiki.en.grepolis.com/images/b/bd/Hoplite_40x40.png',
  4152. rider: 'http://wiki.en.grepolis.com/images/e/e9/Rider_40x40.png',
  4153. chariot: 'http://wiki.en.grepolis.com/images/b/b8/Chariot_40x40.png',
  4154. catapult: 'http://wiki.en.grepolis.com/images/f/f0/Catapult_40x40.png',
  4155. godsent: 'http://wiki.de.grepolis.com/images/6/6e/Grepolis_Wiki_225.png',
  4156. def_sum: 'http://s14.directupload.net/images/140127/6cxnis9r.png',
  4157. minotaur: 'http://wiki.de.grepolis.com/images/7/70/Minotaur_40x40.png',
  4158. manticore: 'http://wiki.de.grepolis.com/images/5/5e/Manticore_40x40.png',
  4159. zyclop: 'http://wiki.de.grepolis.com/images/6/66/Zyklop_40x40.png',
  4160. sea_monster:'http://wiki.de.grepolis.com/images/7/70/Sea_monster_40x40.png',
  4161. harpy: 'http://wiki.de.grepolis.com/images/8/80/Harpy_40x40.png',
  4162. medusa: 'http://wiki.de.grepolis.com/images/d/db/Medusa_40x40.png',
  4163. centaur: 'http://wiki.de.grepolis.com/images/5/53/Centaur_40x40.png',
  4164. pegasus: 'http://wiki.de.grepolis.com/images/5/54/Pegasus_40x40.png',
  4165. cerberus: 'http://wiki.de.grepolis.com/images/6/67/Zerberus_40x40.png',
  4166. fury: 'http://wiki.de.grepolis.com/images/6/67/Erinys_40x40.png',
  4167. griffin: 'http://wiki.de.grepolis.com/images/d/d1/Unit_greif.png',
  4168. calydonian_boar: 'http://wiki.de.grepolis.com/images/9/93/Unit_eber.png',
  4169. big_transporter: 'http://wiki.en.grepolis.com/images/0/04/Big_transporter_40x40.png',
  4170. bireme: 'http://wiki.en.grepolis.com/images/4/44/Bireme_40x40.png',
  4171. attack_ship: 'http://wiki.en.grepolis.com/images/e/e6/Attack_ship_40x40.png',
  4172. demolition_ship: 'http://wiki.en.grepolis.com/images/e/ec/Demolition_ship_40x40.png',
  4173. small_transporter: 'http://wiki.en.grepolis.com/images/8/85/Small_transporter_40x40.png',
  4174. trireme: 'http://wiki.en.grepolis.com/images/a/ad/Trireme_40x40.png',
  4175. colonize_ship: 'http://wiki.en.grepolis.com/images/d/d1/Colonize_ship_40x40.png',
  4176. move_icon: 'http://de.cdn.grepolis.com/images/game/unit_overview/',
  4177. bordure: 'http://s1.directupload.net/images/140126/8y6pmetk.png'
  4178. };
  4179. $('<div class="bb_def_chooser">'+
  4180. '<div class="bbcode_box middle_center">'+
  4181. '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div>'+
  4182. '<div class="bbcode_box top_center"></div><div class="bbcode_box bottom_center"></div>'+
  4183. '<div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>'+
  4184. '<div class="bbcode_box middle_left"></div><div class="bbcode_box middle_right"></div>'+
  4185. '<div class="bbcode_box content clearfix" style="padding:5px">'+
  4186. '<div id="f_uni" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("labels", "det") +'</div></div><br><br>'+
  4187. '<div id="f_prm" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("labels", "prm") +'</div></div><br><br>'+
  4188. '<div id="f_sil" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("labels", "sil") +'</div></div><br><br>'+
  4189. '<div id="f_mov" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("labels", "mov") +'</div></div><br><br>'+
  4190. '<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>'+
  4191. '</div></div></div>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
  4192. $('.bb_def_chooser').css({
  4193. display: 'none',
  4194. top: '38px',
  4195. left: '510px',
  4196. position: 'absolute',
  4197. width: '190px',
  4198. zIndex: 10000
  4199. });
  4200. $(bbcodeBarId + " .bb_def_chooser .checkbox_new").click(function () {
  4201. $(this).toggleClass("checked");
  4202. });
  4203. $(bbcodeBarId + ' .def_form').toggle(function(){
  4204. $(this).parent().find(".bb_def_chooser").get(0).style.display = "block";
  4205. }, function(){
  4206. $(this).parent().find(".bb_def_chooser").get(0).style.display = "none";
  4207. });
  4208. $(bbcodeBarId + ' #dio_insert').click(function(){
  4209. var textarea = $(textareaId).get(0), text = $(textarea).val(), troop_table = "", troop_img = "", troop_count = "", separator = "", move_table = "", landunit_sum = 0;
  4210. $('.def_form').click();
  4211. if($('#f_uni').hasClass("checked")){
  4212. $('.units_land .unit, .units_naval .unit').each(function(){
  4213. troop_img += separator + '[img]' + imgArray[this.className.split(" ")[1]] + '[/img]';
  4214. troop_count += separator + '[center]' + $(this).find(".value").get(0).innerHTML + '[/center]';
  4215. separator = "[||]";
  4216. });
  4217. } else {
  4218. $('.units_land .unit').each(function(){
  4219. 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);
  4220. if(def > 10){
  4221. landunit_sum += parseInt($(this).find(".value").get(0).innerHTML, 10) * uw.GameData.units[a].population * ((def > 20) ? 2 : 1);
  4222. }
  4223. });
  4224. landunit_sum = (landunit_sum > 10000) ? ((Math.round(landunit_sum / 100))/10) + "k" : landunit_sum;
  4225. troop_img += '[img]'+ imgArray.def_sum +'[/img]';
  4226. troop_count += '[center]'+ landunit_sum +'[/center]';
  4227. separator = "[||]";
  4228. $('.units_naval .unit').each(function(){
  4229. troop_img += separator + '[img]' + imgArray[this.className.split(" ")[1]] + '[/img]';
  4230. troop_count += separator + '[center]' + $(this).find(".value").get(0).innerHTML + '[/center]';
  4231. });
  4232. }
  4233. if(troop_img !== ""){ troop_table = "\n[table][**]" + troop_img + "[/**][**]" + troop_count + "[/**][/table]\n"; }
  4234. var str = '[img]'+ imgArray.bordure + '[/img]'+
  4235. '\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'+
  4236. //'[table][**][img]'+ imgArray.sup +'[/img][||]'+
  4237. '[size=12][town]' + uw.ITowns.getTown(uw.Game.townId).getId() + '[/town] ([player]'+ uw.Game.player_name +'[/player])[/size]'+
  4238. //'[||][img]'+ imgArray['rev' + (uw.ITowns.getTown(uw.Game.townId).hasConqueror()?1:0)] +'[/img][/**][/table]'+
  4239. '\n\n[i][b]'+ getText("labels", "inf") +'[/b][/i]' + troop_table +
  4240. '[table][*]'+
  4241. '[img]'+ imgArray.wall +'[/img][|]\n'+
  4242. '[img]'+ imgArray.tower +'[/img][|]\n'+
  4243. '[img]'+ imgArray.phalanx +'[/img][|]\n'+
  4244. '[img]'+ imgArray.ram +'[/img][|]\n'+
  4245. ($('#f_prm').hasClass("checked") ? '[img]'+ imgArray.commander +'[/img][|]\n' : ' ')+
  4246. ($('#f_prm').hasClass("checked") ? '[img]'+ imgArray.captain +'[/img][|]\n' : ' ')+
  4247. ($('#f_prm').hasClass("checked") ? '[img]'+ imgArray.priest +'[/img][|]\n' : ' ')+
  4248. ($('#f_sil').hasClass("checked") ? '[center][img]'+imgArray.spy+'[/img][/center][|]\n' : ' ')+
  4249. '[img]'+ imgArray.pop +'[/img][|]\n'+
  4250. '[img]'+ imgArray[(uw.ITowns.getTown(uw.Game.townId).god() || "nogod")] +'[/img][/*]\n'+
  4251. '[**][center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("wall")+ '[/center][||]'+
  4252. '[center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("tower")+ '[/center][||]'+
  4253. '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.phalanx? '+' : '-') + '[/center][||]'+
  4254. '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.ram? '+' : '-')+ '[/center][||]'+
  4255. ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.commander >= uw.Timestamp.now())? '+' : '-') + '[/center][||]' : ' ')+
  4256. ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.captain >= uw.Timestamp.now())? '+' : '-')+ '[/center][||]' : ' ')+
  4257. ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.priest >= uw.Timestamp.now())? '+' : '-') + '[/center][||]' : ' ')+
  4258. ($('#f_sil').hasClass("checked") ? '[center]' + Math.round(uw.ITowns.getTown(uw.Game.townId).getEspionageStorage()/1000) + 'k[/center][||]': ' ')+
  4259. '[center]' + uw.ITowns.getTown(uw.Game.townId).getAvailablePopulation() + '[/center][||]'+
  4260. '[center]' + $('.gods_favor_amount').get(0).innerHTML + '[/center]'+
  4261. '[/**][/table]';
  4262. var bb_count_str = parseInt(str.match(/\[/g).length, 10), bb_count_move = 0;
  4263. var i = 0;
  4264. if($('#f_mov').hasClass("checked")){
  4265. move_table += '\n[i][b]'+ getText("labels", "mov") +'[/b][/i]\n[table]';
  4266. $('#toolbar_activity_commands').mouseover();
  4267. $('#toolbar_activity_commands_list .content .command').each(function(){
  4268. var cl = $(this).children()[0].className.split(" ");
  4269. 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)) {
  4270. move_table += (i%1) ? "" : "[**]";
  4271. i++;
  4272. move_table += "[img]" + imgArray.move_icon + cl[2] + ".png[/img][||]";
  4273. move_table += getArrivalTime($(this).children()[1].innerHTML) + (uw.Game.market_id === "de" ? " Uhr[||]" : " [||]");
  4274. move_table += "[town]" + JSON.parse(atob($(this).children()[2].firstChild.href.split("#")[1])).id + "[/town]";
  4275. move_table += (i%1) ? "[||]" : "[/**]";
  4276. }
  4277. bb_count_move = parseInt(move_table.match(/\[/g).length, 10);
  4278. });
  4279. if((bb_count_str + bb_count_move) > 480){
  4280. move_table += '[**]...[/**]';
  4281. }
  4282. $('#toolbar_activity_commands').mouseout();
  4283. //console.log((bb_count_str + bb_count_move));
  4284. move_table += (i%1) ? "[/**]" : "";
  4285. move_table += "[*][|][color=#800000][size=6][i] ("+ getText("labels", "dev") +": ±1s)[/i][/size][/color][/*][/table]\n";
  4286. }
  4287. str += move_table + '[img]'+ imgArray.bordure + '[/img]';
  4288. $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + str + text.substring($(textarea).get(0).selectionEnd));
  4289. });
  4290. }
  4291. function getArrivalTime(duration_time){
  4292. /*
  4293. var server_time = new Date((uw.Timestamp.server() + 7200) * 1000);
  4294.  
  4295. duration_time = duration_time.split(":");
  4296. s = server_time.getUTCSeconds() + parseInt(duration_time[2], 10);
  4297. m = server_time.getUTCMinutes() + parseInt(duration_time[1], 10) + ((s>=60)? 1 : 0);
  4298. h = server_time.getUTCHours() + parseInt(duration_time[0], 10) + ((m>=60)? 1 : 0);
  4299. */
  4300. var server_time = $('.server_time_area').get(0).innerHTML.split(" ")[0].split(":"), arrival_time, s, m, h;
  4301. duration_time = duration_time.split(":");
  4302. s = parseInt(server_time[2], 10) + parseInt(duration_time[2], 10);
  4303. m = parseInt(server_time[1], 10) + parseInt(duration_time[1], 10) + ((s>=60)? 1 : 0);
  4304. h = parseInt(server_time[0], 10) + parseInt(duration_time[0], 10) + ((m>=60)? 1 : 0);
  4305. s = s%60; m = m%60; h = h%24;
  4306. s = ((s<10) ? "0" : "") + s;
  4307. m = ((m<10) ? "0" : "") + m;
  4308. h = ((h<10) ? "0" : "") + h;
  4309. arrival_time = h + ":" + m + ":" + s;
  4310. return arrival_time;
  4311. }
  4312. /*******************************************************************************************************************************
  4313. * Smiley box
  4314. * ----------------------------------------------------------------------------------------------------------------------------
  4315. * | ● Display of a smiley selection box for text input fields (forum, messages, notes):
  4316. * | ● Used smileys: http://www.greensmilies.com/smilie-album/
  4317. * | + Own Grepolis smileys
  4318. * ----------------------------------------------------------------------------------------------------------------------------
  4319. *******************************************************************************************************************************/
  4320. var smileyArray = { "standard": {}, "nature": {}, "grepolis": {}, "people": {}, "other":{} };
  4321. // smiley categories
  4322. smileyArray.button = [ "rollsmiliey", "smile" ];
  4323. smileyArray.standard = [
  4324. "smilenew", "i/cnfy7elqh8dotnsdp", "lol", "neutral_new", "afraid", "freddus_pacman", "auslachen2", "kolobok-sanduhr", "bussi2", "winken4", "flucht2", "panik4", "ins-auge-stechen",
  4325. "seb_zunge", "fluch4_GREEN", "baby_junge2", "blush-reloaded6", "frown", "verlegen", "blush-pfeif", "stevieh_rolleyes", "daumendreh2", "baby_taptap",
  4326. "sadnew", "hust", "confusednew", "idea2", "irre", "irre4", "sleep", "candle", "nicken", "no_sad",
  4327. "thumbs-up_new", "thumbs-down_new", "bravo2", "oh-no2", "kaffee2", "drunk", "saufen", "freu-dance", "hecheln", "headstand", "rollsmiliey", "eazy_cool01", "motz", "cuinlove", "biggrin"
  4328. ];
  4329. smileyArray.nature = [
  4330. "dinosaurier07", "flu-super-gau", "ben_cat", "schwein", "hundeleine01", "blume", "ben_sharky", "ben_cow", "charly_bissig", "gehirnschnecke_confused", "mttao_fische", "mttao_angler",
  4331. "insel", "fliegeschnappen", "i/cifohy0y1cl7nckzw", /* Spinne */ "i/cifogx34asrswrcjw", /* Schiffbrüchiger */ "plapperhase", "ben_dumbo"
  4332. ];
  4333. smileyArray.grepolis = [
  4334. "mttao_wassermann", "i/cigrmpfofys5xtiks", /* Hera */ "i/cifvfsu3e2sdiipn0", /* Medusa */ "i/cigmv8wnffb3v0ifg", /* Mantikor */ "i/cigrqlp2odi2kqo24", /* Zyklop */
  4335. "i/cj1l9gndtu3nduyvi", /* Minotaurus */ "i/cj2byjendffymp88t", /* Pegasus */ "i/cj2ccmi2x8mhcoikd", /* Hydra */
  4336. "silvester_cuinlove", "mttao_schuetze", "kleeblatt2", "wallbash", /* "glaskugel4", */ "musketiere_fechtend", /* "krone-hoch",*/ "i/cifojb85jytq5h07g", // Wikinger
  4337. "mttao_waage2", "steckenpferd", /* "kinggrin_anbeten2", */ "i/cifohielywpedbyh8", /* Grepo Love */ "skullhaufen", "pferdehaufen" // "i/ckajscggscw4s2u60"
  4338. ];
  4339. smileyArray.people = [
  4340. "seb_hut5", "opa_boese2", "star-wars-yoda1-gruen", "hexefliegend", "snob", "seb_detektiv_ani", "seb_cowboy", "devil", "segen", "pirat5", "borg", "hexe3b",
  4341. "i/cifoqe3geok0jco5o", // Ägypter
  4342. "i/ciforgs313z0ae1cc", // Hippie
  4343. "eazy_polizei", "stars_elvis", "mttao_chefkoch", "nikolaus", "pirate3_biggrin", "batman_skeptisch", "tubbie1", "tubbie2", "tubbie3", "tubbie4"
  4344. ];
  4345. smileyArray.other = [
  4346. "steinwerfen", "herzen02", "scream-if-you-can", "kolobok", "headbash", "liebeskummer", "bussi", "brautpaar-reis", "grab-schaufler2", "boxen2", "aufsmaul",
  4347. "sauf", "mttao_kehren", "sm", "weckruf", "klugscheisser2", "karte2_rot", "dagegen", "party","dafuer", "outofthebox", "pokal_gold", "koepfler", "transformer"
  4348. ];
  4349. // Forum: extra smiley
  4350. if($(".editor_textbox_container").get(0)){
  4351. smileyArray.grepolis.push("i/ckajscggscw4s2u60"); // Pacman
  4352. smileyArray.grepolis.push("i/cowqyl57t5o255zli"); // Bugpolis
  4353. smileyArray.grepolis.push("i/cowquq2foog1qrbee"); // Inno
  4354. }
  4355. var id = 0, error_count = 0;
  4356. var er = false;
  4357. // preload images
  4358. function loadSmileys(){
  4359. // Replace german sign smilies
  4360. if(LID !== "de"){
  4361. smileyArray.other[17] = "dagegen2";
  4362. smileyArray.other[19] = "dafuer2";
  4363. }
  4364. for(var e in smileyArray){
  4365. if(smileyArray.hasOwnProperty(e)) {
  4366. for(var f in smileyArray[e]){
  4367. if(smileyArray[e].hasOwnProperty(f)) {
  4368. var src = smileyArray[e][f];
  4369. smileyArray[e][f] = new Image();
  4370. smileyArray[e][f].className = "smiley" + (id++);
  4371. smileyArray[e][f].style.margin = '3px';
  4372. smileyArray[e][f].style.maxHeight = '35px';
  4373. smileyArray[e][f].style.cursor = 'pointer';
  4374. if(src.substring(0,2) == "i/" ) {
  4375. smileyArray[e][f].src = "http://666kb.com/" + src + ".gif";
  4376. } else {
  4377. if(er == false){
  4378. smileyArray[e][f].src = "http://www.greensmilies.com/smile/smiley_emoticons_" + src + ".gif";
  4379. } else {
  4380. smileyArray[e][f].src = 'http://s1.directupload.net/images/140128/93x3p4co.gif';
  4381. }
  4382. }
  4383. smileyArray[e][f].onerror = function () {
  4384. this.src = 'http://s1.directupload.net/images/140128/93x3p4co.gif';
  4385. };
  4386. }
  4387. }
  4388. }
  4389. }
  4390. }
  4391. // Forum smilies
  4392. function changeForumEditorLayout(){
  4393. $('.blockrow').css({ border: "none" });
  4394. // Subject/Title
  4395. $($('.section div label[for="title"]').parent()).css({ float:"left", width:"36%", marginRight: "20px"});
  4396. $($('.section div label[for="subject"]').parent()).css({ float:"left", width:"36%", marginRight: "20px"});
  4397. $('.section div input').eq(0).css({ marginBottom: "-10px", marginTop: "10px"});
  4398. $('#display_posticon').remove();
  4399. // Posticons
  4400. $('.posticons table').css({ width: "50%", /*marginTop: "-16px"*/});
  4401. $('.posticons').css({ marginBottom: "-16px" });
  4402. $('.posticons').insertAfter($('.section div label[for="title"]').parent());
  4403. $('.posticons').insertAfter($('.section div label[for="subject"]').parent());
  4404. // Posticons hint
  4405. $('.posticons p').remove();
  4406. // Posticons: No Icon - radio button
  4407. $(".posticons [colspan='14']").parent().replaceWith($(".posticons [colspan='14']"));
  4408. $(".posticons [colspan='14']").children().wrap("<nobr></nobr>");
  4409. $(".posticons [colspan='14']").appendTo('.posticons tr:eq(0)');
  4410. $(".posticons [colspan='4']").remove();
  4411. }
  4412. function addSmileyBoxForum(){
  4413. $('<div class="smiley_box"><div>'+
  4414. '<div align="center" style="float:left">'+
  4415. '<a class="group" name="standard">'+ getText("labels", "std") +' </a>'+
  4416. '<a class="group" name="grepolis">'+ getText("labels", "gre") +' </a>'+
  4417. '<a class="group" name="nature">'+ getText("labels", "nat") +' </a>'+
  4418. '<a class="group" name="people">'+ getText("labels", "ppl") +' </a>'+
  4419. '<a class="group" name="other">'+ getText("labels", "oth") +' </a>'+
  4420. '</div><div align="right" style="margin-top:2px;"><a class="smiley_link" href="http://adf.ly/eDbBl" target="_blank">WWW.GREENSMILIES.COM</a></div>'+
  4421. '<hr class="smiley_hr">'+
  4422. '<div class="smiley_box_cont" style="overflow: hidden;"><hr class="smiley_hr"></div>'+
  4423. '</div></div><br>').insertAfter(".texteditor");
  4424. addSmileys("standard", "");
  4425. $('.smiley_hr').css({ margin: '3px 0px 0px 0px', color: '#086b18', border: '1px solid' });
  4426. $('.smiley_link').css({ color: '#0c450c' });
  4427. $('.smiley_link').hover(
  4428. function(){$(this).css({ color: '#14999E' });},
  4429. function(){$(this).css({ color: '#0c450c' });}
  4430. );
  4431. $('.smiley_box').css({ maxHeight: '90px', marginLeft: "5px", width: "99%", minHeight:"10px" });
  4432. $('.smiley_box_cont').css({ overflow: 'overlay', minHeight: '70px', marginBottom: '10px' });
  4433. $('.group').css({ color:'#0c450c', marginRight: '10px', cursor:"pointer"}); $('.group[name="standard"]').css({ color:'#089421' });
  4434. $('.group').click(function(){
  4435. $('.group').each(function(){
  4436. $(this).get(0).style.color = '#0c450c';
  4437. });
  4438. $(this).get(0).style.color = '#089421';
  4439. // change smiley group
  4440. addSmileys($(this).get(0).name, "");
  4441. });
  4442. }
  4443. // add smiley box
  4444. function addSmileyBox(e){
  4445. var bbcodeBarId = "";
  4446. switch (e) {
  4447. case "/alliance_forum/forum": bbcodeBarId = "#forum";
  4448. break;
  4449. case "/message/forward": bbcodeBarId = "#message_bbcodes";
  4450. break;
  4451. case "/message/new": bbcodeBarId = "#message_bbcodes";
  4452. break;
  4453. case "/message/view": bbcodeBarId = "#message_bbcodes";
  4454. break;
  4455. case "/player_memo/load_memo_content": bbcodeBarId = "#memo_edit";
  4456. break;
  4457. }
  4458. if(($(bbcodeBarId + ' #emots_popup_7').get(0) || $(bbcodeBarId + ' #emots_popup_15').get(0)) && PID == 84367){
  4459. $(bbcodeBarId + " .bb_button_wrapper").get(0).lastChild.remove();
  4460. }
  4461. $('<img class="smiley_button" src="http://www.greensmilies.com/smile/smiley_emoticons_smile.gif">').appendTo(bbcodeBarId + ' .bb_button_wrapper');
  4462. $('<div class="smiley_box">'+
  4463. '<div class="bbcode_box middle_center"><div class="bbcode_box middle_right"></div><div class="bbcode_box middle_left"></div>'+
  4464. '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div><div class="bbcode_box top_center"></div>'+
  4465. '<div class="bbcode_box bottom_center"></div><div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>'+
  4466. '<div align="center" style="width:100%;">'+
  4467. '<a class="group" name="standard" href="">'+ getText("labels", "std") +' </a>'+
  4468. '<a class="group" name="grepolis" href="">'+ getText("labels", "gre") +' </a>'+
  4469. '<a class="group" name="nature" href="">'+ getText("labels", "nat") +' </a>'+
  4470. '<a class="group" name="people" href="">'+ getText("labels", "ppl") +' </a>'+
  4471. '<a class="group" name="other" href="">'+ getText("labels", "oth") +' </a>'+
  4472. '</div>'+
  4473. '<hr class="smiley_hr">'+
  4474. '<div class="smiley_box_cont" style="overflow: hidden;"></div>'+
  4475. '<hr class="smiley_hr">'+
  4476. '<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>'+
  4477. '</div>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
  4478. $(bbcodeBarId + ' .smiley_button').css({
  4479. cursor: 'pointer',
  4480. margin:'3px 2px 2px 2px'
  4481. });
  4482. $(bbcodeBarId + ' .smiley_box').css({
  4483. zIndex: '5000',
  4484. position: 'absolute',
  4485. top: '27px',
  4486. left: '430px',
  4487. width: '300px',
  4488. display: 'none'
  4489. });
  4490. $(bbcodeBarId + ' .smiley_link').css({
  4491. color: '#086b18',
  4492. fontSize: '0.6em'
  4493. });
  4494. $(bbcodeBarId + ' .smiley_hr').css({
  4495. margin: '3px 0px 0px 0px',
  4496. color: '#086b18',
  4497. border: '1px solid'
  4498. });
  4499. $(bbcodeBarId + ' .group').css({
  4500. color:'#0c450c'
  4501. });
  4502. $(bbcodeBarId + ' .group[name="standard"]').css({
  4503. color:'#089421'
  4504. });
  4505. $(bbcodeBarId + ' .group').click(function(){
  4506. $("#"+ $(this).closest('.bb_button_wrapper').parent().get(0).id +' .group').each(function(){
  4507. $(this).get(0).style.color = '#0c450c';
  4508. });
  4509. $(this).get(0).style.color = '#089421';
  4510. // change smiley group
  4511. addSmileys($(this).get(0).name, "#"+ $(this).closest('.bb_button_wrapper').parent().get(0).id);
  4512. });
  4513. addSmileys("standard", bbcodeBarId);
  4514. // smiley box toggle
  4515. $(bbcodeBarId + " .smiley_button").toggle(
  4516. function(){
  4517. $(this).get(0).src = smileyArray.button[0].src;
  4518. $(this).closest('.bb_button_wrapper').find(".smiley_box").get(0).style.display = "block";
  4519. },
  4520. function(){
  4521. $(this).get(0).src = smileyArray.button[1].src;
  4522. $(this).closest('.bb_button_wrapper').find(".smiley_box").get(0).style.display = "none";
  4523. }
  4524. );
  4525. }
  4526. if($(".editor_textbox_container").get(0)){
  4527. loadSmileys();
  4528. changeForumEditorLayout();
  4529. addSmileyBoxForum();
  4530. }
  4531. // insert smileys from arrays into smiley box
  4532. function addSmileys(type, bbcodeBarId){
  4533. // reset smilies
  4534. if($(bbcodeBarId + " .smiley_box_cont").get(0)) {$(bbcodeBarId + " .smiley_box_cont").get(0).innerHTML='';}
  4535. // add smilies
  4536. for(var e in smileyArray[type]){
  4537. if(smileyArray[type].hasOwnProperty(e)) {
  4538. //$(smileyArray[type][e]).clone();
  4539. $('<img src="' + smileyArray[type][e].src + '" class="smiley">').appendTo(bbcodeBarId + " .smiley_box_cont");
  4540. }
  4541. }
  4542. $('.smiley').css({ margin:'3px', maxHeight:'35px', cursor:'pointer' });
  4543. $(bbcodeBarId + " .smiley_box_cont .smiley").click(function(){
  4544. var textarea;
  4545. if(uw.location.pathname === "/game/index"){
  4546. // hide smiley box
  4547. $(this).closest('.bb_button_wrapper').find(".smiley_button").click();
  4548. // find textarea
  4549. textarea = $(this).closest('.gpwindow_content').find("textarea").get(0);
  4550. } else {
  4551. if($('.editor_textbox_container').get(0)) {
  4552. textarea = $('.editor_textbox_container .cke_contents textarea').get(0);
  4553. } else {
  4554. $(this).appendTo('iframe .forum');
  4555. }
  4556. //$(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + "[img]"+ $(this).get(0).src + "[/img]" + text.substring($(textarea).get(0).selectionEnd));
  4557. }
  4558. var text = $(textarea).val();
  4559. $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + "[img]"+ $(this).get(0).src + "[/img]" + text.substring($(textarea).get(0).selectionEnd));
  4560. });
  4561. }
  4562. /*******************************************************************************************************************************
  4563. * Biremes counter
  4564. * ----------------------------------------------------------------------------------------------------------------------------
  4565. * | ● Incremental update when calling a city (experimental, especially intended for siege worlds)
  4566. * ----------------------------------------------------------------------------------------------------------------------------
  4567. * *****************************************************************************************************************************/
  4568. var count, townId;
  4569. function updateBiriCount(){
  4570. var sum =0, e;
  4571. for(e in biriArray) {
  4572. if(biriArray.hasOwnProperty(e)) {
  4573. if(!uw.ITowns.getTown(e)) { // town is no longer in possession of user
  4574. delete biriArray[e];
  4575. saveBiri();
  4576. } else {
  4577. sum += parseInt(biriArray[e], 10);
  4578. }
  4579. }
  4580. }
  4581. if(DATA.options.bir){
  4582. sum = sum.toString();
  4583. var str ="", fsize = ['1.4em', '1.2em', '1.15em', '1.1em', '1.0em'], i;
  4584. for(i = 0; i<sum.length; i++){
  4585. str += "<span style='font-size:" + fsize[i] + "'>" + sum[i] + "</span>";
  4586. }
  4587. $('#bi_count').get(0).innerHTML = "<b>" + str + "</b>";
  4588. }
  4589. }
  4590. function getBiri(){
  4591. var biremeIn = parseInt(uw.ITowns.getTown(uw.Game.townId).units().bireme, 10),
  4592. biremeOut = parseInt(uw.ITowns.getTown(uw.Game.townId).unitsOuter().bireme, 10);
  4593. if(isNaN(biremeIn)) biremeIn = 0;
  4594. if(isNaN(biremeOut)) biremeOut = 0;
  4595. if(!biriArray[uw.Game.townId] || biriArray[uw.Game.townId] < (biremeIn + biremeOut)) {
  4596. biriArray[uw.Game.townId] = biremeIn;
  4597. }
  4598. updateBiriCount();
  4599. saveBiri();
  4600. }
  4601. function getBiriDocks(){
  4602. var windowID = uw.BuildingWindowFactory.getWnd().getID(),
  4603. biremeTotal = parseInt($('#gpwnd_' + windowID + ' #unit_order_tab_bireme .unit_order_total').get(0).innerHTML, 10);
  4604. if(!isNaN(biremeTotal)) biriArray[uw.Game.townId] = biremeTotal;
  4605. updateBiriCount();
  4606. saveBiri();
  4607. }
  4608. function getBiriAgora(){
  4609. var biremeTotal = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().bireme, 10);
  4610. if(isNaN(biremeTotal)) biremeTotal = 0;
  4611. $('#units_beyond_list .bireme').each(function(){
  4612. biremeTotal += parseInt($(this).get(0).children[0].innerHTML, 10);
  4613. });
  4614. biriArray[uw.Game.townId] = biremeTotal;
  4615. updateBiriCount();
  4616. saveBiri();
  4617. }
  4618. function saveBiri(){
  4619. saveValue(WID + "_biremes", JSON.stringify(biriArray));
  4620. }
  4621. function initBiri() {
  4622. $(".picomap_container").prepend("<div id='unit_count'><div id='bi_count'></div></div>");
  4623. updateBiriCount();
  4624. $('#unit_count').css({
  4625. background: 'url(http://de.cdn.grepolis.com/images/game/units/units_sprite_90x90_compressed.jpg)',
  4626. height: '90px',
  4627. width: '90px',
  4628. position: 'relative',
  4629. margin: '5px 28px 0px 28px',
  4630. backgroundPosition: '-270px 0px'
  4631. });
  4632. $('#bi_count').css({
  4633. color: '#826021',
  4634. position: 'relative',
  4635. top: '28px',
  4636. fontStyle: 'italic',
  4637. width: '79px'
  4638. });
  4639. $('.picomap_overlayer').tooltip(getText("options", "bir")[0]);
  4640. // Set Sea-ID beside the bull eye
  4641. $('#sea_id').prependTo('#ui_box');
  4642. $('#sea_id').css({
  4643. background: 'none',
  4644. fontSize: '25px',
  4645. cursor: 'default',
  4646. height: '50px',
  4647. width: '50px',
  4648. position: 'absolute',
  4649. top: '70px',
  4650. left: '157px',
  4651. zIndex: 30
  4652. });
  4653. }
  4654. /*******************************************************************************************************************************
  4655. * Popups
  4656. * ----------------------------------------------------------------------------------------------------------------------------
  4657. * | ● Available units (no supporting or outer units)
  4658. * | ● Improved favor
  4659. * | ● getTownTypes
  4660. * ----------------------------------------------------------------------------------------------------------------------------
  4661. *******************************************************************************************************************************/
  4662. var groupUnitArray = {};
  4663. // TODO: split Function (getUnits, calcUnitsSum, availableUnits, countBiremes, getTownTypes)?
  4664. function getAllUnits(){
  4665. try {
  4666. var townArray = uw.ITowns.getTowns(), groupArray = uw.ITowns.townGroups.getGroupsDIO(),
  4667. unitArray = {"sword":0, "archer":0, "hoplite":0, "chariot":0, "godsent":0, "rider":0, "slinger":0, "catapult":0, "small_transporter":0, "big_transporter":0,
  4668. "manticore":0, "harpy":0, "pegasus":0, "cerberus":0, "minotaur":0, "medusa":0, "zyklop":0, "centaur":0, "fury":0, "sea_monster":0 },
  4669. unitArraySea = {"bireme":0, "trireme":0, "attack_ship":0, "demolition_ship":0, "colonize_ship":0 };
  4670. if(uw.Game.hasArtemis){
  4671. unitArray = $.extend(unitArray, {"griffin":0, "calydonian_boar":0});
  4672. }
  4673. unitArray = $.extend(unitArray, unitArraySea);
  4674. for(var group in groupArray){
  4675. if(groupArray.hasOwnProperty(group)){
  4676. // clone Object "unitArray"
  4677. groupUnitArray[group] = Object.create(unitArray);
  4678. for(var town in groupArray[group].towns){
  4679. if(groupArray[group].towns.hasOwnProperty(town)){
  4680. var type = { lo: 0, ld: 0, so: 0, sd: 0, fo: 0, fd: 0 }; // Type for TownList
  4681. for(var unit in unitArray){
  4682. if(unitArray.hasOwnProperty(unit)){
  4683. // All Groups: Available units
  4684. var tmp = parseInt(uw.ITowns.getTown(town).units()[unit], 10);
  4685. groupUnitArray[group][unit] += tmp || 0;
  4686. // Only for group "All"
  4687. if(group == -1){
  4688. //Bireme counter
  4689. if( unit === "bireme" && ((biriArray[townArray[town].id] || 0) < (tmp || 0))) {
  4690. biriArray[townArray[town].id] = tmp;
  4691. }
  4692. //TownTypes
  4693. if(!uw.GameData.units[unit].is_naval){
  4694. if(uw.GameData.units[unit].flying){
  4695. type.fd += ((uw.GameData.units[unit].def_hack + uw.GameData.units[unit].def_pierce + uw.GameData.units[unit].def_distance)/3 * (tmp || 0));
  4696. type.fo += (uw.GameData.units[unit].attack * (tmp || 0));
  4697. } else {
  4698. type.ld += ((uw.GameData.units[unit].def_hack + uw.GameData.units[unit].def_pierce + uw.GameData.units[unit].def_distance)/3 * (tmp || 0));
  4699. type.lo += (uw.GameData.units[unit].attack * (tmp || 0));
  4700. }
  4701. } else {
  4702. type.sd += (uw.GameData.units[unit].defense * (tmp || 0));
  4703. type.so += (uw.GameData.units[unit].attack * (tmp || 0));
  4704. }
  4705. }
  4706. }
  4707. }
  4708. // Only for group "All"
  4709. if(group == -1){
  4710. // Icon: DEF or OFF?
  4711. var z = ((type.sd + type.ld + type.fd) <= (type.so + type.lo + type.fo)) ? "o" : "d",
  4712. temp = 0;
  4713. for(var t in type){
  4714. if(type.hasOwnProperty(t)){
  4715. // Icon: Land/Sea/Fly (t[0]) + OFF/DEF (z)
  4716. if(temp < type[t]){
  4717. autoTownTypes[townArray[town].id] = t[0] + z;
  4718. temp = type[t];
  4719. }
  4720. // Icon: Troops Outside (overwrite)
  4721. if(temp < 1000){
  4722. autoTownTypes[townArray[town].id] = "no";
  4723. }
  4724. }
  4725. }
  4726. // Icon: Empty Town (overwrite)
  4727. var popBuilding = 0, buildVal = uw.GameData.buildings, levelArray = townArray[town].buildings().getLevels(),
  4728. popMax = Math.floor(buildVal.farm.farm_factor * Math.pow(townArray[town].buildings().getBuildingLevel("farm"), buildVal.farm.farm_pow)), // Population from farm level
  4729. popPlow = townArray[town].researches().attributes.plow ? 200 : 0,
  4730. popFactor = townArray[town].buildings().getBuildingLevel("thermal") ? 1.1 : 1.0, // Thermal
  4731. popExtra = townArray[town].getPopulationExtra();
  4732. for(var b in levelArray){
  4733. if(levelArray.hasOwnProperty(b)){
  4734. popBuilding += Math.round(buildVal[b].pop * Math.pow(levelArray[b], buildVal[b].pop_factor));
  4735. }
  4736. }
  4737. population[town] = {};
  4738. population[town].max = popMax * popFactor + popPlow + popExtra;
  4739. population[town].buildings = popBuilding;
  4740. population[town].units = parseInt((population[town].max - (popBuilding + townArray[town].getAvailablePopulation()) ), 10);
  4741. if(population[town].units < 300){
  4742. autoTownTypes[townArray[town].id] = "po";
  4743. }
  4744. population[town].percent = Math.round(100/(population[town].max - popBuilding) * population[town].units);
  4745. }
  4746. }
  4747. }
  4748. }
  4749. }
  4750. updateBiriCount();
  4751. saveBiri();
  4752. updateAvailableUnitsBox(groupUnitArray[-1]);
  4753. } catch(error){
  4754. errorHandling(error, "getAllUnits"); // TODO: Eventueller Fehler in Funktion
  4755. }
  4756. }
  4757. function addFunctionToITowns(){
  4758. // Copy function and prevent an error
  4759. uw.ITowns.townGroups.getGroupsDIO = function(){
  4760. var town_groups_towns=MM.collections.TownGroupTown[0],
  4761. town_groups=MM.collections.TownGroup[0],
  4762. groups={};
  4763. town_groups_towns.each(function(town_group_town){
  4764. var gid=town_group_town.getGroupId(),
  4765. group=groups[gid],
  4766. town_id=town_group_town.getTownId();
  4767. if(!group){
  4768. groups[gid] = group = {
  4769. id:gid,
  4770. //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
  4771. towns:{}
  4772. };
  4773. }
  4774. group.towns[town_id]={id:town_id};
  4775. //groups[gid].towns[town_id]={id:town_id};
  4776. });
  4777. //console.log(groups);
  4778. return groups;
  4779. };
  4780. }
  4781. function addAvailableUnitsBox(){
  4782. try {
  4783. var groupArray = uw.ITowns.townGroups.getGroupsDIO(),
  4784. default_title = DM.getl10n("place", "support_overview").options.troop_count + " ("+ DM.getl10n("hercules2014", "available")+")";
  4785. if(default_title.length >= 20){
  4786. default_title = default_title.substr(0, default_title.indexOf("("));
  4787. }
  4788. $('<div id="available_units_box" class="ui-dialog">'+
  4789. '<div class="bbcode_box middle_center"><div class="bbcode_box middle_right"></div><div class="bbcode_box middle_left"></div>'+
  4790. '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div><div class="bbcode_box top_center"></div>'+
  4791. '<div class="bbcode_box bottom_center"></div><div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>'+
  4792. '<h4><nobr>'+ (LANG.hasOwnProperty(LID) ? getText("labels", "uni") : default_title) + '</nobr></h4>'+
  4793. '<div class="drop_box">'+
  4794. '<div class="drop_group dropdown default">'+
  4795. '<div class="border-left"></div><div class="border-right"></div>'+
  4796. '<div class="caption" name="'+ groupArray[-1].id +'">'+ ITowns.town_groups._byId[groupArray[-1].id].attributes.name +'</div>'+
  4797. '<div class="arrow"></div>'+
  4798. '</div>'+
  4799. '<div class="select_group dropdown-list default active"><div class="item-list"></div></div>'+
  4800. '</div><hr>'+
  4801. '<div class="box_content"></div>'+
  4802. '</div>').appendTo('body');
  4803. for(var group in groupArray){
  4804. if(groupArray.hasOwnProperty(group)){
  4805. var group_name = ITowns.town_groups._byId[group].attributes.name;
  4806. $('<div class="option'+ (group == -1 ? " sel" : "") +'" name="'+ group +'">'+ group_name +'</div>').appendTo('#available_units_box .item-list');
  4807. }
  4808. }
  4809. // Styles
  4810. $('#available_units_box .drop_box').css({
  4811. float: 'left',
  4812. position: 'absolute',
  4813. top: '1px',
  4814. right: '0px',
  4815. width: '90px',
  4816. zIndex: '1'
  4817. });
  4818. $('#available_units_box h4').css({
  4819. color: 'rgb(128, 64, 0)',
  4820. width: '10px',
  4821. height: '25px',
  4822. marginLeft: '4px',
  4823. lineHeight: '1.9'
  4824. });
  4825. $('#available_units_box .drop_group').css({
  4826. width: '84px'
  4827. });
  4828. $('#available_units_box .select_group').css({
  4829. position: 'absolute',
  4830. width: '80px',
  4831. display: "none",
  4832. right: '3px'
  4833. });
  4834. //$('#available_units_box .item-list').css({ maxHeight: '400px', maxWidth: '200px', align: "right" });
  4835. $('#available_units_box .arrow').css({
  4836. width: '18px',
  4837. height: '18px',
  4838. background: 'url('+ drop_out.src +') no-repeat -1px -1px',
  4839. position: 'absolute'
  4840. });
  4841. // hover effects of the elements in the drop menu
  4842. $('#available_units_box .option').hover(
  4843. function(){ $(this).css({color: '#fff', background: "#328BF1"}); },
  4844. function(){ $(this).css({color: '#000', background: "#FFEEC7"}); }
  4845. );
  4846. // click events of the drop menu
  4847. $('#available_units_box .select_group .option').each(function(){
  4848. $(this).click(function(e){
  4849. $(this).parent().find(".sel").toggleClass("sel");
  4850. $(this).toggleClass("sel");
  4851. $('#available_units_box .drop_group .caption').attr("name", $(this).attr("name"));
  4852. $('#available_units_box .drop_group .caption').get(0).innerHTML = $(this).get(0).innerHTML;
  4853. $('#available_units_box .select_group')[0].style.display = "none";
  4854. updateAvailableUnitsBox(groupUnitArray[$(this).attr("name")]);
  4855. //$('#available_units_box .drop_group .caption').change();
  4856. });
  4857. });
  4858. // show & hide drop menu on click
  4859. $('#available_units_box .drop_group').click(function(){
  4860. if($('#available_units_box .select_group')[0].style.display === "none"){
  4861. $('#available_units_box .select_group')[0].style.display = "block";
  4862. } else {
  4863. $('#available_units_box .select_group')[0].style.display = "none";
  4864. }
  4865. });
  4866. $('#available_units_box').click(function(e){
  4867. var clicked = $(e.target);
  4868. if(!(clicked[0].parentNode.className.split(" ")[1] === "dropdown")){
  4869. $('#available_units_box .select_group').get(0).style.display = "none";
  4870. }
  4871. });
  4872. // hover arrow change
  4873. $('#available_units_box .dropdown').hover(function(e){
  4874. $(e.target)[0].parentNode.childNodes[3].style.background = "url('"+ drop_over.src +"') no-repeat -1px -1px";
  4875. }, function(e){
  4876. $(e.target)[0].parentNode.childNodes[3].style.background = "url('"+ drop_out.src +"') no-repeat -1px -1px";
  4877. });
  4878. //$("#available_units_box .drop_group .caption").attr("name", "All");
  4879. //$('#available_units_box .drop_group').tooltip();
  4880. $('#available_units_box').draggable({
  4881. containment: "body",
  4882. snap: "body",
  4883. });
  4884. $('#available_units_box').css({
  4885. color: 'rgb(12, 69, 12)',
  4886. position: 'absolute',
  4887. top: '100px',
  4888. left: '200px',
  4889. zIndex: getMaxZIndex() + 1,
  4890. display: 'none'
  4891. });
  4892. $('#available_units_box .box_content').css({
  4893. background: 'url(http://s1.directupload.net/images/140206/8jd9d3ec.png) 94% 94% no-repeat',
  4894. backgroundSize: '140px'
  4895. });
  4896. $('#available_units_box').bind("mousedown",function(){
  4897. $(this).get(0).style.zIndex = getMaxZIndex() + 1;
  4898. });
  4899. $('#available_units_box hr').css({ margin: '3px 0px 0px', border: '1px solid', color: 'rgb(128, 64, 0)'});
  4900. } catch(error){
  4901. errorHandling(error, "addAvailableUnitsBox");
  4902. }
  4903. }
  4904. function updateAvailableUnitsBox(unitArray){
  4905. var i = 0, content = '<table><tr><td>', ttpArray = {};
  4906. for(var u in unitArray){
  4907. if(unitArray.hasOwnProperty(u)){
  4908. if(((i%5 == 0) && (i!== 25)) || u == "bireme") {
  4909. content += "</td></tr><tr><td>";
  4910. }
  4911. content += '<div class="unit index_unit bold unit_icon40x40 ' + u + ' " ><span style="font-size:0.9em">' + unitArray[u] + '</span></div> ';
  4912. ttpArray[u] = GameData.units[u].name;
  4913. i++;
  4914. }
  4915. }
  4916. content += '</td></tr></table>';
  4917. $('#available_units_box .box_content').get(0).innerHTML = "";
  4918. $('#available_units_box .box_content').append(content);
  4919. // Unit name tooltips
  4920. for(var o in ttpArray){
  4921. if(ttpArray.hasOwnProperty(o)){
  4922. $("#available_units_box ."+ o).tooltip(ttpArray[o]);
  4923. }
  4924. }
  4925. }
  4926. function unbindFavorPopup(){
  4927. //$('.gods_favor_button_area, #favor_circular_progress').mouseover();
  4928. //$('.gods_favor_button_area, #favor_circular_progress').mouseout();
  4929. $('.gods_favor_button_area, #favor_circular_progress').bind('mouseover mouseout', function(){
  4930. return false;
  4931. });
  4932. $('.gods_area').bind('mouseover', function(){
  4933. setFavorPopup();
  4934. });
  4935. }
  4936. var godArray = {
  4937. zeus: ' 0px', //'http://s1.directupload.net/images/140116/mkhzwush.png',
  4938. hera: '-152px', //'http://s1.directupload.net/images/140116/58ob8z82.png',
  4939. poseidon: '-101px', //'http://s1.directupload.net/images/140116/dkfxrw2f.png',
  4940. athena: ' -50px', //'http://s14.directupload.net/images/140116/iprgopak.png',
  4941. hades: '-203px', //'http://s14.directupload.net/images/140116/c9juk95y.png',
  4942. artemis: '-305px', //'http://s14.directupload.net/images/140116/pdc8vxe2.png'
  4943. };
  4944. var godImg = new Image(); godImg.src = "http://diotools.pf-control.de/images/game/gods.png";
  4945. function setFavorPopup(){
  4946. var pic_row = "",
  4947. fav_row = "",
  4948. prod_row = "";
  4949. for(var g in godArray){
  4950. if(godArray.hasOwnProperty(g)){
  4951. if(uw.ITowns.player_gods.attributes.temples_for_gods[g]){
  4952. pic_row += '<td><div style="width:50px;height:51px;background:url('+ godImg.src +');background-position: 0px '+ godArray[g] +';"></td>';
  4953. fav_row += '<td class="bold" style="color:blue">'+ uw.ITowns.player_gods.attributes[g + "_favor"] +'</td>';
  4954. prod_row += '<td class="bold">'+ uw.ITowns.player_gods.attributes.production_overview[g].production +'</td>';
  4955. }
  4956. }
  4957. }
  4958. var tool_element = $('<table><tr><td></td>'+ pic_row +'</tr>'+
  4959. '<tr align="center"><td><img src="http://de.cdn.grepolis.com/images/game/res/favor.png"></td>'+ fav_row +'</tr>'+
  4960. '<tr align="center"><td>+</td>'+ prod_row +'</tr>'+
  4961. '</table>');
  4962. $('.gods_favor_button_area, #favor_circular_progress').tooltip(tool_element);
  4963. }
  4964. /*******************************************************************************************************************************
  4965. * GUI Optimization
  4966. * ----------------------------------------------------------------------------------------------------------------------------
  4967. * | ● Modified spell box (smaller, moveable & position memory)
  4968. * | ● Larger taskbar and minimize daily reward-window on startup
  4969. * | ● Modify chat
  4970. * | ● Improved display of troops and trade activity boxes (movable with position memory on startup)
  4971. * ----------------------------------------------------------------------------------------------------------------------------
  4972. *******************************************************************************************************************************/
  4973. // Spell box
  4974. function catchSpellBox(){
  4975. $.Observer(uw.GameEvents.ui.layout_gods_spells.rendered).subscribe('DIO_SPELLBOX_CHANGE_OPEN', function () {
  4976. if(spellbox.show == false) {
  4977. spellbox.show = true;
  4978. saveValue("spellbox", JSON.stringify(spellbox));
  4979. }
  4980. changeSpellBox();
  4981. });
  4982. $.Observer(uw.GameEvents.ui.layout_gods_spells.state_changed).subscribe('DIO_SPELLBOX_CLOSE', function () {
  4983. spellbox.show = false;
  4984. saveValue("spellbox", JSON.stringify(spellbox));
  4985. });
  4986. }
  4987. function initSpellBox(){
  4988. try {
  4989. $('<style type="text/css">'+
  4990. '.gods_spells_active .nui_right_box {'+
  4991. 'overflow: visible !important;'+
  4992. '</style>').appendTo('head');
  4993. $(".gods_spells_menu").css({
  4994. width: "134px"
  4995. });
  4996. $("#ui_box .gods_area .gods_spells_menu .content").css({
  4997. background: "url(http://gpzz.innogamescdn.com/images/game/layout/power_tile.png) 1px 4px",
  4998. overflow: "auto",
  4999. margin: "0 0 0px 0px",
  5000. border: "3px inset rgb(16, 87, 19)",
  5001. borderRadius: "10px"
  5002. });
  5003. $('.nui_units_box').css({
  5004. display: 'block',
  5005. marginTop: '-8px',
  5006. position: 'relative'
  5007. });
  5008. $('.nui_units_box .bottom_ornament').css({
  5009. marginTop: '-28px',
  5010. position: 'relative'
  5011. });
  5012. $('.gods_area').css({
  5013. height: '150px'
  5014. });
  5015. if($(".gods_spells_menu .left").get(0)){
  5016. $(".gods_spells_menu .left").remove(); $(".gods_spells_menu .right").remove();
  5017. $(".gods_spells_menu .top").remove(); $(".gods_spells_menu .bottom").remove();
  5018. }
  5019. $(".gods_spells_menu").draggable({
  5020. containment: "body",
  5021. distance: 10 ,
  5022. snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, #island_quests_overview",
  5023. opacity: 0.7,
  5024. stop : function(){
  5025. spellbox.top = this.style.top;
  5026. spellbox.left = this.style.left;
  5027. saveValue("spellbox", JSON.stringify(spellbox));
  5028. }
  5029. });
  5030. $(".gods_area .gods_spells_menu").before($('.nui_units_box'));
  5031. // Position
  5032. $('.gods_spells_menu').css({
  5033. position: 'absolute',
  5034. left: spellbox.left,
  5035. top: spellbox.top,
  5036. zIndex: '5000',
  5037. padding: '30px 0px 0px -4px'
  5038. });
  5039. // Active at game start?
  5040. if(spellbox.show) {
  5041. $('.btn_gods_spells').click();
  5042. }
  5043. } catch(error){
  5044. errorHandling(error, "initSpellBox");
  5045. }
  5046. }
  5047. function changeSpellBox(){
  5048. try {
  5049. $(".gods_spells_menu").css({
  5050. //height: "300px"
  5051. //height: $(".nui_units_box").height() + "px"
  5052. });
  5053. //console.log($(".nui_units_box").height());
  5054. $('.god_container[data-god_id="zeus"]').css({
  5055. //float: 'left'
  5056. });
  5057. $('.powers_container').css({
  5058. background: 'none'
  5059. });
  5060. $('.god_container').css({
  5061. float: 'left'
  5062. });
  5063. $('.god_container[data-god_id="zeus"], .god_container[data-god_id="athena"]').css({
  5064. float: 'none'
  5065. });
  5066. $('.content .title').each(function(){
  5067. $(this).get(0).style.display = "none";
  5068. });
  5069. $('.god_container[data-god_id="poseidon"]').prependTo('.gods_spells_menu .content');
  5070. $('.god_container[data-god_id="athena"]').appendTo('.gods_spells_menu .content');
  5071. $('.god_container[data-god_id="artemis"]').appendTo('.gods_spells_menu .content');
  5072. if($('.bolt').get(0)) { $('.bolt').remove(); }
  5073. if($('.earthquake').get(0)) { $('.earthquake').remove(); }
  5074. if($('.pest').get(0)) { $('.pest').remove(); }
  5075. } catch(error){
  5076. errorHandling(error, "changeSpellBox");
  5077. }
  5078. }
  5079. // Minimize Daily reward window on startup
  5080. function minimizeDailyReward(){
  5081. /*
  5082. $.Observer(uw.GameEvents.window.open).subscribe('DIO_WINDOW', function(u,dato){});
  5083. $.Observer(uw.GameEvents.window.reload).subscribe('DIO_WINDOW2', function(f){});
  5084. */
  5085. if(MutationObserver) {
  5086. var startup = new MutationObserver(function(mutations) {
  5087. mutations.forEach(function(mutation) {
  5088. if(mutation.addedNodes[0]){
  5089. if($('.daily_login').get(0)){ // && !uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).isMinimized()
  5090. $('.daily_login').find(".minimize").click();
  5091. //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).minimize();
  5092. }
  5093. }
  5094. });
  5095. });
  5096. startup.observe($('body').get(0), { attributes: false, childList: true, characterData: false});
  5097. setTimeout(function(){ startup.disconnect();}, 3000);
  5098. }
  5099. }
  5100. // Larger taskbar
  5101. function scaleTaskbar(){
  5102. $('.minimized_windows_area').get(0).style.width= "150%";
  5103. $('.minimized_windows_area').get(0).style.left= "-25%";
  5104. }
  5105. // hide fade out buttons => only for myself
  5106. function hideNavElements() {
  5107. if(uw.Game.premium_features.curator<=uw.Timestamp.now()){
  5108. $('.nav').each(function() {
  5109. $(this).get(0).style.display = "none";
  5110. });
  5111. }
  5112. }
  5113. /*******************************************************************************************************************************
  5114. * Modify Chat
  5115. *******************************************************************************************************************************/
  5116. function popupChatUser(){ // not used yet
  5117. setTimeout(function(){
  5118. GM_xmlhttpRequest({
  5119. method: "POST",
  5120. url: "http://wwwapi.iz-smart.net/modules.php?name=Chaninfo&file=nicks&chan=Grepolis"+ uw.Game.market_id.toUpperCase(),
  5121. onload: function(response) {
  5122. //$('.nui_main_menu .chat .indicator').get(0).innerHTML =
  5123. //console.log(response.responseText);
  5124. //$('.nui_main_menu .chat .indicator').get(0).style.display = 'inline';
  5125. }
  5126. });
  5127. }, 0);
  5128. }
  5129. function initChatUser(){
  5130. $('.nui_main_menu .chat .button, .nui_main_menu .chat .name_wrapper').css({
  5131. WebkitFilter: 'hue-rotate(65deg)',
  5132. filter: 'url(#Hue1)'
  5133. });
  5134. updateChatUser();
  5135. setInterval(function(){ updateChatUser(); }, 300000);
  5136. $('.nui_main_menu .chat').mouseover(function(){
  5137. //popupChatUser();
  5138. });
  5139. if($('.nui_main_menu .chat').hasClass('disabled')){ $('.nui_main_menu .chat').removeClass('disabled');}
  5140. }
  5141. function updateChatUser(){
  5142. var market = uw.Game.market_id;
  5143. if(gm){
  5144. // GM-BROWSER:
  5145. chatUserRequest();
  5146. } else {
  5147. // SAFARI:
  5148. $.ajax({
  5149. url:"http://diotools.pf-control.de/game/chatuser_count.php?chan=Grepo"+ (market === "de" ? "lisDE" : ""),
  5150. dataType : 'text',
  5151. success: function(text) {
  5152. $('.nui_main_menu .chat .indicator').get(0).innerHTML = text;
  5153. $('.nui_main_menu .chat .indicator').get(0).style.display = 'block';
  5154. },
  5155. error: function (xhr, ajaxOptions, thrownError) {
  5156. $('.nui_main_menu .chat .indicator').get(0).style.display = 'none';
  5157. }
  5158. });
  5159. }
  5160. }
  5161. $('<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>').appendTo('head');
  5162. // Modify chat window
  5163. function modifyChat() {
  5164. var host = { fr: 'irc.quakenet.org', def: 'flash.afterworkchat.de'},
  5165. market = uw.Game.market_id, select_nick = false, chatwnd_id,
  5166. nickname = uw.Game.player_name;
  5167. setTimeout(function(){ updateChatUser(); }, 10000); setTimeout(function(){ updateChatUser(); }, 30000);
  5168. //uw.GPWindowMgr.Create(uw.Layout.wnd.TYPE_CHAT);
  5169. //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).setWidth(600);
  5170. //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).setHeight(300);
  5171. //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).setPosition([0,'bottom']);
  5172. //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT));
  5173. chatwnd_id = '#gpwnd_' + uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).getID();
  5174. $('#chat').get(0).innerHTML = "";
  5175. //$(chatwnd_id).parent().children('.gpwindow_left').remove();
  5176. //$(chatwnd_id).parent().children('.gpwindow_right').remove();
  5177. //$(chatwnd_id).parent().children('.gpwindow_top').remove();
  5178. //$(chatwnd_id).parent().children('.gpwindow_bottom').remove();
  5179. //$(chatwnd_id).parent().parent().children('.ui-dialog-titlebar').remove();
  5180. var replaceArray = {
  5181. // Russian:
  5182. "Ё":"YO","Й":"I","Ц":"TS","У":"U","К":"K","Е":"E","Н":"N","Г":"G","Ш":"SH","Щ":"SCH","З":"Z","Х":"H","Ъ":"'",
  5183. "ё":"yo","й":"i","ц":"ts","у":"u","к":"k","е":"e","н":"n","г":"g","ш":"sh","щ":"sch","з":"z","х":"h","ъ":"'",
  5184. "Ф":"F","Ы":"I","В":"V","А":"a","П":"P","Р":"R","О":"O","Л":"L","Д":"D","Ж":"ZH","Э":"E",
  5185. "ф":"f","ы":"i","в":"v","а":"a","п":"p","р":"r","о":"o","л":"l","д":"d","ж":"zh","э":"e",
  5186. "Я":"Ya","Ч":"CH","С":"S","М":"M","И":"I","Т":"T","Ь":"'","Б":"B","Ю":"YU",
  5187. "я":"ya","ч":"ch","с":"s","м":"m","и":"i","т":"t","ь":"'","б":"b","ю":"yu",
  5188. // Greek:
  5189. 'Α':'A','Β':'B','Γ':'G','Δ':'D','Ε':'E','Ζ':'Z','Η':'H','Θ':'Th','Ι':'I','Κ':'K','Λ':'L','Μ':'M','Ν':'N','Ξ':'J','Ο':'O','Π':'P','Ρ':'R','Σ':'S',
  5190. 'Τ':'T','Υ':'U','Φ':'F','Χ':'Ch','Ψ':'Ps','Ω':'W','Ά':'A','Έ':'E','Ή':'H','Ί':'I','Ό':'O','Ύ':'U','Ώ':'W','Ϊ':'I',
  5191. 'α':'a','β':'b','γ':'g','δ':'d','ε':'e','ζ':'z','η':'h','θ':'th','ι':'i','κ':'k','λ':'l','μ':'m','ν':'n','ξ':'j','ο':'o','π':'p','ρ':'r','ς':'s',
  5192. 'σ':'s','τ':'t','υ':'u','φ':'f','χ':'ch','ψ':'ps','ω':'w','ά':'a','έ':'e','ή':'h','ί':'i','ό':'o','ύ':'u','ώ':'w','ϊ':'i','ΐ':'i'
  5193. };
  5194. function replaceNick(word){
  5195. var temp = "", temp2 = "";
  5196. // Step 1: Replace Special and some german chars
  5197. word = word.replace(/[.,:,+,*]/g,"").replace(/[=,\ ,\-]/g,"_").replace(/ö/gi,"oe").replace(/ä/gi,"ae").replace(/ü/gi,"ue").replace(/ß/g,"ss");
  5198. // Step 2: Replace russian and greek chars
  5199. if(!word.match(/^[a-zA-Z0-9_]+$/)){
  5200. temp = word.split('').map(function (char) {
  5201. var ch = "";
  5202. ch = replaceArray[char] || char;
  5203. return ch;
  5204. }).join("");
  5205. // Step 3: Delete all other special chars
  5206. if(!temp.match(/^[a-zA-Z0-9_]+$/)){
  5207. for(var c = 0; c < temp.length; c++){
  5208. if(temp[c].match(/^[a-zA-Z0-9_]+$/)){
  5209. temp2 += temp[c];
  5210. }
  5211. }
  5212. select_nick = true;
  5213. temp = temp2;
  5214. }
  5215. word = temp;
  5216. }
  5217. return word;
  5218. }
  5219. //nickname = "kνnmδενεί-ναισυνδεδ*εμένος_Ιππέας"; // test nickname
  5220. nickname = replaceNick(nickname);
  5221. if(PID == 84367){ nickname = "DionY_"; }
  5222. $('<iframe src="http://flash.afterworkchat.de/1.0/FlashChat.swf'+ //http://grepodio.heliohost.org/lightIRC/index.php'+
  5223. '?host=flash.afterworkchat.de'+
  5224. '&languagePath=http://flash.afterworkchat.de/1.0/language/'+
  5225. '&port=6667'+
  5226. '&policyPort=9000'+
  5227. '&styleURL=http://diotools.pf-control.de/css/green2.css'+ //http://grepodio.heliohost.org/style.css'+ //
  5228. '&emoticonPath=http://diotools.pf-control.de/chat/emoticons/' + //http://www.greensmilies.com/smile/smiley_emoticons_'+
  5229. '&emoticonList='+
  5230. ':)->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,'+
  5231. ':$->blush.swf,:]->lol.swf,:*->bussi.swf,:[->fluch.swf'+
  5232. //'&accessKey=54a2846a460ae1703ac690d21551b997'+
  5233. '&nick='+ nickname +
  5234. '&nickAlternate='+ nickname +'_'+
  5235. '&autojoin=%23GREPO,%23Grepolis'+ market.toUpperCase() +
  5236. '&showNickSelection='+ select_nick +
  5237. '&showNavigation=true'+
  5238. '&navigationPosition=top'+
  5239. '&showNickSelection=false'+
  5240. '&showIdentifySelection=false'+
  5241. '&language='+ LID +
  5242. '&quitMessage=CYA'+
  5243. '&showChannelHeader=false'+
  5244. //'&useUserListIcons=true'+
  5245. '&userListWidth=100'+
  5246. '&soundAlerts=true'+
  5247. '&soundOnNewChannelMessage=false'+
  5248. '&showServerWindow=false'+
  5249. '&fontSize=9'+
  5250. '&showJoinPartMessages=false'+
  5251. '&showMenuButton=false'+
  5252. '&showTranslationButton=false'+
  5253. '&showTimestamps=true'+
  5254. //'&showInfoMessages=false'+
  5255. '&showRegisterNicknameButton=false'+
  5256. '&showRichTextControls=false'+
  5257. //'&useUserListIcons=true'+
  5258. '&showUserListInformationPopup=false'+
  5259. '&showNickChangeButton=false'+
  5260. '&showChannelCentral=false'+
  5261. '&showOptionsButton=false'+
  5262. '&showEmoticonsButton=true'+
  5263. '&rememberNickname=false'+
  5264. '" style="width:518px; height:357px; border:0px;"></iframe>').appendTo("#chat");
  5265. /*
  5266. $('<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>'+
  5267. '<script type="text/javascript">'+
  5268. 'var params = {};'+
  5269. 'params.languagePath = "http://flash.afterworkchat.de/1.0/language/";'+
  5270. 'params.host = "flash.afterworkchat.de";'+
  5271. 'params.port = 6667;'+
  5272. 'params.policyPort = 9000;'+
  5273. //'params.accessKey = "54a2846a460ae1703ac690d21551b997";'+
  5274. 'params.styleURL = "http://diotools.pf-control.de/css/green2.css";'+
  5275. 'params.emoticonPath = "http://diotools.pf-control.de/chat/emoticons/";'+
  5276. '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,'+
  5277. ':$->blush.swf,:]->lol.swf,:*->bussi.swf,:[->fluch.swf";'+
  5278. 'params.nick = "'+ nickname + '";' +
  5279. 'params.autojoin = "%23GREPO,%23Grepolis'+ market.toUpperCase() + '";' +
  5280. 'params.showNickSelection = ' + select_nick + ';'+
  5281. 'params.showIdentifySelection = false;'+
  5282. 'params.language = "'+ LID +'";'+
  5283. 'params.soundAlerts = true;'+
  5284. 'params.fontSize = "10";'+
  5285. 'params.navigationPosition = "top";'+
  5286. 'params.showJoinPartMessages = false;'+
  5287. 'params.showTimestamps = true;'+
  5288. 'params.showRegisterNicknameButton = false;'+
  5289. 'params.showNickChangeButton = true;'+
  5290. 'params.showOptionsButton = true;'+
  5291. 'params.showServerWindow = false;'+
  5292. 'params.showOptionsButton = false;'+
  5293. 'params.showMenuButton = false;'+
  5294. 'params.showTranslationButton = false;'+
  5295. 'params.showRichTextControls = false;'+
  5296. 'params.showChannelHeader = false;'+
  5297. 'params.rememberNickname = false;'+
  5298. 'params.userListWidth = 100;' +
  5299. 'params.soundAlerts = true;'+
  5300. 'params.soundOnNewChannelMessage = false;'+
  5301. '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"});'+
  5302. '</script></body></html>').appendTo("#chat");
  5303. */
  5304. }
  5305. /*******************************************************************************************************************************
  5306. * Activity boxes
  5307. * ----------------------------------------------------------------------------------------------------------------------------
  5308. * | ● Show troops and trade activity boxes
  5309. * | ● Boxes are magnetic & movable (position memory)
  5310. * ----------------------------------------------------------------------------------------------------------------------------
  5311. *******************************************************************************************************************************/
  5312. var mut_toolbar, mut_command, mut_trade;
  5313. function checkToolbarAtStart(){
  5314. if(parseInt($('.toolbar_activities .commands .count').get(0).innerHTML, 10) > 0){
  5315. $('#toolbar_activity_commands_list').get(0).style.display = "block";
  5316. } else {
  5317. $('#toolbar_activity_commands_list').get(0).style.display = "none";
  5318. }
  5319. if(parseInt($('.toolbar_activities .trades .count').get(0).innerHTML, 10) > 0){
  5320. $('#toolbar_activity_trades_list').get(0).style.display = "block";
  5321. } else {
  5322. $('#toolbar_activity_trades_list').get(0).style.display = "none";
  5323. }
  5324. }
  5325. function catchToolbarEvents(){
  5326. mut_toolbar = new MutationObserver(function(mutations) {
  5327. mutations.forEach(function(mutation) {
  5328. if(mutation.addedNodes[0]){
  5329. //console.log(mutation);
  5330. if(mutation.target.id === "toolbar_activity_trades_list"){
  5331. draggableTradeBox();
  5332. } else {
  5333. draggableCommandBox();
  5334. }
  5335. mutation.addedNodes[0].remove();
  5336. }
  5337. });
  5338. });
  5339. mut_command = new MutationObserver(function(mutations) {
  5340. mutations.forEach(function(mutation) {
  5341. if(mutation.addedNodes[0]){
  5342. if(mutation.addedNodes[0].nodeValue > 0){
  5343. $('#toolbar_activity_commands_list').get(0).style.display = "block";
  5344. } else {
  5345. $('#toolbar_activity_commands_list').get(0).style.display = "none";
  5346. }
  5347. }
  5348. });
  5349. });
  5350. mut_trade = new MutationObserver(function(mutations) {
  5351. mutations.forEach(function(mutation) {
  5352. if(mutation.addedNodes[0]){
  5353. if(mutation.addedNodes[0].nodeValue > 0){
  5354. $('#toolbar_activity_trades_list').get(0).style.display = "block";
  5355. } else {
  5356. $('#toolbar_activity_trades_list').get(0).style.display = "none";
  5357. }
  5358. }
  5359. });
  5360. });
  5361. }
  5362. // moveable boxes
  5363. function draggableTradeBox(){
  5364. $("#toolbar_activity_trades_list").draggable({
  5365. containment: "body",
  5366. distance: 20,
  5367. snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, .nui_left_box",
  5368. opacity: 0.7,
  5369. start : function () {
  5370. $("#fix_trade").remove();
  5371. },
  5372. stop : function () {
  5373. var pos = $('#toolbar_activity_trades_list').position();
  5374. tradebox.left = pos.left;
  5375. saveValue("tradebox", JSON.stringify(tradebox));
  5376. $('<style id="fix_trade" type="text/css">'+
  5377. '#toolbar_activity_trades_list {'+
  5378. 'left:' + tradebox.left + 'px !important;'+
  5379. 'top: ' + tradebox.top + 'px !important}'+
  5380. '</style>').appendTo('head');
  5381. }
  5382. });
  5383. }
  5384. function draggableCommandBox(){
  5385. $("#toolbar_activity_commands_list").draggable({
  5386. containment: "body",
  5387. distance: 20,
  5388. snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, .nui_left_box",
  5389. opacity: 0.7,
  5390. stop : function () {
  5391. var pos = $('#toolbar_activity_commands_list').position();
  5392. commandbox.left = pos.left;
  5393. commandbox.top = pos.top;
  5394. saveValue("commandbox", JSON.stringify(commandbox));
  5395. }
  5396. });
  5397. }
  5398. function showActivityBoxes(){
  5399. var observe_options = { attributes: false, childList: true, characterData: false};
  5400. catchToolbarEvents();
  5401. mut_toolbar.observe($('#toolbar_activity_commands_list').get(0), observe_options );
  5402. mut_toolbar.observe($('#toolbar_activity_trades_list').get(0), observe_options );
  5403. mut_command.observe($('.toolbar_activities .commands .count').get(0), observe_options );
  5404. mut_trade.observe($('.toolbar_activities .trades .count').get(0), observe_options );
  5405. $('#toolbar_activity_commands').mouseover();
  5406. $('#toolbar_activity_trades').mouseover();
  5407. $('#toolbar_activity_commands, #toolbar_activity_trades').unbind("mouseover");
  5408. $('#toolbar_activity_commands, #toolbar_activity_commands_list, #toolbar_activity_trades, #toolbar_activity_trades_list').unbind("mouseout");
  5409. $('#toolbar_activity_trades_list').unbind("click");
  5410. checkToolbarAtStart();
  5411. $('#toolbar_activity_commands_list').css({
  5412. left: commandbox.left + "px",
  5413. top: commandbox.top + "px"
  5414. });
  5415. $('<style id="fix_lists" type="text/css">'+
  5416. '#toolbar_activity_commands_list, #toolbar_activity_trades_list { width: 160px}'+
  5417. '.dropdown-list .content { max-height: 329px}'+
  5418. '</style>'+
  5419. '<style id="fix_trade" type="text/css">'+
  5420. '#toolbar_activity_trades_list {'+
  5421. 'left:' + tradebox.left + 'px !important;'+
  5422. 'top: ' + tradebox.top + 'px !important}'+
  5423. '</style>').appendTo('head');
  5424. draggableCommandBox();
  5425. draggableTradeBox();
  5426. $('.toolbar_activities .commands').mouseover(function(){
  5427. $('#toolbar_activity_commands_list').get(0).style.display = "block";
  5428. });
  5429. $('.toolbar_activities .trades').mouseover(function(){
  5430. $('#toolbar_activity_trades_list').get(0).style.display = "block";
  5431. });
  5432. }
  5433. /*******************************************************************************************************************************
  5434. * Other stuff
  5435. *******************************************************************************************************************************/
  5436. function counter(time){
  5437. var type = "", today, counted, year, month, day;
  5438. if(uw.Game.market_id !== "zz"){
  5439. counted = DATA.count;
  5440. today = new Date((time + 7200) * 1000);
  5441. year = today.getUTCFullYear();
  5442. month = ((today.getUTCMonth()+1) < 10 ? "0" : "") + (today.getUTCMonth()+1);
  5443. day = (today.getUTCDate() < 10 ? "0" : "") + today.getUTCDate();
  5444. today = year + month + day;
  5445. //console.log(today);
  5446. if(counted[0] !== today){type += "d"; }
  5447. if(counted[1] == false){ type += "t"; }
  5448. if((counted[2] == undefined) || (counted[2] == false)){ type += "b"; }
  5449. if(type !== ""){
  5450. $.ajax({
  5451. type: "GET",
  5452. url: "http://diotools.pf-control.de/game/count.php?type="+ type + "&market="+ uw.Game.market_id + "&date="+ today + "&browser="+ getBrowser(),
  5453. dataType : 'text',
  5454. success: function (text) {
  5455. if(text.indexOf("dly") > -1){
  5456. counted[0] = today;
  5457. }
  5458. if(text.indexOf("tot") > -1){
  5459. counted[1] = true;
  5460. }
  5461. if(text.indexOf("bro") > -1){
  5462. counted[2] = true;
  5463. }
  5464. saveValue("dio_count", JSON.stringify(counted));
  5465. }
  5466. });
  5467. }
  5468. }
  5469. }
  5470. /*
  5471. function xmas(){
  5472. $('<a href="http://www.greensmilies.com/smilie-album/" target="_blank"><div id="xmas"></div></a>').appendTo('#ui_box');
  5473. $('#xmas').css({
  5474. background: 'url("http://www.greensmilies.com/smile/smiley_emoticons_weihnachtsmann_nordpol.gif") no-repeat',
  5475. height: '51px',
  5476. width: '61px',
  5477. position:'absolute',
  5478. bottom:'10px',
  5479. left:'60px',
  5480. zIndex:'2000'
  5481. });
  5482. $('#xmas').tooltip("HO HO HO, Frohe Weihnachten!");
  5483. }
  5484. function silvester(){
  5485. $('<a href="http://www.greensmilies.com/smilie-album/" target="_blank"><div id="silv">'+
  5486. '<img src="http://www.greensmilies.com/smile/sign2_2.gif">'+
  5487. '<img src="http://www.greensmilies.com/smile/sign2_0.gif">'+
  5488. '<img src="http://www.greensmilies.com/smile/sign2_1.gif">'+
  5489. '<img src="http://www.greensmilies.com/smile/sign2_4.gif">'+
  5490. '</div></a>').appendTo('#ui_box');
  5491. $('#silv').css({
  5492. //background: 'url("http://www.greensmilies.com/smile/buchstaben_0.gif") no-repeat',
  5493. //height: '57px',
  5494. //width: '34px',
  5495. position:'absolute',
  5496. bottom:'10px',
  5497. left:'70px',
  5498. zIndex:'10'
  5499. });
  5500. $('#silv').tooltip("Frohes Neues!");
  5501. }
  5502. function joke(){
  5503. setTimeout(function(){
  5504. if($('#grcgrc').get(0)){
  5505. $('<a href="http://www.greensmilies.com/smilie-album/" target="_blank"><div id="fight"></div></a>').appendTo('#ui_box');
  5506. $('#fight').css({
  5507. background: 'url("http://www.greensmilies.com/smile/smiley_emoticons_hoplit_speer4.gif") no-repeat',
  5508. height: '51px',
  5509. width: '61px',
  5510. position:'absolute',
  5511. bottom:'10px',
  5512. left:'39px',
  5513. zIndex:'2000'
  5514. });
  5515. $('#fight').tooltip("WWW.GREENSMILIES.COM");
  5516. }
  5517. }, 5000);
  5518. }
  5519. */
  5520. }

QingJ © 2025

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