Greasy Fork is available in English.

DIO-TOOLS

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

  1. // ==UserScript==
  2. // @name DIO-TOOLS
  3. // @namespace DIO
  4. // @version 3.07
  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[s]{0,1}://[a-z]{2}[0-9]{1,2}\.grepolis\.com/game*/
  9. // @include https://*forum.*.grepolis.com/*.php*
  10. // @include http://diotools.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.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. // @grant GM_getResourceURL
  21. // ==/UserScript==
  22.  
  23. var version = '3.07';
  24.  
  25. //if(unsafeWindow.DM) console.dir(unsafeWindow.DM.status('l10n'));
  26. //console.dir(DM.status('templates'));
  27.  
  28. //http://s7.directupload.net/images/140128/vqchpigi.gif - DIO-Tools-Smiley
  29.  
  30. //http://de44.grepolis.com/cache/js/libs/jquery-1.10.2.min.js
  31.  
  32.  
  33. //console.log(JSON.stringify(DM.getl10n()));
  34.  
  35.  
  36. //// console.log(GM_getResourceText("dio_sprite"));
  37.  
  38. /*******************************************************************************************************************************
  39. * Changes
  40. * ----------------------------------------------------------------------------------------------------------------------------
  41. * | ● Einstellungen und auch das ganze Script komplett überarbeitet
  42. * | ● Features können nun ohne Refresh deaktiviert/aktiviert werden
  43. * | ● Einzelne Features sind unabhängiger voneinander und somit auch fehlerresistenter (einzelne Features können sich bei Fehlerauftreten durch Grepolis-Updates nicht mehr gegenseitig blockieren)
  44. * | ● Fehlerhafter Biremenzähler als Kompromiss für die Erweiterung der "Verfügbare Einheiten"-Anzeige entfernt: es kann nun jede Einheit im Bullauge angezeigt werden
  45. * | ● EO-Zähler hat ATT/UT's doppelt gezählt, wenn nebenher der veröffentlichte Belagerungsbericht im Forum offen war
  46. * | ● 3 kleine Layoutfehler beim EO-Zähler behoben
  47. * | ● Wenn Zauberfenster und Zauberbox gleichzeitig offen waren, kam es zu einem Layoutfehler
  48. * | ● Fehler beim Mausrad-Zoom behoben
  49. * | ● Fehler bei der Transporteranzeige behoben: die Kapazität der großen Transporter wurde durch das Rebalancing nichtmehr korrekt berechnet
  50. * | ● Smileybox etwas verbessert
  51. * | ● Weihnachtssmileys hinzugefügt
  52. * | ● Kontextmenü der Stadticons auf der strategischen Karte konnte im Nachtmodus nicht geöffnet werden
  53. * | ● Grüner Fortschrittsbalken beim Weltwunderzähler wurde nicht angezeigt
  54. * | ● Fenster wurden angepasst (Verfügbare Einheiten und Einheitenvergleich)
  55. * ----------------------------------------------------------------------------------------------------------------------------
  56. *******************************************************************************************************************************/
  57.  
  58. /*******************************************************************************************************************************
  59. * Bugs / TODOs
  60. * ----------------------------------------------------------------------------------------------------------------------------
  61. * | ● Aktivitätsbox für Angriffe blendet nicht aus
  62. * | ● Smileys verschwinden manchmal? -> bisher nicht reproduzierbar
  63. * | ● Performanceeinbruch nach dem Switchen des WW-Fensters
  64. * | ● keine Smileys im Grepoforum mit Safari (fehlendes jQuery)
  65. * ----------------------------------------------------------------------------------------------------------------------------
  66. *******************************************************************************************************************************/
  67.  
  68. /*******************************************************************************************************************************
  69. * Global stuff
  70. *******************************************************************************************************************************/
  71. var uw = unsafeWindow || window, $ = uw.jQuery || jQuery, DATA, GM;
  72.  
  73. // GM-API?
  74. GM = (typeof GM_info === 'object');
  75.  
  76. console.log('%c|= DIO-Tools is active =|', 'color: green; font-size: 1em; font-weight: bolder; ');
  77.  
  78. function loadValue(name, default_val){
  79. var value;
  80. if(GM){
  81. value = GM_getValue(name, default_val);
  82. } else {
  83. value = localStorage.getItem(name) || default_val;
  84. }
  85.  
  86. if(typeof(value) === "string"){
  87. value = JSON.parse(value)
  88. }
  89. return value;
  90. }
  91.  
  92. // LOAD DATA
  93. if(GM && (uw.location.pathname === "/game/index")){
  94. var WID = uw.Game.world_id, MID = uw.Game.market_id, AID = uw.Game.alliance_id;
  95.  
  96. //GM_deleteValue(WID + "_bullseyeUnit");
  97.  
  98. DATA = {
  99. // GLOBAL
  100. options : loadValue("options", "{}"),
  101.  
  102. user : loadValue("dio_user", "{}"),
  103. count: loadValue("dio_count", "[]"),
  104.  
  105. notification : loadValue('notif', '0'),
  106.  
  107. error: loadValue('error', '{}'),
  108.  
  109. spellbox : loadValue("spellbox", '{ "top":"23%", "left": "-150%", "show": false }'),
  110. commandbox: loadValue("commandbox" , '{ "top":55, "left": 250 }'),
  111. tradebox : loadValue("tradebox", '{ "top":55, "left": 450 }'),
  112.  
  113. // WORLD
  114. townTypes : loadValue(WID + "_townTypes", "{}"),
  115. sentUnits : loadValue(WID + "_sentUnits", '{ "attack": {}, "support": {} }'),
  116.  
  117. biremes : loadValue(WID + "_biremes", "{}"), //old
  118. bullseyeUnit : loadValue(WID + "_bullseyeUnit", '{ "current_group" : -1 }'), // new
  119.  
  120. worldWonder : loadValue(WID + "_wonder", '{ "ratio": {}, "storage": {}, "map": {} }'),
  121.  
  122. clickCount : loadValue(WID + "_click_count", '{}'), // old
  123. statistic : loadValue(WID + "_statistic", '{}'), // new
  124.  
  125. // MARKET
  126. worldWonderTypes : loadValue(MID + "_wonderTypes", '{}')
  127. };
  128.  
  129. if(!DATA.worldWonder.map) {
  130. DATA.worldWonder.map = {};
  131. }
  132.  
  133. // Temporary:
  134. if(typeof DATA.options.trd == 'boolean') {
  135. DATA.options.per = DATA.options.rec = DATA.options.trd; delete DATA.options.trd;
  136. }
  137. if(typeof DATA.options.mov == 'boolean') {
  138. DATA.options.act = DATA.options.mov; delete DATA.options.mov;
  139. }
  140. if(typeof DATA.options.twn == 'boolean') {
  141. DATA.options.tic = DATA.options.til = DATA.options.tim = DATA.options.twn; delete DATA.options.twn;
  142. }
  143. if(GM) GM_deleteValue("notification");
  144. }
  145.  
  146. // GM: EXPORT FUNCTIONS
  147. uw.saveValueGM = function(name, val){
  148. setTimeout(function(){
  149. GM_setValue(name, val);
  150. }, 0);
  151. };
  152.  
  153. uw.deleteValueGM = function(name){
  154. setTimeout(function(){
  155. GM_deleteValue(name);
  156. },0);
  157. };
  158.  
  159. uw.chatUserRequest = function(){
  160. var _chatIndicator = $('.nui_main_menu .chat .indicator');
  161.  
  162. setTimeout(function(){
  163. GM_xmlhttpRequest({
  164. method: "GET",
  165. url: "http://api.relay-chat.de/compteur_js.php?chan="+ (uw.Game.market_id === "de" ? "Grepolis" + uw.Game.market_id.toUpperCase() : "GREPO"),
  166. onload: function(text){
  167. _chatIndicator.get(0).innerHTML = text.response.split("'")[1];
  168. _chatIndicator.get(0).style.display = 'block';
  169. },
  170. onerror: function(){
  171. _chatIndicator.get(0).style.display = 'none';
  172. }
  173. });
  174. }, 0);
  175. };
  176.  
  177. uw.getImageDataFromCanvas = function(x, y){
  178.  
  179. console.debug("HEY", document.getElementById('canvas_picker').getContext('2d').getImageData(x, y, 1, 1));
  180. };
  181. uw.calculateConcaveHull = function() {
  182. var contour = [
  183. new poly2tri.Point(100, 100),
  184. new poly2tri.Point(100, 300),
  185. new poly2tri.Point(300, 300),
  186. new poly2tri.Point(300, 100)
  187. ];
  188.  
  189. var swctx = new poly2tri.SweepContext(contour);
  190.  
  191. swctx.triangulate();
  192. var triangles = swctx.getTriangles();
  193.  
  194. console.debug(triangles);
  195.  
  196. return triangles;
  197. };
  198.  
  199. if(typeof exportFunction == 'function'){
  200. // Firefox > 30
  201. //uw.DATA = cloneInto(DATA, unsafeWindow);
  202. exportFunction(uw.saveValueGM, unsafeWindow, {defineAs: "saveValueGM"});
  203. exportFunction(uw.deleteValueGM, unsafeWindow, {defineAs: "deleteValueGM"});
  204. exportFunction(uw.chatUserRequest, unsafeWindow, {defineAs: "chatUserRequest"});
  205. exportFunction(uw.calculateConcaveHull, unsafeWindow, {defineAs: "calculateConcaveHull"});
  206. exportFunction(uw.getImageDataFromCanvas, unsafeWindow, {defineAs: "getImageDataFromCanvas"});
  207. } else {
  208. // Firefox < 30, Chrome, Opera, ...
  209. //uw.DATA = DATA;
  210. }
  211.  
  212. var time_a, time_b;
  213.  
  214. // APPEND SCRIPT
  215. function appendScript(){
  216. //console.log("GM-API: " + gm_bool);
  217. if(document.getElementsByTagName('body')[0]){
  218. var dioscript = document.createElement('script');
  219. dioscript.type ='text/javascript';
  220. dioscript.id = 'diotools';
  221.  
  222. time_a = uw.Timestamp.client();
  223. dioscript.textContent = DIO_GAME.toString().replace(/uw\./g, "") + "\n DIO_GAME('"+ version +"', "+ GM +", '" + JSON.stringify(DATA).replace(/'/g, "##") + "', "+ time_a +");";
  224. document.body.appendChild(dioscript);
  225. } else {
  226. setTimeout(function(){
  227. appendScript();
  228. }, 500);
  229. }
  230. }
  231.  
  232. if(location.host === "diotools.de"){
  233. // PAGE
  234. DIO_PAGE();
  235. } else {
  236. if((location.pathname !== "/game/index") && GM){
  237. // FORUM
  238. DIO_GAME(version);
  239. } else {
  240. // GAME
  241. appendScript();
  242. }
  243. }
  244.  
  245. function DIO_PAGE(){
  246. if(typeof GM_info == 'object') {
  247. setTimeout(function() {
  248. dio_user = JSON.parse(loadValue("dio_user", ""));
  249. console.log(dio_user);
  250. uw.dio_version = parseFloat(version);
  251. }, 0);
  252. } else {
  253. dio_user = localStorage.getItem("dio_user") || "";
  254.  
  255. dio_version = parseFloat(version);
  256. }
  257. }
  258. function DIO_FORUM(){
  259. if($(".editor_textbox_container").get(0)){
  260. loadSmileys();
  261. changeForumEditorLayout();
  262. addForum();
  263. }
  264. }
  265. function DIO_GAME(version, gm, DATA, time_a) {
  266. var MutationObserver = uw.MutationObserver || window.MutationObserver,
  267.  
  268. WID, MID, AID, PID, LID,
  269.  
  270. dio_sprite = "http://666kb.com/i/ct1etaz0uyohw402i.png"; // http://abload.de/img/dio_spritejmqxp.png, http://img1.myimg.de/DIOSPRITEe9708.png -> Forbidden!?
  271.  
  272. if (uw.location.pathname === "/game/index") {
  273. DATA = JSON.parse(DATA.replace(/##/g, "'"));
  274.  
  275. WID = uw.Game.world_id;
  276. MID = uw.Game.market_id;
  277. AID = uw.Game.alliance_id;
  278. PID = uw.Game.player_id;
  279. LID = uw.Game.locale_lang.split("_")[0]; // LID ="es";
  280.  
  281. // World with Artemis ??
  282. Game.hasArtemis = true; //Game.constants.gods.length == 6;
  283. }
  284.  
  285. $.prototype.reverseList = [].reverse;
  286.  
  287. // Implement old jQuery method (version < 1.9)
  288. $.fn.toggleClick = function () {
  289. var methods = arguments; // Store the passed arguments for future reference
  290. var count = methods.length; // Cache the number of methods
  291.  
  292. // Use return this to maintain jQuery chainability
  293. // For each element you bind to
  294. return this.each(function (i, item) {
  295. // Create a local counter for that element
  296. var index = 0;
  297.  
  298. // Bind a click handler to that element
  299. $(item).on('click', function () {
  300. // That when called will apply the 'index'th method to that element
  301. // the index % count means that we constrain our iterator between 0
  302. // and (count-1)
  303. return methods[index++ % count].apply(this, arguments);
  304. });
  305. });
  306. };
  307.  
  308. function saveValue(name, val) {
  309. if (gm) {
  310. saveValueGM(name, val);
  311. } else {
  312. localStorage.setItem(name, val);
  313. }
  314. }
  315.  
  316. function deleteValue(name) {
  317. if (gm) {
  318. deleteValueGM(name);
  319. } else {
  320. localStorage.removeItem(name);
  321. }
  322. }
  323.  
  324. /*******************************************************************************************************************************
  325. * Graphic filters
  326. *******************************************************************************************************************************/
  327. if (uw.location.pathname === "/game/index") {
  328. $('<svg width="0%" height="0%">' +
  329. // GREYSCALE
  330. '<filter id="GrayScale">' +
  331. '<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">' +
  332. '</filter>' +
  333. // SEPIA
  334. '<filter id="Sepia">' +
  335. '<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">' +
  336. '</filter>' +
  337. // SATURATION
  338. '<filter id="Saturation"><feColorMatrix type="saturate" values="0.2"></filter>' +
  339. '<filter id="Saturation1"><feColorMatrix type="saturate" values="1"></filter>' +
  340. '<filter id="Saturation2"><feColorMatrix type="saturate" values="2"></filter>' +
  341. // HUE
  342. '<filter id="Hue1"><feColorMatrix type="hueRotate" values= "65"></filter>' +
  343. '<filter id="Hue2"><feColorMatrix type="hueRotate" values="150"></filter>' +
  344. '<filter id="Hue3"><feColorMatrix type="hueRotate" values="-65"></filter>' +
  345. // BRIGHTNESS
  346. '<filter id="Brightness15">' +
  347. '<feComponentTransfer><feFuncR type="linear" slope="1.5"/><feFuncG type="linear" slope="1.5"/><feFuncB type="linear" slope="1.5"/></feComponentTransfer>' +
  348. '</filter>' +
  349. '<filter id="Brightness12">' +
  350. '<feComponentTransfer><feFuncR type="linear" slope="1.2"/><feFuncG type="linear" slope="1.2"/><feFuncB type="linear" slope="1.2"/></feComponentTransfer>' +
  351. '</filter>' +
  352. '<filter id="Brightness11">' +
  353. '<feComponentTransfer><feFuncR type="linear" slope="1.1"/><feFuncG type="linear" slope="1.1"/><feFuncB type="linear" slope="1.1"/></feComponentTransfer>' +
  354. '</filter>' +
  355. '<filter id="Brightness10">' +
  356. '<feComponentTransfer><feFuncR type="linear" slope="1.0"/><feFuncG type="linear" slope="1.0"/><feFuncB type="linear" slope="1.0"/></feComponentTransfer>' +
  357. '</filter>' +
  358. '<filter id="Brightness07">' +
  359. '<feComponentTransfer><feFuncR type="linear" slope="0.7"/><feFuncG type="linear" slope="0.7"/><feFuncB type="linear" slope="0.7"/></feComponentTransfer>' +
  360. '</filter>' +
  361. '</svg>').appendTo('#ui_box');
  362. }
  363.  
  364. /*******************************************************************************************************************************
  365. * Language versions: german, english, french, russian, polish, spanish
  366. *******************************************************************************************************************************/
  367. var LANG = {
  368. de: {
  369. settings: {
  370. dsc: "DIO-Tools bietet unter anderem einige Anzeigen, eine Smileyauswahlbox,<br>Handelsoptionen und einige Veränderungen des Layouts.",
  371. act: "Funktionen der Toolsammlung aktivieren/deaktivieren:",
  372. prv: "Vorschau einzelner Funktionen:",
  373.  
  374. version_old: "DIO-Tools-Version ist nicht aktuell",
  375. version_new: "DIO-Tools-Version ist aktuell",
  376. version_dev: "DIO-Tools-Entwicklerversion",
  377.  
  378. version_update: "Aktualisieren",
  379.  
  380. link_forum: "http://forum.de.grepolis.com/showthread.php?28838&goto=newpost", //"http://forum.de.grepolis.com/showthread.php?28838"
  381. link_contact: "http://forum.de.grepolis.com/private.php?do=newpm&u=10548",
  382.  
  383. forum: "Forum",
  384. author: "Autor",
  385.  
  386. cat_units: "Einheiten",
  387. cat_icons: "Stadticons",
  388. cat_forum: "Forum",
  389. cat_trade: "Handel",
  390. cat_wonders: "Weltwunder",
  391. cat_layout: "Layout",
  392. cat_other: "Sonstiges"
  393. },
  394. options: {
  395. bir: ["Biremenzähler", "Zählt die jeweiligen Biremen einer Stadt und summiert diese.<br><br>Anzeige im Minimap-Bullauge oben links"],
  396. ava: ["Verfügbare Einheiten", "Zählt die verfügbaren Einheiten von allen Städten"],
  397. sml: ["Smileys", "Erweitert die BBCode-Leiste um eine Smileybox"],
  398. str: ["Einheitenstärke", "Fügt mehrere Einheitenstärketabellen in verschiedenen Bereichen hinzu"],
  399. tra: ["Transportkapazität", "Zeigt die belegte und verfügbare Transportkapazität im Einheitenmenu an"],
  400. per: ["Prozentualer Handel", "Erweitert das Handelsfenster um einen Prozentualer Handel"],
  401. rec: ["Rekrutierungshandel", "Erweitert das Handelsfenster um einen Rekrutierungshandel"],
  402. cnt: ["EO-Zähler", "Zählt die ATT/UT-Anzahl im EO-Fenster"],
  403. way: ["Laufzeit", "Zeigt im ATT/UT-Fenster die Laufzeit bei Verbesserter Truppenbewegung an"],
  404. sim: ["Simulator", "Anpassung des Simulatorlayouts & permanente Anzeige der Erweiterten Modifikatorbox"],
  405. spl: ["Zauberbox", "Komprimierte verschiebbare & magnetische Zauberbox (Positionsspeicherung)"],
  406. act: ["Aktivitätsboxen", "Verbesserte Anzeige der Handels- und Truppenaktivitätsboxen (Positionsspeicherung)"],
  407. pop: ["Gunst-Popup", 'Ändert das Aussehen des Gunst-Popups'],
  408. tsk: ["Taskleiste", 'Vergrößert die Taskleiste und minimiert das "Tägliche Belohnung"-Fenster beim Start'],
  409. irc: ["Chat", "Ersetzt den Allianzchat durch einen IRC-Chat"],
  410. bbc: ["DEF-Formular", "Erweitert die BBCode-Leiste um ein automatisches DEF-Formular"],
  411. com: ["Einheitenvergleich", "Fügt Einheitenvergleichstabellen hinzu"],
  412. tic: ["Stadticons", "Jede Stadt erhält ein Icon für den Stadttyp (Automatische Erkennung)", "Zusätzliche Icons stehen bei der manuellen Auswahl zur Verfügung"],
  413. til: ["Stadtliste", "Fügt die Stadticons zur Stadtliste hinzu"],
  414. tim: ["Karte", "Setzt die Stadticons auf die strategische Karte"],
  415. wwc: ["Anteil", "Anteilsrechner & Rohstoffzähler + Vor- & Zurück-Buttons bei fertiggestellten WW's (momentan nicht deaktivierbar!)"],
  416. wwr: ["Rangliste", "Überarbeitete Weltwunderrangliste"],
  417. wwi: ["Icons", 'Fügt Weltwundericons auf der strategischen Karte hinzu'],
  418. con: ["Kontextmenu", 'Vertauscht "Stadt selektieren" und "Stadtübersicht" im Kontextmenu'],
  419. sen: ["Abgeschickte Einheiten", 'Zeigt im Angriffs-/Unterstützungsfenster abgeschickte Einheiten an'],
  420. tov: ["Stadtübersicht", 'Ersetzt die neue Stadtansicht mit der alten Fensteransicht'],
  421. scr: ["Mausrad-Zoom", 'Man kann mit dem Mausrad die 3 Ansichten wechseln'],
  422.  
  423. err: ["Automatische Fehlerberichte senden", "Wenn du diese Option aktivierst, kannst du dabei helfen Fehler zu identifizieren."],
  424. her: ["Thrakische Eroberung", "Verkleinerung der Karte der Thrakischen Eroberung."]
  425. },
  426. labels: {
  427. uni: "Verfügbare Einheiten",
  428. con: "Selektieren",
  429. // Smileys
  430. std: "Standard",
  431. gre: "Grepolis",
  432. nat: "Natur",
  433. ppl: "Leute",
  434. oth: "Sonstige",
  435. // Defense form
  436. ttl: "Übersicht: Stadtverteidigung",
  437. inf: "Informationen zur Stadt:",
  438. dev: "Abweichung",
  439. det: "Detailierte Landeinheiten",
  440. prm: "Premiumboni",
  441. sil: "Silberstand",
  442. mov: "Truppenbewegungen:",
  443. // WW
  444. leg: "WW-Anteil",
  445. stg: "Stufe",
  446. tot: "Gesamt",
  447. // Simulator
  448. str: "Einheitenstärke",
  449. los: "Verluste",
  450. mod: "ohne Modifikatoreinfluss",
  451. // Comparison box
  452. dsc: "Einheitenvergleich",
  453. hck: "Schlag",
  454. prc: "Stich",
  455. dst: "Distanz",
  456. sea: "See",
  457. att: "Angriff",
  458. def: "Verteidigung",
  459. spd: "Geschwindigkeit",
  460. bty: "Beute (Rohstoffe)",
  461. cap: "Transportkapazität",
  462. res: "Baukosten (Rohstoffe)",
  463. fav: "Gunst",
  464. tim: "Bauzeit (s)",
  465. // Trade
  466. rat: "Ressourcenverhältnis eines Einheitentyps",
  467. shr: "Anteil an der Lagerkapazität der Zielstadt",
  468. per: "Prozentualer Handel",
  469. // Sent units box
  470. lab: "Abgeschickt",
  471. improved_movement: "Verbesserte Truppenbewegung"
  472. },
  473. buttons: {
  474. sav: "Speichern", ins: "Einfügen", res: "Zurücksetzen"
  475. }
  476. },
  477.  
  478. en: {
  479. settings: {
  480. dsc: "DIO-Tools offers, among other things, some displays, a smiley box,<br>trade options and some changes to the layout.",
  481. act: "Activate/deactivate features of the toolset:",
  482. prv: "Preview of several features:",
  483.  
  484. version_old: "Version is not up to date",
  485. version_new: "Version is up to date",
  486. version_dev: "Developer version",
  487.  
  488. version_update: "Update",
  489.  
  490. link_forum: "http://forum.en.grepolis.com/showthread.php?52104&goto=newpost",
  491. link_contact: "http://forum.en.grepolis.com/private.php?do=newpm&u=46211",
  492.  
  493. forum: "Forum",
  494. author: "Author",
  495.  
  496. cat_units: "Units",
  497. cat_icons: "Town icons",
  498. cat_forum: "Forum",
  499. cat_trade: "Trade",
  500. cat_wonders: "World wonder",
  501. cat_layout: "Layout",
  502. cat_other: "Miscellaneous"
  503. },
  504. options: {
  505. bir: ["Bireme counter", "Counts the biremes of a city and sums these"],
  506. ava: ["Available units", "Counts the available units of all cities"],
  507. sml: ["Smilies", "Extends the bbcode bar by a smiley box"],
  508. str: ["Unit strength", "Adds unit strength tables in various areas"],
  509. tra: ["Transport capacity", "Shows the occupied and available transport capacity in the unit menu"],
  510. per: ["Percentual trade", "Extends the trade window by a percentual trade"],
  511. rec: ["Recruiting trade", "Extends the trade window by a recruiting trade"],
  512. cnt: ["Conquests", "Counts the attacks/supports in the conquest window"],
  513. way: ["Troop speed", "Displays improved troop speed in the attack/support window"],
  514. sim: ["Simulator", "Adaptation of the simulator layout & permanent display of the extended modifier box"],
  515. spl: ["Spell box", "Compressed movable & magnetic spell box (position memory)"],
  516. act: ["Activity boxes", "Improved display of trade and troop activity boxes (position memory)"],
  517. pop: ["Favor popup", "Changes the favor popup"],
  518. tsk: ["Taskbar", "Increases the taskbar and minimizes the daily reward window on startup"],
  519. irc: ["Chat", 'Replaced the alliance chat by an irc chat. (FlashPlayer required)'],
  520. bbc: ["Defense form", "Extends the bbcode bar by an automatic defense form"],
  521. com: ["Unit Comparison", "Adds unit comparison tables"],
  522. tic: ["Town icons", "Each city receives an icon for the town type (automatic detection)", "Additional icons are available for manual selection"],
  523. til: ["Town list", "Adds the town icons to the town list"],
  524. tim: ["Map", "Sets the town icons on the strategic map"],
  525. wwc: ["Calculator", "Share calculation & resources counter + previous & next buttons on finished world wonders (currently not deactivatable!)"],
  526. wwr: ["Ranking", "Redesigned world wonder rankings"],
  527. wwi: ["Icons", 'Adds world wonder icons on the strategic map'],
  528. con: ["Context menu", 'Swaps "Select town" and "City overview" in the context menu'],
  529. sen: ["Sent units", 'Shows sent units in the attack/support window'],
  530. tov: ["Town overview", 'Replaces the new town overview with the old window style'],
  531. scr: ["Mouse wheel", 'You can change the views with the mouse wheel'],
  532.  
  533. err: ["Send bug reports automatically", "If you activate this option, you can help identify bugs."],
  534. her: ["Thracian Conquest", "Downsizing of the map of the Thracian conquest."]
  535. },
  536. labels: {
  537. uni: "Available Units",
  538. con: "Select town",
  539. // Smileys
  540. std: "Standard",
  541. gre: "Grepolis",
  542. nat: "Nature",
  543. ppl: "People",
  544. oth: "Other",
  545. hal: "Halloween",
  546. xma: "Xmas",
  547. // Defense form
  548. ttl: "Overview: Town defense",
  549. inf: "Town information:",
  550. dev: "Deviation",
  551. det: "Detailed land units",
  552. prm: "Premium bonuses",
  553. sil: "Silver volume",
  554. mov: "Troop movements:",
  555. // WW
  556. leg: "WW Share",
  557. stg: "Stage",
  558. tot: "Total",
  559. // Simulator
  560. str: "Unit strength",
  561. los: "Loss",
  562. mod: "without modificator influence",
  563. // Comparison box
  564. dsc: "Unit comparison",
  565. hck: "Blunt",
  566. prc: "Sharp",
  567. dst: "Distance",
  568. sea: "Sea",
  569. att: "Offensive",
  570. def: "Defensive",
  571. spd: "Speed",
  572. bty: "Booty (resources)",
  573. cap: "Transport capacity",
  574. res: "Costs (resources)",
  575. fav: "Favor",
  576. tim: "Recruiting time (s)",
  577. // Trade
  578. rat: "Resource ratio of an unit type",
  579. shr: "Share of the storage capacity of the target city",
  580. per: "Percentage trade",
  581. // Sent units box
  582. lab: "Sent units",
  583. improved_movement: "Improved troop movement"
  584. },
  585. buttons: {
  586. sav: "Save", ins: "Insert", res: "Reset"
  587. }
  588. },
  589. ///////////////////////////////////
  590. // French Translation by eclat49 //
  591. ///////////////////////////////////
  592. fr: {
  593. settings: {
  594. 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.",
  595. act: "Activation/Désactivation des fonctions:",
  596. prv: "Aperçu des fonctions séparées:"
  597. },
  598. options: {
  599. 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)"],
  600. sml: ["Smileys", "Rajoutes une boite de smilies à la boite de bbcode"],
  601. str: ["Force unitaire", "Ajoutes des tableaux de force unitaire dans les différentes armes"],
  602. //trd: [ "Commerce", "Ajout d'une option par pourcentage, par troupes pour le commerce, ainsi qu'un affichage des limites pour les festivals" ],
  603. per: ["Commerce de pourcentage", ""],
  604. rec: ["Commerce de recrutement", ""],
  605. cnt: ["Compteur conquête", "Comptabilise le nombre d'attaque et de soutien dans la fenêtre de conquête"],
  606. way: ["Vitesse des troupes ", "Rajoutes le temps de trajet avec le bonus accélération"],
  607. sim: ["Simulateur", "Modification de la présentation du simulateur et affichage permanent des options premium"],
  608. spl: ["Boîte de magie", "Boîte de sort cliquable et positionnable"],
  609. act: ["Boîte d'activité", "Présentation améliorée du commerce et des mouvement de troupes (mémoire de position)"],
  610. pop: ["Popup de faveur", 'Change la popup de faveur'],
  611. tsk: ["Barre de tâches ", "La barre de tâches augmente et minimise le fenêtre de bonus journalier"],
  612. irc: ["Chat", "Remplace le chat de l'alliance à travers un chat IRC. (FlashPlayer requis)"],
  613. bbc: ["Formulaire de défense", "Ajout d'un bouton dans la barre BBCode pour un formulaire de défense automatique"],
  614. com: ["Comparaison des unités", "Ajoutes des tableaux de comparaison des unités"],
  615. tic: ["Icônes des villes", "Chaque ville reçoit une icône pour le type de ville (détection automatique)", "Des icônes supplémentaires sont disponibles pour la sélection manuelle"],
  616. til: ["Liste de ville", "Ajoute les icônes de la ville à la liste de la ville"],
  617. tim: ["Carte", "Définit les icônes de la ville sur la carte stratégique"],
  618. 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)"],
  619. wwr: ["", ""],
  620. //wwi: [ "Icônes",'Adds world wonder icons on the strategic map' ],
  621. con: ["Menu contextuel", 'Swaps "Sélectionner ville" et "Aperçu de la ville" dans le menu contextuel'],
  622. sen: ["Unités envoyées", 'Affiche unités envoyées dans la fenêtre attaque/support'],
  623. tov: ["Aperçu de ville", "Remplace la nouvelle aperçu de la ville avec l'ancien style de fenêtre"],
  624. scr: ["Molette de la souris", 'Avec la molette de la souris vous pouvez changer les vues'],
  625.  
  626. err: ["Envoyer des rapports de bogues automatiquement", "Si vous activez cette option, vous pouvez aider à identifier les bugs."]
  627. },
  628. labels: {
  629. uni: "Unités disponibles",
  630. con: "Sélectionner",
  631. // Smileys
  632. std: "Standard",
  633. gre: "Grepolis",
  634. nat: "Nature",
  635. ppl: "Gens",
  636. oth: "Autres",
  637. // Defense form
  638. ttl: "Aperçu: Défense de ville",
  639. inf: "Renseignements sur la ville:",
  640. dev: "Différence",
  641. det: "Unités terrestres détaillées",
  642. prm: "Bonus premium",
  643. sil: "Remplissage de la grotte",
  644. mov: "Mouvements de troupes:",
  645. // WW
  646. leg: "Participation",
  647. stg: "Niveau",
  648. tot: "Total",
  649. // Simulator
  650. str: "Force unitaire",
  651. los: "Pertes",
  652. mod: "sans influence de modificateur",
  653. // Comparison box
  654. dsc: "Comparaison des unités",
  655. hck: "Contond.",
  656. prc: "Blanche",
  657. dst: "Jet",
  658. sea: "Navale",
  659. att: "Attaque",
  660. def: "Défense",
  661. spd: "Vitesse",
  662. bty: "Butin",
  663. cap: "Capacité de transport",
  664. res: "Coût de construction",
  665. fav: "Faveur",
  666. tim: "Temps de construction (s)",
  667. // Trade
  668. rat: "Ratio des ressources d'un type d'unité",
  669. shr: "Part de la capacité de stockage de la ville cible",
  670. per: "Commerce de pourcentage",
  671. // Sent units box
  672. lab: "Envoyée",
  673. improved_movement: "Mouvement des troupes amélioré"
  674. },
  675. buttons: {
  676. sav: "Sauver", ins: "Insertion", res: "Remettre"
  677. }
  678. },
  679. ///////////////////////////////////
  680. // Russian Translation by MrBobr //
  681. ///////////////////////////////////
  682. ru: {
  683. settings: {
  684. dsc: "DIO-Tools изменяет некоторые окна, добавляет новые смайлы, отчёты,<br>улучшеные варианты торговли и другие функции.",
  685. act: "Включение/выключение функций:",
  686. prv: "Примеры внесённых изменений:"
  687. },
  688. options: {
  689. bir: ["Счётчик бирем", "Показывает число бирем во всех городах"],
  690. sml: ["Смайлы", "Добавляет кнопку для вставки смайлов в сообщения"],
  691. str: ["Сила отряда", "Добавляет таблицу общей силы отряда в некоторых окнах"],
  692. //trd: [ "Торговля", "Добавляет маркеры и отправку недостающих ресурсов, необходимых для фестиваля. Инструменты для долевой торговли" ],
  693. per: ["Процент торговля", ""],
  694. rec: ["Рекрутинг торговля", ""],
  695. cnt: ["Завоевания", "Отображение общего числа атак/подкреплений в окне завоевания города"],
  696. way: ["30% ускорение", "Отображает примерное время движения отряда с 30% бонусом"],
  697. sim: ["Симулятор", "Изменение интерфейса симулятора, добавление новых функций"],
  698. spl: ["Заклинания", "Изменяет положение окна заклинаний"],
  699. act: ["Перемещения", "Показывает окна пересылки ресурсов и перемещения войск"],
  700. pop: ["Благосклонность", "Отображение окна с уровнем благосклонности богов"],
  701. tsk: ["Таскбар", "Увеличение ширины таскбара и сворачивание окна ежедневной награды при входе в игру"],
  702. irc: ["Чат", 'Замена чата игры на irc-чат'],
  703. bbc: ["Форма обороны", "Добавляет кнопку для вставки в сообщение отчёта о городе"], // Beschreibung passt nicht ganz
  704. com: ["Сравнение юнитов", "Добавляет окно сравнения юнитов"],
  705. tic: ["Типы городов", "Каждый город получает значок для городского типа (автоматическое определение)", "Дополнительные иконки доступны для ручного выбора"], // ?
  706. til: ["Список город", "Добавляет значки городские в список города"], // ?
  707. tim: ["Карта", "Устанавливает городские иконки на стратегической карте"], // ?
  708. wwc: ["Чудо света", "Share calculation & resources counter + previous & next buttons on finished world wonders (currently not deactivatable!)"],
  709. wwr: ["", ""],
  710. //wwi: [ "World wonder icons",'Adds world wonder icons on the strategic map' ],
  711. //con: [ "Context menu", 'Swaps "Select town" and "City overview" in the context menu'],
  712. //sen: [ "Sent units", 'Shows sent units in the attack/support window'],
  713. tov: ["Обзор Город", 'Заменяет новый обзор города с старом стиле окна'], // ?
  714. scr: ["Колесо мыши", 'С помощью колеса мыши вы можете изменить взгляды'], // ?
  715.  
  716. err: ["Отправить сообщения об ошибках автоматически", "Если вы включите эту опцию, вы можете помочь идентифицировать ошибки"]
  717. },
  718.  
  719. labels: {
  720. uni: "Доступные войска",
  721. con: "выбирать",
  722. // Smileys
  723. std: "",
  724. gre: "",
  725. nat: "",
  726. ppl: "",
  727. oth: "",
  728. // Defense form
  729. ttl: "Обзор: Отчёт о городе",
  730. inf: "Информация о войсках и постройках:",
  731. dev: "Отклонение",
  732. det: "Детальный отчёт",
  733. prm: "Премиум-бонусы",
  734. sil: "Серебро в пещере",
  735. mov: "Перемещения",
  736. // WW
  737. leg: "",
  738. stg: "",
  739. tot: "",
  740. // Simulator
  741. str: "Сила войск",
  742. los: "Потери",
  743. mod: "без учёта заклинаний, бонусов, исследований",
  744. // Comparison box
  745. dsc: "Сравнение юнитов",
  746. hck: "Ударное",
  747. prc: "Колющее",
  748. dst: "Дальнего боя",
  749. sea: "Морские",
  750. att: "Атака",
  751. def: "Защита",
  752. spd: "Скорость",
  753. bty: "Добыча (ресурсы)",
  754. cap: "Вместимость транспортов",
  755. res: "Стоимость (ресурсы)",
  756. fav: "Благосклонность",
  757. tim: "Время найма (с)",
  758. // Trade
  759. rat: "",
  760. shr: "",
  761. per: "",
  762. // Sent units box
  763. lab: "Отправлено",
  764. improved_movement: "Улучшенная перемещение войск"
  765. },
  766.  
  767. buttons: {
  768. sav: "Сохраниить", ins: "Вставка", res: "Сброс"
  769. }
  770. },
  771. ////////////////////////////////
  772. // Polish Translation by anpu //
  773. ////////////////////////////////
  774. pl: {
  775. settings: {
  776. dsc: "DIO-Tools oferuje (między innymi) poprawione widoki, nowe uśmieszki,<br>opcje handlu i zmiany w wyglądzie.",
  777. act: "Włącz/wyłącz funkcje skryptu:",
  778. prv: "podgląd poszczególnych opcji:"
  779. },
  780. options: {
  781. bir: ["Licznik birem", "Zlicza i sumuje biremy z miast"],
  782. sml: ["Emotki", "Dodaje dodatkowe (zielone) emotikonki"],
  783. str: ["Siła jednostek", "dodaje tabelki z siłą jednostek w różnych miejscach gry"],
  784. //trd: [ "Handel", "Rozszerza okno handlu o handel procentowy, proporcje surowców wg jednostek, dodaje znaczniki dla festynów" ],
  785. per: ["Handel procentowy", ""],
  786. rec: ["Handel rekrutacyjne", ""],
  787. cnt: ["Podboje", "Zlicza wsparcia/ataki w oknie podboju (tylko własne podboje)"],
  788. way: ["Prędkość wojsk", "Wyświetla dodatkowo czas jednostek dla bonusu przyspieszone ruchy wojsk"],
  789. sim: ["Symulator", "Dostosowanie wyglądu symulatora oraz dodanie szybkich pól wyboru"],
  790. spl: ["Ramka czarów", "Kompaktowa pływająca ramka z czarami (można umieścić w dowolnym miejscu ekranu. Zapamiętuje położenie.)"],
  791. act: ["Ramki aktywności", "Ulepszony podgląd ruchów wojsk i handlu (można umieścić w dowolnym miejscu ekranu. Zapamiętuje położenie.)"],
  792. pop: ["Łaski", "Zmienia wygląd ramki informacyjnej o ilości produkowanych łask"],
  793. tsk: ["Pasek skrótów", "Powiększa pasek skrótów i minimalizuje okienko z bonusem dziennym"],
  794. irc: ["Czat", 'Zastępuje standardowy Chat chatem IRC (wymagany FlashPlayer)'],
  795. bbc: ["Raportów obronnych", "Rozszerza pasek skrótów BBcode o generator raportów obronnych"],
  796. com: ["Porównianie", "Dodaje tabelki z porównaniem jednostek"],
  797. tic: ["Ikony miasta", "Każde miasto otrzyma ikonę typu miasta (automatyczne wykrywanie)", "Dodatkowe ikony są dostępne dla ręcznego wyboru"], // ?
  798. til: ["Lista miasto", "Dodaje ikony miasta do listy miasta"], // ?
  799. tim: ["Mapa", "Zestawy ikon miasta na mapie strategicznej"], // ?
  800. 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)"],
  801. wwr: ["", ""],
  802. //wwi: [ "World wonder icons",'Adds world wonder icons on the strategic map' ],
  803. con: ["menu kontekstowe", 'Zamiemia miejcami przycisk "wybierz miasto" z przyciskiem "podgląd miasta" po kliknięciu miasta na mapie'],
  804. sen: ["Wysłane jednostki", 'Pokaż wysłane jednostki w oknie wysyłania ataków/wsparć'],
  805. tov: ["Podgląd miasta", 'Zastępuje nowy podgląd miasta starym'],
  806. scr: ["Zoom", 'Możesz zmienić poziom przybliżenia mapy kółkiem myszy'],
  807.  
  808. err: ["Automatycznie wysyłać raporty o błędach", "Jeśli włączysz tę opcję, możesz pomóc zidentyfikować błędy"]
  809.  
  810. },
  811. labels: {
  812. uni: "Dostępne jednostki",
  813. con: "Wybierz miasto",
  814. // Smileys
  815. std: "Standard" /* "Standardowe" */,
  816. gre: "Grepolis",
  817. nat: "Przyroda",
  818. ppl: "Ludzie",
  819. oth: "Inne",
  820. // Defense form
  821. ttl: "Podgląd: Obrona miasta",
  822. inf: "Informacje o mieście:",
  823. dev: "Ochyłka",
  824. det: "jednostki lądowe",
  825. prm: "opcje Premium",
  826. sil: "Ilość srebra",
  827. mov: "Ruchy wojsk",
  828. // WW
  829. leg: "Udział w Cudzie",
  830. stg: "Poziom",
  831. tot: "Łącznie",
  832. // Simulator
  833. str: "Siła jednostek",
  834. los: "Straty",
  835. mod: "bez modyfikatorów",
  836. // Comparison box
  837. dsc: "Porównianie jednostek",
  838. hck: "Obuchowa",
  839. prc: "Tnąca",
  840. dst: "Dystansowa",
  841. sea: "Morskie",
  842. att: "Offensywne",
  843. def: "Defensywne",
  844. spd: "Prędkość",
  845. bty: "Łup (surowce)",
  846. cap: "Pojemność transportu",
  847. res: "Koszta (surowce)",
  848. fav: "Łaski",
  849. tim: "Czas rekrutacji (s)",
  850. // Trade
  851. rat: "Stosunek surowców dla wybranej jednostki",
  852. shr: "procent zapełnienia magazynu w docelowym mieście",
  853. per: "Handel procentowy",
  854. // Sent units box
  855. lab: "Wysłane jednostki",
  856. improved_movement: "Przyspieszone ruchy wojsk"
  857. },
  858. buttons: {
  859. sav: "Zapisz", ins: "Wstaw", res: "Anuluj"
  860. }
  861. },
  862. //////////////////////////////////////////////
  863. // Spanish Translation by Juana de Castilla //
  864. //////////////////////////////////////////////
  865. es: {
  866. settings: {
  867. dsc: "DIO-Tools ofrece, entre otras cosas, varias pantallas, ventana de <br>emoticones, opciones de comercio y algunos cambios en el diseño.",
  868. act: "Activar/desactivar características de las herramientas:",
  869. prv: "Vista previa de varias características:"
  870. },
  871. options: {
  872. bir: ["Contador de birremes", "Cuenta los birremes de una ciudad y los suma"],
  873. sml: ["Emoticones", "Código BB para emoticones"],
  874. str: ["Fortaleza de la Unidad", "Añade tabla de fortalezas de cada unidad en varias zonas"],
  875. //trd: [ "Comercio", "Añade en la pestaña de comercio un porcentaje de comercio y reclutamiento y limitadores de Mercado por cada ciudad" ],
  876. per: ["Comercio de porcentual", ""],
  877. rec: ["Comercio de reclutamiento", ""],
  878. cnt: ["Conquistas", "contador de ataques y refuerzos en la pestaña de conquista"],
  879. way: ["Velocidad de tropas", "Muestra movimiento de tropas mejorado en la ventana de ataque/refuerzo"],
  880. sim: ["Simulador", "Adaptación de la ventana del simulador incluyendo recuadro de modificadores"],
  881. spl: ["Ventana de hechizos", "Ventana deslizante y comprimida de los hechizos (memoria posicional)"],
  882. act: ["Ventana de actividad", "Mejora las ventanas de comercio y movimiento de tropas (memoria posicional)"],
  883. pop: ["Popup", "Cambia el popup de favores"],
  884. tsk: ["Barra de tareas", "aumenta la barra de tareas y minimice la recompensa al aparecer"],
  885. irc: ["Chat", 'Sustituye el chat de la alianza con un irc chat. (require FlashPlayer)'],
  886. bbc: ["Formulario de defensa", "Añade en la barra de códigos bb un formulario de defensa"],
  887. com: ["Comparación", "añade ventana de comparación de unidades"],
  888. tic: ["Iconos de la ciudad", "Cada ciudad recibe un icono para el tipo de la ciudad (detección automática)", "Iconos adicionales están disponibles para la selección manual"],
  889. til: ["Lista de la ciudad", "Agrega los iconos de la ciudad a la lista de la ciudad"],
  890. tim: ["Map", "Establece los iconos de la ciudad en el mapa estratégico"],
  891. wwc: ["Maravillas", "Calcula participación & contador de recursos + antes y después teclas de maravillas terminadas (no desactibable ahora!)"],
  892. wwr: ["", ""],
  893. //wwi: [ "World wonder icons",'Adds world wonder icons on the strategic map' ],
  894. con: ["menú contextual", 'Cambia "Elegir ciudad" y "vista de la ciudad" en el menú contextual '],
  895. sen: ["Unidades enviadas", 'Muestra las unidades enviadas en la ventana de ataque/refuerzos'],
  896. tov: ["Información de la ciudad", 'sustituye la vista nueva de ciudad por la ventana antigua'],
  897. scr: ["Rueda raton", 'Puede cambiar las vistas con la rueda del raton'],
  898.  
  899. err: ["Enviar informes de errores automáticamente", "Si se activa esta opción, puede ayudar a identificar errores."]
  900. },
  901. labels: {
  902. uni: "Unidades disponibles",
  903. con: "Escoger ciudad",
  904. // Smileys
  905. std: "Standard",
  906. gre: "Grepolis",
  907. nat: "Natura",
  908. ppl: "Gente",
  909. oth: "Otros",
  910. // Defense form
  911. ttl: "Vista general: Defensa de la ciudad",
  912. inf: "Información de la ciudad:",
  913. dev: "Desviación",
  914. det: "Unidades de tierra detalladas",
  915. prm: "Bonos Premium",
  916. sil: "Volumen de plata",
  917. mov: "Movimientos de tropas:",
  918. // WW
  919. leg: "WW cuota",
  920. stg: "Nivel",
  921. tot: "Total",
  922. // Simulator
  923. str: "Fortaleza de la Unidad",
  924. los: "Perdida",
  925. mod: "sin influencia del modificador",
  926. // Comparison box
  927. dsc: "Comparación de Unidades",
  928. hck: "Contundente",
  929. prc: "Punzante",
  930. dst: "Distancia",
  931. sea: "Mar",
  932. att: "Ataque",
  933. def: "Defensa",
  934. spd: "Velocidad",
  935. bty: "Botín (recursos)",
  936. cap: "Capacidad de transporte",
  937. res: "Costes (recursos)",
  938. fav: "Favor",
  939. tim: "Tiempo de reclutamiento (s)",
  940. // Trade
  941. rat: "Proporción de recursos de un tipo de unidad",
  942. shr: "Porcentaje de la capacidad de almacenamiento de la ciudad destino",
  943. per: "Porcentaje de comercio",
  944. // Sent units box
  945. lab: "Unidades enviadas",
  946. improved_movement: "Movimiento de tropas mejorados"
  947. },
  948. buttons: {
  949. sav: "Guardar", ins: "Insertar", res: "Reinicio"
  950. }
  951. },
  952. ar: {},
  953. ////////////////////////////////////////////
  954. // Portuguese (BR) Translation by HELL //
  955. ////////////////////////////////////////////
  956. br: {
  957. settings: {
  958. dsc: "DIO-Tools oferece, entre outras coisas, algumas telas, uma caixa de smiley, opções de comércio <br> e algumas alterações no layout.",
  959. act: "Ativar/desativar recursos do conjunto de ferramentas:",
  960. prv: "Pré-visualização de vários recursos:",
  961.  
  962. version_old: "Versão não está atualizada",
  963. version_new: "Versão está atualizada",
  964. version_dev: "Versão do desenvolvedor",
  965.  
  966. version_update: "Atualização",
  967.  
  968. link_forum: "http://forum.en.grepolis.com/showthread.php?52104&goto=newpost",
  969. link_contact: "http://forum.en.grepolis.com/private.php?do=newpm&u=46211",
  970.  
  971. forum: "Forum",
  972. author: "Autor",
  973.  
  974. cat_units: "Unidades",
  975. cat_icons: "Ícones nas Cidades",
  976. cat_forum: "Forum",
  977. cat_trade: "Comércio",
  978. cat_wonders: "Maravilhas do Mundo",
  979. cat_layout: "Layout",
  980. cat_other: "Outros"
  981. },
  982. options: {
  983. bir: ["Contador de Birremes", "Conta as biremes da cidade na cidade"],
  984. ava: ["Unidades Disponíveis", "Conta as unidades disponíveis de todas as cidades"],
  985. sml: ["Smilies", "Estende o bbcode com uma caixa de smiley"],
  986. str: ["Força das Tropas", "Adiciona quadros de força das tropas em diversas áreas"],
  987. tra: ["Capacidade de Transporte", "Mostra a capacidade de transporte ocupado e disponível no menu de unidades"],
  988. per: ["Percentual de comércio", "Estende-se a janela de comércio com um percentual de comércio"],
  989. rec: ["Comércio para recrutamento", "Estende-se a janela de comércio com um comércio de recrutamento"],
  990. cnt: ["Conquistas", "Conta os ataques/apoios na janela de conquista"],
  991. way: ["Velocidade da Tropa", "Displays mostram a possivél velocidade de tropa na janela de ataque/suporte"],
  992. sim: ["Simulador", "Adaptação do layout simulador & exposição permanente da caixa poderes estendida"],
  993. spl: ["Caixa de Poderes Divinos", "Pequena caixa móvel & magnética de poderes divinos (com memória de posição) "],
  994. act: ["Ativar caixas suspensas de comércio e ataque", "Melhorias da exibição de caixas de comércio e atividade tropa (com memória de posição)"],
  995. pop: ["Caixa de favores divino", "Altera a caixa de favores divino por um novo layout"],
  996. tsk: ["Barra de tarefas", "Aumenta a barra de tarefas e minimiza a janela recompensa diária no inicio"],
  997. irc: ["Chat", 'Substituiu o da bate-papo por um bate-papo IRC. (Flash Player requerido)'],
  998. bbc: ["Pedido de Apoio", "Estende a barra de bbcode com uma forma de Pedido de Apoio Automática"],
  999. com: ["Comparação de Unidades", "Adiciona tabelas de comparação de unidade"],
  1000. tic: ["Ícones nas Cidades", "Cada cidade recebe um ícone para o tipo de tropas na cidade (detecção automática) "," Ícones adicionais estão disponíveis para seleção manual"],
  1001. til: ["Lista das Cidades", "Adiciona os ícones da cidade na lista de cidades"],
  1002. tim: ["Mapa", "Mostra os ícones das cidades no mapa estratégico"],
  1003. wwc: ["Calculadora de WW", "Cálculo compartilhado & contador de recursos + botões anterior e próxima maravilhas do mundo (atualmente não desactivável!)"],
  1004. wwr: ["Classificação", "Classificação das maravilha do mundo redesenhadas"],
  1005. wwi: ["Icones", 'Adiciona ícones nas maravilha do mundo no mapa estratégico'],
  1006. con: ["Menu de Contexto", 'Troca da "Selecione cidade" e "Visão Geral da Cidade" no menu de contexto'],
  1007. sen: ["Unidades Enviadas", 'Shows sent units in the attack/support window'],
  1008. tov: ["Visão da Cidade", 'Substitui o novo panorama da cidade, com o estilo da janela antiga'],
  1009. scr: ["Roda do Mouse", 'Você pode alterar os pontos de vista com a roda do mouse'],
  1010.  
  1011. err: ["Enviar automaticamente relatórios de erros", "Se você ativar essa opção, você pode ajudar a identificar erros."],
  1012. her: ["Conquista Thracian", "Redução de tamanho do mapa da conquista Thracian."]
  1013. },
  1014. labels: {
  1015. uni: "Unidades disponíveis",
  1016. con: "Selecionar cidade",
  1017. // Smileys
  1018. std: "Padrão",
  1019. gre: "Grepolis",
  1020. nat: "Natural",
  1021. ppl: "Popular",
  1022. oth: "Outros",
  1023. hal: "Halloween",
  1024. xma: "Natal",
  1025. // Defense form
  1026. ttl: "Pedido de Apoio",
  1027. inf: "Informação da cidade:",
  1028. dev: "Desvio",
  1029. det: "Unidades Detalhadas",
  1030. prm: "Bônus Premium",
  1031. sil: "Prata na Gruta",
  1032. mov: "Movimentação de Tropas:",
  1033. // WW
  1034. leg: "WW Maravilhas",
  1035. stg: "Level",
  1036. tot: "Total",
  1037. // Simulator
  1038. str: "Força das Unidades",
  1039. los: "Perdas",
  1040. mod: "Sem modificador de influência",
  1041. // Comparison box
  1042. dsc: "Comparação de unidades",
  1043. hck: "Impacto",
  1044. prc: "Corte",
  1045. dst: "Arremço",
  1046. sea: "Naval",
  1047. att: "Ofensivo",
  1048. def: "Defensivo",
  1049. spd: "Velocidade",
  1050. bty: "Saque (recursos)",
  1051. cap: "Capacidade de trasporte",
  1052. res: "Custo (recursos)",
  1053. fav: "Favor",
  1054. tim: "Tempo de recrutamento (s)",
  1055. // Trade
  1056. rat: "Proporção de recursos de um tipo de unidade",
  1057. shr: "A partir do armazenamento sobre a cidade de destino",
  1058. per: "Percentual de comércio",
  1059. // Sent units box
  1060. lab: "Unidades enviadas",
  1061. improved_movement: "Movimentação de tropas com ajuste de bônus"
  1062. },
  1063. buttons: {
  1064. sav: "Salvar", ins: "Inserir", res: "Resetar"
  1065. }
  1066. },
  1067. pt : {}
  1068. };
  1069.  
  1070. LANG.ar = LANG.es;
  1071. LANG.pt = LANG.br;
  1072.  
  1073. // Create JSON
  1074. // console.log(JSON.stringify(LANG.en));
  1075.  
  1076. // Forum: Choose language
  1077. if (uw.location.pathname !== "/game/index") {
  1078. LID = uw.location.host.split(".")[1];
  1079. }
  1080.  
  1081. // Translation GET
  1082. function getText(category, name) {
  1083. var txt = "???";
  1084. if (LANG[LID]) {
  1085. if (LANG[LID][category]) {
  1086. if (LANG[LID][category][name]) {
  1087. txt = LANG[LID][category][name];
  1088. } else {
  1089. if (LANG.en[category]) {
  1090. if (LANG.en[category][name]) {
  1091. txt = LANG.en[category][name];
  1092. }
  1093. }
  1094. }
  1095. } else {
  1096. if (LANG.en[category]) {
  1097. if (LANG.en[category][name]) {
  1098. txt = LANG.en[category][name];
  1099. }
  1100. }
  1101. }
  1102. } else {
  1103. if (LANG.en[category]) {
  1104. if (LANG.en[category][name]) {
  1105. txt = LANG.en[category][name];
  1106. }
  1107. }
  1108. }
  1109. return txt;
  1110. }
  1111.  
  1112. /*******************************************************************************************************************************
  1113. * Settings
  1114. *******************************************************************************************************************************/
  1115.  
  1116. // (De)activation of the features
  1117. var options_def = {
  1118. bir: true, // Biremes counter
  1119. ava: true, // Available units
  1120. sml: true, // Smileys
  1121. str: true, // Unit strength
  1122. tra: true, // Transport capacity
  1123. per: true, // Percentual Trade
  1124. rec: true, // Recruiting Trade
  1125. way: true, // Troop speed
  1126. cnt: true, // Attack/support counter
  1127. sim: true, // Simulator
  1128. spl: true, // Spell box
  1129. act: false,// Activity boxes
  1130. tsk: true, // Task bar
  1131. irc: true, // IRC-Chat
  1132. pop: true, // Favor popup
  1133. bbc: true, // BBCode bar
  1134. com: true, // Unit comparison
  1135. tic: true, // Town icons
  1136. til: true, // Town icons: Town list
  1137. tim: true, // Town icons: Map
  1138. wwc: true, // World wonder counter
  1139. wwr: true, // World wonder ranking
  1140. wwi: true, // World wonder icons
  1141. con: true, // Context menu
  1142. sen: true, // Sent units
  1143. tov: false,// Town overview
  1144. scr: true, // Mausrad,
  1145.  
  1146. err: false,// Error Reports
  1147. her: true // Thrakische Eroberung
  1148. };
  1149.  
  1150. if (uw.location.pathname === "/game/index") {
  1151. for (var opt in options_def) {
  1152. if (options_def.hasOwnProperty(opt)) {
  1153. if (DATA.options[opt] === undefined) {
  1154. DATA.options[opt] = options_def[opt];
  1155. }
  1156. }
  1157. }
  1158. }
  1159.  
  1160. var version_text = '', version_color = 'black';
  1161.  
  1162. function getLatestVersion() {
  1163. $('<style id="dio_version">' +
  1164. '#version_info .version_icon { background: url(http://666kb.com/i/ct1etaz0uyohw402i.png) -50px -50px no-repeat; width:25px; height:25px; float:left; } ' +
  1165. '#version_info .version_icon.red { -webkit-filter: hue-rotate(-100deg); } ' +
  1166. '#version_info .version_icon.green { -webkit-filter: hue-rotate(0deg); } ' +
  1167. '#version_info .version_icon.blue { -webkit-filter: hue-rotate(120deg); } ' +
  1168. '#version_info .version_text { line-height: 2; margin: 0px 6px 0px 6px; float: left;} ' +
  1169. '</style>').appendTo("head");
  1170.  
  1171. var v_info = $('#version_info');
  1172. if (version_text === '') {
  1173. $.ajax({
  1174. type: "GET", url: "https://diotools.de/scripts/version.php",
  1175. success: function (response) {
  1176. var latest_version = parseFloat(response),
  1177. current_version = parseFloat(version);
  1178.  
  1179. if (current_version < latest_version) {
  1180. version_text = "<div class='version_icon red'></div><div class='version_text'>" + getText('settings', 'version_old') + "</div><div class='version_icon red'></div>" +
  1181. '<a class="version_text" href="https://diotools.de/downloads/DIO-TOOLS.user.js" target="_blank">--> Update</a>';
  1182. version_color = 'crimson';
  1183. } else if (current_version == latest_version) {
  1184. version_text = "<div class='version_icon green'></div><div class='version_text'>" + getText('settings', 'version_new') + "</div><div class='version_icon green'></div>";
  1185. version_color = 'darkgreen';
  1186. } else {
  1187. version_text = "<div class='version_icon blue'></div><div class='version_text'>" + getText('settings', 'version_dev') + "</div><div class='version_icon blue'></div>";
  1188. version_color = 'darkblue';
  1189. }
  1190. v_info.html(version_text).css({color: version_color});
  1191. }
  1192. });
  1193. } else {
  1194. v_info.html(version_text).css({color: version_color});
  1195. }
  1196. }
  1197.  
  1198. // Add DIO-Tools to grepo settings
  1199. function settings() {
  1200. var wid = $(".settings-menu").get(0).parentNode.id;
  1201.  
  1202. if (!$("#dio_tools").get(0)) {
  1203. $(".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>');
  1204. }
  1205.  
  1206. $(".settings-link").click(function () {
  1207. $('.section').each(function () {
  1208. this.style.display = "block";
  1209. });
  1210. $('.settings-container').removeClass("dio_overflow");
  1211.  
  1212. $('#dio_bg_medusa').css({display: "none"});
  1213.  
  1214. if ($('#dio_settings').get(0)) {
  1215. $('#dio_settings').get(0).style.display = "none";
  1216. }
  1217. });
  1218.  
  1219. $("#dio_tools").click(function () {
  1220. if ($('.email').get(0)) {
  1221. $('.settings-container').removeClass("email");
  1222. }
  1223.  
  1224. $('.settings-container').addClass("dio_overflow");
  1225.  
  1226. $('#dio_bg_medusa').css({display: "block"});
  1227.  
  1228. if (!$('#dio_settings').get(0)) {
  1229. // Styles
  1230. $('<style id="dio_settings_style">' +
  1231. // Chrome Scroollbar Style
  1232. '#dio_settings ::-webkit-scrollbar { width: 13px; } ' +
  1233. '#dio_settings ::-webkit-scrollbar-track { background-color: rgba(130, 186, 135, 0.5); border-top-right-radius: 4px; border-bottom-right-radius: 4px; } ' +
  1234. '#dio_settings ::-webkit-scrollbar-thumb { background-color: rgba(87, 121, 45, 0.5); border-radius: 3px; } ' +
  1235. '#dio_settings ::-webkit-scrollbar-thumb:hover { background-color: rgba(87, 121, 45, 0.8); } ' +
  1236.  
  1237. '#dio_settings table tr :first-child { text-align:center; vertical-align:top; } ' +
  1238.  
  1239. '#dio_settings #version_info { font-weight:bold;height: 35px;margin-top:-5px; } ' +
  1240. '#dio_settings #version_info img { margin:-1px 2px -8px 0px; } ' +
  1241.  
  1242. '#dio_settings .icon_types_table { font-size:0.7em; line-height:2.5; border:1px solid green; border-spacing:10px 2px; border-radius:5px; } ' +
  1243. '#dio_settings .icon_types_table td { text-align:left; } ' +
  1244.  
  1245. '#dio_settings table p { margin:0.2em 0em; } ' +
  1246.  
  1247. '#dio_settings .checkbox_new .cbx_caption { white-space:nowrap; margin-right:10px; font-weight:bold; } ' +
  1248.  
  1249. '#dio_settings .dio_settings_tabs {width:auto; border:2px solid darkgreen; background:#2B241A; padding:1px 1px 0px 1px; right:auto; border-top-left-radius:5px; border-top-right-radius:5px; border-bottom:0px;} ' +
  1250.  
  1251. '#dio_settings .dio_settings_tabs li { float:left; } ' +
  1252.  
  1253. '#dio_settings .icon_small { margin:0px; } ' +
  1254.  
  1255. '#dio_settings img { max-width:90px; max-height:90px; margin-right:10px; } ' +
  1256.  
  1257. '#dio_settings .content { border:2px solid darkgreen; border-radius:5px; border-top-left-radius:0px; background:rgba(31, 25, 12, 0.1); top:23px; position:relative; padding:10px; height:350px; overflow-y:auto; } ' +
  1258. '#dio_settings .content .content_category { display:none; border-spacing:5px; } ' +
  1259.  
  1260. '#dio_settings .dio_options_table legend { font-weight:bold; } ' +
  1261. '#dio_settings .dio_options_table p { margin:0px; } ' +
  1262. '#dio_settings #donate_btn { -webkit-filter: hue-rotate(45deg); } ' +
  1263.  
  1264. '#donate_btn { background: url(' + dio_sprite + '); width:100px; height:26px;} ' +
  1265. '#donate_btn.de { background-position: 0px 250px } ' +
  1266. '#donate_btn.en { background-position: 0px 300px } ' +
  1267.  
  1268. '#dio_hall table { border-spacing: 9px 3px; } ' +
  1269. '#dio_hall table th { text-align:left !important;color:green;text-decoration:underline;padding-bottom:10px; } ' +
  1270. '#dio_hall table td.value { text-align: right; } ' +
  1271.  
  1272. '#dio_hall table td.laurel.green { background: url("/images/game/ally/founder.png") no-repeat; height:18px; width:18px; background-size:100%; } ' +
  1273. '#dio_hall table td.laurel.bronze { background: url("https://diotools.de/images/game/laurel_sprite.png") no-repeat 25%; height:18px; width:18px; } ' +
  1274. '#dio_hall table td.laurel.silver { background: url("https://diotools.de/images/game/laurel_sprite.png") no-repeat 50%; height:18px; width:18px; } ' +
  1275. '#dio_hall table td.laurel.gold { background: url("https://diotools.de/images/game/laurel_sprite.png") no-repeat 75%; height:18px; width:18px; } ' +
  1276. '#dio_hall table td.laurel.blue { background: url("https://diotools.de/images/game/laurel_sprite.png") no-repeat 100%; height:18px; width:18px; } ' +
  1277. '</style>').appendTo('head');
  1278.  
  1279.  
  1280. $('.settings-container').append(
  1281. '<div id="dio_settings" class="player_settings section"><div id="dio_bg_medusa"></div>' +
  1282. '<div class="game_header bold"><a href="#" target="_blank" style="color:white">DIO-Tools (v' + version + ')</a></div>' +
  1283.  
  1284. // Check latest version
  1285. '<div id="version_info"><img src="http://666kb.com/i/csmicltyu4zhiwo5b.gif" /></div>' +
  1286.  
  1287. // Donate button
  1288. '<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">' +
  1289. '<div id="donate_btn" class="' + LID + '" alt="Donate"></div></a></div>' +
  1290.  
  1291. // Settings navigation
  1292. '<ul class="menu_inner dio_settings_tabs">' +
  1293. '<li><a class="submenu_link active" href="#" id="dio_units"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_units") + '</span></span></span></a></li>' +
  1294. '<li><a class="submenu_link" href="#" id="dio_icons"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_icons") + '</span></span></span></a></li>' +
  1295. '<li><a class="submenu_link" href="#" id="dio_forum"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_forum") + '</span></span></span></a></li>' +
  1296. '<li><a class="submenu_link" href="#" id="dio_trade"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_trade") + '</span></span></span></a></li>' +
  1297. '<li><a class="submenu_link" href="#" id="dio_wonder"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_wonders") + '</span></span></span></a></li>' +
  1298. '<li><a class="submenu_link" href="#" id="dio_layout"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_layout") + '</span></span></span></a></li>' +
  1299. '<li><a class="submenu_link" href="#" id="dio_other"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_other") + '</span></span></span></a></li>' +
  1300. '</ul>' +
  1301.  
  1302. // Settings content
  1303. '<DIV class="content">' +
  1304.  
  1305. // Units tab
  1306. '<table id="dio_units_table" class="content_category visible"><tr>' +
  1307. '<td><img src="https://diotools.de/images/game/settings/units/available_units.png" alt="" /></td>' +
  1308. '<td><div id="ava" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "ava")[0] + '</div></div>' +
  1309. '<p>' + getText("options", "ava")[1] + '</p></td>' +
  1310. '</tr><tr>' +
  1311. '<td><img src="https://diotools.de/images/game/settings/units/sent_units.png" alt="" /></td>' +
  1312. '<td><div id="sen" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "sen")[0] + '</div></div>' +
  1313. '<p>' + getText("options", "sen")[1] + '</p></td>' +
  1314. '</tr><tr>' +
  1315. '<td><img src="https://diotools.de/images/game/settings/units/unit_strength.png" alt="" /></td>' +
  1316. '<td><div id="str" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "str")[0] + '</div></div>' +
  1317. '<p>' + getText("options", "str")[1] + '</p></td>' +
  1318. '</tr><tr>' +
  1319. '<td><img src="https://diotools.de/images/game/settings/units/transport_capacity.png" alt="" /></td>' +
  1320. '<td><div id="tra" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "tra")[0] + '</div></div>' +
  1321. '<p>' + getText("options", "tra")[1] + '</p></td>' +
  1322. '</tr><tr>' +
  1323. '<td><img src="https://diotools.de/images/game/settings/units/unit_comparison.png" alt="" /></td>' +
  1324. '<td><div id="com" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "com")[0] + '</div></div>' +
  1325. '<p>' + getText("options", "com")[1] + '</p></td>' +
  1326. '</tr></table>' +
  1327.  
  1328. // Icons tab
  1329. '<table id="dio_icons_table" class="content_category"><tr>' +
  1330. '<td><img src="https://diotools.de/images/game/settings/townicons/townicons.png" alt="" /></td>' +
  1331. '<td><div id="tic" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "tic")[0] + '</div></div>' +
  1332. '<p>' + getText("options", "tic")[1] + '</p>' +
  1333. '<table class="icon_types_table">' +
  1334. '<tr><td style="width:115px"><div class="icon_small townicon_lo"></div> Land Offensive</td>' + '<td><div class="icon_small townicon_fo"></div> Fly Offensive</td></tr>' +
  1335. '<tr><td><div class="icon_small townicon_ld"></div> Land Defensive</td>' + '<td><div class="icon_small townicon_fd"></div> Fly Defensive</td></tr>' +
  1336. '<tr><td><div class="icon_small townicon_so"></div> Navy Offensive</td>' + '<td><div class="icon_small townicon_no"></div> Outside</td></tr>' +
  1337. '<tr><td><div class="icon_small townicon_sd"></div> Navy Defensive</td>' + '<td><div class="icon_small townicon_po"></div> Empty</td></tr>' +
  1338. '</table><br>' +
  1339. '<p>' + getText("options", "tic")[2] + ':</p>' +
  1340. '<div class="icon_small townicon_sh"></div><div class="icon_small townicon_di"></div><div class="icon_small townicon_un"></div><div class="icon_small townicon_ko"></div>' +
  1341. '<div class="icon_small townicon_ti"></div><div class="icon_small townicon_gr"></div><div class="icon_small townicon_dp"></div><div class="icon_small townicon_re"></div>' +
  1342. '<div class="icon_small townicon_wd"></div><div class="icon_small townicon_st"></div><div class="icon_small townicon_si"></div><div class="icon_small townicon_bu"></div>' +
  1343. '<div class="icon_small townicon_he"></div><div class="icon_small townicon_ch"></div><div class="icon_small townicon_bo"></div><div class="icon_small townicon_fa"></div>' +
  1344. '<div class="icon_small townicon_wo"></div>' +
  1345. '</td>' +
  1346. '</tr><tr>' +
  1347. '<td><img src="https://diotools.de/images/game/settings/townicons/townlist.png" alt="" style="border: 1px solid rgb(158, 133, 78);" /></td>' +
  1348. '<td><div id="til" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "til")[0] + '</div></div>' +
  1349. '<p>' + getText("options", "til")[1] + '</p></td>' +
  1350. '</tr><tr>' +
  1351. '<td><img src="https://diotools.de/images/game/settings/townicons/map.png" alt="" /></td>' +
  1352. '<td><div id="tim" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "tim")[0] + '</div></div>' +
  1353. '<p>' + getText("options", "tim")[1] + '</p></td>' +
  1354. '</tr></table>' +
  1355.  
  1356. // Forum tab
  1357. '<table id="dio_forum_table" class="content_category"><tr>' +
  1358. '<td><img src="https://diotools.de/images/game/settings/forum/smiley_box.png" alt="" /></td>' +
  1359. '<td><div id="sml" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "sml")[0] + '</div></div>' +
  1360. '<p>' + getText("options", "sml")[1] + '</p>' +
  1361. '<img src="http://www.greensmilies.com/smile/smiley_emoticons_mttao_wassermann.gif" /> <img src="http://666kb.com/i/cigrqlp2odi2kqo24.gif" /> ' +
  1362. '<img src="http://666kb.com/i/cifvfsu3e2sdiipn0.gif" alt="" /> <img src="http://666kb.com/i/cigmv8wnffb3v0ifg.gif" /> ' +
  1363. '<img src="http://666kb.com/i/cj2byjendffymp88t.gif" alt="" /> <img src="http://666kb.com/i/cj1l9gndtu3nduyvi.gif" /> ' +
  1364. '<img src="http://666kb.com/i/cigrmpfofys5xtiks.gif" alt="" />' + //'<img src="http://666kb.com/i/cifohielywpedbyh8.gif" />'+
  1365. '<br><br><br></td>' +
  1366. '</tr><tr>' +
  1367. '<td><img src="https://diotools.de/images/game/settings/forum/def_formular.png" alt="" /></td>' +
  1368. '<td><div id="bbc" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "bbc")[0] + '</div></div>' +
  1369. '<p>' + getText("options", "bbc")[1] + '</p><br><img src="http://s1.directupload.net/images/140401/9b2ydh82.png" alt="" style="max-width:none !important;" /></td>' +
  1370. '</tr></table>' +
  1371.  
  1372. // Trade tab
  1373. '<table id="dio_trade_table" class="content_category"><tr>' +
  1374. '<td><img src="https://diotools.de/images/game/settings/trade/recruiting_trade.png" /></td>' +
  1375. '<td><div id="rec" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "rec")[0] + '</div></div>' +
  1376. '<p>' + getText("options", "rec")[1] + '</p><br>' +
  1377. /*
  1378. '<p><u>Beispiel Feuerschiffe:</u><br>'+
  1379. '<p>Verhältnisauswahl</p>'+
  1380. '<table style="font-size: 0.7em;line-height: 2.5;border: 1px solid green;border-spacing: 10px 2px;border-radius: 5px;">'+
  1381. '<tr><th></th><th><div class="icon_small townicon_wd"></div></th><td></td><th><div class="icon_small townicon_st"></div></th><td></td><th><div class="icon_small townicon_si"></div></th></tr>'+
  1382. '<tr><td>Kosten</td><td>1300</td><td></td><td>300</td><td></td><td>800</td></tr>'+
  1383. '<tr><td>Verhältnis</td><td>1</td><td>:</td><td>0.23</td><td>:</td><td>0.62</td></tr>'+
  1384. '</table>'+
  1385. '<p>Lagergröße Zielstadt: 25500 - 1000 Puffer (=100%)</p>'+
  1386. '<p>Handelsmenge 25%: </p>'+
  1387. '<table style="font-size: 0.7em;line-height: 2.5;">'+
  1388. '<tr><td>4 x 25%</td><td>4 x 25%</td><td>...</td></tr>'+
  1389. '<tr><td><img src="http://s7.directupload.net/images/140920/uc4dsyp9.png" style="width:60px" /></td>'+
  1390. '<td><img src="http://s7.directupload.net/images/140920/uc4dsyp9.png" style="width:60px" /></td><td>...</td></tr>'+
  1391. '</table>'+
  1392. //'- Versenden von 35 einzelnen Rohstoffportionen im Anteil 20% (z.B. 4900 Holz, 1130 Stein, 3015 Silber bei Lagerkapazität von 25.500), das heißt 5 Portionen für einen Rekrutierungsslot'+
  1393. //'- nach Ankommen von jeweils 5 Portionen, Einheiten in Auftrag geben (19-21 Feuerschiffe bei maximaler Lagerkapazität)'+
  1394. //'Ein Puffer von 1000 Rohstoffeinheiten wird dabei von der Lagerkapazität der Zielstadt abgezogen, damit Rekrutierungsreste und neu produzierte Rohstoffe nicht gleich zum Überlaufen des Lagers führen.'+
  1395. //'Das Ganze beschleunigt das Befüllen der Rekrutierungsschleifen enorm und es gehen dabei keine Rohstoffe verloren.</p>'+
  1396. '<br><br><br></td>'+
  1397. */
  1398. '</tr><tr>' +
  1399. '<td><img src="https://diotools.de/images/game/settings/trade/percentage_trade.png" /></td>' +
  1400. '<td><div id="per" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "per")[0] + '</div></div>' +
  1401. '<p>' + getText("options", "per")[1] + '</p><br></td>' +
  1402. /*
  1403. '</tr><tr>'+
  1404. '<td><img src="http://s7.directupload.net/images/140917/tveb5n33.png" /></td>'+
  1405. '<td><div id="trd2" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">Trade Limit Marker</div></div>'+
  1406. '<p></p></td>'+
  1407. */
  1408. '</tr></table>' +
  1409.  
  1410. // World wonder tab
  1411. '<table id="dio_wonder_table" class="content_category"><tr>' +
  1412. '<td><img src="https://diotools.de/images/game/settings/wonders/share.png" alt="" /></td>' +
  1413. '<td><div id="wwc" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "wwc")[0] + '</div></div>' +
  1414. '<p>' + getText("options", "wwc")[1] + '</p><br/>' +
  1415. '<img src="https://diotools.de/images/game/settings/wonders/share_calculator.png" alt="" style="max-width:none !important;" /></td>' +
  1416. '</tr><tr>' +
  1417. '<td><img src="https://diotools.de/images/game/settings/wonders/ranking.png" alt="" /></td>' +
  1418. '<td><div id="wwr" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "wwr")[0] + '</div></div>' +
  1419. '<p>' + getText("options", "wwr")[1] + '</p></td>' +
  1420. '</tr><tr>' +
  1421. '<td><img src="https://diotools.de/images/game/settings/wonders/icons.png" alt="" /></td>' +
  1422. '<td><div id="wwi" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "wwi")[0] + '</div></div>' +
  1423. '<p>' + getText("options", "wwi")[1] + '</p></td>' +
  1424. '</tr></table>' +
  1425.  
  1426. // Layout tab
  1427. '<table id="dio_layout_table" class="content_category"><tr>' +
  1428. '<td><img src="https://diotools.de/images/game/settings/layout/simulator.png" alt="" /></td>' +
  1429. '<td><div id="sim" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "sim")[0] + '</div></div>' +
  1430. '<p>' + getText("options", "sim")[1] + '</p></td>' +
  1431. '</tr><tr>' +
  1432. '<td><img src="https://diotools.de/images/game/settings/layout/spellbox.png" alt="" /></td>' +
  1433. '<td><div id="spl" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "spl")[0] + '</div></div>' +
  1434. '<p>' + getText("options", "spl")[1] + '</p></td>' +
  1435. '</tr><tr>' +
  1436. '<td><img src="https://diotools.de/images/game/settings/layout/taskbar.png" alt="" /></td>' +
  1437. '<td><div id="tsk" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "tsk")[0] + '</div></div>' +
  1438. '<p>' + getText("options", "tsk")[1] + '</p></td>' +
  1439. '</tr><tr>' +
  1440. '<td><img src="https://diotools.de/images/game/settings/layout/favor_popup.png" alt="" /></td>' +
  1441. '<td><div id="pop" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "pop")[0] + '</div></div>' +
  1442. '<p>' + getText("options", "pop")[1] + '</p></td>' +
  1443. '</tr><tr>' +
  1444. '<td><img src="https://diotools.de/images/game/settings/layout/contextmenu.png" alt="" /></td>' +
  1445. '<td><div id="con" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "con")[0] + '</div></div>' +
  1446. '<p>' + getText("options", "con")[1] + '</p></td>' +
  1447. '</tr><tr>' +
  1448. '<td><img src="https://diotools.de/images/game/settings/layout/activity_boxes.png" alt="" /></td>' +
  1449. '<td><div id="act" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "act")[0] + '</div></div>' +
  1450. '<p>' + getText("options", "act")[1] + '</p></td>' +
  1451. '</tr></table>' +
  1452.  
  1453. // Other Stuff tab
  1454. '<table id="dio_other_table" class="content_category"><tr>' +
  1455. '<td><img src="https://diotools.de/images/game/settings/misc/troop_speed.png" style="border: 1px solid rgb(158, 133, 78);" alt="" /></td>' +
  1456. '<td><div id="way" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "way")[0] + '</div></div>' +
  1457. '<p>' + getText("options", "way")[1] + '</p></td>' +
  1458. '</tr><tr>' +
  1459. '<td><img src="https://diotools.de/images/game/settings/misc/chat.png" alt="" /></td>' +
  1460. '<td><div id="irc" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "irc")[0] + '</div></div>' +
  1461. '<p>' + getText("options", "irc")[1] + '</p></td>' +
  1462. '</tr><tr>' +
  1463. '<td><img src="https://diotools.de/images/game/settings/misc/conquer_counter.png" style="border: 1px solid rgb(158, 133, 78);" alt="" /></td>' +
  1464. '<td><div id="cnt" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "cnt")[0] + '</div></div>' +
  1465. '<p>' + getText("options", "cnt")[1] + '</p></td>' +
  1466. '</tr><tr>' +
  1467. '<td><img src="https://diotools.de/images/game/settings/misc/mousewheel_zoom.png" alt="" /></td>' +
  1468. '<td><div id="scr" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "scr")[0] + '</div></div>' +
  1469. '<p>' + getText("options", "scr")[1] + '</p><br><br></td>' +
  1470. '</tr><tr>' +
  1471. '<td><img src="" alt="" /></td>' +
  1472. '<td><div id="err" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "err")[0] + '</div></div>' +
  1473. '<p>' + getText("options", "err")[1] + '</p></td>' +
  1474. '</tr></table>' +
  1475.  
  1476.  
  1477. // Hall of DIO-Tools tab
  1478. '<div id="dio_hall" class="content_category">'+
  1479. "<p>I like to thank all of you who helped the development of DIO-Tools by donating or translating!</p>"+
  1480. '<table style="float:left;margin-right: 75px;">'+
  1481. '<tr><th colspan="3">Donations</th></tr>'+
  1482. (function(){
  1483. var donations = [
  1484. ["Eduard R", 50],
  1485. ["Gregoire L", 25],
  1486. ["Renee A", 20], ["Dirk R", 20], ["Patti T", 20],
  1487. ["Klaus N", 15],
  1488. ["Marco S", 10], ["Richard L", 10], ["Carsten K", 10], ["Tatiana H", 10], ["Ursula S", 10], ["Susanne S", 10], ["Falk T", 10],
  1489. ["Belinda M", 8], ["Wolfgang R", 8],
  1490. ["Miguel B", 7],
  1491. ["Antje S", 5], ["Hans-Jörg S", 5], ["Deanna P", 5], ["ForexTraction", 5], ["Rene F", 5], ["Rüdiger D", 5], ["Hans Hermann S", 5],
  1492. ["Siegbert M", 5], ["Wilhelm B", 5], ["Peter P", 5], ["Helga W", 5], ["Lydia R", 5],
  1493. ["Michael S", 3],
  1494. ["Mario P", 2], ["Artur G", 2], ["Heiko K", 2], ["Alexander B", 2], ["Dick N", 2],
  1495. ["Marcel G", 1], ["Ramona L", 1], ["Dennis S", 1], ["Konstandinos K", 1], ["Sarl T", 1], ["Jagadics I", 1], ["Andreas R", 1],
  1496. ["Peter F", 1], ["Vinicio G", 1], ["Marielle M", 1], ["Christian B", 1], ["Bernd W", 1], ["Maria N", 1], ["Thomas W", 1],
  1497. ["Domenik F", 1], ["Oliver H", 1], ["Jens R", 1], ["Nicole S", 1], ["Hartmut S", 1], ["Alex L", 1], ["Andreas S", 1]
  1498. ];
  1499. var donation_table = "";
  1500.  
  1501. for(var d = 0; d < donations.length; d++){
  1502.  
  1503. var donation_class = "";
  1504.  
  1505. switch(donations[d][1]){
  1506. case 50: donation_class = "gold"; break;
  1507. case 25: donation_class = "silver"; break;
  1508. case 20: donation_class = "bronze"; break;
  1509. default: donation_class = "green"; break;
  1510. }
  1511.  
  1512. donation_table += '<tr class="donation"><td class="laurel '+ donation_class +'"></td><td>' + donations[d][0] + '</td><td class="value">' + donations[d][1] + '€</td></tr>';
  1513. }
  1514.  
  1515. return donation_table;
  1516. })() +
  1517. '</table>'+
  1518. '<table>'+
  1519. '<tr><th colspan="3">Translations</th></tr>'+
  1520. (function(){
  1521. var translations = [
  1522. ["eclat49", "FR"],
  1523. ["MrBobr", "RU"],
  1524. ["anpu", "PL"],
  1525. ["Juana de Castilla", "ES"],
  1526. ["HELL", "BR"]
  1527. ];
  1528.  
  1529. var translation_table = "";
  1530.  
  1531. for(var d = 0; d < translations.length; d++){
  1532. translation_table += '<tr class="translation"><td class="laurel blue"></td><td >' + translations[d][0] + '</td><td class="value">' + translations[d][1] + '</td></tr>';
  1533. }
  1534.  
  1535. return translation_table;
  1536. })() +
  1537. '</table>'+
  1538. '</div>' +
  1539.  
  1540. '</DIV>' +
  1541.  
  1542. // Links (Forum, PM, ...)
  1543. '<div style="bottom: -50px;font-weight: bold;position: absolute;width: 99%;">' +
  1544.  
  1545. '<a id="hall_of_diotools" href="#" style="font-weight:bold; float:left">' +
  1546. '<img src="/images/game/ally/founder.png" alt="" style="float:left;height:19px;margin:0px 5px -3px;"><span>Hall of DIO-Tools</span></a>' +
  1547.  
  1548. '<span class="bbcodes_player bold" style="font-weight:bold; float:right; margin-left:20px;">' + getText("settings", "author") + ': ' +
  1549. '<a id="link_contact" href=' + getText("settings", "link_contact") + ' target="_blank">Diony</a></span>' +
  1550.  
  1551. '<a id="link_forum" href=' + getText("settings", "link_forum") + ' target="_blank" style="font-weight:bold; float:right">' +
  1552. '<img src="http://forum.de.grepolis.com/grepolis/statusicon/forum_new-16.png" alt="" style="margin: 0px 5px -3px 5px;" /><span>' + getText("settings", "forum") + '</span></a>' +
  1553.  
  1554. '</div>' +
  1555.  
  1556. '</div></div>');
  1557.  
  1558. getLatestVersion();
  1559.  
  1560. // Tab event handler
  1561. $('#dio_settings .dio_settings_tabs .submenu_link').click(function () {
  1562. if (!$(this).hasClass("active")) {
  1563. $('#dio_settings .dio_settings_tabs .submenu_link.active').removeClass("active");
  1564. $(this).addClass("active");
  1565. $("#dio_settings .visible").removeClass("visible");
  1566. $("#" + this.id + "_table").addClass("visible");
  1567. }
  1568. });
  1569.  
  1570. //
  1571. $('#hall_of_diotools').click(function () {
  1572. $('#dio_settings .dio_settings_tabs .submenu_link.active').removeClass("active");
  1573.  
  1574. $("#dio_settings .visible").removeClass("visible");
  1575. $("#dio_hall").addClass("visible");
  1576. });
  1577.  
  1578. $("#dio_settings .checkbox_new").click(function () {
  1579. $(this).toggleClass("checked").toggleClass("disabled").toggleClass("green");
  1580. toggleActivation(this.id);
  1581.  
  1582. DATA.options[this.id] = $(this).hasClass("checked");
  1583.  
  1584. saveValue("options", JSON.stringify(DATA.options));
  1585. });
  1586. for (var e in DATA.options) {
  1587. if (DATA.options.hasOwnProperty(e)) {
  1588. if (DATA.options[e] === true) {
  1589. $("#" + e).addClass("checked").addClass("green");
  1590. } else {
  1591. $("#" + e).addClass("disabled");
  1592. }
  1593. }
  1594. }
  1595.  
  1596. $('#dio_save').click(function () {
  1597. $('#dio_settings .checkbox_new').each(function () {
  1598. var act = false;
  1599. if ($("#" + this.id).hasClass("checked")) {
  1600. act = true;
  1601. }
  1602. DATA.options[this.id] = act;
  1603. });
  1604. saveValue("options", JSON.stringify(DATA.options));
  1605. });
  1606. }
  1607. $('.section').each(function () {
  1608. this.style.display = "none";
  1609. });
  1610. $('#dio_settings').get(0).style.display = "block";
  1611. });
  1612. }
  1613.  
  1614. function toggleActivation(opt) {
  1615. var FEATURE, activation = true;
  1616. switch (opt) {
  1617. case "sml":
  1618. FEATURE = SmileyBox;
  1619. break;
  1620. case "bir":
  1621. FEATURE = BiremeCounter;
  1622. break;
  1623. case "str":
  1624. FEATURE = UnitStrength.Menu;
  1625. break;
  1626. case "tra":
  1627. FEATURE = TransportCapacity;
  1628. break;
  1629. case "ava":
  1630. FEATURE = AvailableUnits;
  1631. break;
  1632. case "sim":
  1633. FEATURE = Simulator;
  1634. break;
  1635. case "spl":
  1636. FEATURE = Spellbox;
  1637. break;
  1638. case "tsk":
  1639. FEATURE = Taskbar;
  1640. break;
  1641. case "scr":
  1642. FEATURE = MouseWheelZoom;
  1643. break;
  1644. case "irc":
  1645. FEATURE = Chat;
  1646. break;
  1647. case "com":
  1648. FEATURE = UnitComparison;
  1649. break;
  1650. case "pop":
  1651. FEATURE = FavorPopup;
  1652. break;
  1653. case "con":
  1654. FEATURE = ContextMenu;
  1655. break;
  1656. case "tic":
  1657. FEATURE = TownIcons;
  1658. break;
  1659. case "tim":
  1660. FEATURE = TownIcons.Map;
  1661. break;
  1662. case "til":
  1663. FEATURE = TownList;
  1664. break;
  1665. case "sen":
  1666. FEATURE = SentUnits;
  1667. break;
  1668. case "act":
  1669. FEATURE = ActivityBoxes;
  1670. break;
  1671. case "wwc":
  1672. FEATURE = WorldWonderCalculator;
  1673. break;
  1674. case "wwr":
  1675. FEATURE = WorldWonderRanking;
  1676. break;
  1677. case "wwi":
  1678. FEATURE = WorldWonderIcons;
  1679. break;
  1680. case "pom":
  1681. FEATURE = PoliticalMap;
  1682. break;
  1683.  
  1684. default:
  1685. activation = false;
  1686. break;
  1687. }
  1688. if (activation) {
  1689. if (DATA.options[opt]) {
  1690. FEATURE.deactivate();
  1691. } else {
  1692. FEATURE.activate();
  1693. }
  1694. }
  1695. }
  1696.  
  1697. function addSettingsButton() {
  1698. var tooltip_str = "DIO-Tools: " + (DM.getl10n("layout", "config_buttons").settings || "Settings");
  1699.  
  1700. $('<div class="btn_settings circle_button dio_settings"><div class="dio_icon js-caption"></div></div>').appendTo(".gods_area");
  1701.  
  1702. // Style
  1703. $('<style id="dio_settings_button" type="text/css">' +
  1704. '#ui_box .btn_settings.dio_settings { top:95px; right:103px; z-index:10; } ' +
  1705. '#ui_box .dio_settings .dio_icon { margin:7px 0px 0px 4px; width:24px; height:24px; background:url(http://666kb.com/i/cifvfsu3e2sdiipn0.gif) no-repeat 0px 0px; background-size:100% } ' +
  1706. '#ui_box .dio_settings .dio_icon.click { margin-top:8px; }' +
  1707. '</style>').appendTo('head');
  1708.  
  1709. // Tooltip
  1710. $('.dio_settings').tooltip(tooltip_str);
  1711.  
  1712. // Mouse Events
  1713. $('.dio_settings').on('mousedown', function () {
  1714. $('.dio_icon').addClass('click');
  1715. });
  1716. $('.dio_settings').on('mouseup', function () {
  1717. $('.dio_icon').removeClass('click');
  1718. });
  1719. $('.dio_settings').click(openSettings);
  1720. }
  1721.  
  1722. var diosettings = false;
  1723.  
  1724. function openSettings() {
  1725. if (!GPWindowMgr.getOpenFirst(Layout.wnd.TYPE_PLAYER_SETTINGS)) {
  1726. diosettings = true;
  1727. }
  1728. Layout.wnd.Create(GPWindowMgr.TYPE_PLAYER_SETTINGS, 'Settings');
  1729. }
  1730.  
  1731. var exc = false, sum = 0, ch = ["FBADAF", "IGCCJB"], alpha = 'ABCDEFGHIJ';
  1732.  
  1733. function a() {
  1734. var pA = PID.toString(), pB = "";
  1735.  
  1736. for (var c in pA) {
  1737. if (pA.hasOwnProperty(c)) {
  1738. pB += alpha[pA[parseInt(c, 10)]];
  1739. }
  1740. }
  1741.  
  1742. sum = 0;
  1743. for (var b in ch) {
  1744. if (ch.hasOwnProperty(b)) {
  1745. if (pB !== ch[b]) {
  1746. exc = true;
  1747. } else {
  1748. exc = false;
  1749. return;
  1750. }
  1751. for (var s in ch[b]) {
  1752. if (ch[b].hasOwnProperty(s)) {
  1753. sum += alpha.indexOf(ch[b][s]);
  1754. }
  1755. }
  1756. }
  1757. }
  1758. }
  1759.  
  1760. var autoTownTypes, manuTownTypes, population, sentUnitsArray, biriArray, spellbox, commandbox, tradebox, wonder, wonderTypes;
  1761.  
  1762. function setStyle() {
  1763. // Settings
  1764. $('<style id="dio_settings_style" type="text/css">' +
  1765. '#dio_bg_medusa { background:url(' + dio_sprite + ') -160px -43px no-repeat; height: 510px; width: 260px; right: -10px; z-index: -1; position: absolute;} ' +
  1766. '.dio_overflow { overflow: hidden; } ' +
  1767. '#dio_icon { width:15px; vertical-align:middle; margin-top:-2px; } ' +
  1768. '#quackicon { width:15px !important; vertical-align:middle !important; margin-top:-2px; height:12px !important; } ' +
  1769. '#dio_settings .green { color: green; } ' +
  1770. '#dio_settings .visible { display:block !important; } ' +
  1771. '</style>').appendTo('head');
  1772.  
  1773. // Town Icons
  1774. $('<style id="dio_icons" type="text/css">.icon_small { position:relative; height:20px; width:25px; margin-left:-25px; }</style>').appendTo('head');
  1775.  
  1776. // Tutorial-Quest Container
  1777. $('<style id="dio_quest_container" type="text/css"> #tutorial_quest_container { top: 130px } </style>').appendTo('head');
  1778.  
  1779. // Velerios
  1780. $('<style id="dio_velerios" type="text/css"> #ph_trader_image { background-image: url(http://s14.directupload.net/images/140826/mh8k8nyw.jpg); } </style>').appendTo('head');
  1781. // http://s7.directupload.net/images/140826/bgqlsdrf.jpg
  1782.  
  1783. // Specific player wishes
  1784. if (PID == 1212083) {
  1785. $('<style id="dio_wishes" type="text/css"> #world_end_info { display: none; } </style>').appendTo('head');
  1786. }
  1787. }
  1788.  
  1789. if (uw.location.pathname === "/game/index") {
  1790. setStyle();
  1791. }
  1792.  
  1793. function loadFeatures() {
  1794. if (typeof(ITowns) !== "undefined") {
  1795.  
  1796. autoTownTypes = {};
  1797. manuTownTypes = DATA.townTypes;
  1798. population = {};
  1799.  
  1800. sentUnitsArray = DATA.sentUnits;
  1801. biriArray = DATA.biremes;
  1802.  
  1803. spellbox = DATA.spellbox;
  1804. commandbox = DATA.commandbox;
  1805. tradebox = DATA.tradebox;
  1806.  
  1807. wonder = DATA.worldWonder;
  1808. wonderTypes = DATA.worldWonderTypes;
  1809.  
  1810. var DIO_USER = {'name': uw.Game.player_name, 'market': MID};
  1811. saveValue("dio_user", JSON.stringify(DIO_USER));
  1812.  
  1813.  
  1814. $.Observer(uw.GameEvents.game.load).subscribe('DIO_START', function (e, data) {
  1815. a();
  1816.  
  1817. // English => default language
  1818. if (!LANG[LID]) {
  1819. LID = "en";
  1820. }
  1821.  
  1822. if ((ch.length == 2) && exc && (sum == 42)) {
  1823. // AJAX-EVENTS
  1824. setTimeout(function () {
  1825. ajaxObserver();
  1826. }, 0);
  1827.  
  1828. addSettingsButton();
  1829.  
  1830. addFunctionToITowns();
  1831.  
  1832. if (DATA.options.tsk) {
  1833. setTimeout(function () {
  1834. minimizeDailyReward();
  1835. Taskbar.activate();
  1836. }, 0);
  1837. }
  1838.  
  1839. //addStatsButton();
  1840.  
  1841. fixUnitValues();
  1842.  
  1843. setTimeout(function () {
  1844.  
  1845. var waitCount = 0;
  1846.  
  1847. // No comment... it's Grepolis... i don't know... *rolleyes*
  1848. function waitForGrepoLazyLoading() {
  1849. if (typeof(ITowns.townGroups.getGroupsDIO()[-1]) !== "undefined" && typeof(ITowns.getTown(Game.townId).getBuildings) !== "undefined") {
  1850.  
  1851. try {
  1852. // Funktion wird manchmal nicht ausgeführt:
  1853. var units = ITowns.getTown(Game.townId).units();
  1854.  
  1855.  
  1856. getAllUnits();
  1857.  
  1858. setInterval(function () {
  1859. getAllUnits();
  1860. }, 900000); // 15min
  1861.  
  1862. if (DATA.options.ava) {
  1863. setTimeout(function () {
  1864. AvailableUnits.activate();
  1865. }, 0);
  1866. }
  1867. if (DATA.options.tic) {
  1868. setTimeout(function () {
  1869. TownIcons.activate();
  1870. }, 0);
  1871. }
  1872. if (DATA.options.tim) {
  1873. setTimeout(function () {
  1874. TownIcons.Map.activate();
  1875. }, 0);
  1876. }
  1877. if (DATA.options.til) {
  1878. setTimeout(function () {
  1879. TownList.activate();
  1880. }, 0);
  1881. }
  1882. } catch(e){
  1883. if(waitCount < 12) {
  1884. waitCount++;
  1885.  
  1886. console.warn("DIO-Tools | Fehler | getAllUnits | units() fehlerhaft ausgeführt?", e);
  1887.  
  1888. // Ausführung wiederholen
  1889. setTimeout(function () {
  1890. waitForGrepoLazyLoading();
  1891. }, 5000); // 5s
  1892. }
  1893. else {
  1894. errorHandling(e, "waitForGrepoLazyLoading2");
  1895. }
  1896. }
  1897. }
  1898. else {
  1899. var e = { "stack": "getGroups() = " + typeof(ITowns.townGroups.getGroupsDIO()[-1]) + ", getBuildings() = " + typeof(ITowns.getTown(Game.townId).getBuildings) };
  1900.  
  1901. if(waitCount < 12) {
  1902. waitCount++;
  1903.  
  1904. console.warn("DIO-Tools | Fehler | getAllUnits | " + e.stack);
  1905.  
  1906. // Ausführung wiederholen
  1907. setTimeout(function () {
  1908. waitForGrepoLazyLoading();
  1909. }, 5000); // 5s
  1910. }
  1911. else {
  1912.  
  1913.  
  1914. errorHandling(e, "waitForGrepoLazyLoading2");
  1915. }
  1916. }
  1917. }
  1918.  
  1919. waitForGrepoLazyLoading();
  1920.  
  1921. }, 0);
  1922.  
  1923. if (DATA.options.pop) {
  1924. setTimeout(function () {
  1925. FavorPopup.activate();
  1926. }, 0);
  1927. }
  1928. if (DATA.options.spl) {
  1929. setTimeout(function () {
  1930. Spellbox.activate();
  1931. }, 0);
  1932. }
  1933.  
  1934. imageSelectionProtection();
  1935.  
  1936. if (DATA.options.con) {
  1937. setTimeout(function () {
  1938. ContextMenu.activate();
  1939. }, 0);
  1940. }
  1941.  
  1942. if (DATA.options.act) {
  1943. setTimeout(function () {
  1944. ActivityBoxes.activate();
  1945. }, 0);
  1946. }
  1947.  
  1948. if (DATA.options.str) {
  1949. setTimeout(function () {
  1950. UnitStrength.Menu.activate();
  1951. hideNavElements();
  1952. }, 0);
  1953. }
  1954.  
  1955. if (DATA.options.tra) {
  1956. setTimeout(function () {
  1957. TransportCapacity.activate();
  1958. }, 0);
  1959. }
  1960.  
  1961. if (DATA.options.com) {
  1962. setTimeout(function () {
  1963. UnitComparison.activate();
  1964. }, 0);
  1965. }
  1966.  
  1967. if (DATA.options.sml) {
  1968. setTimeout(function () {
  1969. SmileyBox.activate();
  1970. }, 0);
  1971. }
  1972.  
  1973. if (DATA.options.irc) {
  1974. setTimeout(function () {
  1975. Chat.activate();
  1976. }, 0);
  1977. }
  1978.  
  1979. if (DATA.options.scr) {
  1980. setTimeout(function () {
  1981. MouseWheelZoom.activate();
  1982. }, 0);
  1983. }
  1984.  
  1985. if (DATA.options.sim) {
  1986. setTimeout(function () {
  1987. Simulator.activate();
  1988. }, 0);
  1989. }
  1990.  
  1991. if (DATA.options.sen) {
  1992. setTimeout(function () {
  1993. SentUnits.activate();
  1994. }, 0);
  1995. }
  1996.  
  1997. if (DATA.options.wwc) {
  1998. setTimeout(function () {
  1999. WorldWonderCalculator.activate();
  2000. }, 0);
  2001. }
  2002.  
  2003. if (PID === 84367 || PID === 104769 || PID === 1291505) {
  2004. setTimeout(function() {
  2005. PoliticalMap.activate();
  2006.  
  2007. //PoliticalMap.getAllianceColors();
  2008.  
  2009. //Statistics.activate();
  2010. }, 0);
  2011. }
  2012.  
  2013. setTimeout(function () {
  2014. counter(uw.Timestamp.server());
  2015. setInterval(function () {
  2016. counter(uw.Timestamp.server());
  2017. }, 21600000);
  2018. }, 60000);
  2019.  
  2020. // Notifications
  2021. setTimeout(function () {
  2022. Notification.init();
  2023. }, 0);
  2024.  
  2025. // setTimeout(function(){ HolidaySpecial.activate(); }, 0);
  2026.  
  2027.  
  2028. // Execute once to get the world wonder types and coordinates
  2029. setTimeout(function () {
  2030. if (!wonderTypes.great_pyramid_of_giza) {
  2031. getWorldWonderTypes();
  2032. }
  2033. if (wonderTypes.great_pyramid_of_giza) {
  2034. setTimeout(function () {
  2035. if (!wonder.map.mausoleum_of_halicarnassus) {
  2036. getWorldWonders();
  2037. } else {
  2038. if (DATA.options.wwi) {
  2039. WorldWonderIcons.activate();
  2040. }
  2041. }
  2042. }, 2000);
  2043. }
  2044. }, 3000);
  2045.  
  2046. // Execute once to get alliance ratio
  2047. if (wonder.ratio[AID] == -1 || !$.isNumeric(wonder.ratio[AID])) {
  2048. setTimeout(function () {
  2049. getPointRatioFromAllianceProfile();
  2050. }, 5000);
  2051. }
  2052. }
  2053. time_b = uw.Timestamp.client();
  2054. //console.log("Gebrauchte Zeit:" + (time_b - time_a));
  2055. });
  2056. } else {
  2057. setTimeout(function () {
  2058. loadFeatures();
  2059. }, 100);
  2060. }
  2061. }
  2062.  
  2063. if (uw.location.pathname === "/game/index") {
  2064. loadFeatures();
  2065. }
  2066.  
  2067. /*******************************************************************************************************************************
  2068. * HTTP-Requests
  2069. * *****************************************************************************************************************************/
  2070. function ajaxObserver() {
  2071. $(document).ajaxComplete(function (e, xhr, opt) {
  2072. var url = opt.url.split("?"),
  2073. action = url[0].substr(5) + "/" + url[1].split(/&/)[1].substr(7);
  2074. if (PID == 84367 || PID == 104769) {
  2075. console.log(action);
  2076. //console.log((JSON.parse(xhr.responseText).json));
  2077. }
  2078. switch (action) {
  2079. case "/frontend_bridge/fetch": // Daily Reward
  2080. //$('.daily_login').find(".minimize").click();
  2081. break;
  2082. case "/player/index":
  2083. settings();
  2084. if (diosettings) {
  2085. $('#dio_tools').click();
  2086. diosettings = false;
  2087. }
  2088. break;
  2089. case "/index/switch_town":
  2090. if (DATA.options.str) {
  2091. UnitStrength.Menu.update();
  2092. }
  2093. if (DATA.options.str) {
  2094. TransportCapacity.update();
  2095. }
  2096. if (DATA.options.bir) {
  2097. BiremeCounter.get();
  2098. }
  2099. if (DATA.options.tic) {
  2100. TownIcons.changeTownIcon();
  2101. }
  2102. break;
  2103. case "/building_docks/index":
  2104. if (DATA.options.bir) {
  2105. BiremeCounter.getDocks();
  2106. }
  2107. break;
  2108. case "/building_place/units_beyond":
  2109. if (DATA.options.bir) {
  2110. BiremeCounter.getAgora();
  2111. }
  2112. //addTransporterBackButtons();
  2113. break;
  2114. case "/building_place/simulator":
  2115. if (DATA.options.sim) {
  2116. Simulator.change();
  2117. }
  2118. break;
  2119. case "/building_place/simulate":
  2120. if (DATA.options.sim) {
  2121. afterSimulation();
  2122. }
  2123. break;
  2124.  
  2125. case "/alliance_forum/forum":
  2126. case "/message/new":
  2127. case "/message/forward":
  2128. case "/message/view":
  2129. case "/player_memo/load_memo_content":
  2130. if (DATA.options.sml) {
  2131. SmileyBox.add(action);
  2132. }
  2133. if (DATA.options.bbc) {
  2134. addForm(action);
  2135. }
  2136. break;
  2137. case "/wonders/index":
  2138. if (DATA.options.per) {
  2139. WWTradeHandler();
  2140. }
  2141. if (DATA.options.wwc) {
  2142. getResWW();
  2143. }
  2144. break;
  2145. case "/wonders/send_resources":
  2146. if (DATA.options.wwc) {
  2147. getResWW();
  2148. }
  2149. break;
  2150. case "/ranking/alliance":
  2151. getPointRatioFromAllianceRanking();
  2152. break;
  2153. case "/ranking/wonder_alliance":
  2154. getPointRatioFromAllianceRanking();
  2155. if (DATA.options.wwr) {
  2156. WorldWonderRanking.change(JSON.parse(xhr.responseText).plain.html);
  2157. }
  2158. if (DATA.options.wwi) {
  2159. WorldWonderIcons.activate();
  2160. }
  2161. break;
  2162. case "/alliance/members_show":
  2163. getPointRatioFromAllianceMembers();
  2164. break;
  2165. case "/town_info/trading":
  2166. addTradeMarks(15, 18, 15, "red");
  2167. TownTabHandler(action.split("/")[2]);
  2168. break;
  2169. case "/town_overviews/trade_overview":
  2170. addPercentTrade(1234, false); // TODO
  2171. case "/farm_town_overviews/get_farm_towns_for_town":
  2172. changeResColor();
  2173. break;
  2174. case "/command_info/conquest_info":
  2175. if (DATA.options.str) {
  2176. UnitStrength.Conquest.add();
  2177. }
  2178. break;
  2179. case "/command_info/conquest_movements":
  2180. case "/conquest_info/getinfo":
  2181. if (DATA.options.cnt) {
  2182. countMovements();
  2183. }
  2184. break;
  2185. case "/building_barracks/index":
  2186. case "/building_barracks/build":
  2187. if (DATA.options.str) {
  2188. UnitStrength.Barracks.add();
  2189. }
  2190. break;
  2191. case "/town_info/attack":
  2192. case "/town_info/support":
  2193. console.debug(JSON.parse(xhr.responseText));
  2194. TownTabHandler(action.split("/")[2]);
  2195.  
  2196. break;
  2197. case "/report/index":
  2198. changeDropDownButton();
  2199. loadFilter();
  2200. saveFilter();
  2201. //removeReports();
  2202. break;
  2203. case "/report/view":
  2204. Statistics.LuckCounter.count();
  2205. break;
  2206. case "/message/default":
  2207. case "/message/index":
  2208. break;
  2209. case "/chat/init":
  2210. if (DATA.options.irc) {
  2211. Chat.open();
  2212. }
  2213. break;
  2214. case "/town_info/go_to_town":
  2215. /*
  2216. //console.log(uw.Layout.wnd);
  2217. var windo = uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).getID();
  2218. //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX));
  2219. uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).setPosition([100,400]);
  2220. //console.log(windo);
  2221. //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).getPosition());
  2222. */
  2223. break;
  2224. }
  2225. });
  2226. }
  2227.  
  2228. function test() {
  2229. //http://gpde.innogamescdn.com/images/game/temp/island.png
  2230.  
  2231. //console.log(uw.WMap);
  2232. //console.log(uw.WMap.getSea(uw.WMap.getXCoord(), uw.WMap.getYCoord()));
  2233.  
  2234. //console.log(uw.GameControllers.LayoutToolbarActivitiesController().prototype.getActivityTypes());
  2235. //console.log(uw.GameViews);
  2236. //console.log(uw.GameViews.BarracksUnitDetails());
  2237.  
  2238. //console.log(uw.ITowns.getTown(uw.Game.townId).unitsOuter().sword);
  2239. //console.log(uw.ITowns.getCurrentTown().unitsOuter().sword);
  2240.  
  2241. //console.log(uw.ITowns.getTown(uw.Game.townId).researches().attributes);
  2242. //console.log(uw.ITowns.getTown(uw.Game.townId).hasConqueror());
  2243. //console.log(uw.ITowns.getTown(uw.Game.townId).allUnits());
  2244. //console.log(uw.ITowns.all_units.fragments[uw.Game.townId]._byId);
  2245. //console.log("Zeus: " + uw.ITowns.player_gods.zeus_favor_delta_property.lastTriggeredVirtualPropertyValue);
  2246. //console.log(uw.ITowns.player_gods.attributes);
  2247.  
  2248. //console.log(uw.ITowns.getTown('5813').createTownLink());
  2249. //console.log(uw.ITowns.getTown(5813).unitsOuterTown);
  2250.  
  2251. //console.log(uw.ITowns.getTown(uw.Game.townId).getLinkFragment());
  2252.  
  2253. //console.log(uw.ITowns.getTown(uw.Game.townId).allGodsFavors());
  2254. }
  2255.  
  2256. /*******************************************************************************************************************************
  2257. * Helping functions
  2258. * ----------------------------------------------------------------------------------------------------------------------------
  2259. * | ● fixUnitValues: Get unit values and overwrite some wrong values
  2260. * | ● getMaxZIndex: Get the highest z-index of "ui-dialog"-class elements
  2261. * ----------------------------------------------------------------------------------------------------------------------------
  2262. *******************************************************************************************************************************/
  2263.  
  2264. // Fix buggy grepolis values
  2265. function fixUnitValues() {
  2266. //uw.GameData.units.small_transporter.attack = uw.GameData.units.big_transporter.attack = uw.GameData.units.demolition_ship.attack = uw.GameData.units.militia.attack = 0;
  2267. //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;
  2268. uw.GameData.units.militia.resources = {wood: 0, stone: 0, iron: 0};
  2269. }
  2270.  
  2271. function getMaxZIndex() {
  2272. var maxZ = Math.max.apply(null, $.map($("div[class^='ui-dialog']"), function (e, n) {
  2273. if ($(e).css('position') == 'absolute') {
  2274. return parseInt($(e).css('z-index'), 10) || 1000;
  2275. }
  2276. }));
  2277. return (maxZ !== -Infinity) ? maxZ + 1 : 1000;
  2278. }
  2279.  
  2280. function getBrowser() {
  2281. var ua = navigator.userAgent,
  2282. tem,
  2283. M = ua.match(/(opera|maxthon|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
  2284. if (/trident/i.test(M[1])) {
  2285. tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
  2286. M[1] = 'IE';
  2287. M[2] = tem[1] || '';
  2288. }
  2289. if (M[1] === 'Chrome') {
  2290. tem = ua.match(/\bOPR\/(\d+)/);
  2291. if (tem !== null) {
  2292. M[1] = 'Opera';
  2293. M[2] = tem[1];
  2294. }
  2295. }
  2296. M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
  2297. if ((tem = ua.match(/version\/(\d+)/i)) !== null) M.splice(1, 1, tem[1]);
  2298.  
  2299. return M.join(' ');
  2300. }
  2301.  
  2302. // Error Handling / Remote diagnosis / Automatic bug reports
  2303. function errorHandling(e, fn) {
  2304. if (PID == 84367 || PID == 104769 || PID === 1291505) {
  2305. HumanMessage.error("DIO-TOOLS(" + version + ")-ERROR: " + e.message);
  2306. console.log("DIO-TOOLS | Error-Stack | ", e.stack);
  2307. } else {
  2308. if (!DATA.error[version]) {
  2309. DATA.error[version] = {};
  2310. }
  2311.  
  2312. if (DATA.options.err && !DATA.error[version][fn]) {
  2313. $.ajax({
  2314. type: "POST",
  2315. url: "https://diotools.de/game/error.php",
  2316. data: {error: e.stack.replace(/'/g, '"'), "function": fn, browser: getBrowser(), version: version},
  2317. success: function (text) {
  2318. DATA.error[version][fn] = true;
  2319. saveValue("error", JSON.stringify(DATA.error));
  2320. }
  2321. });
  2322. }
  2323. }
  2324. }
  2325.  
  2326. function createWindowType(name, title, width, height, minimizable, position) {
  2327. $('<style id="dio_window">' +
  2328. '.dio_title_img { height:18px; float:left; margin-right:3px; } ' +
  2329. '.dio_title { margin:1px 6px 13px 23px; color:rgb(126,223,126); } ' +
  2330. '</style>').appendTo('head');
  2331.  
  2332. // Create Window Type
  2333. function WndHandler(wndhandle) {
  2334. this.wnd = wndhandle;
  2335. }
  2336.  
  2337. Function.prototype.inherits.call(WndHandler, WndHandlerDefault);
  2338. WndHandler.prototype.getDefaultWindowOptions = function () {
  2339. return {
  2340. position: position,
  2341. width: width,
  2342. height: height,
  2343. minimizable: minimizable,
  2344. title: "<img class='dio_title_img' src='http://666kb.com/i/cifvfsu3e2sdiipn0.gif' /><div class='dio_title'>" + title + "</div>"
  2345. };
  2346. };
  2347. GPWindowMgr.addWndType(name, "", WndHandler, 1);
  2348. }
  2349.  
  2350. // Notification
  2351. var Notification = {
  2352. init: function () {
  2353. // NotificationType
  2354. NotificationType.DIO_TOOLS = "diotools";
  2355.  
  2356. // Style
  2357. $('<style id="dio_notification" type="text/css">' +
  2358. '#notification_area .diotools .icon { background: url(http://666kb.com/i/cifvfsu3e2sdiipn0.gif) 4px 7px no-repeat !important;} ' +
  2359. '#notification_area .diotools { cursor:pointer; } ' +
  2360. '</style>').appendTo('head');
  2361.  
  2362. var notif = DATA.notification;
  2363. if (notif <= 7) {
  2364. //Notification.create(1, 'Swap context menu buttons ("Select town" and "City overview")');
  2365. //Notification.create(2, 'Town overview (old window mode)');
  2366. //Notification.create(3, 'Mouse wheel: You can change the views with the mouse wheel');
  2367. //Notification.create(4, 'Town icons on the strategic map');
  2368. //Notification.create(5, 'Percentual unit population in the town list');
  2369. //Notification.create(6, 'New world wonder ranking');
  2370. //Notification.create(7, 'World wonder icons on the strategic map');
  2371.  
  2372. // Click Event
  2373. $('.diotools .icon').click(function () {
  2374. openSettings();
  2375. $(this).parent().find(".close").click();
  2376. });
  2377.  
  2378. saveValue('notif', '8');
  2379. }
  2380. },
  2381. create: function (nid, feature) {
  2382. var Notification = new NotificationHandler();
  2383. Notification.notify($('#notification_area>.notification').length + 1, uw.NotificationType.DIO_TOOLS,
  2384. "<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>");
  2385. }
  2386. };
  2387.  
  2388. /*******************************************************************************************************************************
  2389. * Mousewheel Zoom
  2390. *******************************************************************************************************************************/
  2391.  
  2392. var MouseWheelZoom = {
  2393. // Scroll trough the views
  2394. activate: function () {
  2395. $('#main_area, #dio_political_map, .viewport, .sjs-city-overview-viewport').bind('mousewheel', function (e) {
  2396. e.stopPropagation();
  2397. var current = $('.bull_eye_buttons .checked').get(0).getAttribute("name"), delta = 0, scroll, sub_scroll = 6;
  2398.  
  2399. switch (current) {
  2400. case 'political_map':
  2401. scroll = 4;
  2402. break;
  2403. case 'strategic_map':
  2404. scroll = 3;
  2405. break;
  2406. case 'island_view':
  2407. scroll = 2;
  2408. break;
  2409. case 'city_overview':
  2410. scroll = 1;
  2411. break;
  2412. }
  2413. delta = -e.originalEvent.detail || e.originalEvent.wheelDelta; // Firefox || Chrome & Opera
  2414.  
  2415. //console.debug("cursor_pos", e.pageX, e.pageY);
  2416.  
  2417. if (scroll !== 4) {
  2418. if (delta < 0) {
  2419. scroll += 1;
  2420. } else {
  2421. scroll -= 1;
  2422. }
  2423. } else {
  2424. // Zoomstufen bei der Politischen Karte
  2425. sub_scroll = $('.zoom_select').get(0).selectedIndex;
  2426.  
  2427. if (delta < 0) {
  2428. sub_scroll -= 1;
  2429. } else {
  2430. sub_scroll += 1;
  2431. }
  2432. if (sub_scroll === -1) {
  2433. sub_scroll = 0;
  2434. }
  2435. if (sub_scroll === 7) {
  2436. scroll = 3;
  2437. }
  2438. }
  2439. switch (scroll) {
  2440. case 4:
  2441. if (!$('.bull_eye_buttons .btn_political_map').hasClass("checked")) {
  2442. $('.bull_eye_buttons .btn_political_map').click();
  2443. }
  2444.  
  2445. // onChange wird aufgerufen, wenn sich die Selektierung ändert
  2446. //$('.zoom_select option').eq(sub_scroll).prop('selected', true);
  2447. $('.zoom_select').get(0)[sub_scroll].selected = true;
  2448. //$('.zoom_select').get(0).change();
  2449. //$('.zoom_select').get(0).val(sub_scroll);
  2450.  
  2451.  
  2452. PoliticalMap.zoomToCenter();
  2453. //PoliticalMap.zoomToCenterToCursorPosition($('.zoom_select').get(0)[sub_scroll].value, [e.pageX, e.pageY]);
  2454.  
  2455. break;
  2456. case 3:
  2457. $('.bull_eye_buttons .strategic_map').click();
  2458. $('#popup_div').css('display', 'none');
  2459. break;
  2460. case 2:
  2461. $('.bull_eye_buttons .island_view').click();
  2462. break;
  2463. case 1:
  2464. $('.bull_eye_buttons .city_overview').click();
  2465. break;
  2466. }
  2467.  
  2468. // Prevent page from scrolling
  2469. return false;
  2470. });
  2471. },
  2472. deactivate: function () {
  2473. $('#main_area, .ui_city_overview').unbind('mousewheel');
  2474. }
  2475. };
  2476.  
  2477.  
  2478. /*******************************************************************************************************************************
  2479. * Statistics
  2480. * ----------------------------------------------------------------------------------------------------------------------------
  2481. * | ● Expansion of towns?
  2482. * | ● Occupancy of the farms?
  2483. * | ● Mouseclick-Counter?
  2484. * | ● Resource distribution (%)?
  2485. * | ● Building level counter ?
  2486. * ----------------------------------------------------------------------------------------------------------------------------
  2487. *******************************************************************************************************************************/
  2488. //$('<script src="https://github.com/mbostock/d3/blob/master/d3.js"></script>').appendTo("head");
  2489. // http://mbostock.github.com/d3/d3.v2.js
  2490. var Statistics = {
  2491. activate: function () {
  2492. Statistics.addButton();
  2493.  
  2494. $('<style id="dio_statistic">' +
  2495. 'path { stroke: steelblue; stroke-width: 1; fill: none; } ' +
  2496. '.axis { shape-rendering: crispEdges; } ' +
  2497. '.x.axis line { stroke: lightgrey; } ' +
  2498. '.x.axis .minor { stroke-opacity: .5; } ' +
  2499. '.x.axis path { display: none; } ' +
  2500. '.y.axis line, .y.axis path { fill: none; stroke: #000; } ' +
  2501. '</style>').appendTo('head');
  2502.  
  2503. Statistics.ClickCounter.activate();
  2504.  
  2505. // Create Window Type
  2506. createWindowType("DIO_STATISTICS", "Statistics", 300, 250, true, ["center", "center", 100, 100]);
  2507. },
  2508. deactivate: function () {
  2509. $('#dio_statistic_button').remove();
  2510. $('#dio_statistic').remove();
  2511. Statistics.ClickCounter.deactivate();
  2512. },
  2513. addButton: function () {
  2514. $('<div id="dio_statistic_button" class="circle_button"><div class="ico_statistics js-caption"></div></div>').appendTo(".gods_area");
  2515.  
  2516. // Style
  2517. $('<style id="dio_statistic_style">' +
  2518. '#dio_statistic_button { top:56px; left:-4px; z-index:10; position:absolute; } ' +
  2519.  
  2520. '#dio_statistic_button .ico_statistics { margin:7px 0px 0px 8px; width:17px; height:17px; background:url(http://s1.directupload.net/images/140408/pltgqlaw.png) no-repeat 0px 0px; background-size:100%; } ' +
  2521. // http://s14.directupload.net/images/140408/k4wikrlq.png // http://s7.directupload.net/images/140408/ahfr8227.png
  2522. '#dio_statistic_button .ico_statistics.checked { margin-top:8px; } ' +
  2523. '</style>').appendTo('head');
  2524.  
  2525. // Tooltip
  2526. $('#dio_statistic_button').tooltip(getText("labels", "uni")); // TODO
  2527.  
  2528. // Events
  2529. $('#dio_statistic_button').on('mousedown', function () {
  2530. $('#dio_statistic_button, .ico_statistics').addClass("checked");
  2531. }).on('mouseup', function () {
  2532. $('#dio_statistic_button, .ico_statistics').removeClass("checked");
  2533. });
  2534.  
  2535. $('#dio_statistic_button').click(function () {
  2536. if (!Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_STATISTICS)) {
  2537. Statistics.openWindow();
  2538. $('#dio_statistic_button, .ico_statistics').addClass("checked");
  2539. } else {
  2540. Statistics.closeWindow();
  2541. $('#dio_statistic_button, .ico_statistics').removeClass("checked");
  2542. }
  2543. });
  2544. },
  2545. openWindow: function () {
  2546. var content =
  2547. '<div id="dio_mouseclicks" style="margin-bottom:5px; font-style:italic;">' +
  2548. '<span style="text-decoration:underline;">Insgesamt:</span> <span></span>' +
  2549. '<span style="float:right;"></span><span style="text-decoration:underline;float:right;">Heute:</span> ' +
  2550. '</div><canvas id="dio_graph" width="290" height="150" style="margin-top:15px;"></canvas>';
  2551.  
  2552. Layout.wnd.Create(GPWindowMgr.TYPE_DIO_STATISTICS).setContent(content);
  2553.  
  2554. Statistics.ClickCounter.onOpenWindow();
  2555.  
  2556. // Draw diagram
  2557. var graph, xPadding = 35, yPadding = 25;
  2558.  
  2559. var data = {values: [{X: "Jan", Y: 0}]};
  2560.  
  2561. console.log(DATA.clickCount);
  2562. for (var o in DATA.clickCount) {
  2563. data.values.push({X: "opp", Y: DATA.clickCount[o]});
  2564. }
  2565.  
  2566. function getMaxY() {
  2567. var max = 0;
  2568. for (var i = 0; i < data.values.length; i++) {
  2569. if (data.values[i].Y > max) {
  2570. max = data.values[i].Y;
  2571. }
  2572. }
  2573. max += 10 - max % 10;
  2574. return max + 10;
  2575. }
  2576.  
  2577. function getXPixel(val) {
  2578. return ((graph.width() - xPadding) / data.values.length) * val + (xPadding + 10);
  2579. }
  2580.  
  2581. function getYPixel(val) {
  2582. return graph.height() - (((graph.height() - yPadding) / getMaxY()) * val) - yPadding;
  2583. }
  2584.  
  2585. graph = $('#dio_graph');
  2586. var c = graph[0].getContext('2d');
  2587.  
  2588. c.lineWidth = 2;
  2589. c.strokeStyle = '#333';
  2590. c.font = 'italic 8pt sans-serif';
  2591. c.textAlign = "center";
  2592.  
  2593. // Axis
  2594. c.beginPath();
  2595. c.moveTo(xPadding, 0);
  2596. c.lineTo(xPadding, graph.height() - yPadding);
  2597. c.lineTo(graph.width(), graph.height() - yPadding);
  2598. c.stroke();
  2599.  
  2600. // X-Axis caption
  2601. for (var x = 0; x < data.values.length; x++) {
  2602. c.fillText(data.values[x].X, getXPixel(x), graph.height() - yPadding + 20);
  2603. }
  2604.  
  2605. // Y-Axis caption
  2606. c.textAlign = "right";
  2607. c.textBaseline = "middle";
  2608.  
  2609. var maxY = getMaxY(), maxYscala = Math.ceil(maxY / 1000) * 1000;
  2610. console.log(maxY);
  2611. for (var y = 0; y < maxY; y += maxYscala / 10) {
  2612. c.fillText(y, xPadding - 10, getYPixel(y));
  2613. }
  2614.  
  2615. // Graph
  2616. c.strokeStyle = 'rgb(0,150,0)';
  2617. c.beginPath();
  2618. c.moveTo(getXPixel(0), getYPixel(data.values[0].Y));
  2619.  
  2620. for (var i = 1; i < data.values.length; i++) {
  2621. c.lineTo(getXPixel(i), getYPixel(data.values[i].Y));
  2622. }
  2623. c.stroke();
  2624.  
  2625. // Points
  2626. c.fillStyle = '#333';
  2627.  
  2628. for (var p = 0; p < data.values.length; p++) {
  2629. c.beginPath();
  2630. c.arc(getXPixel(p), getYPixel(data.values[p].Y), 2, 0, Math.PI * 2, true);
  2631. c.fill();
  2632. }
  2633. },
  2634. closeWindow: function () {
  2635. Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_STATISTICS).close();
  2636. },
  2637.  
  2638. ClickCounter: {
  2639. today: "00000000",
  2640. activate: function () {
  2641. Statistics.ClickCounter.updateDate();
  2642.  
  2643. $(document).on("mousedown", function () {
  2644. DATA.clickCount[Statistics.ClickCounter.today]++;
  2645. });
  2646.  
  2647. window.onbeforeunload = function () {
  2648. Statistics.ClickCounter.save();
  2649. };
  2650.  
  2651. // TODO: Update date
  2652. setTimeout(function () {
  2653. Statistics.ClickCounter.updateDate();
  2654. }, 0);
  2655. },
  2656. deactivate: function () {
  2657. $(document).off("mousedown");
  2658. },
  2659. save: function () {
  2660. saveValue(WID + "_click_count", JSON.stringify(DATA.clickCount));
  2661. },
  2662. updateDate: function () {
  2663. var today = new Date((window.Timestamp.server() + 7200) * 1000);
  2664.  
  2665. Statistics.ClickCounter.today = today.getUTCFullYear() + ((today.getUTCMonth() + 1) < 10 ? "0" : "") + (today.getUTCMonth() + 1) + (today.getUTCDate() < 10 ? "0" : "") + today.getUTCDate();
  2666.  
  2667. DATA.clickCount[Statistics.ClickCounter.today] = DATA.clickCount[Statistics.ClickCounter.today] || 0;
  2668. },
  2669. onOpenWindow: function () {
  2670. $('#dio_mouseclicks span:eq(2)').get(0).innerHTML = DATA.clickCount[Statistics.ClickCounter.today];
  2671. $(document).off("mousedown");
  2672. $(document).on("mousedown", function () {
  2673. if ($('#dio_mouseclicks').get(0)) {
  2674. $('#dio_mouseclicks span:eq(2)').get(0).innerHTML = ++DATA.clickCount[Statistics.ClickCounter.today];
  2675. } else {
  2676. DATA.clickCount[Statistics.ClickCounter.today]++;
  2677. $(document).off("mousedown");
  2678. $(document).on("mousedown", function () {
  2679. DATA.clickCount[Statistics.ClickCounter.today]++;
  2680. });
  2681. }
  2682. });
  2683. }
  2684. },
  2685. LuckCounter: {
  2686. luckArray: {},
  2687. count: function () {
  2688. if ($('.fight_bonus.luck').get(0)) {
  2689. var report_id = $('#report_report_header .game_arrow_delete').attr("onclick").split(",")[1].split(")")[0].trim(),
  2690. luck = parseInt($('.fight_bonus.luck').get(0).innerHTML.split(":")[1].split("%")[0].trim(), 10);
  2691.  
  2692. Statistics.LuckCounter.luckArray[report_id] = luck;
  2693.  
  2694. console.log(Statistics.LuckCounter.calcAverage());
  2695. }
  2696. },
  2697. calcAverage: function () {
  2698. var sum = 0, count = 0;
  2699. for (var report_id in Statistics.LuckCounter.luckArray) {
  2700. if (Statistics.LuckCounter.luckArray.hasOwnProperty(report_id)) {
  2701. sum += parseInt(Statistics.LuckCounter.luckArray[report_id], 10);
  2702. count++;
  2703. }
  2704. }
  2705. return (parseFloat(sum) / parseFloat(count));
  2706. }
  2707. }
  2708. };
  2709.  
  2710. /*******************************************************************************************************************************
  2711. * Body Handler
  2712. * ----------------------------------------------------------------------------------------------------------------------------
  2713. * | ● Town icon
  2714. * | ● Town list: Adds town type to the town list
  2715. * | ● Swap Context Icons
  2716. * | ● City overview
  2717. * ----------------------------------------------------------------------------------------------------------------------------
  2718. *******************************************************************************************************************************/
  2719.  
  2720. function imageSelectionProtection() {
  2721. $('<style id="dio_image_selection" type="text/css"> img { -moz-user-select: -moz-none; -khtml-user-select: none; -webkit-user-select: none;} </style>').appendTo('head');
  2722. }
  2723.  
  2724. var worldWonderIcon = {
  2725. colossus_of_rhodes: "url(https://gpall.innogamescdn.com/images/game/map/wonder_colossus_of_rhodes.png) 38px -1px;",
  2726. great_pyramid_of_giza: "url(https://gpall.innogamescdn.com/images/game/map/wonder_great_pyramid_of_giza.png) 34px -6px;",
  2727. hanging_gardens_of_babylon: "url(https://gpall.innogamescdn.com/images/game/map/wonder_hanging_gardens_of_babylon.png) 34px -5px;",
  2728. lighthouse_of_alexandria: "url(https://gpall.innogamescdn.com/images/game/map/wonder_lighthouse_of_alexandria.png) 37px -1px;",
  2729. mausoleum_of_halicarnassus: "url(https://gpall.innogamescdn.com/images/game/map/wonder_mausoleum_of_halicarnassus.png) 37px -4px;",
  2730. statue_of_zeus_at_olympia: "url(https://gpall.innogamescdn.com/images/game/map/wonder_statue_of_zeus_at_olympia.png) 36px -3px;",
  2731. temple_of_artemis_at_ephesus: "url(https://gpall.innogamescdn.com/images/game/map/wonder_temple_of_artemis_at_ephesus.png) 34px -5px;"
  2732. };
  2733.  
  2734. var WorldWonderIcons = {
  2735. activate: function () {
  2736. try {
  2737. if (!$('#dio_wondericons').get(0)) {
  2738. var color = "orange";
  2739.  
  2740. // style for world wonder icons
  2741. var style_str = "<style id='dio_wondericons' type='text/css'>";
  2742. for (var ww_type in wonder.map) {
  2743. if (wonder.map.hasOwnProperty(ww_type)) {
  2744. for (var ww in wonder.map[ww_type]) {
  2745. if (wonder.map[ww_type].hasOwnProperty(ww)) {
  2746. /*
  2747. if(wonder.map[ww_type][ww] !== AID){
  2748. color = "rgb(192, 109, 54)";
  2749. } else {
  2750. color = "orange";
  2751. }
  2752. */
  2753. style_str += "#mini_i" + ww + ":before {" +
  2754. "content: '';" +
  2755. "background:" + color + " " + worldWonderIcon[ww_type] +
  2756. "background-size: auto 97%;" +
  2757. "padding: 8px 16px;" +
  2758. "top: 50px;" +
  2759. "position: relative;" +
  2760. "border-radius: 40px;" +
  2761. "z-index: 200;" +
  2762. "cursor: pointer;" +
  2763. "box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5);" +
  2764. "border: 2px solid green; } " +
  2765. "#mini_i" + ww + ":hover:before { z-index: 201; " +
  2766. "filter: url(#Brightness12);" +
  2767. "-webkit-filter: brightness(1.2); } ";
  2768. }
  2769. }
  2770. }
  2771. }
  2772. $(style_str + "</style>").appendTo('head');
  2773.  
  2774. // Context menu on mouseclick
  2775. $('#minimap_islands_layer').on('click', '.m_island', function (e) {
  2776. var ww_coords = this.id.split("i")[3].split("_");
  2777. uw.Layout.contextMenu(e, 'wonder', {ix: ww_coords[0], iy: ww_coords[1]});
  2778. });
  2779.  
  2780.  
  2781. }
  2782. } catch (error) {
  2783. errorHandling(error, "setWonderIconsOnMap");
  2784. }
  2785. },
  2786. deactivate: function () {
  2787. $('#dio_wondericons').remove();
  2788. }
  2789. };
  2790.  
  2791. var TownIcons = {
  2792. types: {
  2793. // Automatic Icons
  2794. lo: 0,
  2795. ld: 3,
  2796. so: 6,
  2797. sd: 7,
  2798. fo: 10,
  2799. fd: 9,
  2800. bu: 14, /* Building */
  2801. po: 22,
  2802. no: 12,
  2803.  
  2804. // Manual Icons
  2805. fa: 20, /* Favor */
  2806. re: 15, /* Resources */
  2807. di: 2, /* Distance */
  2808. sh: 1, /* Pierce */
  2809. lu: 13, /* ?? */
  2810. dp: 11, /* Diplomacy */
  2811. ha: 15, /* ? */
  2812. si: 18, /* Silber */
  2813. ra: 17,
  2814. ch: 19, /* Research */
  2815. ti: 23, /* Time */
  2816. un: 5,
  2817. wd: 16, /* Wood */
  2818. wo: 24, /* World */
  2819. bo: 13, /* Booty */
  2820. gr: 21, /* Lorbeer */
  2821. st: 17, /* Stone */
  2822. is: 26, /* ?? */
  2823. he: 4, /* Helmet */
  2824. ko: 8 /* Kolo */
  2825.  
  2826. },
  2827. deactivate: function () {
  2828. $('#town_icon').remove();
  2829. $('#dio_townicons_field').remove();
  2830. },
  2831. activate: function () {
  2832. try {
  2833. $('<div id="town_icon"><div class="town_icon_bg"><div class="icon_big townicon_' +
  2834. (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no") + " auto")) + '"></div></div></div>').appendTo('.town_name_area');
  2835.  
  2836. // Town Icon Style
  2837. $('#town_icon .icon_big').css({
  2838. backgroundPosition: TownIcons.types[(manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")))] * -25 + 'px 0px'
  2839. });
  2840. console.debug(dio_sprite);
  2841. $('<style id="dio_townicons_field" type="text/css">' +
  2842. '#town_icon { background:url(' + dio_sprite + ') 0 -125px no-repeat; position:absolute; width:69px; height:61px; left:-47px; top:0px; z-index: 10; } ' +
  2843. '#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; } ' +
  2844. '#town_icon .town_icon_bg:hover { filter:url(#Brightness11); -webkit-filter:brightness(1.1); box-shadow: 0px 0px 15px rgb(1, 197, 33); } ' +
  2845. '#town_icon .icon_big { position:absolute; left:9px; top:9px; height:25px; width:25px; } ' +
  2846.  
  2847. '#town_icon .select_town_icon {position: absolute; top:47px; left:23px; width:145px; display:none; padding:2px; border:3px inset rgb(7, 99, 12); box-shadow:rgba(0, 0, 0, 0.5) 4px 4px 6px; border-radius:0px 10px 10px 10px;' +
  2848. 'background:url(https://gpall.innogamescdn.com/images/game/popup/middle_middle.png); } ' +
  2849. '#town_icon .item-list { max-height:400px; max-width:200px; align:right; overflow-x:hidden; } ' +
  2850.  
  2851. '#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;} ' +
  2852. '#town_icon .option_s:hover { border: 2px solid rgb(59, 121, 81) !important;-webkit-filter: brightness(1.3); } ' +
  2853. '#town_icon .sel { border: 2px solid rgb(202, 176, 109); } ' +
  2854. '#town_icon hr { width:145px; margin:0px 0px 7px 0px; position:relative; top:3px; border:0px; border-top:2px dotted #000; float:left} ' +
  2855. '#town_icon .auto_s { width:136px; height:16px; float:left} ' +
  2856.  
  2857. // Quickbar modification
  2858. '.ui_quickbar .left, .ui_quickbar .right { width:46%; } ' +
  2859.  
  2860. // because of Kapsonfires Script and Beta Worlds bug report bar:
  2861. '.town_name_area { z-index:11; left:52%; } ' +
  2862. '.town_name_area .left { z-index:20; left:-39px; } ' +
  2863. '</style>').appendTo('head');
  2864.  
  2865.  
  2866. var icoArray = ['ld', 'lo', 'sh', 'di', 'un',
  2867. 'sd', 'so', 'ko', 'ti', 'gr',
  2868. 'fd', 'fo', 'dp', 'no', 'po',
  2869. 're', 'wd', 'st', 'si', 'bu',
  2870. 'he', 'ch', 'bo', 'fa', 'wo'];
  2871.  
  2872. // Fill select box with town icons
  2873. $('<div class="select_town_icon dropdown-list default active"><div class="item-list"></div></div>').appendTo("#town_icon");
  2874. for (var i in icoArray) {
  2875. if (icoArray.hasOwnProperty(i)) {
  2876. $('.select_town_icon .item-list').append('<div class="option_s icon_small townicon_' + icoArray[i] + '" name="' + icoArray[i] + '"></div>');
  2877. }
  2878. }
  2879. $('<hr><div class="option_s auto_s" name="auto"><b>Auto</b></div>').appendTo('.select_town_icon .item-list');
  2880.  
  2881. $('#town_icon .option_s').click(function () {
  2882. $("#town_icon .sel").removeClass("sel");
  2883. $(this).addClass("sel");
  2884.  
  2885. if ($(this).attr("name") === "auto") {
  2886. delete manuTownTypes[uw.Game.townId];
  2887. } else {
  2888. manuTownTypes[uw.Game.townId] = $(this).attr("name");
  2889. }
  2890. TownIcons.changeTownIcon();
  2891.  
  2892. // Update town icons on the map
  2893. TownIcons.Map.activate(); //setOnMap();
  2894.  
  2895. saveValue(WID + "_townTypes", JSON.stringify(manuTownTypes));
  2896. });
  2897.  
  2898. // Show & hide drop menus on click
  2899. $('#town_icon .town_icon_bg').click(function () {
  2900. var el = $('#town_icon .select_town_icon').get(0);
  2901. if (el.style.display === "none") {
  2902. el.style.display = "block";
  2903. } else {
  2904. el.style.display = "none";
  2905. }
  2906. });
  2907.  
  2908. $('#town_icon .select_town_icon [name="' + (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" : "" )) + '"]').addClass("sel");
  2909.  
  2910. } catch (error) {
  2911. errorHandling(error, "addTownIcon");
  2912. }
  2913. },
  2914. changeTownIcon: function () {
  2915. var townType = (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")));
  2916. $('#town_icon .icon_big').removeClass().addClass('icon_big townicon_' + townType + " auto");
  2917. $('#town_icon .sel').removeClass("sel");
  2918. $('#town_icon .select_town_icon [name="' + (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" : "" )) + '"]').addClass("sel");
  2919.  
  2920. $('#town_icon .icon_big').css({
  2921. backgroundPosition: TownIcons.types[townType] * -25 + 'px 0px'
  2922. });
  2923.  
  2924. $('#town_icon .select_town_icon').get(0).style.display = "none";
  2925. },
  2926. Map: {
  2927. activate: function () {
  2928. try {
  2929. // if town icon changed
  2930. if ($('#dio_townicons_map').get(0)) {
  2931. $('#dio_townicons_map').remove();
  2932. }
  2933.  
  2934. // style for own towns (town icons)
  2935. var start = (new Date()).getTime(), end, style_str = "<style id='dio_townicons_map' type='text/css'>";
  2936. for (var e in autoTownTypes) {
  2937. if (autoTownTypes.hasOwnProperty(e)) {
  2938. style_str += "#mini_t" + e + " { height: 19px;" +
  2939. "width:19px;" +
  2940. "border-radius: 11px;" +
  2941. "border: 2px solid rgb(16, 133, 0);" +
  2942. "margin: -4px;" +
  2943. //"background: rgb(255, 187, 0) url(http://s7.directupload.net/images/140404/xt839us6.png) repeat;"+
  2944. "background: rgb(255, 187, 0) url(" + dio_sprite + ") " + (TownIcons.types[(manuTownTypes[e] || autoTownTypes[e])] * -25) + "px -27px repeat;" +
  2945. "z-index: 100;" +
  2946. "font-size: 0em;" +
  2947. "cursor: pointer;" +
  2948. (Game.night_mode ? "filter:url(#Brightness07); -webkit-filter: brightness(0.7);" : " ") +
  2949. "box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5);} " +
  2950. // Mouseover Style
  2951. "#mini_t" + e + ":hover { z-index: 101; " +
  2952. (Game.night_mode ? "filter:none; -webkit-filter: none;" : "filter: url(#Brightness12); -webkit-filter: brightness(1.2);") +
  2953. "} ";
  2954. }
  2955. }
  2956. // Context menu on mouseclick
  2957. $('#minimap_islands_layer').on('click', '.m_town', function (z) {
  2958. var id = parseInt(this.id.substring(6), 10);
  2959. Layout.contextMenu(z, 'determine', {"id": id, "name": uw.ITowns.getTown(id).name});
  2960.  
  2961. z.stopPropagation(); // prevent parent world wonder event
  2962. });
  2963.  
  2964. // Style for foreign cities (shadow)
  2965. style_str += "#minimap_islands_layer .m_town { text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.7); } ";
  2966.  
  2967. // Style for night mode
  2968. style_str += "#minimap { z-index: auto } ";
  2969.  
  2970. style_str += "</style>";
  2971. $(style_str).appendTo('head');
  2972.  
  2973. // Test:
  2974. $.Observer(GameEvents.game.night).subscribe('DIO_SWITCH_NIGHT', function (o) {
  2975. console.log("Switch Night: " + Timestamp.serverTime());
  2976. console.log(o);
  2977. });
  2978.  
  2979.  
  2980. /*
  2981. setTimeout(function(){
  2982. uw.MapTiles.createTownDiv_old = uw.MapTiles.createTownDiv;
  2983.  
  2984. uw.MapTiles.createTownDiv = function(town, player_current_town) {
  2985. var ret = uw.MapTiles.createTownDiv_old(town, player_current_town);
  2986.  
  2987. if(!isNaN(town.id) && town.player_id == PID) {
  2988.  
  2989. //setIconMap(town.id);
  2990. console.log(town.id);
  2991. console.log(player_current_town);
  2992. }
  2993. return ret;
  2994. };
  2995. },2000);
  2996. */
  2997. } catch (error) {
  2998. errorHandling(error, "TownIcons.Map.activate");
  2999. }
  3000. },
  3001. deactivate: function () {
  3002. $('#dio_townicons_map').remove();
  3003.  
  3004. $('#minimap_islands_layer').off('click');
  3005. }
  3006. }
  3007. };
  3008.  
  3009. // Style for town icons
  3010. var style_str = '<style id="dio_townicons" type="text/css">';
  3011. for (var s in TownIcons.types) {
  3012. if (TownIcons.types.hasOwnProperty(s)) {
  3013. style_str += '.townicon_' + s + ' { background:url(' + dio_sprite + ') ' + (TownIcons.types[s] * -25) + 'px -26px repeat;float:left;} ';
  3014. }
  3015. }
  3016. style_str += '</style>';
  3017. $(style_str).appendTo('head');
  3018.  
  3019.  
  3020. var ContextMenu = {
  3021. activate: function () {
  3022. // Set context menu event handler
  3023. $.Observer(uw.GameEvents.map.context_menu.click).subscribe('DIO_CONTEXT', function (e, data) {
  3024. if (DATA.options.con && $('#context_menu').children().length == 4) {
  3025. // Clear animation
  3026. $('#context_menu div#goToTown').css({
  3027. left: '0px',
  3028. top: '0px',
  3029. WebkitAnimation: 'none', //'A 0s linear',
  3030. animation: 'none' //'B 0s linear'
  3031. });
  3032. }
  3033. // Replace german label of 'select town' button
  3034. if (LID === "de" && $('#select_town').get(0)) {
  3035. $("#select_town .caption").get(0).innerHTML = "Selektieren";
  3036. }
  3037. });
  3038.  
  3039. // Set context menu animation
  3040. $('<style id="dio_context_menu" type="text/css">' +
  3041. // set fixed position of 'select town' button
  3042. '#select_town { left: 0px !important; top: 0px !important; z-index: 6; } ' +
  3043. // set animation of 'goToTown' button
  3044. '#context_menu div#goToTown { left: 30px; top: -51px; ' +
  3045. '-webkit-animation: A 0.115s linear; animation: B 0.2s;} ' +
  3046. '@-webkit-keyframes A { from {left: 0px; top: 0px;} to {left: 30px; top: -51px;} }' +
  3047. '@keyframes B { from {left: 0px; top: 0px;} to {left: 30px; top: -51px;} }' +
  3048. '</style>').appendTo('head');
  3049. },
  3050. deactivate: function () {
  3051. $.Observer(uw.GameEvents.map.context_menu.click).unsubscribe('DIO_CONTEXT');
  3052.  
  3053. $('#dio_context_menu').remove();
  3054. }
  3055. };
  3056.  
  3057.  
  3058. var TownList = {
  3059. activate: function () {
  3060. // Style town list
  3061. $('<style id="dio_town_list" type="text/css">' +
  3062. '#town_groups_list .item { text-align: left; padding-left:35px; } ' +
  3063. '#town_groups_list .inner_column { border: 1px solid rgba(100, 100, 0, 0.3);margin: -2px 0px 0px 2px; } ' +
  3064. '#town_groups_list .island_quest_icon { background-size: 90%; position: absolute; right: 37px; top: 4px; } ' +
  3065. '#town_groups_list .island_quest_icon.hidden { display:none; } ' +
  3066. // Quacks Zentrier-Button verschieben
  3067. '#town_groups_list .jump_town { right: 37px !important; } ' +
  3068. // Population percentage
  3069. '#town_groups_list .pop_percent { position: absolute; right: 7px; top:0px; font-size: 0.7em; display:block !important;} ' +
  3070. '#town_groups_list .full { color: green; } ' +
  3071. '#town_groups_list .threequarter { color: darkgoldenrod; } ' +
  3072. '#town_groups_list .half { color: darkred; } ' +
  3073. '#town_groups_list .quarter { color: red; } ' +
  3074. '</style>').appendTo('head');
  3075.  
  3076.  
  3077. // Open town list: hook to grepolis function render()
  3078. var i = 0;
  3079. while (uw.layout_main_controller.sub_controllers[i].name != 'town_name_area') {
  3080. i++;
  3081. }
  3082.  
  3083. 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;
  3084.  
  3085. uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render = function () {
  3086. uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render_old();
  3087. TownList.change();
  3088. };
  3089.  
  3090. // Town List open?
  3091. if ($('#town_groups_list').get(0)) {
  3092. TownList.change();
  3093. }
  3094. },
  3095. deactivate: function () {
  3096. var i = 0;
  3097. while (uw.layout_main_controller.sub_controllers[i].name != 'town_name_area') {
  3098. i++;
  3099. }
  3100.  
  3101. layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render = layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render_old;
  3102.  
  3103. $('#dio_town_list').remove();
  3104.  
  3105. $('#town_groups_list .small_icon, #town_groups_list .pop_percent').css({display: 'none'});
  3106.  
  3107. //$.Observer(uw.GameEvents.town.town_switch).unsubscribe('DIO_SWITCH_TOWN');
  3108.  
  3109. $("#town_groups_list .town_group_town").unbind('mouseenter mouseleave');
  3110. },
  3111. change: function () {
  3112. if (!$('#town_groups_list .icon_small').get(0) && !$('#town_groups_list .pop_percent').get(0)) {
  3113. $("#town_groups_list .town_group_town").each(function () {
  3114. try {
  3115. var town_item = $(this), town_id = town_item.attr('name'), townicon_div, percent_div = "", percent = -1, pop_space = "full";
  3116.  
  3117. if (population[town_id]) {
  3118. percent = population[town_id].percent;
  3119. }
  3120. if (percent < 75) {
  3121. pop_space = "threequarter";
  3122. }
  3123. if (percent < 50) {
  3124. pop_space = "half";
  3125. }
  3126. if (percent < 25) {
  3127. pop_space = "quarter";
  3128. }
  3129.  
  3130. if (!town_item.find('icon_small').length) {
  3131. townicon_div = '<div class="icon_small townicon_' + (manuTownTypes[town_id] || autoTownTypes[town_id] || "no") + '"></div>';
  3132. // TODO: Notlösung...
  3133. if (percent != -1) {
  3134. percent_div = '<div class="pop_percent ' + pop_space + '">' + percent + '%</div>';
  3135. }
  3136. town_item.prepend(townicon_div + percent_div);
  3137. }
  3138.  
  3139. // opening context menu
  3140. /*
  3141. $(this).click(function(e){
  3142. console.log(e);
  3143. uw.Layout.contextMenu(e, 'determine', {"id": town_id,"name": uw.ITowns[town_id].getName()});
  3144. });
  3145. */
  3146.  
  3147. } catch (error) {
  3148. errorHandling(error, "TownList.change");
  3149. }
  3150. });
  3151.  
  3152. }
  3153.  
  3154. // Hover Effect for Quacks Tool:
  3155. $("#town_groups_list .town_group_town").hover(function () {
  3156. $(this).find('.island_quest_icon').addClass("hidden");
  3157. }, function () {
  3158. $(this).find('.island_quest_icon').removeClass("hidden");
  3159. });
  3160.  
  3161. // Add change town list event handler
  3162. //$.Observer(uw.GameEvents.town.town_switch).subscribe('DIO_SWITCH_TOWN', function () {
  3163. //TownList.change();
  3164. //});
  3165. }
  3166. };
  3167.  
  3168. /*******************************************************************************************************************************
  3169. * Available units
  3170. * ----------------------------------------------------------------------------------------------------------------------------
  3171. * | ● GetAllUnits
  3172. * | ● Shows all available units
  3173. * ----------------------------------------------------------------------------------------------------------------------------
  3174. *******************************************************************************************************************************/
  3175. var groupUnitArray = {};
  3176. // TODO: split Function (getUnits, calcUnitsSum, availableUnits, countBiremes, getTownTypes)?
  3177. function getAllUnits() {
  3178. try {
  3179. var townArray = uw.ITowns.getTowns(), groupArray = uw.ITowns.townGroups.getGroupsDIO(),
  3180.  
  3181. unitArray = {
  3182. "sword": 0,
  3183. "archer": 0,
  3184. "hoplite": 0,
  3185. "chariot": 0,
  3186. "godsent": 0,
  3187. "rider": 0,
  3188. "slinger": 0,
  3189. "catapult": 0,
  3190. "small_transporter": 0,
  3191. "big_transporter": 0,
  3192. "manticore": 0,
  3193. "harpy": 0,
  3194. "pegasus": 0,
  3195. "cerberus": 0,
  3196. "minotaur": 0,
  3197. "medusa": 0,
  3198. "zyklop": 0,
  3199. "centaur": 0,
  3200. "fury": 0,
  3201. "sea_monster": 0
  3202. },
  3203.  
  3204. unitArraySea = {"bireme": 0, "trireme": 0, "attack_ship": 0, "demolition_ship": 0, "colonize_ship": 0};
  3205.  
  3206. console.debug("DIO-TOOLS | getAllUnits | GROUP ARRAY", groupArray);
  3207.  
  3208.  
  3209. if (uw.Game.hasArtemis) {
  3210. unitArray = $.extend(unitArray, {"griffin": 0, "calydonian_boar": 0});
  3211. }
  3212. unitArray = $.extend(unitArray, unitArraySea);
  3213.  
  3214. for (var group in groupArray) {
  3215. if (groupArray.hasOwnProperty(group)) {
  3216. // Clone Object "unitArray"
  3217. groupUnitArray[group] = Object.create(unitArray);
  3218.  
  3219. for (var town in groupArray[group].towns) {
  3220. if (groupArray[group].towns.hasOwnProperty(town)) {
  3221. var type = {lo: 0, ld: 0, so: 0, sd: 0, fo: 0, fd: 0}; // Type for TownList
  3222.  
  3223. for (var unit in unitArray) {
  3224. if (unitArray.hasOwnProperty(unit)) {
  3225. // All Groups: Available units
  3226. var tmp = parseInt(uw.ITowns.getTown(town).units()[unit], 10);
  3227. groupUnitArray[group][unit] += tmp || 0;
  3228. // Only for group "All"
  3229. if (group == -1) {
  3230. // Bireme counter // old
  3231. if (unit === "bireme" && ((biriArray[townArray[town].id] || 0) < (tmp || 0))) {
  3232. biriArray[townArray[town].id] = tmp;
  3233. }
  3234. //TownTypes
  3235. if (!uw.GameData.units[unit].is_naval) {
  3236. if (uw.GameData.units[unit].flying) {
  3237. type.fd += ((uw.GameData.units[unit].def_hack + uw.GameData.units[unit].def_pierce + uw.GameData.units[unit].def_distance) / 3 * (tmp || 0));
  3238. type.fo += (uw.GameData.units[unit].attack * (tmp || 0));
  3239. } else {
  3240. type.ld += ((uw.GameData.units[unit].def_hack + uw.GameData.units[unit].def_pierce + uw.GameData.units[unit].def_distance) / 3 * (tmp || 0));
  3241. type.lo += (uw.GameData.units[unit].attack * (tmp || 0));
  3242. }
  3243. } else {
  3244. type.sd += (uw.GameData.units[unit].defense * (tmp || 0));
  3245. type.so += (uw.GameData.units[unit].attack * (tmp || 0));
  3246. }
  3247. }
  3248. }
  3249. }
  3250. // Only for group "All"
  3251. if (group == -1) {
  3252. // Icon: DEF or OFF?
  3253. var z = ((type.sd + type.ld + type.fd) <= (type.so + type.lo + type.fo)) ? "o" : "d",
  3254. temp = 0;
  3255.  
  3256. for (var t in type) {
  3257. if (type.hasOwnProperty(t)) {
  3258. // Icon: Land/Sea/Fly (t[0]) + OFF/DEF (z)
  3259. if (temp < type[t]) {
  3260. autoTownTypes[townArray[town].id] = t[0] + z;
  3261. temp = type[t];
  3262. }
  3263. // Icon: Troops Outside (overwrite)
  3264. if (temp < 1000) {
  3265. autoTownTypes[townArray[town].id] = "no";
  3266. }
  3267. }
  3268. }
  3269. // Icon: Empty Town (overwrite)
  3270. var popBuilding = 0, buildVal = uw.GameData.buildings, levelArray = townArray[town].buildings().getLevels(),
  3271. popMax = Math.floor(buildVal.farm.farm_factor * Math.pow(townArray[town].buildings().getBuildingLevel("farm"), buildVal.farm.farm_pow)), // Population from farm level
  3272. popPlow = townArray[town].getResearches().attributes.plow ? 200 : 0,
  3273. popFactor = townArray[town].getBuildings().getBuildingLevel("thermal") ? 1.1 : 1.0, // Thermal
  3274. popExtra = townArray[town].getPopulationExtra();
  3275.  
  3276. for (var b in levelArray) {
  3277. if (levelArray.hasOwnProperty(b)) {
  3278. popBuilding += Math.round(buildVal[b].pop * Math.pow(levelArray[b], buildVal[b].pop_factor));
  3279. }
  3280. }
  3281. population[town] = {};
  3282.  
  3283. population[town].max = popMax * popFactor + popPlow + popExtra;
  3284. population[town].buildings = popBuilding;
  3285. population[town].units = parseInt((population[town].max - (popBuilding + townArray[town].getAvailablePopulation()) ), 10);
  3286.  
  3287. if (population[town].units < 300) {
  3288. autoTownTypes[townArray[town].id] = "po";
  3289. }
  3290.  
  3291. population[town].percent = Math.round(100 / (population[town].max - popBuilding) * population[town].units);
  3292. }
  3293. }
  3294. }
  3295. }
  3296. }
  3297.  
  3298. // Update Available Units
  3299. AvailableUnits.updateBullseye();
  3300. if (GPWindowMgr.TYPE_DIO_UNITS) {
  3301. if (Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS)) {
  3302. AvailableUnits.updateWindow();
  3303. }
  3304. }
  3305. } catch (error) {
  3306. errorHandling(error, "getAllUnits"); // TODO: Eventueller Fehler in Funktion
  3307. }
  3308. }
  3309.  
  3310. function addFunctionToITowns() {
  3311. // Copy function and prevent an error
  3312. uw.ITowns.townGroups.getGroupsDIO = function () {
  3313. var town_groups_towns, town_groups, groups = {};
  3314.  
  3315. // #Grepolis Fix: 2.75 -> 2.76
  3316. if (MM.collections) {
  3317. town_groups_towns = MM.collections.TownGroupTown[0];
  3318. town_groups = MM.collections.TownGroup[0];
  3319. } else {
  3320. town_groups_towns = MM.getCollections().TownGroupTown[0];
  3321. town_groups = MM.getCollections().TownGroup[0];
  3322. }
  3323.  
  3324. town_groups_towns.each(function (town_group_town) {
  3325. var gid = town_group_town.getGroupId(),
  3326. group = groups[gid],
  3327. town_id = town_group_town.getTownId();
  3328.  
  3329. if (!group) {
  3330. groups[gid] = group = {
  3331. id: gid,
  3332. //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
  3333. towns: {}
  3334. };
  3335. }
  3336.  
  3337. group.towns[town_id] = {id: town_id};
  3338. //groups[gid].towns[town_id]={id:town_id};
  3339. });
  3340. //console.log(groups);
  3341. return groups;
  3342. };
  3343. }
  3344.  
  3345. var AvailableUnits = {
  3346. activate: function () {
  3347. var default_title = DM.getl10n("place", "support_overview").options.troop_count + " (" + DM.getl10n("hercules2014", "available") + ")";
  3348.  
  3349. $(".picomap_container").prepend("<div id='available_bullseye_unit' class='unit_icon90x90 " + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme") + "'><div class='amount'></div></div>");
  3350.  
  3351. $('.picomap_overlayer').tooltip(getText("options", "ava")[0]);
  3352.  
  3353. // Style
  3354. $('<style id="dio_available_units_style">' +
  3355.  
  3356. '@-webkit-keyframes Z { 0% { opacity: 0; } 100% { opacity: 1; } } ' +
  3357. '@keyframes Z { 0% { opacity: 0; } 100% { opacity: 1; } } ' +
  3358.  
  3359. '@-webkit-keyframes blurr { 0% { -webkit-filter: blur(5px); } 100% { -webkit-filter: blur(0px); } } ' +
  3360.  
  3361. '.picomap_overlayer { cursor:pointer; } ' +
  3362.  
  3363. '.picomap_area .bull_eye_buttons { height: 55px; } ' +
  3364.  
  3365. '#sea_id { background: none; font-size:25px; cursor:default; height:50px; width:50px; position:absolute; top:70px; left:157px; z-index: 30; } ' +
  3366.  
  3367. // Available bullseye unit
  3368. '#available_bullseye_unit { margin: 5px 28px 0px 28px; -webkit-animation: blur 2s; animation: Z 1s; } ' +
  3369.  
  3370. '#available_bullseye_unit .amount { color:#826021; position:relative; top:28px; font-style:italic; width:79px; font-weight: bold; text-shadow: 0px 0px 2px black, 1px 1px 2px black, 0px 2px 2px black; -webkit-animation: blur 3s; } ' +
  3371.  
  3372. '#available_bullseye_unit.big_number { font-size: 0.90em; line-height: 1.4; } ' +
  3373.  
  3374. '#available_bullseye_unit.blur { -webkit-animation: blurr 0.6s; } ' +
  3375.  
  3376. // Land units
  3377. '#available_bullseye_unit.sword .amount { color:#E2D9C1; top:57px; width:90px; } ' +
  3378. '#available_bullseye_unit.hoplite .amount { color:#E2D9C1; top:57px; width:90px; } ' +
  3379. '#available_bullseye_unit.archer .amount { color:#E2D0C1; top:47px; width:70px; } ' +
  3380. '#available_bullseye_unit.chariot { background-position: -990px 10px; } ' +
  3381. '#available_bullseye_unit.rider .amount { color:#DFCC6C; top:52px; width:105px; } ' +
  3382. '#available_bullseye_unit.chariot .amount,' +
  3383. '#available_bullseye_unit.slinger .amount { color:#F5E8B4; top:53px; width:91px; } ' +
  3384. '#available_bullseye_unit.catapult .amount { color:#F5F6C5; top:36px; width:87px; } ' +
  3385. '#available_bullseye_unit.godsent .amount { color:#F5F6C5; top:57px; width:92px; } ' +
  3386.  
  3387. // Mythic units
  3388. '#available_bullseye_unit.medusa .amount { color:#FBFFBB; top:50px; width:65px; } ' +
  3389. '#available_bullseye_unit.manticore .amount { color:#ECD181; top:50px; width:55px; } ' +
  3390. '#available_bullseye_unit.pegasus { background-position: -2970px 11px; } ' +
  3391. '#available_bullseye_unit.pegasus .amount { color:#F7F8E3; top:52px; width:90px; } ' +
  3392. '#available_bullseye_unit.minotaur { background-position: -2700px 5px; } ' +
  3393. '#available_bullseye_unit.minotaur .amount { color:#EAD88A; top:58px; width:78px; } ' +
  3394. //'#available_bullseye_unit.zyklop { background-position: -4140px 10px; } '+
  3395. '#available_bullseye_unit.zyklop .amount { color:#EDE0B0; top:53px; width:95px; } ' +
  3396. '#available_bullseye_unit.harpy { background-position: -1800px 11px; } ' +
  3397. '#available_bullseye_unit.harpy .amount { color:#E7DB79; top:40px; width:78px; } ' +
  3398. '#available_bullseye_unit.sea_monster .amount { color:#D8EA84; top:58px; width:91px; } ' +
  3399. '#available_bullseye_unit.cerberus .amount { color:#EC7445; top:25px; width:101px; } ' +
  3400. '#available_bullseye_unit.centaur { background-position: -810px 10px; } ' +
  3401. '#available_bullseye_unit.centaur .amount { color:#ECE0A8; top:44px; width:83px; } ' +
  3402. '#available_bullseye_unit.fury .amount { color:#E0E0BC; top:57px; width:95px; } ' +
  3403. '#available_bullseye_unit.griffin { background-position: -1710px 10px; } ' +
  3404. '#available_bullseye_unit.griffin .amount { color:#FFDC9D; top:55px; width:98px; } ' +
  3405. '#available_bullseye_unit.calydonian_boar .amount { color:#FFDC9D; top:17px; width:85px; } ' +
  3406.  
  3407. // Naval units
  3408. '#available_bullseye_unit.attack_ship .amount { color:#FFCB00; top:26px; width:99px; } ' +
  3409. '#available_bullseye_unit.bireme .amount { color:#DFC677; color:azure; top:28px; width:79px; } ' +
  3410. '#available_bullseye_unit.trireme .amount { color:#F4FFD4; top:24px; width:90px; } ' +
  3411. '#available_bullseye_unit.small_transporter .amount { color:#F5F6C5; top:26px; width:84px; } ' +
  3412. '#available_bullseye_unit.big_transporter .amount { color:#FFDC9D; top:27px; width:78px; } ' +
  3413. '#available_bullseye_unit.colonize_ship .amount { color:#F5F6C5; top:29px; width:76px; } ' +
  3414. '#available_bullseye_unit.colonize_ship .amount { color:#F5F6C5; top:29px; width:76px; } ' +
  3415. '#available_bullseye_unit.demolition_ship .amount { color:#F5F6C5; top:35px; width:90px; } ' +
  3416.  
  3417. // Available units window
  3418. '#available_units { overflow: auto; height: 250px; } ' +
  3419. '#available_units .unit { margin: 5px; cursor:pointer; overflow:visible; } ' +
  3420. '#available_units .unit.active { border: 2px solid #7f653a; border-radius:30px; margin:4px; } ' +
  3421. '#available_units .unit span { text-shadow: 1px 1px 1px black, 1px 1px 2px black;} ' +
  3422. '#available_units hr { border: none; border-top: 1px solid rgb(8, 148, 33); margin-top: 10px; } ' +
  3423. '#available_units .option { float: left; margin-right: 30px; width:100%; } ' +
  3424.  
  3425. //'#available_units .box_content { background:url(http://s1.directupload.net/images/140206/8jd9d3ec.png) 94% 94% no-repeat; background-size:140px; } '+
  3426.  
  3427. '#available_units .drop_box { position:absolute; top: -38px; right: 83px; width:90px; z-index:10; } ' +
  3428. '#available_units .drop_group { width: 120px; } ' +
  3429. '#available_units .select_group.open { display:block; } ' +
  3430. '#available_units .item-list { overflow: auto; overflow-x: hidden; } ' +
  3431. '#available_units .arrow { width:18px; height:18px; background:url(' + drop_out.src + ') no-repeat -1px -1px; position:absolute; } ' +
  3432.  
  3433. // Available units button
  3434. '#btn_available_units { top:86px; left:119px; z-index:10; position:absolute; } ' +
  3435. '#btn_available_units .ico_available_units { margin:5px 0px 0px 4px; width:24px; height:24px; ' +
  3436. 'background:url(http://s1.directupload.net/images/140323/w4ekrw8b.png) no-repeat 0px 0px;background-size:100%; filter:url(#Hue1); -webkit-filter:hue-rotate(100deg); } ' +
  3437.  
  3438. '</style>').appendTo('head');
  3439.  
  3440. createWindowType("DIO_UNITS", (LANG.hasOwnProperty(LID) ? getText("options", "ava")[0] : default_title), 365, 270, true, [240, 70]);
  3441.  
  3442. // Set Sea-ID beside the bull eye
  3443. $('#sea_id').prependTo('#ui_box');
  3444.  
  3445. AvailableUnits.addButton();
  3446.  
  3447. AvailableUnits.updateBullseye();
  3448. },
  3449. deactivate: function () {
  3450. $('#available_bullseye_unit').remove();
  3451. $('#dio_available_units_style').remove();
  3452. $('#btn_available_units').remove();
  3453.  
  3454. if (Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS)) {
  3455. Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS).close();
  3456. }
  3457.  
  3458. $('.picomap_overlayer').unbind();
  3459.  
  3460. $('#sea_id').appendTo('.picomap_container')
  3461. },
  3462. addButton: function () {
  3463. var default_title = DM.getl10n("place", "support_overview").options.troop_count + " (" + DM.getl10n("hercules2014", "available") + ")";
  3464.  
  3465. $('<div id="btn_available_units" class="circle_button"><div class="ico_available_units js-caption"></div></div>').appendTo(".bull_eye_buttons");
  3466.  
  3467. // Events
  3468. $('#btn_available_units').on('mousedown', function () {
  3469. $('#btn_available_units, .ico_available_units').addClass("checked");
  3470. }).on('mouseup', function () {
  3471. $('#btn_available_units, .ico_available_units').removeClass("checked");
  3472. });
  3473.  
  3474. $('#btn_available_units, .picomap_overlayer').click(function () {
  3475. if (!Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS)) {
  3476. AvailableUnits.openWindow();
  3477. $('#btn_available_units, .ico_available_units').addClass("checked");
  3478. } else {
  3479. AvailableUnits.closeWindow();
  3480. $('#btn_available_units, .ico_available_units').removeClass("checked");
  3481. }
  3482. });
  3483.  
  3484. // Tooltip
  3485. $('#btn_available_units').tooltip(LANG.hasOwnProperty(LID) ? getText("labels", "uni") : default_title);
  3486. },
  3487. openWindow: function () {
  3488. var groupArray = uw.ITowns.townGroups.getGroupsDIO(),
  3489.  
  3490. unitArray = {
  3491. "sword": 0,
  3492. "archer": 0,
  3493. "hoplite": 0,
  3494. "slinger": 0,
  3495. "rider": 0,
  3496. "chariot": 0,
  3497. "catapult": 0,
  3498. "godsent": 0,
  3499. "manticore": 0,
  3500. "harpy": 0,
  3501. "pegasus": 0,
  3502. "griffin": 0,
  3503. "cerberus": 0,
  3504. "minotaur": 0,
  3505. "medusa": 0,
  3506. "zyklop": 0,
  3507. "centaur": 0,
  3508. "calydonian_boar": 0,
  3509. "fury": 0,
  3510. "sea_monster": 0,
  3511. "small_transporter": 0,
  3512. "big_transporter": 0,
  3513. "bireme": 0,
  3514. "attack_ship": 0,
  3515. "trireme": 0,
  3516. "demolition_ship": 0,
  3517. "colonize_ship": 0
  3518. };
  3519.  
  3520. if (!uw.Game.hasArtemis) {
  3521. delete unitArray.calydonian_boar;
  3522. delete unitArray.griffin;
  3523. }
  3524.  
  3525. var land_units_str = "", content =
  3526. '<div id="available_units">' +
  3527. // Dropdown menu
  3528. '<div class="drop_box">' +
  3529. '<div class="drop_group dropdown default">' +
  3530. '<div class="border-left"></div><div class="border-right"></div>' +
  3531. '<div class="caption" name="' + groupArray[DATA.bullseyeUnit.current_group].id + '">' + ITowns.town_groups._byId[groupArray[DATA.bullseyeUnit.current_group].id].attributes.name + '</div>' +
  3532. '<div class="arrow"></div>' +
  3533. '</div>' +
  3534. '<div class="select_group dropdown-list default active"><div class="item-list"></div></div>' +
  3535. '</div>' +
  3536. // Content
  3537. '<div class="box_content">';
  3538.  
  3539. for (var unit in unitArray) {
  3540. if (unitArray.hasOwnProperty(unit)) {
  3541. land_units_str += '<div class="unit index_unit bold unit_icon40x40 ' + unit + '"></div>';
  3542. if (unit == "sea_monster") {
  3543. land_units_str += '<div style="clear:left;"></div>'; // break
  3544. }
  3545. }
  3546. }
  3547. content += land_units_str + '</div></div>';
  3548.  
  3549. AvailableUnits.wnd = Layout.wnd.Create(GPWindowMgr.TYPE_DIO_UNITS);
  3550.  
  3551. AvailableUnits.wnd.setContent(content);
  3552.  
  3553. if (Game.premium_features.curator <= Timestamp.now()) {
  3554. $('#available_units .drop_box').css({display: 'none'});
  3555. DATA.bullseyeUnit.current_group = -1;
  3556. }
  3557.  
  3558. // Add groups to dropdown menu
  3559. for (var group in groupArray) {
  3560. if (groupArray.hasOwnProperty(group)) {
  3561. var group_name = ITowns.town_groups._byId[group].attributes.name;
  3562. $('<div class="option' + (group == -1 ? " sel" : "") + '" name="' + group + '">' + group_name + '</div>').appendTo('#available_units .item-list');
  3563. }
  3564. }
  3565.  
  3566. // Update
  3567. AvailableUnits.updateWindow();
  3568.  
  3569. // Dropdown menu Handler
  3570. $('#available_units .drop_group').click(function () {
  3571. $('#available_units .select_group').toggleClass('open');
  3572. });
  3573. // Change group
  3574. $('#available_units .select_group .option').click(function () {
  3575. DATA.bullseyeUnit.current_group = $(this).attr("name");
  3576. $('#available_units .select_group').removeClass('open');
  3577. $('#available_units .select_group .option.sel').removeClass("sel");
  3578. $(this).addClass("sel");
  3579.  
  3580. $('#available_units .drop_group .caption').attr("name", DATA.bullseyeUnit.current_group);
  3581. $('#available_units .drop_group .caption').get(0).innerHTML = this.innerHTML;
  3582.  
  3583. $('#available_units .unit.active').removeClass("active");
  3584. $('#available_units .unit.' + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme")).addClass("active");
  3585.  
  3586. AvailableUnits.updateWindow();
  3587. AvailableUnits.updateBullseye();
  3588. AvailableUnits.save();
  3589. });
  3590.  
  3591. // Set active bullseye unit
  3592. $('#available_units .unit.' + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme")).addClass("active");
  3593.  
  3594. // Change bullseye unit
  3595. $('#available_units .unit').click(function () {
  3596. DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] = this.className.split(" ")[4].trim();
  3597.  
  3598. $('#available_units .unit.active').removeClass("active");
  3599. $(this).addClass("active");
  3600.  
  3601. AvailableUnits.updateBullseye();
  3602. AvailableUnits.save();
  3603.  
  3604. });
  3605.  
  3606. // Close button event - uncheck available units button
  3607. Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS).getJQCloseButton().get(0).onclick = function () {
  3608. $('#btn_available_units, .ico_available_units').removeClass("checked");
  3609. };
  3610. },
  3611. closeWindow: function () {
  3612. Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS).close();
  3613. },
  3614. save: function () {
  3615. saveValue(WID + "_bullseyeUnit", JSON.stringify(DATA.bullseyeUnit));
  3616. },
  3617. updateBullseye: function () {
  3618. var sum = 0, str = "", fsize = ['1.4em', '1.2em', '1.15em', '1.1em', '1.0em', '0.95em'], i;
  3619. if ($('#available_bullseye_unit').get(0)) {
  3620. $('#available_bullseye_unit').get(0).className = "unit_icon90x90 " + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme");
  3621.  
  3622. if (groupUnitArray[DATA.bullseyeUnit.current_group]) {
  3623. sum = groupUnitArray[DATA.bullseyeUnit.current_group][(DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme")];
  3624. }
  3625. sum = sum.toString();
  3626.  
  3627. for (i = 0; i < sum.length; i++) {
  3628. str += "<span style='font-size:" + fsize[i] + "'>" + sum[i] + "</span>";
  3629. }
  3630. $('#available_bullseye_unit .amount').get(0).innerHTML = str;
  3631.  
  3632. if (sum >= 100000) {
  3633. $('#available_bullseye_unit').addClass("big_number");
  3634. } else {
  3635. $('#available_bullseye_unit').removeClass("big_number");
  3636. }
  3637. }
  3638. },
  3639. updateWindow: function () {
  3640. $('#available_units .box_content .unit').each(function () {
  3641. var unit = this.className.split(" ")[4];
  3642. this.innerHTML = '<span style="font-size:0.9em">' + groupUnitArray[DATA.bullseyeUnit.current_group][unit] + '</span>';
  3643. });
  3644. }
  3645. };
  3646.  
  3647. /*******************************************************************************************************************************
  3648. * Comparison box
  3649. * ----------------------------------------------------------------------------------------------------------------------------
  3650. * | ● Compares the units of each unit type
  3651. * ----------------------------------------------------------------------------------------------------------------------------
  3652. *******************************************************************************************************************************/
  3653. var UnitComparison = {
  3654. activate: function () {
  3655. //UnitComparison.addBox();
  3656. UnitComparison.addButton();
  3657.  
  3658. // Create Window Type
  3659. createWindowType("DIO_COMPARISON", getText("labels", "dsc"), 480, 315, true, ["center", "center", 100, 100]);
  3660.  
  3661. // Style
  3662. $('<style id="dio_comparison_style"> ' +
  3663.  
  3664. // Button
  3665. '#dio_comparison_button { top:51px; left:120px; z-index:10; position:absolute; } ' +
  3666. '#dio_comparison_button .ico_comparison { margin:5px 0px 0px 4px; width:24px; height:24px; ' +
  3667. 'background:url(http://666kb.com/i/cjq6cxia4ms8mn95r.png) no-repeat 0px 0px; background-size:100%; filter:url(#Hue1); -webkit-filter:hue-rotate(60deg); } ' +
  3668. '#dio_comparison_button.checked .ico_comparison { margin-top:6px; } ' +
  3669.  
  3670. // Window
  3671. '#dio_comparison a { float:left; background-repeat:no-repeat; background-size:25px; line-height:2; margin-right:10px; } ' +
  3672. '#dio_comparison .box_content { text-align:center; font-style:normal; } ' +
  3673.  
  3674. // Menu tabs
  3675. '#dio_comparison_menu .tab_icon { left: 23px;} ' +
  3676. '#dio_comparison_menu .tab_label { margin-left: 18px; } ' +
  3677.  
  3678. // Content
  3679. '#dio_comparison .hidden { display:none; } ' +
  3680. '#dio_comparison table { width:480px; } ' +
  3681. '#dio_comparison .hack .t_hack, #dio_comparison .pierce .t_pierce, #dio_comparison .distance .t_distance, #dio_comparison .sea .t_sea { display:inline-table; } ' +
  3682.  
  3683. '#dio_comparison .box_content { background:url(http://s1.directupload.net/images/140206/8jd9d3ec.png) 94% 94% no-repeat; background-size:140px; } ' +
  3684.  
  3685. '#dio_comparison .compare_type_icon { height:25px; width:25px; background:url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png); background-size:100%; } ' +
  3686. '#dio_comparison .compare_type_icon.booty { background:url(http://s14.directupload.net/images/140404/ki4gwd7x.png); background-size:100%; } ' +
  3687. '#dio_comparison .compare_type_icon.time { background:url(https://gpall.innogamescdn.com/images/game/res/time.png); background-size:100%; } ' +
  3688. '#dio_comparison .compare_type_icon.favor { background:url(https://gpall.innogamescdn.com/images/game/res/favor.png); background-size:100%; } ' +
  3689. '</style>').appendTo("head");
  3690. },
  3691. deactivate: function () {
  3692. $('#dio_comparison_button').remove();
  3693. $('#dio_comparison_style').remove();
  3694.  
  3695. if (Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON)) {
  3696. Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON).close();
  3697. }
  3698. },
  3699. addButton: function () {
  3700. $('<div id="dio_comparison_button" class="circle_button"><div class="ico_comparison js-caption"></div></div>').appendTo(".bull_eye_buttons");
  3701.  
  3702. // Events
  3703. /*
  3704. $('#dio_comparison_button').on('mousedown', function(){
  3705. $('#dio_comparison_button').addClass("checked");
  3706. }, function(){
  3707. $('#dio_comparison_button').removeClass("checked");
  3708. });
  3709. */
  3710. $('#dio_comparison_button').on('click', function () {
  3711. if (!Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON)) {
  3712. UnitComparison.openWindow();
  3713. $('#dio_comparison_button').addClass("checked");
  3714. } else {
  3715. UnitComparison.closeWindow();
  3716. $('#dio_comparison_button').removeClass("checked");
  3717. }
  3718. });
  3719.  
  3720. // Tooltip
  3721. $('#dio_comparison_button').tooltip(getText("labels", "dsc"));
  3722. },
  3723. openWindow: function () {
  3724. var content =
  3725. // Title tabs
  3726. '<ul id="dio_comparison_menu" class="menu_inner" style="top: -36px; right: 35px;">' +
  3727. '<li><a class="submenu_link sea" href="#"><span class="left"><span class="right"><span class="middle">' +
  3728. '<span class="tab_icon icon_small townicon_so"></span><span class="tab_label">' + getText("labels", "sea") + '</span>' +
  3729. '</span></span></span></a></li>' +
  3730. '<li><a class="submenu_link distance" href="#"><span class="left"><span class="right"><span class="middle">' +
  3731. '<span class="tab_icon icon_small townicon_di"></span><span class="tab_label">' + getText("labels", "dst") + '</span>' +
  3732. '</span></span></span></a></li>' +
  3733. '<li><a class="submenu_link pierce" href="#"><span class="left"><span class="right"><span class="middle">' +
  3734. '<span class="tab_icon icon_small townicon_sh"></span><span class="tab_label">' + getText("labels", "prc") + '</span>' +
  3735. '</span></span></span></a></li>' +
  3736. '<li><a class="submenu_link hack active" href="#"><span class="left"><span class="right"><span class="middle">' +
  3737. '<span class="tab_icon icon_small townicon_lo"></span><span class="tab_label">' + getText("labels", "hck") + '</span>' +
  3738. '</span></span></span></a></li>' +
  3739. '</ul>' +
  3740. // Content
  3741. '<div id="dio_comparison" style="margin-bottom:5px; font-style:italic;"><div class="box_content hack"></div></div>';
  3742.  
  3743. Layout.wnd.Create(GPWindowMgr.TYPE_DIO_COMPARISON).setContent(content);
  3744.  
  3745. UnitComparison.addComparisonTable("hack");
  3746. UnitComparison.addComparisonTable("pierce");
  3747. UnitComparison.addComparisonTable("distance");
  3748. UnitComparison.addComparisonTable("sea");
  3749.  
  3750. // Tooltips
  3751. var labelArray = DM.getl10n("barracks"),
  3752. labelAttack = DM.getl10n("context_menu", "titles").attack,
  3753. labelDefense = DM.getl10n("place", "tabs")[0];
  3754.  
  3755. $('.tr_att').tooltip(labelAttack);
  3756. $('.tr_def').tooltip(labelDefense + " (Ø)");
  3757. $('.tr_def_sea').tooltip(labelDefense);
  3758. $('.tr_spd').tooltip(labelArray.tooltips.speed);
  3759. $('.tr_bty').tooltip(labelArray.tooltips.booty.title);
  3760. $('.tr_bty_sea').tooltip(labelArray.tooltips.ship_transport.title);
  3761. $('.tr_res').tooltip(labelArray.costs + " (" +
  3762. labelArray.cost_details.wood + " + " +
  3763. labelArray.cost_details.stone + " + " +
  3764. labelArray.cost_details.iron + ")"
  3765. );
  3766. $('.tr_fav').tooltip(labelArray.costs + " (" + labelArray.cost_details.favor + ")");
  3767. $('.tr_tim').tooltip(labelArray.cost_details.buildtime_barracks + " (s)");
  3768. $('.tr_tim_sea').tooltip(labelArray.cost_details.buildtime_docks + " (s)");
  3769.  
  3770. UnitComparison.switchComparisonTables();
  3771.  
  3772. // Close button event - uncheck available units button
  3773. Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON).getJQCloseButton().get(0).onclick = function () {
  3774. $('#dio_comparison_button').removeClass("checked");
  3775. $('.ico_comparison').get(0).style.marginTop = "5px";
  3776. };
  3777. },
  3778. closeWindow: function () {
  3779. Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON).close();
  3780. },
  3781. switchComparisonTables: function () {
  3782. $('#dio_comparison_menu .hack, #dio_comparison_menu .pierce, #dio_comparison_menu .distance, #dio_comparison_menu .sea').click(function () {
  3783. $('#dio_comparison .box_content').removeClass($('#dio_comparison .box_content').get(0).className.split(" ")[1]);
  3784. console.debug(this.className.split(" ")[1]);
  3785. $('#dio_comparison .box_content').addClass(this.className.split(" ")[1]);
  3786.  
  3787. $('#dio_comparison_menu .active').removeClass("active");
  3788. $(this).addClass("active");
  3789. });
  3790. },
  3791.  
  3792. tooltips: [], t: 0,
  3793.  
  3794. addComparisonTable: function (type) {
  3795. var pos = {
  3796. att: {hack: "36%", pierce: "27%", distance: "45.5%", sea: "72.5%"},
  3797. def: {hack: "18%", pierce: "18%", distance: "18%", sea: "81.5%"}
  3798. };
  3799. var unitIMG = "https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png";
  3800. var strArray = [
  3801. "<td></td>",
  3802. '<td><div class="compare_type_icon" style="background-position: 0% ' + pos.att[type] + ';"></div></td>',
  3803. '<td><div class="compare_type_icon" style="background-position: 0% ' + pos.def[type] + ';"></div></td>',
  3804. '<td><div class="compare_type_icon" style="background-position: 0% 63%;"></div></td>',
  3805. (type !== "sea") ? '<td><div class="compare_type_icon booty"></div></td>' : '<td><div class="compare_type_icon" style="background-position: 0% 91%;"></div></td>',
  3806. '<td><div class="compare_type_icon" style="background-position: 0% 54%;"></div></td>',
  3807. '<td><div class="compare_type_icon favor"></div></td>',
  3808. '<td><div class="compare_type_icon time"></div></td>'
  3809. ];
  3810.  
  3811. for (var e in uw.GameData.units) {
  3812. if (uw.GameData.units.hasOwnProperty(e)) {
  3813. var valArray = [];
  3814.  
  3815. if (type === (uw.GameData.units[e].attack_type || "sea") && (e !== "militia")) {
  3816. valArray.att = Math.round(uw.GameData.units[e].attack * 10 / uw.GameData.units[e].population) / 10;
  3817. 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;
  3818. valArray.def = valArray.def || Math.round(uw.GameData.units[e].defense * 10 / uw.GameData.units[e].population) / 10;
  3819. valArray.speed = uw.GameData.units[e].speed;
  3820. valArray.booty = Math.round(((uw.GameData.units[e].booty) * 10) / uw.GameData.units[e].population) / 10;
  3821. 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;
  3822. valArray.favor = Math.round((uw.GameData.units[e].favor * 10) / uw.GameData.units[e].population) / 10;
  3823. 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));
  3824. valArray.time = Math.round(uw.GameData.units[e].build_time / uw.GameData.units[e].population);
  3825.  
  3826. // World without Artemis? -> grey griffin and boar
  3827. valArray.heroStyle = "";
  3828. valArray.heroStyleIMG = "";
  3829.  
  3830. if (!uw.Game.hasArtemis && ((e === "griffin") || (e === "calydonian_boar"))) {
  3831. valArray.heroStyle = "color:black;opacity: 0.4;";
  3832. valArray.heroStyleIMG = "filter: url(#GrayScale); -webkit-filter:grayscale(100%);";
  3833. }
  3834.  
  3835. strArray[0] += '<td class="un' + (UnitComparison.t) + '"><span class="unit index_unit unit_icon40x40 ' + e + '" style="' + valArray.heroStyle + valArray.heroStyleIMG + '"></span></td>';
  3836. strArray[1] += '<td class="bold" style="color:' + ((valArray.att > 19) ? 'green;' : ((valArray.att < 10 && valArray.att !== 0 ) ? 'red;' : 'black;')) + valArray.heroStyle + '">' + valArray.att + '</td>';
  3837. strArray[2] += '<td class="bold" style="color:' + ((valArray.def > 19) ? 'green;' : ((valArray.def < 10 && valArray.def !== 0 ) ? 'red;' : 'black;')) + valArray.heroStyle + '">' + valArray.def + '</td>';
  3838. strArray[3] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.speed + '</td>';
  3839. strArray[4] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.booty + '</td>';
  3840. strArray[5] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.res + '</td>';
  3841. strArray[6] += '<td class="bold" style="color:' + ((valArray.favor > 0) ? 'rgb(0, 0, 214);' : 'black;') + valArray.heroStyle + ';">' + valArray.favor + '</td>';
  3842. strArray[7] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.time + '</td>';
  3843.  
  3844. UnitComparison.tooltips[UnitComparison.t] = uw.GameData.units[e].name;
  3845. UnitComparison.t++;
  3846. }
  3847. }
  3848. }
  3849.  
  3850. $('<table class="hidden t_' + type + '" cellpadding="1px">' +
  3851. '<tr>' + strArray[0] + '</tr>' +
  3852. '<tr class="tr_att">' + strArray[1] + '</tr><tr class="tr_def' + (type == "sea" ? "_sea" : "") + '">' + strArray[2] + '</tr>' +
  3853. '<tr class="tr_spd">' + strArray[3] + '</tr><tr class="tr_bty' + (type == "sea" ? "_sea" : "") + '">' + strArray[4] + '</tr>' +
  3854. '<tr class="tr_res">' + strArray[5] + '</tr><tr class="tr_fav">' + strArray[6] + '</tr><tr class="tr_tim' + (type == "sea" ? "_sea" : "") + '">' + strArray[7] + '</tr>' +
  3855. '</table>').appendTo('#dio_comparison .box_content');
  3856.  
  3857. for (var i = 0; i <= UnitComparison.t; i++) {
  3858. $('.un' + i).tooltip(UnitComparison.tooltips[i]);
  3859. }
  3860. }
  3861. };
  3862.  
  3863. /*******************************************************************************************************************************
  3864. * Reports and Messages
  3865. * ----------------------------------------------------------------------------------------------------------------------------
  3866. * | ● Storage of the selected filter (only in German Grepolis yet)
  3867. * ----------------------------------------------------------------------------------------------------------------------------
  3868. *******************************************************************************************************************************/
  3869.  
  3870. var filter = "all";
  3871.  
  3872. function saveFilter() {
  3873. $('#dd_filter_type_list .item-list div').each(function () {
  3874. $(this).click(function () {
  3875. filter = $(this).attr("name");
  3876. });
  3877. });
  3878. /*
  3879. var i = 0;
  3880. $("#report_list a").each(function () {
  3881. //console.log((i++) +" = " + $(this).attr('data-reportid'));
  3882. });
  3883. */
  3884. }
  3885.  
  3886. function loadFilter() {
  3887. if ($('#dd_filter_type_list .selected').attr("name") !== filter) {
  3888. $('#dd_filter_type .caption').click();
  3889. $('#dd_filter_type_list .item-list div[name=' + filter + ']').click();
  3890. }
  3891. }
  3892.  
  3893. function removeReports() {
  3894. $("#report_list li:contains('spioniert')").each(function () {
  3895. //$(this).remove();
  3896. });
  3897. }
  3898.  
  3899. var zut = 0;
  3900. var messageArray = {};
  3901.  
  3902. function filterPlayer() {
  3903. if (!$('#message_filter_list').get(0)) {
  3904. $('<div id="message_filter_list" style="height:300px;overflow-y:scroll; width: 790px;"></div>').appendTo('#folder_container');
  3905. $("#message_list").get(0).style.display = "none";
  3906. }
  3907. if (zut < parseInt($('.es_last_page').get(0).value, 10) - 1) {
  3908. $('.es_page_input').get(0).value = zut++;
  3909. $('.jump_button').click();
  3910. $("#message_list li:contains('')").each(function () {
  3911. $(this).appendTo('#message_filter_list');
  3912. });
  3913. } else {
  3914. zut = 1;
  3915. }
  3916. }
  3917.  
  3918.  
  3919. /*******************************************************************************************************************************
  3920. * World Wonder Ranking - Change
  3921. *******************************************************************************************************************************/
  3922.  
  3923. function getWorldWonderTypes() {
  3924. $.ajax({
  3925. type: "GET",
  3926. url: "/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 +
  3927. "%7D&_=" + uw.Game.server_time,
  3928. success: function (text) {
  3929. try {
  3930. //console.log(JSON.parse(text));
  3931. temp = JSON.parse(text).json.data.world_wonders;
  3932. for (var t in temp) {
  3933. if (temp.hasOwnProperty(t)) {
  3934. wonderTypes[temp[t].wonder_type] = temp[t].full_name;
  3935. }
  3936. }
  3937. temp = JSON.parse(text).json.data.buildable_wonders;
  3938. for (var x in temp) {
  3939. if (temp.hasOwnProperty(x)) {
  3940. wonderTypes[x] = temp[x].name;
  3941. }
  3942. }
  3943. saveValue(MID + "_wonderTypes", JSON.stringify(wonderTypes));
  3944. } catch (error) {
  3945. errorHandling(error, "getWorldWonderTypes");
  3946. }
  3947. }
  3948. });
  3949. }
  3950.  
  3951. function getWorldWonders() {
  3952. $.ajax({
  3953. type: "GET",
  3954. 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 +
  3955. "%7D&_=" + uw.Game.server_time
  3956. });
  3957. }
  3958.  
  3959. var WorldWonderRanking = {
  3960. activate: function () {
  3961. if ($('#dio_wonder_ranking').get(0)) {
  3962. $('#dio_wonder_ranking').remove();
  3963. }
  3964. $('<style id="dio_wonder_ranking" type="text/css"> .wonder_ranking { display: none; } </style>').appendTo('head');
  3965. },
  3966. deactivate: function () {
  3967. if ($('#dio_wonder_ranking').get(0)) {
  3968. $('#dio_wonder_ranking').remove();
  3969. }
  3970. $('<style id="dio_wonder_ranking" type="text/css"> .wonder_ranking { display: block; } </style>').appendTo('head');
  3971. },
  3972. change: function (html) {
  3973. if ($('#ranking_inner tr', html)[0].children.length !== 1) { // world wonders exist?
  3974. try {
  3975. var ranking = {}, temp_ally, temp_ally_id, temp_ally_link;
  3976.  
  3977. // Save world wonder ranking into array
  3978. $('#ranking_inner tr', html).each(function () {
  3979. try {
  3980. if (this.children[0].innerHTML) {
  3981. temp_ally = this.children[1].children[0].innerHTML; // das hier
  3982.  
  3983. temp_ally_id = this.children[1].children[0].onclick.toString();
  3984. temp_ally_id = temp_ally_id.substring(temp_ally_id.indexOf(",") + 1);
  3985. temp_ally_id = temp_ally_id.substring(0, temp_ally_id.indexOf(")"));
  3986.  
  3987. temp_ally_link = this.children[1].innerHTML;
  3988.  
  3989. } else {
  3990. //World wonder name
  3991. var wonder_name = this.children[3].children[0].innerHTML;
  3992.  
  3993. for (var w in wonderTypes) {
  3994. if (wonderTypes.hasOwnProperty(w)) {
  3995. if (wonder_name == wonderTypes[w]) {
  3996. var level = this.children[4].innerHTML, // world wonder level
  3997. ww_data = JSON.parse(atob(this.children[3].children[0].href.split("#")[1])), wonder_link;
  3998. //console.log(ww_data);
  3999.  
  4000. if (!ranking.hasOwnProperty(level)) {
  4001. // add wonder types
  4002. ranking[level] = {
  4003. colossus_of_rhodes: {},
  4004. great_pyramid_of_giza: {},
  4005. hanging_gardens_of_babylon: {},
  4006. lighthouse_of_alexandria: {},
  4007. mausoleum_of_halicarnassus: {},
  4008. statue_of_zeus_at_olympia: {},
  4009. temple_of_artemis_at_ephesus: {}
  4010. };
  4011. }
  4012.  
  4013. if (!ranking[level][w].hasOwnProperty(temp_ally_id)) {
  4014. ranking[level][w][temp_ally_id] = {}; // add alliance array
  4015. }
  4016. // island coordinates of the world wonder:
  4017. ranking[level][w][temp_ally_id].ix = ww_data.ix;
  4018. ranking[level][w][temp_ally_id].iy = ww_data.iy;
  4019. ranking[level][w][temp_ally_id].sea = this.children[5].innerHTML; // world wonder sea
  4020.  
  4021. wonder_link = this.children[3].innerHTML;
  4022. if (temp_ally.length > 15) {
  4023. temp_ally = temp_ally.substring(0, 15) + '.';
  4024. }
  4025. wonder_link = wonder_link.substr(0, wonder_link.indexOf(">") + 1) + temp_ally + '</a>';
  4026.  
  4027. ranking[level][w][temp_ally_id].ww_link = wonder_link;
  4028.  
  4029. // other data of the world wonder
  4030. ranking[level][w][temp_ally_id].ally_link = temp_ally_link;
  4031. ranking[level][w][temp_ally_id].ally_name = temp_ally; // alliance name
  4032. ranking[level][w][temp_ally_id].name = wonder_name; // world wonder name
  4033.  
  4034. // Save wonder coordinates for wonder icons on map
  4035. if (!wonder.map[w]) {
  4036. wonder.map[w] = {};
  4037. }
  4038. wonder.map[w][ww_data.ix + "_" + ww_data.iy] = level;
  4039. saveValue(WID + "_wonder", JSON.stringify(wonder));
  4040.  
  4041. }
  4042. }
  4043. }
  4044. }
  4045. } catch (error) {
  4046. errorHandling(error, "WorldWonderRanking.change(function)");
  4047. }
  4048. });
  4049.  
  4050. if ($('#ranking_table_wrapper').get(0)) {
  4051. $('#ranking_fixed_table_header').get(0).innerHTML = '<tr>' +
  4052. '<td style="width:10px">#</td>' +
  4053. '<td>Colossus</td>' +
  4054. '<td>Pyramid</td>' +
  4055. '<td>Garden</td>' +
  4056. '<td>Lighthouse</td>' +
  4057. '<td>Mausoleum</td>' +
  4058. '<td>Statue</td>' +
  4059. '<td>Temple</td>' +
  4060. '</tr>';
  4061.  
  4062. $('#ranking_fixed_table_header').css({
  4063. tableLayout: 'fixed',
  4064. width: '100%',
  4065. //paddingLeft: '0px',
  4066. paddingRight: '15px'
  4067. });
  4068.  
  4069. var ranking_substr = '', z = 0;
  4070. for (var level = 10; level >= 1; level--) {
  4071. if (ranking.hasOwnProperty(level)) {
  4072. var complete = "";
  4073. if (level == 10) {
  4074. complete = "background: rgba(255, 236, 108, 0.36);";
  4075. }
  4076.  
  4077. // Alternate table background color
  4078. if (z === 0) {
  4079. ranking_substr += '<tr class="game_table_odd" style="' + complete + '"><td style="border-right: 1px solid #d0be97;">' + level + '</td>';
  4080. z = 1;
  4081. } else {
  4082. ranking_substr += '<tr class="game_table_even" style="' + complete + '"><td style="border-right: 1px solid #d0be97;">' + level + '</td>';
  4083. z = 0;
  4084. }
  4085. for (var w in ranking[level]) {
  4086. if (ranking[level].hasOwnProperty(w)) {
  4087. ranking_substr += '<td>';
  4088.  
  4089. for (var a in ranking[level][w]) {
  4090. if (ranking[level][w].hasOwnProperty(a)) {
  4091. ranking_substr += '<nobr>' + ranking[level][w][a].ww_link + '</nobr><br />'; // ww link
  4092. }
  4093. }
  4094. ranking_substr += '</td>';
  4095. }
  4096. }
  4097. ranking_substr += '</tr>';
  4098. }
  4099. }
  4100.  
  4101. var ranking_str = '<table id="ranking_endless_scroll" class="game_table" cellspacing="0"><tr>' +
  4102. '<td style="width:10px;border-right: 1px solid #d0be97;"></td>' +
  4103. '<td><div class="dio_wonder" style="background:' + worldWonderIcon.colossus_of_rhodes + ';margin-left:26px"></div></td>' + // Colossus
  4104. '<td><div class="dio_wonder" style="background:' + worldWonderIcon.great_pyramid_of_giza + ';margin-left:19px"></div></td>' + // Pyramid
  4105. '<td><div class="dio_wonder" style="background:' + worldWonderIcon.hanging_gardens_of_babylon + ';margin-left:19px"></div></td>' + // Garden
  4106. '<td><div class="dio_wonder" style="background:' + worldWonderIcon.lighthouse_of_alexandria + ';margin-left:24px"></div></td>' + // Lighthouse
  4107. '<td><div class="dio_wonder" style="background:' + worldWonderIcon.mausoleum_of_halicarnassus + ';margin-left:25px"></div></td>' + // Mausoleum
  4108. '<td><div class="dio_wonder" style="background:' + worldWonderIcon.statue_of_zeus_at_olympia + ';margin-left:25px"></div></td>' + // Statue
  4109. '<td><div class="dio_wonder" style="background:' + worldWonderIcon.temple_of_artemis_at_ephesus + ';margin-left:22px"></div></td>' + // Temple
  4110. '</tr>' + ranking_substr + '</table>';
  4111.  
  4112. $('#ranking_table_wrapper').get(0).innerHTML = ranking_str;
  4113.  
  4114. $('#ranking_endless_scroll .dio_wonder').css({
  4115. width: "65px", height: "60px",
  4116. backgroundSize: "auto 100%",
  4117. backgroundPosition: "64px 0px"
  4118. });
  4119.  
  4120. $('#ranking_endless_scroll').css({
  4121. tableLayout: 'fixed',
  4122. width: '100%',
  4123. overflowY: 'auto',
  4124. overflowX: 'hidden',
  4125. fontSize: '0.7em',
  4126. lineHeight: '2'
  4127. });
  4128. $('#ranking_endless_scroll tbody').css({
  4129. verticalAlign: 'text-top'
  4130. });
  4131.  
  4132. $('#ranking_table_wrapper img').css({
  4133. width: "60px"
  4134. });
  4135. $('#ranking_table_wrapper').css({
  4136. overflowY: 'scroll'
  4137. });
  4138. }
  4139. } catch (error) {
  4140. errorHandling(error, "WorldWonderRanking.change");
  4141. }
  4142. }
  4143. if ($('.wonder_ranking').get(0)) {
  4144. $('.wonder_ranking').get(0).style.display = "block";
  4145. }
  4146. }
  4147. };
  4148.  
  4149. /*******************************************************************************************************************************
  4150. * World Wonder
  4151. * ----------------------------------------------------------------------------------------------------------------------------
  4152. * | ● click adjustment
  4153. * | ● Share calculation (= ratio of player points to alliance points)
  4154. * | ● Resources calculation & counter (stores amount)
  4155. * | ● Adds missing previous & next buttons on finished world wonders (better browsing through world wonders)
  4156. * ----------------------------------------------------------------------------------------------------------------------------
  4157. *******************************************************************************************************************************/
  4158.  
  4159. // getPointRatio: Default
  4160. function getPointRatioFromAllianceProfile() {
  4161. if (AID) {
  4162. $.ajax({
  4163. type: "GET",
  4164. 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 +
  4165. '%2C%22nlreq_id%22%3A' + uw.Game.notification_last_requested_id + '%7D&_=' + uw.Game.server_time,
  4166. success: function (text) {
  4167. try {
  4168. text = text.substr(text.indexOf("/li") + 14).substr(0, text.indexOf("\ "));
  4169. var AP = parseInt(text, 10);
  4170. wonder.ratio[AID] = 100 / AP * uw.Game.player_points;
  4171. saveValue(WID + "_wonder", JSON.stringify(wonder));
  4172. } catch (error) {
  4173. errorHandling(error, "getPointRatioFromAllianceProfile");
  4174. }
  4175. }
  4176. });
  4177. } else {
  4178. wonder.ratio[AID] = -1;
  4179. saveValue(WID + "_wonder", JSON.stringify(wonder));
  4180. }
  4181. }
  4182.  
  4183. function getPointRatioFromAllianceRanking() {
  4184. try {
  4185. if (AID && $('.current_player .r_points').get(0)) {
  4186. wonder.ratio[AID] = 100 / parseInt($('.current_player .r_points').get(0).innerHTML, 10) * uw.Game.player_points;
  4187. saveValue(WID + "_wonder", JSON.stringify(wonder));
  4188. }
  4189. } catch (error) {
  4190. errorHandling(error, "getPointRatioFromAllianceRaking");
  4191. }
  4192. }
  4193.  
  4194. function getPointRatioFromAllianceMembers() {
  4195. try {
  4196. var ally_points = 0;
  4197. $('#ally_members_body tr').each(function () {
  4198. ally_points += parseInt($(this).children().eq(2).text(), 10) || 0;
  4199. });
  4200. wonder.ratio[AID] = 100 / ally_points * uw.Game.player_points;
  4201. saveValue(WID + "_wonder", JSON.stringify(wonder));
  4202. } catch (error) {
  4203. errorHandling(error, "getPointRatioFromAllianceMembers");
  4204. }
  4205. }
  4206.  
  4207. var WorldWonderCalculator = {
  4208. activate: function () {
  4209. // Style
  4210. $('<style id="dio_wonder_calculator"> ' +
  4211. '.wonder_controls { height:380px; } ' +
  4212. '.wonder_controls .wonder_progress { margin: 0px auto 5px; } ' +
  4213. '.wonder_controls .wonder_header { text-align:left; margin:10px -8px 12px 3px; }' +
  4214. '.wonder_controls .build_wonder_icon { top:25px !important; }' +
  4215. '.wonder_controls .wonder_progress_bar { top:54px; }' +
  4216. '.wonder_controls .trade fieldset { float:right; } ' +
  4217. '.wonder_controls .wonder_res_container { right:29px; } ' +
  4218. '.wonder_controls .ww_ratio {position:relative; height:auto; } ' +
  4219. '.wonder_controls fieldset.next_level_res { height:auto; } ' +
  4220. '.wonder_controls .town-capacity-indicator { margin-top:0px; } ' +
  4221.  
  4222. '.wonder_controls .ww_ratio .progress { line-height:1; color:white; font-size:0.8em; } ' +
  4223. '.wonder_controls .ww_perc { position:absolute; width:242px; text-align:center; } ' +
  4224. '.wonder_controls .indicator3 { z-index:0; } ' +
  4225. '.wonder_controls .indicator3.red { background-position:right -203px; height:10px; width:242px; } ' +
  4226. '.wonder_controls .indicator3.green { background-position:right -355px; height:10px; width:242px; } ' +
  4227. '.wonder_controls .all_res { background:url(https://gpall.innogamescdn.com/images/game/layout/resources_2.32.png) no-repeat 0 -90px; width:30px; height:30px; margin:0 auto; margin-left:5px; } ' +
  4228. '.wonder_controls .town-capacity-indicator { margin-top:0px; } ' +
  4229. '</style>').appendTo('head');
  4230. },
  4231. deactivate: function () {
  4232. $('#dio_wonder_calculator').remove();
  4233. }
  4234. };
  4235.  
  4236. // TODO: Split function...
  4237. function getResWW() {
  4238. try {
  4239. var wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_WONDERS);
  4240.  
  4241. for (var e in wndArray) {
  4242. if (wndArray.hasOwnProperty(e)) {
  4243. var wndID = "#gpwnd_" + wndArray[e].getID() + " ";
  4244.  
  4245. if ($(wndID + '.wonder_progress').get(0)) {
  4246. var res = 0,
  4247. ww_share = {total: {share: 0, sum: 0}, stage: {share: 0, sum: 0}},
  4248. ww_type = $(wndID + '.finished_image_small').attr('src').split("/")[6].split("_")[0], // Which world wonder?
  4249. res_stages = [2, 4, 6, 10, 16, 28, 48, 82, 140, 238], // Rohstoffmenge pro Rohstofftyp in 100.000 Einheiten
  4250. stage = parseInt($(wndID + '.wonder_expansion_stage span').get(0).innerHTML.split("/")[0], 10) + 1, // Derzeitige Füllstufe
  4251. speed = uw.Game.game_speed;
  4252.  
  4253. wonder.storage[AID] = wonder.storage[AID] || {};
  4254.  
  4255. wonder.storage[AID][ww_type] = wonder.storage[AID][ww_type] || {};
  4256.  
  4257. wonder.storage[AID][ww_type][stage] = wonder.storage[AID][ww_type][stage] || 0;
  4258.  
  4259. if (!$(wndID + '.ww_ratio').get(0)) {
  4260. $('<fieldset class="ww_ratio"></fieldset>').appendTo(wndID + '.wonder_res_container .trade');
  4261. $(wndID + '.wonder_header').prependTo(wndID + '.wonder_progress');
  4262. $(wndID + '.wonder_res_container .send_res').insertBefore(wndID + '.wonder_res_container .next_level_res');
  4263. }
  4264.  
  4265. for (var d in res_stages) {
  4266. if (res_stages.hasOwnProperty(d)) {
  4267. ww_share.total.sum += res_stages[d];
  4268. }
  4269. }
  4270.  
  4271. ww_share.total.sum *= speed * 300000;
  4272.  
  4273. ww_share.total.share = parseInt(wonder.ratio[AID] * (ww_share.total.sum / 100), 10);
  4274.  
  4275. ww_share.stage.sum = speed * res_stages[stage - 1] * 300000;
  4276.  
  4277. ww_share.stage.share = parseInt(wonder.ratio[AID] * (ww_share.stage.sum / 100), 10); // ( 3000 = 3 Rohstofftypen * 100000 Rohstoffe / 100 Prozent)
  4278. setResWW(stage, ww_type, ww_share, wndID);
  4279.  
  4280.  
  4281. $(wndID + '.wonder_res_container .send_resources_btn').click(function (e) {
  4282. try {
  4283. wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_wood input:text').get(0).value, 10);
  4284. wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_stone input:text').get(0).value, 10);
  4285. wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_iron input:text').get(0).value, 10);
  4286.  
  4287. setResWW(stage, ww_type, ww_share, wndID);
  4288. saveValue(WID + "_wonder", JSON.stringify(wonder));
  4289. } catch (error) {
  4290. errorHandling(error, "getResWW_Click");
  4291. }
  4292. });
  4293.  
  4294. } else {
  4295. $('<div class="prev_ww pos_Y"></div><div class="next_ww pos_Y"></div>').appendTo(wndID + '.wonder_controls');
  4296.  
  4297. $(wndID + '.wonder_finished').css({width: '100%'});
  4298.  
  4299. $(wndID + '.pos_Y').css({
  4300. top: '-266px'
  4301. });
  4302. }
  4303. }
  4304. }
  4305. } catch (error) {
  4306. errorHandling(error, "getResWW");
  4307. }
  4308. }
  4309.  
  4310. function setResWW(stage, ww_type, ww_share, wndID) {
  4311. try {
  4312. var stage_width, total_width, res_total = 0, stage_color = "red", total_color = "red";
  4313.  
  4314. for (var z in wonder.storage[AID][ww_type]) {
  4315. if (wonder.storage[AID][ww_type].hasOwnProperty(z)) {
  4316. res_total += wonder.storage[AID][ww_type][z];
  4317. }
  4318. }
  4319.  
  4320. // Progressbar
  4321. if (ww_share.stage.share > wonder.storage[AID][ww_type][stage]) {
  4322. stage_width = (242 / ww_share.stage.share) * wonder.storage[AID][ww_type][stage];
  4323. stage_color = "red";
  4324. } else {
  4325. stage_width = 242;
  4326. stage_color = "green"
  4327. }
  4328. if (ww_share.total.share > res_total) {
  4329. total_color = "red";
  4330. total_width = (242 / ww_share.total.share) * res_total;
  4331. } else {
  4332. total_width = 242;
  4333. total_color = "green"
  4334. }
  4335.  
  4336. $(wndID + '.ww_ratio').get(0).innerHTML = "";
  4337. $(wndID + '.ww_ratio').append(
  4338. '<legend>' + getText("labels", "leg") + ' (<span style="color:#090">' + (Math.round(wonder.ratio[AID] * 100) / 100) + '%</span>):</legend>' +
  4339. '<div class="town-capacity-indicator">' +
  4340. '<div class="icon all_res"></div>' +
  4341. '<div id="ww_town_capacity_stadium" class="tripple-progress-progressbar">' +
  4342. '<div class="border_l"></div><div class="border_r"></div><div class="body"></div>' +
  4343. '<div class="progress overloaded">' +
  4344. '<div class="indicator3 ' + stage_color + '" style="width:' + stage_width + 'px"></div>' +
  4345. '<span class="ww_perc">' + Math.round(wonder.storage[AID][ww_type][stage] / ww_share.stage.share * 100) + '%</span>' +
  4346. '</div>' +
  4347. '<div class="amounts">' + getText("labels", "stg") + ': <span class="curr">' + pointNumber(wonder.storage[AID][ww_type][stage]) + '</span> / ' +
  4348. '<span class="max">' + pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) + '</span></div>' +
  4349. '</div></div>' +
  4350. '<div class="town-capacity-indicator">' +
  4351. '<div class="icon all_res"></div>' +
  4352. '<div id="ww_town_capacity_total" class="tripple-progress-progressbar">' +
  4353. '<div class="border_l"></div><div class="border_r"></div><div class="body"></div>' +
  4354. '<div class="progress overloaded">' +
  4355. '<div class="indicator3 ' + total_color + '" style="width:' + total_width + 'px;"></div>' +
  4356. '<span class="ww_perc">' + Math.round(res_total / ww_share.total.share * 100) + '%</span>' +
  4357. '</div>' +
  4358. '<div class="amounts">' + getText("labels", "tot") + ': <span class="curr">' + pointNumber(res_total) + '</span> / ' +
  4359. '<span class="max">' + pointNumber((Math.round(ww_share.total.share / 1000) * 1000)) + '</span></div>' +
  4360. '</div></div>');
  4361.  
  4362. $(wndID + '.ww_ratio').tooltip(
  4363. "<table style='border-spacing:0px; text-align:right' cellpadding='5px'><tr>" +
  4364. "<td align='right' style='border-right: 1px solid;border-bottom: 1px solid'></td>" +
  4365. "<td style='border-right: 1px solid; border-bottom: 1px solid'><span class='bbcodes_player bold'>(" + (Math.round((wonder.ratio[AID]) * 100) / 100) + "%)</span></td>" +
  4366. "<td style='border-bottom: 1px solid'><span class='bbcodes_ally bold'>(100%)</span></td></tr>" +
  4367. "<tr><td class='bold' style='border-right:1px solid;text-align:center'>" + getText("labels", "stg") + "&nbsp;" + stage + "</td>" +
  4368. "<td style='border-right: 1px solid'>" + pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) + "</td>" +
  4369. "<td>" + pointNumber(Math.round(ww_share.stage.sum / 1000) * 1000) + "</td></tr>" +
  4370. "<tr><td class='bold' style='border-right:1px solid;text-align:center'>" + getText("labels", "tot") + "</td>" +
  4371. "<td style='border-right: 1px solid'>" + pointNumber(Math.round(ww_share.total.share / 1000) * 1000) + "</td>" +
  4372. "<td>" + pointNumber(Math.round(ww_share.total.sum / 1000) * 1000) + "</td>" +
  4373. "</tr></table>");
  4374.  
  4375. } catch (error) {
  4376. errorHandling(error, "setResWW");
  4377. }
  4378. }
  4379.  
  4380. // Adds points to numbers
  4381. function pointNumber(number) {
  4382. var sep;
  4383. if (LID === "de") {
  4384. sep = ".";
  4385. } else {
  4386. sep = ",";
  4387. }
  4388.  
  4389. number = number.toString();
  4390. if (number.length > 3) {
  4391. var mod = number.length % 3;
  4392. var output = (mod > 0 ? (number.substring(0, mod)) : '');
  4393.  
  4394. for (var i = 0; i < Math.floor(number.length / 3); i++) {
  4395. if ((mod == 0) && (i == 0)) {
  4396. output += number.substring(mod + 3 * i, mod + 3 * i + 3);
  4397. } else {
  4398. output += sep + number.substring(mod + 3 * i, mod + 3 * i + 3);
  4399. }
  4400. }
  4401. number = output;
  4402. }
  4403. return number;
  4404. }
  4405.  
  4406. /*******************************************************************************************************************************
  4407. * Farming Village Overview
  4408. * ----------------------------------------------------------------------------------------------------------------------------
  4409. * | ● Color change on possibility of city festivals
  4410. * ----------------------------------------------------------------------------------------------------------------------------
  4411. * *****************************************************************************************************************************/
  4412.  
  4413. function changeResColor() {
  4414. var res, res_min, i = 0;
  4415. $('#fto_town_list .fto_resource_count :last-child').reverseList().each(function () {
  4416. if ($(this).parent().hasClass("stone")) {
  4417. res_min = 18000;
  4418. } else {
  4419. res_min = 15000;
  4420. }
  4421. res = parseInt(this.innerHTML, 10);
  4422. if ((res >= res_min) && !($(this).hasClass("town_storage_full"))) {
  4423. this.style.color = '#0A0';
  4424. }
  4425. if (res < res_min) {
  4426. this.style.color = '#000';
  4427. }
  4428. });
  4429. }
  4430.  
  4431. /********************************************************************************************************************************
  4432. * Conquest Info
  4433. * -----------------------------------------------------------------------------------------------------------------------------
  4434. * | ● Amount of supports und attacks in the conquest window
  4435. * | ● Layout adjustment (for reasons of clarity)
  4436. * | - TODO: conquest window of own cities
  4437. * -----------------------------------------------------------------------------------------------------------------------------
  4438. * ******************************************************************************************************************************/
  4439.  
  4440. function countMovements() {
  4441. var sup = 0, att = 0;
  4442. $('.tab_content #unit_movements .support').each(function () {
  4443. sup++;
  4444. });
  4445. $('.tab_content #unit_movements .attack_land, .tab_content #unit_movements .attack_sea, .tab_content #unit_movements .attack_takeover').each(function () {
  4446. att++;
  4447. });
  4448.  
  4449. var str = "<div id='move_counter' style=''><div style='float:left;margin-right:5px;'></div>" +
  4450. "<div class='movement def'></div>" +
  4451. "<div class='movement' style='color:green;'> " + sup + "</div>" +
  4452. "<div class='movement off'> </div>" +
  4453. "<div style='color:red;'> " + att + "</div></div>" +
  4454. "<hr class='move_hr'>";
  4455.  
  4456. if ($('.gpwindow_content .tab_content .bold').get(0)) {
  4457. $('.gpwindow_content .tab_content .bold').append(str);
  4458. } else {
  4459. $('.gpwindow_content h4:eq(1)').append(str);
  4460.  
  4461. // TODO: set player link ?
  4462. /*
  4463. $('#unit_movements li div').each(function(){
  4464.  
  4465. //console.log(this.innerHTML);
  4466. });
  4467. */
  4468. }
  4469.  
  4470. $('<style id="dio_conquest"> ' +
  4471. '.move_hr { margin:7px 0px 0px 0px; background-color:#5F5242; height:2px; border:0px solid; } ' +
  4472. // Smaller movements
  4473. '#unit_movements { font-size: 0.80em; } ' +
  4474. '#unit_movements .incoming { width:150px; height:45px; float:left; } ' +
  4475. // Counter
  4476. '#move_counter { position:relative; width:100px; margin-top:-16px; left: 40%; } ' +
  4477. '#move_counter .movement { float:left; margin:0px 5px 0px 0px; height:18px; width:18px; position:relative; } ' +
  4478. '#move_counter .def { background:url(https://gpall.innogamescdn.com/images/game/place/losts.png); background-position:0 -36px; } ' +
  4479. '#move_counter .off { background:url(https://gpall.innogamescdn.com/images/game/place/losts.png); background-position:0 0px; }' +
  4480. '</style>').appendTo("head");
  4481.  
  4482. /*
  4483. $('#unit_movements div').each(function(){
  4484. if($(this).attr('class') === "unit_movements_arrow"){
  4485. // delete placeholder for arrow of outgoing movements (there are no outgoing movements)
  4486. if(!this.style.background) { this.remove(); }
  4487. } else {
  4488. // realign texts
  4489. $(this).css({
  4490. margin: '3px',
  4491. paddingLeft: '3px'
  4492. });
  4493. }
  4494. });
  4495. */
  4496. }
  4497.  
  4498. /*******************************************************************************************************************************
  4499. * Town window
  4500. * ----------------------------------------------------------------------------------------------------------------------------
  4501. * | ● TownTabHandler (trade, attack, support,...)
  4502. * | ● Sent units box
  4503. * | ● Short duration: Display of 30% troop speed improvement in attack/support tab
  4504. * | ● Trade options:
  4505. * | - Ressource marks on possibility of city festivals
  4506. * | - Percentual Trade: Trade button
  4507. * | - Recruiting Trade: Selection boxes (ressource ratio of unit type + share of the warehouse capacity of the target town)
  4508. * ----------------------------------------------------------------------------------------------------------------------------
  4509. *******************************************************************************************************************************/
  4510. var arrival_interval = {};
  4511. // TODO: Change both functions in MultipleWindowHandler()
  4512. function TownTabHandler(action) {
  4513. var wndArray, wndID, wndA;
  4514. wndArray = Layout.wnd.getOpen(uw.Layout.wnd.TYPE_TOWN);
  4515. //console.log(wndArray);
  4516. for (var e in wndArray) {
  4517. if (wndArray.hasOwnProperty(e)) {
  4518. //console.log(wndArray[e].getHandler());
  4519. wndA = wndArray[e].getAction();
  4520. wndID = "#gpwnd_" + wndArray[e].getID() + " ";
  4521. if (!$(wndID).get(0)) {
  4522. wndID = "#gpwnd_" + (wndArray[e].getID() + 1) + " ";
  4523. }
  4524. //console.log(wndID);
  4525. if (wndA === action) {
  4526. switch (action) {
  4527. case "trading":
  4528. if ($(wndID + '#trade_tab').get(0)) {
  4529. if (!$(wndID + '.rec_trade').get(0) && DATA.options.rec) {
  4530. addRecTrade(wndID);
  4531. }
  4532. console.log(DATA.options.per);
  4533. if (!$(wndID + '.btn_trade').get(0) && DATA.options.per) {
  4534. addPercentTrade(wndID, false);
  4535. }
  4536. }
  4537. //addTradeMarks(wndID, 15, 18, 15, "red"); // town festival
  4538. break;
  4539. case "support":
  4540. case "attack":
  4541. //if(!arrival_interval[wndID]){
  4542. if (DATA.options.way && !($('.js-casted-powers-viewport .unit_movement_boost').get(0) || $(wndID + '.short_duration').get(0))) {
  4543. //if(arrival_interval[wndID]) console.log("add " + wndID);
  4544. ShortDuration.add(wndID);
  4545. }
  4546. if (DATA.options.sen) {
  4547. SentUnits.add(wndID, action);
  4548. }
  4549. //}
  4550. break;
  4551. case "rec_mark":
  4552. //addTradeMarks(wndID, 15, 18, 15, "lime");
  4553. break;
  4554. }
  4555. }
  4556. }
  4557. }
  4558. }
  4559.  
  4560. function WWTradeHandler() {
  4561. var wndArray, wndID, wndA;
  4562. wndArray = uw.GPWindowMgr.getOpen(uw.GPWindowMgr.TYPE_WONDERS);
  4563. for (var e in wndArray) {
  4564. if (wndArray.hasOwnProperty(e)) {
  4565. wndID = "#gpwnd_" + wndArray[e].getID() + " ";
  4566. if (DATA.options.per && !($(wndID + '.btn_trade').get(0) || $(wndID + '.next_building_phase').get(0) || $(wndID + '#ww_time_progressbar').get(0))) {
  4567. addPercentTrade(wndID, true);
  4568. }
  4569. }
  4570. }
  4571. }
  4572.  
  4573. /*******************************************************************************************************************************
  4574. * ● Sent units box
  4575. *******************************************************************************************************************************/
  4576. var SentUnits = {
  4577. activate: function () {
  4578. $.Observer(GameEvents.command.send_unit).subscribe('DIO_SEND_UNITS', function (e, data) {
  4579. for (var z in data.params) {
  4580. if (data.params.hasOwnProperty(z) && (data.sending_type !== "")) {
  4581. if (uw.GameData.units[z]) {
  4582. sentUnitsArray[data.sending_type][z] = (sentUnitsArray[data.sending_type][z] == undefined ? 0 : sentUnitsArray[data.sending_type][z]);
  4583. sentUnitsArray[data.sending_type][z] += data.params[z];
  4584. }
  4585. }
  4586. }
  4587. //SentUnits.update(data.sending_type); ????
  4588. });
  4589. },
  4590. deactivate: function () {
  4591. $.Observer(GameEvents.command.send_unit).unsubscribe('DIO_SEND_UNITS');
  4592. },
  4593. add: function (wndID, action) {
  4594. if (!$(wndID + '.sent_units_box').get(0)) {
  4595. $('<div class="game_inner_box sent_units_box ' + action + '"><div class="game_border ">' +
  4596. '<div class="game_border_top"></div><div class="game_border_bottom"></div><div class="game_border_left"></div><div class="game_border_right"></div>' +
  4597. '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
  4598. '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
  4599. '<div class="game_header bold">' +
  4600. '<div class="icon_sent townicon_' + (action == "attack" ? "lo" : "ld") + '"></div><span>' + getText("labels", "lab") + ' (' + (action == "attack" ? "OFF" : "DEF") + ')</span>' +
  4601. '</div>' +
  4602. '<div class="troops"><div class="units_list"></div><hr style="width: 172px;border: 1px solid rgb(185, 142, 93);margin: 3px 0px 2px -1px;">' +
  4603. '<div id="btn_sent_units_reset" class="button_new">' +
  4604. '<div class="left"></div>' +
  4605. '<div class="right"></div>' +
  4606. '<div class="caption js-caption">' + getText("buttons", "res") + '<div class="effect js-effect"></div></div>' +
  4607. '</div>' +
  4608. '</div></div>').appendTo(wndID + '.attack_support_window');
  4609.  
  4610. SentUnits.update(action);
  4611.  
  4612. $(wndID + '.icon_sent').css({
  4613. height: '20px',
  4614. marginTop: '-2px',
  4615. width: '20px',
  4616. backgroundPositionY: '-26px',
  4617. paddingLeft: '0px',
  4618. marginLeft: '0px'
  4619. });
  4620.  
  4621. $(wndID + '.sent_units_box').css({
  4622. position: 'absolute',
  4623. right: '0px',
  4624. bottom: '16px',
  4625. width: '192px'
  4626. });
  4627. $(wndID + '.troops').css({padding: '6px 0px 6px 6px'});
  4628.  
  4629. $(wndID + '#btn_sent_units_reset').click(function () {
  4630. // Overwrite old array
  4631. sentUnitsArray[action] = {};
  4632.  
  4633. SentUnits.update(action);
  4634. });
  4635. }
  4636. },
  4637. update: function (action) {
  4638. try {
  4639. // Remove old unit list
  4640. $('.sent_units_box.' + action + ' .units_list').each(function () {
  4641. this.innerHTML = "";
  4642. });
  4643. // Add new unit list
  4644. for (var x in sentUnitsArray[action]) {
  4645. if (sentUnitsArray[action].hasOwnProperty(x)) {
  4646. if ((sentUnitsArray[action][x] || 0) > 0) {
  4647. $('.sent_units_box.' + action + ' .units_list').each(function () {
  4648. $(this).append('<div class="unit_icon25x25 ' + x +
  4649. (sentUnitsArray[action][x] >= 1000 ? (sentUnitsArray[action][x] >= 10000 ? " five_digit_number" : " four_digit_number") : "") + '">' +
  4650. '<span class="count text_shadow">' + sentUnitsArray[action][x] + '</span>' +
  4651. '</div>');
  4652. });
  4653. }
  4654. }
  4655. }
  4656. saveValue(WID + "_sentUnits", JSON.stringify(sentUnitsArray));
  4657. } catch (error) {
  4658. errorHandling(error, "updateSentUnitsBox");
  4659. }
  4660. }
  4661. };
  4662.  
  4663. /*******************************************************************************************************************************
  4664. * ● Short duration
  4665. *******************************************************************************************************************************/
  4666.  
  4667. var DurationCalculator = {
  4668. activate: function () {
  4669. var speedBoosterSprite = "https://diotools.de/images/game/speed_booster.png";
  4670.  
  4671. $('<style id="dio_duration_calculator_style">' +
  4672. '.dio_speed_booster { border:1px solid #724B08; border-spacing: 0px;} ' +
  4673. '.dio_speed_booster td { border:0; padding:2px; } ' +
  4674. '.dio_speed_booster .checkbox_new { margin: 4px 0px 1px 3px; } ' +
  4675. '.dio_speed_booster .odd { background: url("https://gpall.innogamescdn.com/images/game/border/brown.png") repeat scroll 0% 0% transparent; } ' +
  4676. '.dio_speed_booster .even { background: url("https://gpall.innogamescdn.com/images/game/border/odd.png") repeat scroll 0% 0% transparent; } ' +
  4677. '.booster_icon { width:20px; height:20px; background-image:url(' + speedBoosterSprite + ');} ' +
  4678. '.booster_icon.improved_speed { background-position:0 0; } ' +
  4679. '.booster_icon.cartography { background-position:-20px 0; } ' +
  4680. '.booster_icon.meteorology { background-position:-40px 0; } ' +
  4681. '.booster_icon.lighthouse { background-position:-60px 0; } ' +
  4682. '.booster_icon.set_sail { background-position:-80px 0; } ' +
  4683. '.booster_icon.atalanta { background-position:-100px 0; } ' +
  4684. '</style>').appendTo('head');
  4685. },
  4686. deactivate: function () {
  4687. $('#dio_duration_calculator_style').remove();
  4688. },
  4689. add: function (wndID, data) {
  4690.  
  4691. }
  4692. };
  4693.  
  4694.  
  4695. // TODO : Style Umstellen!
  4696. var ShortDuration = {
  4697. activate: function () {
  4698.  
  4699. },
  4700. deactivate: function () {
  4701.  
  4702. },
  4703. add: function (wndID) {
  4704. //console.log($(wndID + ".duration_container").get(0));
  4705. try {
  4706. var tooltip = (LANG.hasOwnProperty(LID) ? getText("labels", "improved_movement") : "") + " (+30% " + DM.getl10n("barracks", "tooltips").speed.trim() + ")";
  4707.  
  4708. var speedBoosterSprite = "https://diotools.de/images/game/speed_booster.png";
  4709.  
  4710. $('<table class="dio_duration">' +
  4711. '<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>' +
  4712. '<tr class="short_duration_row" style="color:darkgreen">' +
  4713. '<td>&nbsp;╚&gt;&nbsp;</td><td><span class="short_duration">~0:00:00</span></td>' +
  4714. '<td>&nbsp;&nbsp;&nbsp;╚&gt;</td><td><span class="short_arrival">~00:00:00</span></td>' +
  4715. '<td class="short_icon"></td><td></td></tr>' +
  4716. '</table>').prependTo(wndID + ".duration_container");
  4717.  
  4718. /*
  4719. $('<style id="dio_speed_booster_style">' +
  4720. '.dio_speed_booster { border:1px solid #724B08; border-spacing: 0px;} ' +
  4721. '.dio_speed_booster td { border:0; padding:2px; } ' +
  4722. '.dio_speed_booster .checkbox_new { margin: 4px 0px 1px 3px; } ' +
  4723. '.dio_speed_booster .odd { background: url("https://gpall.innogamescdn.com/images/game/border/brown.png") repeat scroll 0% 0% transparent; } ' +
  4724. '.dio_speed_booster .even { background: url("https://gpall.innogamescdn.com/images/game/border/odd.png") repeat scroll 0% 0% transparent; } ' +
  4725. '.booster_icon { width:20px; height:20px; background-image:url(' + speedBoosterSprite + ');} ' +
  4726. '.booster_icon.improved_speed { background-position:0 0; } ' +
  4727. '.booster_icon.cartography { background-position:-20px 0; } ' +
  4728. '.booster_icon.meteorology { background-position:-40px 0; } ' +
  4729. '.booster_icon.lighthouse { background-position:-60px 0; } ' +
  4730. '.booster_icon.set_sail { background-position:-80px 0; } ' +
  4731. '.booster_icon.atalanta { background-position:-100px 0; } ' +
  4732. '</style>').appendTo('head');
  4733.  
  4734. $('<table class="dio_speed_booster"><tr>' +
  4735. '<td class="odd"><div class="booster_icon improved_speed"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
  4736. '<td class="even"><div class="booster_icon cartography"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
  4737. '<td class="odd"><div class="booster_icon meteorology"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
  4738. '<td class="even"><div class="booster_icon lighthouse"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
  4739. '<td class="odd"><div class="booster_icon set_sail"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
  4740. '<td class="even"><div class="booster_icon atalanta"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
  4741. '</tr></table>').appendTo(wndID + ".duration_container");
  4742. */
  4743.  
  4744. $(wndID + ".nightbonus").appendTo(wndID + ".dio_night");
  4745. $(wndID + '.way_duration').appendTo(wndID + ".dio_way");
  4746. $(wndID + ".arrival_time").appendTo(wndID + ".dio_arrival");
  4747.  
  4748. // Style TODO: Umschreiben!
  4749. $(wndID + '.duration_container').css({
  4750. width: 'auto'
  4751. });
  4752. $(wndID + '.dio_duration').css({
  4753. borderSpacing: '0px',
  4754. marginBottom: '2px',
  4755. textAlign: 'right'
  4756. });
  4757. $(wndID + '.dio_way span,' + wndID + '.dio_arrival span').css({
  4758. padding: '0px 0px 0px 0px',
  4759. background: 'none'
  4760. });
  4761. $(wndID + '.short_icon').css({
  4762. padding: '20px 0px 0px 30px',
  4763. background: 'url(http://666kb.com/i/ck2c7eohpyfa3yczt.png) 11px -1px / 21px no-repeat',
  4764. WebkitFilter: 'hue-rotate(50deg)'
  4765. });
  4766. $(wndID + '.way_icon').css({
  4767. padding: '30px 0px 0px 30px',
  4768. background: 'transparent url(https://gpall.innogamescdn.com/images/game/towninfo/traveltime.png) no-repeat 0 0'
  4769. });
  4770. $(wndID + '.arrival_icon').css({
  4771. padding: '30px 0px 0px 30px',
  4772. background: 'transparent url(https://gpall.innogamescdn.com/images/game/towninfo/arrival.png) no-repeat 0 0'
  4773. });
  4774. $(wndID + '.max_booty').css({
  4775. padding: '0px 0px 0px 30px',
  4776. margin: '3px 0 4px 4px',
  4777. width: 'auto'
  4778. });
  4779. $(wndID + '.fast_boats_needed').css({
  4780. background: 'transparent url(http://s7.directupload.net/images/140724/4pvfuch8.png) no-repeat 0 0',
  4781. padding: '2px 10px 7px 24px',
  4782. margin: '0px 0px 0px 6px'
  4783. });
  4784. $(wndID + '.slow_boats_needed').css({
  4785. background: 'transparent url(http://s1.directupload.net/images/140724/b5xl8nmj.png) no-repeat 0 0',
  4786. padding: '2px 10px 7px 24px',
  4787. margin: '0px 0px 0px 6px'
  4788. });
  4789.  
  4790. // Tooltip
  4791. $(wndID + '.short_duration_row').tooltip(tooltip);
  4792.  
  4793. // Detection of changes
  4794. ShortDuration.change(wndID);
  4795. // $(wndID + '.way_duration').bind('DOMSubtreeModified', function(e) { console.log(e); }); // Alternative
  4796.  
  4797. } catch (error) {
  4798. errorHandling(error, "addShortDuration");
  4799. }
  4800. },
  4801. change: function (wndID) {
  4802. var duration = new MutationObserver(function (mutations) {
  4803. mutations.forEach(function (mutation) {
  4804. if (mutation.addedNodes[0]) {
  4805. //console.log(mutation);
  4806. ShortDuration.calculate(wndID);
  4807. }
  4808. });
  4809. });
  4810. if ($(wndID + '.way_duration').get(0)) {
  4811. duration.observe($(wndID + '.way_duration').get(0), {
  4812. attributes: false,
  4813. childList: true,
  4814. characterData: false
  4815. });
  4816. }
  4817. },
  4818. //$('<style> .duration_container { display: block !important } </style>').appendTo("head");
  4819. calculate: function (wndID) {
  4820. //console.log(wndID);
  4821. //console.log($(wndID + '.duration_container .way_duration').get(0));
  4822. try {
  4823. var setup_time = 900 / Game.game_speed,
  4824. duration_time = $(wndID + '.duration_container .way_duration').get(0).innerHTML.replace("~", "").split(":"),
  4825. // TODO: hier tritt manchmal Fehler auf TypeError: Cannot read property "innerHTML" of undefined at calcShortDuration (<anonymous>:3073:86)
  4826. arrival_time,
  4827. h, m, s,
  4828. atalanta_factor = 0;
  4829.  
  4830. var hasCartography = ITowns.getTown(Game.townId).getResearches().get("cartography");
  4831. var hasMeteorology = ITowns.getTown(Game.townId).getResearches().get("meteorology");
  4832. var hasSetSail = ITowns.getTown(Game.townId).getResearches().get("set_sail");
  4833.  
  4834. var hasLighthouse = ITowns.getTown(Game.townId).buildings().get("lighthouse");
  4835.  
  4836. // Atalanta aktiviert?
  4837. if ($(wndID + '.unit_container.heroes_pickup .atalanta').get(0)) {
  4838. if ($(wndID + '.cbx_include_hero').hasClass("checked")) {
  4839. // Beschleunigung hängt vom Level ab, Level 1 = 11%, Level 20 = 30%
  4840. var atalanta_level = MM.getCollections().PlayerHero[0].models[1].get("level");
  4841.  
  4842. atalanta_factor = (atalanta_level + 10) / 100;
  4843. }
  4844. }
  4845.  
  4846. // Sekunden, Minuten und Stunden zusammenrechnen (-> in Sekunden)
  4847. duration_time = ((parseInt(duration_time[0], 10) * 60 + parseInt(duration_time[1], 10)) * 60 + parseInt(duration_time[2], 10));
  4848.  
  4849. // Verkürzte Laufzeit berechnen
  4850. duration_time = ((duration_time - setup_time) * (1 + atalanta_factor)) / (1 + 0.3 + atalanta_factor) + setup_time;
  4851.  
  4852.  
  4853. h = Math.floor(duration_time / 3600);
  4854. m = Math.floor((duration_time - h * 3600) / 60);
  4855. s = Math.floor(duration_time - h * 3600 - m * 60);
  4856.  
  4857. if (m < 10) {
  4858. m = "0" + m;
  4859. }
  4860. if (s < 10) {
  4861. s = "0" + s;
  4862. }
  4863.  
  4864. $(wndID + '.short_duration').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
  4865.  
  4866. // Ankunftszeit errechnen
  4867. arrival_time = Math.round((Timestamp.server() + Game.server_gmt_offset)) + duration_time;
  4868.  
  4869. h = Math.floor(arrival_time / 3600);
  4870. m = Math.floor((arrival_time - h * 3600) / 60);
  4871. s = Math.floor(arrival_time - h * 3600 - m * 60);
  4872.  
  4873. h %= 24;
  4874.  
  4875. if (m < 10) {
  4876. m = "0" + m;
  4877. }
  4878. if (s < 10) {
  4879. s = "0" + s;
  4880. }
  4881.  
  4882. $(wndID + '.short_arrival').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
  4883.  
  4884. clearInterval(arrival_interval[wndID]);
  4885.  
  4886. arrival_interval[wndID] = setInterval(function () {
  4887. arrival_time += 1;
  4888.  
  4889. h = Math.floor(arrival_time / 3600);
  4890. m = Math.floor((arrival_time - h * 3600) / 60);
  4891. s = Math.floor(arrival_time - h * 3600 - m * 60);
  4892.  
  4893. h %= 24;
  4894.  
  4895. if (m < 10) {
  4896. m = "0" + m;
  4897. }
  4898. if (s < 10) {
  4899. s = "0" + s;
  4900. }
  4901.  
  4902. if ($(wndID + '.short_arrival').get(0)) {
  4903. $(wndID + '.short_arrival').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
  4904. } else {
  4905. clearInterval(arrival_interval[wndID]);
  4906. }
  4907. }, 1000);
  4908.  
  4909. } catch (error) {
  4910. errorHandling(error, "ShortDuration.calculate");
  4911. }
  4912. }
  4913. };
  4914.  
  4915. /*******************************************************************************************************************************
  4916. * ● Dropdown menu
  4917. *******************************************************************************************************************************/
  4918.  
  4919. // TODO: Umstellen!
  4920. // Preload images for drop down arrow buttons
  4921. var drop_over = new Image();
  4922. drop_over.src = "http://s7.directupload.net/images/140107/hna95u8a.png";
  4923. var drop_out = new Image();
  4924. drop_out.src = "http://s14.directupload.net/images/140107/ppsz5mxk.png";
  4925.  
  4926. function changeDropDownButton() {
  4927. $('<style id="dio_style_arrow" type="text/css">' +
  4928. '#dd_filter_type .arrow, .select_rec_unit .arrow {' +
  4929. 'width: 18px !important; height: 17px !important; background: url("http://s14.directupload.net/images/140107/ppsz5mxk.png") no-repeat 0px -1px !important;' +
  4930. 'position: absolute; top: 2px !important; right: 3px; } ' +
  4931. '</style>').appendTo('head');
  4932.  
  4933. }
  4934.  
  4935. /*******************************************************************************************************************************
  4936. * ● Recruiting Trade
  4937. * *****************************************************************************************************************************/
  4938. var trade_count = 0, unit = "FS", percent = "0.0"; // Recruiting Trade
  4939.  
  4940. function addRecTrade(wndID) {
  4941. var max_amount;
  4942.  
  4943. $('<div class="rec_trade">' +
  4944. // DropDown-Button for unit
  4945. '<div class="drop_rec_unit dropdown default">' +
  4946. '<div class="border-left"></div>' +
  4947. '<div class="border-right"></div>' +
  4948. '<div class="caption" name="' + unit + '">' + unit + '</div>' +
  4949. '<div class="arrow"></div>' +
  4950. '</div>' +
  4951. '<div class="drop_rec_perc dropdown default">' +
  4952. // DropDown-Button for ratio
  4953. '<div class="border-left"></div>' +
  4954. '<div class="border-right"></div>' +
  4955. '<div class="caption" name="' + percent + '">' + Math.round(percent * 100) + '%</div>' +
  4956. '<div class="arrow"></div>' +
  4957. '</div></div><span class="rec_count" style="top:30px">(' + trade_count + ')</span>').appendTo(wndID + ".content");
  4958.  
  4959. // Select boxes for unit and ratio
  4960. $('<div class="select_rec_unit dropdown-list default active">' +
  4961. '<div class="item-list">' +
  4962. '<div class="option_s unit index_unit unit_icon40x40 attack_ship" name="FS"></div>' +
  4963. '<div class="option_s unit index_unit unit_icon40x40 bireme" name="BI"></div>' +
  4964. '<div class="option_s unit index_unit unit_icon40x40 sword" name="SK"></div>' +
  4965. '<div class="option_s unit index_unit unit_icon40x40 slinger" name="SL"></div>' +
  4966. '<div class="option_s unit index_unit unit_icon40x40 archer" name="BS"></div>' +
  4967. '<div class="option_s unit index_unit unit_icon40x40 hoplite" name="HO"></div>' +
  4968. '<div class="option_s unit index_unit unit_icon40x40 rider" name="RE"></div>' +
  4969. '<div class="option_s unit index_unit unit_icon40x40 chariot" name="SW"></div>' +
  4970. '</div></div>').appendTo(wndID + ".rec_trade");
  4971. $('<div class="select_rec_perc dropdown-list default inactive">' +
  4972. '<div class="item-list">' +
  4973. '<div class="option sel" name="0.0">&nbsp;&nbsp;0%</div>' +
  4974. '<div class="option" name="0.05">&nbsp;&nbsp;5%</div>' +
  4975. '<div class="option" name="0.1">10%</div>' +
  4976. '<div class="option" name="0.16666">17%</div>' +
  4977. '<div class="option" name="0.2">20%</div>' +
  4978. '<div class="option" name="0.25">25%</div>' +
  4979. '<div class="option" name="0.33">33%</div>' +
  4980. '<div class="option" name="0.5">50%</div>' +
  4981. '</div></div>').appendTo(wndID + ".rec_trade");
  4982.  
  4983. $(wndID + ".rec_trade [name='" + unit + "']").toggleClass("sel");
  4984.  
  4985. // Styles
  4986. $(wndID + '.rec_trade').css({position: 'absolute', left: '30px', top: '70px'});
  4987. $(wndID + '.select_rec_unit').css({
  4988. position: 'absolute',
  4989. top: '20px',
  4990. width: '84px',
  4991. display: "none"
  4992. });
  4993. $(wndID + '.select_rec_perc').css({
  4994. position: 'absolute',
  4995. left: '50px',
  4996. top: '20px',
  4997. width: '50px',
  4998. display: "none"
  4999. });
  5000. $(wndID + '.item-list').css({maxHeight: '400px', maxWidth: '200px', align: "right"});
  5001.  
  5002. $(wndID + '.arrow').css({
  5003. width: '18px',
  5004. height: '18px',
  5005. background: 'url(' + drop_out.src + ') no-repeat -1px -1px',
  5006. position: 'absolute'
  5007. });
  5008.  
  5009. $(wndID + '.option_s').css({
  5010. filter: "url(#GrayScale)",
  5011. WebkitFilter: "grayscale(100%)",
  5012. cursor: 'pointer',
  5013. color: 'black',
  5014. lineHeight: '14px',
  5015. float: 'left',
  5016.  
  5017. position: 'relative',
  5018. width: '40px',
  5019. margin: '0px',
  5020. padding: '0px'
  5021. });
  5022.  
  5023. $('.select_rec_unit .sel').css({"filter": "url(#Sepia)", "-webkit-filter": "sepia(100%)"});
  5024.  
  5025. // hover effects of the elements in the drop menus
  5026. $(wndID + '.option_s').hover(
  5027. function () {
  5028. //console.log(this.className);
  5029. $(this).css({"filter": "none", "-webkit-filter": "grayscale(0%) sepia(0%)"});
  5030. if (!($(this).hasClass("sel"))) {
  5031. $('.option_s .sel').css({"filter": "url(#Sepia)", "-webkit-filter": "grayscale(0%) sepia(100%)"});
  5032. }
  5033. },
  5034. function () {
  5035. $('.select_rec_unit .option_s').css({
  5036. "filter": "url(#GrayScale)",
  5037. "-webkit-filter": "grayscale(100%) sepia(0%)"
  5038. });
  5039. $('.select_rec_unit .sel').css({
  5040. "filter": "url(#Sepia)",
  5041. "-webkit-filter": "grayscale(0%) sepia(100%)"
  5042. });
  5043. }
  5044. );
  5045. $(wndID + '.option').hover(
  5046. function () {
  5047. $(this).css({color: '#fff', background: "#328BF1"});
  5048. },
  5049. function () {
  5050. $(this).css({color: '#000', background: "#FFEEC7"});
  5051. }
  5052. );
  5053.  
  5054. // click events of the drop menu
  5055. $(wndID + ' .select_rec_unit .option_s').each(function () {
  5056. $(this).click(function (e) {
  5057. $(".select_rec_unit .sel").toggleClass("sel");
  5058. $("." + this.className.split(" ")[4]).toggleClass("sel");
  5059.  
  5060. unit = $(this).attr("name");
  5061. $('.drop_rec_unit .caption').attr("name", unit);
  5062. $('.drop_rec_unit .caption').each(function () {
  5063. this.innerHTML = unit;
  5064. });
  5065. $(this).parent().parent().get(0).style.display = "none";
  5066. $('.drop_rec_unit .caption').change();
  5067. });
  5068. });
  5069. $(wndID + ' .select_rec_perc .option').each(function () {
  5070. $(this).click(function (e) {
  5071. $(this).parent().find(".sel").toggleClass("sel");
  5072. $(this).toggleClass("sel");
  5073.  
  5074. percent = $(this).attr("name");
  5075. $('.drop_rec_perc .caption').attr("name", percent);
  5076. $('.drop_rec_perc .caption').each(function () {
  5077. this.innerHTML = Math.round(percent * 100) + "%";
  5078. });
  5079. $(this).parent().parent().get(0).style.display = "none";
  5080. $('.drop_rec_perc .caption').change();
  5081. });
  5082. });
  5083.  
  5084. // show & hide drop menus on click
  5085. $(wndID + '.drop_rec_perc').click(function (e) {
  5086. if ($(e.target)[0].parentNode.parentNode.childNodes[3].style.display === "none") {
  5087. $(e.target)[0].parentNode.parentNode.childNodes[3].style.display = "block";
  5088. $(e.target)[0].parentNode.parentNode.childNodes[2].style.display = "none";
  5089. } else {
  5090. $(e.target)[0].parentNode.parentNode.childNodes[3].style.display = "none";
  5091. }
  5092. });
  5093. $(wndID + '.drop_rec_unit').click(function (e) {
  5094. if ($(e.target)[0].parentNode.parentNode.childNodes[2].style.display === "none") {
  5095. $(e.target)[0].parentNode.parentNode.childNodes[2].style.display = "block";
  5096. $(e.target)[0].parentNode.parentNode.childNodes[3].style.display = "none";
  5097. } else {
  5098. $(e.target)[0].parentNode.parentNode.childNodes[2].style.display = "none";
  5099. }
  5100. });
  5101.  
  5102. $(wndID).click(function (e) {
  5103. var clicked = $(e.target), element = $('#' + this.id + ' .select_rec_unit').get(0);
  5104. if ((clicked[0].parentNode.className.split(" ")[1] !== "dropdown") && element) {
  5105. element.style.display = "none";
  5106. }
  5107. });
  5108.  
  5109. // hover arrow change
  5110. $(wndID + '.dropdown').hover(function (e) {
  5111. $(e.target)[0].parentNode.childNodes[3].style.background = "url('" + drop_over.src + "') no-repeat -1px -1px";
  5112. }, function (e) {
  5113. $(e.target)[0].parentNode.childNodes[3].style.background = "url('" + drop_out.src + "') no-repeat -1px -1px";
  5114. });
  5115.  
  5116. $(wndID + ".drop_rec_unit .caption").attr("name", unit);
  5117. $(wndID + ".drop_rec_perc .caption").attr("name", percent);
  5118.  
  5119. $(wndID + '.drop_rec_unit').tooltip(getText("labels", "rat"));
  5120. $(wndID + '.drop_rec_perc').tooltip(getText("labels", "shr"));
  5121.  
  5122. var ratio = {
  5123. NO: {w: 0, s: 0, i: 0},
  5124. FS: {w: 1, s: 0.2308, i: 0.6154},
  5125. BI: {w: 1, s: 0.8750, i: 0.2250},
  5126. SL: {w: 0.55, s: 1, i: 0.4},
  5127. RE: {w: 0.6666, s: 0.3333, i: 1},
  5128. SK: {w: 1, s: 0, i: 0.8947},
  5129. HO: {w: 0, s: 0.5, i: 1},
  5130. BS: {w: 1, s: 0, i: 0.6250},
  5131. SW: {w: 0.4545, s: 1, i: 0.7273}
  5132. };
  5133.  
  5134.  
  5135. if ($('#town_capacity_wood .max').get(0)) {
  5136. max_amount = parseInt($('#town_capacity_wood .max').get(0).innerHTML, 10);
  5137. } else {
  5138. max_amount = 25500;
  5139. }
  5140.  
  5141. $(wndID + '.caption').change(function (e) {
  5142. //console.log($(this).attr('name') + ", " + unit + "; " + percent);
  5143. if (!(($(this).attr('name') === unit) || ($(this).attr('name') === percent))) {
  5144. //trade_count = 0;
  5145. $('.rec_count').get(0).innerHTML = "(" + trade_count + ")";
  5146. }
  5147.  
  5148. var tmp = $(this).attr('name');
  5149.  
  5150. if ($(this).parent().attr('class').split(" ")[0] === "drop_rec_unit") {
  5151. unit = tmp;
  5152. } else {
  5153. percent = tmp;
  5154. }
  5155. var max = (max_amount - 100) / 1000;
  5156. addTradeMarks(max * ratio[unit].w, max * ratio[unit].s, max * ratio[unit].i, "lime");
  5157.  
  5158. 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)
  5159. var rArray = uw.ITowns.getTown(uw.Game.townId).getCurrentResources();
  5160. var tradeCapacity = uw.ITowns.getTown(uw.Game.townId).getAvailableTradeCapacity();
  5161.  
  5162. var wood = ratio[unit].w * part;
  5163. var stone = ratio[unit].s * part;
  5164. var iron = ratio[unit].i * part;
  5165.  
  5166. if ((wood > rArray.wood) || (stone > rArray.stone) || (iron > rArray.iron) || ( (wood + stone + iron) > tradeCapacity)) {
  5167. wood = stone = iron = 0;
  5168. $('.drop_rec_perc .caption').css({color: '#f00'});
  5169. //$('.' + e.target.parentNode.parentNode.className + ' .select_rec_perc .sel').css({color:'#f00'});
  5170. //$('.select_rec_perc .sel').css({color:'#f00'});
  5171. } else {
  5172. $('.' + e.target.parentNode.parentNode.className + ' .drop_rec_perc .caption').css({color: '#000'});
  5173. }
  5174. $("#trade_type_wood [type='text']").select().val(wood).blur();
  5175. $("#trade_type_stone [type='text']").select().val(stone).blur();
  5176. $("#trade_type_iron [type='text']").select().val(iron).blur();
  5177. });
  5178.  
  5179. $('#trade_button').click(function () {
  5180. trade_count++;
  5181. $('.rec_count').get(0).innerHTML = "(" + trade_count + ")";
  5182.  
  5183. });
  5184.  
  5185. $(wndID + '.rec_count').css({
  5186. position: 'absolute',
  5187. display: 'block',
  5188. left: '33px',
  5189. top: '95px',
  5190. width: '20px'
  5191. });
  5192. $(wndID + '.drop_rec_unit').css({
  5193. position: 'absolute',
  5194. display: 'block',
  5195. width: '50px',
  5196. overflow: 'visible'
  5197. });
  5198. $(wndID + '.drop_rec_perc').css({
  5199. position: 'absolute',
  5200. display: 'block',
  5201. left: '49px',
  5202. width: '55px',
  5203. color: '#000'
  5204. });
  5205. $(wndID + '.drop_rec_perc .caption').change();
  5206. }
  5207.  
  5208. /*******************************************************************************************************************************
  5209. * ● Ressources marks
  5210. *******************************************************************************************************************************/
  5211. function addTradeMarks(woodmark, stonemark, ironmark, color) {
  5212. var max_amount, limit, wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_TOWN), wndID;
  5213. for (var e in wndArray) {
  5214. if (wndArray.hasOwnProperty(e)) {
  5215. wndID = "#gpwnd_" + wndArray[e].getID() + " ";
  5216. if ($(wndID + '.town-capacity-indicator').get(0)) {
  5217.  
  5218. max_amount = $(wndID + '.amounts .max').get(0).innerHTML;
  5219.  
  5220. $('#trade_tab .c_' + color).each(function () {
  5221. this.remove();
  5222. });
  5223. $('#trade_tab .progress').each(function () {
  5224. if ($("p", this).length < 3) {
  5225. if ($(this).parent().get(0).id != "big_progressbar") {
  5226. limit = 1000 * (242 / parseInt(max_amount, 10));
  5227.  
  5228. switch ($(this).parent().get(0).id.split("_")[2]) {
  5229. case "wood":
  5230. limit = limit * woodmark;
  5231. break;
  5232. case "stone":
  5233. limit = limit * stonemark;
  5234. break;
  5235. case "iron":
  5236. limit = limit * ironmark;
  5237. break;
  5238. }
  5239. $('<p class="c_' + color + '"style="position:absolute;left: ' + limit + 'px; background:' + color + ';width:2px;height:100%;margin:0px"></p>').appendTo(this);
  5240. }
  5241. }
  5242. });
  5243. }
  5244. }
  5245. }
  5246. }
  5247.  
  5248. /*******************************************************************************************************************************
  5249. * ● Percentual Trade
  5250. *******************************************************************************************************************************/
  5251. var rest_count = 0;
  5252.  
  5253. function addPercentTrade(wndID, ww) {
  5254.  
  5255. var a = "";
  5256. var content = wndID + ".content";
  5257. if (ww) {
  5258. a = "ww_";
  5259. content = wndID + '.trade .send_res';
  5260. }
  5261. $('<div class="btn btn_trade"><a class="button" href="#">' +
  5262. '<span class="left"><span class="right">' +
  5263. '<span class="middle mid">' +
  5264. '<span class="img_trade"></span></span></span></span>' +
  5265. '<span style="clear:both;"></span>' +
  5266. '</a></div>').prependTo(content);
  5267.  
  5268. $(wndID + '.btn_trade').tooltip(getText("labels", "per"));
  5269.  
  5270. setPercentTrade(wndID, ww);
  5271.  
  5272. // Style
  5273. $(wndID + '.btn').css({width: '20px', overflow: 'visible', position: 'absolute', display: 'block'});
  5274.  
  5275. if (!ww) {
  5276. $(wndID + '.content').css({height: '320px'});
  5277. }
  5278.  
  5279. if (ww) {
  5280. $(wndID + '.btn_trade').css({left: '678px', top: '154px'});
  5281. } else {
  5282. $(wndID + '.btn_trade').css({left: '336px', top: '135px'});
  5283. }
  5284.  
  5285. $(wndID + '.mid').css({minWidth: '26px'});
  5286.  
  5287. $(wndID + '.img_trade').css({
  5288. width: '27px',
  5289. height: '27px',
  5290. top: '-3px',
  5291. float: 'left',
  5292. position: 'relative',
  5293. background: 'url("http://666kb.com/i/cjq6d72qk521ig1zz.png") no-repeat'
  5294. });
  5295.  
  5296. }
  5297.  
  5298. var res = {};
  5299.  
  5300. function setPercentTrade(wndID, ww) {
  5301. var a = ww ? "ww_" : "", own_town = $(wndID + '.town_info').get(0) ? true : false;
  5302.  
  5303. $(wndID + '.btn_trade').toggleClick(function () {
  5304. res.wood = {};
  5305. res.stone = {};
  5306. res.iron = {};
  5307. res.sum = {};
  5308.  
  5309. res.sum.amount = 0;
  5310. // Set amount of resources to 0
  5311. setAmount(true, a, wndID);
  5312. // Total amount of resources // TODO: ITowns.getTown(Game.townId).getCurrentResources(); ?
  5313. for (var e in res) {
  5314. if (res.hasOwnProperty(e) && e != "sum") {
  5315. res[e].rest = false;
  5316. res[e].amount = parseInt($('.ui_resources_bar .' + e + ' .amount').get(0).innerHTML, 10);
  5317. res.sum.amount += res[e].amount;
  5318. }
  5319. }
  5320. // Percentage of total resources
  5321. res.wood.percent = 100 / res.sum.amount * res.wood.amount;
  5322. res.stone.percent = 100 / res.sum.amount * res.stone.amount;
  5323. res.iron.percent = 100 / res.sum.amount * res.iron.amount;
  5324.  
  5325. // Total trading capacity
  5326. res.sum.cur = parseInt($(wndID + '#' + a + 'big_progressbar .caption .curr').get(0).innerHTML, 10);
  5327.  
  5328. // Amount of resources on the percentage of trading capacity (%)
  5329. res.wood.part = parseInt(res.sum.cur / 100 * res.wood.percent, 10);
  5330. res.stone.part = parseInt(res.sum.cur / 100 * res.stone.percent, 10);
  5331. res.iron.part = parseInt(res.sum.cur / 100 * res.iron.percent, 10);
  5332.  
  5333. // Get rest warehouse capacity of each resource type
  5334. for (var f in res) {
  5335. if (res.hasOwnProperty(f) && f != "sum") {
  5336. if (!ww && own_town) { // Own town
  5337. var curr = parseInt($(wndID + '#town_capacity_' + f + ' .amounts .curr').get(0).innerHTML.replace('+', '').trim(), 10) || 0,
  5338. curr2 = parseInt($(wndID + '#town_capacity_' + f + ' .amounts .curr2').get(0).innerHTML.replace('+', '').trim(), 10) || 0,
  5339. max = parseInt($(wndID + '#town_capacity_' + f + ' .amounts .max').get(0).innerHTML.replace('+', '').trim(), 10) || 0;
  5340.  
  5341. res[f].cur = curr + curr2;
  5342. res[f].max = max - res[f].cur;
  5343.  
  5344. if (res[f].max < 0) {
  5345. res[f].max = 0;
  5346. }
  5347.  
  5348. } else { // World wonder or foreign town
  5349. res[f].max = 30000;
  5350. }
  5351. }
  5352. }
  5353. // Rest of fraction (0-2 units) add to stone amount
  5354. res.stone.part += res.sum.cur - (res.wood.part + res.stone.part + res.iron.part);
  5355.  
  5356. res.sum.rest = 0;
  5357. rest_count = 0;
  5358. calcRestAmount();
  5359. setAmount(false, a, wndID);
  5360. }, function () {
  5361. setAmount(true, a, wndID);
  5362. });
  5363. }
  5364.  
  5365. function calcRestAmount() {
  5366. // Subdivide rest
  5367. if (res.sum.rest > 0) {
  5368. for (var e in res) {
  5369. if (res.hasOwnProperty(e) && e != "sum" && res[e].rest != true) {
  5370. res[e].part += res.sum.rest / (3 - rest_count);
  5371. }
  5372. }
  5373. res.sum.rest = 0;
  5374. }
  5375. // Calculate new rest
  5376. for (var f in res) {
  5377. if (res.hasOwnProperty(f) && f != "sum" && res[f].rest != true) {
  5378. if (res[f].max <= res[f].part) {
  5379. res[f].rest = true;
  5380. res.sum.rest += res[f].part - res[f].max;
  5381. rest_count += 1;
  5382. res[f].part = res[f].max;
  5383. }
  5384. }
  5385. }
  5386. // Recursion
  5387. if (res.sum.rest > 0 && rest_count < 3) {
  5388. calcRestAmount();
  5389. }
  5390. }
  5391.  
  5392. function setAmount(clear, a, wndID) {
  5393. for (var e in res) {
  5394. if (res.hasOwnProperty(e) && e != "sum") {
  5395. if (clear == true) {
  5396. res[e].part = 0;
  5397. }
  5398. $(wndID + "#" + a + "trade_type_" + e + ' [type="text"]').select().val(res[e].part).blur();
  5399. }
  5400. }
  5401. }
  5402.  
  5403. /********************************************************************************************************************************
  5404. * Unit strength (blunt/sharp/distance) and Transport Capacity
  5405. * ----------------------------------------------------------------------------------------------------------------------------
  5406. * | ● Unit strength: Menu
  5407. * | - Switching of def/off display with buttons
  5408. * | - Possible Selection of certain unit types
  5409. * | ● Unit strength: Conquest
  5410. * | ● Unit strength: Barracks
  5411. * | ● Transport capacity: Menu
  5412. * | - Switching of transporter speed (+/- big transporter)
  5413. * ----------------------------------------------------------------------------------------------------------------------------
  5414. * ******************************************************************************************************************************/
  5415.  
  5416. var def = true, blunt = 0, sharp = 0, dist = 0, shipsize = false;
  5417.  
  5418. var UnitStrength = {
  5419. // Calculate defensive strength
  5420. calcDef: function (units) {
  5421. var e;
  5422. blunt = sharp = dist = 0;
  5423. for (e in units) {
  5424. if (units.hasOwnProperty(e)) {
  5425. blunt += units[e] * uw.GameData.units[e].def_hack;
  5426. sharp += units[e] * uw.GameData.units[e].def_pierce;
  5427. dist += units[e] * uw.GameData.units[e].def_distance;
  5428. }
  5429. }
  5430. },
  5431. // Calculate offensive strength
  5432. calcOff: function (units, selectedUnits) {
  5433. var e;
  5434. blunt = sharp = dist = 0;
  5435. for (e in selectedUnits) {
  5436. if (selectedUnits.hasOwnProperty(e)) {
  5437. var attack = (units[e] || 0) * uw.GameData.units[e].attack;
  5438. switch (uw.GameData.units[e].attack_type) {
  5439. case 'hack':
  5440. blunt += attack;
  5441. break;
  5442. case 'pierce':
  5443. sharp += attack;
  5444. break;
  5445. case 'distance':
  5446. dist += attack;
  5447. break;
  5448. }
  5449. }
  5450. }
  5451. },
  5452. /*******************************************************************************************************************************
  5453. * ● Unit strength: Unit menu
  5454. *******************************************************************************************************************************/
  5455. Menu: {
  5456. activate: function () {
  5457. $('<div id="strength" class="cont def"><hr>' +
  5458. '<span class="bold text_shadow cont_left strength_font">' +
  5459. '<table style="margin:0px;">' +
  5460. '<tr><td><div class="ico units_info_sprite img_hack"></td><td id="blunt">0</td></tr>' +
  5461. '<tr><td><div class="ico units_info_sprite img_pierce"></td><td id="sharp">0</td></tr>' +
  5462. '<tr><td><div class="ico units_info_sprite img_dist"></td><td id="dist">0</td></tr>' +
  5463. '</table>' +
  5464. '</span>' +
  5465. '<div class="cont_right">' +
  5466. '<img id="def_button" class="active img" src="https://gpall.innogamescdn.com/images/game/unit_overview/support.png">' +
  5467. '<img id="off_button" class="img" src="https://gpall.innogamescdn.com/images/game/unit_overview/attack.png">' +
  5468. '</div></div>').appendTo('.units_land .content');
  5469.  
  5470. // Style
  5471. $('<style id="dio_strength_style">' +
  5472. '#strength.def #off_button, #strength.off #def_button { filter:url(#Sepia); -webkit-filter:sepia(1); }' +
  5473. '#strength.off #off_button, #strength.def #def_button { filter:none; -webkit-filter:none; } ' +
  5474.  
  5475. '#strength.off .img_hack { background-position:0% 36%;} ' +
  5476. '#strength.def .img_hack { background-position:0% 0%;} ' +
  5477. '#strength.off .img_pierce { background-position:0% 27%;} ' +
  5478. '#strength.def .img_pierce { background-position:0% 9%;} ' +
  5479. '#strength.off .img_dist { background-position:0% 45%;} ' +
  5480. '#strength.def .img_dist { background-position:0% 18%;} ' +
  5481.  
  5482. '#strength .strength_font { font-size: 0.8em; } ' +
  5483. '#strength.off .strength_font { color:#edb;} ' +
  5484. '#strength.def .strength_font { color:#fc6;} ' +
  5485.  
  5486. '#strength .ico { height:20px; width:20px; } ' +
  5487. '#strength .units_info_sprite { background:url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png); background-size:100%; } ' +
  5488.  
  5489. '#strength .img_pierce { background-position:0px -20px; } ' +
  5490. '#strength .img_dist { background-position:0px -40px; } ' +
  5491. '#strength hr { margin:0px; background-color:#5F5242; height:2px; border:0px solid; } ' +
  5492. '#strength .cont_left { width:65%; display:table-cell; } ' +
  5493.  
  5494. '#strength.cont { background:url(https://gpall.innogamescdn.com/images/game/layout/layout_units_nav_border.png); } ' +
  5495.  
  5496. '#strength .cont_right { width:30%; display:table-cell; vertical-align:middle; } ' +
  5497. '#strength .img { float:right; background:none; margin:2px 8px 2px 0px; } ' +
  5498.  
  5499. '</style>').appendTo("head");
  5500.  
  5501. // Button events
  5502. $('.units_land .units_wrapper, .btn_gods_spells .checked').click(function () {
  5503. setTimeout(function () {
  5504. UnitStrength.Menu.update();
  5505. }, 100);
  5506. });
  5507.  
  5508. $('#off_button').click(function () {
  5509. $('#strength').addClass('off').removeClass('def');
  5510.  
  5511. def = false;
  5512. UnitStrength.Menu.update();
  5513. });
  5514. $('#def_button').click(function () {
  5515. $('#strength').addClass('def').removeClass('off');
  5516.  
  5517. def = true;
  5518. UnitStrength.Menu.update();
  5519. });
  5520. $('#def_button, #off_button').hover(function () {
  5521. $(this).css('cursor', 'pointer');
  5522. });
  5523.  
  5524. UnitStrength.Menu.update();
  5525. },
  5526. deactivate: function () {
  5527. $('#strength').remove();
  5528. $('#dio_strength_style').remove();
  5529. },
  5530. update: function () {
  5531. var unitsIn = uw.ITowns.getTown(uw.Game.townId).units(), units = UnitStrength.Menu.getSelected();
  5532.  
  5533. // Calculation
  5534. if (def === true) {
  5535. UnitStrength.calcDef(units);
  5536. } else {
  5537. UnitStrength.calcOff(unitsIn, units);
  5538. }
  5539. $('#blunt').get(0).innerHTML = blunt;
  5540. $('#sharp').get(0).innerHTML = sharp;
  5541. $('#dist').get(0).innerHTML = dist;
  5542. },
  5543. getSelected: function () {
  5544. var units = [];
  5545. if ($(".units_land .units_wrapper .selected").length > 0) {
  5546. $(".units_land .units_wrapper .selected").each(function () {
  5547. units[this.className.split(" ")[1]] = this.children[0].innerHTML;
  5548. });
  5549. } else {
  5550. $(".units_land .units_wrapper .unit").each(function () {
  5551. units[this.className.split(" ")[1]] = this.children[0].innerHTML;
  5552. });
  5553. }
  5554. return units;
  5555. }
  5556. },
  5557. /*******************************************************************************************************************************
  5558. * ● Unit strength: Conquest
  5559. *******************************************************************************************************************************/
  5560. Conquest: {
  5561. add: function () {
  5562. var units = [], str;
  5563.  
  5564. // units of the siege
  5565. $('#conqueror_units_in_town .unit').each(function () {
  5566. str = $(this).attr("class").split(" ")[4];
  5567. if (!uw.GameData.units[str].is_naval) {
  5568. units[str] = parseInt(this.children[0].innerHTML, 10);
  5569. //console.log($(this).attr("class").split(" ")[4]);
  5570. }
  5571. });
  5572. // calculation
  5573. UnitStrength.calcDef(units);
  5574.  
  5575. $('<div id="strength_eo" class="game_border" style="width:90px; margin: 20px; align:center;">' +
  5576. '<div class="game_border_top"></div><div class="game_border_bottom"></div>' +
  5577. '<div class="game_border_left"></div><div class="game_border_right"></div>' +
  5578. '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
  5579. '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
  5580. '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">' +
  5581. '<tr><td width="1%"><div class="ico units_info_sprite img_hack"></div></td><td id="bl" align="center" width="100%">0</td></tr>' +
  5582. '<tr><td><div class="ico units_info_sprite img_pierce"></div></td><td id="sh" align="center">0</td></tr>' +
  5583. '<tr><td><div class="ico units_info_sprite img_dist"></div></td><td id="di" align="center">0</td></tr>' +
  5584. '</table></span>' +
  5585. '</div>').appendTo('#conqueror_units_in_town');
  5586.  
  5587. $('#strength_eo').tooltip('Gesamteinheitenstärke der Belagerungstruppen');
  5588.  
  5589. // Veröffentlichung-Button-Text
  5590. $('#conqueror_units_in_town .publish_conquest_public_id_wrap').css({
  5591. marginLeft: '130px'
  5592. });
  5593.  
  5594. $('#strength_eo .ico').css({
  5595. height: '20px',
  5596. width: '20px'
  5597. });
  5598. $('#strength_eo .units_info_sprite').css({
  5599. background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
  5600. backgroundSize: '100%'
  5601. });
  5602. $('#strength_eo .img_pierce').css({backgroundPosition: '0% 9%'});
  5603. $('#strength_eo .img_dist').css({backgroundPosition: '0% 18%'});
  5604.  
  5605.  
  5606. $('#bl').get(0).innerHTML = blunt;
  5607. $('#sh').get(0).innerHTML = sharp;
  5608. $('#di').get(0).innerHTML = dist;
  5609. }
  5610. },
  5611. /*******************************************************************************************************************************
  5612. * ● Unit strength: Barracks
  5613. *******************************************************************************************************************************/
  5614. Barracks: {
  5615. add: function () {
  5616. if (!$('#strength_baracks').get(0)) {
  5617. var units = [], pop = 0;
  5618.  
  5619. // whole units of the town
  5620. $('#units .unit_order_total').each(function () {
  5621. units[$(this).parent().parent().attr("id")] = this.innerHTML;
  5622. });
  5623. // calculation
  5624. UnitStrength.calcDef(units);
  5625.  
  5626. // population space of the units
  5627. for (var e in units) {
  5628. if (units.hasOwnProperty(e)) {
  5629. pop += units[e] * uw.GameData.units[e].population;
  5630. }
  5631. }
  5632. $('<div id="strength_baracks" class="game_border" style="float:right; width:70px; align:center;">' +
  5633. '<div class="game_border_top"></div><div class="game_border_bottom"></div>' +
  5634. '<div class="game_border_left"></div><div class="game_border_right"></div>' +
  5635. '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
  5636. '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
  5637. '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">' +
  5638. '<tr><td width="1%"><div class="ico units_info_sprite img_hack"></div></td><td id="b" align="center" width="100%">0</td></tr>' +
  5639. '<tr><td><div class="ico units_info_sprite img_pierce"></div></td><td id="s" align="center">0</td></tr>' +
  5640. '<tr><td><div class="ico units_info_sprite img_dist"></div></td><td id="d" align="center">0</td></tr>' +
  5641. '</table></span>' +
  5642. '</div>').appendTo('.ui-dialog #units');
  5643.  
  5644. $('<div id="pop_baracks" class="game_border" style="float:right; width:60px; align:center;">' +
  5645. '<div class="game_border_top"></div><div class="game_border_bottom"></div>' +
  5646. '<div class="game_border_left"></div><div class="game_border_right"></div>' +
  5647. '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
  5648. '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
  5649. '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">' +
  5650. '<tr><td width="1%"><img class="ico" src="https://gpall.innogamescdn.com/images/game/res/pop.png"></td><td id="p" align="center" width="100%">0</td></tr>' +
  5651. '</table></span>' +
  5652. '</div>').appendTo('.ui-dialog #units');
  5653.  
  5654. $('.ui-dialog #units .ico').css({
  5655. height: '20px',
  5656. width: '20px'
  5657. });
  5658. $('.ui-dialog #units .units_info_sprite').css({
  5659. background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
  5660. backgroundSize: '100%'
  5661. });
  5662. $('.ui-dialog #units .img_pierce').css({backgroundPosition: '0% 9%'});
  5663. $('.ui-dialog #units .img_dist').css({backgroundPosition: '0% 18%'});
  5664.  
  5665. //$('#pop_baracks').tooltip('Bevölkerungszahl aller Landeinheiten der Stadt');
  5666. //$('#strength_baracks').tooltip('Gesamteinheitenstärke stadteigener Truppen');
  5667.  
  5668. $('#b').get(0).innerHTML = blunt;
  5669. $('#s').get(0).innerHTML = sharp;
  5670. $('#d').get(0).innerHTML = dist;
  5671. $('#p').get(0).innerHTML = pop;
  5672. }
  5673. }
  5674. }
  5675. };
  5676.  
  5677. /*******************************************************************************************************************************
  5678. * ● Transporter capacity
  5679. *******************************************************************************************************************************/
  5680. var TransportCapacity = {
  5681. activate: function () {
  5682. // transporter display
  5683. $('<div id="transporter" class="cont" style="height:25px;">' +
  5684. '<table style=" margin:0px;"><tr align="center" >' +
  5685. '<td><img id="ship_img" class="ico" src="http://s7.directupload.net/images/140724/4pvfuch8.png"></td>' +
  5686. '<td><span id="ship" class="bold text_shadow" style="color:#FFCC66;font-size: 10px;line-height: 2.1;"></span></td>' +
  5687. '</tr></table>' +
  5688. '</div>').appendTo('.units_naval .content');
  5689.  
  5690. $('#transporter.cont').css({
  5691. background: 'url(https://gpall.innogamescdn.com/images/game/layout/layout_units_nav_border.png)'
  5692. });
  5693.  
  5694. $('#transporter').hover(function () {
  5695. $(this).css('cursor', 'pointer');
  5696. });
  5697. $('#transporter').toggleClick(
  5698. function () {
  5699. $('#ship_img').get(0).src = "http://s1.directupload.net/images/140724/b5xl8nmj.png";
  5700. shipsize = !shipsize;
  5701. TransportCapacity.update();
  5702. },
  5703. function () {
  5704. $('#ship_img').get(0).src = "http://s7.directupload.net/images/140724/4pvfuch8.png";
  5705. shipsize = !shipsize;
  5706. TransportCapacity.update();
  5707. }
  5708. );
  5709. TransportCapacity.update();
  5710. },
  5711. deactivate: function () {
  5712. $('#transporter').remove();
  5713. },
  5714. update: function () {
  5715. var bigTransp = 0, smallTransp = 0, pop = 0, ship = 0, unit, berth, units = [];
  5716. // Ship space (available)
  5717. smallTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().small_transporter, 10);
  5718. if (isNaN(smallTransp)) smallTransp = 0;
  5719. if (shipsize) {
  5720. bigTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().big_transporter, 10);
  5721. if (isNaN(bigTransp)) bigTransp = 0;
  5722. }
  5723.  
  5724. // Checking: Research berth
  5725. berth = 0;
  5726. if (uw.ITowns.getTown(uw.Game.townId).researches().hasBerth()) {
  5727. berth = GameData.research_bonus.berth;
  5728. }
  5729. ship = bigTransp * (GameData.units.big_transporter.capacity + berth) + smallTransp * (GameData.units.small_transporter.capacity + berth);
  5730.  
  5731. units = uw.ITowns.getTown(uw.Game.townId).units();
  5732.  
  5733. // Ship space (required)
  5734. for (var e in units) {
  5735. if (units.hasOwnProperty(e)) {
  5736. if (uw.GameData.units[e]) { // without Heroes
  5737. if (!(uw.GameData.units[e].is_naval || uw.GameData.units[e].flying)) {
  5738. pop += units[e] * uw.GameData.units[e].population;
  5739. }
  5740. }
  5741. }
  5742. }
  5743. $('#ship').get(0).innerHTML = pop + "/" + ship;
  5744. }
  5745. };
  5746.  
  5747.  
  5748. /*******************************************************************************************************************************
  5749. * Simulator
  5750. * ----------------------------------------------------------------------------------------------------------------------------
  5751. * | ● Layout adjustment
  5752. * | ● Permanent display of the extended modifier box
  5753. * | ● Unit strength for entered units (without modificator influence yet)
  5754. * ----------------------------------------------------------------------------------------------------------------------------
  5755. *******************************************************************************************************************************/
  5756. var Simulator = {
  5757. activate: function () {
  5758. $('<style id="dio_simulator" type="text/css">' +
  5759.  
  5760. '#place_simulator { overflow: hidden !important} ' +
  5761. '#place_simulator .game_body { height: 457px !important} ' +
  5762.  
  5763. // Bonus container
  5764. '.place_sim_bonuses_heroes { position:absolute; right:-20px; top:24px; width: 300px;} ' +
  5765. '.place_sim_bonuses_heroes .place_sim_showhide { display:none; } ' + // Hide modifier box button
  5766.  
  5767.  
  5768. //'.place_sim_wrap_mods {position: relative; right: -17px !important} '+
  5769. '.place_sim_wrap_mods .place_simulator_table :eq(1) { width: 300px;} ' + ////////////// genauer!
  5770. '.place_sim_wrap_mods > .place_simulator_table { width: 272px;} ' + ////////////// genauer!
  5771.  
  5772. // Wall losses
  5773. '.place_sim_wrap_mods tr:last-child { display:none; } ' +
  5774.  
  5775. // Extended modifier box
  5776. //'@-webkit-keyframes MODBOX { 0% { opacity: 0; } 100% { opacity: 1; } } '+
  5777. //'@keyframes MODBOX { 0% { opacity: 0; } 100% { opacity: 1; } } '+
  5778.  
  5779. '.place_sim_wrap_mods_extended { display: table-cell !important; -webkit-animation:MODBOX 1s; animation:MODBOX 1s; position: relative; width:272px; padding-top: 3px; opacity: 1 !important; left: 0px; top: 0px} ' +
  5780. '.place_sim_wrap_mods_extended table tr td:eq(0) { width: 18px !important } ' +
  5781. '.place_sim_wrap_mods_extended td { border:0px; } ' +
  5782. '.place_sim_wrap_mods_extended tr td:first-child { border-left:0px; width:19px; padding-left:0px; } ' +
  5783. '.place_sim_wrap_mods_extended .place_simulator_table { border:0; margin:2px; border-collapse:separate; border:1px solid #724B08; table-layout:fixed; width:100% } ' +
  5784.  
  5785. '.place_simulator_table .place_image { display:block; width: 20px; height:20px; background-size:100%; margin:auto; } ' +
  5786.  
  5787. '.place_simulator_table .place_image.pa_commander { background: url(https://diotools.de/images/game/advisors/advisors_22.png); background-position: 0px 44px; } ' +
  5788. '.place_simulator_table .place_image.pa_captain { background: url(https://diotools.de/images/game/advisors/advisors_22.png); background-position: 0px 88px; } ' +
  5789. '.place_simulator_table .place_image.pa_priest { background: url(https://diotools.de/images/game/advisors/advisors_22.png); background-position: 0px 66px; } ' +
  5790.  
  5791. '.place_simulator_table .place_image.is_night { background-position: 0px -40px; } ' +
  5792. '.place_simulator_table .place_image.research_ram { background-position: 0px -300px; } ' +
  5793. '.place_simulator_table .place_image.research_phalanx { background-position: 0px -280px; }' +
  5794.  
  5795. '.place_sim_wrap_mods_extended .place_cross { height:16px; background:none; } ' +
  5796. '.place_sim_wrap_mods_extended .place_checkbox_field { display:table-cell; width:13px; height:13px; } ' +
  5797.  
  5798. '.place_sim_wrap_mods_extended tr:last-child { display:none;} ' +
  5799.  
  5800. '.place_sim_wrap_mods_extended tr:nth-of-type(3) td, .place_sim_wrap_mods_extended tr:nth-of-type(5) td { border-top: 2px solid #BFA978 !important; padding-top: 3px !important} ' +
  5801.  
  5802. '.place_sim_wrap_mods_extended .game_border>div { display:none; } ' +
  5803. '.place_sim_wrap_mods_extended .game_border { margin:0px; } ' +
  5804.  
  5805. '.place_sim_wrap_mods_extended .game_border { height: 139px; overflow-y: auto; overflow-x: hidden; }' + // Größe der Modfikatorbox begrenzen
  5806.  
  5807. '#place_simulator .window_inner_curtain { display: none !important } ' + // Hintergrund entfernen bei offener Modifikatorbox
  5808.  
  5809. // Unit container
  5810. '#simulator_body .unit_container { height: 50px !important; width: 50px !important; margin: 0px 3px 0px 1px !important} ' +
  5811. '.place_simulator_odd, .place_simulator_even { text-align: center !important} ' +
  5812. '.place_insert_field { margin: 0px !important} ' +
  5813.  
  5814. '#place_sim_ground_units { position:absolute; bottom: 35px;} ' +
  5815.  
  5816. // Sea unit box
  5817. '#place_sim_naval_units { position: absolute; } ' +
  5818. '#place_sim_naval_units tbody tr:last-child { height:auto !important; }' +
  5819.  
  5820. '.place_sim_select_strategies select { width: 95px !important} ' +
  5821. '.place_sim_select_strategies { margin-left: 99px !important} ' +
  5822.  
  5823.  
  5824. // Land unit box
  5825. '#place_sim_wrap_units { position: absolute !important; bottom: 35px !important} ' +
  5826.  
  5827. '#simulator_body>h4 { position:absolute;bottom:188px;} ' +
  5828.  
  5829. // Select boxes
  5830. '.place_sim_select_gods_wrap { position:absolute; bottom:185px; left:96px;} ' +
  5831.  
  5832. '.place_sim_select_gods { width: 105px !important} ' +
  5833. '.place_sim_select_gods select { width: 80px !important} ' +
  5834.  
  5835. '#select_insert_units { width: 130px !important} ' +
  5836.  
  5837. '.place_sim_select_gods_wrap .place_symbol, .place_sim_select_strategies .place_symbol { margin: 0px 2px 0px 5px !important} ' +
  5838. '.place_sim_insert_units .place_symbol { background: url(https://gpall.innogamescdn.com/images/game/towninfo/traveltime.png) !important; background-size: 140% !important; background-position-y: -4px !important} ' +
  5839. '.place_attack { float: left !important} ' +
  5840. '#simulator_body .att { margin-left: 19px !important} ' +
  5841.  
  5842. // Hero box
  5843. '.place_sim_heroes_container { position: absolute !important; right: 26px !important; padding-top: 3px !important; z-index: 1 !important} ' +
  5844. '.place_sim_hero_container { width: 45px !important; height: 25px !important} ' +
  5845.  
  5846. '#place_simulator .place_sim_bonuses_heroes h4:nth-of-type(2) { display:none; }' + // Heroes title
  5847.  
  5848. // - Hero container
  5849. '.place_sim_hero_choose, .place_sim_hero_unit_container { height: 26px !important; width: 30px !important} ' +
  5850. '#hero_defense_icon, #hero_attack_icon { height: 25px !important; width: 25px !important; margin: 0px !important} ' +
  5851. '#hero_defense_dd, #hero_attack_dd { height: 25px !important; width: 25px !important; margin: 1px !important} ' +
  5852. '.place_sim_hero_attack, .place_sim_hero_defense { margin-left: 3px !important} ' +
  5853. '#hero_attack_text, #hero_defense_text { font-size: 11px !important; bottom: 0px !important} ' +
  5854. '.place_sim_heroes_container .plus { left: 2px; top: 2px !important} ' +
  5855.  
  5856. '.place_sim_heroes_container .button_new.square { left: 2px !important; } ' +
  5857.  
  5858.  
  5859. // - Hero spinner
  5860. '.place_sim_heroes_container .spinner { height: 25px !important; width: 40px !important } ' +
  5861. '.place_sim_heroes_container td:nth-child(0) { height: 30px !important} ' +
  5862. '.place_sim_heroes_container .spinner { height: 24px !important; position:absolute !important; width:12px !important; left:29px !important; '+
  5863. 'background:url(https://gpall.innogamescdn.com/images/game/border/odd.png) repeat !important; border: 1px solid rgb(107, 107, 107) !important; } ' +
  5864. '.place_sim_heroes_container .spinner .button_down, .place_sim_heroes_container .spinner .button_up { bottom: 2px !important; cursor: pointer !important} ' +
  5865. '.place_sim_heroes_container .spinner .border_l, .place_sim_heroes_container .spinner .border_r, .place_sim_heroes_container .spinner .body { display:none; } '+
  5866.  
  5867. // Quack
  5868. '#q_place_sim_lost_res { display: none; } ' +
  5869. '</style>').appendTo('head');
  5870.  
  5871. if($('#place_simulator').get(0)) {
  5872. Simulator.change();
  5873. }
  5874.  
  5875. },
  5876. deactivate: function () {
  5877. $('#dio_simulator').remove();
  5878. if($('#simu_table').get(0)) {
  5879. $('#simu_table').remove();
  5880.  
  5881. // Hero box
  5882. if ($('.place_sim_heroes_container').get(0)) {
  5883. $('.hero_unit').each(function () {
  5884. $(this).addClass('unit_icon40x40').removeClass('unit_icon25x25');
  5885. });
  5886.  
  5887. // Hero spinner
  5888. $('.place_sim_heroes_container .spinner').each(function () {
  5889. $(this).addClass('place_sim_hero_spinner');
  5890. });
  5891. }
  5892. }
  5893. },
  5894. change: function () {
  5895. // TODO: Durch CSS ersetzen...
  5896.  
  5897. // Wall loss
  5898. $('.place_sim_wrap_mods tr:eq(1) td:eq(5)').html('<span id="building_place_def_losses_wall_level" class="place_losses bold"></span>');
  5899.  
  5900. // Extended modificator box
  5901. $('.place_sim_wrap_mods_extended .power').each(function () {
  5902. $(this).removeClass("power_icon45x45").addClass("power_icon16x16");
  5903. });
  5904. $('.place_sim_wrap_mods_extended td:nth-child(even)').each(function () {
  5905. $(this).addClass("left_border place_simulator_odd");
  5906. });
  5907. $('.place_sim_wrap_mods_extended td:nth-child(odd)').each(function () {
  5908. $(this).addClass("left_border place_simulator_even");
  5909. });
  5910.  
  5911. // Border entfernen
  5912. $('.place_sim_wrap_mods_extend td:first-child').each(function () {
  5913. $(this).removeClass("left_border");
  5914. });
  5915.  
  5916. // -> Update percentage each time
  5917. $('.place_checkbox_field').click(function () {
  5918. FightSimulator.closeModsExtended(); //$('.place_sim_bonuses_more_confirm').get(0).click();
  5919. });
  5920.  
  5921. // Hero world ?
  5922. if (uw.Game.hasArtemis) {
  5923. $('.place_sim_wrap_mods_extend tr').each(function () {
  5924. this.children[1].style.borderLeft = "none";
  5925. this.children[0].remove();
  5926. });
  5927. }
  5928.  
  5929. // Hero box
  5930. if ($('.place_sim_heroes_container').get(0)) {
  5931. $('.hero_unit').each(function () {
  5932. $(this).removeClass('unit_icon40x40').addClass('unit_icon25x25');
  5933. });
  5934.  
  5935. // Hero spinner
  5936. $('.place_sim_heroes_container .spinner').each(function () {
  5937. $(this).removeClass('place_sim_hero_spinner');
  5938. });
  5939. }
  5940.  
  5941. setStrengthSimulator();
  5942. }
  5943. };
  5944.  
  5945. function afterSimulation() {
  5946. var lossArray = {att: {res: 0, fav: 0, pop: 0}, def: {res: 0, fav: 0, pop: 0}},
  5947. wall_level = parseInt($('.place_sim_wrap_mods .place_insert_field[name="sim[mods][def][wall_level]"]').val(), 10),
  5948. wall_damage = parseInt($('#building_place_def_losses_wall_level').get(0).innerHTML, 10),
  5949. 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];
  5950.  
  5951. // Calculate unit losses
  5952. $('#place_sim_ground_units .place_losses, #place_sim_naval_units .place_losses').each(function () {
  5953. var loss = parseInt(this.innerHTML, 10) || 0;
  5954. console.log(this.innerHTML);
  5955. if (loss > 0) {
  5956. var unit = this.id.substring(26);
  5957. var side = this.id.split("_")[2]; // att / def
  5958. lossArray[side].res += loss * (uw.GameData.units[unit].resources.wood + uw.GameData.units[unit].resources.stone + uw.GameData.units[unit].resources.iron);
  5959. lossArray[side].fav += loss * uw.GameData.units[unit].favor;
  5960. lossArray[side].pop += loss * uw.GameData.units[unit].population;
  5961. }
  5962. });
  5963. // Calculate wall resource losses
  5964. for (var w = wall_level; w > wall_level - wall_damage; w--) {
  5965. 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
  5966. }
  5967.  
  5968. // Insert losses into table
  5969. for (var x in lossArray) {
  5970. if (lossArray.hasOwnProperty(x)) {
  5971. for (var z in lossArray[x]) {
  5972. if (lossArray[x].hasOwnProperty(z)) {
  5973. console.log(((z === "res") && (lossArray[x][z] > 10000)) ? (Math.round(lossArray[x][z] / 1000) + "k") : lossArray[x][z]);
  5974. $("#" + x + "_" + z).get(0).innerHTML = ((z === "res") && (lossArray[x][z] > 10000)) ? (Math.round(lossArray[x][z] / 1000) + "k") : lossArray[x][z];
  5975.  
  5976. }
  5977. }
  5978. }
  5979. }
  5980. }
  5981.  
  5982. // Stärkeanzeige: Simulator
  5983. var unitsGround = {att: {}, def: {}}, unitsNaval = {att: {}, def: {}}, name = "";
  5984.  
  5985. function setStrengthSimulator() {
  5986. $('<div id="simu_table">' +
  5987. '<div style="float:left; margin-right:12px;"><h4>' + getText("labels", "str") + '</h4>' +
  5988. '<table class="place_simulator_table strength" cellpadding="0px" cellspacing="0px" style="align:center;">' +
  5989. '<tr>' +
  5990. '<td class="place_simulator_even"></td>' +
  5991. '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_hack"></div></td>' +
  5992. '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_pierce"></div></td>' +
  5993. '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_dist"></div></td>' +
  5994. '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_ship"></div></td>' +
  5995. '</tr><tr>' +
  5996. '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>' +
  5997. '<td class="left_border place_simulator_odd" id="att_b">0</td>' +
  5998. '<td class="left_border place_simulator_even" id="att_s">0</td>' +
  5999. '<td class="left_border place_simulator_odd" id="att_d">0</td>' +
  6000. '<td class="left_border place_simulator_even" id="att_ship">0</td>' +
  6001. '</tr><tr>' +
  6002. '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
  6003. '<td class="left_border place_simulator_odd" id="def_b">0</td>' +
  6004. '<td class="left_border place_simulator_even" id="def_s">0</td>' +
  6005. '<td class="left_border place_simulator_odd" id="def_d">0</td>' +
  6006. '<td class="left_border place_simulator_even" id="def_ship">0</td>' +
  6007. '</tr>' +
  6008. '</table>' +
  6009. '</div><div><h4>' + getText("labels", "los") + '</h4>' +
  6010. '<table class="place_simulator_table loss" cellpadding="0px" cellspacing="0px" style="align:center;">' +
  6011. '<tr>' +
  6012. '<td class="place_simulator_even"></td>' +
  6013. '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_res"></div></td>' +
  6014. '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_fav"></div></td>' +
  6015. '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_pop"></div></td>' +
  6016. '</tr><tr>' +
  6017. '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>' +
  6018. '<td class="left_border place_simulator_odd" id="att_res">0</td>' +
  6019. '<td class="left_border place_simulator_even" id="att_fav">0</td>' +
  6020. '<td class="left_border place_simulator_odd" id="att_pop">0</td>' +
  6021. '</tr><tr>' +
  6022. '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
  6023. '<td class="left_border place_simulator_odd" id="def_res">0</td>' +
  6024. '<td class="left_border place_simulator_even" id="def_fav">0</td>' +
  6025. '<td class="left_border place_simulator_odd" id="def_pop">0</td>' +
  6026. '</tr>' +
  6027. '</table>' +
  6028. '</div></div>').appendTo('#simulator_body');
  6029.  
  6030. $('#simu_table').css({
  6031. position: 'absolute',
  6032. top: '200px',
  6033. fontSize: '0.8em',
  6034. width: '63%'
  6035. });
  6036. $('#simu_table .ico').css({
  6037. height: '20px',
  6038. width: '20px',
  6039. margin: 'auto'
  6040. });
  6041. $('#simu_table .units_info_sprite').css({
  6042. background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
  6043. backgroundSize: '100%'
  6044. });
  6045. $('#simu_table .img_hack').css({backgroundPosition: '0% 36%'});
  6046. $('#simu_table .img_pierce').css({backgroundPosition: '0% 27%'});
  6047. $('#simu_table .img_dist').css({backgroundPosition: '0% 45%'});
  6048. $('#simu_table .img_ship').css({backgroundPosition: '0% 72%'});
  6049.  
  6050. $('#simu_table .img_fav').css({
  6051. background: 'url(https://gpall.innogamescdn.com/images/game/res/favor.png)',
  6052. backgroundSize: '100%'
  6053. });
  6054. $('#simu_table .img_res').css({
  6055. background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png) 0% 54%',
  6056. backgroundSize: '100%'
  6057. });
  6058. $('#simu_table .img_pop').css({
  6059. background: 'url(https://gpall.innogamescdn.com/images/game/res/pop.png)',
  6060. backgroundSize: '100%'
  6061. });
  6062.  
  6063. $('#simu_table .left_border').css({
  6064. width: '54px'
  6065. });
  6066. $('#simu_table .left_border').each(function () {
  6067. $(this)[0].align = 'center';
  6068. });
  6069.  
  6070. $('#simu_table .strength').tooltip(getText("labels", "str") + " (" + getText("labels", "mod") + ")");
  6071. $('#simu_table .loss').tooltip(getText("labels", "los"));
  6072.  
  6073. // Klick auf Einheitenbild
  6074. $('.index_unit').click(function () {
  6075. var type = $(this).attr('class').split(" ")[4];
  6076. $('.place_insert_field[name="sim[units][att][' + type + ']"]').change();
  6077. });
  6078.  
  6079. $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').on('input change', function () {
  6080. name = $(this).attr("name").replace(/\]/g, "").split("[");
  6081. var str = this;
  6082. //console.log(str);
  6083. setTimeout(function () {
  6084. var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2],
  6085. val, e;
  6086.  
  6087. val = parseInt($(str).val(), 10);
  6088. val = val || 0;
  6089.  
  6090. if (unit_type == "ground") {
  6091. unitsGround[name[2]][name[3]] = val;
  6092.  
  6093. if (name[2] == "def") {
  6094. UnitStrength.calcDef(unitsGround.def);
  6095. } else {
  6096. UnitStrength.calcOff(unitsGround.att, unitsGround.att);
  6097. }
  6098. $('#' + name[2] + '_b').get(0).innerHTML = blunt;
  6099. $('#' + name[2] + '_s').get(0).innerHTML = sharp;
  6100. $('#' + name[2] + '_d').get(0).innerHTML = dist;
  6101.  
  6102. } else {
  6103. var att = 0, def = 0;
  6104. unitsNaval[name[2]][name[3]] = val;
  6105.  
  6106. if (name[2] == "def") {
  6107. for (e in unitsNaval.def) {
  6108. if (unitsNaval.def.hasOwnProperty(e)) {
  6109. def += unitsNaval.def[e] * uw.GameData.units[e].defense;
  6110. }
  6111. }
  6112. $('#def_ship').get(0).innerHTML = def;
  6113. } else {
  6114. for (e in unitsNaval.att) {
  6115. if (unitsNaval.att.hasOwnProperty(e)) {
  6116. att += unitsNaval.att[e] * uw.GameData.units[e].attack;
  6117. }
  6118. }
  6119. $('#att_ship').get(0).innerHTML = att;
  6120. }
  6121. }
  6122. }, 100);
  6123. });
  6124.  
  6125. // Abfrage wegen eventueller Spionageweiterleitung
  6126. getUnitInputs();
  6127. setTimeout(function () {
  6128. setChangeUnitInputs("def");
  6129. }, 100);
  6130.  
  6131. $('#select_insert_units').change(function () {
  6132. var side = $(this).find('option:selected').val();
  6133. setTimeout(function () {
  6134. getUnitInputs();
  6135. if (side === "att" || side === "def") {
  6136. setChangeUnitInputs(side);
  6137. }
  6138. }, 200);
  6139. });
  6140. }
  6141.  
  6142. function getUnitInputs() {
  6143. $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').each(function () {
  6144. name = $(this).attr("name").replace(/\]/g, "").split("[");
  6145. var str = this;
  6146. var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2],
  6147. val, e;
  6148. val = parseInt($(str).val(), 10);
  6149. val = val || 0;
  6150. if (unit_type === "ground") {
  6151. unitsGround[name[2]][name[3]] = val;
  6152. } else {
  6153. var att = 0, def = 0;
  6154. unitsNaval[name[2]][name[3]] = val;
  6155. }
  6156. });
  6157. }
  6158.  
  6159. function setChangeUnitInputs(side) {
  6160. $('.place_insert_field[name="sim[units][' + side + '][godsent]"]').change();
  6161. setTimeout(function () {
  6162. $('.place_insert_field[name="sim[units][' + side + '][colonize_ship]"]').change();
  6163. }, 100);
  6164. }
  6165.  
  6166. /*******************************************************************************************************************************
  6167. * Defense form
  6168. * ----------------------------------------------------------------------------------------------------------------------------
  6169. * | ● Adds a defense form to the bbcode bar
  6170. * ----------------------------------------------------------------------------------------------------------------------------
  6171. *******************************************************************************************************************************/
  6172.  
  6173. // Funktion aufteilen...
  6174. function addForm(e) {
  6175. var textareaId = "", bbcodeBarId = "";
  6176.  
  6177. switch (e) {
  6178. case "/alliance_forum/forum":
  6179. textareaId = "#forum_post_textarea";
  6180. bbcodeBarId = "#forum";
  6181. break;
  6182. case "/message/forward":
  6183. textareaId = "#message_message";
  6184. bbcodeBarId = "#message_bbcodes";
  6185. break;
  6186. case "/message/new":
  6187. textareaId = "#message_new_message";
  6188. bbcodeBarId = "#message_bbcodes";
  6189. break;
  6190. case "/message/view":
  6191. textareaId = "#message_reply_message";
  6192. bbcodeBarId = "#message_bbcodes";
  6193. break;
  6194. case "/player_memo/load_memo_content":
  6195. textareaId = "#memo_text_area";
  6196. bbcodeBarId = "#memo_edit";
  6197. break;
  6198. }
  6199.  
  6200. $('<a title="Verteidigungsformular" href="#" class="dio_bbcode_option def_form" name="def_form"></a>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
  6201.  
  6202. $('.def_form_button').css({
  6203. cursor: 'pointer',
  6204. marginTop: '3px'
  6205. });
  6206.  
  6207. $(bbcodeBarId + ' .dio_bbcode_option').css({
  6208. background: 'url("http://s14.directupload.net/images/140126/lt3hyb8j.png")',
  6209. display: 'block',
  6210. float: 'left',
  6211. width: '22px',
  6212. height: '23px',
  6213. margin: '0 3px 0 0',
  6214. position: 'relative'
  6215. });
  6216. $(bbcodeBarId + ' .def_form').css({
  6217. backgroundPosition: '-89px 0px'
  6218. });
  6219. var imgArray = {
  6220. wall: 'https://gpall.innogamescdn.com/images/game/main/wall.png',
  6221. tower: 'https://gpall.innogamescdn.com/images/game/main/tower.png',
  6222. hide: 'https://gpall.innogamescdn.com/images/game/main/hide.png',
  6223.  
  6224. spy: 'http://s7.directupload.net/images/140114/yr993xwc.png',
  6225. pop: 'http://s7.directupload.net/images/140114/4d6xktxm.png',
  6226.  
  6227. rev1: 'http://s7.directupload.net/images/140115/9cv6otiu.png',
  6228. rev0: 'http://s7.directupload.net/images/140115/aue4rg6i.png',
  6229. eo1: 'http://s1.directupload.net/images/140115/fkzlipyh.png',
  6230. eo0: 'http://s1.directupload.net/images/140115/hs2kg59c.png',
  6231. att: 'http://s1.directupload.net/images/140115/3t6uy4te.png',
  6232. sup: 'http://s7.directupload.net/images/140115/ty6szerx.png',
  6233.  
  6234. zeus: 'http://s1.directupload.net/images/140114/cdxecrpu.png',
  6235. hera: 'http://s1.directupload.net/images/140114/mve54v2o.png',
  6236. athena: 'http://s14.directupload.net/images/140114/kyqyedhe.png',
  6237. poseidon: 'http://s7.directupload.net/images/140114/tusr9oyi.png',
  6238. hades: 'http://s7.directupload.net/images/140114/huins2gn.png',
  6239. artemis: 'http://s7.directupload.net/images/140114/kghjhko8.png',
  6240. nogod: 'http://s1.directupload.net/images/140114/e7vmvfap.png',
  6241.  
  6242. captain: 'http://s14.directupload.net/images/140114/88gg75rc.png',
  6243. commander: 'http://s14.directupload.net/images/140114/slbst52o.png',
  6244. priest: 'http://s1.directupload.net/images/140114/glptekkx.png',
  6245.  
  6246. phalanx: 'http://s7.directupload.net/images/140114/e97wby6z.png',
  6247. ram: 'http://s7.directupload.net/images/140114/s854ds3w.png',
  6248.  
  6249. militia: 'http://wiki.en.grepolis.com/images/9/9b/Militia_40x40.png',
  6250. sword: 'http://wiki.en.grepolis.com/images/9/9c/Sword_40x40.png',
  6251. slinger: 'http://wiki.en.grepolis.com/images/d/dc/Slinger_40x40.png',
  6252. archer: 'http://wiki.en.grepolis.com/images/1/1a/Archer_40x40.png',
  6253. hoplite: 'http://wiki.en.grepolis.com/images/b/bd/Hoplite_40x40.png',
  6254. rider: 'http://wiki.en.grepolis.com/images/e/e9/Rider_40x40.png',
  6255. chariot: 'http://wiki.en.grepolis.com/images/b/b8/Chariot_40x40.png',
  6256. catapult: 'http://wiki.en.grepolis.com/images/f/f0/Catapult_40x40.png',
  6257. godsent: 'http://wiki.de.grepolis.com/images/6/6e/Grepolis_Wiki_225.png',
  6258.  
  6259. def_sum: 'http://s14.directupload.net/images/140127/6cxnis9r.png',
  6260.  
  6261. minotaur: 'http://wiki.de.grepolis.com/images/7/70/Minotaur_40x40.png',
  6262. manticore: 'http://wiki.de.grepolis.com/images/5/5e/Manticore_40x40.png',
  6263. zyclop: 'http://wiki.de.grepolis.com/images/6/66/Zyklop_40x40.png',
  6264. sea_monster: 'http://wiki.de.grepolis.com/images/7/70/Sea_monster_40x40.png',
  6265. harpy: 'http://wiki.de.grepolis.com/images/8/80/Harpy_40x40.png',
  6266. medusa: 'http://wiki.de.grepolis.com/images/d/db/Medusa_40x40.png',
  6267. centaur: 'http://wiki.de.grepolis.com/images/5/53/Centaur_40x40.png',
  6268. pegasus: 'http://wiki.de.grepolis.com/images/5/54/Pegasus_40x40.png',
  6269. cerberus: 'http://wiki.de.grepolis.com/images/6/67/Zerberus_40x40.png',
  6270. fury: 'http://wiki.de.grepolis.com/images/6/67/Erinys_40x40.png',
  6271. griffin: 'http://wiki.de.grepolis.com/images/d/d1/Unit_greif.png',
  6272. calydonian_boar: 'http://wiki.de.grepolis.com/images/9/93/Unit_eber.png',
  6273.  
  6274. big_transporter: 'http://wiki.en.grepolis.com/images/0/04/Big_transporter_40x40.png',
  6275. bireme: 'http://wiki.en.grepolis.com/images/4/44/Bireme_40x40.png',
  6276. attack_ship: 'http://wiki.en.grepolis.com/images/e/e6/Attack_ship_40x40.png',
  6277. demolition_ship: 'http://wiki.en.grepolis.com/images/e/ec/Demolition_ship_40x40.png',
  6278. small_transporter: 'http://wiki.en.grepolis.com/images/8/85/Small_transporter_40x40.png',
  6279. trireme: 'http://wiki.en.grepolis.com/images/a/ad/Trireme_40x40.png',
  6280. colonize_ship: 'http://wiki.en.grepolis.com/images/d/d1/Colonize_ship_40x40.png',
  6281.  
  6282. move_icon: 'https://gpall.innogamescdn.com/images/game/unit_overview/',
  6283.  
  6284. bordure: 'http://s1.directupload.net/images/140126/8y6pmetk.png'
  6285. };
  6286.  
  6287. $('<div class="bb_def_chooser">' +
  6288. '<div class="bbcode_box middle_center">' +
  6289. '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div>' +
  6290. '<div class="bbcode_box top_center"></div><div class="bbcode_box bottom_center"></div>' +
  6291. '<div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>' +
  6292. '<div class="bbcode_box middle_left"></div><div class="bbcode_box middle_right"></div>' +
  6293. '<div class="bbcode_box content clearfix" style="padding:5px">' +
  6294. '<div id="f_uni" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "det") + '</div></div><br><br>' +
  6295. '<div id="f_prm" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "prm") + '</div></div><br><br>' +
  6296. '<div id="f_sil" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "sil") + '</div></div><br><br>' +
  6297. '<div id="f_mov" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "mov") + '</div></div><br><br>' +
  6298. '<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>' +
  6299. '</div></div></div>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
  6300.  
  6301. $('.bb_def_chooser').css({
  6302. display: 'none',
  6303. top: '38px',
  6304. left: '510px',
  6305. position: 'absolute',
  6306. width: '190px',
  6307. zIndex: 10000
  6308. });
  6309.  
  6310. $(bbcodeBarId + " .bb_def_chooser .checkbox_new").click(function () {
  6311. $(this).toggleClass("checked");
  6312. });
  6313.  
  6314. $(bbcodeBarId + ' .def_form').toggleClick(function () {
  6315. $(this).parent().find(".bb_def_chooser").get(0).style.display = "block";
  6316. }, function () {
  6317. $(this).parent().find(".bb_def_chooser").get(0).style.display = "none";
  6318. });
  6319.  
  6320. $(bbcodeBarId + ' #dio_insert').click(function () {
  6321. var textarea = $(textareaId).get(0), text = $(textarea).val(), troop_table = "", troop_img = "", troop_count = "", separator = "", move_table = "", landunit_sum = 0;
  6322.  
  6323. $('.def_form').click();
  6324.  
  6325. if ($('#f_uni').hasClass("checked")) {
  6326. $('.units_land .unit, .units_naval .unit').each(function () {
  6327. troop_img += separator + '[img]' + imgArray[this.className.split(" ")[1]] + '[/img]';
  6328. troop_count += separator + '[center]' + $(this).find(".value").get(0).innerHTML + '[/center]';
  6329. separator = "[||]";
  6330. });
  6331. } else {
  6332. $('.units_land .unit').each(function () {
  6333. 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);
  6334. if (def > 10) {
  6335. landunit_sum += parseInt($(this).find(".value").get(0).innerHTML, 10) * uw.GameData.units[a].population * ((def > 20) ? 2 : 1);
  6336. }
  6337. });
  6338. landunit_sum = (landunit_sum > 10000) ? ((Math.round(landunit_sum / 100)) / 10) + "k" : landunit_sum;
  6339.  
  6340. troop_img += '[img]' + imgArray.def_sum + '[/img]';
  6341. troop_count += '[center]' + landunit_sum + '[/center]';
  6342. separator = "[||]";
  6343. $('.units_naval .unit').each(function () {
  6344. troop_img += separator + '[img]' + imgArray[this.className.split(" ")[1]] + '[/img]';
  6345. troop_count += separator + '[center]' + $(this).find(".value").get(0).innerHTML + '[/center]';
  6346. });
  6347. }
  6348. if (troop_img !== "") {
  6349. troop_table = "\n[table][**]" + troop_img + "[/**][**]" + troop_count + "[/**][/table]\n";
  6350. }
  6351.  
  6352. var str = '[img]' + imgArray.bordure + '[/img]' +
  6353. '\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' +
  6354. //'[table][**][img]'+ imgArray.sup +'[/img][||]'+
  6355. '[size=12][town]' + uw.ITowns.getTown(uw.Game.townId).getId() + '[/town] ([player]' + uw.Game.player_name + '[/player])[/size]' +
  6356. //'[||][img]'+ imgArray['rev' + (uw.ITowns.getTown(uw.Game.townId).hasConqueror()?1:0)] +'[/img][/**][/table]'+
  6357. '\n\n[i][b]' + getText("labels", "inf") + '[/b][/i]' + troop_table +
  6358. '[table][*]' +
  6359. '[img]' + imgArray.wall + '[/img][|]\n' +
  6360. '[img]' + imgArray.tower + '[/img][|]\n' +
  6361. '[img]' + imgArray.phalanx + '[/img][|]\n' +
  6362. '[img]' + imgArray.ram + '[/img][|]\n' +
  6363. ($('#f_prm').hasClass("checked") ? '[img]' + imgArray.commander + '[/img][|]\n' : ' ') +
  6364. ($('#f_prm').hasClass("checked") ? '[img]' + imgArray.captain + '[/img][|]\n' : ' ') +
  6365. ($('#f_prm').hasClass("checked") ? '[img]' + imgArray.priest + '[/img][|]\n' : ' ') +
  6366. ($('#f_sil').hasClass("checked") ? '[center][img]' + imgArray.spy + '[/img][/center][|]\n' : ' ') +
  6367. '[img]' + imgArray.pop + '[/img][|]\n' +
  6368. '[img]' + imgArray[(uw.ITowns.getTown(uw.Game.townId).god() || "nogod")] + '[/img][/*]\n' +
  6369. '[**][center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("wall") + '[/center][||]' +
  6370. '[center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("tower") + '[/center][||]' +
  6371. '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.phalanx ? '+' : '-') + '[/center][||]' +
  6372. '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.ram ? '+' : '-') + '[/center][||]' +
  6373. ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.commander >= uw.Timestamp.now()) ? '+' : '-') + '[/center][||]' : ' ') +
  6374. ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.captain >= uw.Timestamp.now()) ? '+' : '-') + '[/center][||]' : ' ') +
  6375. ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.priest >= uw.Timestamp.now()) ? '+' : '-') + '[/center][||]' : ' ') +
  6376. ($('#f_sil').hasClass("checked") ? '[center]' + Math.round(uw.ITowns.getTown(uw.Game.townId).getEspionageStorage() / 1000) + 'k[/center][||]' : ' ') +
  6377. '[center]' + uw.ITowns.getTown(uw.Game.townId).getAvailablePopulation() + '[/center][||]' +
  6378. '[center]' + $('.gods_favor_amount').get(0).innerHTML + '[/center]' +
  6379. '[/**][/table]';
  6380.  
  6381. var bb_count_str = parseInt(str.match(/\[/g).length, 10), bb_count_move = 0;
  6382.  
  6383. var i = 0;
  6384. if ($('#f_mov').hasClass("checked")) {
  6385. move_table += '\n[i][b]' + getText("labels", "mov") + '[/b][/i]\n[table]';
  6386.  
  6387. $('#toolbar_activity_commands').mouseover();
  6388.  
  6389. $('#toolbar_activity_commands_list .content .command').each(function () {
  6390. var cl = $(this).children()[0].className.split(" ");
  6391. 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)) {
  6392. move_table += (i % 1) ? "" : "[**]";
  6393. i++;
  6394. move_table += "[img]" + imgArray.move_icon + cl[2] + ".png[/img][||]";
  6395. move_table += getArrivalTime($(this).children()[1].innerHTML) + (uw.Game.market_id === "de" ? " Uhr[||]" : " [||]");
  6396. move_table += "[town]" + JSON.parse(atob($(this).children()[2].firstChild.href.split("#")[1])).id + "[/town]";
  6397. move_table += (i % 1) ? "[||]" : "[/**]";
  6398. }
  6399. bb_count_move = parseInt(move_table.match(/\[/g).length, 10);
  6400. });
  6401. if ((bb_count_str + bb_count_move) > 480) {
  6402. move_table += '[**]...[/**]';
  6403. }
  6404.  
  6405. $('#toolbar_activity_commands').mouseout();
  6406.  
  6407. //console.log((bb_count_str + bb_count_move));
  6408. move_table += (i % 1) ? "[/**]" : "";
  6409. move_table += "[*][|][color=#800000][size=6][i] (" + getText("labels", "dev") + ": ±1s)[/i][/size][/color][/*][/table]\n";
  6410. }
  6411.  
  6412. str += move_table + '[img]' + imgArray.bordure + '[/img]';
  6413.  
  6414.  
  6415. $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + str + text.substring($(textarea).get(0).selectionEnd));
  6416. });
  6417. }
  6418.  
  6419. function getArrivalTime(duration_time) {
  6420. /*
  6421. var server_time = new Date((uw.Timestamp.server() + 7200) * 1000);
  6422.  
  6423. duration_time = duration_time.split(":");
  6424.  
  6425. s = server_time.getUTCSeconds() + parseInt(duration_time[2], 10);
  6426. m = server_time.getUTCMinutes() + parseInt(duration_time[1], 10) + ((s>=60)? 1 : 0);
  6427. h = server_time.getUTCHours() + parseInt(duration_time[0], 10) + ((m>=60)? 1 : 0);
  6428. */
  6429.  
  6430. var server_time = $('.server_time_area').get(0).innerHTML.split(" ")[0].split(":"), arrival_time, s, m, h;
  6431. duration_time = duration_time.split(":");
  6432.  
  6433. s = parseInt(server_time[2], 10) + parseInt(duration_time[2], 10);
  6434. m = parseInt(server_time[1], 10) + parseInt(duration_time[1], 10) + ((s >= 60) ? 1 : 0);
  6435. h = parseInt(server_time[0], 10) + parseInt(duration_time[0], 10) + ((m >= 60) ? 1 : 0);
  6436.  
  6437. s = s % 60;
  6438. m = m % 60;
  6439. h = h % 24;
  6440.  
  6441. s = ((s < 10) ? "0" : "") + s;
  6442. m = ((m < 10) ? "0" : "") + m;
  6443. h = ((h < 10) ? "0" : "") + h;
  6444.  
  6445. arrival_time = h + ":" + m + ":" + s;
  6446.  
  6447. return arrival_time;
  6448. }
  6449.  
  6450.  
  6451. /*******************************************************************************************************************************
  6452. * Smiley box
  6453. * ----------------------------------------------------------------------------------------------------------------------------
  6454. * | ● Display of a smiley selection box for text input fields (forum, messages, notes):
  6455. * | ● Used smileys: http://www.greensmilies.com/smilie-album/
  6456. * | + Own Grepolis smileys
  6457. * ----------------------------------------------------------------------------------------------------------------------------
  6458. *******************************************************************************************************************************/
  6459.  
  6460. var smileyArray = {};
  6461.  
  6462. var SmileyBox = {
  6463. loading_error: false, isHalloween: false, isXmas: false, isForum: $(".editor_textbox_container").get(0),
  6464.  
  6465. activate: function () {
  6466. $('<style id="dio_smiley">' +
  6467. '.smiley_button { cursor:pointer; margin:3px 2px 2px 2px; } ' +
  6468.  
  6469. '.smiley_box.game { z-index:5000; position:absolute; top:27px; left:430px; min-width:300px; display:none; } ' +
  6470.  
  6471. // Smiley categories
  6472. '.smiley_box .box_header { display: table; width: 100%; text-align:center; } ' +
  6473. '.smiley_box .group { display:table-cell; color: #0c450c; cursor: pointer; font-weight:bold; padding: 0px 2px 0px 2px; } ' +
  6474. '.smiley_box .group.active { color: #089421; text-decoration:underline;} ' +
  6475. '.smiley_box .group:hover { color: #14999E; } ' + // #11AD6C
  6476.  
  6477. // Special smiley categories
  6478. '.smiley_box .halloween { color: #E25E00; } ' +
  6479. '.smiley_box .xmas { color: darkred; } ' +
  6480.  
  6481. '.smiley_box hr { margin:3px 0px 0px 0px; color:#086b18; border:1px solid; } ' +
  6482.  
  6483. // Smilies
  6484. '.smiley_box .box_content { overflow: hidden; } ' +
  6485. '.smiley_box .box_content .smiley { border: 1px solid rgba(0,0,0,0); border-radius: 5px;} ' +
  6486. '.smiley_box .box_content .smiley:hover { background: rgba(8, 148, 77, 0.2); border: 1px solid rgba(0, 128, 0, 0.5); } ' +
  6487.  
  6488. // Smiley page link
  6489. '.smiley_box .box_footer { text-align:center; margin-top:4px; } ' +
  6490. '.smiley_box a:link, .smiley_box a:visited { color: #086b18; font-size: 0.7em; } ' +
  6491. '.smiley_box a:hover { color: #14999E; } ' +
  6492.  
  6493. // TODO Forum ...
  6494. '.smiley_box.forum .box_header_left { float:left; } ' +
  6495. //'.smiley_box.forum .group { padding-right: 10px; } '+
  6496. '.smiley_box.forum .box_header_right { text-align:right; margin-top:2px; } ' +
  6497.  
  6498. '.smiley_box.forum { max-height:90px; margin-left:5px; width:99%; min-height:10px; } ' +
  6499. '.smiley_box.forum .box_content { overflow:overlay; min-height:70px; margin-bottom:10px; } ' +
  6500.  
  6501. '.smiley_box.forum a:link, .smiley_box.forum a:visited { font-size: 1em; } ' +
  6502.  
  6503. '</style>').appendTo('head');
  6504.  
  6505.  
  6506. // Smiley categories
  6507. smileyArray.button = ["rollsmiliey", "smile"];
  6508.  
  6509. smileyArray.standard = [
  6510. "smilenew", "i/cnfy7elqh8dotnsdp", "lol", "neutral_new", "afraid", "freddus_pacman", "auslachen2", "kolobok-sanduhr", "bussi2", "winken4", "flucht2", "panik4", "ins-auge-stechen",
  6511. "seb_zunge", "fluch4_GREEN", "baby_junge2", "blush-reloaded6", "frown", "verlegen", "blush-pfeif", "stevieh_rolleyes", "daumendreh2", "baby_taptap",
  6512. "sadnew", "hust", "confusednew", "idea2", "irre", "irre4", "sleep", "candle", "nicken", "no_sad",
  6513. "thumbs-up_new", "thumbs-down_new", "bravo2", "oh-no2", "kaffee2", "drunk", "saufen", "freu-dance", "hecheln", "headstand", "rollsmiliey", "eazy_cool01", "motz", "cuinlove", "biggrin"
  6514. ];
  6515. smileyArray.nature = [
  6516. "dinosaurier07", "flu-super-gau", "ben_cat", "schwein", "hundeleine01", "blume", "ben_sharky", "ben_cow", "charly_bissig", "gehirnschnecke_confused", "mttao_fische", "mttao_angler",
  6517. "insel", "fliegeschnappen", "i/cifohy0y1cl7nckzw", /* Spinne */ "i/cifogx34asrswrcjw", /* Schiffbrüchiger */ "plapperhase", "ben_dumbo"
  6518. ];
  6519. smileyArray.grepolis = [
  6520. "mttao_wassermann", "i/cigrmpfofys5xtiks", /* Hera */ "i/cifvfsu3e2sdiipn0", /* Medusa */ "i/cigmv8wnffb3v0ifg", /* Mantikor */ "i/cigrqlp2odi2kqo24", /* Zyklop */
  6521. "i/cj1l9gndtu3nduyvi", /* Minotaurus */ "i/cj2byjendffymp88t", /* Pegasus */ "i/cj2ccmi2x8mhcoikd", /* Hydra */
  6522. "silvester_cuinlove", "mttao_schuetze", "kleeblatt2", "wallbash", /* "glaskugel4", */ "musketiere_fechtend", /* "krone-hoch",*/ "i/cifojb85jytq5h07g", // Wikinger
  6523. "mttao_waage2", "steckenpferd", /* "kinggrin_anbeten2", */ "i/cifohielywpedbyh8", /* Grepo Love */ "skullhaufen", "pferdehaufen" // "i/ckajscggscw4s2u60"
  6524. ];
  6525. smileyArray.people = [
  6526. "seb_hut5", "opa_boese2", "star-wars-yoda1-gruen", "hexefliegend", "snob", "seb_detektiv_ani", "seb_cowboy", "devil", "segen", "pirat5", "borg", "hexe3b",
  6527. "i/cifoqe3geok0jco5o", // Ägypter
  6528. "i/ciforgs313z0ae1cc", // Hippie
  6529. "eazy_polizei", "stars_elvis", "mttao_chefkoch", "nikolaus", "pirate3_biggrin", "batman_skeptisch", "tubbie1", "tubbie2", "tubbie3", "tubbie4"
  6530. ];
  6531. smileyArray.other = [
  6532. "steinwerfen", "herzen02", "scream-if-you-can", "kolobok", "headbash", "liebeskummer", "bussi", "brautpaar-reis", "grab-schaufler2", "boxen2", "aufsmaul",
  6533. "sauf", "mttao_kehren", "sm", "weckruf", "klugscheisser2", "karte2_rot", "dagegen", "party", "dafuer", "outofthebox", "pokal_gold", "koepfler", "transformer"
  6534. ];
  6535.  
  6536. SmileyBox.checkHolidaySeason();
  6537.  
  6538. if (SmileyBox.isHalloween) {
  6539. smileyArray.halloween = [
  6540. "zombies_alien", "zombies_lol", "zombies_rolleyes", "zombie01", "zombies_smile", "zombie02", "zombies_skeptisch", "zombies_eek", "zombies_frown",
  6541. "scream-if-you-can", "geistani", "pfeildurchkopf01", "grab-schaufler", "kuerbisleuchten", "mummy3",
  6542. "kuerbishaufen", "halloweenskulljongleur", "fledermausvampir", "frankenstein_lol", "halloween_confused", "zombies_razz",
  6543. "halloweenstars_freddykrueger", "zombies_cool", "geist2", "fledermaus2", "halloweenstars_dracula"
  6544. // "batman" "halloweenstars_lastsummer"
  6545. ];
  6546. }
  6547. if (SmileyBox.isXmas) {
  6548. smileyArray.xmas = [
  6549. "schneeballwerfen", "schneeball", "xmas4_advent4", "nikolaus", "weihnachtsmann_junge", "schneewerfen_wald", "weihnachtsmann_nordpol", "xmas_kilroy_kamin",
  6550. "xmas4_laola", "xmas4_aufsmaul", "xmas3_smile", "xmas4_paketliebe", "mttao_ruprecht_peitsche", "3hlkoenige", "santa", "xmas4_hurra2", "weihnachtsgeschenk2", "fred_weihnachten-ostern"
  6551. //"dafuer", "outofthebox", "pokal_gold", "koepfler", "transformer"
  6552. ];
  6553. }
  6554.  
  6555. //smileyArray.other = smileyArray.halloween.slice();
  6556.  
  6557. // Forum: Extra smiley
  6558. if (SmileyBox.isForum) {
  6559. smileyArray.grepolis.push("i/ckajscggscw4s2u60"); // Pacman
  6560. smileyArray.grepolis.push("i/cowqyl57t5o255zli"); // Bugpolis
  6561. smileyArray.grepolis.push("i/cowquq2foog1qrbee"); // Inno
  6562. }
  6563.  
  6564. SmileyBox.loadSmileys();
  6565. },
  6566. deactivate: function () {
  6567. $('#dio_smiley').remove();
  6568. },
  6569. checkHolidaySeason: function () {
  6570. // TODO: HolidaySpecial-Klasse stattdessen benutzen
  6571. var daystamp = 1000 * 60 * 60 * 24, today = new Date((new Date()) % (daystamp * (365 + 1 / 4))), // without year
  6572.  
  6573. // Halloween-Smileys ->15 days
  6574. halloween_start = daystamp * 297, // 25. Oktober
  6575. halloween_end = daystamp * 321, // 8. November
  6576. // Xmas-Smileys -> 28 Tage
  6577. xmas_start = daystamp * 334, // 1. Dezember
  6578. xmas_end = daystamp * 361; // 28. Dezember
  6579.  
  6580. SmileyBox.isHalloween = (today >= halloween_start) ? (today <= halloween_end) : false;
  6581.  
  6582. SmileyBox.isXmas = (today >= xmas_start) ? (today <= xmas_end) : false;
  6583. },
  6584. // preload images
  6585. loadSmileys: function () {
  6586. // Replace german sign smilies
  6587. if (LID !== "de") {
  6588. smileyArray.other[17] = "dagegen2";
  6589. smileyArray.other[19] = "dafuer2";
  6590. }
  6591.  
  6592. for (var e in smileyArray) {
  6593. if (smileyArray.hasOwnProperty(e)) {
  6594. for (var f in smileyArray[e]) {
  6595. if (smileyArray[e].hasOwnProperty(f)) {
  6596. var src = smileyArray[e][f];
  6597.  
  6598. smileyArray[e][f] = new Image();
  6599. smileyArray[e][f].className = "smiley";
  6600.  
  6601. if (src.substring(0, 2) == "i/") {
  6602. smileyArray[e][f].src = "http://666kb.com/" + src + ".gif";
  6603. } else {
  6604. if (SmileyBox.loading_error == false) {
  6605. smileyArray[e][f].src = "http://www.greensmilies.com/smile/smiley_emoticons_" + src + ".gif";
  6606. } else {
  6607. smileyArray[e][f].src = 'http://s1.directupload.net/images/140128/93x3p4co.gif';
  6608. }
  6609. }
  6610. smileyArray[e][f].onerror = function () {
  6611. this.src = 'http://s1.directupload.net/images/140128/93x3p4co.gif';
  6612. };
  6613. }
  6614. }
  6615. }
  6616. }
  6617. },
  6618.  
  6619. // Forum smilies
  6620. changeForumEditorLayout: function () {
  6621. $('.blockrow').css({border: "none"});
  6622.  
  6623. // Subject/Title
  6624. $($('.section div label[for="title"]').parent()).css({float: "left", width: "36%", marginRight: "20px"});
  6625. $($('.section div label[for="subject"]').parent()).css({float: "left", width: "36%", marginRight: "20px"});
  6626.  
  6627. $('.section div input').eq(0).css({marginBottom: "-10px", marginTop: "10px"});
  6628. $('#display_posticon').remove();
  6629.  
  6630. // Posticons
  6631. $('.posticons table').css({width: "50%" /* marginTop: "-16px"*/});
  6632. $('.posticons').css({marginBottom: "-16px"});
  6633. $('.posticons').insertAfter($('.section div label[for="title"]').parent());
  6634. $('.posticons').insertAfter($('.section div label[for="subject"]').parent());
  6635. // Posticons hint
  6636. $('.posticons p').remove();
  6637. // Posticons: No Icon - radio button
  6638. $(".posticons [colspan='14']").parent().replaceWith($(".posticons [colspan='14']"));
  6639. $(".posticons [colspan='14']").children().wrap("<nobr></nobr>");
  6640. $(".posticons [colspan='14']").appendTo('.posticons tr:eq(0)');
  6641. $(".posticons [colspan='4']").remove();
  6642. },
  6643.  
  6644. addForum: function () {
  6645. $('<div class="smiley_box forum"><div>' +
  6646. '<div class="box_header_left">' +
  6647. '<span class="group standard active">' + getText("labels", "std") + '</span>' +
  6648. '<span class="group grepolis">' + getText("labels", "gre") + '</span>' +
  6649. '<span class="group nature">' + getText("labels", "nat") + '</span>' +
  6650. '<span class="group people">' + getText("labels", "ppl") + '</span>' +
  6651. '<span class="group other">' + getText("labels", "oth") + '</span>' +
  6652. (SmileyBox.isHalloween ? '<span class="group halloween">' + getText("labels", "hal") + '</span>' : '') +
  6653. (SmileyBox.isXmas ? '<span class="group xmas">' + getText("labels", "xma") + '</span>' : '') +
  6654. '</div>' +
  6655. '<div class="box_header_right"><a class="smiley_link" href="http://www.greensmilies.com/smilie-album/" target="_blank">WWW.GREENSMILIES.COM</a></div>' +
  6656. '<hr>' +
  6657. '<div class="box_content" style="overflow: hidden;"><hr></div>' +
  6658. '</div></div><br>').insertAfter(".texteditor");
  6659.  
  6660. SmileyBox.addSmileys("standard", "");
  6661.  
  6662. $('.group').click(function () {
  6663. $('.group.active').removeClass("active");
  6664. $(this).addClass("active");
  6665. // Change smiley group
  6666. SmileyBox.addSmileys(this.className.split(" ")[1], "");
  6667. });
  6668. },
  6669.  
  6670. // add smiley box
  6671. add: function (e) {
  6672. var bbcodeBarId = "";
  6673. switch (e) {
  6674. case "/alliance_forum/forum":
  6675. bbcodeBarId = "#forum";
  6676. break;
  6677. case "/message/forward":
  6678. bbcodeBarId = "#message_bbcodes";
  6679. break;
  6680. case "/message/new":
  6681. bbcodeBarId = "#message_bbcodes";
  6682. break;
  6683. case "/message/view":
  6684. bbcodeBarId = "#message_bbcodes";//setWonderIconsOnMap
  6685. break;
  6686. case "/player_memo/load_memo_content":
  6687. bbcodeBarId = "#memo_edit"; // old notes
  6688. break;
  6689. case "/frontend_bridge/fetch":
  6690. bbcodeBarId = ".notes_container"; // TODO: new notes
  6691. break;
  6692. }
  6693. if (($(bbcodeBarId + ' #emots_popup_7').get(0) || $(bbcodeBarId + ' #emots_popup_15').get(0)) && PID == 84367) {
  6694. $(bbcodeBarId + " .bb_button_wrapper").get(0).lastChild.remove();
  6695. }
  6696. $('<img class="smiley_button" src="http://www.greensmilies.com/smile/smiley_emoticons_smile.gif">').appendTo(bbcodeBarId + ' .bb_button_wrapper');
  6697.  
  6698. $('<div class="smiley_box game">' +
  6699. '<div class="bbcode_box middle_center"><div class="bbcode_box middle_right"></div><div class="bbcode_box middle_left"></div>' +
  6700. '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div><div class="bbcode_box top_center"></div>' +
  6701. '<div class="bbcode_box bottom_center"></div><div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>' +
  6702. '<div class="box_header">' +
  6703. '<span class="group standard active">' + getText("labels", "std") + '</span>' +
  6704. '<span class="group grepolis">' + getText("labels", "gre") + '</span>' +
  6705. '<span class="group nature">' + getText("labels", "nat") + '</span>' +
  6706. '<span class="group people">' + getText("labels", "ppl") + '</span>' +
  6707. '<span class="group ' + (SmileyBox.isHalloween ? 'halloween' : (SmileyBox.isXmas ? 'xmas' : 'other')) + '">' + getText("labels", (SmileyBox.isHalloween ? 'hal' : (SmileyBox.isXmas ? 'xma' : 'oth'))) + '</span>' +
  6708. '</div>' +
  6709. '<hr>' +
  6710. '<div class="box_content"></div>' +
  6711. '<hr>' +
  6712. '<div class="box_footer"><a href="http://www.greensmilies.com/smilie-album/" target="_blank">WWW.GREENSMILIES.COM</a></div>' +
  6713. '</div>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
  6714.  
  6715.  
  6716. $(bbcodeBarId + ' .group').click(function () {
  6717. $('.group.active').removeClass("active");
  6718. $(this).addClass("active");
  6719. // Change smiley group
  6720. SmileyBox.addSmileys(this.className.split(" ")[1], "#" + $(this).closest('.bb_button_wrapper').parent().get(0).id);
  6721. });
  6722.  
  6723. SmileyBox.addSmileys("standard", bbcodeBarId);
  6724.  
  6725. // smiley box toggle
  6726. $(bbcodeBarId + " .smiley_button").toggleClick(
  6727. function () {
  6728. this.src = smileyArray.button[0].src;
  6729. $(this).closest('.bb_button_wrapper').find(".smiley_box").get(0).style.display = "block";
  6730. },
  6731. function () {
  6732. this.src = smileyArray.button[1].src;
  6733. $(this).closest('.bb_button_wrapper').find(".smiley_box").get(0).style.display = "none";
  6734. }
  6735. );
  6736. },
  6737.  
  6738. // insert smileys from arrays into smiley box
  6739. addSmileys: function (type, bbcodeBarId) {
  6740. // reset smilies
  6741. if ($(bbcodeBarId + " .box_content").get(0)) {
  6742. $(bbcodeBarId + " .box_content").get(0).innerHTML = '';
  6743. }
  6744. // add smilies
  6745. for (var e in smileyArray[type]) {
  6746. if (smileyArray[type].hasOwnProperty(e)) {
  6747. $(smileyArray[type][e]).clone().appendTo(bbcodeBarId + " .box_content");
  6748. //$('<img class="smiley" src="' + smileyArray[type][e].src + '" alt="" />').appendTo(bbcodeBarId + " .box_content");
  6749. }
  6750. }
  6751. $('.smiley').css({margin: '0px', padding: '2px', maxHeight: '35px', cursor: 'pointer'});
  6752.  
  6753. $(bbcodeBarId + " .box_content .smiley").click(function () {
  6754. var textarea;
  6755. if (uw.location.pathname === "/game/index") {
  6756. // hide smiley box
  6757. $(this).closest('.bb_button_wrapper').find(".smiley_button").click();
  6758. // find textarea
  6759. textarea = $(this).closest('.gpwindow_content').find("textarea").get(0);
  6760. } else {
  6761.  
  6762. if ($('.editor_textbox_container').get(0)) {
  6763. textarea = $('.editor_textbox_container .cke_contents textarea').get(0);
  6764. } else {
  6765. $(this).appendTo('iframe .forum');
  6766. }
  6767. }
  6768. var text = $(textarea).val();
  6769. $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + "[img]" + this.src + "[/img]" + text.substring($(textarea).get(0).selectionEnd));
  6770. });
  6771. }
  6772. };
  6773.  
  6774. if ($(".editor_textbox_container").get(0)) {
  6775. SmileyBox.activate();
  6776. SmileyBox.changeForumEditorLayout();
  6777. SmileyBox.addForum();
  6778. }
  6779.  
  6780. /*******************************************************************************************************************************
  6781. * Biremes counter
  6782. * ----------------------------------------------------------------------------------------------------------------------------
  6783. * | ● Incremental update when calling a city (experimental, especially intended for siege worlds)
  6784. * ----------------------------------------------------------------------------------------------------------------------------
  6785. * @deprecated
  6786. * *****************************************************************************************************************************/
  6787. var BiremeCounter = {
  6788. activate: function () {
  6789. $(".picomap_container").prepend("<div id='available_bullseye_unit'><div id='bi_count'></div></div>");
  6790.  
  6791. $('.picomap_overlayer').tooltip(getText("options", "bir")[0]);
  6792. BiremeCounter.update();
  6793.  
  6794. // Style
  6795. $('<style id="dio_bireme_counter">' +
  6796. '#available_bullseye_unit { background: url(https://gpall.innogamescdn.com/images/game/units/units_sprite_90x90_compressed.jpg); height:90px;' +
  6797. 'width:90px; position: relative; margin: 5px 28px 0px 28px; background-position: -270px 0px; } ' +
  6798. '#bi_count { color:#826021; position:relative; top:28px; font-style:italic; width:79px; } ' +
  6799. '#sea_id { background: none; font-size:25px; cursor:default; height:50px; width:50px; position:absolute; top:70px; left:157px; z-index: 30; } ' +
  6800. '</style>').appendTo('head');
  6801.  
  6802. // fs_count: color: #FFC374;position: relative;top: 30px;font-style: italic;width: 101px;text-shadow: 1px 1px 0px rgb(69, 0, 0);
  6803. // manti: background-position: -1350px 180px;
  6804. // manti-count: color: #ECD181;position: relative;top: 48px;font-style: italic;width: 52px;text-shadow: 2px 2px 0px rgb(0, 0, 0);
  6805. // medusa:-1440px 182px;
  6806. // med-count: color: #DEECA4;position: relative;top: 50px;font-style: italic;width: 55px;text-shadow: 2px 2px 0px rgb(0, 0, 0);
  6807.  
  6808. // Set Sea-ID beside the bull eye
  6809. $('#sea_id').prependTo('#ui_box');
  6810. },
  6811. deactivate: function () {
  6812. $('#available_bullseye_unit').remove();
  6813. $('#dio_bireme_counter').remove();
  6814. $('#sea_id').appendTo('.picomap_container');
  6815. },
  6816. save: function () {
  6817. saveValue(WID + "_biremes", JSON.stringify(biriArray));
  6818. },
  6819. update: function () {
  6820. var sum = 0, e;
  6821. if ($('#bi_count').get(0)) {
  6822. for (e in biriArray) {
  6823. if (biriArray.hasOwnProperty(e)) {
  6824. if (!uw.ITowns.getTown(e)) { // town is no longer in possession of user
  6825. delete biriArray[e];
  6826. BiremeCounter.save();
  6827. } else {
  6828. sum += parseInt(biriArray[e], 10);
  6829. }
  6830. }
  6831. }
  6832.  
  6833. sum = sum.toString();
  6834. var str = "", fsize = ['1.4em', '1.2em', '1.15em', '1.1em', '1.0em'], i;
  6835.  
  6836. for (i = 0; i < sum.length; i++) {
  6837. str += "<span style='font-size:" + fsize[i] + "'>" + sum[i] + "</span>";
  6838. }
  6839. $('#bi_count').get(0).innerHTML = "<b>" + str + "</b>";
  6840. }
  6841. },
  6842. get: function () {
  6843. var biremeIn = parseInt(uw.ITowns.getTown(uw.Game.townId).units().bireme, 10),
  6844. biremeOut = parseInt(uw.ITowns.getTown(uw.Game.townId).unitsOuter().bireme, 10);
  6845. if (isNaN(biremeIn)) biremeIn = 0;
  6846. if (isNaN(biremeOut)) biremeOut = 0;
  6847. if (!biriArray[uw.Game.townId] || biriArray[uw.Game.townId] < (biremeIn + biremeOut)) {
  6848. biriArray[uw.Game.townId] = biremeIn;
  6849. }
  6850. BiremeCounter.update();
  6851. BiremeCounter.save();
  6852. },
  6853. getDocks: function () {
  6854. var windowID = uw.BuildingWindowFactory.getWnd().getID(),
  6855. biremeTotal = parseInt($('#gpwnd_' + windowID + ' #unit_order_tab_bireme .unit_order_total').get(0).innerHTML, 10);
  6856.  
  6857. if (!isNaN(biremeTotal)) biriArray[uw.Game.townId] = biremeTotal;
  6858. BiremeCounter.update();
  6859. BiremeCounter.save();
  6860. },
  6861. getAgora: function () {
  6862. var biremeTotal = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().bireme, 10);
  6863. if (isNaN(biremeTotal)) biremeTotal = 0;
  6864.  
  6865. $('#units_beyond_list .bireme').each(function () {
  6866. biremeTotal += parseInt(this.children[0].innerHTML, 10);
  6867. });
  6868. biriArray[uw.Game.townId] = biremeTotal;
  6869. BiremeCounter.update();
  6870. BiremeCounter.save();
  6871. }
  6872. };
  6873.  
  6874. /*******************************************************************************************************************************
  6875. * Favor Popup
  6876. * ----------------------------------------------------------------------------------------------------------------------------
  6877. * | ● Improved favor popup
  6878. * ----------------------------------------------------------------------------------------------------------------------------
  6879. *******************************************************************************************************************************/
  6880. var FavorPopup = {
  6881. godArray: {
  6882. zeus: '0px',
  6883. hera: '-152px',
  6884. poseidon: '-101px',
  6885. athena: '-50px',
  6886. hades: '-203px',
  6887. artemis: '-305px'
  6888. }, godImg: (new Image()).src = "https://diotools.de/images/game/gods.png",
  6889.  
  6890. activate: function () {
  6891. $('.gods_favor_button_area, #favor_circular_progress').bind('mouseover mouseout', function () {
  6892. return false;
  6893. });
  6894. $('.gods_area').bind('mouseover', function () {
  6895. FavorPopup.setFavorPopup();
  6896. });
  6897. },
  6898.  
  6899. deactivate: function () {
  6900. $('.gods_favor_button_area, #favor_circular_progress').unbind('mouseover mouseout');
  6901. $('.gods_area').unbind('mouseover');
  6902. },
  6903.  
  6904. setFavorPopup: function () {
  6905. var pic_row = "", fav_row = "", prod_row = "", tooltip_str;
  6906.  
  6907. for (var g in FavorPopup.godArray) {
  6908. if (FavorPopup.godArray.hasOwnProperty(g)) {
  6909. if (uw.ITowns.player_gods.attributes.temples_for_gods[g]) {
  6910. pic_row += '<td><div style="width:50px;height:51px;background:url(' + FavorPopup.godImg + ');background-position: 0px ' + FavorPopup.godArray[g] + ';"></td>';
  6911. fav_row += '<td class="bold" style="color:blue">' + uw.ITowns.player_gods.attributes[g + "_favor"] + '</td>';
  6912. prod_row += '<td class="bold">' + uw.ITowns.player_gods.attributes.production_overview[g].production + '</td>';
  6913. }
  6914. }
  6915. }
  6916. tooltip_str = $('<table><tr><td></td>' + pic_row + '</tr>' +
  6917. '<tr align="center"><td><img src="https://gpall.innogamescdn.com/images/game/res/favor.png"></td>' + fav_row + '</tr>' +
  6918. '<tr align="center"><td>+</td>' + prod_row + '</tr>' +
  6919. '</table>');
  6920.  
  6921. $('.gods_favor_button_area, #favor_circular_progress').tooltip(tooltip_str);
  6922. }
  6923. };
  6924.  
  6925. /*******************************************************************************************************************************
  6926. * GUI Optimization
  6927. * ----------------------------------------------------------------------------------------------------------------------------
  6928. * | ● Modified spell box (smaller, moveable & position memory)
  6929. * | ● Larger taskbar and minimize daily reward-window on startup
  6930. * | ● Modify chat
  6931. * | ● Improved display of troops and trade activity boxes (movable with position memory on startup)
  6932. * ----------------------------------------------------------------------------------------------------------------------------
  6933. *******************************************************************************************************************************/
  6934.  
  6935. var Spellbox = {
  6936. observe: function () {
  6937. $.Observer(uw.GameEvents.ui.layout_gods_spells.rendered).subscribe('DIO_SPELLBOX_CHANGE_OPEN', function () {
  6938. if (spellbox.show == false) {
  6939. spellbox.show = true;
  6940. saveValue("spellbox", JSON.stringify(spellbox));
  6941. }
  6942. Spellbox.change();
  6943. });
  6944. $.Observer(uw.GameEvents.ui.layout_gods_spells.state_changed).subscribe('DIO_SPELLBOX_CLOSE', function () {
  6945. spellbox.show = false;
  6946. saveValue("spellbox", JSON.stringify(spellbox));
  6947. });
  6948.  
  6949. // GRCRT Bug-Fix
  6950. if(typeof(RepConv) !== "undefined") {
  6951. $.Observer(uw.GameEvents.ui.layout_gods_spells.rendered).unsubscribe('GRCRT_GRC_ui_layout_gods_spells_rendered');
  6952.  
  6953. $.Observer(uw.GameEvents.ui.layout_gods_spells.rendered).subscribe('GRCRT_GRC_ui_layout_gods_spells_rendered', function () {
  6954. // PlayerGods doesn't exists at game start and the function would call an error
  6955. if (typeof(RepConv.models.PlayerGods) !== "undefined") {
  6956. RepConvTool.loadPower();
  6957. }
  6958. });
  6959. }
  6960. },
  6961.  
  6962. activate: function () {
  6963. Spellbox.observe();
  6964. Spellbox.change();
  6965.  
  6966. $('<style id="dio_spellbox_style" type="text/css">' +
  6967. // Don't hide hero box, unit time box and hero coin box from GRC
  6968. '#ui_box .nui_right_box { overflow: visible; } ' +
  6969. // Hide negative spells
  6970. '#ui_box .bolt, #ui_box .earthquake, #ui_box .pest { display: none } ' +
  6971. // Change spell order
  6972. '#ui_box .god_container { float: left } ' +
  6973. '#ui_box .god_container[data-god_id="zeus"], #ui_box .god_container[data-god_id="athena"] { float: none } ' +
  6974. // Remove background
  6975. '#ui_box .powers_container { background: none !important } ' +
  6976. // Hide god titles
  6977. '#ui_box .content .title { display: none !important } ' +
  6978. // Hide border elements
  6979. '#ui_box .gods_spells_menu .left, #ui_box .gods_spells_menu .right, #ui_box .gods_spells_menu .top, #ui_box .gods_spells_menu .bottom { display: none } ' +
  6980. // Layout
  6981. '#ui_box .gods_area { height:150px } ' +
  6982.  
  6983. '#ui_box .gods_spells_menu { width: 134px; position:absolute; z-index:5000; padding:30px 0px 0px -4px } ' +
  6984. '#ui_box .gods_spells_menu .content { background:url(https://gpall.innogamescdn.com/images/game/layout/power_tile.png) 1px 4px; overflow:auto; margin:0 0 0px 0px; border:3px inset rgb(16, 87, 19); border-radius:10px } ' +
  6985.  
  6986. '#ui_box .nui_units_box { display:block; margin-top:-8px; position:relative } ' +
  6987. '#ui_box .nui_units_box .bottom_ornament { margin-top:-28px; position: relative } ' +
  6988. '</style>').appendTo('head');
  6989.  
  6990. // Draggable Box
  6991. $("#ui_box .gods_spells_menu").draggable({
  6992. containment: "body",
  6993. distance: 10,
  6994. snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, #island_quests_overview",
  6995. opacity: 0.7,
  6996. stop: function () {
  6997. spellbox.top = this.style.top;
  6998. spellbox.left = this.style.left;
  6999.  
  7000. saveValue("spellbox", JSON.stringify(spellbox));
  7001. }
  7002. });
  7003. $("#ui_box .gods_spells_menu").before($('#ui_box .nui_units_box'));
  7004.  
  7005. // Position
  7006. $('#ui_box .gods_spells_menu').css({
  7007. left: spellbox.left,
  7008. top: spellbox.top
  7009. });
  7010.  
  7011. // Active at game start?
  7012. if (spellbox.show && !$('#ui_box .btn_gods_spells').hasClass('active')) {
  7013. $('#ui_box .btn_gods_spells').click();
  7014. }
  7015. },
  7016. deactivate: function () {
  7017. $('#ui_box .gods_spells_menu').draggable('destroy');
  7018.  
  7019. // Position
  7020. $('#ui_box .gods_spells_menu').css({
  7021. left: "auto",
  7022. top: "150px"
  7023. });
  7024.  
  7025. //$("#ui_box .gods_spells_menu").appendTo('gods_area'); // ?
  7026.  
  7027. $('#dio_spellbox_style').remove();
  7028.  
  7029. $.Observer(GameEvents.ui.layout_gods_spells.rendered).unsubscribe('DIO_SPELLBOX_CHANGE_OPEN');
  7030. $.Observer(GameEvents.ui.layout_gods_spells.state_changed).unsubscribe('DIO_SPELLBOX_CLOSE');
  7031. },
  7032.  
  7033. change: function () {
  7034. //console.log("Unitsbox: "+ $(".nui_units_box").height());
  7035. //console.log("Spellbox: "+ $(".gods_spells_menu").height());
  7036.  
  7037. // Change spell order
  7038. $('#ui_box .god_container[data-god_id="poseidon"]').prependTo('#ui_box .gods_spells_menu .content');
  7039. $('#ui_box .god_container[data-god_id="athena"]').appendTo('#ui_box .gods_spells_menu .content');
  7040. $('#ui_box .god_container[data-god_id="artemis"]').appendTo('#ui_box .gods_spells_menu .content');
  7041. }
  7042.  
  7043. };
  7044.  
  7045.  
  7046. // Minimize Daily reward window on startup
  7047. function minimizeDailyReward() {
  7048. /*
  7049. $.Observer(uw.GameEvents.window.open).subscribe('DIO_WINDOW', function(u,dato){});
  7050. $.Observer(uw.GameEvents.window.reload).subscribe('DIO_WINDOW2', function(f){});
  7051. */
  7052. if (MutationObserver) {
  7053. var startup = new MutationObserver(function (mutations) {
  7054. mutations.forEach(function (mutation) {
  7055. if (mutation.addedNodes[0]) {
  7056. if ($('.daily_login').get(0)) { // && !uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).isMinimized()
  7057. $('.daily_login').find(".minimize").click();
  7058. //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).minimize();
  7059. }
  7060. }
  7061. });
  7062. });
  7063. startup.observe($('body').get(0), {attributes: false, childList: true, characterData: false});
  7064.  
  7065. setTimeout(function () {
  7066. startup.disconnect();
  7067. }, 3000);
  7068. }
  7069. }
  7070.  
  7071. // Larger taskbar
  7072. var Taskbar = {
  7073. activate: function () {
  7074. $('.minimized_windows_area').get(0).style.width = "150%";
  7075. $('.minimized_windows_area').get(0).style.left = "-25%";
  7076. },
  7077. deactivate: function () {
  7078. $('.minimized_windows_area').get(0).style.width = "100%";
  7079. $('.minimized_windows_area').get(0).style.left = "0%";
  7080. }
  7081. };
  7082.  
  7083. // Hide fade out buttons
  7084. function hideNavElements() {
  7085. if (Game.premium_features.curator <= Timestamp.now()) {
  7086. $('.nav').each(function () {
  7087. this.style.display = "none";
  7088. });
  7089. }
  7090. }
  7091.  
  7092. /*******************************************************************************************************************************
  7093. * Modify Chat
  7094. *******************************************************************************************************************************/
  7095. var Chat = {
  7096. interval: null,
  7097.  
  7098. activate: function () {
  7099. if (!$('#dio_flash').get(0)) {
  7100. $('<script id="dio_flash" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>').appendTo('head');
  7101. }
  7102. $('<style id="dio_chat">.nui_main_menu .chat { filter: "url(#Hue1)"; -webkit-filter: "hue-rotate(65deg)"; }</style>').appendTo('head');
  7103. Chat.updateChatUser();
  7104. Chat.interval = setInterval(function () {
  7105. Chat.updateChatUser();
  7106. }, 300000); // 5 minutes
  7107. $('.nui_main_menu .chat').mouseover(function () {
  7108. //Chat.popupChatUser();
  7109. });
  7110. // No alliance chat:
  7111. if ($('.nui_main_menu .chat').hasClass('disabled')) {
  7112. $('.nui_main_menu .chat').removeClass('disabled');
  7113. }
  7114. },
  7115. deactivate: function () {
  7116. $('#dio_chat').remove();
  7117. $('.nui_main_menu .chat .indicator').get(0).style.display = 'none';
  7118.  
  7119. clearInterval(Chat.interval);
  7120.  
  7121. if (GPWindowMgr.getOpenFirst(Layout.wnd.TYPE_CHAT)) {
  7122. GPWindowMgr.getOpenFirst(Layout.wnd.TYPE_CHAT).close();
  7123. }
  7124. },
  7125.  
  7126. updateChatUser: function () {
  7127. var market = uw.Game.market_id;
  7128. if (gm) {
  7129. // GM-BROWSER:
  7130. chatUserRequest();
  7131. } else {
  7132. // SAFARI:
  7133. $.ajax({
  7134. url: "https://diotools.de/game/chatuser_count.php?chan=Grepo" + (market === "de" ? "lisDE" : ""),
  7135. dataType: 'text',
  7136. success: function (text) {
  7137. $('.nui_main_menu .chat .indicator').get(0).innerHTML = text;
  7138. $('.nui_main_menu .chat .indicator').get(0).style.display = 'block';
  7139. },
  7140. error: function (xhr, ajaxOptions, thrownError) {
  7141. $('.nui_main_menu .chat .indicator').get(0).style.display = 'none';
  7142. }
  7143. });
  7144. }
  7145. },
  7146.  
  7147. popupChatUser: function () { // not used yet
  7148. setTimeout(function () {
  7149. GM_xmlhttpRequest({
  7150. method: "POST",
  7151. url: "http://wwwapi.iz-smart.net/modules.php?name=Chaninfo&file=nicks&chan=Grepolis" + uw.Game.market_id.toUpperCase(),
  7152. onload: function (response) {
  7153. //$('.nui_main_menu .chat .indicator').get(0).innerHTML =
  7154. //console.log(response.responseText);
  7155. //$('.nui_main_menu .chat .indicator').get(0).style.display = 'inline';
  7156. }
  7157. });
  7158. }, 0);
  7159. },
  7160.  
  7161. // Modify chat window
  7162. open: function () {
  7163. var host = {fr: 'irc.quakenet.org', def: 'flash.afterworkchat.de'},
  7164. market = uw.Game.market_id, select_nick = false, chatwnd_id,
  7165. nickname = uw.Game.player_name;
  7166.  
  7167. setTimeout(function () {
  7168. Chat.updateChatUser();
  7169. }, 30000); // 30 seconds
  7170.  
  7171. //uw.GPWindowMgr.Create(uw.Layout.wnd.TYPE_CHAT);
  7172.  
  7173. //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).setWidth(600);
  7174. //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).setHeight(300);
  7175. //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).setPosition([0,'bottom']);
  7176.  
  7177. //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT));
  7178.  
  7179. chatwnd_id = '#gpwnd_' + uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).getID();
  7180.  
  7181. $('#chat').get(0).innerHTML = "";
  7182. //$(chatwnd_id).parent().children('.gpwindow_left').remove();
  7183. //$(chatwnd_id).parent().children('.gpwindow_right').remove();
  7184. //$(chatwnd_id).parent().children('.gpwindow_top').remove();
  7185. //$(chatwnd_id).parent().children('.gpwindow_bottom').remove();
  7186. //$(chatwnd_id).parent().parent().children('.ui-dialog-titlebar').remove();
  7187.  
  7188. var replaceArray = {
  7189. // Russian:
  7190. "Ё": "YO",
  7191. "Й": "I",
  7192. "Ц": "TS",
  7193. "У": "U",
  7194. "К": "K",
  7195. "Е": "E",
  7196. "Н": "N",
  7197. "Г": "G",
  7198. "Ш": "SH",
  7199. "Щ": "SCH",
  7200. "З": "Z",
  7201. "Х": "H",
  7202. "Ъ": "'",
  7203. "ё": "yo",
  7204. "й": "i",
  7205. "ц": "ts",
  7206. "у": "u",
  7207. "к": "k",
  7208. "е": "e",
  7209. "н": "n",
  7210. "г": "g",
  7211. "ш": "sh",
  7212. "щ": "sch",
  7213. "з": "z",
  7214. "х": "h",
  7215. "ъ": "'",
  7216. "Ф": "F",
  7217. "Ы": "I",
  7218. "В": "V",
  7219. "А": "a",
  7220. "П": "P",
  7221. "Р": "R",
  7222. "О": "O",
  7223. "Л": "L",
  7224. "Д": "D",
  7225. "Ж": "ZH",
  7226. "Э": "E",
  7227. "ф": "f",
  7228. "ы": "i",
  7229. "в": "v",
  7230. "а": "a",
  7231. "п": "p",
  7232. "р": "r",
  7233. "о": "o",
  7234. "л": "l",
  7235. "д": "d",
  7236. "ж": "zh",
  7237. "э": "e",
  7238. "Я": "Ya",
  7239. "Ч": "CH",
  7240. "С": "S",
  7241. "М": "M",
  7242. "И": "I",
  7243. "Т": "T",
  7244. "Ь": "'",
  7245. "Б": "B",
  7246. "Ю": "YU",
  7247. "я": "ya",
  7248. "ч": "ch",
  7249. "с": "s",
  7250. "м": "m",
  7251. "и": "i",
  7252. "т": "t",
  7253. "ь": "'",
  7254. "б": "b",
  7255. "ю": "yu",
  7256.  
  7257. // Greek:
  7258. 'Α': 'A',
  7259. 'Β': 'B',
  7260. 'Γ': 'G',
  7261. 'Δ': 'D',
  7262. 'Ε': 'E',
  7263. 'Ζ': 'Z',
  7264. 'Η': 'H',
  7265. 'Θ': 'Th',
  7266. 'Ι': 'I',
  7267. 'Κ': 'K',
  7268. 'Λ': 'L',
  7269. 'Μ': 'M',
  7270. 'Ν': 'N',
  7271. 'Ξ': 'J',
  7272. 'Ο': 'O',
  7273. 'Π': 'P',
  7274. 'Ρ': 'R',
  7275. 'Σ': 'S',
  7276. 'Τ': 'T',
  7277. 'Υ': 'U',
  7278. 'Φ': 'F',
  7279. 'Χ': 'Ch',
  7280. 'Ψ': 'Ps',
  7281. 'Ω': 'W',
  7282. 'Ά': 'A',
  7283. 'Έ': 'E',
  7284. 'Ή': 'H',
  7285. 'Ί': 'I',
  7286. 'Ό': 'O',
  7287. 'Ύ': 'U',
  7288. 'Ώ': 'W',
  7289. 'Ϊ': 'I',
  7290. 'α': 'a',
  7291. 'β': 'b',
  7292. 'γ': 'g',
  7293. 'δ': 'd',
  7294. 'ε': 'e',
  7295. 'ζ': 'z',
  7296. 'η': 'h',
  7297. 'θ': 'th',
  7298. 'ι': 'i',
  7299. 'κ': 'k',
  7300. 'λ': 'l',
  7301. 'μ': 'm',
  7302. 'ν': 'n',
  7303. 'ξ': 'j',
  7304. 'ο': 'o',
  7305. 'π': 'p',
  7306. 'ρ': 'r',
  7307. 'ς': 's',
  7308. 'σ': 's',
  7309. 'τ': 't',
  7310. 'υ': 'u',
  7311. 'φ': 'f',
  7312. 'χ': 'ch',
  7313. 'ψ': 'ps',
  7314. 'ω': 'w',
  7315. 'ά': 'a',
  7316. 'έ': 'e',
  7317. 'ή': 'h',
  7318. 'ί': 'i',
  7319. 'ό': 'o',
  7320. 'ύ': 'u',
  7321. 'ώ': 'w',
  7322. 'ϊ': 'i',
  7323. 'ΐ': 'i'
  7324. };
  7325.  
  7326. function replaceNick(word) {
  7327. var temp = "", temp2 = "";
  7328. // Step 1: Replace Special and some german chars
  7329. word = word.replace(/[.,:,+,*]/g, "").replace(/[=,\ ,\-]/g, "_").replace(/ö/gi, "oe").replace(/ä/gi, "ae").replace(/ü/gi, "ue").replace(/ß/g, "ss");
  7330. // Step 2: Replace russian and greek chars
  7331. if (!word.match(/^[a-zA-Z0-9_]+$/)) {
  7332. temp = word.split('').map(function (char) {
  7333. var ch = "";
  7334. ch = replaceArray[char] || char;
  7335. return ch;
  7336. }).join("");
  7337. // Step 3: Delete all other special chars
  7338. if (!temp.match(/^[a-zA-Z0-9_]+$/)) {
  7339. for (var c = 0; c < temp.length; c++) {
  7340. if (temp[c].match(/^[a-zA-Z0-9_]+$/)) {
  7341. temp2 += temp[c];
  7342. }
  7343. }
  7344. select_nick = true;
  7345. temp = temp2;
  7346. }
  7347. word = temp;
  7348. }
  7349. return word;
  7350. }
  7351.  
  7352. //nickname = "kνnmδενεί-ναισυνδεδ*εμένος_Ιππέας"; // test nickname
  7353. nickname = replaceNick(nickname);
  7354.  
  7355. if (PID == 84367) {
  7356. nickname = "DionY_";
  7357. }
  7358.  
  7359. $('<iframe src="http://flash.afterworkchat.de/1.0/FlashChat.swf' + //http://grepodio.heliohost.org/lightIRC/index.php'+
  7360. '?host=flash.afterworkchat.de' +
  7361. '&languagePath=http://flash.afterworkchat.de/1.0/language/' +
  7362. '&port=6667' +
  7363. '&policyPort=9000' +
  7364. '&styleURL=https://diotools.de/css/green2.css' + //http://grepodio.heliohost.org/style.css'+ //
  7365. '&emoticonPath=https://diotools.de/chat/emoticons/' + //http://www.greensmilies.com/smile/smiley_emoticons_'+
  7366. '&emoticonList=' +
  7367. ':)->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,' +
  7368. ':$->blush.swf,:]->lol.swf,:*->bussi.swf,:[->fluch.swf' +
  7369. //'&accessKey=54a2846a460ae1703ac690d21551b997'+
  7370. '&nick=' + nickname +
  7371. '&nickAlternate=' + nickname + '_' +
  7372. '&autojoin=%23GREPO,%23Grepolis' + market.toUpperCase() +
  7373. '&showNickSelection=' + select_nick +
  7374. '&showNavigation=true' +
  7375. '&navigationPosition=top' +
  7376. '&showNickSelection=false' +
  7377. '&showIdentifySelection=false' +
  7378. '&language=' + LID +
  7379. '&quitMessage=CYA' +
  7380. '&showChannelHeader=false' +
  7381. //'&useUserListIcons=true'+
  7382. '&userListWidth=100' +
  7383. '&soundAlerts=true' +
  7384. '&soundOnNewChannelMessage=false' +
  7385. '&showServerWindow=false' +
  7386. '&fontSize=9' +
  7387. '&showJoinPartMessages=false' +
  7388. '&showMenuButton=false' +
  7389. '&showTranslationButton=false' +
  7390. '&showTimestamps=true' +
  7391. //'&showInfoMessages=false'+
  7392. '&showRegisterNicknameButton=false' +
  7393. '&showRichTextControls=false' +
  7394. //'&useUserListIcons=true'+
  7395. '&showUserListInformationPopup=false' +
  7396. '&showNickChangeButton=false' +
  7397. '&showChannelCentral=false' +
  7398. '&showOptionsButton=false' +
  7399. '&showEmoticonsButton=true' +
  7400. '&rememberNickname=false' +
  7401. '" style="width:518px; height:357px; border:0px;"></iframe>').appendTo("#chat");
  7402.  
  7403. /*
  7404. $('<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>'+
  7405. '<script type="text/javascript">'+
  7406. 'var params = {};'+
  7407. 'params.languagePath = "http://flash.afterworkchat.de/1.0/language/";'+
  7408. 'params.host = "flash.afterworkchat.de";'+
  7409. 'params.port = 6667;'+
  7410. 'params.policyPort = 9000;'+
  7411. //'params.accessKey = "54a2846a460ae1703ac690d21551b997";'+
  7412. 'params.styleURL = "http://diotools.de/css/green2.css";'+
  7413. 'params.emoticonPath = "http://diotools.de/chat/emoticons/";'+
  7414. '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,'+
  7415. ':$->blush.swf,:]->lol.swf,:*->bussi.swf,:[->fluch.swf";'+
  7416. 'params.nick = "'+ nickname + '";' +
  7417. 'params.autojoin = "%23GREPO,%23Grepolis'+ market.toUpperCase() + '";' +
  7418. 'params.showNickSelection = ' + select_nick + ';'+
  7419. 'params.showIdentifySelection = false;'+
  7420. 'params.language = "'+ LID +'";'+
  7421. 'params.soundAlerts = true;'+
  7422. 'params.fontSize = "10";'+
  7423. 'params.navigationPosition = "top";'+
  7424. 'params.showJoinPartMessages = false;'+
  7425. 'params.showTimestamps = true;'+
  7426. 'params.showRegisterNicknameButton = false;'+
  7427. 'params.showNickChangeButton = true;'+
  7428. 'params.showOptionsButton = true;'+
  7429. 'params.showServerWindow = false;'+
  7430. 'params.showOptionsButton = false;'+
  7431. 'params.showMenuButton = false;'+
  7432. 'params.showTranslationButton = false;'+
  7433. 'params.showRichTextControls = false;'+
  7434. 'params.showChannelHeader = false;'+
  7435. 'params.rememberNickname = false;'+
  7436. 'params.userListWidth = 100;' +
  7437. 'params.soundAlerts = true;'+
  7438. 'params.soundOnNewChannelMessage = false;'+
  7439. '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"});'+
  7440. '</script></body></html>').appendTo("#chat");
  7441. */
  7442. }
  7443. };
  7444.  
  7445. /*******************************************************************************************************************************
  7446. * Activity boxes
  7447. * ----------------------------------------------------------------------------------------------------------------------------
  7448. * | ● Show troops and trade activity boxes
  7449. * | ● Boxes are magnetic & movable (position memory)
  7450. * ----------------------------------------------------------------------------------------------------------------------------
  7451. *******************************************************************************************************************************/
  7452. var mut_toolbar, mut_command, mut_trade;
  7453.  
  7454. var save_command_mouseout,
  7455. save_commandlist_mouseout,
  7456. save_trade_mouseout,
  7457. save_tradelist_mouseout,
  7458.  
  7459. save_command_mouseover,
  7460. save_trade_mouseover;
  7461.  
  7462.  
  7463. var ActivityBoxes = {
  7464. activate: function () {
  7465. ActivityBoxes.checkToolbarAtStart();
  7466.  
  7467. $('#toolbar_activity_commands_list').css({
  7468. left: commandbox.left + "px",
  7469. top: commandbox.top + "px"
  7470. });
  7471.  
  7472. $('<style id="fix_lists" type="text/css">' +
  7473. '#toolbar_activity_commands_list, #toolbar_activity_trades_list { width: 160px}' +
  7474. '.dropdown-list .content { max-height: 329px}' +
  7475. '</style>' +
  7476. '<style id="dio_fix_trade" type="text/css">' +
  7477. '#toolbar_activity_trades_list {' +
  7478. 'left:' + tradebox.left + 'px !important;' +
  7479. 'top: ' + tradebox.top + 'px !important}' +
  7480. '</style>').appendTo('head');
  7481.  
  7482.  
  7483. ActivityBoxes.draggableTradeBox();
  7484. ActivityBoxes.draggableCommandBox();
  7485.  
  7486. ActivityBoxes.catchToolbarEvents();
  7487. },
  7488. deactivate: function () {
  7489. ActivityBoxes.hideTradeList();
  7490. ActivityBoxes.hideCommandList();
  7491.  
  7492. mut_toolbar.disconnect();
  7493. mut_command.disconnect();
  7494. mut_trade.disconnect();
  7495. },
  7496. showTradeList: function () {
  7497. if (!$('#dio_trades_activity_style').get(0)) {
  7498. $('#toolbar_activity_trades').mouseover();
  7499. $('<style id="dio_trades_activity_style"> #toolbar_activity_trades_list { display: block !important; } </style>').appendTo("head");
  7500. }
  7501. },
  7502. showCommandList: function () {
  7503. if (!$('#dio_commands_activity_style').get(0)) {
  7504. $('#toolbar_activity_commands').mouseover();
  7505. $('<style id="dio_commands_activity_style"> #toolbar_activity_commands_list { ' +
  7506. 'display:block !important; left:' + commandbox.left + 'px; top:' + commandbox.top + 'px; }' +
  7507. '</style>').appendTo("head");
  7508. }
  7509. },
  7510. hideTradeList: function () {
  7511. if ($('#dio_trades_activity_style').get(0)) {
  7512. $('#dio_trades_activity_style').remove();
  7513. $('#toolbar_activity_trades').mouseout();
  7514. }
  7515. },
  7516. hideCommandList: function () {
  7517. if ($('#dio_commands_activity_style').get(0)) {
  7518. $('#dio_commands_activity_style').remove();
  7519. $('#toolbar_activity_commands').mouseout();
  7520. }
  7521. },
  7522. activate2: function () {
  7523. var observe_options = {attributes: false, childList: true, characterData: false};
  7524.  
  7525. ActivityBoxes.catchToolbarEvents();
  7526.  
  7527. mut_command.observe($('.toolbar_activities .commands .count').get(0), observe_options);
  7528. mut_trade.observe($('.toolbar_activities .trades .count').get(0), observe_options);
  7529.  
  7530. $('<style id="dio_activity_style"> ' +
  7531. '#toolbar_activity_commands_list.active { display: block !important; } ' +
  7532. '#toolbar_activity_trades_list.active { display: block !important; } ' +
  7533. '</style>').appendTo("head");
  7534.  
  7535.  
  7536. $('#toolbar_activity_commands').mouseover();
  7537. $('#toolbar_activity_trades').mouseover();
  7538.  
  7539. $('#toolbar_activity_commands, #toolbar_activity_trades').off("mouseover");
  7540.  
  7541. $('#toolbar_activity_commands, #toolbar_activity_commands_list, #toolbar_activity_trades, #toolbar_activity_trades_list').off("mouseout");
  7542.  
  7543. $('#toolbar_activity_trades_list').unbind("click");
  7544. //console.log($('#toolbar_activity_commands').data('events')["dd:list:show"][0].handler());
  7545.  
  7546. ActivityBoxes.checkToolbarAtStart();
  7547.  
  7548. $('#toolbar_activity_commands_list').css({
  7549. left: commandbox.left + "px",
  7550. top: commandbox.top + "px"
  7551. });
  7552.  
  7553. $('<style id="fix_lists" type="text/css">' +
  7554. '#toolbar_activity_commands_list, #toolbar_activity_trades_list { width: 160px}' +
  7555. '.dropdown-list .content { max-height: 329px}' +
  7556. '</style>' +
  7557. '<style id="dio_fix_trade" type="text/css">' +
  7558. '#toolbar_activity_trades_list {' +
  7559. 'left:' + tradebox.left + 'px !important;' +
  7560. 'top: ' + tradebox.top + 'px !important}' +
  7561. '</style>').appendTo('head');
  7562.  
  7563. ActivityBoxes.draggableCommandBox();
  7564. ActivityBoxes.draggableTradeBox();
  7565.  
  7566.  
  7567. /*
  7568. $('.toolbar_activities .commands').on("mouseover.bla", function(){
  7569. $('#toolbar_activity_commands_list').addClass("active");
  7570. });
  7571.  
  7572. $('.toolbar_activities .trades').mouseover(function(){
  7573. $('#toolbar_activity_trades_list').addClass("active");
  7574. });
  7575. */
  7576. },
  7577. deactivate2: function () {
  7578. mut_toolbar.disconnect();
  7579. mut_command.disconnect();
  7580. mut_trade.disconnect();
  7581. /*
  7582. $('#toolbar_activity_commands').on("mouseover", save_command_mouseover);
  7583. $('#toolbar_activity_trades').on("mouseover", save_trade_mouseover);
  7584.  
  7585. $('#toolbar_activity_commands').on("mouseout", save_command_mouseout);
  7586. $('#toolbar_activity_commands_list').on("mouseout", save_commandlist_mouseout);
  7587. $('#toolbar_activity_trades').on("mouseout", save_trade_mouseout);
  7588. $('#toolbar_activity_trades_list').on("mouseout", save_tradelist_mouseout);
  7589. */
  7590.  
  7591. $('#toolbar_activity_commands').mouseover = save_command_mouseover;
  7592. $('#toolbar_activity_trades').mouseover = save_trade_mouseover;
  7593.  
  7594. $('#toolbar_activity_commands').mouseout = save_command_mouseout;
  7595. $('#toolbar_activity_commands_list').mouseout = save_commandlist_mouseout;
  7596. $('#toolbar_activity_trades').mouseout = save_trade_mouseout;
  7597. $('#toolbar_activity_trades_list').mouseout = save_tradelist_mouseout;
  7598.  
  7599.  
  7600. $('#toolbar_activity_trades_list').removeClass("active");
  7601. $('#toolbar_activity_commands_list').removeClass("active");
  7602. /*
  7603. $('.toolbar_activities .commands').off("mouseover.bla");
  7604. */
  7605. $('#dio_activity_style').remove();
  7606.  
  7607.  
  7608. },
  7609. checkToolbarAtStart: function () {
  7610. if (parseInt($('.toolbar_activities .commands .count').get(0).innerHTML, 10) > 0) {
  7611. ActivityBoxes.showCommandList();
  7612. } else {
  7613. ActivityBoxes.hideCommandList();
  7614. }
  7615. if (parseInt($('.toolbar_activities .trades .count').get(0).innerHTML, 10) > 0) {
  7616. ActivityBoxes.showTradeList();
  7617. } else {
  7618. ActivityBoxes.hideTradeList();
  7619. }
  7620. },
  7621. catchToolbarEvents: function () {
  7622. var observe_options = {attributes: false, childList: true, characterData: false};
  7623.  
  7624. mut_toolbar = new MutationObserver(function (mutations) {
  7625. mutations.forEach(function (mutation) {
  7626. if (mutation.addedNodes[0]) {
  7627. console.debug(mutation.target.id);
  7628. if (mutation.target.id === "toolbar_activity_trades_list") {
  7629. ActivityBoxes.draggableTradeBox();
  7630. } else {
  7631. ActivityBoxes.draggableCommandBox();
  7632. }
  7633. mutation.addedNodes[0].remove();
  7634. }
  7635. });
  7636. });
  7637. //mut_toolbar.observe($('#toolbar_activity_commands_list').get(0), observe_options );
  7638. //mut_toolbar.observe($('#toolbar_activity_trades_list').get(0), observe_options );
  7639.  
  7640. mut_command = new MutationObserver(function (mutations) {
  7641. mutations.forEach(function (mutation) {
  7642. if (mutation.addedNodes[0]) {
  7643. console.debug(mutation.addedNodes[0].nodeValue);
  7644. if (mutation.addedNodes[0].nodeValue > 0) {
  7645. ActivityBoxes.showCommandList();
  7646. } else {
  7647. console.debug("hiiiiiiiide commands");
  7648. ActivityBoxes.hideCommandList();
  7649. }
  7650. }
  7651. });
  7652. });
  7653. mut_trade = new MutationObserver(function (mutations) {
  7654. mutations.forEach(function (mutation) {
  7655. if (mutation.addedNodes[0]) {
  7656. if (mutation.addedNodes[0].nodeValue > 0) {
  7657. ActivityBoxes.showTradeList();
  7658. } else {
  7659. ActivityBoxes.hideTradeList();
  7660. }
  7661. }
  7662. });
  7663. });
  7664. mut_command.observe($('.toolbar_activities .commands .count').get(0), observe_options);
  7665. mut_trade.observe($('.toolbar_activities .trades .count').get(0), observe_options);
  7666. },
  7667. // Moveable boxes
  7668. draggableTradeBox: function () {
  7669. $("#toolbar_activity_trades_list").draggable({
  7670. containment: "body",
  7671. distance: 20,
  7672. snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, .nui_left_box",
  7673. opacity: 0.7,
  7674. start: function () {
  7675. $("#dio_fix_trade").remove();
  7676. },
  7677. stop: function () {
  7678. var pos = $('#toolbar_activity_trades_list').position();
  7679.  
  7680. tradebox.left = pos.left;
  7681. tradebox.top = pos.top;
  7682.  
  7683. saveValue("tradebox", JSON.stringify(tradebox));
  7684.  
  7685. $('<style id="dio_fix_trade" type="text/css">' +
  7686. '#toolbar_activity_trades_list { left:' + tradebox.left + 'px !important; top:' + tradebox.top + 'px !important; } ' +
  7687. '</style>').appendTo('head');
  7688. }
  7689. });
  7690. },
  7691. draggableCommandBox: function () {
  7692. $("#toolbar_activity_commands_list").draggable({
  7693. containment: "body",
  7694. distance: 20,
  7695. snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, .nui_left_box",
  7696. opacity: 0.7,
  7697. stop: function () {
  7698. var pos = $('#toolbar_activity_commands_list').position();
  7699. commandbox.left = pos.left;
  7700. commandbox.top = pos.top;
  7701.  
  7702. saveValue("commandbox", JSON.stringify(commandbox));
  7703. }
  7704. });
  7705. }
  7706. };
  7707.  
  7708. /*******************************************************************************************************************************
  7709. * Counter
  7710. *******************************************************************************************************************************/
  7711.  
  7712. function counter(time) {
  7713. var type = "", today, counted, year, month, day;
  7714. if (uw.Game.market_id !== "zz") {
  7715. counted = DATA.count;
  7716. today = new Date((time + 7200) * 1000);
  7717. year = today.getUTCFullYear();
  7718. month = ((today.getUTCMonth() + 1) < 10 ? "0" : "") + (today.getUTCMonth() + 1);
  7719. day = (today.getUTCDate() < 10 ? "0" : "") + today.getUTCDate();
  7720. today = year + month + day;
  7721. //console.log(today);
  7722. if (counted[0] !== today) {
  7723. type += "d";
  7724. }
  7725. if (counted[1] == false) {
  7726. type += "t";
  7727. }
  7728. if ((counted[2] == undefined) || (counted[2] == false)) {
  7729. type += "b";
  7730. }
  7731. if (type !== "") {
  7732. $.ajax({
  7733. type: "GET",
  7734. url: "https://diotools.de/game/count.php?type=" + type + "&market=" + uw.Game.market_id + "&date=" + today + "&browser=" + getBrowser(),
  7735. dataType: 'text',
  7736. success: function (text) {
  7737. if (text.indexOf("dly") > -1) {
  7738. counted[0] = today;
  7739. }
  7740. if (text.indexOf("tot") > -1) {
  7741. counted[1] = true;
  7742. }
  7743. if (text.indexOf("bro") > -1) {
  7744. counted[2] = true;
  7745. }
  7746. saveValue("dio_count", JSON.stringify(counted));
  7747. }
  7748. });
  7749. }
  7750. }
  7751. }
  7752.  
  7753.  
  7754. /*******************************************************************************************************************************
  7755. * Political Map
  7756. *******************************************************************************************************************************/
  7757.  
  7758. var PoliticalMap = {
  7759. data: null,
  7760. activate: function () {
  7761. $('<div id="dio_political_map">' +
  7762. '<div class="canvas_wrapper"></div>' +
  7763. '<select class="zoom_select">' +
  7764. '<option value="0.50">1 : 0.50</option>' +
  7765. '<option value="0.75">1 : 0.75</option>' +
  7766. '<option value="1.00" selected>1 : 1.00</option>' +
  7767. '<option value="1.25">1 : 1.25</option>' +
  7768. '<option value="1.50">1 : 1.50</option>' +
  7769. '<option value="2.00">1 : 2.00</option>' +
  7770. '<option value="3.00">1 : 3.00</option>' +
  7771. '</select>' +
  7772. '<div class="legend sandy-box">' +
  7773. '<div class="corner_tl"></div>' +
  7774. '<div class="corner_tr"></div>' +
  7775. '<div class="corner_bl"></div>' +
  7776. '<div class="corner_br"></div>' +
  7777. '<div class="border_t"></div>' +
  7778. '<div class="border_b"></div>' +
  7779. '<div class="border_l"></div>' +
  7780. '<div class="border_r"></div>' +
  7781. '<div class="middle"></div>' +
  7782. '<div class="content"><div class="item"></div></div>' +
  7783. '</div></div>').appendTo('#ui_box');
  7784.  
  7785. // Style
  7786. $('<style id="dio_political_map_style">' +
  7787. '#dio_political_map { width:100%; height:100%; z-index:3; background:#123d70; display:none; position:absolute; top:0; } ' +
  7788. '#dio_political_map.active { display: block; } ' +
  7789. '#dio_political_map .canvas_wrapper { } ' +
  7790. '#dio_political_map canvas { position: absolute; cursor:move; top:0; left:0; } ' +
  7791. '#dio_political_map .zoom_select { position:absolute; top:70px; left:300px; font-size: 2em; opacity:0.5; } ' +
  7792. '#dio_political_map .zoom_select:hover { opacity:1; } ' +
  7793. '#dio_political_map .legend { position:absolute; right:200px; top:50px; width:200px; height:auto; text-align:left; } ' +
  7794. '#dio_political_map .legend .color_checker { width:15px; height:15px; float:left; border:1px solid rgb(100, 100, 0); margin:5px; position:relative; cursor:pointer; } ' +
  7795. '#dio_political_map .legend .wonder_icon { float: left; margin: 4px; } ' +
  7796.  
  7797. '.btn_political_map { top:56px; left:-4px; z-index:10; position:absolute; } ' +
  7798.  
  7799. '.btn_political_map .ico_political_map { margin:7px 0px 0px 8px; width:17px; height:17px; background:url(http://s1.directupload.net/images/140408/pltgqlaw.png) no-repeat 0px 0px; background-size:100%; } ' +
  7800. // http://s14.directupload.net/images/140408/k4wikrlq.png // http://s7.directupload.net/images/140408/ahfr8227.png
  7801. '.btn_political_map .ico_political_map.checked { margin-top:8px; } ' +
  7802. '</style>').appendTo('head');
  7803.  
  7804. PoliticalMap.addButton();
  7805.  
  7806. var zoomSelect = $('.zoom_select');
  7807.  
  7808. zoomSelect.change(function () {
  7809. //PoliticalMap.zoomToCenter();
  7810. });
  7811. zoomSelect.on("change", function () {
  7812. PoliticalMap.zoomToCenter();
  7813. });
  7814.  
  7815. ColorPicker.init();
  7816. },
  7817. deactivate: function () {
  7818. $('.btn_political_map').remove();
  7819. $('#dio_political_map_style').remove();
  7820. },
  7821. addButton: function () {
  7822. var m_ZoomFactor = 1.0;
  7823. $('<div class="btn_political_map circle_button" name="political_map"><div class="ico_political_map js-caption"></div></div>').appendTo(".bull_eye_buttons");
  7824.  
  7825. var politicalMapButton = $('.btn_political_map');
  7826.  
  7827. // Tooltip
  7828. politicalMapButton.tooltip("Political Map"); // TODO: Language
  7829.  
  7830. // Events
  7831. politicalMapButton.on('mousedown', function () {
  7832. //$('.btn_political_map, .ico_political_map').addClass("checked");
  7833. }).on('mouseup', function () {
  7834. //$('.btn_political_map, .ico_political_map').removeClass("checked");
  7835. });
  7836.  
  7837. $('.rb_map .option').click(function () {
  7838. $('.btn_political_map, .ico_political_map').removeClass("checked");
  7839. $('#dio_political_map').removeClass("active");
  7840. $(this).addClass("checked");
  7841. });
  7842.  
  7843. politicalMapButton.click(function () {
  7844. $('.rb_map .checked').removeClass("checked");
  7845. $('.btn_political_map, .ico_political_map').addClass("checked");
  7846. $('#dio_political_map').addClass("active");
  7847.  
  7848. if ($('#dio_political_map').hasClass("active")) {
  7849. if (PoliticalMap.data == null) {
  7850. $('#ajax_loader').css({visibility: "visible"});
  7851. // Map-Daten aus DB auslesen
  7852. PoliticalMap.loadMapData();
  7853. } else {
  7854. //PoliticalMap.drawMap(PoliticalMap.data);
  7855. }
  7856. }
  7857. });
  7858. },
  7859. /**
  7860. * Läd die Allianzen und Inseln aus der Datenbank
  7861. * @since 3.0
  7862. */
  7863. loadMapData: function () {
  7864. $.ajax({
  7865. type: "GET",
  7866. url: "https://diotools.de/php/map.php?world_id=" + WID + "&callback=jsonCallback",
  7867. //dataType: 'jsonp',
  7868. //async: false,
  7869. //jsonpCallback: 'jsonCallback',
  7870. //contentType: "application/json",
  7871. success: function (response) {
  7872. if (response !== "") {
  7873. PoliticalMap.data = response;
  7874.  
  7875. var m_ZoomFactor = $('.zoom_select').get(0)[$('.zoom_select').get(0).selectedIndex].selected;
  7876.  
  7877. PoliticalMap.drawMap(PoliticalMap.data, m_ZoomFactor);
  7878. PoliticalMap.drawWonders(PoliticalMap.data, m_ZoomFactor);
  7879.  
  7880. $('#ajax_loader').css({visibility: "hidden"});
  7881.  
  7882. // Überprüfen, ob die Weltdaten geupdatet werden müssen
  7883. $.ajax({
  7884. type: "GET",
  7885. url: "https://diotools.de/php/update_db.php?world_id=" + WID
  7886. });
  7887. } else {
  7888. // Welt existiert noch nicht in DB
  7889. $.ajax({
  7890. type: "GET", url: "https://diotools.de/php/update_db.php?world_id=" + WID,
  7891. success: function () {
  7892. // Map-Daten aus DB auslesen, wenn die Weltdaten erfolgreich in die DB geladen wurden
  7893. $.ajax({
  7894. type: "GET",
  7895. url: "https://diotools.de/php/map.php?world_id=" + WID,
  7896. success: function (response) {
  7897. PoliticalMap.data = response;
  7898.  
  7899. var m_ZoomFactor = $('.zoom_select').get(0)[$('.zoom_select').get(0).selectedIndex].selected;
  7900.  
  7901. PoliticalMap.drawMap(PoliticalMap.data, m_ZoomFactor);
  7902. PoliticalMap.drawWonders(PoliticalMap.data, m_ZoomFactor);
  7903.  
  7904. $('#ajax_loader').css({visibility: "hidden"});
  7905. }
  7906. });
  7907. }
  7908. });
  7909. }
  7910. }
  7911. });
  7912. },
  7913. /**
  7914. * Ändert die Zoomstufe der Karte zum Zentrum hin
  7915. *
  7916. * @param _zoom
  7917. * @since 3.0
  7918. */
  7919. zoomToCenter: function () {
  7920. var _zoom = $('.zoom_select').get(0)[$('.zoom_select').get(0).selectedIndex].value;
  7921.  
  7922. var canvas = $('#dio_political_map canvas'),
  7923.  
  7924. canvas_size = parseInt($('#dio_political_map canvas').width(), 10); // Breite und Höhe sind immer gleich
  7925.  
  7926. var canvas_style = $('#dio_political_map .canvas_wrapper').get(0).style;
  7927.  
  7928. // Berechnung: Alter Abstand + (1000 * Zoomänderung / 2)
  7929. canvas_style.top = parseInt(canvas_style.top, 10) + (1000 * (canvas_size / 1000 - _zoom)) / 2 + "px";
  7930. canvas_style.left = parseInt(canvas_style.left, 10) + (1000 * (canvas_size / 1000 - _zoom)) / 2 + "px";
  7931.  
  7932. PoliticalMap.clearMap();
  7933. PoliticalMap.drawMap(PoliticalMap.data, _zoom);
  7934. PoliticalMap.drawWonders(PoliticalMap.data, _zoom);
  7935.  
  7936. },
  7937. /**
  7938. * Ändert die Zoomstufe der Karte zur Cursorposition hin
  7939. *
  7940. * @param _zoom
  7941. * @param _pos
  7942. *
  7943. * @since 3.0
  7944. */
  7945. zoomToCursorPosition: function (_zoom, _pos) {
  7946.  
  7947. },
  7948. /**
  7949. * Zeichnet die Karte in ein Canvas
  7950. *
  7951. * @param _islandArray {Array}
  7952. * @param _zoom {int}
  7953. *
  7954. * @since 3.0
  7955. */
  7956. drawMap: function (_islandArray, _zoom) {
  7957.  
  7958. $('<canvas class="canv_map" height="' + (1000 * _zoom) + 'px" width="' + (1000 * _zoom) + "px\"></canvas>").prependTo('.canvas_wrapper')
  7959.  
  7960. // TODO: Weite und Höhe vom Fenster ermitteln, Update Containment bei onResizeWindow
  7961. $('#dio_political_map .canvas_wrapper').draggable({
  7962. // left, top, right, bottom
  7963. //containment: [-500 * _zoom, -300 * _zoom, 500 * _zoom, 300 * _zoom],
  7964. distance: 10,
  7965. grid: [100 * _zoom, 100 * _zoom],
  7966. //limit: 500,
  7967. cursor: 'pointer'
  7968. });
  7969.  
  7970. var ally_ranking = JSON.parse(_islandArray)['ally_ranking'];
  7971. var island_array = JSON.parse(_islandArray)['ally_island_array'];
  7972.  
  7973.  
  7974. var c = $('#dio_political_map .canv_map')[0].getContext('2d');
  7975.  
  7976. // Grid
  7977. c.strokeStyle = 'rgb(0,100,0)';
  7978.  
  7979. for (var l = 0; l <= 10; l++) {
  7980. // Horizontal Line
  7981. c.moveTo(0, l * 100 * _zoom);
  7982. c.lineTo(1000 * _zoom, l * 100 * _zoom);
  7983. c.stroke();
  7984.  
  7985. // Vertical Line
  7986. c.moveTo(l * 100 * _zoom, 0);
  7987. c.lineTo(l * 100 * _zoom, 1000 * _zoom);
  7988. c.stroke();
  7989. }
  7990.  
  7991. // Center Circle
  7992. c.beginPath();
  7993. c.arc(500 * _zoom, 500 * _zoom, 100 * _zoom, 0, Math.PI * 2, true);
  7994. c.fillStyle = 'rgba(0,100,0,0.2)';
  7995. c.fill();
  7996. c.stroke();
  7997.  
  7998. // Sea numbers
  7999. c.fillStyle = 'rgb(0,100,0)';
  8000.  
  8001. for (var y = 0; y <= 10; y++) {
  8002. for (var x = 0; x <= 10; x++) {
  8003. c.fillText(y + "" + x, y * 100 * _zoom + 2, x * 100 * _zoom + 10);
  8004. }
  8005. }
  8006.  
  8007. // Alliance Colors
  8008. var colorArray = ["#00A000", "yellow", "red", "rgb(255, 116, 0)", "cyan", "#784D00", "white", "purple", "#0078FF", "deeppink", "darkslategrey"];
  8009.  
  8010. // Islands
  8011. for (var t in island_array) {
  8012. if (island_array.hasOwnProperty(t)) {
  8013. var tmp_points = 0, dom_ally = "";
  8014. for (var ally in island_array[t]) {
  8015. if (island_array[t].hasOwnProperty(ally)) {
  8016. if (tmp_points < island_array[t][ally] && (ally !== "X") && (ally !== "")) {
  8017. tmp_points = island_array[t][ally];
  8018. dom_ally = ally;
  8019. }
  8020. }
  8021. }
  8022.  
  8023. c.fillStyle = colorArray[parseInt(ally_ranking[dom_ally], 10) - 1] || "darkslategrey";
  8024. //c.fillRect(t.split("x")[0] * _zoom, t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
  8025.  
  8026. //c.beginPath();
  8027. //console.info(island_array[t]);
  8028. //c.arc(t.split("x")[0], t.split("x")[1], 2, 0, Math.PI * 2, true);
  8029. //c.fillRect(t.split("x")[0] * _zoom,t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
  8030. //c.fill();
  8031.  
  8032. // TEST HEATMAP
  8033. console.debug("Blaaa", c.fillStyle);
  8034. if (c.fillStyle !== "#2f4f4f") {
  8035. var color = c.fillStyle;
  8036. console.debug("Hallo");
  8037. var radgrad = c.createRadialGradient(t.split("x")[0] * _zoom + 1, t.split("x")[1] * _zoom + 1, 0, t.split("x")[0] * _zoom + 1, t.split("x")[1] * _zoom + 1, 10);
  8038. radgrad.addColorStop(0, PoliticalMap.convertHexToRgba(color, 0.2));
  8039. radgrad.addColorStop(0.6, PoliticalMap.convertHexToRgba(color, 0.2));
  8040. radgrad.addColorStop(1, PoliticalMap.convertHexToRgba(color, 0.0));
  8041.  
  8042. // draw shape
  8043. c.fillStyle = radgrad;
  8044.  
  8045. c.fillRect(t.split("x")[0] * _zoom - 10, t.split("x")[1] * _zoom - 10, 22, 22);
  8046.  
  8047. c.fillStyle = PoliticalMap.convertHexToRgba(color, 0.7);
  8048. c.fillRect(t.split("x")[0] * _zoom, t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
  8049. }
  8050. else {
  8051. c.fillRect(t.split("x")[0] * _zoom, t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
  8052. }
  8053. }
  8054. }
  8055.  
  8056.  
  8057.  
  8058. // Legende
  8059. var legend = $('#dio_political_map .legend .content');
  8060.  
  8061. legend.get(0).innerHTML = "";
  8062.  
  8063. for (var ally in ally_ranking) {
  8064. if (ally_ranking.hasOwnProperty(ally)) {
  8065. //legend.append("<div class='item' style='color:"+ colorAllyArray[ally] +"'><div class='color_checker' style='background-color:"+ colorAllyArray[ally] +"'></div>...</div>");
  8066.  
  8067. if (ally_ranking[ally] > 10) {
  8068. legend.append("<div class='item' style='color:" + colorArray[ally_ranking[ally] - 1] + "'><div class='color_checker' style='background-color:" + colorArray[ally_ranking[ally] - 1] + "'></div>...</div>");
  8069.  
  8070. break;
  8071. } else {
  8072. legend.append("<div class='item' style='color:" + colorArray[ally_ranking[ally] - 1] + "'><div class='color_checker' style='background-color:" + colorArray[ally_ranking[ally] - 1] + "'></div>" + ally + "</div>");
  8073.  
  8074. }
  8075. }
  8076. }
  8077.  
  8078. $('#dio_political_map .legend .color_checker').click(function (event) {
  8079. // getting user coordinates
  8080. var x = event.pageX - this.offsetLeft;
  8081. var y = event.pageY - this.offsetTop;
  8082.  
  8083. console.debug("HALLO 0", event.pageX, this.offsetLeft);
  8084.  
  8085. ColorPicker.open(x,y);
  8086. });
  8087.  
  8088.  
  8089. // TODO: Wenn eine Farbe ausgewählt wurde, soll [...]
  8090. $(ColorPicker).on("onColorChanged", function(event, color){
  8091. console.debug("Farbe setzen", event, color);
  8092.  
  8093. $.ajax({
  8094. type: "POST",
  8095. url: "https://" + Game.world_id + ".grepolis.com/game/alliance?town_id=" + Game.townId + "&action=assign_map_color&h=" + Game.csrfToken,
  8096. data: {
  8097. "json": "{\"alliance_id\":\"217\",\"color\":"+ color +",\"player_id\":\"8512878\",\"town_id\":\"71047\",\"nl_init\":true}"
  8098. },
  8099. success: function (response) {
  8100. console.debug("Erfolgreich übertragen", response);
  8101. }
  8102. });
  8103. });
  8104.  
  8105. },
  8106. convertHexToRgba: function (hex, opacity) {
  8107. console.debug("hex", hex);
  8108. hex = hex.replace('#', '');
  8109. r = parseInt(hex.substring(0, 2), 16);
  8110. g = parseInt(hex.substring(2, 4), 16);
  8111. b = parseInt(hex.substring(4, 6), 16);
  8112.  
  8113. result = 'rgba(' + r + ',' + g + ',' + b + ',' + opacity + ')';
  8114. return result;
  8115. },
  8116. /**
  8117. * Zeichnet die Weltwunder auf der Karte
  8118. *
  8119. * @param _islandArray {Array}
  8120. * @param _zoom {int}
  8121. *
  8122. * @since 3.0
  8123. */
  8124. drawWonders: function (_islandArray, _zoom) {
  8125.  
  8126. $('<canvas class="canv_ww" height="' + (1000 * _zoom) + 'px" width="' + (1000 * _zoom) + 'px"></canvas>').appendTo('.canvas_wrapper')
  8127.  
  8128. var c = $('#dio_political_map .canv_ww')[0].getContext('2d');
  8129.  
  8130. c.strokeStyle = 'rgb(0,100,0)';
  8131.  
  8132. // World Wonders
  8133. var wonders = {}, wonderImages = {};
  8134. //console.debug(JSON.stringify(wonder.map));
  8135.  
  8136. for (var wonderType in wonder.map) {
  8137. if (wonder.map.hasOwnProperty(wonderType)) {
  8138. var tmp = 0;
  8139. for (var wonderCoords in wonder.map[wonderType]) {
  8140. if (parseInt(wonder.map[wonderType][wonderCoords], 10) > tmp) {
  8141. wonders[wonderType] = wonderCoords;
  8142. tmp = parseInt(wonder.map[wonderType][wonderCoords], 10)
  8143. }
  8144. }
  8145. }
  8146. }
  8147.  
  8148. // Legende
  8149. var legend = $('#dio_political_map .legend .content');
  8150.  
  8151. legend.append("<div class=\"item no_results\"></div>");
  8152.  
  8153. for (var w in wonders) {
  8154. if (wonders.hasOwnProperty(w)) {
  8155. var _w = w;
  8156.  
  8157. wonderImages[_w] = new Image();
  8158.  
  8159. wonderImages[_w].onload = function () {
  8160. c.drawImage(this, this.pos.split("_")[0] * _zoom - 9, this.pos.split("_")[1] * _zoom - 9);
  8161. };
  8162.  
  8163. wonderImages[_w].pos = wonders[_w];
  8164. wonderImages[_w].src = "https://diotools.de/images/icons/ww/" + _w + ".png";
  8165.  
  8166. var wonder_string = _w.split("_of")[0].split("_");
  8167. wonder_string = wonder_string[wonder_string.length - 1];
  8168. wonder_string = wonder_string.substring(0, 1).toUpperCase() + wonder_string.substring(1);
  8169.  
  8170. legend.append("<img class='wonder_icon' src='" + wonderImages[_w].src + "'><div class='item'>" + wonder_string + "</div>");
  8171. }
  8172. }
  8173. },
  8174. clearMap: function () {
  8175. $('#dio_political_map .canv_map').remove();
  8176. $('#dio_political_map .canv_ww').remove();
  8177. },
  8178. getAllianceColors: function () {
  8179. $.ajax({
  8180. type: "GET",
  8181. url: "https://" + Game.world_id + ".grepolis.com/game/map_data?town_id=" + Game.townId + "&action=get_custom_colors&h=" + Game.csrfToken,
  8182. dataType: 'json',
  8183. success: function (response) {
  8184. // Allianzbox herausfiltern
  8185. var html_string = $('#alliance_box', $(response.json.list_html));
  8186.  
  8187. var flagArray = $('.flag', html_string);
  8188. var linkArray = $('a', html_string);
  8189.  
  8190. var allianceColorArray = [];
  8191.  
  8192. for (var i = 0; i < flagArray.length; i++) {
  8193. allianceColorArray[i] = {
  8194. "id": parseInt(linkArray[i].attributes.onclick.value.split(",")[1].split(")")[0], 10),
  8195. "color": flagArray[i].style.backgroundColor
  8196. };
  8197. }
  8198.  
  8199. console.debug("ANTWORT", allianceColorArray);
  8200. }
  8201. });
  8202. }
  8203. };
  8204.  
  8205. var ColorPicker = {
  8206. open: function(pos_left, pos_top){
  8207. $('#dio_color_picker').removeClass("hidden");
  8208. $('#dio_color_picker').css({
  8209. left: pos_left,
  8210. top: pos_top
  8211. });
  8212. },
  8213. close: function(){
  8214. $('#dio_color_picker').addClass("hidden");
  8215. },
  8216. init: function () {
  8217. // Style
  8218. $('<style id="dio_color_picker_style">' +
  8219. '#dio_color_picker { left:200px;top:300px;position:absolute;z-index:1000;} ' +
  8220. '#dio_color_picker.hidden { display:none;} ' +
  8221. '#dio_color_picker span.grepo_input, ' +
  8222. '#dio_color_picker a.color_table, ' +
  8223. '#dio_color_picker a.confirm, ' +
  8224. '#dio_color_picker a.cancel' +
  8225. ' { float:left; } ' +
  8226. '</style>').appendTo('head');
  8227.  
  8228. $(
  8229. '<canvas width="600" height="440" style="left:200px !important;top:100px !important;" id="canvas_picker" onclick="console.debug(this.getContext(\'2d\').getImageData(10, 10, 1, 1).data)"></canvas>' +
  8230. '<div id="hex">HEX: <input type="text"></input></div>' +
  8231. '<div id="rgb">RGB: <input type="text"></input></div>'
  8232. ).prependTo('#dio_political_map')
  8233.  
  8234. $(
  8235. '<div id="dio_color_picker" class="hidden"><table class="bb_popup" cellpadding="0" cellspacing="0"><tbody>' +
  8236. '<tr class="bb_popup_top">' +
  8237. '<td class="bb_popup_top_left"></td>' +
  8238. '<td class="bb_popup_top_middle"></td>' +
  8239. '<td class="bb_popup_top_right"></td>' +
  8240. '</tr>' +
  8241. '<tr>' +
  8242. '<td class="bb_popup_middle_left"></td>' +
  8243. '<td class="bb_popup_middle_middle">' +
  8244. '<div class="bb_color_picker_colors">' +
  8245. '<div style="background-color: rgb(255, 0, 0);"></div>' +
  8246. '<div style="background-color: rgb(0, 255, 0);"></div>' +
  8247. '<div style="background-color: rgb(0, 0, 255);"></div>' +
  8248. '</div>' +
  8249. '<a href="#" class="cancel"></a>' +
  8250. '<span class="grepo_input">' +
  8251. '<span class="left">' +
  8252. '<span class="right">' +
  8253. '<input class="color_string" style="width:50px;" maxlength="6" type="text">' +
  8254. '</span>' +
  8255. '</span>' +
  8256. '</span>' +
  8257. '<a href="#" class="color_table"><input type="color" id="c" tabindex=-1 class="hidden"></a>' +
  8258. '<a href="#" class="confirm"></a>' +
  8259. '</td>' +
  8260. '<td class="bb_popup_middle_right"></td>' +
  8261. '</tr>' +
  8262. '<tr class="bb_popup_bottom">' +
  8263. '<td class="bb_popup_bottom_left"></td>' +
  8264. '<td class="bb_popup_bottom_middle"></td>' +
  8265. '<td class="bb_popup_bottom_right"></td>' +
  8266. '</tr>' +
  8267. '</tbody></table></div>'
  8268. ).prependTo('#dio_political_map');
  8269.  
  8270. var canvas = document.getElementById('canvas_picker').getContext('2d');
  8271.  
  8272. var count = 5, line = 0, width = 16, height = 12, sep = 1;
  8273.  
  8274. var offset = (count - 2) * width;
  8275.  
  8276. for (var i = 2, j = 0; i < count; i++, j++) {
  8277.  
  8278. line = 0;
  8279.  
  8280. // Pinktöne (255,0,255)
  8281. canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", 0, " + ((i / count * 255) | 0) + ")";
  8282. canvas.fillRect(i * width, line, width - sep, height - sep);
  8283.  
  8284. canvas.fillStyle = "rgb(255," + ((j / (count - 1) * 255) | 0) + ", 255)";
  8285. canvas.fillRect(i * width + offset, line, width - sep, height - sep);
  8286.  
  8287. line = line + height;
  8288.  
  8289. // Rosatöne (255,0,127)
  8290. canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", 0, " + ((i / count * 127) | 0) + ")";
  8291. canvas.fillRect(i * width, line, width - sep, height - sep);
  8292.  
  8293. canvas.fillStyle = "rgb(255," + ((j / (count - 1) * 255) | 0) + "," + (127 + ((j / (count - 1) * 127) | 0)) + ")";
  8294. canvas.fillRect(i * width + offset, line, width - sep, height - sep);
  8295.  
  8296. line = line + height;
  8297.  
  8298. // Rottöne (255,0,0)
  8299. canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", 0, 0)";
  8300. canvas.fillRect(i * width, line, width - sep, height - sep);
  8301.  
  8302. canvas.fillStyle = "rgb(255," + ((j / (count - 1) * 255) | 0) + "," + ((j / (count - 1) * 255) | 0) + ")";
  8303. canvas.fillRect(i * width + offset, line, width - sep, height - sep);
  8304.  
  8305. line = line + height;
  8306.  
  8307. // Orangetöne (255, 127, 0)
  8308. canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", " + ((i / count * 127) | 0) + ", 0)";
  8309. canvas.fillRect(i * width, line, width - sep, height - sep);
  8310.  
  8311. canvas.fillStyle = "rgb(255, " + (127 + ((j / (count - 1) * 127) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ")";
  8312. canvas.fillRect(i * width + offset, line, width - sep, height - sep);
  8313.  
  8314. line = line + height;
  8315.  
  8316. // Dunkelbrauntöne (170, 85, 0)
  8317. canvas.fillStyle = "rgb(" + ((i / count * 170) | 0) + ", " + ((i / count * 85) | 0) + ", 0)";
  8318. canvas.fillRect(i * width, line, width - sep, height - sep);
  8319.  
  8320. canvas.fillStyle = "rgb(" + (170 + (j / (count - 1) * 85) | 0) + ", " + (85 + ((j / (count - 1) * 170) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ")";
  8321. canvas.fillRect(i * width + offset, line, width - sep, height - sep);
  8322.  
  8323. line = line + height;
  8324.  
  8325. // Brauntöne (191, 127, 0)
  8326. canvas.fillStyle = "rgb(" + ((i / count * 191) | 0) + ", " + ((i / count * 127) | 0) + ", 0)";
  8327. canvas.fillRect(i * width, line, width - sep, height - sep);
  8328.  
  8329. canvas.fillStyle = "rgb(" + (191 + (j / (count - 1) * 64) | 0) + ", " + (127 + ((j / (count - 1) * 127) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ")";
  8330. canvas.fillRect(i * width + offset, line, width - sep, height - sep);
  8331.  
  8332. line = line + height;
  8333.  
  8334. // Gelbtöne (255,255,0)
  8335. canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ", 0)";
  8336. canvas.fillRect(i * width, line, width - sep, height - sep);
  8337.  
  8338. canvas.fillStyle = "rgb(255, 255," + ((j / (count - 1) * 255) | 0) + ")";
  8339. canvas.fillRect(i * width + offset, line, width - sep, height - sep);
  8340.  
  8341. line = line + height;
  8342.  
  8343. // Gelbgrüntöne (127,255,0)
  8344. canvas.fillStyle = "rgb(" + ((i / count * 127) | 0) + "," + ((i / count * 191) | 0) + ", 0)";
  8345. canvas.fillRect(i * width, line, width - sep, height - sep);
  8346.  
  8347. canvas.fillStyle = "rgb(" + (127 + (j / (count - 1) * 127) | 0) + "," + (191 + (j / (count - 1) * 64) | 0) + "," + ((j / (count - 1) * 255) | 0) + ")";
  8348. canvas.fillRect(i * width + offset, line, width - sep, height - sep);
  8349.  
  8350. line = line + height;
  8351.  
  8352. // Dunkelgrasgrüntöne (85, 170, 0)
  8353. /*
  8354. canvas.fillStyle = "rgb("+ ((i/count*85)|0) +", "+ ((i/count*170)|0) +", 0)";
  8355. canvas.fillRect(i * width, line, width-sep, height-sep);
  8356.  
  8357. canvas.fillStyle = "rgb("+ (85 + (j/(count-1)*170)|0) +", "+ (170 + ((j/(count-1)*85)|0)) +","+ ((j/(count-1)*255)|0) +")";
  8358. canvas.fillRect(i * width + offset, line, width-sep, height-sep);
  8359.  
  8360. line = line + height;
  8361. */
  8362.  
  8363. // Grüntöne (0,255,0)
  8364. canvas.fillStyle = "rgb(0," + ((i / count * 255) | 0) + ", 0)";
  8365. canvas.fillRect(i * width, line, width - sep, height - sep);
  8366.  
  8367. canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + ", 255," + ((j / (count - 1) * 255) | 0) + ")";
  8368. canvas.fillRect(i * width + offset, line, width - sep, height - sep);
  8369.  
  8370. line = line + height;
  8371.  
  8372. // Türkistöne (0,255,127)
  8373. /*
  8374. canvas.fillStyle = "rgb(0,"+ ((i/count*255)|0) +","+ ((i/count*127)|0) + ")";
  8375. canvas.fillRect(i * width, line, width-sep, height-sep);
  8376.  
  8377. canvas.fillStyle = "rgb("+ ((j/(count-1)*255)|0) +", 255,"+ (127 + ((j/(count-1)*127)|0)) +")";
  8378. canvas.fillRect(i * width + offset, line, width-sep, height-sep);
  8379.  
  8380. line = line + height;
  8381. */
  8382.  
  8383. // Dunkel-Türkistöne (0,191,127)
  8384. canvas.fillStyle = "rgb(0, " + ((i / count * 191) | 0) + "," + ((i / count * 127) | 0) + ")";
  8385. canvas.fillRect(i * width, line, width - sep, height - sep);
  8386.  
  8387. canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + "," + (191 + (j / (count - 1) * 64) | 0) + ", " + (127 + ((j / (count - 1) * 127) | 0)) + ")";
  8388. canvas.fillRect(i * width + offset, line, width - sep, height - sep);
  8389.  
  8390. line = line + height;
  8391.  
  8392.  
  8393. // Cyantöne (0,255,255)
  8394. canvas.fillStyle = "rgb(0, " + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ")";
  8395. canvas.fillRect(i * width, line, width - sep, height - sep);
  8396.  
  8397. canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + ",255, 255)";
  8398. canvas.fillRect(i * width + offset, line, width - sep, height - sep);
  8399.  
  8400. line = line + height;
  8401.  
  8402. // Hellblautöne (0,127,255)
  8403. canvas.fillStyle = "rgb(0, " + ((i / count * 127) | 0) + "," + ((i / count * 255) | 0) + ")";
  8404. canvas.fillRect(i * width, line, width - sep, height - sep);
  8405.  
  8406. canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + "," + (127 + ((j / (count - 1) * 127) | 0)) + ", 255)";
  8407. canvas.fillRect(i * width + offset, line, width - sep, height - sep);
  8408.  
  8409. line = line + height;
  8410.  
  8411. // Blautöne (0,0,255)
  8412. canvas.fillStyle = "rgb(0, 0, " + ((i / count * 255) | 0) + ")";
  8413. canvas.fillRect(i * width, line, width - sep, height - sep);
  8414.  
  8415. canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + "," + ((j / (count - 1) * 255) | 0) + ", 255)";
  8416. canvas.fillRect(i * width + offset, line, width - sep, height - sep);
  8417.  
  8418. line = line + height;
  8419.  
  8420. // Lilatöne (127,0,255)
  8421. canvas.fillStyle = "rgb(" + ((i / count * 127) | 0) + ", 0, " + ((i / count * 255) | 0) + ")";
  8422. canvas.fillRect(i * width, line, width - sep, height - sep);
  8423.  
  8424. canvas.fillStyle = "rgb(" + (127 + ((j / (count - 1) * 127) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ", 255)";
  8425. canvas.fillRect(i * width + offset, line, width - sep, height - sep);
  8426.  
  8427. line = line + height;
  8428.  
  8429. // Grautöne
  8430. /*
  8431. canvas.fillStyle = "rgb("+ ((i/count*127)|0) +", "+ ((i/count*127)|0) +", "+ ((i/count*127)|0) +")";
  8432. canvas.fillRect(i * width, line, width-sep, height-sep);
  8433.  
  8434. canvas.fillStyle = "rgb("+ (127 + ((j/(count-1)*127)|0)) +","+ (127 + ((j/(count-1)*127)|0)) +","+ (127 + ((j/(count-1)*127)|0)) +")";
  8435. canvas.fillRect(i * width + offset, line, width-sep, height-sep);
  8436.  
  8437. line = line + height;
  8438. */
  8439.  
  8440. }
  8441.  
  8442. line = line + height;
  8443.  
  8444. for (var i = 0; i <= count; i++) {
  8445. // Grautöne
  8446. canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ")";
  8447. canvas.fillRect(i * width + width * 2, line, width - sep, height - sep);
  8448. }
  8449.  
  8450.  
  8451. // http://www.javascripter.net/faq/rgbtohex.htm
  8452. function rgbToHex(R, G, B) {
  8453. return toHex(R) + toHex(G) + toHex(B)
  8454. }
  8455.  
  8456. function toHex(n) {
  8457. n = parseInt(n, 10);
  8458. if (isNaN(n)) return "00";
  8459. n = Math.max(0, Math.min(n, 255));
  8460. return "0123456789ABCDEF".charAt((n - n % 16) / 16) + "0123456789ABCDEF".charAt(n % 16);
  8461. }
  8462.  
  8463. $('#dio_color_picker a.cancel').click(function () {
  8464. ColorPicker.close();
  8465. });
  8466.  
  8467.  
  8468. $('#dio_color_picker a.confirm').click(function () {
  8469. // Custom-Event auslösen
  8470. $(ColorPicker).trigger("onColorChanged", [$('#dio_color_picker .color_string')[0].value]);
  8471. ColorPicker.close();
  8472. });
  8473.  
  8474. $('#dio_color_picker a.color_table').click(function () {
  8475. document.getElementById("c").click();
  8476. });
  8477.  
  8478. $('#dio_color_picker a.color_table #c').change(function () {
  8479. $('#dio_color_picker input.color_string')[0].value = this.value;
  8480. $('#dio_color_picker input.color_string')[0].style.color = this.value;
  8481. });
  8482. }
  8483. };
  8484.  
  8485. var UnitImages = {
  8486. activate : function(){
  8487. $('<style id="dio_unit_images">' +
  8488.  
  8489. '.unit_icon25x25 { background-image: url(https://diotools.de/images/game/units/unit_icons_25x25_2.91.png);} ' +
  8490. '.unit_icon40x40 { background-image: url(https://diotools.de/images/game/units/unit_icons_40x40_2.91.png);} ' +
  8491. '.unit_icon50x50 { background-image: url(https://diotools.de/images/game/units/unit_icons_50x50_2.91.png);} ' +
  8492. '.unit_icon90x90 { background-image: url(https://diotools.de/images/game/units/unit_icons_90x90_2.91.png);} ' +
  8493.  
  8494. '.unit_icon228x165 { background-image: none; height:0px;} ' +
  8495. '.unit_card .deco_statue { background-image: none !important;} ' +
  8496. '.grepo_box_silver .border_l, .grepo_box_silver .border_r { background-image: none;} ' +
  8497. '.box_corner .box_corner_tl, .grepo_box_silver .box_corner_tr { height:31px; } ' +
  8498. '.grepo_box_silver .grepo_box_content { padding: 21px 10px 0px; } ' +
  8499.  
  8500. '</style>').appendTo('head');
  8501. },
  8502. deactivate : function(){
  8503. $('#dio_unit_images').remove();
  8504.  
  8505. }
  8506. };
  8507.  
  8508. /*******************************************************************************************************************************
  8509. * Holiday Special
  8510. *******************************************************************************************************************************/
  8511.  
  8512. var HolidaySpecial = {
  8513. isHalloween : false, isXmas : false, isNewYear : false,
  8514.  
  8515. activate : function(){
  8516. var daystamp = 1000*60*60*24, today = new Date((new Date())%(daystamp*(365+1/4))), // without year
  8517.  
  8518. // Halloween -> 15 days
  8519. halloween_start = daystamp * 297, // 25. Oktober
  8520. halloween_end = daystamp * 321, // 8. November
  8521. // Xmas -> 28 days
  8522. xmas_start = daystamp * 334, // 1. Dezember
  8523. xmas_end = daystamp * 361, // 28. Dezember
  8524. // NewYear -> 7 days
  8525. newYear_start = daystamp * 0, // 1. Januar
  8526. newYear_end = daystamp * 7; // 7. Januar
  8527.  
  8528. HolidaySpecial.isHalloween = (today >= halloween_start) ? (today <= halloween_end) : false;
  8529.  
  8530. HolidaySpecial.isXmas = (today >= xmas_start) ? (today <= xmas_end) : false;
  8531.  
  8532. HolidaySpecial.isNewYear = (today >= newYear_start) ? (today <= newYear_end) : false;
  8533.  
  8534. if(HolidaySpecial.isXmas){ HolidaySpecial.XMas.add(); }
  8535. if(HolidaySpecial.isNewYear){ HolidaySpecial.NewYear.add(); }
  8536. },
  8537. XMas : {
  8538. add : function(){
  8539. $('<a href="http://www.greensmilies.com/smilie-album/weihnachten-smilies/" target="_blank"><div id="dio_xmas"></div></a>').appendTo('#ui_box');
  8540.  
  8541. var dioXMAS = $('#dio_xmas');
  8542.  
  8543. dioXMAS.css({
  8544. background: 'url("http://www.greensmilies.com/smile/smiley_emoticons_weihnachtsmann_nordpol.gif") no-repeat',
  8545. height: '51px',
  8546. width: '61px',
  8547. position:'absolute',
  8548. bottom:'10px',
  8549. left:'60px',
  8550. zIndex:'2000'
  8551. });
  8552. dioXMAS.tooltip("Ho Ho Ho, Merry Christmas!");
  8553. }
  8554. },
  8555. NewYear : {
  8556. add : function(){
  8557. // TODO: Jahreszahl dynamisch setzen
  8558. $('<a href="http://www.greensmilies.com/smilie-album/" target="_blank"><div id="dio_newYear">'+
  8559. '<img src="http://www.greensmilies.com/smile/sign2_2.gif">'+
  8560. '<img src="http://www.greensmilies.com/smile/sign2_0.gif">'+
  8561. '<img src="http://www.greensmilies.com/smile/sign2_1.gif">'+
  8562. '<img src="http://www.greensmilies.com/smile/sign2_6.gif">'+
  8563. '</div></a>').appendTo('#ui_box');
  8564.  
  8565. var dioNewYear = $('#dio_newYear');
  8566.  
  8567. dioNewYear.css({
  8568. position:'absolute',
  8569. bottom:'10px',
  8570. left:'70px',
  8571. zIndex:'10'
  8572. });
  8573. dioNewYear.tooltip("Happy new year!");
  8574. }
  8575. }
  8576. };
  8577.  
  8578. }