DIO-TOOLS

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

当前为 2015-05-23 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name DIO-TOOLS
  3. // @namespace DIO
  4. // @version 2.30
  5. // @author Diony
  6. // @description DIO-Tools is a small extension for the browser game Grepolis. (counter, displays, smilies, trade options, changes to the layout)
  7. // @include https://de.grepolis.com/game*
  8. // @include http://*.grepolis.com/game*
  9. // @include https://*.grepolis.com/game*
  10. // @include http://*forum.*.grepolis.com/*.php*
  11. // @include http://diotools.pf-control.de/*
  12. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
  13. // @icon http://s7.directupload.net/images/140128/vqchpigi.gif
  14. // @icon64 http://diotools.pf-control.de/images/icon_dio_64x64.png
  15. // @copyright 2013+, DIONY
  16. // @grant GM_info
  17. // @grant GM_setValue
  18. // @grant GM_getValue
  19. // @grant GM_deleteValue
  20. // @grant GM_xmlhttpRequest
  21. // ==/UserScript==
  22.  
  23. var version = '2.30';
  24.  
  25. //if(unsafeWindow.DM) console.dir(unsafeWindow.DM.status('l10n'));
  26. //console.dir(DM.status('templates'));
  27.  
  28. //http://s7.directupload.net/images/140128/vqchpigi.gif - DIO-Tools-Smiley
  29.  
  30. //http://de44.grepolis.com/cache/js/libs/jquery-1.10.2.min.js
  31.  
  32.  
  33. //console.log(JSON.stringify(DM.getl10n()));
  34.  
  35. /*******************************************************************************************************************************
  36. * Changes
  37. * ----------------------------------------------------------------------------------------------------------------------------
  38. * | ● ...
  39. * | ● ...
  40. * | ● ...
  41. * | ● ...
  42. * ----------------------------------------------------------------------------------------------------------------------------
  43. *******************************************************************************************************************************/
  44.  
  45. /*******************************************************************************************************************************
  46. * Bugs / TODOs
  47. * ----------------------------------------------------------------------------------------------------------------------------
  48. * | ● Aktivitätsbox für Angriffe blendet nicht aus
  49. * | ● Smileys verschwinden manchmal? -> bisher nicht reproduzierbar
  50. * | ● Performanceeinbruch nach dem Switchen des WW-Fensters
  51. * | ● keine Smileys im Grepoforum mit Safari (fehlendes jQuery)
  52. * ----------------------------------------------------------------------------------------------------------------------------
  53. *******************************************************************************************************************************/
  54.  
  55. /*******************************************************************************************************************************
  56. * Global stuff
  57. *******************************************************************************************************************************/
  58. var uw = unsafeWindow || window, $ = uw.jQuery || jQuery, DATA, GM;
  59.  
  60. // GM-API?
  61. GM = (typeof GM_info === 'object') ? true : false;
  62.  
  63. // LOAD DATA
  64. if(GM && (uw.location.pathname === "/game/index")){
  65. var WID = uw.Game.world_id, MID = uw.Game.market_id, AID = uw.Game.alliance_id;
  66.  
  67. DATA = {
  68. // GLOBAL
  69. options : JSON.parse(GM_getValue("options", "{}")),
  70.  
  71. user : JSON.parse(GM_getValue("dio_user", "{}")),
  72. count: JSON.parse(GM_getValue("dio_count", "[]")),
  73.  
  74. notification : GM_getValue('notification', 0),
  75.  
  76. error: JSON.parse(GM_getValue('error', '{}')),
  77.  
  78. spellbox : JSON.parse(GM_getValue("spellbox", '{ "top":"23%", "left": "-150%", "show": false }')),
  79. commandbox: JSON.parse(GM_getValue("commandbox" , '{ "top":55, "left": 250 }')),
  80. tradebox : JSON.parse(GM_getValue("tradebox", '{ "top":55, "left": 450 }')),
  81.  
  82. // WORLD
  83. townTypes : JSON.parse(GM_getValue(WID + "_townTypes", GM_getValue("town_types", "{}"))),
  84. sentUnits : JSON.parse(GM_getValue(WID + "_sentUnits", GM_getValue(WID + "_sentUnitsArray", '{ "attack": {}, "support": {} }'))),
  85. biremes : JSON.parse(GM_getValue(WID + "_biremes", GM_getValue(WID + "_biri_data", "{}"))),
  86.  
  87. worldWonder : JSON.parse(GM_getValue(WID + "_wonder", '{ "ratio": {}, "storage": {}, "map": {} }')),
  88.  
  89. // MARKET
  90. worldWonderTypes : JSON.parse(GM_getValue(MID + "_wonderTypes", '{}'))
  91. };
  92.  
  93. if(!DATA.worldWonder.map) {
  94. DATA.worldWonder.map = {};
  95. }
  96.  
  97. // Temporary:
  98. if(GM_getValue(WID + "_ww_res")){
  99. DATA.worldWonder.ratio[AID] = parseInt(GM_getValue(WID + "_ratio", -1), 10);
  100. DATA.worldWonder.storage[AID] = JSON.parse(GM_getValue(WID + "_ww_res", "{}"));
  101.  
  102. GM_deleteValue(WID + "_ratio");
  103. GM_deleteValue(WID + "_ww_res");
  104. }
  105. //console.log(DATA.worldWonder);
  106.  
  107. GM_deleteValue("movebox");
  108. GM_deleteValue(WID + "_sentUnitsArray");
  109. GM_deleteValue(WID + "_biri_data");
  110. GM_deleteValue("town_types");
  111. GM_deleteValue('DIO-Notification');
  112. }
  113.  
  114. // GM: EXPORT FUNCTIONS
  115. uw.saveValueGM = function(name, val){
  116. setTimeout(function(){
  117. GM_setValue(name, val);
  118.  
  119. // Reload after saving settings
  120. if(name == "options") {
  121. window.location.reload();
  122. }
  123. }, 0);
  124. };
  125.  
  126. uw.deleteValueGM = function(name){
  127. setTimeout(function(){
  128. GM_deleteValue(name);
  129. },0, name);
  130. };
  131.  
  132. uw.chatUserRequest = function(){
  133. setTimeout(function(){
  134. GM_xmlhttpRequest({
  135. method: "GET",
  136. url: "http://api.relay-chat.de/compteur_js.php?chan="+ (uw.Game.market_id === "de" ? "Grepolis" + uw.Game.market_id.toUpperCase() : "GREPO"),
  137. onload: function(text){
  138. $('.nui_main_menu .chat .indicator').get(0).innerHTML = text.response.split("'")[1];
  139. $('.nui_main_menu .chat .indicator').get(0).style.display = 'block';
  140. },
  141. onerror: function(){
  142. $('.nui_main_menu .chat .indicator').get(0).style.display = 'none';
  143. }
  144. });
  145. }, 0);
  146. };
  147.  
  148. if(typeof exportFunction == 'function'){
  149. // Firefox > 30
  150. uw.DATA = cloneInto(DATA, unsafeWindow);
  151. exportFunction(uw.saveValueGM, unsafeWindow, {defineAs: "saveValueGM"});
  152. exportFunction(uw.deleteValueGM, unsafeWindow, {defineAs: "deleteValueGM"});
  153. exportFunction(uw.chatUserRequest, unsafeWindow, {defineAs: "chatUserRequest"});
  154. } else {
  155. // Firefox < 30, Chrome, Opera, ...
  156. uw.DATA = DATA;
  157. }
  158.  
  159. var time_a, time_b;
  160.  
  161. // APPEND SCRIPT
  162. function appendScript(){
  163. //console.log("GM-API: " + gm_bool);
  164. if(document.getElementsByTagName('body')[0]){
  165. var dioscript = document.createElement('script');
  166. dioscript.type ='text/javascript';
  167. dioscript.id = 'diotools';
  168.  
  169. time_a = uw.Timestamp.client();
  170. dioscript.textContent = DIO_GAME.toString().replace(/uw\./g, "") + "\n DIO_GAME("+ version +", "+ GM +", "+ time_a +");";
  171. document.body.appendChild(dioscript);
  172. } else {
  173. setTimeout(function(){
  174. appendScript();
  175. }, 500);
  176. }
  177. }
  178.  
  179. if(location.host === "diotools.pf-control.de"){
  180. // PAGE
  181. DIO_PAGE();
  182. } else {
  183. if((location.pathname !== "/game/index") && GM){
  184. // FORUM
  185. DIO_GAME(version);
  186. } else {
  187. // GAME
  188. appendScript();
  189. }
  190. }
  191.  
  192. function DIO_PAGE(){
  193. if(typeof GM_info == 'object') {
  194. setTimeout(function() {
  195. dio_user = JSON.parse(GM_getValue("dio_user", ""));
  196. console.log(dio_user);
  197. uw.dio_version = parseFloat(version);
  198. }, 0);
  199. } else {
  200. dio_user = localStorage.getItem("dio_user") || "";
  201.  
  202. dio_version = parseFloat(version);
  203. }
  204. }
  205. function DIO_FORUM(){
  206. if($(".editor_textbox_container").get(0)){
  207. loadSmileys();
  208. changeForumEditorLayout();
  209. addSmileyBoxForum();
  210. }
  211. }
  212. function DIO_GAME(version, gm, time_a){
  213. var MutationObserver = uw.MutationObserver || window.MutationObserver,
  214.  
  215. WID, MID, AID, PID, LID,
  216.  
  217. dio_sprite = "http://abload.de/img/dio_spritejmqxp.png"; // http://img1.myimg.de/DIOSPRITEe9708.png -> Forbidden!?
  218.  
  219. if(uw.location.pathname === "/game/index"){
  220. WID = uw.Game.world_id;
  221. MID = uw.Game.market_id;
  222. AID = uw.Game.alliance_id;
  223. PID = uw.Game.player_id;
  224. LID = uw.Game.locale_lang.split("_")[0]; // LID ="es";
  225.  
  226. // World with Artemis ??
  227. Game.hasArtemis = Game.constants.gods.length == 6;
  228. }
  229.  
  230. $.prototype.reverseList = [].reverse;
  231.  
  232. // LOAD DATA for Safari:
  233. if((typeof DATA === 'undefined') && (uw.location.pathname === "/game/index")){
  234.  
  235. DATA = {
  236. //GLOBAL
  237. options : JSON.parse(localStorage.getItem("options") || "{}"),
  238.  
  239. user : JSON.parse(localStorage.getItem("dio_user") || "{}"),
  240. count: JSON.parse(localStorage.getItem("dio_count") || "[]"),
  241.  
  242. notification : localStorage.getItem('notification') || localStorage.getItem('DIO-Notification') || 0,
  243.  
  244. error: JSON.parse(localStorage.getItem('error') || '{}'),
  245.  
  246. spellbox : JSON.parse(localStorage.getItem("spellbox") || '{ "top":"23%", "left": "-150%", "show": false }' ),
  247. commandbox: JSON.parse(localStorage.getItem("commandbox") || '{ "top":55, "left": 250 }' ),
  248. tradebox : JSON.parse(localStorage.getItem("tradebox") || '{ "top":55, "left": 450 }' ),
  249.  
  250. //WORLD
  251. townTypes : JSON.parse(localStorage.getItem(WID + "_townTypes") || localStorage.getItem("town_types") || "{}" ),
  252. sentUnits : JSON.parse(localStorage.getItem(WID + "_sentUnits") || localStorage.getItem(WID + "_sentUnitsArray") || '{ "attack": {}, "support": {} }' ),
  253. biremes : JSON.parse(localStorage.getItem(WID + "_biremes") || localStorage.getItem(WID + "_biri_data") || "{}" ),
  254.  
  255. worldWonder : JSON.parse(localStorage.getItem(WID + "_wonder") || '{ "ratio": {}, "storage": {}, "map": {} }'),
  256.  
  257. // MARKET
  258. worldWonderTypes : JSON.parse(localStorage.getItem(MID + "_wonderTypes") || '{}')
  259. };
  260.  
  261. if(!DATA.worldWonder.map) {
  262. DATA.worldWonder.map = {};
  263. }
  264.  
  265. // Temporary:
  266. if(GM_getValue(WID + "_ww_res")){
  267. DATA.worldWonder.ratio[AID] = parseInt((localStorage.getItem(WID + "_ratio") || -1), 10);
  268. DATA.worldWonder.storage[AID] = JSON.parse(localStorage.getItem(WID + "_ww_res") || "{}");
  269.  
  270. localStorage.removeItem(WID + "_ratio");
  271. localStorage.removeItem(WID + "_ww_res");
  272. }
  273.  
  274. }
  275.  
  276. function saveValue(name, val){
  277. if(gm){
  278. saveValueGM(name, val);
  279. } else {
  280. localStorage.setItem(name, val);
  281. }
  282. }
  283.  
  284. function deleteValue(name){
  285. if(gm){
  286. deleteValueGM(name);
  287. } else {
  288. localStorage.removeItem(name);
  289. }
  290. }
  291.  
  292. /*******************************************************************************************************************************
  293. * Graphic filters
  294. *******************************************************************************************************************************/
  295. if(uw.location.pathname === "/game/index"){
  296. $('<svg width="0%" height="0%">'+
  297. '<filter id="GrayScale">'+
  298. '<feColorMatrix type="matrix" values="0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0">'+
  299. '</filter>'+
  300. '<filter id="Sepia">'+
  301. '<feColorMatrix type="matrix" values="0.343 0.669 0.119 0 0 0.249 0.626 0.130 0 0 0.172 0.334 0.111 0 0 0.000 0.000 0.000 1 0">'+
  302. '</filter>'+
  303. '<filter id="Saturation"><feColorMatrix type="saturate" values="0.2"></filter>'+
  304. '<filter id="Saturation1"><feColorMatrix type="saturate" values="1"></filter>'+
  305. '<filter id="Saturation2"><feColorMatrix type="saturate" values="2"></filter>'+
  306. '<filter id="Hue1"><feColorMatrix type="hueRotate" values= "65"></filter>'+
  307. '<filter id="Hue2"><feColorMatrix type="hueRotate" values="150"></filter>'+
  308. '<filter id="Hue3"><feColorMatrix type="hueRotate" values="-65"></filter>'+
  309. '<filter id="Brightness15">'+
  310. '<feComponentTransfer>'+
  311. '<feFuncR type="linear" slope="1.5"/><feFuncG type="linear" slope="1.5"/><feFuncB type="linear" slope="1.5"/>'+
  312. '</feComponentTransfer>'+
  313. '</filter>'+
  314. '<filter id="Brightness12">'+
  315. '<feComponentTransfer>'+
  316. '<feFuncR type="linear" slope="1.2"/><feFuncG type="linear" slope="1.2"/><feFuncB type="linear" slope="1.2"/>'+
  317. '</feComponentTransfer>'+
  318. '</filter>'+
  319. '<filter id="Brightness11">'+
  320. '<feComponentTransfer>'+
  321. '<feFuncR type="linear" slope="1.1"/><feFuncG type="linear" slope="1.1"/><feFuncB type="linear" slope="1.1"/>'+
  322. '</feComponentTransfer>'+
  323. '</filter>'+
  324. '<filter id="Brightness10">'+
  325. '<feComponentTransfer>'+
  326. '<feFuncR type="linear" slope="1.0"/><feFuncG type="linear" slope="1.0"/><feFuncB type="linear" slope="1.0"/>'+
  327. '</feComponentTransfer>'+
  328. '</filter>'+
  329. '</svg>').appendTo('#ui_box');
  330. }
  331.  
  332. /*******************************************************************************************************************************
  333. * Language versions: german, english, french, russian, polish, spanish
  334. *******************************************************************************************************************************/
  335. var LANG = {
  336. de : {
  337. settings : {
  338. dsc: "DIO-Tools bietet unter anderem einige Anzeigen, eine Smileyauswahlbox,<br>Handelsoptionen und einige Veränderungen des Layouts.",
  339. act: "Funktionen der Toolsammlung aktivieren/deaktivieren:",
  340. prv: "Vorschau einzelner Funktionen:"
  341. },
  342. options : {
  343. bir: [ "Biremenzähler", "Zählt die jeweiligen Biremen einer Stadt und summiert diese. (Anzeige im Minimap-Bullauge links oben)" ],
  344. sml: [ "Smileys", "Erweitert die BBCode-Leiste um eine Smileybox" ],
  345. str: [ "Einheitenstärke", "Fügt mehrere Einheitenstärketabellen in verschiedenen Bereichen hinzu" ],
  346. trd: [ "Handel", "Erweitert das Handelsfenster um einen Prozentualer Handel, einen Rekrutierungshandel und Limitmarker für Stadtfeste" ],
  347. cnt: [ "EO-Zähler", "Zählt die ATT/UT-Anzahl im EO-Fenster (bisher nur bei eigenen Eroberungen)" ],
  348. way: [ "Laufzeit", "Zeigt im ATT/UT-Fenster die Laufzeit bei Verbesserter Truppenbewegung an" ],
  349. wwc: [ "Weltwunder", "Anteilsrechner & Rohstoffzähler + Vor- & Zurück-Buttons bei fertiggestellten WW's (momentan nicht deaktivierbar!)" ],
  350. sim: [ "Simulator", "Anpassung des Simulatorlayouts & permanente Anzeige der Erweiterten Modifikatorbox" ],
  351. spl: [ "Zauberbox", "Komprimierte verschiebbare & magnetische Zauberbox (Positionsspeicherung)" ],
  352. mov: [ "Aktivitätsboxen", "Verbesserte Anzeige der Handels- und Truppenaktivitätsboxen (Positionsspeicherung)" ],
  353. pop: [ "Popup", 'Ändert Gunst-Popup' ],
  354. tsk: [ "Taskleiste", 'Vergrößert die Taskleiste und minimiert das "Tägliche Belohnung"-Fenster beim Start' ],
  355. irc: [ "Chat", "Ersetzt den Allianzchat durch einen IRC-Chat" ],
  356. bbc: [ "DEF-Formular", "Erweitert die BBCode-Leiste um ein automatisches DEF-Formular" ],
  357. com: [ "Einheitenvergleich","Fügt Einheitenvergleichstabellen hinzu" ],
  358. twn: [ "Stadticons", "Fügt Stadttyp-Icons zur Stadtliste hinzu" ],
  359. con: [ "Kontextmenu", 'Vertauscht "Stadt selektieren" und "Stadtübersicht" im Kontextmenu'],
  360. sen: [ "Abgeschickte Einheiten", 'Zeigt im Angriffs-/Unterstützungsfenster abgeschickte Einheiten an'],
  361. tov: [ "Stadtübersicht", 'Ersetzt die neue Stadtansicht mit der alten Fensteransicht'],
  362. scr: [ "Mausrad", 'Man kann mit dem Mausrad die Übersichten wechseln'],
  363.  
  364. err: [ "Automatische Fehlerberichte senden", "Wenn du diese Option aktivierst, kannst du dabei helfen Fehler zu identifizieren." ],
  365. her: [ "Thrakische Eroberung", "Verkleinerung der Karte der Thrakischen Eroberung." ]
  366. },
  367. labels: {
  368. uni : "Verfügbare Einheiten",
  369. con : "Selektieren",
  370. // Smileys
  371. std: "Standard", gre: "Grepolis", nat: "Natur", ppl: "Leute", oth: "Sonstige",
  372. // Defense form
  373. ttl: "Übersicht: Stadtverteidigung", inf: "Informationen zur Stadt:", dev: "Abweichung",
  374. det: "Detailierte Landeinheiten", prm: "Premiumboni", sil: "Silberstand", mov: "Truppenbewegungen:",
  375. // WW
  376. leg: "WW-Anteil", stg: "Stufe", tot: "Gesamt",
  377. // Simulator
  378. str: "Einheitenstärke", los: "Verluste", mod: "ohne Modifikatoreinfluss",
  379. // Comparison box
  380. dsc: "Einheitenvergleich", hck: "Schlag", prc: "Stich", dst: "Distanz", sea: "See", att: "Angriff", def: "Verteidigung", spd: "Geschwindigkeit",
  381. bty: "Beute (Rohstoffe)", cap: "Transportkapazität", res: "Baukosten (Rohstoffe)", fav: "Gunst", tim: "Bauzeit (s)",
  382. // Trade
  383. rat: "Ressourcenverhältnis eines Einheitentyps", shr: "Anteil an der Lagerkapazität der Zielstadt", per: "Prozentualer Handel",
  384. // Sent units box
  385. lab: "Abgeschickt",
  386. improved_movement: "Verbesserte Truppenbewegung"
  387. },
  388. buttons: {
  389. sav: "Speichern", ins: "Einfügen", res: "Zurücksetzen"
  390. },
  391. },
  392. en : {
  393. settings : {
  394. dsc: "DIO-Tools offers, among other things, some displays, a smiley box,<br>trade options and some changes to the layout.",
  395. act: "Activate/deactivate features of the toolset:",
  396. prv: "Preview of several features:"
  397. },
  398. options : {
  399. bir: [ "Bireme counter", "Counts the biremes of a city and sums these" ],
  400. sml: [ "Smilies", "Extends the bbcode bar by a smiley box" ],
  401. str: [ "Unit strength", "Adds unit strength tables in various areas" ],
  402. trd: [ "Trade", "Extends the trade window by a percentage trade, a recruitment trade and limit markers for city festivals" ],
  403. cnt: [ "Conquests", "Counts the attacks/supports in the conquest window (only own conquests yet)" ],
  404. way: [ "Troop speed", "Displays improved troop speed in the attack/support window" ],
  405. wwc: [ "World wonder", "Share calculation & resources counter + previous & next buttons on finished world wonders (currently not deactivatable!)" ],
  406. sim: [ "Simulator", "Adaptation of the simulator layout & permanent display of the extended modifier box" ],
  407. spl: [ "Spell box", "Compressed movable & magnetic spell box (position memory)" ],
  408. mov: [ "Activity boxes", "Improved display of trade and troop activity boxes (position memory)" ],
  409. pop: [ "Popup", "Changes the favor popup" ],
  410. tsk: [ "Taskbar", "Increases the taskbar and minimizes the daily reward window on startup" ],
  411. irc: [ "Chat", 'Replaced the alliance chat by an irc chat. (FlashPlayer required)' ],
  412. bbc: [ "Defense form", "Extends the bbcode bar by an automatic defense form" ],
  413. com: [ "Unit Comparison", "Adds unit comparison tables" ],
  414. twn: [ "Town icons", "Adds town type icons to the town list" ],
  415. con: [ "Context menu", 'Swaps "Select town" and "City overview" in the context menu'],
  416. sen: [ "Sent units", 'Shows sent units in the attack/support window'],
  417. tov: [ "Town overview", 'Replaces the new town overview with the old window style'],
  418. scr: [ "Mouse wheel", 'You can change the views with the mouse wheel'],
  419.  
  420. err: [ "Send bug reports automatically", "If you activate this option, you can help identify bugs." ],
  421. her: [ "Thracian Conquest", "Downsizing of the map of the Thracian conquest." ]
  422. },
  423. labels: {
  424. uni : "Available Units",
  425. con : "Select town",
  426. // Smileys
  427. std: "Standard", gre: "Grepolis", nat: "Nature", ppl: "People", oth: "Other",
  428. // Defense form
  429. ttl: "Overview: Town defense", inf: "Town information:", dev: "Deviation",
  430. det: "Detailed land units", prm: "Premium bonuses", sil: "Silver volume", mov: "Troop movements:",
  431. // WW
  432. leg: "WW Share", stg: "Stage", tot: "Total",
  433. // Simulator
  434. str: "Unit strength", los: "Loss", mod: "without modificator influence",
  435. // Comparison box
  436. dsc: "Unit comparison",
  437. hck: "Blunt", prc: "Sharp", dst: "Distance", sea: "Sea",
  438. att: "Offensive", def: "Defensive", spd: "Speed", bty: "Booty (resources)",
  439. cap: "Transport capacity", res: "Costs (resources)", fav: "Favor", tim: "Recruiting time (s)",
  440. // Trade
  441. rat: "Resource ratio of an unit type", shr: "Share of the storage capacity of the target city", per: "Percentage trade",
  442. // Sent units box
  443. lab: "Sent units",
  444. improved_movement: "Improved troop movement"
  445. },
  446. buttons: {
  447. sav: "Save", ins: "Insert", res: "Reset"
  448. },
  449. },
  450. ///////////////////////////////////
  451. // French Translation by eclat49 //
  452. ///////////////////////////////////
  453. fr : {
  454. settings: {
  455. dsc: "DIO-Tools offres certains écrans, une boîte de smiley, les options <br>commerciales, des changements à la mise en page et d'autres choses.",
  456. act: "Activation/Désactivation des fonctions:",
  457. prv: "Aperçu des fonctions séparées:"
  458. },
  459. options : {
  460. bir: [ "Compteur de birèmes ", "Totalise l'ensemble des birèmes présentent en villes et les résume. (Remplace la mini carte dans le cadran)" ],
  461. sml: [ "Smileys", "Rajoutes une boite de smilies à la boite de bbcode" ],
  462. str: [ "Force unitaire", "Ajoutes des tableaux de force unitaire dans les différentes armes" ],
  463. trd: [ "Commerce", "Ajout d'une option par pourcentage, par troupes pour le commerce, ainsi qu'un affichage des limites pour les festivals" ],
  464. cnt: [ "Compteur conquête", "Comptabilise le nombre d'attaque et de soutien dans la fenêtre de conquête (valable que pour ses propre conquêtes)" ],
  465. way: [ "Vitesse des troupes ", "Rajoutes le temps de trajet avec le bonus accélération" ],
  466. wwc: [ "Merveille du monde", "Compteur de ressource et calcul d'envoi + bouton précédent et suivant sur les merveilles finies(ne peut être désactivé pour le moment)" ],
  467. sim: [ "Simulateur", "Modification de la présentation du simulateur et affichage permanent des options premium" ],
  468. spl: [ "Boîte de magie", "Boîte de sort cliquable et positionnable" ],
  469. mov: [ "Boîte d'activité", "Présentation améliorée du commerce et des mouvement de troupes (mémoire de position)" ],
  470. pop: [ "Popup", 'Change la popup de faveur' ],
  471. tsk: [ "Barre de tâches ", "La barre de tâches augmente et minimise le fenêtre de bonus journalier" ],
  472. irc: [ "Chat", "Remplace le chat de l'alliance à travers un chat IRC. (FlashPlayer requis)" ],
  473. bbc: [ "Formulaire de défense", "Ajout d'un bouton dans la barre BBCode pour un formulaire de défense automatique" ],
  474. com: [ "Comparaison des unités","Ajoutes des tableaux de comparaison des unités" ],
  475. twn: [ "Icônes des villes", "Ajoutes desicônes de type de ville à la liste de ville" ],
  476. con: [ "Menu contextuel", 'Swaps "Sélectionner ville" et "Aperçu de la ville" dans le menu contextuel'],
  477. sen: [ "Unités envoyées", 'Affiche unités envoyées dans la fenêtre attaque/support'],
  478. tov: [ "Aperçu de ville", "Remplace la nouvelle aperçu de la ville avec l'ancien style de fenêtre"],
  479. scr: [ "Molette de la souris", 'Avec la molette de la souris vous pouvez changer les vues'],
  480.  
  481. err: [ "Envoyer des rapports de bogues automatiquement", "Si vous activez cette option, vous pouvez aider à identifier les bugs." ]
  482. },
  483. labels: {
  484. uni : "Unités disponibles",
  485. con : "Sélectionner",
  486. // Smileys
  487. std: "Standard", gre: "Grepolis", nat: "Nature", ppl: "Gens", oth: "Autres",
  488. // Defense form
  489. ttl: "Aperçu: Défense de ville", inf: "Renseignements sur la ville:", dev: "Différence",
  490. det: "Unités terrestres détaillées", prm: "Bonus premium", sil: "Remplissage de la grotte", mov: "Mouvements de troupes:",
  491. // WW
  492. leg: "Participation", stg: "Niveau", tot: "Total",
  493. // Simulator
  494. str: "Force unitaire", los: "Pertes", mod: "sans influence de modificateur",
  495. // Comparison box
  496. dsc: "Comparaison des unités", hck: "Contond.", prc: "Blanche", dst: "Jet", sea: "Navale", att: "Attaque", def: "Défense", spd: "Vitesse",
  497. bty: "Butin", cap: "Capacité de transport", res: "Coût de construction", fav: "Faveur", tim: "Temps de construction (s)",
  498. // Trade
  499. rat: "Ratio des ressources d'un type d'unité", shr: "Part de la capacité de stockage de la ville cible", per: "Commerce de pourcentage",
  500. // Sent units box
  501. lab: "Envoyée",
  502. improved_movement: "Mouvement des troupes amélioré"
  503. },
  504. buttons: {
  505. sav: "Sauver", ins: "Insertion", res: "Remettre"
  506. },
  507. },
  508. ///////////////////////////////////
  509. // Russian Translation by MrBobr //
  510. ///////////////////////////////////
  511. ru : {
  512. settings : {
  513. dsc: "DIO-Tools изменяет некоторые окна, добавляет новые смайлы, отчёты,<br>улучшеные варианты торговли и другие функции.",
  514. act: "Включение/выключение функций:",
  515. prv: "Примеры внесённых изменений:"
  516. },
  517. options : {
  518. bir: [ "Счётчик бирем", "Показывает число бирем во всех городах" ],
  519. sml: [ "Смайлы", "Добавляет кнопку для вставки смайлов в сообщения" ],
  520. str: [ "Сила отряда", "Добавляет таблицу общей силы отряда в некоторых окнах" ],
  521. trd: [ "Торговля", "Добавляет маркеры и отправку недостающих ресурсов, необходимых для фестиваля. Инструменты для долевой торговли" ],
  522. cnt: [ "Завоевания", "Отображение общего числа атак/подкреплений в окне завоевания города (only own conquests yet)" ],
  523. way: [ "30% ускорение", "Отображает примерное время движения отряда с 30% бонусом" ],
  524. wwc: [ "Чудо света", "Share calculation & resources counter + previous & next buttons on finished world wonders (currently not deactivatable!)" ],
  525. sim: [ "Симулятор", "Изменение интерфейса симулятора, добавление новых функций" ],
  526. spl: [ "Заклинания", "Изменяет положение окна заклинаний" ],
  527. mov: [ "Перемещения", "Показывает окна пересылки ресурсов и перемещения войск" ],
  528. pop: [ "Благосклонность", "Отображение окна с уровнем благосклонности богов" ],
  529. tsk: [ "Таскбар", "Увеличение ширины таскбара и сворачивание окна ежедневной награды при входе в игру" ],
  530. irc: [ "Чат", 'Замена чата игры на irc-чат' ],
  531. bbc: [ "Форма обороны", "Добавляет кнопку для вставки в сообщение отчёта о городе" ], // Beschreibung passt nicht ganz
  532. com: [ "Сравнение юнитов", "Добавляет окно сравнения юнитов" ],
  533. twn: [ "Типы городов", "Добавляет иконку к городу в списке" ],
  534. //con: [ "Context menu", 'Swaps "Select town" and "City overview" in the context menu'],
  535. //sen: [ "Sent units", 'Shows sent units in the attack/support window'],
  536. tov: [ "Обзор Город", 'Заменяет новый обзор города с старом стиле окна'], // ?
  537. scr: [ "Колесо мыши", 'С помощью колеса мыши вы можете изменить взгляды'], // ?
  538.  
  539. err: [ "Отправить сообщения об ошибках автоматически", "Если вы включите эту опцию, вы можете помочь идентифицировать ошибки"]
  540. },
  541.  
  542. labels: {
  543. uni : "Доступные войска",
  544. con : "выбирать",
  545. // Smileys
  546. std: "", gre: "", nat: "", ppl: "", oth: "",
  547. // Defense form
  548. ttl: "Обзор: Отчёт о городе", inf: "Информация о войсках и постройках:", dev: "Отклонение",
  549. det: "Детальный отчёт", prm: "Премиум-бонусы", sil: "Серебро в пещере", mov: "Перемещения",
  550. // WW
  551. leg: "", stg: "", tot: "",
  552. // Simulator
  553. str: "Сила войск", los: "Потери", mod: "без учёта заклинаний, бонусов, исследований",
  554. // Comparison box
  555. dsc: "Сравнение юнитов", hck: "Ударное", prc: "Колющее", dst: "Дальнего боя", sea: "Морские", att: "Атака", def: "Защита", spd: "Скорость",
  556. bty: "Добыча (ресурсы)", cap: "Вместимость транспортов", res: "Стоимость (ресурсы)", fav: "Благосклонность", tim: "Время найма (с)",
  557. // Trade
  558. rat: "", shr: "", per: "",
  559. // Sent units box
  560. lab: "Отправлено",
  561. improved_movement: "Улучшенная перемещение войск"
  562. },
  563.  
  564. buttons: {
  565. sav: "Сохраниить", ins: "Вставка", res: "Сброс"
  566. },
  567. },
  568. ////////////////////////////////
  569. // Polish Translation by anpu //
  570. ////////////////////////////////
  571. pl : {
  572. settings: {
  573. dsc: "DIO-Tools oferuje (między innymi) poprawione widoki, nowe uśmieszki,<br>opcje handlu i zmiany w wyglądzie.",
  574. act: "Włącz/wyłącz funkcje skryptu:",
  575. prv: "podgląd poszczególnych opcji:"
  576. },
  577. options : {
  578. bir: [ "Licznik birem", "Zlicza i sumuje biremy z miast" ],
  579. sml: [ "Emotki", "Dodaje dodatkowe (zielone) emotikonki" ],
  580. str: [ "Siła jednostek", "dodaje tabelki z siłą jednostek w różnych miejscach gry" ],
  581. trd: [ "Handel", "Rozszerza okno handlu o handel procentowy, proporcje surowców wg jednostek, dodaje znaczniki dla festynów" ],
  582. cnt: [ "Podboje", "Zlicza wsparcia/ataki w oknie podboju (tylko własne podboje)" ],
  583. way: [ "Prędkość wojsk", "Wyświetla dodatkowo czas jednostek dla bonusu przyspieszone ruchy wojsk" ],
  584. wwc: [ "Cuda Świata", "Liczy udział w budowie oraz ilość wysłanych surowców na budowę Cudu Świata oraz dodaje przyciski do szybkiego przełączania między cudami (obecnie nie możliwe do wyłączenia)" ],
  585. sim: [ "Symulator", "Dostosowanie wyglądu symulatora oraz dodanie szybkich pól wyboru" ],
  586. spl: [ "Ramka czarów", "Kompaktowa pływająca ramka z czarami (można umieścić w dowolnym miejscu ekranu. Zapamiętuje położenie.)" ],
  587. mov: [ "Ramki aktywności", "Ulepszony podgląd ruchów wojsk i handlu (można umieścić w dowolnym miejscu ekranu. Zapamiętuje położenie.)" ],
  588. pop: [ "Łaski", "Zmienia wygląd ramki informacyjnej o ilości produkowanych łask" ],
  589. tsk: [ "Pasek skrótów", "Powiększa pasek skrótów i minimalizuje okienko z bonusem dziennym" ],
  590. irc: [ "Czat", 'Zastępuje standardowy Chat chatem IRC (wymagany FlashPlayer)' ],
  591. bbc: [ "Raportów obronnych","Rozszerza pasek skrótów BBcode o generator raportów obronnych" ],
  592. com: [ "Porównianie", "Dodaje tabelki z porównaniem jednostek" ],
  593. twn: [ "Oznaczanie miast", "Możliwość oznaczania ikonami miast na liście" ],
  594. con: [ "menu kontekstowe", 'Zamiemia miejcami przycisk "wybierz miasto" z przyciskiem "podgląd miasta" po kliknięciu miasta na mapie'],
  595. sen: [ "Wysłane jednostki", 'Pokaż wysłane jednostki w oknie wysyłania ataków/wsparć'],
  596. tov: [ "Podgląd miasta", 'Zastępuje nowy podgląd miasta starym'],
  597. scr: [ "Zoom", 'Możesz zmienić poziom przybliżenia mapy kółkiem myszy'],
  598.  
  599. err: [ "Automatycznie wysyłać raporty o błędach", "Jeśli włączysz tę opcję, możesz pomóc zidentyfikować błędy"]
  600.  
  601. },
  602. labels: {
  603. uni : "Dostępne jednostki",
  604. con : "Wybierz miasto",
  605. // Smileys
  606. std: "Standard" /* "Standardowe" */, gre: "Grepolis", nat: "Przyroda", ppl: "Ludzie", oth: "Inne",
  607. // Defense form
  608. ttl: "Podgląd: Obrona miasta", inf: "Informacje o mieście:", dev: "Ochyłka",
  609. det: "jednostki lądowe", prm: "opcje Premium", sil: "Ilość srebra", mov: "Ruchy wojsk",
  610. // WW
  611. leg: "Udział w Cudzie", stg: "Poziom", tot: "Łącznie",
  612. // Simulator
  613. str: "Siła jednostek", los: "Straty", mod: "bez modyfikatorów",
  614. // Comparison box
  615. dsc: "Porównianie jednostek", hck: "Obuchowa", prc: "Tnąca", dst: "Dystansowa", sea: "Morskie", att: "Offensywne", def: "Defensywne", spd: "Prędkość",
  616. bty: "Łup (surowce)", cap: "Pojemność transportu", res: "Koszta (surowce)", fav: "Łaski", tim: "Czas rekrutacji (s)",
  617. // Trade
  618. rat: "Stosunek surowców dla wybranej jednostki", shr: "procent zapełnienia magazynu w docelowym mieście", per: "Handel procentowy",
  619. // Sent units box
  620. lab: "Wysłane jednostki",
  621. improved_movement: "Przyspieszone ruchy wojsk‎"
  622. },
  623. buttons: {
  624. sav: "Zapisz", ins: "Wstaw", res: "Anuluj"
  625. },
  626. },
  627. //////////////////////////////////////////////
  628. // Spanish Translation by Juana de Castilla //
  629. //////////////////////////////////////////////
  630. es : {
  631. settings : {
  632. dsc: "DIO-Tools ofrece, entre otras cosas, varias pantallas, ventana de <br>emoticones, opciones de comercio y algunos cambios en el diseño.",
  633. act: "Activar/desactivar características de las herramientas:",
  634. prv: "Vista previa de varias características:"
  635. },
  636. options : {
  637. bir: [ "Contador de birremes", "Cuenta los birremes de una ciudad y los suma" ],
  638. sml: [ "Emoticones", "Código BB para emoticones" ],
  639. str: [ "Fortaleza de la Unidad", "Añade tabla de fortalezas de cada unidad en varias zonas" ],
  640. trd: [ "Comercio", "Añade en la pestaña de comercio un porcentaje de comercio y reclutamiento y limitadores de Mercado por cada ciudad" ],
  641. cnt: [ "Conquistas", "contador de ataques y refuerzos en la pestaña de conquista" ],
  642. way: [ "Velocidad de tropas", "Muestra movimiento de tropas mejorado en la ventana de ataque/refuerzo" ],
  643. wwc: [ "Maravillas", "Calcula participación & contador de recursos + antes y después teclas de maravillas terminadas (no desactibable ahora!)" ],
  644. sim: [ "Simulador", "Adaptación de la ventana del simulador incluyendo recuadro de modificadores" ],
  645. spl: [ "Ventana de hechizos", "Ventana deslizante y comprimida de los hechizos (memoria posicional)"],
  646. mov: [ "Ventana de actividad", "Mejora las ventanas de comercio y movimiento de tropas (memoria posicional)" ],
  647. pop: [ "Popup", "Cambia el popup de favores" ],
  648. tsk: [ "Barra de tareas", "aumenta la barra de tareas y minimice la recompensa al aparecer" ],
  649. irc: [ "Chat", 'Sustituye el chat de la alianza con un irc chat. (require FlashPlayer)' ],
  650. bbc: [ "Formulario de defensa", "Añade en la barra de códigos bb un formulario de defensa" ],
  651. com: [ "Comparación", "añade ventana de comparación de unidades" ],
  652. twn: [ "Iconos de la ciudad", "Añade iconos de tipo de ciudad en el listado de ciudades" ],
  653. con: [ "menú contextual", 'Cambia "Elegir ciudad" y "vista de la ciudad" en el menú contextual '],
  654. sen: [ "Unidades enviadas", 'Muestra las unidades enviadas en la ventana de ataque/refuerzos'],
  655. tov: [ "Información de la ciudad", 'sustituye la vista nueva de ciudad por la ventana antigua'],
  656. scr: [ "Rueda raton", 'Puede cambiar las vistas con la rueda del raton'],
  657.  
  658. err: [ "Enviar informes de errores automáticamente", "Si se activa esta opción, puede ayudar a identificar errores." ]
  659. },
  660. labels: {
  661. uni : "Unidades disponibles",
  662. con : "Escoger ciudad",
  663. // Smileys
  664. std: "Standard", gre: "Grepolis", nat: "Natura", ppl: "Gente", oth: "Otros",
  665. // Defense form
  666. ttl: "Vista general: Defensa de la ciudad", inf: "Información de la ciudad:", dev: "Desviación",
  667. det: "Unidades de tierra detalladas", prm: "Bonos Premium", sil: "Volumen de plata", mov: "Movimientos de tropas:",
  668. // WW
  669. leg: "WW cuota", stg: "Nivel", tot: "Total",
  670. // Simulator
  671. str: "Fortaleza de la Unidad", los: "Perdida", mod: "sin influencia del modificador",
  672. // Comparison box
  673. dsc: "Comparación de Unidades",
  674. hck: "Contundente", prc: "Punzante", dst: "Distancia", sea: "Mar",
  675. att: "Ataque", def: "Defensa", spd: "Velocidad", bty: "Botín (recursos)",
  676. cap: "Capacidad de transporte", res: "Costes (recursos)", fav: "Favor", tim: "Tiempo de reclutamiento (s)",
  677. // Trade
  678. rat: "Proporción de recursos de un tipo de unidad", shr: "Porcentaje de la capacidad de almacenamiento de la ciudad destino", per: "Porcentaje de comercio",
  679. // Sent units box
  680. lab: "Unidades enviadas",
  681. improved_movement: "Movimiento de tropas mejorados"
  682. },
  683. buttons: {
  684. sav: "Guardar", ins: "Insertar", res: "Reinicio"
  685. }
  686. },
  687. ar : {}
  688. };
  689.  
  690. LANG.ar = LANG.es;
  691.  
  692. // Create JSON
  693. // console.log(JSON.stringify(LANG.en));
  694.  
  695. /*******************************************************************************************************************************
  696. * Settings
  697. *******************************************************************************************************************************/
  698.  
  699. // (De)activation of the features
  700. var options_def = {
  701. bir : true, // Biremes counter
  702. sml : true, // Smileys
  703. str : true, // Unit strength
  704. trd : true, // Trade options
  705. way : true, // Troop speed
  706. cnt : true, // Attack/support counter
  707. sim : true, // Simulator
  708. spl : true, // Spell box
  709. mov : false,// Activity boxes
  710. tsk : true, // Task bar
  711. irc : true, // IRC-Chat
  712. pop : true, // Favor popup
  713. wwc : true, // World wonder
  714. bbc : true, // BBCode bar
  715. com : true, // Unit comparison
  716. twn : true, // Town icons
  717. con : true, // Context menu
  718. sen : true, // Sent units
  719. tov : false,// Town overview
  720. scr : true, // Mausrad,
  721.  
  722. err : false,
  723. her : true // Thrakische Eroberung
  724. };
  725. if(uw.location.pathname === "/game/index"){
  726. for(var opt in options_def){
  727. if(options_def.hasOwnProperty(opt)){
  728. if(DATA.options[opt] == undefined) {
  729. DATA.options[opt] = options_def[opt];
  730. }
  731. }
  732. }
  733. }
  734.  
  735. // Add DIO-Tools to grepo settings
  736. function settings() {
  737. var wid = $(".settings-menu").get(0).parentNode.id;
  738.  
  739. if(!$("#dio_tools").get(0)){
  740. $(".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>');
  741. }
  742.  
  743. $(".settings-link").click(function () {
  744. $('.section').each(function(){
  745. $(this).get(0).style.display = "block";
  746. });
  747. $('.settings-container').removeClass("dio_overflow");
  748.  
  749. $('#dio_bg_medusa').css({ display: "none" });
  750.  
  751. if($('#dio_settings').get(0)) { $('#dio_settings').get(0).style.display = "none"; }
  752. });
  753.  
  754. $("#dio_tools").click(function () {
  755. if($('.email').get(0)) { $('.settings-container').removeClass("email"); }
  756.  
  757. $('.settings-container').addClass("dio_overflow");
  758.  
  759. $('#dio_bg_medusa').css({ display: "block" });
  760.  
  761. if(!$('#dio_settings').get(0)){
  762. $('.settings-container').append(
  763. '<div id="dio_settings" class="player_settings section"><div id="dio_bg_medusa"></div>'+
  764. '<div class="game_header bold"><a href="#" target="_blank" style="color:white">DIO-Tools (v'+ version +')</a></div>'+
  765. '<p>' + getText("settings", "dsc") + '</p>'+
  766. '<p class="bold"><u>'+ getText("settings", "act") + '</u></p>'+
  767. '<table width="100%" style=" font-size: 0.8em;"><tr><td width="24%">'+
  768. '<div id="bir" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "bir")[0] +'</div></div><br><br>'+
  769. '<div id="sml" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "sml")[0] +'</div></div><br><br>'+
  770. '<div id="str" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "str")[0] +'</div></div><br><br>'+
  771. '<div id="bbc" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "bbc")[0] +'</div></div><br><br>'+
  772. '<div id="con" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "con")[0] +'</div></div><br><br>'+
  773. '</td><td width="21%">'+
  774. '<div id="trd" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "trd")[0] +'</div></div><br><br>'+
  775. '<div id="cnt" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "cnt")[0] +'</div></div><br><br>'+
  776. '<div id="way" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "way")[0] +'</div></div><br><br>'+
  777. '<div id="wwc" class="checkbox_new disabled"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "wwc")[0] +'</div></div><br><br>'+
  778. '<div id="sen" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "sen")[0] +'</div></div><br><br>'+
  779. '</td><td width="20%">'+
  780. '<div id="sim" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "sim")[0] +'</div></div><br><br>'+
  781. '<div id="spl" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "spl")[0] +'</div></div><br><br>'+
  782. '<div id="tsk" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "tsk")[0] +'</div></div><br><br>'+
  783. '<div id="twn" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "twn")[0] +'</div></div><br><br>'+
  784. '<div id="tov" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "tov")[0] +'</div></div><br><br>'+
  785. '</td><td>'+
  786. '<div id="com" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "com")[0] +'</div></div><br><br>'+
  787. '<div id="mov" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "mov")[0] +'</div></div><br><br>'+
  788. '<div id="pop" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "pop")[0] +'</div></div><br><br>'+
  789. '<div id="irc" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "irc")[0] +'</div></div><br><br>'+
  790. '<div id="scr" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "scr")[0] +'</div></div><br><br>'+
  791. '</td></tr><tr><td colspan="4">'+
  792. '<div id="err" class="checkbox_new" style="float:left"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "err")[0] +'</div></div>'+
  793. '<div id="her" class="checkbox_new" style="float:left"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("options", "her")[0] +'</div></div><br><br>'+
  794. '</td></tr>'+
  795. '</table>'+
  796. '<div><a class="button" id="dio_save" href="#">'+
  797. '<span class="left"><span class="right"><span class="middle"><small>' + getText("buttons", "sav") + '</small></span></span></span><span></span>'+
  798. '</a></div>'+
  799. '<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">'+
  800. '<img alt="Donate" src="' + (LID === "de" ? "http://s7.directupload.net/images/140131/ctahnu2q.png" : "https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif") + '"></a></div>'+
  801. //'<p class="bold"><u>'+ getText("settings", "prv") + '</u></p>'+
  802. '<br /><table><tr>'+
  803. '<td><img id="bi_img" src="http://i.imgur.com/94m7Gg8.png"></td>'+
  804. '<td><img id="sm_img" src="http://i.imgur.com/Y3BsENb.png"></td>'+
  805. '<td><img id="un_img" src="http://i.imgur.com/LXkSxsS.png"></td>'+
  806. '</tr></table></div></div>');
  807.  
  808. $('.checkbox_new .cbx_caption').css({
  809. whiteSpace: 'nowrap',
  810. marginRight: '10px'
  811. });
  812.  
  813. // Thrakische Eroberung
  814. if(!$('#happening_large_icon.hercules2014').get(0)){
  815. $('#her').css({ display: "none" });
  816. }
  817.  
  818. $("#bi_img").tooltip(getText("options", "bir")[0]); $("#sm_img").tooltip(getText("options", "sml")[0]); $("#un_img").tooltip(getText("options", "str")[0]);
  819.  
  820. $("#bir").tooltip(getText("options", "bir")[1]); $("#sml").tooltip(getText("options", "sml")[1] + "<br><br><img src='http://666kb.com/i/ckajscggscw4s2u60.gif'>");
  821. $("#str").tooltip(getText("options", "str")[1]); $("#bbc").tooltip(getText("options", "bbc")[1]);
  822. $("#con").tooltip(getText("options", "con")[1]);
  823.  
  824. $("#trd").tooltip(getText("options", "trd")[1]); $("#cnt").tooltip(getText("options", "cnt")[1]); $("#way").tooltip(getText("options", "way")[1]);
  825. $("#wwc").tooltip(getText("options", "wwc")[1]); $("#sen").tooltip(getText("options", "sen")[1]);
  826.  
  827. $("#sim").tooltip(getText("options", "sim")[1]); $("#spl").tooltip(getText("options", "spl")[1]); $("#mov").tooltip(getText("options", "mov")[1]);
  828. $("#com").tooltip(getText("options", "com")[1]); $("#tov").tooltip(getText("options", "tov")[1]);
  829.  
  830. $("#pop").tooltip(getText("options", "pop")[1]); $("#tsk").tooltip(getText("options", "tsk")[1]); $("#irc").tooltip(getText("options", "irc")[1]);
  831. $("#twn").tooltip(getText("options", "twn")[1]); $("#scr").tooltip(getText("options", "scr")[1]);
  832.  
  833. $("#err").tooltip(getText("options", "err")[1]); $("#her").tooltip(getText("options", "her")[1]);
  834.  
  835. if(!uw.Layout.wnd.TYPE_TOWNINDEX){
  836. $('#tov').addClass("disabled");
  837. $('#tov .cbx_caption').get(0).style.color = "red";
  838. $("#tov").tooltip('<span style="color:red">This feature was unfortunately prevented by the Grepolis developers on purpose. They call it "code cleanup". Sorry...</span>');
  839. }
  840.  
  841. $("#dio_settings .checkbox_new").click(function () {
  842. $(this).toggleClass("checked");
  843. });
  844. for(var e in DATA.options) {
  845. if(DATA.options.hasOwnProperty(e)){
  846. if (DATA.options[e] == true) {
  847. $("#" + e).addClass("checked");
  848. }
  849. }
  850. }
  851.  
  852. $('#dio_save').click(function(){
  853. $('#dio_settings .checkbox_new').each(function(){
  854. var act = false;
  855. if ($("#" + this.id).hasClass("checked")) {
  856. act = true;
  857. }
  858. DATA.options[this.id] = act;
  859. });
  860. saveValue("options", JSON.stringify(DATA.options));
  861. });
  862. }
  863. $('.section').each(function(){
  864. $(this).get(0).style.display = "none";
  865. });
  866. $('#dio_settings').get(0).style.display = "block";
  867. });
  868. }
  869.  
  870.  
  871. function addSettingsButton(){
  872. $('<div class="btn_settings circle_button dio_settings"><div class="dio_icon js-caption"></div></div>').appendTo(".gods_area");
  873. $('.dio_settings').css({
  874. top: '95px',
  875. right: '103px',
  876. zIndex: '10'
  877. });
  878. $('.dio_settings .dio_icon').css({
  879. margin: '7px 0px 0px 4px', width: '24px', height: '24px',
  880. background: 'url(http://666kb.com/i/cifvfsu3e2sdiipn0.gif) no-repeat 0px 0px',
  881. backgroundSize: "100%"
  882. });
  883. $('.dio_settings').on('mouseup', function(){
  884. $('.dio_icon').get(0).style.marginTop = "7px";
  885. });
  886. $('.dio_settings').on('mousedown', function(){
  887. $('.dio_icon').get(0).style.marginTop = "8px";
  888. });
  889. $('.dio_settings').tooltip("DIO-Tools: " + DM.getl10n("layout", "config_buttons").settings);
  890.  
  891. $('.dio_settings').click(function(){
  892. clickDioSettings();
  893. });
  894. }
  895.  
  896. var diosettings = false;
  897. function clickDioSettings(){
  898. if(!uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_PLAYER_SETTINGS)){
  899. diosettings = true;
  900. }
  901. uw.Layout.wnd.Create(uw.GPWindowMgr.TYPE_PLAYER_SETTINGS,'Settings');
  902. }
  903.  
  904.  
  905. // Forum: Choose language
  906. if(!(uw.location.pathname === "/game/index")){
  907. LID = uw.location.host.split(".")[1];
  908. }
  909.  
  910. // Translation GET
  911. function getText(category, name){
  912. var txt = "???";
  913. if(LANG[LID]){
  914. if(LANG[LID][category]){
  915. if(LANG[LID][category][name]){
  916. txt = LANG[LID][category][name];
  917. } else { if(LANG.en[category]){ if(LANG.en[category][name]){
  918. txt = LANG.en[category][name];
  919. }}}
  920. } else {
  921. if(LANG.en[category]){ if(LANG.en[category][name]){
  922. txt = LANG.en[category][name];
  923. }}
  924. }
  925. } else {
  926. if(LANG.en[category]){ if(LANG.en[category][name]){
  927. txt = LANG.en[category][name];
  928. }}
  929. }
  930. return txt;
  931. }
  932.  
  933. var exc = false, sum = 0, ch = ["FBADAF", "IGCCJB"], alpha = 'ABCDEFGHIJ';
  934.  
  935. function a(){
  936. var pA = PID.toString(), pB = "";
  937.  
  938. for(var c in pA){ if(pA.hasOwnProperty(c)){ pB += alpha[pA[parseInt(c, 10)]];}}
  939.  
  940. sum = 0;
  941. for(var b in ch){
  942. if(ch.hasOwnProperty(b)){
  943. if(!(pB === ch[b])){exc = true;} else {exc = false; return;}
  944. for(var s in ch[b]){if(ch[b].hasOwnProperty(s)){sum += alpha.indexOf(ch[b][s]); }}
  945. }
  946. }
  947. }
  948.  
  949. var autoTownTypes, manuTownTypes, population, sentUnitsArray, biriArray, spellbox, commandbox, tradebox, wonder, wonderTypes;
  950.  
  951.  
  952. function setStyle(){
  953. // Settings
  954. $('<style type="text/css">'+
  955. '#dio_bg_medusa { background:url('+ dio_sprite +') -160px -43px no-repeat; height: 510px; width: 260px; right: -10px; z-index: -1; position: absolute;} '+
  956. '.dio_overflow { overflow: hidden; } '+
  957. '#dio_icon { width:15px; vertical-align:middle; margin-top:-2px; } '+
  958. '#quackicon { width:15px !important; vertical-align:middle !important; margin-top:-2px; height:12px !important; } '+
  959. '</style>').appendTo('head');
  960.  
  961. // Tutorial-Quest Container
  962. $('<style type="text/css"> #tutorial_quest_container { top: 130px } </style>').appendTo('head');
  963.  
  964. // Ranking
  965. $('<style type="text/css"> .wonder_ranking { display: none; } </style>').appendTo('head');
  966.  
  967. // Velerios
  968. $('<style id="dio_velerios" type="text/css"> #ph_trader_image { background-image: url(http://s14.directupload.net/images/140826/mh8k8nyw.jpg); } </style>').appendTo('head');
  969. // http://s7.directupload.net/images/140826/bgqlsdrf.jpg
  970.  
  971. // Specific player wishes
  972. if(PID == 1212083){
  973. $('<style id="dio_whishes" type="text/css"> #world_end_info { display: none; } </style>').appendTo('head');
  974. }
  975.  
  976. //Thracian Event Map
  977. if(DATA.options.her){
  978. $('<style id="dio_hercules" type="text/css"> .hercules_map .stages { -webkit-transform: scale(0.5); transform: scale(0.5); margin-left: -33%; } '+
  979. '.hercules2014_map .dragdrop, .hercules2014_map .hercules_map { width: 800px !important; height: 600px !important; } '+
  980. '.hercules_map { background-size: 100% !important; } '+
  981. '</style>').appendTo('head');
  982. }
  983. }
  984. if(uw.location.pathname === "/game/index"){
  985. setStyle();
  986. }
  987.  
  988. function loadFeatures(){
  989. if(typeof(ITowns) !== "undefined"){
  990.  
  991. autoTownTypes = {}; manuTownTypes = DATA.townTypes; population = {};
  992.  
  993. sentUnitsArray = DATA.sentUnits; biriArray = DATA.biremes;
  994.  
  995. spellbox = DATA.spellbox; commandbox = DATA.commandbox; tradebox = DATA.tradebox;
  996.  
  997. wonder = DATA.worldWonder; wonderTypes = DATA.worldWonderTypes;
  998.  
  999.  
  1000. var DIO_USER = { 'name': uw.Game.player_name, 'market': MID };
  1001. saveValue("dio_user", JSON.stringify(DIO_USER));
  1002.  
  1003. $.Observer(uw.GameEvents.game.load).subscribe('DIO_START', function(e,data){
  1004. // check if city overview window exists
  1005. if(!uw.Layout.wnd.TYPE_TOWNINDEX){
  1006. DATA.options.tov = false;
  1007. }
  1008. // replace start city overview with the window style
  1009. if(DATA.options.tov){
  1010. if($('#ui_box').hasClass("city-overview-enabled") && uw.Layout.wnd.TYPE_TOWNINDEX) {
  1011. $.Observer(uw.GameEvents.ui.bull_eye.radiobutton.island_view.click).publish({});
  1012. uw.GPWindowMgr.Create(uw.Layout.wnd.TYPE_TOWNINDEX, uw.DM.getl10n('town_index').window_title +" - "+ uw.ITowns.getTown(uw.Game.townId).name);
  1013. }
  1014. }
  1015. minimizeDailyReward();
  1016.  
  1017. a();
  1018.  
  1019. // English => default language
  1020. if(!LANG[LID]){ LID = "en"; }
  1021.  
  1022. if((ch.length == 2) && exc && (sum == 42)){
  1023. addFunctionToITowns();
  1024.  
  1025. if(DATA.options.tsk) {scaleTaskbar(); hideNavElements();}
  1026.  
  1027. if(DATA.options.com) {addComparisonButton();}
  1028. addSettingsButton();
  1029. addAvailableUnitsBox();
  1030. addAvailableUnitsButton();
  1031.  
  1032. //addStatsButton();
  1033.  
  1034. fixUnitValues();
  1035. if(DATA.options.bir) {initBiri();}
  1036.  
  1037. getAllUnits();
  1038. setInterval(function(){
  1039. getAllUnits();
  1040. },1800000);
  1041.  
  1042. if(DATA.options.pop) {unbindFavorPopup();}
  1043. if(DATA.options.spl) {catchSpellBox(); initSpellBox();}
  1044. imageSelectionProtection();
  1045.  
  1046. if(DATA.options.con) {changeContextMenu();}
  1047.  
  1048. /*
  1049. $.Observer(uw.GameEvents.menu.click).subscribe('DIO_MENU', function(e,data){
  1050. //console.log(data.option_id);
  1051. });
  1052. $.Observer(uw.GameEvents.attack.incoming).subscribe('DIO_ATTACK', function(e,data){
  1053. //console.log(data.count);
  1054. });
  1055. $.Observer(uw.GameEvents.town.units.change).subscribe('DIO_UNITCHANGE', function(e,data){
  1056. //console.log(data.count);
  1057. });
  1058. */
  1059.  
  1060. //Notification
  1061. uw.NotificationType.DIO_TOOLS = "diotools";
  1062. $('<style type="text/css"> #notification_area .diotools .icon { background: url(http://666kb.com/i/cifvfsu3e2sdiipn0.gif) 4px 7px no-repeat !important;} </style>').appendTo('head');
  1063.  
  1064. var notif = DATA.notification;
  1065. if(notif <= 7){
  1066. //newFeatureNotification(1, 'Swap context menu buttons ("Select town" and "City overview")');
  1067. //newFeatureNotification(2, 'Town overview (old window mode)');
  1068. //newFeatureNotification(3, 'Mouse wheel: You can change the views with the mouse wheel');
  1069. //newFeatureNotification(4, 'Town icons on the strategic map');
  1070. //newFeatureNotification(5, 'Percentual unit population in the town list');
  1071. //newFeatureNotification(6, 'New world wonder ranking');
  1072. newFeatureNotification(7, 'World wonder icons on the strategic map');
  1073. $('.diotools .icon').each(function(){
  1074. $(this).click(function(){
  1075. clickDioSettings();
  1076. $(this).parent().find(".close").click();
  1077. });
  1078. });
  1079. $('.diotools').css({
  1080. cursor: "pointer"
  1081. });
  1082. saveValue('notification', 8);
  1083. }
  1084.  
  1085. if(DATA.options.mov){showActivityBoxes();}
  1086. if(DATA.options.str){addStrengthMenu(); setStrengthMenu();}
  1087.  
  1088. if(DATA.options.twn){setTownList(); addTownIcon(); setTownIconsOnMap();}
  1089.  
  1090. if(DATA.options.com){addComparisonBox();}
  1091. if(DATA.options.sml){loadSmileys();}
  1092. if(DATA.options.irc){initChatUser();}
  1093.  
  1094. if(DATA.options.tov){setCityWindowButton();}
  1095.  
  1096. if(DATA.options.scr){scrollViews();}
  1097. if(DATA.options.sen){getSentUnits();}
  1098.  
  1099.  
  1100. setTimeout(function(){
  1101. counter(uw.Timestamp.server());
  1102. setInterval(function(){
  1103. counter(uw.Timestamp.server());
  1104. }, 21600000);
  1105. }, 60000);
  1106.  
  1107. // AJAX-EVENTS
  1108. ajaxObserver();
  1109.  
  1110. // Execute once to get the world wonder types and coordinates
  1111. setTimeout(function(){
  1112. if(!wonderTypes.great_pyramid_of_giza){
  1113. getWorldWonderTypes();
  1114. }
  1115. if(wonderTypes.great_pyramid_of_giza){
  1116. setTimeout(function(){
  1117. if(!wonder.map.mausoleum_of_halicarnassus){
  1118. getWorldWonders();
  1119. } else {
  1120. setWonderIconsOnMap();
  1121. }
  1122. }, 2000);
  1123. }
  1124. }, 3000);
  1125.  
  1126. // Execute once to get alliance ratio
  1127. if (wonder.ratio[AID] == -1 || !$.isNumeric(wonder.ratio[AID])){
  1128. setTimeout(function(){
  1129. getPointRatioFromAllianceProfile();
  1130. }, 5000);
  1131. }
  1132.  
  1133. }
  1134. time_b = uw.Timestamp.client();
  1135. //console.log("Gebrauchte Zeit:" + (time_b - time_a));
  1136. });
  1137. } else {
  1138. setTimeout(function(){
  1139. loadFeatures();
  1140. }, 100);
  1141. }
  1142. }
  1143. if(uw.location.pathname === "/game/index"){
  1144. loadFeatures();
  1145. }
  1146.  
  1147. /*******************************************************************************************************************************
  1148. * HTTP-Requests
  1149. * *****************************************************************************************************************************/
  1150. function ajaxObserver(){
  1151. $(document).ajaxComplete(function (e, xhr, opt) {
  1152. var url = opt.url.split("?"),
  1153. action = url[0].substr(5) + "/" + url[1].split(/&/)[1].substr(7);
  1154. if(PID == 84367 || PID == 104769){
  1155. console.log(action);
  1156. console.log((JSON.parse(xhr.responseText).json));
  1157. }
  1158. setTimeout(function(){
  1159. switch (action) {
  1160. case "/frontend_bridge/fetch": // Daily Reward
  1161.  
  1162. // Thracian Event
  1163. var el = $('.js-hercules2014-dragdrop.dragdrop').get(0);
  1164. if(el){
  1165. var map_left = parseInt(el.style.left.split("p")[0], 10);
  1166. var map_top = parseInt(el.style.top.split("p")[0], 10);
  1167.  
  1168. if((map_top < -216) || (map_left < -143)){
  1169. $('.js-hercules2014-dragdrop.dragdrop').css({
  1170. top: '-40px',
  1171. left: '-40px'
  1172. });
  1173. }
  1174. }
  1175.  
  1176. //console.log("done");
  1177. //$('.daily_login').find(".minimize").click();
  1178. break;
  1179. case "/player/index":
  1180. settings();
  1181. if(diosettings){ $('#dio_tools').click(); diosettings = false; }
  1182. break;
  1183. case "/index/switch_town":
  1184.  
  1185. if(DATA.options.str) {setStrengthMenu();}
  1186. if(DATA.options.bir) {getBiri();}
  1187. if(DATA.options.twn) {changeTownIcon();}
  1188.  
  1189. // Update city window
  1190. if(uw.Layout.wnd.TYPE_TOWNINDEX){ // check if the window type exists
  1191. if(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX)){
  1192. uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).setTitle(uw.DM.getl10n('town_index').window_title +" - "+ uw.ITowns.getTown(uw.Game.townId).name);
  1193. uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).reloadContent();
  1194. }
  1195. }
  1196. break;
  1197. case "/building_docks/index":
  1198. if(DATA.options.bir) {getBiriDocks();}
  1199. break;
  1200. case "/building_place/units_beyond":
  1201. if(DATA.options.bir) {getBiriAgora();}
  1202. //addTransporterBackButtons();
  1203. break;
  1204. case "/building_place/simulator":
  1205. if(DATA.options.sim) {changeSimulatorLayout(); }
  1206. break;
  1207. case "/building_place/simulate":
  1208. if(DATA.options.sim) {afterSimulation(); }
  1209. break;
  1210.  
  1211. case "/alliance_forum/forum": case "/message/new": case "/message/forward": case "/message/view": case "/player_memo/load_memo_content":
  1212. if(DATA.options.sml){addSmileyBox(action); }
  1213. if(DATA.options.bbc){addForm(action); }
  1214. break;
  1215. case "/wonders/index":
  1216. if(DATA.options.trd){WWTradeHandler(); }
  1217. getResWW();
  1218. break;
  1219. case "/wonders/send_resources":
  1220. getResWW();
  1221. break;
  1222. case "/ranking/alliance":
  1223. getPointRatioFromAllianceRanking();
  1224. break;
  1225. case "/ranking/wonder_alliance":
  1226. getPointRatioFromAllianceRanking();
  1227. changeWWRanking(JSON.parse(xhr.responseText).plain.html);
  1228. setWonderIconsOnMap();
  1229. break;
  1230. case "/alliance/members_show":
  1231. getPointRatioFromAllianceMembers();
  1232. break;
  1233. case "/town_info/trading":
  1234. if(DATA.options.trd){addTradeMarks(15, 18, 15, "red"); TownTabHandler(action.split("/")[2]); }
  1235. break;
  1236. case "/farm_town_overviews/get_farm_towns_for_town":
  1237. changeResColor();
  1238. break;
  1239. case "/command_info/conquest_info":
  1240. if(DATA.options.str) {addStrengthConquest();}
  1241. break;
  1242. case "/command_info/conquest_movements": case "/conquest_info/getinfo":
  1243. if(DATA.options.cnt) {countMovements();}
  1244. break;
  1245. case "/building_barracks/index": case "/building_barracks/build":
  1246. if(DATA.options.str) {setStrengthBarracks();}
  1247. break;
  1248. case "/town_info/attack": case "/town_info/support":
  1249. TownTabHandler(action.split("/")[2]);
  1250. break;
  1251. case "/report/index":
  1252. changeDropDownButton();
  1253. loadFilter();
  1254. saveFilter();
  1255. //removeReports();
  1256. break;
  1257. case "/message/default": case "/message/index":
  1258. break;
  1259. case "/chat/init":
  1260. if(DATA.options.irc) {modifyChat();}
  1261. break;
  1262. case "/town_info/go_to_town":
  1263. /*
  1264. //console.log(uw.Layout.wnd);
  1265. var windo = uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).getID();
  1266. //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX));
  1267. uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).setPosition([100,400]);
  1268. //console.log(windo);
  1269. //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).getPosition());
  1270. */
  1271.  
  1272. break;
  1273. }
  1274. },0);
  1275.  
  1276. });
  1277. }
  1278.  
  1279. function test(){
  1280. //http://gpde.innogamescdn.com/images/game/temp/island.png
  1281.  
  1282. //console.log(uw.WMap);
  1283. //console.log(uw.WMap.getSea(uw.WMap.getXCoord(), uw.WMap.getYCoord()));
  1284.  
  1285. //console.log(uw.GameControllers.LayoutToolbarActivitiesController().prototype.getActivityTypes());
  1286. //console.log(uw.GameViews);
  1287. //console.log(uw.GameViews.BarracksUnitDetails());
  1288.  
  1289. //console.log(uw.ITowns.getTown(uw.Game.townId).unitsOuter().sword);
  1290. //console.log(uw.ITowns.getCurrentTown().unitsOuter().sword);
  1291.  
  1292. //console.log(uw.ITowns.getTown(uw.Game.townId).researches().attributes);
  1293. //console.log(uw.ITowns.getTown(uw.Game.townId).hasConqueror());
  1294. //console.log(uw.ITowns.getTown(uw.Game.townId).allUnits());
  1295. //console.log(uw.ITowns.all_units.fragments[uw.Game.townId]._byId);
  1296. //console.log("Zeus: " + uw.ITowns.player_gods.zeus_favor_delta_property.lastTriggeredVirtualPropertyValue);
  1297. //console.log(uw.ITowns.player_gods.attributes);
  1298.  
  1299. //console.log(uw.ITowns.getTown('5813').createTownLink());
  1300. //console.log(uw.ITowns.getTown(5813).unitsOuterTown);
  1301.  
  1302. //console.log(uw.ITowns.getTown(uw.Game.townId).getLinkFragment());
  1303.  
  1304. //console.log(uw.ITowns.getTown(uw.Game.townId).allGodsFavors());
  1305. }
  1306.  
  1307. /*******************************************************************************************************************************
  1308. * Helping functions
  1309. * ----------------------------------------------------------------------------------------------------------------------------
  1310. * | ● fixUnitValues: Get unit values and overwrite some wrong values
  1311. * | ● getMaxZIndex: Get the highest z-index of "ui-dialog"-class elements
  1312. * ----------------------------------------------------------------------------------------------------------------------------
  1313. *******************************************************************************************************************************/
  1314.  
  1315. // Fix buggy grepolis values
  1316. function fixUnitValues(){
  1317. uw.GameData.units.small_transporter.attack = uw.GameData.units.big_transporter.attack = uw.GameData.units.demolition_ship.attack = uw.GameData.units.militia.attack = 0;
  1318. 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;
  1319. uw.GameData.units.militia.resources = { wood: 0, stone: 0, iron: 0 };
  1320. }
  1321.  
  1322. function getMaxZIndex(){
  1323. var maxZ = Math.max.apply(null,$.map($("div[class^='ui-dialog']"), function(e,n){
  1324. if($(e).css('position')=='absolute'){
  1325. return parseInt($(e).css('z-index'), 10) || 1000;
  1326. }
  1327. }));
  1328. return (maxZ !== -Infinity)? maxZ + 1 : 1000;
  1329. }
  1330.  
  1331. function getBrowser(){
  1332. var ua = navigator.userAgent, tem,
  1333. M = ua.match(/(opera|maxthon|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
  1334. if(/trident/i.test(M[1])){
  1335. tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
  1336. M[1] = 'IE';
  1337. M[2] = tem[1] || '';
  1338. }
  1339. if(M[1] === 'Chrome'){
  1340. tem = ua.match(/\bOPR\/(\d+)/);
  1341. if(tem != null){
  1342. M[1] = 'Opera';
  1343. M[2] = tem[1];
  1344. }
  1345. }
  1346. M = M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?'];
  1347. if((tem = ua.match(/version\/(\d+)/i))!= null) M.splice(1, 1, tem[1]);
  1348.  
  1349. return M.join(' ');
  1350. }
  1351.  
  1352. // Error Handling / Remote diagnosis / Automatic bug reports
  1353. function errorHandling(e, fn){
  1354. if(PID == 84367 || PID == 104769){
  1355. HumanMessage.error("DIO-TOOLS("+ version +")-ERROR: " + e.message);
  1356. console.log(e.stack);
  1357. } else {
  1358. if(!DATA.error[version]){
  1359. DATA.error[version] = {};
  1360. }
  1361.  
  1362. if(DATA.options.err && !DATA.error[version][fn]){
  1363. $.ajax({
  1364. type: "POST",
  1365. url: "https://diotools.pf-control.de/game/error.php",
  1366. data: { error: e.stack.replace(/'/g,'"') , "function": fn, browser: getBrowser(), version: version },
  1367. success: function (text) {
  1368. DATA.error[version][fn] = true;
  1369. saveValue("error", JSON.stringify(DATA.error));
  1370. }
  1371. });
  1372. }
  1373. }
  1374. }
  1375.  
  1376. // Notification
  1377. function newFeatureNotification(nid, feature){
  1378. var Notification = new NotificationHandler();
  1379. Notification.notify($('#notification_area>.notification').length+1, uw.NotificationType.DIO_TOOLS,
  1380. "<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>");
  1381. }
  1382.  
  1383. /*******************************************************************************************************************************
  1384. * Mousewheel Zoom
  1385. *******************************************************************************************************************************/
  1386.  
  1387. // Scroll trough the 2-3 views
  1388. function scrollViews(){
  1389. try {
  1390. var scroll = 2;
  1391. $('#main_area, .ui_city_overview').bind('mousewheel', function(e){
  1392. if($('.island_view').hasClass('checked')){
  1393. scroll = 2;
  1394. } else if($('.strategic_map').hasClass('checked')){
  1395. scroll = 1;
  1396. } else {
  1397. scroll = 3;
  1398. }
  1399. var delta = 0;
  1400. if (e.originalEvent.wheelDelta) {
  1401. if(e.originalEvent.wheelDelta < 0) { delta = -1;} else { delta = 1; }
  1402. }
  1403. if (e.originalEvent.detail) {
  1404. if(e.originalEvent.detail < 0) { delta = 1;} else { delta = -1; }
  1405. }
  1406.  
  1407. if(delta < 0) {
  1408. scroll -= 1;
  1409. if(scroll < 1) { scroll = 1; }
  1410. }else {
  1411. scroll += 1;
  1412. if(scroll > 2 && DATA.options.tov) { scroll = 2; }
  1413. if(scroll > 3) { scroll = 3; }
  1414. }
  1415.  
  1416. switch(scroll){
  1417. case 1: $('.strategic_map').click(); $('#popup_div').css('display', 'none'); break;
  1418. case 2: $('.island_view').click(); break;
  1419. case 3: $('.city_overview').click(); break;
  1420. }
  1421. //prevent page from scrolling
  1422. return false;
  1423. });
  1424. } catch(error){
  1425. errorHandling(error, "scrollViews");
  1426. }
  1427. }
  1428.  
  1429.  
  1430. /*******************************************************************************************************************************
  1431. * Statistics
  1432. * ----------------------------------------------------------------------------------------------------------------------------
  1433. * | ● Expansion of towns?
  1434. * | ● Occupancy of the farms?
  1435. * | ● Mouseclick-Counter?
  1436. * | ● Resource distribution (%)?
  1437. * | ● Building level counter ?
  1438. * ----------------------------------------------------------------------------------------------------------------------------
  1439. *******************************************************************************************************************************/
  1440.  
  1441. function addStatsButton(){
  1442. $('<div class="btn_statistics circle_button"><div class="ico_statistics js-caption"></div></div>').appendTo(".gods_area");
  1443. $('.btn_statistics').css({
  1444. top: '56px',
  1445. left: '-4px',
  1446. zIndex: '10',
  1447. position: 'absolute'
  1448. });
  1449. $('.btn_statistics .ico_statistics').css({
  1450. margin: '7px 0px 0px 8px', width: '17px', height: '17px',
  1451. background: 'url(http://s1.directupload.net/images/140408/pltgqlaw.png) no-repeat 0px 0px', // http://s14.directupload.net/images/140408/k4wikrlq.png // http://s7.directupload.net/images/140408/ahfr8227.png
  1452. backgroundSize: "100%",
  1453. //WebkitFilter: 'hue-rotate(100deg)',
  1454. //filter: 'url(#Hue3)'
  1455. });
  1456.  
  1457. mouseclickCounter();
  1458.  
  1459. $('.btn_statistics').on('mousedown', function(){
  1460. $('.ico_statistics').get(0).style.marginTop = "8px";
  1461. });
  1462. $('.btn_statistics').toggle(function(){
  1463. $('.btn_statistics').addClass("checked");
  1464. $('.ico_statistics').get(0).style.marginTop = "8px";
  1465. //console.log(click_cnt);
  1466. $('#statistics_box').get(0).style.display = "block";
  1467. $('#statistics_box').get(0).style.zIndex = getMaxZIndex() + 1;
  1468. }, function(){
  1469. $('.btn_statistics').removeClass("checked");
  1470. $('.ico_statistics').get(0).style.marginTop = "7px";
  1471. $('#statistics_box').get(0).style.display = "none";
  1472. });
  1473. $('.btn_statistics').tooltip(getText("labels", "uni"));
  1474. }
  1475.  
  1476. var click_cnt = 0;
  1477. function mouseclickCounter(){
  1478. // TODO: start date and reset button
  1479. $('body').click(function(){
  1480. click_cnt++;
  1481. });
  1482. }
  1483.  
  1484. /*******************************************************************************************************************************
  1485. * Body Handler
  1486. * ----------------------------------------------------------------------------------------------------------------------------
  1487. * | ● Town icon
  1488. * | ● Town list: Adds town type to the town list
  1489. * | ● Swap Context Icons
  1490. * | ● City overview
  1491. * ----------------------------------------------------------------------------------------------------------------------------
  1492. *******************************************************************************************************************************/
  1493.  
  1494. var townTypeIcon = {
  1495. // Automatic Icons
  1496. lo: 0, ld: 3, so: 6, sd: 7, fo: 10, fd: 9, bu: 14, /* Building */ po: 22, no: 12,
  1497.  
  1498. // Manual Icons
  1499. fa: 20, /* Favor */ re: 15, /* Resources */ di: 2, /* Distance */ sh: 1, /* Pierce */ lu: 13, /* ?? */ dp: 11, /* Diplomacy */ ha: 15, /* ? */ si: 18, /* Silber */ ra: 17, ch: 19, /* Research */ ti: 23, /* Time */ un: 5,
  1500. wd: 16, /* Wood */ wo: 24, /* World */ bo: 13, /* Booty */ gr: 21, /* Lorbeer */ st: 17, /* Stone */ is: 26, /* ?? */ he: 4, /* Helmet */ ko: 8 /* Kolo */
  1501. },
  1502. townTypeIcon2 = {
  1503. lo: "http://s14.directupload.net/images/140129/gvctb3i5.png", // red: http://s7.directupload.net/images/140129/mn4m2vhx.png kreuz: http://s1.directupload.net/images/140129/rdvuhlmc.png
  1504. ld: "http://s7.directupload.net/images/140129/zwts6zz8.png", // blue: http://s1.directupload.net/images/140129/oua87w9q.png
  1505. so: "http://s7.directupload.net/images/140129/674supp9.png", // smaller: http://s14.directupload.net/images/140129/x7jv2kc9.png
  1506. sd: "http://s14.directupload.net/images/140129/aseivxpl.png",
  1507. fo: "http://s14.directupload.net/images/140129/j9mwfuu4.png", // bright: http://s1.directupload.net/images/140129/7ueia7ja.png
  1508. fd: "http://s7.directupload.net/images/140129/lwtlj9ej.png", // bright: http://s1.directupload.net/images/140129/4an4dhr7.png
  1509.  
  1510. bu: "http://s1.directupload.net/images/140129/y3d6znpg.png", // http://s14.directupload.net/images/140129/wb9w9odq.png, // build2: http://s1.directupload.net/images/140129/qzj2vem6.png bbcode: http://s7.directupload.net/images/140129/d39yg9zj.png
  1511. po: "http://gpde.innogamescdn.com/images/game/res/pop.png",
  1512. no: "http://s7.directupload.net/images/140129/t8tjs543.png", // green: http://s7.directupload.net/images/140129/zneb6f3m.png
  1513. // brown: http://s14.directupload.net/images/140129/fhlanrua.png http://s14.directupload.net/images/140129/9m4xtmys.png http://s7.directupload.net/images/140129/9hflkab3.png
  1514.  
  1515. // Manual Icons
  1516. fa: "http://s7.directupload.net/images/140404/xt839us6.png", // "http://s7.directupload.net/images/140404/xifwkdqy.png",
  1517. re: "http://s14.directupload.net/images/140404/b4n3tyjh.png",
  1518. di: "http://s14.directupload.net/images/140404/nvqxx5j7.png",
  1519. sh: "http://s1.directupload.net/images/140404/mbvpptpg.png",
  1520. lu: "http://s1.directupload.net/images/140404/38n97lp5.png",
  1521. // ro: "http://s14.directupload.net/images/140404/9o22obra.png",
  1522. dp: "http://s1.directupload.net/images/140404/95cgvzcp.png",
  1523. ha: "http://s1.directupload.net/images/140404/9om7bf4m.png",
  1524. si: "http://s1.directupload.net/images/140404/b5eumrw7.png",
  1525. ra: "http://s14.directupload.net/images/140404/3qofe863.png",
  1526. ch: "http://s7.directupload.net/images/140404/jrthehnw.png",
  1527. ti: "http://s7.directupload.net/images/140404/u2a5x7as.png", // "http://s1.directupload.net/images/140404/ceubhq4f.png",
  1528. un: "http://s1.directupload.net/images/140404/x3um2uvt.png", //"http://s14.directupload.net/images/140404/ib4w63he.png", //"http://s7.directupload.net/images/140404/ltegir8t.png", //"http://s1.directupload.net/images/140404/88ljrpvt.png",
  1529.  
  1530. wd: "http://s7.directupload.net/images/140404/te9zldjx.png",
  1531. wo: "http://s1.directupload.net/images/140404/cxbjhapw.png",
  1532. bo: "http://s14.directupload.net/images/140404/ki4gwd7x.png",
  1533. gr: "http://s14.directupload.net/images/140404/n7bq4ixc.png",
  1534. st: "http://s1.directupload.net/images/140404/zwc8ctqh.png",
  1535. is: "http://s1.directupload.net/images/140404/48nlm7xd.png",
  1536. he: "http://s7.directupload.net/images/140404/uldko8rb.png",
  1537.  
  1538.  
  1539. ko: "http://s7.directupload.net/images/140404/r8kikv5d.png", // "http://s7.directupload.net/images/140404/qpawnrwd.png" // "http://s1.directupload.net/images/140404/icuao2mf.png" //
  1540. },
  1541. worldWonderIcon = {
  1542. colossus_of_rhodes: "url(http://gpde.innogamescdn.com/images/game/map/wonder_colossus_of_rhodes.png) 38px -1px;",
  1543. great_pyramid_of_giza: "url(http://gpde.innogamescdn.com/images/game/map/wonder_great_pyramid_of_giza.png) 34px -6px;",
  1544. hanging_gardens_of_babylon: "url(http://gpde.innogamescdn.com/images/game/map/wonder_hanging_gardens_of_babylon.png) 34px -5px;",
  1545. lighthouse_of_alexandria: "url(http://gpde.innogamescdn.com/images/game/map/wonder_lighthouse_of_alexandria.png) 37px -1px;",
  1546. mausoleum_of_halicarnassus: "url(http://gpde.innogamescdn.com/images/game/map/wonder_mausoleum_of_halicarnassus.png) 37px -4px;",
  1547. statue_of_zeus_at_olympia: "url(http://gpde.innogamescdn.com/images/game/map/wonder_statue_of_zeus_at_olympia.png) 36px -3px;",
  1548. temple_of_artemis_at_ephesus: "url(http://gpde.innogamescdn.com/images/game/map/wonder_temple_of_artemis_at_ephesus.png) 34px -5px;"
  1549. };
  1550.  
  1551. function setWonderIconsOnMap(){
  1552. try {
  1553. if(!$('#wondericons_map').get(0)){
  1554. var color = "orange";
  1555.  
  1556. // style for world wonder icons
  1557. var style_str = "<style id='wondericons_map' type='text/css'>";
  1558. for(var ww_type in wonder.map){
  1559. if(wonder.map.hasOwnProperty(ww_type)){
  1560. for(var ww in wonder.map[ww_type]){
  1561. if(wonder.map[ww_type].hasOwnProperty(ww)){
  1562. /*
  1563. if(wonder.map[ww_type][ww] !== AID){
  1564. color = "rgb(192, 109, 54)";
  1565. } else {
  1566. color = "orange";
  1567. }
  1568. */
  1569. style_str += "#mini_i" + ww + ":before {"+
  1570. "content: '';"+
  1571. "background:"+ color + " " + worldWonderIcon[ww_type] +
  1572. "background-size: auto 97%;"+
  1573. "padding: 8px 16px;"+
  1574. "top: 50px;"+
  1575. "position: relative;"+
  1576. "border-radius: 40px;"+
  1577. "z-index: 200;"+
  1578. "cursor: pointer;"+
  1579. "box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5);"+
  1580. "border: 2px solid green; } "+
  1581. "#mini_i" + ww + ":hover:before { z-index: 201; "+
  1582. "filter: url(#Brightness12);"+
  1583. "-webkit-filter: brightness(1.2);} ";
  1584. }
  1585. }
  1586. }
  1587. }
  1588. $(style_str + "</style>").appendTo('head');
  1589.  
  1590. // Context menu on mouseclick
  1591. $('#minimap_islands_layer').on('click', '.m_island', function(e){
  1592. var ww_coords = this.id.split("i")[3].split("_");
  1593. uw.Layout.contextMenu(e, 'wonder', {ix: ww_coords[0], iy: ww_coords[1]});
  1594. });
  1595.  
  1596.  
  1597. }
  1598. } catch(error) {
  1599. errorHandling(error, "setWonderIconsOnMap");
  1600. }
  1601. }
  1602.  
  1603. function setTownIconsOnMap(){
  1604. try {
  1605. // if town icon changed
  1606. if($('#townicons_map').get(0)){ $('#townicons_map').remove(); }
  1607.  
  1608. // style for own towns (town icons)
  1609. var start = (new Date()).getTime(), end, style_str = "<style id='townicons_map' type='text/css'>";
  1610. for(var e in autoTownTypes){
  1611. if(autoTownTypes.hasOwnProperty(e)){
  1612. style_str += "#mini_t"+ e +" { height: 19px;"+
  1613. "width:19px;"+
  1614. "border-radius: 11px;"+
  1615. "border: 2px solid rgb(16, 133, 0);"+
  1616. "margin: -4px;"+
  1617. //"background: rgb(255, 187, 0) url(http://s7.directupload.net/images/140404/xt839us6.png) repeat;"+
  1618. "background: rgb(255, 187, 0) url("+ dio_sprite +") "+ (townTypeIcon[(manuTownTypes[e] || autoTownTypes[e])]*-25) +"px -27px repeat;"+
  1619. "z-index: 100;"+
  1620. "font-size: 0em;"+
  1621. "cursor: pointer;"+
  1622. "box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5);} "+
  1623. "#mini_t"+ e +":hover { z-index: 101; "+
  1624. "filter: url(#Brightness12);" +
  1625. "-webkit-filter: brightness(1.2);} ";
  1626. }
  1627. }
  1628.  
  1629. // Context menu on mouseclick
  1630. $('#minimap_islands_layer').on('click', '.m_town', function(z){
  1631. var id = parseInt($(this).get(0).id.substring(6), 10);
  1632. uw.Layout.contextMenu(z, 'determine', {"id": id, "name": uw.ITowns.getTown(id).name });
  1633.  
  1634. z.stopPropagation(); // prevent parent world wonder event
  1635. });
  1636.  
  1637. // Style for foreign cities (shadow)
  1638. style_str += ".m_town { text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.7); } ";
  1639.  
  1640. style_str += "</style>";
  1641. $(style_str).appendTo('head');
  1642. /*
  1643. setTimeout(function(){
  1644. uw.MapTiles.createTownDiv_old = uw.MapTiles.createTownDiv;
  1645.  
  1646. uw.MapTiles.createTownDiv = function(town, player_current_town) {
  1647. var ret = uw.MapTiles.createTownDiv_old(town, player_current_town);
  1648.  
  1649. if(!isNaN(town.id) && town.player_id == PID) {
  1650.  
  1651. //setIconMap(town.id);
  1652. console.log(town.id);
  1653. console.log(player_current_town);
  1654. }
  1655. return ret;
  1656. };
  1657. },2000);
  1658. */
  1659. } catch(error) {
  1660. errorHandling(error, "setTownIconsOnMap");
  1661. }
  1662. }
  1663.  
  1664. // Style for town icons
  1665. var style_str = '<style id="townicons" type="text/css">';
  1666. for(var s in townTypeIcon){
  1667. if(townTypeIcon.hasOwnProperty(s)){
  1668. style_str += '.townicon_'+ s +' { background:url('+ dio_sprite +') '+ (townTypeIcon[s]*-25) +'px -26px repeat;float:left;} ';
  1669. }
  1670. }
  1671. style_str += '</style>';
  1672. $(style_str).appendTo('head');
  1673.  
  1674.  
  1675. // City overview
  1676. function setCityWindowContext(){
  1677. // $.each($("#goToTown").data("events"), function(i, e) { //console.log(i); });
  1678. if(uw.Layout.wnd.TYPE_TOWNINDEX){
  1679. $('#goToTown').unbind("mousedown");
  1680. $('#goToTown').on("mousedown", function(){
  1681. uw.GPWindowMgr.Create(uw.Layout.wnd.TYPE_TOWNINDEX, uw.DM.getl10n('town_index').window_title +" - "+ uw.ITowns.getTown(uw.Game.townId).name);
  1682. if($('#select_town').get(0)) {$('#select_town').mousedown(); }
  1683. var town = setInterval(function(){
  1684. if($('#town_background').get(0)){
  1685. document.getSelection().removeAllRanges();
  1686. clearInterval(town);
  1687. }
  1688. }, 50);
  1689. });
  1690. }
  1691. }
  1692. function setCityWindowButton(){
  1693. $("#ui_box .bull_eye_buttons .city_overview").appendTo('#ui_box .bull_eye_buttons');
  1694. $("#ui_box .bull_eye_buttons .city_overview").css({
  1695. left: '18px',
  1696. top: '3px'
  1697. });
  1698. if(uw.Layout.wnd.TYPE_TOWNINDEX){
  1699. $('.bull_eye_buttons .city_overview').on("click", function(){
  1700. uw.GPWindowMgr.Create(uw.Layout.wnd.TYPE_TOWNINDEX, uw.DM.getl10n('town_index').window_title +" - "+ uw.ITowns.getTown(uw.Game.townId).name);
  1701. });
  1702. }
  1703. }
  1704.  
  1705. function changeContextMenu(){
  1706. // Set context menu event handler
  1707. $.Observer(uw.GameEvents.map.context_menu.click).subscribe('DIO_CONTEXT', function(e,data){
  1708. if(DATA.options.con && $('#context_menu').children().length == 4){
  1709. // Clear animation
  1710. $('#context_menu div#goToTown').css({
  1711. left: '0px',
  1712. top: '0px',
  1713. WebkitAnimation: 'none', //'A 0s linear',
  1714. animation: 'none' //'B 0s linear'
  1715. });
  1716. }
  1717. // Set 'goToTown' button
  1718. if(DATA.options.tov && $('#goToTown').get(0)){
  1719. setCityWindowContext();
  1720. }
  1721. // Replace german label of 'select town' button
  1722. if(LID === "de" && $('#select_town').get(0)){
  1723. $("#select_town .caption").get(0).innerHTML = "Selektieren";
  1724. }
  1725. });
  1726.  
  1727. // Set context menu animation
  1728. if(!$('#select_town').get(0) && !$('#espionage').get(0)){
  1729. var ani_duration = 0;
  1730. // set fixed position of 'select town' button
  1731. $('<style type="text/css"> #select_town { left: 0px !important; top: 0px !important; z-index: 6} </style>').appendTo('head'); //-webkit-filter: hue-rotate(65deg);filter: url(#Hue1);
  1732.  
  1733. // set animation of 'goToTown' button
  1734. $('<style id="dio_context" type="text/css"> #context_menu div#goToTown { left: 30px; top: -51px; '+
  1735. '-webkit-animation: A 0.115s linear; animation: B 0.2s;} '+
  1736. '@-webkit-keyframes A { from {left: 0px; top: 0px;} to {left: 30px; top: -51px;} }'+
  1737. '@keyframes B { from {left: 0px; top: 0px;} to {left: 30px; top: -51px;} }'+
  1738. '</style>').appendTo('head');
  1739. }
  1740. }
  1741.  
  1742. function imageSelectionProtection(){
  1743. $('<style type="text/css"> img { -moz-user-select: -moz-none; -khtml-user-select: none; -webkit-user-select: none;} </style>').appendTo('head');
  1744. }
  1745.  
  1746. function setTownList(){
  1747. // TODO: rewrite in one style tag
  1748.  
  1749. // Town list
  1750. $('<style type="text/css"> #town_groups_list .item { text-align: left; padding-left:35px;} </style>').appendTo('head');
  1751. //$('<style type="text/css"> #town_groups_list .inner_column { width: 172px !important; float:left; margin-bottom:20px; position:relative !important; left:0px !important; top:0px !important} </style>').appendTo('head');
  1752. $('<style type="text/css"> #town_groups_list .inner_column { border: 1px solid rgba(100, 100, 0, 0.3);margin: -2px 0px 0px 2px;} </style>').appendTo('head');
  1753. $('<style type="text/css"> .town_groups_list .island_quest_icon { background-size: 90%; position: absolute; right: 37px; top: 4px;} </style>').appendTo('head');
  1754.  
  1755. // Quacks Zentrier-Button verschieben
  1756. $('<style type="text/css"> #town_groups_list .jump_town { right: 37px !important;} </style>').appendTo('head');
  1757.  
  1758. // Population percentage
  1759. $('<style type="text/css"> #town_groups_list .pop_percent { position: absolute; right: 7px; font-size: 0.7em;} '+
  1760. '#town_groups_list .full { color: green; }'+
  1761. '#town_groups_list .threequarter { color: darkgoldenrod; }'+
  1762. '#town_groups_list .half { color: darkred; }'+
  1763. '#town_groups_list .quarter { color: red; }'+
  1764. '</style>').appendTo('head');
  1765.  
  1766. // Town Icons
  1767. $('<style type="text/css"> .icon_small { height:20px;padding-left:25px;margin-left:-25px; background-clip:padding-box;} </style>').appendTo('head');
  1768.  
  1769.  
  1770. // Open town list: hook to grepolis function render()
  1771. if(DATA.options.twn){
  1772. var i = 0;
  1773. while(uw.layout_main_controller.sub_controllers[i].name != 'town_name_area'){ i++; }
  1774.  
  1775. 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;
  1776.  
  1777. uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render = function() {
  1778. uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render_old();
  1779. changeTownList();
  1780. };
  1781. }
  1782. }
  1783.  
  1784. function changeTownList(){
  1785. $("#town_groups_list .town_group_town").each(function() {
  1786. try {
  1787. var town_id = $(this).attr('name'), str = $(this).get(0).innerHTML, townicon_str, percent_str = "", percent = -1,
  1788. space = "full";
  1789.  
  1790. if(population[town_id]){
  1791. percent = population[town_id].percent;
  1792. }
  1793.  
  1794. if(percent < 75){ space = "threequarter"; }
  1795. if(percent < 50){ space = "half"; }
  1796. if(percent < 25){ space = "quarter"; }
  1797.  
  1798. if (!(str.indexOf("townicon") >= 0)){
  1799. townicon_str= '<div class="icon_small townicon_'+ (manuTownTypes[town_id] || autoTownTypes[town_id] || "no") +'"></div>';
  1800. // TODO: Notlösung...
  1801. if(percent != -1){
  1802. percent_str = '<div class="pop_percent '+ space +'">' + percent + '%</div>';
  1803. }
  1804.  
  1805. $(this).get(0).innerHTML = townicon_str + percent_str + str;
  1806. }
  1807.  
  1808. // opening context menu
  1809. /*
  1810. $(this).click(function(e){
  1811. console.log(e);
  1812. uw.Layout.contextMenu(e, 'determine', {"id": town_id,"name": uw.ITowns[town_id].getName()});
  1813. });
  1814. */
  1815.  
  1816. } catch(error){
  1817. errorHandling(error, "changeTownList");
  1818. }
  1819. });
  1820.  
  1821. $("#town_groups_list .town_group_town").hover(function(){
  1822. $(this).find('.island_quest_icon').css({
  1823. display: "none"
  1824. });
  1825. }, function(){
  1826. $(this).find('.island_quest_icon').css({
  1827. display: "block"
  1828. });
  1829. });
  1830.  
  1831. // Add change town list event handler
  1832. $.Observer(uw.GameEvents.town.town_switch).unsubscribe('DIO_SWITCH_TOWN');
  1833. $.Observer(uw.GameEvents.town.town_switch).subscribe('DIO_SWITCH_TOWN', function () {
  1834. changeTownList();
  1835. });
  1836. }
  1837.  
  1838. function addTownIcon(){
  1839. try {
  1840. // Quickbar modification
  1841. $('.ui_quickbar .left, .ui_quickbar .right').css({ width: '46%' });
  1842.  
  1843. $('<div id="town_icon"><div class="town_icon_bg"><div class="icon_big townicon_'+
  1844. (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no") + " auto")) + '"></div></div></div>').appendTo('.town_name_area');
  1845.  
  1846.  
  1847. $('.town_name_area').css({ zIndex: 11, left: '52%' }); // because of Kapsonfires Script and Beta Worlds bug report bar
  1848. $('.town_name_area .left').css({
  1849. zIndex: 20,
  1850. left: '-39px'
  1851. });
  1852.  
  1853. // Town Icon Style
  1854. $('#town_icon .icon_big').css({
  1855. backgroundPosition: townTypeIcon[(manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")))]*-25 + 'px 0px'
  1856. });
  1857.  
  1858. $('<style type="text/css">'+
  1859. '#town_icon { background:url('+ dio_sprite +') 0 -125px no-repeat; position:absolute; width:69px; height:61px; left:-47px; top:0px; z-index: 10; } '+
  1860. '#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; } '+
  1861. '#town_icon .town_icon_bg:hover { filter:url(#Brightness11); -webkit-filter:brightness(1.1); box-shadow: 0px 0px 15px rgb(1, 197, 33); } '+
  1862. '#town_icon .icon_big { position:absolute; left:9px; top:9px; height:25px; width:25px; } '+
  1863. '</style>').appendTo('head');
  1864.  
  1865.  
  1866. var icoArray = ['ld', 'lo', 'sh', 'di', 'un',
  1867. 'sd', 'so', 'ko', 'ti', 'gr',
  1868. 'fd', 'fo', 'dp', 'no', 'po',
  1869. 're', 'wd', 'st', 'si', 'bu',
  1870. 'he', 'ch', 'bo', 'fa', 'wo'];
  1871.  
  1872. // Fill select box with town icons
  1873. $('<div class="select_town_icon dropdown-list default active"><div class="item-list"></div></div>').appendTo("#town_icon");
  1874. for(var i in icoArray){
  1875. if(icoArray.hasOwnProperty(i)){
  1876. $('.select_town_icon .item-list').append('<div class="option_s icon_small townicon_'+ icoArray[i] +'" name="'+ icoArray[i] +'"></div>');
  1877. }
  1878. }
  1879. $('<hr><div class="option_s auto_s" name="auto"><b>Auto</b></div>').appendTo('.select_town_icon .item-list');
  1880.  
  1881. // Styles
  1882. $('#town_icon .select_town_icon').css({
  1883. position: 'absolute',
  1884. top: '47px',
  1885. left: '23px',
  1886. width: '145px',
  1887. display: "none",
  1888. padding: '2px',
  1889. border: '3px inset rgb(7, 99, 12)',
  1890. boxShadow: 'rgba(0, 0, 0, 0.5) 4px 4px 6px',
  1891. borderRadius: '0px 10px 10px 10px',
  1892. background: "url(https://gpde.innogamescdn.com/images/game/popup/middle_middle.png)"
  1893. });
  1894. $('#town_icon .item-list').css({ maxHeight: '400px', maxWidth: '200px', align: "right", overflowX: 'hidden' });
  1895.  
  1896. $('<style type="text/css">'+
  1897. '#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;} '+
  1898. '#town_icon .option_s:hover { border: 2px solid rgb(59, 121, 81) !important;-webkit-filter: brightness(1.3); } '+
  1899. '#town_icon .sel { border: 2px solid rgb(202, 176, 109); } '+
  1900. '#town_icon hr { width:145px; margin:0px 0px 7px 0px; position:relative; top:3px; border:0px; border-top:2px dotted #000; float:left} '+
  1901. '#town_icon .auto_s { width:136px; height:16px; float:left} '+
  1902. '</style>').appendTo('head');
  1903.  
  1904. $('#town_icon .option_s').click(function(){
  1905. $("#town_icon .sel").removeClass("sel"); $(this).addClass("sel");
  1906.  
  1907. if($(this).attr("name") === "auto"){
  1908. delete manuTownTypes[uw.Game.townId];
  1909. } else {
  1910. manuTownTypes[uw.Game.townId] = $(this).attr("name");
  1911. }
  1912. changeTownIcon();
  1913. saveValue(WID + "_townTypes", JSON.stringify(manuTownTypes));
  1914. });
  1915.  
  1916. // Show & hide drop menus on click
  1917. $('#town_icon .town_icon_bg').click(function(){
  1918. var el = $('#town_icon .select_town_icon').get(0);
  1919. if( el.style.display === "none"){
  1920. el.style.display = "block";
  1921. } else {
  1922. el.style.display = "none";
  1923. }
  1924. });
  1925.  
  1926. $('#town_icon .select_town_icon [name="'+ (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" :"" )) +'"]').addClass("sel");
  1927.  
  1928. } catch(error){
  1929. errorHandling(error, "addTownIcon");
  1930. }
  1931. }
  1932.  
  1933. function changeTownIcon(){
  1934. var townType = (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")));
  1935. $('#town_icon .icon_big').removeClass().addClass('icon_big townicon_'+ townType + " auto");
  1936. $('#town_icon .sel').removeClass("sel");
  1937. $('#town_icon .select_town_icon [name="'+ (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" :"" )) +'"]').addClass("sel");
  1938.  
  1939. $('#town_icon .icon_big').css({
  1940. backgroundPosition: townTypeIcon[townType]*-25 + 'px 0px'
  1941. });
  1942.  
  1943. $('#town_icon .select_town_icon').get(0).style.display = "none";
  1944.  
  1945. // update town icons on the map
  1946. setTownIconsOnMap();
  1947. }
  1948.  
  1949. /*******************************************************************************************************************************
  1950. * Available units
  1951. * ----------------------------------------------------------------------------------------------------------------------------
  1952. * | ● Shows all available units
  1953. * ----------------------------------------------------------------------------------------------------------------------------
  1954. *******************************************************************************************************************************/
  1955. function addAvailableUnitsButton(){
  1956. var default_title = DM.getl10n("place", "support_overview").options.troop_count + " ("+ DM.getl10n("hercules2014", "available")+")";
  1957.  
  1958. $('<div class="btn_available_units circle_button"><div class="ico_available_units js-caption"></div></div>').appendTo(".bull_eye_buttons");
  1959. $('.btn_available_units').css({
  1960. top: '86px',
  1961. left: '119px',
  1962. zIndex: '10',
  1963. position: 'absolute'
  1964. });
  1965. $('.btn_available_units .ico_available_units').css({
  1966. margin: '5px 0px 0px 4px', width: '24px', height: '24px',
  1967. background: 'url(http://s1.directupload.net/images/140323/w4ekrw8b.png) no-repeat 0px 0px', //http://gpde.innogamescdn.com/images/game/res/unit.png
  1968. backgroundSize: "100%",
  1969. filter: 'url(#Hue1)',
  1970. WebkitFilter: 'hue-rotate(100deg)'
  1971.  
  1972. });
  1973. $('.btn_available_units').on('mousedown', function(){
  1974. $('.ico_available_units').get(0).style.marginTop = "6px";
  1975. });
  1976. $('.btn_available_units').toggle(function(){
  1977. $('#available_units_box').get(0).style.display = "block";
  1978. $('#available_units_box').get(0).style.zIndex = getMaxZIndex() + 1;
  1979. $('.btn_available_units').addClass("checked");
  1980. $('.ico_available_units').get(0).style.marginTop = "6px";
  1981. }, function(){
  1982. $('#available_units_box').get(0).style.display = "none";
  1983. $('.btn_available_units').removeClass("checked");
  1984. $('.ico_available_units').get(0).style.marginTop = "5px";
  1985. });
  1986. $('.btn_available_units').tooltip(LANG.hasOwnProperty(LID) ? getText("labels", "uni") : default_title);
  1987. }
  1988.  
  1989. /*******************************************************************************************************************************
  1990. * Comparison
  1991. * ----------------------------------------------------------------------------------------------------------------------------
  1992. * | ● Compares the units of each unit type
  1993. * ----------------------------------------------------------------------------------------------------------------------------
  1994. *******************************************************************************************************************************/
  1995. function addComparisonButton(){
  1996. $('<div class="btn_comparison circle_button"><div class="ico_comparison js-caption"></div></div>').appendTo(".bull_eye_buttons");
  1997. $('.btn_comparison').css({
  1998. top: '51px',
  1999. left: '120px',
  2000. zIndex: '10',
  2001. position: 'absolute'
  2002. });
  2003. $('.btn_comparison .ico_comparison').css({
  2004. margin: '5px 0px 0px 4px', width: '24px', height: '24px',
  2005. background: 'url(http://666kb.com/i/cjq6cxia4ms8mn95r.png) no-repeat 0px 0px',
  2006. backgroundSize: "100%",
  2007. filter: 'url(#Hue1)',
  2008. WebkitFilter: 'hue-rotate(60deg)'
  2009. });
  2010. $('.btn_comparison').on('mousedown', function(){
  2011. $('.ico_comparison').get(0).style.marginTop = "6px";
  2012. });
  2013. $('.btn_comparison').toggle(function(){
  2014. $('#unit_box').get(0).style.display = "block";
  2015. $('#unit_box').get(0).style.zIndex = getMaxZIndex() + 1;
  2016. $('.btn_comparison').addClass("checked");
  2017. $('.ico_comparison').get(0).style.marginTop = "6px";
  2018. }, function(){
  2019. $('#unit_box').get(0).style.display = "none";
  2020. $('.btn_comparison').removeClass("checked");
  2021. $('.ico_comparison').get(0).style.marginTop = "5px";
  2022. });
  2023. $('.btn_comparison').tooltip(getText("labels", "dsc"));
  2024. }
  2025.  
  2026. function addComparisonBox(){
  2027. var pos = {
  2028. att: { hack: "36%", pierce: "27%", distance: "45.5%", ship: "72.5%" },
  2029. def: { hack: "18%", pierce: "18%", distance: "18%", ship: "81.5%" }
  2030. };
  2031.  
  2032. var unitIMG = "https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png";
  2033. $('<div id="unit_box" class="ui-dialog">'+
  2034. '<div class="bbcode_box middle_center"><div class="bbcode_box middle_right"></div><div class="bbcode_box middle_left"></div>'+
  2035. '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div><div class="bbcode_box top_center"></div>'+
  2036. '<div class="bbcode_box bottom_center"></div><div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>'+
  2037. '<div style="height:20px; margin-left:35px;">'+
  2038. '<a class="hack" href="#" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att.hack +';">'+
  2039. '<span style="margin-left:20px">'+ getText("labels", "hck") +'</span></a>'+
  2040. '<a class="pierce" href="#" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att.pierce +';">'+
  2041. '<span style="margin-left:20px">'+ getText("labels", "prc") +'</span></a>'+
  2042. '<a class="distance" href="#" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att.distance +';">'+
  2043. '<span style="margin-left:20px">'+ getText("labels", "dst") +'</span></a>'+
  2044. '<a class="ship" href="#" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att.ship +';">'+
  2045. '<span style="margin-left:20px">'+ getText("labels", "sea") +'</span></a>'+
  2046. '</div><hr>'+
  2047. '<div class="box_content"></div></div>').appendTo('body');
  2048.  
  2049. $('#unit_box a').css({
  2050. float: 'left',
  2051. backgroundRepeat: 'no-repeat',
  2052. backgroundSize: '25px',
  2053. lineHeight: '2',
  2054. marginRight:'10px'
  2055. });
  2056. $('#unit_box span').css({
  2057. marginLeft: '27px',
  2058. });
  2059. $('#unit_box').draggable({
  2060. containment: "body",
  2061. snap: "body",
  2062. });
  2063. $('#unit_box').css({
  2064. position: 'absolute',
  2065. top: '100px',
  2066. left: '200px',
  2067. zIndex: getMaxZIndex() + 1,
  2068. display: 'none'
  2069. });
  2070. $('#unit_box .box_content').css({
  2071. background: 'url(http://s1.directupload.net/images/140206/8jd9d3ec.png) 94% 94% no-repeat',
  2072. backgroundSize: '140px'
  2073. });
  2074.  
  2075. $('#unit_box').bind("mousedown",function(){
  2076. $(this).get(0).style.zIndex = getMaxZIndex() + 1;
  2077. });
  2078.  
  2079. addComparisonTable("hack");
  2080. addComparisonTable("pierce");
  2081. addComparisonTable("distance");
  2082. addComparisonTable("ship");
  2083.  
  2084. $('#unit_box .t_hack').get(0).style.display = "block";
  2085.  
  2086. // Tooltips
  2087. /*
  2088. var labelArray = DM.getl10n("common", "barracks_and_docs"),
  2089. labelAttack = DM.getl10n("context_menu", "titles").attack,
  2090. labelDefense = DM.getl10n("place", "tabs")[0];
  2091.  
  2092. $('.tr_att').tooltip(labelAttack);
  2093. $('.tr_def').tooltip(labelDefense + " (Ø)");
  2094. $('.tr_def_ship').tooltip(labelDefense);
  2095. $('.tr_spd').tooltip(labelArray.tooltips.speed);
  2096. $('.tr_bty').tooltip(labelArray.tooltips.booty.title);
  2097. $('.tr_bty_ship').tooltip(labelArray.tooltips.ship_transport.title);
  2098. $('.tr_res').tooltip(labelArray.costs + " (" +
  2099. labelArray.cost_details.wood + " + " +
  2100. labelArray.cost_details.stone + " + " +
  2101. labelArray.cost_details.iron + ")"
  2102. );
  2103. $('.tr_fav').tooltip(labelArray.costs + " (" + labelArray.cost_details.favor + ")");
  2104. $('.tr_tim').tooltip(labelArray.cost_details.buildtime_barracks + " (s)");
  2105. $('.tr_tim_ship').tooltip(labelArray.cost_details.buildtime_docks + " (s)");
  2106. */
  2107. switchComparisonTables();
  2108.  
  2109. $('#unit_box hr').css({ border: '1px solid', color: '#804000', float:'none' });
  2110. }
  2111.  
  2112. function switchComparisonTables(){
  2113. $('#unit_box .hack, #unit_box .pierce, #unit_box .distance, #unit_box .ship').click(function(){
  2114. $('#unit_box [class^="t_"]').css({ display : "none" });
  2115. $('#unit_box .t_'+this.className).get(0).style.display = "block";
  2116. });
  2117. }
  2118.  
  2119. var ttpArray = [], t = 0;
  2120. function addComparisonTable(type){
  2121. var pos = {
  2122. att: { hack: "36%", pierce: "27%", distance: "45.5%", ship: "72.5%" },
  2123. def: { hack: "18%", pierce: "18%", distance: "18%", ship: "81.5%" }
  2124. };
  2125. var unitIMG = "https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png";
  2126. var strArray = [
  2127. "<td></td>",
  2128. '<td><div class="bla" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att[type] +';"></div></td>',
  2129. '<td><div class="bla" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.def[type] +';"></div></td>',
  2130. '<td><div class="bla" style="background: url('+ unitIMG +'); background-position: 0% 63%;"></div></td>',
  2131. (type !== "ship") ? '<td><div class="booty"></div></td>' : '<td><div class="bla" style="background-image: url('+ unitIMG +'); background-position: 0% 91%;"></div></td>',
  2132. '<td><div class="bla" style="background: url('+ unitIMG +'); background-position: 0% 54%;"></div></td>',
  2133. '<td><div class="bla" style="background: url(https://gpall.innogamescdn.com/images/game/res/favor.png)"></div></td>',
  2134. '<td><div class="bla" style="background: url(https://gpall.innogamescdn.com/images/game/res/time.png);"></div></td>'
  2135. ];
  2136.  
  2137. for(var e in uw.GameData.units){
  2138. if(uw.GameData.units.hasOwnProperty(e)){
  2139. var valArray = [];
  2140.  
  2141. if(type === (uw.GameData.units[e].attack_type || "ship") && (e !== "militia")) {
  2142. valArray.att = Math.round(uw.GameData.units[e].attack*10 / uw.GameData.units[e].population) / 10;
  2143. 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;
  2144. valArray.def = valArray.def || Math.round(uw.GameData.units[e].defense*10/uw.GameData.units[e].population) / 10;
  2145. valArray.speed = uw.GameData.units[e].speed;
  2146. valArray.booty = Math.round(((uw.GameData.units[e].booty)*10) / uw.GameData.units[e].population) / 10;
  2147. 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;
  2148. valArray.favor = Math.round((uw.GameData.units[e].favor *10)/ uw.GameData.units[e].population) / 10;
  2149. 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));
  2150. valArray.time = Math.round(uw.GameData.units[e].build_time / uw.GameData.units[e].population);
  2151.  
  2152. valArray.heroStyle = ""; valArray.heroStyleIMG = "";
  2153.  
  2154. // World without Artemis? -> grey griffin and boar
  2155. if(!uw.Game.hasArtemis && ((e === "griffin") || (e === "calydonian_boar"))){
  2156. valArray.heroStyle = "color:black;opacity: 0.4;";
  2157. valArray.heroStyleIMG = "filter: url(#GrayScale); -webkit-filter:grayscale(100%); ";
  2158. }
  2159.  
  2160. strArray[0] += '<td class="un'+ (t) +'"><div class="unit index_unit unit_icon40x40 ' + e + '" style="'+ valArray.heroStyle + valArray.heroStyleIMG +'"></div></td>';
  2161. strArray[1] += '<td class="bold" style="color:'+ ((valArray.att>19)?'green;':((valArray.att<10 && valArray.att!=0 )?'red;':'black;')) + valArray.heroStyle +';">'+ valArray.att +'</td>';
  2162. strArray[2] += '<td class="bold" style="color:'+ ((valArray.def>19)?'green;':((valArray.def<10 && valArray.def!=0 )?'red;':'black;')) + valArray.heroStyle +';">'+ valArray.def +'</td>';
  2163. strArray[3] += '<td class="bold" style="'+ valArray.heroStyle +'">'+ valArray.speed +'</td>';
  2164. strArray[4] += '<td class="bold" style="'+ valArray.heroStyle +'">'+ valArray.booty +'</td>';
  2165. strArray[5] += '<td class="bold" style="'+ valArray.heroStyle +'">'+ valArray.res +'</td>';
  2166. strArray[6] += '<td class="bold" style="color:'+ ((valArray.favor>0)?'rgb(0, 0, 214);':'black;') + valArray.heroStyle +';">'+ valArray.favor +'</td>';
  2167. strArray[7] += '<td class="bold" style="'+ valArray.heroStyle +'">'+ valArray.time +'</td>';
  2168.  
  2169. ttpArray[t] = uw.GameData.units[e].name; t++;
  2170. }
  2171. }
  2172. }
  2173.  
  2174. $('<table class="t_'+ type +'" cellpadding="1px" style="display:none">'+
  2175. '<tr>'+ strArray[0] +'</tr>'+
  2176. '<tr class="tr_att">'+ strArray[1] +'</tr><tr class="tr_def'+ (type == "ship" ? "_ship" : "") +'">'+ strArray[2] +'</tr>'+
  2177. '<tr class="tr_spd">'+ strArray[3] +'</tr><tr class="tr_bty'+ (type == "ship" ? "_ship" : "") +'">'+ strArray[4] +'</tr>'+
  2178. '<tr class="tr_res">'+ strArray[5] +'</tr><tr class="tr_fav">'+ strArray[6] +'</tr><tr class="tr_tim'+ (type == "ship" ? "_ship" : "") +'">'+ strArray[7] +'</tr>'+
  2179. '</table>').appendTo('#unit_box .box_content');
  2180.  
  2181. for(var i = 0; i <= t; i++){
  2182. $('.un'+i).tooltip(ttpArray[i]);
  2183. }
  2184.  
  2185.  
  2186. //$('#unit_box .box_content').css({ position: 'relative' });
  2187. $('#unit_box .bla').css({
  2188. height: '25px',
  2189. width: '25px',
  2190. backgroundSize: '100%',
  2191. float: 'left'
  2192. });
  2193. $('#unit_box .booty').css({
  2194. width: '26px',
  2195. height: '25px',
  2196. background: 'url(http://s14.directupload.net/images/140404/ki4gwd7x.png)',
  2197. backgroundSize: '95%'
  2198. });
  2199. }
  2200.  
  2201. /*******************************************************************************************************************************
  2202. * Reports and Messages
  2203. * ----------------------------------------------------------------------------------------------------------------------------
  2204. * | ● Storage of the selected filter (only in German Grepolis yet)
  2205. * ----------------------------------------------------------------------------------------------------------------------------
  2206. *******************************************************************************************************************************/
  2207.  
  2208. var filter = "all";
  2209. function saveFilter(){
  2210. $('#dd_filter_type_list .item-list div').each(function(){
  2211. $(this).click(function(){
  2212. filter = $(this).attr("name");
  2213. });
  2214. });
  2215. /*
  2216. var i = 0;
  2217. $("#report_list a").each(function () {
  2218. //console.log((i++) +" = " + $(this).attr('data-reportid'));
  2219. });
  2220. */
  2221. }
  2222.  
  2223. function loadFilter(){
  2224. if(!($('#dd_filter_type_list .selected').attr("name") === filter)){
  2225. $('#dd_filter_type .caption').click();
  2226. $('#dd_filter_type_list .item-list div[name='+ filter +']').click();
  2227. }
  2228. }
  2229.  
  2230. function removeReports(){
  2231. $("#report_list li:contains('spioniert')").each(function () {
  2232. //$(this).remove();
  2233. });
  2234. }
  2235.  
  2236. var zut = 0;
  2237. var messageArray = {};
  2238. function filterPlayer(){
  2239. if(!$('#message_filter_list').get(0)) {
  2240. $('<div id="message_filter_list" style="height:300px;overflow-y:scroll; width: 790px;"></div>').appendTo('#folder_container');
  2241. $("#message_list").get(0).style.display = "none";
  2242. }
  2243. if(zut < parseInt($('.es_last_page').get(0).value, 10)-1){
  2244. $('.es_page_input').get(0).value = zut++;
  2245. $('.jump_button').click();
  2246. $("#message_list li:contains('')").each(function () {
  2247. $(this).appendTo('#message_filter_list');
  2248. });
  2249. } else {
  2250. zut = 1;
  2251. }
  2252. }
  2253.  
  2254.  
  2255. /*******************************************************************************************************************************
  2256. * World Wonder Ranking - Change
  2257. *******************************************************************************************************************************/
  2258.  
  2259. function getWorldWonderTypes(){
  2260. $.ajax({
  2261. type: "GET",
  2262. url:
  2263. "/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 +
  2264. "%7D&_="+ uw.Game.server_time,
  2265. success: function(text) {
  2266. try {
  2267. //console.log(JSON.parse(text));
  2268. temp = JSON.parse(text).json.data.world_wonders;
  2269. for(var t in temp){
  2270. if(temp.hasOwnProperty(t)){
  2271. wonderTypes[temp[t].wonder_type] = temp[t].full_name;
  2272. }
  2273. }
  2274. temp = JSON.parse(text).json.data.buildable_wonders;
  2275. for(var x in temp){
  2276. if(temp.hasOwnProperty(x)){
  2277. wonderTypes[x] = temp[x].name;
  2278. }
  2279. }
  2280. saveValue(MID + "_wonderTypes", JSON.stringify(wonderTypes));
  2281. } catch(error){
  2282. errorHandling(error, "getWorldWonderTypes");
  2283. }
  2284. }
  2285. });
  2286. }
  2287.  
  2288. function getWorldWonders(){
  2289. $.ajax({
  2290. type: "GET",
  2291. 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 +
  2292. "%7D&_="+ uw.Game.server_time
  2293. });
  2294. }
  2295.  
  2296.  
  2297. function changeWWRanking(html){
  2298. if($('#ranking_inner tr', html)[0].children.length !== 1){ // world wonders existing?
  2299. try {
  2300. var ranking = {}, temp_ally, temp_ally_id, temp_ally_link;
  2301.  
  2302. // Save world wonder ranking into array
  2303. $('#ranking_inner tr', html).each(function(){
  2304. try {
  2305. if(this.children[0].innerHTML){
  2306. temp_ally = this.children[1].children[0].innerHTML; // das hier
  2307.  
  2308. temp_ally_id = this.children[1].children[0].onclick.toString();
  2309. temp_ally_id = temp_ally_id.substring(temp_ally_id.indexOf(",") + 1);
  2310. temp_ally_id = temp_ally_id.substring(0, temp_ally_id.indexOf(")"));
  2311.  
  2312. temp_ally_link = this.children[1].innerHTML;
  2313.  
  2314. } else {
  2315. //World wonder name
  2316. var wonder_name = this.children[3].children[0].innerHTML;
  2317.  
  2318. for(var w in wonderTypes){
  2319. if(wonderTypes.hasOwnProperty(w)){
  2320. if(wonder_name == wonderTypes[w]){
  2321. var level = this.children[4].innerHTML, // world wonder level
  2322. ww_data = JSON.parse(atob(this.children[3].children[0].href.split("#")[1])), wonder_link;
  2323. //console.log(ww_data);
  2324.  
  2325. if(!ranking.hasOwnProperty(level)) {
  2326. // add wonder types
  2327. ranking[level] = {
  2328. colossus_of_rhodes : {},
  2329. great_pyramid_of_giza : {},
  2330. hanging_gardens_of_babylon : {},
  2331. lighthouse_of_alexandria : {},
  2332. mausoleum_of_halicarnassus : {},
  2333. statue_of_zeus_at_olympia : {},
  2334. temple_of_artemis_at_ephesus : {}
  2335. };
  2336. }
  2337.  
  2338. if(!ranking[level][w].hasOwnProperty(temp_ally_id)) {
  2339. ranking[level][w][temp_ally_id] = {}; // add alliance array
  2340. }
  2341. // island coordinates of the world wonder:
  2342. ranking[level][w][temp_ally_id].ix = ww_data.ix;
  2343. ranking[level][w][temp_ally_id].iy = ww_data.iy;
  2344. ranking[level][w][temp_ally_id].sea = this.children[5].innerHTML; // world wonder sea
  2345.  
  2346. wonder_link = this.children[3].innerHTML;
  2347. if(temp_ally.length > 15){
  2348. temp_ally = temp_ally.substring(0,15) + '.';
  2349. }
  2350. wonder_link = wonder_link.substr(0, wonder_link.indexOf(">")+1) + temp_ally +'</a>';
  2351.  
  2352. ranking[level][w][temp_ally_id].ww_link = wonder_link;
  2353.  
  2354. // other data of the world wonder
  2355. ranking[level][w][temp_ally_id].ally_link = temp_ally_link;
  2356. ranking[level][w][temp_ally_id].ally_name = temp_ally; // alliance name
  2357. ranking[level][w][temp_ally_id].name = wonder_name; // world wonder name
  2358.  
  2359. // Save wonder coordinates for wonder icons on map
  2360. if(!wonder.map[w]){
  2361. wonder.map[w] = {};
  2362. }
  2363. wonder.map[w][ww_data.ix + "_" + ww_data.iy] = level;
  2364. saveValue(WID + "_wonder", JSON.stringify(wonder));
  2365.  
  2366. }
  2367. }
  2368. }
  2369. }
  2370. } catch(error){
  2371. errorHandling(error, "changeWWRankingEachFunction");
  2372. }
  2373. });
  2374. //console.log(wonder.map);
  2375. //console.log(ranking);
  2376. if($('#ranking_table_wrapper').get(0)){
  2377. $('#ranking_fixed_table_header').get(0).innerHTML = '<tr>'+
  2378. '<td style="width:10px">#</td>'+
  2379. '<td>Colossus</td>'+
  2380. '<td>Pyramid</td>'+
  2381. '<td>Garden</td>'+
  2382. '<td>Lighthouse</td>'+
  2383. '<td>Mausoleum</td>'+
  2384. '<td>Statue</td>'+
  2385. '<td>Temple</td>'+
  2386. '</tr>';
  2387.  
  2388. $('#ranking_fixed_table_header').css({
  2389. tableLayout: 'fixed',
  2390. width: '100%',
  2391. //paddingLeft: '0px',
  2392. paddingRight: '15px'
  2393. });
  2394.  
  2395. var ranking_substr = '', z = 0;
  2396. for(var level = 10; level >= 1; level--){
  2397. if(ranking.hasOwnProperty(level)){
  2398. var complete = "";
  2399. if(level == 10) { complete = "background: rgba(255, 236, 108, 0.36);"; }
  2400.  
  2401. // Alternate table background color
  2402. if(z == 0){
  2403. ranking_substr += '<tr class="game_table_odd" style="'+ complete +'"><td style="border-right: 1px solid #d0be97;">'+ level +'</td>'; z = 1;
  2404. } else {
  2405. ranking_substr += '<tr class="game_table_even" style="'+ complete +'"><td style="border-right: 1px solid #d0be97;">'+ level +'</td>'; z = 0;
  2406. }
  2407. for(var w in ranking[level]){
  2408. if(ranking[level].hasOwnProperty(w)){
  2409. ranking_substr += '<td>';
  2410.  
  2411. for(var a in ranking[level][w]){
  2412. if(ranking[level][w].hasOwnProperty(a)){
  2413. ranking_substr += '<nobr>' + ranking[level][w][a].ww_link + '</nobr><br />'; // ww link
  2414. }
  2415. }
  2416. ranking_substr += '</td>';
  2417. }
  2418. }
  2419. ranking_substr += '</tr>';
  2420. }
  2421. }
  2422.  
  2423. var ranking_str = '<table id="ranking_endless_scroll" class="game_table" cellspacing="0"><tr>'+
  2424. '<td style="width:10px;border-right: 1px solid #d0be97;"></td>'+
  2425. '<td><div class="dio_wonder" style="background:'+ worldWonderIcon.colossus_of_rhodes +';margin-left:26px"></div></td>'+ // Colossus
  2426. '<td><div class="dio_wonder" style="background:'+ worldWonderIcon.great_pyramid_of_giza +';margin-left:19px"></div></td>'+ // Pyramid
  2427. '<td><div class="dio_wonder" style="background:'+ worldWonderIcon.hanging_gardens_of_babylon +';margin-left:19px"></div></td>'+ // Garden
  2428. '<td><div class="dio_wonder" style="background:'+ worldWonderIcon.lighthouse_of_alexandria +';margin-left:24px"></div></td>'+ // Lighthouse
  2429. '<td><div class="dio_wonder" style="background:'+ worldWonderIcon.mausoleum_of_halicarnassus +';margin-left:25px"></div></td>'+ // Mausoleum
  2430. '<td><div class="dio_wonder" style="background:'+ worldWonderIcon.statue_of_zeus_at_olympia +';margin-left:25px"></div></td>'+ // Statue
  2431. '<td><div class="dio_wonder" style="background:'+ worldWonderIcon.temple_of_artemis_at_ephesus +';margin-left:22px"></div></td>'+ // Temple
  2432. '</tr>'+ ranking_substr + '</table>';
  2433.  
  2434. $('#ranking_table_wrapper').get(0).innerHTML = ranking_str;
  2435.  
  2436. $('#ranking_endless_scroll .dio_wonder').css({
  2437. width: "65px", height: "60px",
  2438. backgroundSize: "auto 100%",
  2439. backgroundPosition: "64px 0px"
  2440. });
  2441.  
  2442. $('#ranking_endless_scroll').css({
  2443. tableLayout: 'fixed',
  2444. width: '100%',
  2445. overflowY: 'auto',
  2446. overflowX: 'hidden',
  2447. fontSize: '0.7em',
  2448. lineHeight: '2'
  2449. });
  2450. $('#ranking_endless_scroll tbody').css({
  2451. verticalAlign: 'text-top'
  2452. });
  2453.  
  2454. $('#ranking_table_wrapper img').css({
  2455. width: "60px"
  2456. });
  2457. $('#ranking_table_wrapper').css({
  2458. overflowY: 'scroll'
  2459. });
  2460. }
  2461. } catch(error){
  2462. errorHandling(error, "changeWWRanking");
  2463. }
  2464. }
  2465. if($('.wonder_ranking').get(0)) {
  2466. $('.wonder_ranking').get(0).style.display = "block";
  2467. }
  2468. }
  2469.  
  2470.  
  2471. /*******************************************************************************************************************************
  2472. * World Wonder
  2473. * ----------------------------------------------------------------------------------------------------------------------------
  2474. * | ● click adjustment
  2475. * | ● Share calculation (= ratio of player points to alliance points)
  2476. * | ● Resources calculation & counter (stores amount)
  2477. * | ● Adds missing previous & next buttons on finished world wonders (better browsing through world wonders)
  2478. * ----------------------------------------------------------------------------------------------------------------------------
  2479. *******************************************************************************************************************************/
  2480.  
  2481. // getPointRatio: Default
  2482. function getPointRatioFromAllianceProfile(){
  2483. if(AID){
  2484. $.ajax({
  2485. type: "GET",
  2486. 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 +
  2487. '%2C%22nlreq_id%22%3A'+ uw.Game.notification_last_requested_id + '%7D&_='+ uw.Game.server_time,
  2488. success: function(text) {
  2489. try {
  2490. text = text.substr(text.indexOf("/li")+14).substr(0, text.indexOf("\ "));
  2491. var AP = parseInt(text, 10);
  2492. wonder.ratio[AID] = 100 / AP * uw.Game.player_points;
  2493. saveValue(WID + "_wonder", JSON.stringify(wonder));
  2494. } catch(error){
  2495. errorHandling(error, "getPointRatioFromAllianceProfile");
  2496. }
  2497. }
  2498. });
  2499. } else {
  2500. wonder.ratio[AID] = -1;
  2501. saveValue(WID + "_wonder", JSON.stringify(wonder));
  2502. }
  2503. }
  2504.  
  2505. function getPointRatioFromAllianceRanking(){
  2506. try {
  2507. if(AID && $('.current_player .r_points').get(0)){
  2508. wonder.ratio[AID] = 100 / parseInt($('.current_player .r_points').get(0).innerHTML, 10) * uw.Game.player_points;
  2509. saveValue(WID + "_wonder", JSON.stringify(wonder));
  2510. }
  2511. } catch(error){
  2512. errorHandling(error, "getPointRatioFromAllianceRaking");
  2513. }
  2514. }
  2515.  
  2516. function getPointRatioFromAllianceMembers(){
  2517. try {
  2518. var ally_points = 0;
  2519. $('#ally_members_body tr').each(function(){
  2520. ally_points += parseInt($(this).children().eq(2).text(), 10) || 0;
  2521. });
  2522. wonder.ratio[AID] = 100 / ally_points * uw.Game.player_points;
  2523. saveValue(WID + "_wonder", JSON.stringify(wonder));
  2524. } catch(error){
  2525. errorHandling(error, "getPointRatioFromAllianceMembers");
  2526. }
  2527. }
  2528.  
  2529. // TODO: Split function...
  2530. function getResWW(){
  2531. try {
  2532. var wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_WONDERS);
  2533.  
  2534. for(var e in wndArray){
  2535. if(wndArray.hasOwnProperty(e)){
  2536. var wndID = "#gpwnd_" + wndArray[e].getID() + " ";
  2537.  
  2538. if($(wndID + '.wonder_progress').get(0)){
  2539. var res = 0,
  2540. ww_share = {total: {share:0, sum:0}, stage: {share:0, sum:0}},
  2541. ww_type = $(wndID + '.finished_image_small').attr('src').split("/")[6].split("_")[0], // Which world wonder?
  2542. res_stages = [ 2, 4, 6, 10, 16, 28, 48, 82, 140, 238], // Rohstoffmenge pro Rohstofftyp in 100.000 Einheiten
  2543. stage = parseInt($(wndID + '.wonder_expansion_stage span').get(0).innerHTML.split("/")[0], 10) + 1, // Derzeitige Füllstufe
  2544. speed = uw.Game.game_speed;
  2545.  
  2546. wonder.storage[AID] = wonder.storage[AID] || {};
  2547.  
  2548. wonder.storage[AID][ww_type] = wonder.storage[AID][ww_type] || {};
  2549.  
  2550. wonder.storage[AID][ww_type][stage] = wonder.storage[AID][ww_type][stage] || 0;
  2551.  
  2552. if(!$(wndID + '.ww_ratio').get(0)) {
  2553. $('<fieldset class="ww_ratio"></fieldset>').appendTo(wndID + '.wonder_res_container .trade');
  2554. $(wndID + '.wonder_header').prependTo(wndID + '.wonder_progress');
  2555. $(wndID + '.wonder_res_container .send_res').insertBefore(wndID + '.wonder_res_container .next_level_res');
  2556. }
  2557.  
  2558. $(wndID + '.wonder_progress').css({
  2559. margin: '0 auto 5px'
  2560. });
  2561. $(wndID + '.wonder_header').css({
  2562. textAlign: 'left',
  2563. margin: '10px -8px 12px 3px'
  2564. });
  2565. $(wndID + '.build_wonder_icon').css({
  2566. top: '25px',
  2567. });
  2568. $(wndID + '.wonder_progress_bar').css({
  2569. top: '54px',
  2570. });
  2571. $(wndID + '.wonder_controls').css({
  2572. height: '380px',
  2573. });
  2574.  
  2575. $(wndID + '.trade fieldset').css({
  2576. float: 'right',
  2577. });
  2578.  
  2579. $(wndID + '.wonder_res_container').css({
  2580. right: '29px'
  2581. });
  2582.  
  2583. $(wndID + '.ww_ratio').css({
  2584. position: 'relative',
  2585. height: 'auto'
  2586. });
  2587. $(wndID + 'fieldset').css({
  2588. height: 'auto'
  2589. });
  2590. $(wndID + '.town-capacity-indicator').css({
  2591. marginTop: '0px'
  2592. });
  2593.  
  2594. for(var d in res_stages){
  2595. if(res_stages.hasOwnProperty(d)){
  2596. ww_share.total.sum += res_stages[d];
  2597. }
  2598. }
  2599.  
  2600. ww_share.total.sum *= speed * 300000;
  2601.  
  2602. ww_share.total.share = parseInt(wonder.ratio[AID] * (ww_share.total.sum / 100), 10);
  2603.  
  2604. ww_share.stage.sum = speed * res_stages[stage-1] * 300000;
  2605.  
  2606. ww_share.stage.share = parseInt(wonder.ratio[AID] * (ww_share.stage.sum / 100), 10); // ( 3000 = 3 Rohstofftypen * 100000 Rohstoffe / 100 Prozent)
  2607. setResWW(stage, ww_type, ww_share, wndID);
  2608.  
  2609.  
  2610. $(wndID + '.wonder_res_container .send_resources_btn').click(function(e){
  2611. try {
  2612. wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_wood input:text').get(0).value, 10);
  2613. wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_stone input:text').get(0).value, 10);
  2614. wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_iron input:text').get(0).value, 10);
  2615.  
  2616. setResWW(stage, ww_type, ww_share, wndID);
  2617. saveValue(WID + "_wonder", JSON.stringify(wonder));
  2618. } catch(error){
  2619. errorHandling(error, "getResWW_Click");
  2620. }
  2621. });
  2622.  
  2623. } else {
  2624. $('<div class="prev_ww pos_Y"></div><div class="next_ww pos_Y"></div>').appendTo(wndID + '.wonder_controls');
  2625.  
  2626. $(wndID + '.wonder_finished').css({ width: '100%' });
  2627.  
  2628. $(wndID + '.pos_Y').css({
  2629. top: '-266px',
  2630. });
  2631.  
  2632. }
  2633. }
  2634. }
  2635. } catch(error){
  2636. errorHandling(error, "getResWW");
  2637. }
  2638. }
  2639.  
  2640. function setResWW(stage, ww_type, ww_share, wndID){
  2641. try {
  2642. var width_stage, width_total, res_total = 0, disp_stage = "none", disp_total = "none";
  2643.  
  2644. for(var z in wonder.storage[AID][ww_type]){
  2645. if(wonder.storage[AID][ww_type].hasOwnProperty(z)){
  2646. res_total += wonder.storage[AID][ww_type][z];
  2647. }
  2648. }
  2649.  
  2650. if(ww_share.stage.share > wonder.storage[AID][ww_type][stage]){
  2651. width_stage = (242 / ww_share.stage.share) * wonder.storage[AID][ww_type][stage];
  2652. } else {
  2653. width_stage = 0;
  2654. disp_stage = "block";
  2655. }
  2656. if(ww_share.total.share > res_total){
  2657. width_total = (242 / ww_share.total.share) * res_total;
  2658. } else {
  2659. width_total = 0;
  2660. disp_total = "block";
  2661. }
  2662.  
  2663. $(wndID + '.ww_ratio').get(0).innerHTML = "";
  2664. $(wndID + '.ww_ratio').append('<legend>'+ getText("labels", "leg") +' (<span style="color:#090">'+ (Math.round(wonder.ratio[AID] * 100) / 100) +'%</span>):</legend>'+
  2665. '<div class="town-capacity-indicator">'+
  2666. '<div class="icon all_res"></div>'+
  2667. '<div id="ww_town_capacity_stadium" class="tripple-progress-progressbar">'+
  2668. '<div class="border_l"></div><div class="border_r"></div><div class="body"></div>'+
  2669. '<div class="progress overloaded">'+
  2670. '<div class="indicator3" style="left: 0px; width:'+ width_stage +'px"></div>'+
  2671. '<span class="ww_perc">' + Math.round(wonder.storage[AID][ww_type][stage]/ww_share.stage.share*100) + '%</span>'+
  2672. '<div class="indicator4" style="left: 0px; display:'+ disp_stage +'"></div>'+
  2673. '</div>'+
  2674. '<div class="amounts">'+ getText("labels", "stg") +': <span class="curr">'+ pointNumber(wonder.storage[AID][ww_type][stage]) +'</span> / '+
  2675. '<span class="max">'+ pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) +'</span></div>'+
  2676. '</div></div>'+
  2677. '<div class="town-capacity-indicator">'+
  2678. '<div class="icon all_res"></div>'+
  2679. '<div id="ww_town_capacity_total" class="tripple-progress-progressbar">'+
  2680. '<div class="border_l"></div><div class="border_r"></div><div class="body"></div>'+
  2681. '<div class="progress overloaded">'+
  2682. '<div class="indicator3" style="left: 0px; width:'+ width_total +'px;"></div>'+
  2683. '<span class="ww_perc">'+ Math.round(res_total/ww_share.total.share*100) +'%</span>'+
  2684. '<div class="indicator4" style="left: 0px; display:'+ disp_total +'"></div>'+
  2685. '</div>'+
  2686. '<div class="amounts">'+ getText("labels", "tot") +': <span class="curr">'+ pointNumber(res_total) +'</span> / '+
  2687. '<span class="max">'+ pointNumber((Math.round(ww_share.total.share / 1000) * 1000)) +'</span></div>'+
  2688. '</div></div>');
  2689.  
  2690. $('.ww_ratio .progress').css({
  2691. lineHeight: '1',
  2692. color: 'white',
  2693. fontSize: '0.8em'
  2694. });
  2695.  
  2696. $(wndID + '.ww_perc').css({
  2697. position:'absolute',
  2698. width:'242px',
  2699. textAlign: 'center'
  2700. });
  2701.  
  2702. $(wndID + '.indicator4').css({
  2703. background: 'url(https://gpall.innogamescdn.com/images/game/layout/progressbars-sprite_2.70_compressed.png) no-repeat 0 0',
  2704. backgroundPosition: '0px -355px',
  2705. height: '10px',
  2706. zIndex: '13000',
  2707. width: '242px'
  2708. });
  2709. $(wndID + '.all_res').css({
  2710. background: 'url(https://gpall.innogamescdn.com/images/game/layout/resources.png) no-repeat 0 -90px',
  2711. width: '30px',
  2712. height: '30px',
  2713. margin: '0 auto',
  2714. marginLeft: '5px'
  2715. });
  2716. $(wndID + '.town-capacity-indicator').css({
  2717. marginTop: '0px'
  2718. });
  2719.  
  2720. $(wndID + '.ww_ratio').tooltip("<table style='border-spacing:0px; text-align:right' cellpadding='5px'><tr>"+
  2721. "<td align='right' style='border-right: 1px solid;border-bottom: 1px solid'></td>"+
  2722. "<td style='border-right: 1px solid; border-bottom: 1px solid'><span class='bbcodes_player bold'>("+ (Math.round((wonder.ratio[AID]) * 100) / 100) +"%)</span></td>"+
  2723. "<td style='border-bottom: 1px solid'><span class='bbcodes_ally bold'>(100%)</span></td></tr>"+
  2724. "<tr><td class='bold' style='border-right:1px solid;text-align:center'>"+ getText("labels", "stg") + "&nbsp;" + stage +"</td>"+
  2725. "<td style='border-right: 1px solid'>"+ pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) +"</td>"+
  2726. "<td>" + pointNumber(Math.round(ww_share.stage.sum / 1000) * 1000) + "</td></tr>"+
  2727. "<tr><td class='bold' style='border-right:1px solid;text-align:center'>"+ getText("labels", "tot") +"</td>"+
  2728. "<td style='border-right: 1px solid'>"+ pointNumber(Math.round(ww_share.total.share / 1000) * 1000) +"</td>"+
  2729. "<td>"+ pointNumber(Math.round(ww_share.total.sum / 1000) * 1000) +"</td>"+
  2730. "</tr></table>");
  2731. } catch(error){
  2732. errorHandling(error, "setResWW");
  2733. }
  2734. }
  2735.  
  2736. // Adds points to numbers
  2737. function pointNumber(number) {
  2738. var sep; if(LID === "de"){ sep = "."; } else { sep = ",";}
  2739.  
  2740. number = number.toString();
  2741. if (number.length > 3) {
  2742. var mod = number.length % 3;
  2743. var output = (mod > 0 ? (number.substring(0,mod)) : '');
  2744.  
  2745. for (var i=0 ; i < Math.floor(number.length / 3); i++) {
  2746. if ((mod == 0) && (i == 0)) {
  2747. output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
  2748. } else {
  2749. output+= sep + number.substring(mod + 3 * i, mod + 3 * i + 3);
  2750. }
  2751. }
  2752. number = output;
  2753. }
  2754. return number;
  2755. }
  2756.  
  2757. /*******************************************************************************************************************************
  2758. * Farming Village Overview
  2759. * ----------------------------------------------------------------------------------------------------------------------------
  2760. * | ● Color change on possibility of city festivals
  2761. * ----------------------------------------------------------------------------------------------------------------------------
  2762. * *****************************************************************************************************************************/
  2763.  
  2764. function changeResColor(){
  2765. var res, res_min, i = 0;
  2766. $('#fto_town_list .fto_resource_count :last-child').reverseList().each(function(){
  2767. if($(this).parent().hasClass("stone")){
  2768. res_min = 18000;
  2769. } else {
  2770. res_min = 15000;
  2771. }
  2772. res = parseInt($(this).get(0).innerHTML, 10);
  2773. if((res >= res_min) && !($(this).hasClass("town_storage_full"))){
  2774. $(this).get(0).style.color = '#0A0';
  2775. }
  2776. if(res < res_min){
  2777. $(this).get(0).style.color = '#000';
  2778. }
  2779. });
  2780. }
  2781.  
  2782. /********************************************************************************************************************************
  2783. * Conquest Info
  2784. * -----------------------------------------------------------------------------------------------------------------------------
  2785. * | ● Amount of supports und attacks in the conquest window
  2786. * | ● Layout adjustment (for reasons of clarity)
  2787. * | - TODO: conquest window of own cities
  2788. * -----------------------------------------------------------------------------------------------------------------------------
  2789. * ******************************************************************************************************************************/
  2790.  
  2791. function countMovements(){
  2792. var i = 0, a = 0;
  2793. $('#unit_movements .support').each(function(){
  2794. i++;
  2795. });
  2796. $('#unit_movements .attack_land, #unit_movements .attack_sea, #unit_movements .attack_takeover').each(function(){
  2797. a++;
  2798. });
  2799.  
  2800. var str = "<div style='position: absolute;width: 100px;margin-top: -16px;left: 40%;'><div style='float:left;margin-right:5px;'></div>"+
  2801. "<div class='troops' id='count_def'></div>"+
  2802. "<div class='troops' style='color:green;'> " + i + "</div>"+
  2803. "<div class='troops' id='count_off'> </div>"+
  2804. "<div style='color:red;'> " + a + "</div></div>"+
  2805. "<hr class='move_hr'>";
  2806.  
  2807. if($('.gpwindow_content .tab_content .bold').get(0)){
  2808. $('.gpwindow_content .tab_content .bold').append(str);
  2809. } else {
  2810. $('.gpwindow_content h4:eq(1)').append(str);
  2811.  
  2812. // TODO: set player link ?
  2813. /*
  2814. $('#unit_movements li div').each(function(){
  2815.  
  2816. //console.log($(this).get(0).innerHTML);
  2817. });
  2818. */
  2819. }
  2820. $('.move_hr').css({
  2821. margin: '7px 0px 0px 0px',
  2822. backgroundColor: '#5F5242',
  2823. height: '2px',
  2824. border: '0px solid'
  2825. });
  2826.  
  2827. // smaller movements
  2828. $('#unit_movements').css({
  2829. fontSize: '0.80em'
  2830. });
  2831. $('.incoming').css({
  2832. width: '150px',
  2833. height: '45px',
  2834. float: 'left'
  2835. });
  2836. $('#unit_movements div').each(function(){
  2837. if($(this).attr('class') === "unit_movements_arrow"){
  2838. // delete placeholder for arrow of outgoing movements (there are no outgoing movements)
  2839. if(!$(this).get(0).style.background) { $(this).get(0).remove(); }
  2840. } else {
  2841. // realign texts
  2842. $(this).css({
  2843. margin: '3px',
  2844. paddingLeft: '3px'
  2845. });
  2846. }
  2847. });
  2848.  
  2849. $('.troops').css({
  2850. float: 'left',
  2851. margin: '0px 5px 0px 0px',
  2852. height:'18px',
  2853. width:'18px',
  2854. position: 'relative'
  2855. });
  2856. $('#count_def').css({
  2857. background: 'url(https://gpall.innogamescdn.com/images/game/place/losts.png)',
  2858. backgroundPosition: '0 -36px'
  2859. });
  2860. $('#count_off').css({
  2861. background: 'url(https://gpall.innogamescdn.com/images/game/place/losts.png)',
  2862. backgroundPosition: '0 0px'
  2863. });
  2864. }
  2865.  
  2866. /*******************************************************************************************************************************
  2867. * Town window
  2868. * ----------------------------------------------------------------------------------------------------------------------------
  2869. * | ● TownTabHandler (trade, attack, support,...)
  2870. * | ● Sent units box
  2871. * | ● Short duration: Display of 30% troop speed improvement in attack/support tab
  2872. * | ● Trade options:
  2873. * | - Ressource marks on possibility of city festivals
  2874. * | - Percentual Trade: Trade button
  2875. * | - Recruiting Trade: Selection boxes (ressource ratio of unit type + share of the warehouse capacity of the target town)
  2876. * ----------------------------------------------------------------------------------------------------------------------------
  2877. *******************************************************************************************************************************/
  2878. var arrival_interval = {};
  2879. // TODO: Change both functions in MultipleWindowHandler()
  2880. function TownTabHandler(action){
  2881. var wndArray, wndID, wndA;
  2882. wndArray = Layout.wnd.getOpen(uw.Layout.wnd.TYPE_TOWN);
  2883. //console.log(wndArray);
  2884. for(var e in wndArray){
  2885. if(wndArray.hasOwnProperty(e)){
  2886. //console.log(wndArray[e].getHandler());
  2887. wndA = wndArray[e].getAction(); wndID = "#gpwnd_" + wndArray[e].getID() + " ";
  2888. if(!$(wndID).get(0)) {
  2889. wndID = "#gpwnd_" + (wndArray[e].getID() + 1) + " ";
  2890.  
  2891. }
  2892. //console.log(wndID);
  2893. if(wndA === action){
  2894. switch(action){
  2895. case "trading":
  2896. if($(wndID + '#trade_tab').get(0)){
  2897. if(!$(wndID + '.rec_trade').get(0)){
  2898. addRecTrade(wndID);
  2899. }
  2900. if(!($(wndID + '.btn_trade').get(0))){
  2901. addPercentTrade(wndID, false);
  2902. }
  2903. }
  2904. //addTradeMarks(wndID, 15, 18, 15, "red"); // town festival
  2905. break;
  2906. case "support": case "attack":
  2907. //if(!arrival_interval[wndID]){
  2908. if(DATA.options.way && !($('.js-casted-powers-viewport .unit_movement_boost').get(0) || $(wndID + '.short_duration').get(0))){
  2909. //if(arrival_interval[wndID]) console.log("add " + wndID);
  2910. addShortDuration(wndID);
  2911. }
  2912. if(DATA.options.sen){
  2913. addSentUnitsBox(wndID, action);
  2914. }
  2915. //}
  2916. break;
  2917. case "rec_mark":
  2918. //addTradeMarks(wndID, 15, 18, 15, "lime");
  2919. break;
  2920. }
  2921. }
  2922. }
  2923. }
  2924. }
  2925.  
  2926. function WWTradeHandler(){
  2927. var wndArray, wndID, wndA;
  2928. wndArray = uw.GPWindowMgr.getOpen(uw.GPWindowMgr.TYPE_WONDERS);
  2929. for(var e in wndArray){
  2930. if(wndArray.hasOwnProperty(e)){
  2931. wndID = "#gpwnd_" + wndArray[e].getID() + " ";
  2932. if(!($(wndID + '.btn_trade').get(0) || $(wndID +'.next_building_phase').get(0) || $(wndID +'#ww_time_progressbar').get(0))){
  2933. addPercentTrade(wndID, true);
  2934. }
  2935. }
  2936. }
  2937. }
  2938.  
  2939. /*******************************************************************************************************************************
  2940. * ● Sent units box
  2941. *******************************************************************************************************************************/
  2942. function addSentUnitsBox(wndID, action){
  2943. if(!$(wndID + '.sent_units_box').get(0)){
  2944. $('<div class="game_inner_box sent_units_box '+ action +'"><div class="game_border ">'+
  2945. '<div class="game_border_top"></div><div class="game_border_bottom"></div><div class="game_border_left"></div><div class="game_border_right"></div>'+
  2946. '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div><div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>'+
  2947. '<div class="game_header bold">'+
  2948. '<div class="icon_sent townicon_'+ (action == "attack" ? "lo" : "ld") +'"></div><span>'+ getText("labels", "lab") +' ('+ (action == "attack" ? "OFF" : "DEF") +')</span>'+
  2949. '</div>'+
  2950. '<div class="troops"><div class="units_list"></div><hr style="width: 172px;border: 1px solid rgb(185, 142, 93);margin: 3px 0px 2px -1px;">'+
  2951. '<div id="btn_sent_units_reset" class="button_new">'+
  2952. '<div class="left"></div>'+
  2953. '<div class="right"></div>'+
  2954. '<div class="caption js-caption">'+ getText("buttons", "res") +'<div class="effect js-effect"></div></div>'+
  2955. '</div>'+
  2956. '</div></div>').appendTo(wndID + '.attack_support_window');
  2957.  
  2958. updateSentUnitsBox(action);
  2959.  
  2960. $(wndID + '.icon_sent').css({
  2961. height: '20px',
  2962. marginTop: '-2px',
  2963. width: '20px',
  2964. backgroundPositionY: '-26px',
  2965. paddingLeft: '0px',
  2966. marginLeft: '0px'
  2967. });
  2968.  
  2969. $(wndID + '.sent_units_box').css({
  2970. position: 'absolute',
  2971. right: '0px',
  2972. bottom: '16px',
  2973. width: '192px',
  2974. //border: '2px solid green',
  2975. //borderRadius: '5px',
  2976. //padding: '5px'
  2977. });
  2978. $(wndID + '.troops').css({ padding: '6px 0px 6px 6px' });
  2979.  
  2980. $(wndID + '#btn_sent_units_reset').click(function(){
  2981. // Overwrite old array
  2982. sentUnitsArray[action] = {}; updateSentUnitsBox(action);
  2983. });
  2984. }
  2985. }
  2986.  
  2987. function getSentUnits(){
  2988. $.Observer(uw.GameEvents.command.send_unit).subscribe('DIO_SEND_UNITS', function(e,data){
  2989. try {
  2990. for(var z in data.params){
  2991. if(data.params.hasOwnProperty(z) && (data.sending_type !== "")){
  2992. if(uw.GameData.units[z]){
  2993. sentUnitsArray[data.sending_type][z] = (sentUnitsArray[data.sending_type][z] == undefined ? 0 : sentUnitsArray[data.sending_type][z]);
  2994. sentUnitsArray[data.sending_type][z] += data.params[z];
  2995. }
  2996. }
  2997. }
  2998. //updateSentUnitsBox(data.sending_type);
  2999. } catch(error){
  3000. errorHandling(error, "getSentUnits");
  3001. }
  3002. });
  3003. }
  3004.  
  3005. function updateSentUnitsBox(action){
  3006. try {
  3007. // Remove old unit list
  3008. $('.sent_units_box.'+ action +' .units_list').each(function(){
  3009. $(this).get(0).innerHTML = "";
  3010. });
  3011.  
  3012. // Add new unit list
  3013. for(var x in sentUnitsArray[action]){
  3014. if(sentUnitsArray[action].hasOwnProperty(x)){
  3015. if((sentUnitsArray[action][x] || 0) > 0){
  3016. $('.sent_units_box.'+ action +' .units_list').each(function(){
  3017. $(this).append('<div class="unit_icon25x25 '+ x +
  3018. (sentUnitsArray[action][x] >= 1000 ? (sentUnitsArray[action][x] >= 10000 ? " five_digit_number" : " four_digit_number") : "") +'">'+
  3019. '<span class="count text_shadow">'+ sentUnitsArray[action][x] +'</span>'+
  3020. '</div>');
  3021. });
  3022. }
  3023. }
  3024. }
  3025. saveValue(WID +"_sentUnits", JSON.stringify(sentUnitsArray));
  3026. } catch(error){
  3027. errorHandling(error, "updateSentUnitsBox");
  3028. }
  3029. }
  3030.  
  3031. /*******************************************************************************************************************************
  3032. * ● Short duration
  3033. *******************************************************************************************************************************/
  3034.  
  3035. function addShortDuration(wndID){
  3036. //console.log($(wndID + ".duration_container").get(0));
  3037. try {
  3038. //var tooltip = (LANG.hasOwnProperty(LID) ? getText("labels", "improved_movement") : "") + " (+30% "+ DM.getl10n("common", "barracks_and_docs").tooltips.speed.trim() + ")";
  3039. var tooltip = (LANG.hasOwnProperty(LID) ? getText("labels", "improved_movement") : "") + " (+30%)";
  3040.  
  3041. $('<table class="dio_duration">'+
  3042. '<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>'+
  3043. '<tr class="short_duration_row" style="color:darkgreen">'+
  3044. '<td>&nbsp;╚&gt;&nbsp;</td><td><span class="short_duration">~0:00:00</span></td>'+
  3045. '<td>&nbsp;&nbsp;&nbsp;╚&gt;</td><td><span class="short_arrival">~00:00:00</span></td>'+
  3046. '<td class="short_icon"></td><td></td></tr>'+
  3047. '</table>').prependTo(wndID + ".duration_container");
  3048.  
  3049.  
  3050. $(wndID + ".nightbonus").appendTo(wndID + ".dio_night");
  3051. $(wndID + '.way_duration').appendTo(wndID + ".dio_way");
  3052. $(wndID + ".arrival_time").appendTo(wndID + ".dio_arrival");
  3053.  
  3054.  
  3055. // Style
  3056. $(wndID + '.duration_container').css({
  3057. width:'auto'
  3058. });
  3059. $(wndID + '.dio_duration').css({
  3060. borderSpacing: '0px',
  3061. marginBottom: '2px',
  3062. textAlign: 'right'
  3063. });
  3064. $(wndID + '.dio_way span,'+ wndID + '.dio_arrival span').css({
  3065. padding: '0px 0px 0px 0px',
  3066. background: 'none'
  3067. });
  3068. $(wndID + '.short_icon').css({
  3069. padding: '20px 0px 0px 30px',
  3070. background: 'url(http://666kb.com/i/ck2c7eohpyfa3yczt.png) 11px -1px / 21px no-repeat',
  3071. WebkitFilter: 'hue-rotate(50deg)'
  3072. });
  3073. $(wndID + '.way_icon').css({
  3074. padding: '30px 0px 0px 30px',
  3075. background: 'transparent url(https://gpall.innogamescdn.com/images/game/towninfo/traveltime.png) no-repeat 0 0'
  3076. });
  3077. $(wndID + '.arrival_icon').css({
  3078. padding: '30px 0px 0px 30px',
  3079. background: 'transparent url(https://gpall.innogamescdn.com/images/game/towninfo/arrival.png) no-repeat 0 0'
  3080. });
  3081. $(wndID + '.max_booty').css({
  3082. padding: '0px 0px 0px 30px',
  3083. margin: '3px 0 4px 4px',
  3084. width: 'auto'
  3085. });
  3086. $(wndID + '.fast_boats_needed').css({
  3087. background: 'transparent url(http://s7.directupload.net/images/140724/4pvfuch8.png) no-repeat 0 0',
  3088. padding: '2px 10px 7px 24px',
  3089. margin: '0px 0px 0px 6px'
  3090. });
  3091. $(wndID + '.slow_boats_needed').css({
  3092. background: 'transparent url(http://s1.directupload.net/images/140724/b5xl8nmj.png) no-repeat 0 0',
  3093. padding: '2px 10px 7px 24px',
  3094. margin: '0px 0px 0px 6px'
  3095. });
  3096.  
  3097. // Tooltip
  3098. $(wndID + '.short_duration_row').tooltip(tooltip);
  3099.  
  3100. // Detection of changes
  3101. changeShortDuration(wndID);
  3102. /*
  3103. $(wndID + '.way_duration').bind('DOMSubtreeModified', function(e) { console.log(e); }); // Alternative
  3104. */
  3105.  
  3106.  
  3107.  
  3108. } catch(error){
  3109. errorHandling(error, "addShortDuration");
  3110. }
  3111. }
  3112.  
  3113. function changeShortDuration(wndID){
  3114. var duration = new MutationObserver(function(mutations) {
  3115. mutations.forEach(function(mutation) {
  3116. if(mutation.addedNodes[0]){
  3117. //console.log(mutation);
  3118. calcShortDuration(wndID);
  3119. }
  3120. });
  3121. });
  3122. if($(wndID + '.way_duration').get(0)){
  3123. duration.observe($(wndID + '.way_duration').get(0), { attributes: false, childList: true, characterData: false});
  3124. }
  3125. }
  3126.  
  3127. //$('<style> .duration_container { display: block !important } </style>').appendTo("head");
  3128.  
  3129. function calcShortDuration(wndID){
  3130. //console.log(wndID);
  3131. //console.log($(wndID + '.duration_container .way_duration').get(0));
  3132. try {
  3133. var setup_time = 900/uw.Game.game_speed,
  3134. duration_time = $(wndID + '.duration_container .way_duration').get(0).innerHTML.replace("~","").split(":"),
  3135. // TODO: hier tritt manchmal Fehler auf TypeError: Cannot read property "innerHTML" of undefined at calcShortDuration (<anonymous>:3073:86)
  3136. arrival_time,
  3137. h,m,s,
  3138. atalanta_factor = 0;
  3139.  
  3140. // Atalanta aktiviert?
  3141. if($(wndID + '.unit_container.heroes_pickup .atalanta').get(0)){
  3142. if($(wndID + '.cbx_include_hero').hasClass("checked")) {
  3143. // Beschleunigung hängt vom Level ab, Level 1 = 11%, Level 20 = 30%
  3144. var atalanta_level = MM.getCollections().PlayerHero[0].models[1].attributes.level;
  3145.  
  3146. atalanta_factor = (atalanta_level + 10) / 100;
  3147. }
  3148. }
  3149.  
  3150. // Sekunden, Minuten und Stunden zusammenrechnen (-> in Sekunden)
  3151. duration_time = ((parseInt(duration_time[0], 10)*60 + parseInt(duration_time[1], 10))*60 + parseInt(duration_time[2], 10));
  3152.  
  3153. // Verkürzte Laufzeit berechnen
  3154. duration_time = ((duration_time - setup_time) * (1 + atalanta_factor)) / (1 + 0.3 + atalanta_factor) + setup_time;
  3155.  
  3156. h = Math.floor(duration_time/3600);
  3157. m = Math.floor((duration_time - h*3600)/60);
  3158. s = Math.floor(duration_time - h*3600 - m*60);
  3159.  
  3160. if(m < 10) { m = "0" + m; }
  3161. if(s < 10) { s = "0" + s; }
  3162.  
  3163. $(wndID + '.short_duration').get(0).innerHTML = "~"+ h +":" + m + ":" + s;
  3164.  
  3165. arrival_time = Math.round((Timestamp.server() + Game.server_gmt_offset)) + duration_time;
  3166.  
  3167. h = Math.floor(arrival_time/3600);
  3168. m = Math.floor((arrival_time - h*3600)/60);
  3169. s = Math.floor(arrival_time - h*3600 - m*60);
  3170.  
  3171. h %= 24;
  3172.  
  3173. if(m < 10) { m = "0" + m; }
  3174. if(s < 10) { s = "0" + s; }
  3175.  
  3176. $(wndID + '.short_arrival').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
  3177.  
  3178. clearInterval(arrival_interval[wndID]);
  3179. arrival_interval[wndID] = setInterval(function(){
  3180. arrival_time += 1;
  3181.  
  3182. h = Math.floor(arrival_time/3600);
  3183. m = Math.floor((arrival_time - h*3600)/60);
  3184. s = Math.floor(arrival_time - h*3600 - m*60);
  3185.  
  3186. h %= 24;
  3187.  
  3188. if(m < 10) { m = "0" + m; }
  3189. if(s < 10) { s = "0" + s; }
  3190.  
  3191. if($(wndID + '.short_arrival').get(0)){
  3192. $(wndID + '.short_arrival').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
  3193. } else {
  3194. clearInterval(arrival_interval[wndID]);
  3195. }
  3196. }, 1000);
  3197.  
  3198. } catch(error){
  3199. errorHandling(error, "calcShortDuration");
  3200. }
  3201. }
  3202.  
  3203. /*******************************************************************************************************************************
  3204. * ● Dropdown menu
  3205. *******************************************************************************************************************************/
  3206.  
  3207. // Preload images for drop down arrow buttons
  3208. var drop_over = new Image(); drop_over.src = "http://s7.directupload.net/images/140107/hna95u8a.png";
  3209. var drop_out = new Image(); drop_out.src = "http://s14.directupload.net/images/140107/ppsz5mxk.png";
  3210.  
  3211. function changeDropDownButton(){
  3212. /*
  3213. $('<style type="text/css">' +
  3214. '#dd_filter_type .arrow, .select_rec_unit .arrow {' +
  3215. 'width: 18px !important; height: 17px !important; background: url("http://s14.directupload.net/images/140107/ppsz5mxk.png") no-repeat 0px -1px !important;' +
  3216. 'position: absolute; top: 2px !important; right: 3px;' +
  3217. '</style>').appendTo('head');
  3218. */
  3219.  
  3220.  
  3221. $('.arrow').css({
  3222. width: '18px',
  3223. height: '17px',
  3224. background: 'url('+ drop_out.src +') no-repeat -1px -1px',
  3225. position: 'absolute',
  3226. top: '2px',
  3227. right: '3px'
  3228. });
  3229. }
  3230.  
  3231. var o = 1; // ????????????????????????????
  3232.  
  3233. /*******************************************************************************************************************************
  3234. * ● Recruiting Trade
  3235. * *****************************************************************************************************************************/
  3236. var trade_count = 0, unit = "FS", percent = "0.0"; // Recruiting Trade
  3237.  
  3238. function addRecTrade(wndID){
  3239. var max_amount;
  3240.  
  3241. $('<div class="rec_trade">'+
  3242. // DropDown-Button for unit
  3243. '<div class="drop_rec_unit dropdown default">'+
  3244. '<div class="border-left"></div>'+
  3245. '<div class="border-right"></div>'+
  3246. '<div class="caption" name="'+ unit +'">'+ unit +'</div>'+
  3247. '<div class="arrow"></div>'+
  3248. '</div>'+
  3249. '<div class="drop_rec_perc dropdown default">'+
  3250. // DropDown-Button for ratio
  3251. '<div class="border-left"></div>'+
  3252. '<div class="border-right"></div>'+
  3253. '<div class="caption" name="'+ percent +'">'+ Math.round(percent * 100)+'%</div>'+
  3254. '<div class="arrow"></div>'+
  3255. '</div></div><span class="rec_count" style="top:30px">('+ trade_count +')</span>').appendTo(wndID + ".content");
  3256.  
  3257. // Select boxes for unit and ratio
  3258. $('<div class="select_rec_unit dropdown-list default active">'+
  3259. '<div class="item-list">'+
  3260. '<div class="option_s unit index_unit unit_icon40x40 attack_ship" name="FS"></div>'+
  3261. '<div class="option_s unit index_unit unit_icon40x40 bireme" name="BI"></div>'+
  3262. '<div class="option_s unit index_unit unit_icon40x40 sword" name="SK"></div>'+
  3263. '<div class="option_s unit index_unit unit_icon40x40 slinger" name="SL"></div>'+
  3264. '<div class="option_s unit index_unit unit_icon40x40 archer" name="BS"></div>'+
  3265. '<div class="option_s unit index_unit unit_icon40x40 hoplite" name="HO"></div>'+
  3266. '<div class="option_s unit index_unit unit_icon40x40 rider" name="RE"></div>'+
  3267. '<div class="option_s unit index_unit unit_icon40x40 chariot" name="SW"></div>'+
  3268. '</div></div>').appendTo(wndID + ".rec_trade");
  3269. $('<div class="select_rec_perc dropdown-list default inactive">'+
  3270. '<div class="item-list">'+
  3271. '<div class="option sel" name="0.0">&nbsp;&nbsp;0%</div>'+
  3272. '<div class="option" name="0.05">&nbsp;&nbsp;5%</div>'+
  3273. '<div class="option" name="0.1">10%</div>'+
  3274. '<div class="option" name="0.16666">17%</div>'+
  3275. '<div class="option" name="0.2">20%</div>'+
  3276. '<div class="option" name="0.25">25%</div>'+
  3277. '<div class="option" name="0.33">33%</div>'+
  3278. '<div class="option" name="0.5">50%</div>'+
  3279. '</div></div>').appendTo(wndID + ".rec_trade");
  3280.  
  3281. $(wndID + ".rec_trade [name='"+ unit +"']").toggleClass("sel");
  3282.  
  3283. // Styles
  3284. $(wndID + '.rec_trade').css({ position: 'absolute', left: '30px', top: '70px' });
  3285. $(wndID + '.select_rec_unit').css({
  3286. position: 'absolute',
  3287. top: '20px',
  3288. width: '84px',
  3289. display: "none"
  3290. });
  3291. $(wndID + '.select_rec_perc').css({
  3292. position: 'absolute',
  3293. left: '50px',
  3294. top: '20px',
  3295. width: '50px',
  3296. display: "none"
  3297. });
  3298. $(wndID + '.item-list').css({ maxHeight: '400px', maxWidth: '200px', align: "right" });
  3299.  
  3300. $(wndID + '.arrow').css({
  3301. width: '18px',
  3302. height: '18px',
  3303. background: 'url('+ drop_out.src +') no-repeat -1px -1px',
  3304. position: 'absolute',
  3305. });
  3306.  
  3307. $(wndID + '.option_s').css({
  3308. filter: "url(#GrayScale)",
  3309. WebkitFilter: "grayscale(100%)",
  3310. cursor: 'pointer',
  3311. color: 'black',
  3312. lineHeight: '14px',
  3313. float: 'left',
  3314.  
  3315. position: 'relative',
  3316. width: '40px',
  3317. margin: '0px',
  3318. padding: '0px'
  3319. });
  3320.  
  3321. $('.select_rec_unit .sel').css({"filter": "url(#Sepia)", "-webkit-filter" : "sepia(100%)"});
  3322.  
  3323. // hover effects of the elements in the drop menus
  3324. $(wndID + '.option_s').hover(
  3325. function(){
  3326. //console.log(this.className);
  3327. $(this).css({ "filter": "none", "-webkit-filter" : "grayscale(0%) sepia(0%)"});
  3328. if(!($(this).hasClass("sel"))){
  3329. $('.option_s .sel').css({"filter": "url(#Sepia)", "-webkit-filter" : "grayscale(0%) sepia(100%)" });
  3330. }
  3331. },
  3332. function(){
  3333. $('.select_rec_unit .option_s').css({ "filter": "url(#GrayScale)", "-webkit-filter" : "grayscale(100%) sepia(0%)" });
  3334. $('.select_rec_unit .sel').css({ "filter": "url(#Sepia)", "-webkit-filter" : "grayscale(0%) sepia(100%)" });
  3335. }
  3336. );
  3337. $(wndID + '.option').hover(
  3338. function(){ $(this).css({color: '#fff', background: "#328BF1"}); },
  3339. function(){ $(this).css({color: '#000', background: "#FFEEC7"}); }
  3340. );
  3341.  
  3342. // click events of the drop menu
  3343. $(wndID + ' .select_rec_unit .option_s').each(function(){
  3344. $(this).click(function(e){
  3345. $(".select_rec_unit .sel").toggleClass("sel");
  3346. $("." + this.className.split(" ")[4]).toggleClass("sel");
  3347.  
  3348. unit = $(this).attr("name");
  3349. $('.drop_rec_unit .caption').attr("name", unit);
  3350. $('.drop_rec_unit .caption').each(function(){
  3351. $(this).get(0).innerHTML = unit;
  3352. });
  3353. $(this).parent().parent().get(0).style.display = "none";
  3354. $('.drop_rec_unit .caption').change();
  3355. });
  3356. });
  3357. $(wndID + ' .select_rec_perc .option').each(function(){
  3358. $(this).click(function(e){
  3359. $(this).parent().find(".sel").toggleClass("sel");
  3360. $(this).toggleClass("sel");
  3361.  
  3362. percent = $(this).attr("name");
  3363. $('.drop_rec_perc .caption').attr("name", percent);
  3364. $('.drop_rec_perc .caption').each(function(){
  3365. $(this).get(0).innerHTML = Math.round(percent * 100)+"%";
  3366. });
  3367. $(this).parent().parent().get(0).style.display = "none";
  3368. $('.drop_rec_perc .caption').change();
  3369. });
  3370. });
  3371.  
  3372. // show & hide drop menus on click
  3373. $(wndID + '.drop_rec_perc').click(function(e){
  3374. if($(e.target)[0].parentNode.parentNode.childNodes[3].style.display === "none"){
  3375. $(e.target)[0].parentNode.parentNode.childNodes[3].style.display = "block";
  3376. $(e.target)[0].parentNode.parentNode.childNodes[2].style.display = "none";
  3377. } else {
  3378. $(e.target)[0].parentNode.parentNode.childNodes[3].style.display = "none";
  3379. }
  3380. });
  3381. $(wndID + '.drop_rec_unit').click(function(e){
  3382. if($(e.target)[0].parentNode.parentNode.childNodes[2].style.display === "none"){
  3383. $(e.target)[0].parentNode.parentNode.childNodes[2].style.display = "block";
  3384. $(e.target)[0].parentNode.parentNode.childNodes[3].style.display = "none";
  3385. } else {
  3386. $(e.target)[0].parentNode.parentNode.childNodes[2].style.display = "none";
  3387. }
  3388. });
  3389.  
  3390. $(wndID).click(function(e){
  3391. var clicked = $(e.target), element = $('#' + this.id + ' .select_rec_unit').get(0);
  3392. if(!(clicked[0].parentNode.className.split(" ")[1] === "dropdown") && element){
  3393. element.style.display = "none";
  3394. }
  3395. });
  3396.  
  3397. // hover arrow change
  3398. $(wndID + '.dropdown').hover(function(e){
  3399. $(e.target)[0].parentNode.childNodes[3].style.background = "url('"+ drop_over.src +"') no-repeat -1px -1px";
  3400. }, function(e){
  3401. $(e.target)[0].parentNode.childNodes[3].style.background = "url('"+ drop_out.src +"') no-repeat -1px -1px";
  3402. });
  3403.  
  3404. $(wndID + ".drop_rec_unit .caption").attr("name", unit);
  3405. $(wndID + ".drop_rec_perc .caption").attr("name",percent);
  3406.  
  3407. $(wndID + '.drop_rec_unit').tooltip(getText("labels", "rat"));
  3408. $(wndID + '.drop_rec_perc').tooltip(getText("labels", "shr"));
  3409.  
  3410. var ratio = {NO: {w:0, s: 0, i: 0 },
  3411. FS: {w:1, s: 0.2308, i: 0.6154 },
  3412. BI: {w:1, s: 0.8750, i: 0.2250 },
  3413. SL: {w:0.55, s: 1, i: 0.4 },
  3414. RE: {w:0.6666, s: 0.3333, i: 1 },
  3415. SK: {w:1, s: 0, i: 0.8947 },
  3416. HO: {w:0, s: 0.5, i: 1 },
  3417. BS: {w:1, s: 0, i: 0.6250 },
  3418. SW: {w:0.4545, s: 1, i: 0.7273 }
  3419. };
  3420.  
  3421.  
  3422. if($('#town_capacity_wood .max').get(0)){
  3423. max_amount = parseInt($('#town_capacity_wood .max').get(0).innerHTML, 10);
  3424. } else {
  3425. max_amount = 25500;
  3426. }
  3427.  
  3428. $(wndID + '.caption').change(function(e){
  3429. //console.log($(this).attr('name') + ", " + unit + "; " + percent);
  3430. if(!(($(this).attr('name') === unit) || ($(this).attr('name') === percent))){
  3431. //trade_count = 0;
  3432. $('.rec_count').get(0).innerHTML = "(" + trade_count + ")";
  3433. }
  3434.  
  3435. var tmp = $(this).attr('name');
  3436.  
  3437. if($(this).parent().attr('class').split(" ")[0] === "drop_rec_unit"){
  3438. unit = tmp;
  3439. } else {
  3440. percent = tmp;
  3441. }
  3442. var max = (max_amount - 100)/1000;
  3443. addTradeMarks(max * ratio[unit].w, max * ratio[unit].s, max * ratio[unit].i, "lime");
  3444.  
  3445. 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)
  3446. var rArray = uw.ITowns.getTown(uw.Game.townId).getCurrentResources();
  3447. var tradeCapacity = uw.ITowns.getTown(uw.Game.townId).getAvailableTradeCapacity();
  3448.  
  3449. var wood = ratio[unit].w * part;
  3450. var stone= ratio[unit].s * part;
  3451. var iron = ratio[unit].i * part;
  3452.  
  3453. if((wood > rArray.wood) || (stone > rArray.stone) || (iron > rArray.iron) || ( (wood + stone + iron) > tradeCapacity)) {
  3454. wood = stone = iron = 0;
  3455. $('.drop_rec_perc .caption').css({color:'#f00'});
  3456. //$('.' + e.target.parentNode.parentNode.className + ' .select_rec_perc .sel').css({color:'#f00'});
  3457. //$('.select_rec_perc .sel').css({color:'#f00'});
  3458. } else {
  3459. $('.' + e.target.parentNode.parentNode.className + ' .drop_rec_perc .caption').css({color:'#000'});
  3460. }
  3461. $("#trade_type_wood [type='text']").select().val(wood).blur();
  3462. $("#trade_type_stone [type='text']").select().val(stone).blur();
  3463. $("#trade_type_iron [type='text']").select().val(iron).blur();
  3464. });
  3465.  
  3466. $('#trade_button').click(function(){
  3467. trade_count++;
  3468. $('.rec_count').get(0).innerHTML = "(" + trade_count + ")";
  3469.  
  3470. });
  3471.  
  3472. $(wndID + '.rec_count').css({
  3473. position: 'absolute',
  3474. display: 'block',
  3475. left: '33px',
  3476. top: '95px',
  3477. width: '20px'
  3478. });
  3479. $(wndID + '.drop_rec_unit').css({
  3480. position: 'absolute',
  3481. display: 'block',
  3482. width: '50px',
  3483. overflow: 'visible'
  3484. });
  3485. $(wndID + '.drop_rec_perc').css({
  3486. position: 'absolute',
  3487. display: 'block',
  3488. left: '49px',
  3489. width: '55px',
  3490. color:'#000'
  3491. });
  3492. $(wndID + '.drop_rec_perc .caption').change();
  3493. }
  3494. /*******************************************************************************************************************************
  3495. * ● Ressources marks
  3496. *******************************************************************************************************************************/
  3497. function addTradeMarks(woodmark, stonemark, ironmark, color){
  3498. var max_amount, limit, wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_TOWN), wndID;
  3499. for(var e in wndArray){
  3500. if(wndArray.hasOwnProperty(e)){
  3501. wndID = "#gpwnd_" + wndArray[e].getID() + " ";
  3502. if($(wndID + '.town-capacity-indicator').get(0)){
  3503.  
  3504. max_amount = $(wndID + '.amounts .max').get(0).innerHTML;
  3505.  
  3506. $('#trade_tab .c_'+ color).each(function(){
  3507. $(this).get(0).remove();
  3508. });
  3509. $('#trade_tab .progress').each(function(){
  3510. if($("p", this).length < 3) {
  3511. if($(this).parent().get(0).id != "big_progressbar"){
  3512. limit = 1000 * (242 / parseInt(max_amount, 10));
  3513.  
  3514. switch($(this).parent().get(0).id.split("_")[2]){
  3515. case "wood": limit = limit * woodmark; break;
  3516. case "stone": limit = limit * stonemark; break;
  3517. case "iron": limit = limit * ironmark; break;
  3518. }
  3519. $('<p class="c_'+ color +'"style="position:absolute;left: '+ limit +'px; background:'+ color +';width:2px;height:100%;margin:0px"></p>').appendTo(this);
  3520. }
  3521. }
  3522. });
  3523. }
  3524. }
  3525. }
  3526. }
  3527.  
  3528. /*******************************************************************************************************************************
  3529. * ● Percentual Trade
  3530. *******************************************************************************************************************************/
  3531. var rest_count = 0;
  3532.  
  3533. function addPercentTrade(wndID, ww){
  3534.  
  3535. var a = ""; var content = wndID + ".content";
  3536. if(ww) {
  3537. a = "ww_";
  3538. content = wndID + '.trade .send_res';
  3539. }
  3540. $('<div class="btn btn_trade"><a class="button" href="#">'+
  3541. '<span class="left"><span class="right">'+
  3542. '<span class="middle mid">'+
  3543. '<span class="img_trade"></span></span></span></span>'+
  3544. '<span style="clear:both;"></span>'+
  3545. '</a></div>').prependTo(content);
  3546.  
  3547. $(wndID + '.btn_trade').tooltip(getText("labels", "per"));
  3548.  
  3549. setPercentTrade(wndID, ww);
  3550.  
  3551. // Style
  3552. $(wndID + '.btn').css({ width: '20px', overflow: 'visible', position: 'absolute', display: 'block' });
  3553.  
  3554. if(!ww){ $(wndID + '.content').css({ height: '320px' }); }
  3555.  
  3556. if(ww){
  3557. $(wndID + '.btn_trade').css({ left: '678px', top: '154px' });
  3558. } else {
  3559. $(wndID + '.btn_trade').css({ left: '336px', top: '135px' });
  3560. }
  3561.  
  3562. $(wndID + '.mid').css({ minWidth: '26px' });
  3563.  
  3564. $(wndID + '.img_trade').css({
  3565. width: '27px',
  3566. height: '27px',
  3567. top: '-3px',
  3568. float: 'left',
  3569. position: 'relative',
  3570. background: 'url("http://666kb.com/i/cjq6d72qk521ig1zz.png") no-repeat'
  3571. });
  3572.  
  3573. }
  3574.  
  3575. var res = {};
  3576. function setPercentTrade(wndID, ww){
  3577. var a = ww ? "ww_" : "", own_town = $(wndID + '.town_info').get(0) ? true : false;
  3578.  
  3579. $(wndID + '.btn_trade').toggle(
  3580. function(){
  3581. res.wood = {}; res.stone = {}; res.iron = {}; res.sum = {};
  3582.  
  3583. res.sum.amount = 0;
  3584. // Set amount of resources to 0
  3585. setAmount(true, a, wndID);
  3586. // Total amount of resources // TODO: ITowns.getTown(Game.townId).getCurrentResources(); ?
  3587. for(var e in res){
  3588. if(res.hasOwnProperty(e) && e != "sum") {
  3589. res[e].rest = false;
  3590. res[e].amount = parseInt($('.ui_resources_bar .'+ e +' .amount').get(0).innerHTML, 10);
  3591. res.sum.amount += res[e].amount;
  3592. }
  3593. }
  3594. // Percentage of total resources
  3595. res.wood.percent = 100/res.sum.amount * res.wood.amount;
  3596. res.stone.percent = 100/res.sum.amount * res.stone.amount;
  3597. res.iron.percent = 100/res.sum.amount * res.iron.amount;
  3598.  
  3599. // Total trading capacity
  3600. res.sum.cur = parseInt($(wndID + '#' + a + 'big_progressbar .caption .curr').get(0).innerHTML, 10);
  3601. //res.sum.max = parseInt($(wndID + '#' + a + 'big_progressbar .caption .max').get(0).innerHTML, 10) - res.sum.cur;
  3602.  
  3603. // Amount of resources on the percentage of trading capacity (%)
  3604. res.wood.part = parseInt(res.sum.cur/100 * res.wood.percent, 10);
  3605. res.stone.part = parseInt(res.sum.cur/100 * res.stone.percent, 10);
  3606. res.iron.part = parseInt(res.sum.cur/100 * res.iron.percent, 10);
  3607.  
  3608. // Get rest warehouse capacity of each resource type
  3609. for(var f in res){
  3610. if(res.hasOwnProperty(f) && f != "sum") {
  3611. if(!ww && own_town){ // Own town
  3612. var curr = parseInt($(wndID + '#town_capacity_'+ f +' .amounts .curr').get(0).innerHTML.replace('+', '').trim(), 10) || 0,
  3613. curr2 = parseInt($(wndID + '#town_capacity_'+ f +' .amounts .curr2').get(0).innerHTML.replace('+', '').trim(), 10) || 0,
  3614. max = parseInt($(wndID + '#town_capacity_'+ f +' .amounts .max').get(0).innerHTML.replace('+', '').trim(), 10) || 0;
  3615.  
  3616. res[f].cur = curr + curr2;
  3617. res[f].max = max - res[f].cur;
  3618.  
  3619. if(res[f].max < 0) { res[f].max = 0; }
  3620.  
  3621. } else { // World wonder or foreign town
  3622. res[f].max = 30000;
  3623. }
  3624. }
  3625. }
  3626. // Rest of fraction (0-2 units) add to stone amount
  3627. res.stone.part += res.sum.cur - (res.wood.part + res.stone.part + res.iron.part);
  3628.  
  3629. res.sum.rest = 0;
  3630. rest_count = 0;
  3631. calcRestAmount();
  3632. setAmount(false, a, wndID);
  3633. },
  3634. function(){
  3635. setAmount(true, a, wndID);
  3636. }
  3637. );
  3638. }
  3639.  
  3640. function calcRestAmount(){
  3641. // Subdivide rest
  3642. if(res.sum.rest > 0){
  3643. for(var e in res){
  3644. if(res.hasOwnProperty(e) && e != "sum" && res[e].rest != true) {
  3645. res[e].part += res.sum.rest/(3 - rest_count);
  3646. }
  3647. }
  3648. res.sum.rest = 0;
  3649. }
  3650. // Calculate new rest
  3651. for(var f in res){
  3652. if(res.hasOwnProperty(f) && f != "sum" && res[f].rest != true) {
  3653. if(res[f].max <= res[f].part) {
  3654. res[f].rest = true;
  3655. res.sum.rest += res[f].part - res[f].max;
  3656. rest_count += 1;
  3657. res[f].part = res[f].max;
  3658. }
  3659. }
  3660. }
  3661. // Recursion
  3662. if(res.sum.rest > 0 && rest_count < 3){
  3663. calcRestAmount();
  3664. }
  3665. }
  3666.  
  3667. function setAmount(clear, a, wndID){
  3668. for(var e in res){
  3669. if(res.hasOwnProperty(e) && e !== "sum") {
  3670. if(clear == true) { res[e].part = 0; }
  3671. $(wndID + "#" + a + "trade_type_" + e + ' [type="text"]').select().val(res[e].part).blur();
  3672. }
  3673. }
  3674. }
  3675.  
  3676. /* ******************************************************************************************************************************
  3677. * Unit strength (blunt/sharp/distance) and Transport Capacity
  3678. * ----------------------------------------------------------------------------------------------------------------------------
  3679. * | ● Unit strength: Unit menu
  3680. * | - Switching of def/off display with buttons
  3681. * | - Possible Selection of certain unit types
  3682. * | ● Unit strength: Siege
  3683. * | ● Unit strength: Barracks
  3684. * | ● Transport capacity: Unit menu
  3685. * | - Switching of transporter speed (+/- big transporter)
  3686. * ----------------------------------------------------------------------------------------------------------------------------
  3687. * ******************************************************************************************************************************/
  3688.  
  3689. var def = true, blunt = 0, sharp = 0, dist = 0, shipsize = false;
  3690.  
  3691. function getSelectedUnitsMenu(){
  3692. var units = [];
  3693. if($(".units_land .units_wrapper .selected").length > 0){
  3694. $(".units_land .units_wrapper .selected").each(function(){
  3695. units[$(this).get(0).className.split(" ")[1]] = $(this).get(0).children[0].innerHTML;
  3696. });
  3697. } else {
  3698. $(".units_land .units_wrapper .unit").each(function(){
  3699. units[$(this).get(0).className.split(" ")[1]] = $(this).get(0).children[0].innerHTML;
  3700. });
  3701. }
  3702. return units;
  3703. }
  3704.  
  3705. // Calculate defensive strength
  3706. function calcDef(units){
  3707. var e; blunt = sharp = dist = 0;
  3708. for(e in units) {
  3709. if(units.hasOwnProperty(e)) {
  3710. blunt += units[e] * uw.GameData.units[e].def_hack;
  3711. sharp += units[e] * uw.GameData.units[e].def_pierce;
  3712. dist += units[e] * uw.GameData.units[e].def_distance;
  3713. }
  3714. }
  3715. }
  3716. // Calculate offensive strength
  3717. function calcOff(units, selectedUnits){
  3718. var e; blunt = sharp = dist = 0;
  3719. for(e in selectedUnits) {
  3720. if(selectedUnits.hasOwnProperty(e)) {
  3721. var attack = (units[e] || 0) * uw.GameData.units[e].attack;
  3722. switch(uw.GameData.units[e].attack_type){
  3723. case 'hack': blunt += attack; break;
  3724. case 'pierce': sharp += attack; break;
  3725. case 'distance':dist += attack; break;
  3726. }
  3727. }
  3728. }
  3729. }
  3730.  
  3731. /*******************************************************************************************************************************
  3732. * ● Unit strength: Unit menu
  3733. *******************************************************************************************************************************/
  3734. function setStrengthMenu() {
  3735. try{
  3736. var unitsIn = uw.ITowns.getTown(uw.Game.townId).units(),
  3737. e, units = getSelectedUnitsMenu();
  3738.  
  3739. // Calculation
  3740. if(def==true){
  3741. calcDef(units);
  3742. } else {
  3743. calcOff(unitsIn, units);
  3744. }
  3745. $('#blunt').get(0).innerHTML = blunt;
  3746. $('#sharp').get(0).innerHTML = sharp;
  3747. $('#dist').get(0).innerHTML = dist;
  3748.  
  3749. setTransportCapacity(units);
  3750. }catch(e){
  3751. handleError(e, "setStrengthMenu");
  3752. }
  3753. }
  3754.  
  3755.  
  3756. function addStrengthMenu(){
  3757. $('<hr><div id="strength" class="cont_left"><span id="str_font" class="bold text_shadow" style="color:#FFCC66;font-size: 0.8em;">'+
  3758. '<table style="margin:0px;">'+
  3759. '<tr><td><div class="ico units_info_sprite img_hack"></td><td id="blunt">0</td></tr>'+
  3760. '<tr><td><div class="ico units_info_sprite img_pierce"></td><td id="sharp">0</td></tr>'+
  3761. '<tr><td><div class="ico units_info_sprite img_dist"></td><td id="dist">0</td></tr>'+
  3762. '</table>'+
  3763. '</span></div>'+
  3764. '<div class="cont_right">'+
  3765. '<img id="def" class="img" src="https://gpall.innogamescdn.com/images/game/unit_overview/support.png">'+
  3766. '<img id="off" class="img" src="https://gpall.innogamescdn.com/images/game/unit_overview/attack.png">'+
  3767. '</div>').appendTo('.units_land .content');
  3768.  
  3769. // transporter display
  3770. $('<div id="transporter" class="cont" style="height:25px;">'+
  3771. '<table style=" margin:0px;"><tr align="center" >'+
  3772. '<td><img id="ship_img" class="ico" src="http://s7.directupload.net/images/140724/4pvfuch8.png"></td>'+
  3773. '<td><span id="ship" class="bold text_shadow" style="color:#FFCC66;font-size: 10px;"></span></td>'+
  3774. '</tr></table>'+
  3775. '</div>').appendTo('.units_naval .content');
  3776.  
  3777. // Styles
  3778. $('.ico').css({
  3779. height: '20px',
  3780. width: '20px'
  3781. });
  3782. $('.units_info_sprite').css({
  3783. background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
  3784. backgroundSize: '100%'
  3785. });
  3786. $('.img_pierce').css({ backgroundPosition: '0px -20px' });
  3787. $('.img_dist').css({ backgroundPosition: '0px -40px' });
  3788. $('hr').css({
  3789. margin: '0px',
  3790. backgroundColor: '#5F5242',
  3791. height: '2px',
  3792. border: '0px solid'
  3793. });
  3794. $('.cont_left').css({
  3795. background: 'url(https://gpall.innogamescdn.com/images/game/layout/layout_units_nav_bg.png)',
  3796. width:'65%',
  3797. display: 'table-cell'
  3798. });
  3799. $('.cont').css({
  3800. background: 'url(https://gpall.innogamescdn.com/images/game/layout/layout_units_nav_bg.png)'
  3801. });
  3802. $('.cont_right').css({
  3803. background:'url(https://gpall.innogamescdn.com/images/game/layout/layout_units_nav_bg.png)',
  3804. width:'30%',
  3805. display: 'table-cell',
  3806. verticalAlign:'middle'
  3807. });
  3808. $('.img').css({
  3809. float:'right',
  3810. background:'none',
  3811. margin:'2px 8px 2px 0px'
  3812. });
  3813.  
  3814. $('.units_land .units_wrapper, .btn_gods_spells .checked').click(function(){
  3815. setTimeout(function(){
  3816. setStrengthMenu();
  3817. }, 100);
  3818. });
  3819.  
  3820. $('#off').css({"filter": "url(#GrayScale)", "-webkit-filter" : "grayscale(80%)" });
  3821.  
  3822. // Buttons
  3823. $('#off').click(function(){
  3824. $('#strength .img_hack').get(0).style.backgroundPosition = '0% 36%';
  3825. $('#strength .img_pierce').get(0).style.backgroundPosition = '0% 27%';
  3826. $('#strength .img_dist').get(0).style.backgroundPosition = '0% 45%';
  3827.  
  3828. $('#str_font').get(0).style.color = "#edb";
  3829.  
  3830. // TODO: doesn't work in FF yet
  3831. $(this).css({ "filter": "none", "-webkit-filter" : "grayscale(0%)" });
  3832.  
  3833. $('#def').css({"filter": "url(#GrayScale)", "-webkit-filter" : "grayscale(80%)" });
  3834. def = false;
  3835. setStrengthMenu();
  3836. });
  3837. $('#def').click(function(){
  3838. $('#strength .img_hack').get(0).style.backgroundPosition = '0% 0%';
  3839. $('#strength .img_pierce').get(0).style.backgroundPosition = '0% 9%';
  3840. $('#strength .img_dist').get(0).style.backgroundPosition = '0% 18%';
  3841.  
  3842. $('#str_font').get(0).style.color = "#fc6";
  3843.  
  3844. $(this).css({"filter": "none", "-webkit-filter" : "grayscale(0%)" });
  3845. $('#off').css({"filter": "url(#GrayScale)", "-webkit-filter" : "grayscale(80%)" });
  3846. def = true;
  3847. setStrengthMenu();
  3848. });
  3849. $('#def,#off,#transporter').hover(function() {
  3850. $(this).css('cursor','pointer');
  3851. });
  3852. $('#transporter').toggle(
  3853. function(){
  3854. $('#ship_img').get(0).src = "http://s1.directupload.net/images/140724/b5xl8nmj.png";
  3855. shipsize = !shipsize;
  3856. setStrengthMenu();
  3857. },
  3858. function(){
  3859. $('#ship_img').get(0).src = "http://s7.directupload.net/images/140724/4pvfuch8.png";
  3860. shipsize = !shipsize;
  3861. setStrengthMenu();
  3862. }
  3863. );
  3864. }
  3865.  
  3866. /*******************************************************************************************************************************
  3867. * ● Unit strength: Siege
  3868. *******************************************************************************************************************************/
  3869. function addStrengthConquest(){
  3870. var units = [], str;
  3871.  
  3872. // units of the siege
  3873. $('#conqueror_units_in_town .unit').each(function(){
  3874. str = $(this).attr("class").split(" ")[4];
  3875. if(!uw.GameData.units[str].is_naval){
  3876. units[str] = parseInt($(this).get(0).children[0].innerHTML, 10);
  3877. //console.log($(this).attr("class").split(" ")[4]);
  3878. }
  3879. });
  3880. // calculation
  3881. calcDef(units);
  3882.  
  3883. $('<div id="strength_eo" class="game_border" style="width:90px; margin: 20px; align:center;">'+
  3884. '<div class="game_border_top"></div><div class="game_border_bottom"></div>'+
  3885. '<div class="game_border_left"></div><div class="game_border_right"></div>'+
  3886. '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>'+
  3887. '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>'+
  3888. '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">'+
  3889. '<tr><td width="1%"><div class="ico units_info_sprite img_hack"></div></td><td id="bl" align="center" width="100%">0</td></tr>'+
  3890. '<tr><td><div class="ico units_info_sprite img_pierce"></div></td><td id="sh" align="center">0</td></tr>'+
  3891. '<tr><td><div class="ico units_info_sprite img_dist"></div></td><td id="di" align="center">0</td></tr>'+
  3892. '</table></span>'+
  3893. '</div>').appendTo('#conqueror_units_in_town');
  3894.  
  3895. $('#strength_eo').tooltip('Gesamteinheitenstärke der Belagerungstruppen');
  3896.  
  3897. $('#strength_eo .ico').css({
  3898. height: '20px',
  3899. width: '20px'
  3900. });
  3901. $('#strength_eo .units_info_sprite').css({
  3902. background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
  3903. backgroundSize: '100%'
  3904. });
  3905. $('#strength_eo .img_pierce').css({ backgroundPosition: '0% 9%' });
  3906. $('#strength_eo .img_dist').css({ backgroundPosition: '0% 18%' });
  3907.  
  3908.  
  3909. $('#bl').get(0).innerHTML = blunt;
  3910. $('#sh').get(0).innerHTML = sharp;
  3911. $('#di').get(0).innerHTML = dist;
  3912. }
  3913.  
  3914. /*******************************************************************************************************************************
  3915. * ● Unit strength: Barracks
  3916. *******************************************************************************************************************************/
  3917. function setStrengthBarracks(){
  3918. if(!$('#strength_baracks').get(0)){
  3919. var units = [], pop = 0;
  3920.  
  3921. // whole units of the town
  3922. $('#units .unit_order_total').each(function(){
  3923. units[$(this).parent().parent().attr("id")] = $(this).get(0).innerHTML;
  3924. });
  3925. // calculation
  3926. calcDef(units);
  3927.  
  3928. // population space of the units
  3929. for(var e in units) {
  3930. if(units.hasOwnProperty(e)) {
  3931. pop += units[e] * uw.GameData.units[e].population;
  3932. }
  3933. }
  3934. $('<div id="strength_baracks" class="game_border" style="float:right; width:70px; align:center;">'+
  3935. '<div class="game_border_top"></div><div class="game_border_bottom"></div>'+
  3936. '<div class="game_border_left"></div><div class="game_border_right"></div>'+
  3937. '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>'+
  3938. '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>'+
  3939. '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">'+
  3940. '<tr><td width="1%"><div class="ico units_info_sprite img_hack"></div></td><td id="b" align="center" width="100%">0</td></tr>'+
  3941. '<tr><td><div class="ico units_info_sprite img_pierce"></div></td><td id="s" align="center">0</td></tr>'+
  3942. '<tr><td><div class="ico units_info_sprite img_dist"></div></td><td id="d" align="center">0</td></tr>'+
  3943. '</table></span>'+
  3944. '</div>').appendTo('.ui-dialog #units');
  3945.  
  3946. $('<div id="pop_baracks" class="game_border" style="float:right; width:60px; align:center;">'+
  3947. '<div class="game_border_top"></div><div class="game_border_bottom"></div>'+
  3948. '<div class="game_border_left"></div><div class="game_border_right"></div>'+
  3949. '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>'+
  3950. '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>'+
  3951. '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">'+
  3952. '<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>'+
  3953. '</table></span>'+
  3954. '</div>').appendTo('.ui-dialog #units');
  3955.  
  3956. $('.ui-dialog #units .ico').css({
  3957. height: '20px',
  3958. width: '20px'
  3959. });
  3960. $('.ui-dialog #units .units_info_sprite').css({
  3961. background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
  3962. backgroundSize: '100%'
  3963. });
  3964. $('.ui-dialog #units .img_pierce').css({ backgroundPosition: '0% 9%' });
  3965. $('.ui-dialog #units .img_dist').css({ backgroundPosition: '0% 18%' });
  3966.  
  3967. //$('#pop_baracks').tooltip('Bevölkerungszahl aller Landeinheiten der Stadt');
  3968. //$('#strength_baracks').tooltip('Gesamteinheitenstärke stadteigener Truppen');
  3969.  
  3970. $('#b').get(0).innerHTML = blunt;
  3971. $('#s').get(0).innerHTML = sharp;
  3972. $('#d').get(0).innerHTML = dist;
  3973. $('#p').get(0).innerHTML = pop;
  3974. }
  3975. }
  3976.  
  3977. /*******************************************************************************************************************************
  3978. * ● Transporter capacity
  3979. *******************************************************************************************************************************/
  3980. function setTransportCapacity(){
  3981. var bigTransp = 0, smallTransp = 0, pop = 0, ship = 0, unit, berth, units = [];
  3982. // Ship space (available)
  3983. smallTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().small_transporter, 10);
  3984. if(isNaN(smallTransp)) smallTransp = 0;
  3985. if(shipsize){
  3986. bigTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().big_transporter, 10);
  3987. if(isNaN(bigTransp)) bigTransp = 0;
  3988. }
  3989.  
  3990. // Checking: Research berth
  3991. berth = 0;
  3992. if(uw.ITowns.getTown(uw.Game.townId).researches().hasBerth()){
  3993. berth = 6;
  3994. }
  3995. ship = bigTransp*(20 + berth) + smallTransp*(10 + berth);
  3996.  
  3997. units = uw.ITowns.getTown(uw.Game.townId).units();
  3998.  
  3999. // Ship space (required)
  4000. for(var e in units) {
  4001. if(units.hasOwnProperty(e)) {
  4002. if(uw.GameData.units[e]){ // without Heroes
  4003. if(!(uw.GameData.units[e].is_naval || uw.GameData.units[e].flying)){
  4004. pop += units[e] * uw.GameData.units[e].population;
  4005. }
  4006. }
  4007. }
  4008. }
  4009. $('#ship').get(0).innerHTML = pop + "/" + ship;
  4010. }
  4011.  
  4012.  
  4013. /*******************************************************************************************************************************
  4014. * Simulator
  4015. * ----------------------------------------------------------------------------------------------------------------------------
  4016. * | ● Layout adjustment
  4017. * | ● Permanent display of the extended modifier box
  4018. * | ● Unit strength for entered units (without modificator influence yet)
  4019. * ----------------------------------------------------------------------------------------------------------------------------
  4020. *******************************************************************************************************************************/
  4021.  
  4022. function changeSimulatorLayoutNew(){
  4023. if(!$('#dio_simulator').get(0)){
  4024. $('<style id="dio_simulator" type="text/css">'+
  4025.  
  4026. '#place_simulator { overflow: hidden !important} '+
  4027. '#place_simulator .game_body { height: 457px !important} '+
  4028.  
  4029. // Bonus container
  4030. '.place_sim_wrap_mods {position: absolute !important; right: -17px !important} '+
  4031. '.place_sim_wrap_mods .place_simulator_table :eq(1) { width: 300px;} '+ ////////////// genauer!
  4032. '.place_sim_wrap_mods > .place_simulator_table { width: 272px;} '+ ////////////// genauer!
  4033.  
  4034.  
  4035.  
  4036. // Extended modifier box
  4037. '.place_sim_wrap_mods_extended { display: table !important; position: relative !important; width: 272px !important; padding-top: 3px !important; opacity: 1 !important; left: 0px; top: 0px} '+
  4038. '.place_sim_wrap_mods_extended table { table-layout: fixed !important; width: 100% !important} '+
  4039. '.place_sim_wrap_mods_extended table tr td:eq(0) { width: 18px !important } '+
  4040. '.place_image { width: 20px !important; height:20px !important; background-size: 100% !important; margin: auto !important} '+
  4041. '.place_cross { height: 19px !important}'+
  4042.  
  4043. '.top_border td { border-top: 2px solid #BFA978 !important; padding-top: 3px !important} '+
  4044.  
  4045. // Unit container
  4046. '#simulator_body .unit_container { height: 50px !important; width: 50px !important; margin: 0px 3px 0px 1px !important} '+
  4047. '.place_simulator_odd, .place_simulator_even { text-align: center !important} '+
  4048. '.place_insert_field { margin: 0px !important} '+
  4049.  
  4050. // Sea unit box
  4051. '.place_sim_sea_wrap h4 { float: left !important} '+
  4052. '.place_sim_select_strategies select { width: 95px !important} '+
  4053. '.place_sim_select_strategies { margin-left: 99px !important} '+
  4054.  
  4055. // Land unit box
  4056. '#place_sim_wrap_units { position: absolute !important; bottom: 35px !important} '+
  4057. '#place_sim_wrap_units h4 { float: left !important} '+
  4058.  
  4059. // Select boxes
  4060. '.place_sim_select_gods { width: 105px !important} '+
  4061. '.place_sim_select_gods select { width: 80px !important} '+
  4062. '.place_sim_select_gods_wrap { padding: 0px !important} '+
  4063. '#select_insert_units { width: 130px !important} '+
  4064.  
  4065. '.place_sim_select_gods_wrap .place_symbol, .place_sim_select_strategies .place_symbol { margin: 0px 2px 0px 5px !important} '+
  4066. '.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} '+
  4067. '.place_attack { float: left !important} '+
  4068. '#simulator_body .att { margin-left: 19px !important} '+
  4069.  
  4070. // Hero box
  4071. '.place_sim_heroes_container { position: absolute !important; right: 26px !important; padding-top: 3px !important; z-index: 1 !important} '+
  4072. '.place_sim_hero_container { width: 45px !important; height: 25px !important} '+
  4073. // - Hero container
  4074. '.place_sim_hero_choose, .place_sim_hero_unit_container { height: 26px !important; width: 30px !important} '+
  4075. '#hero_defense_icon, #hero_attack_icon { height: 25px !important; width: 25px !important; margin: 0px !important} '+
  4076. '#hero_defense_dd, #hero_attack_dd { height: 25px !important; width: 25px !important; margin: 1px !important} '+
  4077. '.place_sim_hero_attack, .place_sim_hero_defense { margin-left: 3px !important} '+
  4078. '#hero_attack_text, #hero_defense_text { font-size: 11px !important; bottom: 0px !important} '+
  4079. '.place_sim_heroes_container .plus { left: 2px; top: 2px !important} '+
  4080. // - Hero spinner
  4081. '.place_sim_hero_spinner { height: 25px !important; width: 40px !important } '+
  4082. '.place_sim_heroes_container td:eq(0) { height: 30px !important} '+
  4083. '.hero_spinner { height: 24px !important;position:absolute !important; width:12px !important; left:29px !important, background:url(https://gpall.innogamescdn.com/images/game/border/odd.png) repeat !important; border: 1px solid rgb(107, 107, 107) !important} '+
  4084. '.place_sim_hero_spinner .button_down, .place_sim_hero_spinner .button_up { bottom: 2px !important; cursor: pointer !important} '+
  4085.  
  4086. // Quack
  4087. '#q_place_sim_lost_res { display: none; } '+
  4088. '</style>').appendTo('head');
  4089. }
  4090.  
  4091. /////////////////////////////////////
  4092.  
  4093.  
  4094. $('.place_sim_bonuses_heroes h4').prependTo('.place_sim_wrap_mods');
  4095.  
  4096. $('.place_sim_bonuses_more_confirm').parent().get(0).style.display = "none";
  4097. $('.place_sim_showhide').remove();
  4098.  
  4099. // Wall loss
  4100. $('.place_sim_wrap_mods tr:eq(1) td:eq(5)').html('<span id="building_place_def_losses_wall_level" class="place_losses bold"></span');
  4101. $('.place_sim_wrap_mods tr:last-child').remove();
  4102. // AutoFillIn
  4103. $('.place_insert_field[name="sim[mods][att][luck]"]').get(0).value = 0;
  4104.  
  4105. // Extended modificator box
  4106. //$('.place_sim_wrap_mods_extended').removeClass().addClass("place_sim_wrap_mods_extend");
  4107. $('.place_sim_wrap_mods_extended').appendTo('.place_sim_wrap_mods');
  4108. $('.place_sim_wrap_mods_extended .place_simulator_table').appendTo('.place_sim_wrap_mods_extended');
  4109. if($('.place_sim_wrap_mods_extended .game_border').get(0)) { $('.place_sim_wrap_mods_extended .game_border').remove(); } // TODO: css!
  4110.  
  4111. $('.place_sim_wrap_mods_extended .place_image').each(function(){
  4112. var s = parseInt($(this).css('backgroundPosition').replace("px", "").split(" ")[1], 10)/2;
  4113. $(this).get(0).style.backgroundPosition = '0px '+s+'px';
  4114. });
  4115. $('.place_sim_wrap_mods_extended .power').each(function(){
  4116. $(this).removeClass("power_icon45x45").addClass("power_icon16x16");
  4117. });
  4118. $('.place_sim_wrap_mods_extended td:nth-child(even)').each(function(){
  4119. $(this).addClass("left_border place_simulator_odd");
  4120. });
  4121. $('.place_sim_wrap_mods_extended td:nth-child(odd)').each(function(){
  4122. $(this).addClass("left_border place_simulator_even");
  4123. });
  4124.  
  4125. // Beta only yet
  4126. //if($('.place_sim_wrap_mods_extend tr').length == 5){
  4127. $('.place_sim_wrap_mods_extended tr:eq(2)').each(function(){
  4128. $(this).addClass("top_border");
  4129. });
  4130. $('.place_sim_wrap_mods_extended tr:last-child').remove();
  4131. //}
  4132.  
  4133. $('.place_sim_wrap_mods_extend td:first-child').each(function(){
  4134. $(this).removeClass("left_border");
  4135. });
  4136. // -> update percentage each time
  4137. $('.place_checkbox_field').each(function(){
  4138. $(this).click(function(){
  4139. uw.FightSimulator.closeModsExtended();
  4140. //$('.place_sim_bonuses_more_confirm').get(0).click();
  4141. });
  4142. });
  4143.  
  4144.  
  4145. // Sea unit box
  4146.  
  4147. $('.place_sim_select_strategies').prependTo('.place_sim_sea_wrap');
  4148. $('.place_sim_sea_wrap h4').prependTo('.place_sim_sea_wrap');
  4149.  
  4150. // Land unit box
  4151. $('<div id="place_sim_wrap_units"></div>').appendTo('#simulator_body');
  4152.  
  4153. $('#place_simulator h4:last, .place_sim_select_gods_wrap').appendTo('#place_sim_wrap_units');
  4154. $('#place_sim_ground_units').appendTo('#place_sim_wrap_units');
  4155. $('#place_sim_wrap_units h4').prependTo('.place_sim_select_gods_wrap');
  4156.  
  4157.  
  4158. // Hero world ?
  4159. if(uw.Game.hasArtemis){
  4160. $('.place_sim_wrap_mods_extend tr').each(function(){
  4161. $(this).get(0).children[1].style.borderLeft = "none";
  4162. $(this).get(0).children[0].remove();
  4163. });
  4164. }
  4165.  
  4166. // Hero box ?
  4167. if($('.place_sim_heroes_container').get(0)){
  4168. $('.place_sim_heroes_container').appendTo(".place_sim_wrap_mods");
  4169.  
  4170. $('#place_simulator h4:eq(2)').remove(); // Delete heroes title
  4171.  
  4172. $('.hero_unit').each(function(){
  4173. $(this).removeClass('unit_icon40x40').addClass('unit_icon25x25');
  4174. });
  4175.  
  4176. // hero spinner
  4177. $('.place_sim_hero_spinner').each(function(){
  4178. $(this).removeClass('place_sim_hero_spinner').addClass('hero_spinner');
  4179. });
  4180. $('.hero_spinner .border_l').remove();
  4181. $('.hero_spinner .border_r').remove();
  4182. $('.hero_spinner .body').remove();
  4183. }
  4184.  
  4185. setStrengthSimulator();
  4186. }
  4187.  
  4188. function changeSimulatorLayout(){
  4189. $('#place_simulator').css({
  4190. overflow: 'hidden'
  4191. });
  4192. $('#place_simulator .game_body').css({
  4193. height: '457px'
  4194. });
  4195.  
  4196. // Bonus container
  4197. $('.place_sim_bonuses_heroes h4').prependTo('.place_sim_wrap_mods');
  4198. $('.place_sim_wrap_mods').css({
  4199. position: 'absolute',
  4200. right: '-17px'
  4201. });
  4202. $('.place_sim_wrap_mods .place_simulator_table .left_border').css({
  4203. width: '47px'
  4204. });
  4205. // Wall loss
  4206. $('.place_sim_wrap_mods tr:eq(1) td:eq(5)').html('<span id="building_place_def_losses_wall_level" class="place_losses bold"></span');
  4207. $('.place_sim_wrap_mods tr:last-child').remove();
  4208. // AutoFillIn
  4209. $('.place_insert_field[name="sim[mods][att][luck]"]').get(0).value = 0;
  4210. //$('.place_insert_field[name="sim[mods][att][morale]"]').get(0).value = 100;
  4211.  
  4212.  
  4213. // Extended modificator box
  4214. $('.place_sim_wrap_mods_extended').removeClass().addClass("place_sim_wrap_mods_extend");
  4215. $('.place_sim_wrap_mods_extend').appendTo('.place_sim_wrap_mods');
  4216. $('.place_sim_wrap_mods_extend .place_simulator_table').appendTo('.place_sim_wrap_mods_extend');
  4217. if($('.place_sim_wrap_mods_extend .game_border').get(0)) { $('.place_sim_wrap_mods_extend .game_border').remove(); }
  4218. $('.place_sim_wrap_mods_extend').css({
  4219. display: 'table',
  4220. position: 'relative',
  4221. width: '272px',
  4222. paddingTop: '3px'
  4223. });
  4224. $('.place_sim_wrap_mods_extend table').css({
  4225. tableLayout: 'fixed',
  4226. width: '100%'
  4227. });
  4228. $('.place_sim_wrap_mods_extend table tr td:eq(0)').css({
  4229. width: '18px'
  4230. });
  4231. $('.place_sim_bonuses_more_confirm').parent().get(0).style.display = "none";
  4232. $('.place_sim_showhide').remove();
  4233. $('.place_image').css({
  4234. width: '20px',
  4235. height:'20px',
  4236. backgroundSize: '100%',
  4237. margin: 'auto'
  4238. });
  4239. $('.place_cross').css({
  4240. height: '19px'
  4241. });
  4242. $('.place_sim_wrap_mods_extend .place_image').each(function(){
  4243. var s = parseInt($(this).css('backgroundPosition').replace("px", "").split(" ")[1], 10)/2;
  4244. $(this).get(0).style.backgroundPosition = '0px '+s+'px';
  4245. });
  4246. $('.place_sim_wrap_mods_extend .power').each(function(){
  4247. $(this).removeClass("power_icon45x45").addClass("power_icon16x16");
  4248. });
  4249. $('.place_sim_wrap_mods_extend td:nth-child(even)').each(function(){
  4250. $(this).addClass("left_border place_simulator_odd");
  4251. });
  4252. $('.place_sim_wrap_mods_extend td:nth-child(odd)').each(function(){
  4253. $(this).addClass("left_border place_simulator_even");
  4254. });
  4255.  
  4256. // Beta only yet
  4257. if($('.place_sim_wrap_mods_extend tr').length == 5){
  4258. $('.place_sim_wrap_mods_extend tr:eq(2)').each(function(){
  4259. $(this).addClass("top_border");
  4260. });
  4261. $('.place_sim_wrap_mods_extend tr:last-child').remove();
  4262. }
  4263. $('.top_border td').css({
  4264. borderTop: '2px solid #BFA978',
  4265. paddingTop: '3px'
  4266. });
  4267. $('.place_sim_wrap_mods_extend td:first-child').each(function(){
  4268. $(this).removeClass("left_border");
  4269. });
  4270. // -> update percentage each time
  4271. $('.place_checkbox_field').each(function(){
  4272. $(this).click(function(){
  4273. uw.FightSimulator.closeModsExtended();
  4274. //$('.place_sim_bonuses_more_confirm').get(0).click();
  4275. });
  4276. });
  4277.  
  4278.  
  4279. // unit container
  4280. $('#simulator_body .unit_container').css({
  4281. height: '50px',
  4282. width: '50px',
  4283. margin: '0px 3px 0px 1px'
  4284. });
  4285. $('.place_simulator_odd, .place_simulator_even').css({
  4286. textAlign: 'center'
  4287. });
  4288. $('.place_insert_field').css({
  4289. margin: '0px'
  4290. });
  4291.  
  4292. // Sea unit box
  4293. $('.place_sim_sea_wrap h4').css({
  4294. float: 'left'
  4295. });
  4296. $('.place_sim_select_strategies').prependTo('.place_sim_sea_wrap');
  4297. $('.place_sim_select_strategies select').css({
  4298. width: '95px'
  4299. });
  4300. $('.place_sim_sea_wrap h4').prependTo('.place_sim_sea_wrap');
  4301. $('.place_sim_select_strategies').css({
  4302. marginLeft: '99px'
  4303. });
  4304.  
  4305. // Land unit box
  4306. $('<div id="place_sim_wrap_units"></div>').appendTo('#simulator_body');
  4307. $('#place_sim_wrap_units').css({
  4308. position: 'absolute',
  4309. bottom: '35px'
  4310. });
  4311. $('#place_simulator h4:last, .place_sim_select_gods_wrap').appendTo('#place_sim_wrap_units');
  4312. $('#place_sim_ground_units').appendTo('#place_sim_wrap_units');
  4313. $('#place_sim_wrap_units h4').prependTo('.place_sim_select_gods_wrap');
  4314. $('#place_sim_wrap_units h4').css({
  4315. float: 'left'
  4316. });
  4317.  
  4318. // Select boxes
  4319. $('.place_sim_select_gods').css({
  4320. width: '105px'
  4321. });
  4322. $('.place_sim_select_gods select').css({
  4323. width: '80px'
  4324. });
  4325. $('.place_sim_select_gods_wrap').css({
  4326. padding: '0px'
  4327. });
  4328. $('#select_insert_units').css({
  4329. width: '130px'
  4330. });
  4331.  
  4332. $('.place_sim_select_gods_wrap .place_symbol, .place_sim_select_strategies .place_symbol').css({
  4333. margin: '0px 2px 0px 5px'
  4334. });
  4335. $('.place_sim_insert_units .place_symbol').css({
  4336. background: 'url(https://gpall.innogamescdn.com/images/game/towninfo/traveltime.png)',
  4337. backgroundSize: '140%',
  4338. backgroundPositionY: '-4px'
  4339. });
  4340. $('.place_attack').css({
  4341. float: 'left'
  4342. });
  4343. $('#simulator_body .att').css({
  4344. marginLeft: '19px'
  4345. });
  4346.  
  4347.  
  4348. // Hero world ?
  4349. if(uw.Game.hasArtemis){
  4350. $('.place_sim_wrap_mods_extend tr').each(function(){
  4351. $(this).get(0).children[1].style.borderLeft = "none";
  4352. $(this).get(0).children[0].remove();
  4353. });
  4354. }
  4355.  
  4356.  
  4357. // Hero box ?
  4358. if($('.place_sim_heroes_container').get(0)){
  4359. $('.place_sim_heroes_container').appendTo(".place_sim_wrap_mods");
  4360.  
  4361. $('#place_simulator h4:eq(2)').remove(); // Delete heroes title
  4362.  
  4363. $('.place_sim_heroes_container').css({
  4364. position: 'absolute',
  4365. right: '26px',
  4366. paddingTop: '3px',
  4367. zIndex: '1'
  4368. });
  4369.  
  4370. $('.place_sim_hero_container').css({
  4371. width: '45px', height: '25px'
  4372. });
  4373.  
  4374. // hero container
  4375. $('.place_sim_hero_choose, .place_sim_hero_unit_container').css({
  4376. height: '26px',
  4377. width: '30px'
  4378. });
  4379.  
  4380. $('#hero_defense_icon, #hero_attack_icon').css({
  4381. height: '25px',
  4382. width: '25px',
  4383. margin: '0px'
  4384. });
  4385. $('#hero_defense_dd, #hero_attack_dd').css({
  4386. height: '25px',
  4387. width: '25px',
  4388. margin: '1px'
  4389. });
  4390.  
  4391. $('.place_sim_hero_attack, .place_sim_hero_defense').css({
  4392. marginLeft: '3px'
  4393. });
  4394. $('#hero_attack_text, #hero_defense_text').css({
  4395. fontSize: '11px',
  4396. bottom: '0px'
  4397. });
  4398. $('.place_sim_heroes_container .plus').css({
  4399. left: '2px', top: '2px'
  4400. });
  4401.  
  4402. $('.hero_unit').each(function(){
  4403. $(this).removeClass('unit_icon40x40').addClass('unit_icon25x25');
  4404. });
  4405.  
  4406.  
  4407.  
  4408. // hero spinner
  4409. $('.place_sim_hero_spinner').css({
  4410. height: '25px', width: '40px'
  4411. });
  4412. $('.place_sim_hero_spinner').each(function(){
  4413. $(this).removeClass('place_sim_hero_spinner').addClass('hero_spinner');
  4414. });
  4415. $('.hero_spinner .border_l').remove();
  4416. $('.hero_spinner .border_r').remove();
  4417. $('.hero_spinner .body').remove();
  4418.  
  4419. $('.place_sim_heroes_container td:eq(0)').css({ height: '30px' });
  4420.  
  4421. $('.hero_spinner').css({
  4422. height: '24px',
  4423. position: 'absolute',
  4424. width: '12px',
  4425. left: '29px',
  4426. background: 'url(https://gpall.innogamescdn.com/images/game/border/odd.png) repeat',
  4427. border: '1px solid rgb(107, 107, 107)'
  4428. });
  4429. $('.place_sim_hero_spinner .button_down, .place_sim_hero_spinner .button_up').css({
  4430. bottom: '2px',
  4431. cursor: 'pointer'
  4432. });
  4433. }
  4434.  
  4435. $('<style type="text/css"> #q_place_sim_lost_res { display: none; } </style>').appendTo('head');
  4436.  
  4437. setStrengthSimulator();
  4438. }
  4439.  
  4440. function afterSimulation(){
  4441. var lossArray = { att : { res: 0, fav: 0, pop: 0 }, def : { res: 0, fav: 0, pop: 0 } },
  4442. wall_level = parseInt($('.place_sim_wrap_mods .place_insert_field[name="sim[mods][def][wall_level]"]').val(), 10),
  4443. wall_damage = parseInt($('#building_place_def_losses_wall_level').get(0).innerHTML, 10),
  4444. 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 ];
  4445.  
  4446. // Calculate unit losses
  4447. $('#place_sim_wrap_units .place_losses, #place_sim_naval_units .place_losses').each(function(){
  4448. var loss = parseInt($(this).get(0).innerHTML, 10) || 0;
  4449. if(loss > 0){
  4450. var unit = this.id.substring(26);
  4451. var side = this.id.split("_")[2]; // att / def
  4452. lossArray[side].res += loss *(uw.GameData.units[unit].resources.wood + uw.GameData.units[unit].resources.stone + uw.GameData.units[unit].resources.iron);
  4453. lossArray[side].fav += loss * uw.GameData.units[unit].favor;
  4454. lossArray[side].pop += loss * uw.GameData.units[unit].population;
  4455. }
  4456. });
  4457. // Calculate wall resource losses
  4458. for(var w = wall_level; w > wall_level - wall_damage; w--){
  4459. 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
  4460. }
  4461.  
  4462. // Insert losses into table
  4463. for(var x in lossArray){
  4464. if(lossArray.hasOwnProperty(x)){
  4465. for(var z in lossArray[x]){
  4466. if(lossArray[x].hasOwnProperty(z)){
  4467. $("#"+ x +"_"+ z).get(0).innerHTML = ((z === "res") && (lossArray[x][z] > 10000))? (Math.round(lossArray[x][z]/1000)+"k"):lossArray[x][z];
  4468. }
  4469. }
  4470. }
  4471. }
  4472. }
  4473.  
  4474. // Stärkeanzeige: Simulator
  4475. var unitsGround = { att: {}, def: {} }, unitsNaval = { att: {}, def: {} }, name ="";
  4476.  
  4477. function setStrengthSimulator() {
  4478. $('<div id="simu_table" style="position:relative; align:center;font-size: 0.8em; margin-top:6px; margin-right:39%;">'+
  4479. '<div style="float:left; margin-right:12px;"><h4>'+ getText("labels", "str") +'</h4>'+
  4480. '<table class="place_simulator_table strength" cellpadding="0px" cellspacing="0px" style="align:center;">'+
  4481. '<tr>'+
  4482. '<td class="place_simulator_even"></td>'+
  4483. '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_hack"></div></td>'+
  4484. '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_pierce"></div></td>'+
  4485. '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_dist"></div></td>'+
  4486. '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_ship"></div></td>'+
  4487. '</tr><tr>'+
  4488. '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>'+
  4489. '<td class="left_border place_simulator_odd" id="att_b">0</td>'+
  4490. '<td class="left_border place_simulator_even" id="att_s">0</td>'+
  4491. '<td class="left_border place_simulator_odd" id="att_d">0</td>'+
  4492. '<td class="left_border place_simulator_even" id="att_ship">0</td>'+
  4493. '</tr><tr>'+
  4494. '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>'+
  4495. '<td class="left_border place_simulator_odd" id="def_b">0</td>'+
  4496. '<td class="left_border place_simulator_even" id="def_s">0</td>'+
  4497. '<td class="left_border place_simulator_odd" id="def_d">0</td>'+
  4498. '<td class="left_border place_simulator_even" id="def_ship">0</td>'+
  4499. '</tr>'+
  4500. '</table>'+
  4501. '</div><div><h4>'+ getText("labels", "los") +'</h4>'+
  4502. '<table class="place_simulator_table loss" cellpadding="0px" cellspacing="0px" style="align:center;">'+
  4503. '<tr>'+
  4504. '<td class="place_simulator_even"></td>'+
  4505. '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_res"></div></td>'+
  4506. '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_fav"></div></td>'+
  4507. '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_pop"></div></td>'+
  4508. '</tr><tr>'+
  4509. '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>'+
  4510. '<td class="left_border place_simulator_odd" id="att_res">0</td>'+
  4511. '<td class="left_border place_simulator_even" id="att_fav">0</td>'+
  4512. '<td class="left_border place_simulator_odd" id="att_pop">0</td>'+
  4513. '</tr><tr>'+
  4514. '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>'+
  4515. '<td class="left_border place_simulator_odd" id="def_res">0</td>'+
  4516. '<td class="left_border place_simulator_even" id="def_fav">0</td>'+
  4517. '<td class="left_border place_simulator_odd" id="def_pop">0</td>'+
  4518. '</tr>'+
  4519. '</table>'+
  4520. '</div></div>').appendTo('#simulator_body');
  4521.  
  4522. $('#simu_table .ico').css({
  4523. height: '20px',
  4524. width: '20px'
  4525. });
  4526. $('#simu_table .units_info_sprite').css({
  4527. background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
  4528. backgroundSize: '100%'
  4529. });
  4530. $('#simu_table .img_hack').css({ backgroundPosition: '0% 36%' });
  4531. $('#simu_table .img_pierce').css({ backgroundPosition: '0% 27%' });
  4532. $('#simu_table .img_dist').css({ backgroundPosition: '0% 45%' });
  4533. $('#simu_table .img_ship').css({ backgroundPosition: '0% 72%' });
  4534.  
  4535. $('#simu_table .img_fav').css({ background: 'url(https://gpall.innogamescdn.com/images/game/res/favor.png)', backgroundSize: '100%' });
  4536. $('#simu_table .img_res').css({ background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png) 0% 54%', backgroundSize: '100%' });
  4537. $('#simu_table .img_pop').css({ background: 'url(https://gpall.innogamescdn.com/images/game/res/pop.png)', backgroundSize: '100%' });
  4538.  
  4539. $('#simu_table .left_border').css({
  4540. width: '54px'
  4541. });
  4542. $('#simu_table .left_border').each(function(){
  4543. $(this)[0].align = 'center';
  4544. });
  4545.  
  4546. $('#simu_table .strength').tooltip(getText("labels", "str") + " (" + getText("labels", "mod") +")");
  4547. $('#simu_table .loss').tooltip(getText("labels", "los"));
  4548.  
  4549. // Klick auf Einheitenbild
  4550. $('.index_unit').click(function(){
  4551. var type = $(this).attr('class').split(" ")[4];
  4552. $('.place_insert_field[name="sim[units][att]['+type+']"]').change();
  4553. });
  4554.  
  4555. $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').on('input change', function(){
  4556. name = $(this).attr("name").replace(/\]/g, "").split("[");
  4557. var str = this;
  4558. //console.log(str);
  4559. setTimeout(function(){
  4560. var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2],
  4561. val, e;
  4562.  
  4563. val = parseInt($(str).val(), 10);
  4564. val = val || 0;
  4565.  
  4566. if(unit_type == "ground"){
  4567. unitsGround[name[2]][name[3]] = val;
  4568.  
  4569. if(name[2] == "def"){
  4570. calcDef(unitsGround.def);
  4571. } else {
  4572. calcOff(unitsGround.att, unitsGround.att);
  4573. }
  4574. $('#' + name[2] + '_b').get(0).innerHTML = blunt;
  4575. $('#' + name[2] + '_s').get(0).innerHTML = sharp;
  4576. $('#' + name[2] + '_d').get(0).innerHTML = dist;
  4577.  
  4578. } else {
  4579. var att = 0, def = 0;
  4580. unitsNaval[name[2]][name[3]] = val;
  4581.  
  4582. if(name[2] == "def"){
  4583. for(e in unitsNaval.def) {
  4584. if(unitsNaval.def.hasOwnProperty(e)) {
  4585. def += unitsNaval.def[e] * uw.GameData.units[e].defense;
  4586. }
  4587. }
  4588. $('#def_ship').get(0).innerHTML = def;
  4589. } else {
  4590. for(e in unitsNaval.att) {
  4591. if(unitsNaval.att.hasOwnProperty(e)) {
  4592. att += unitsNaval.att[e] * uw.GameData.units[e].attack;
  4593. }
  4594. }
  4595. $('#att_ship').get(0).innerHTML = att;
  4596. }
  4597. }
  4598. }, 100);
  4599. });
  4600.  
  4601. // Abfrage wegen eventueller Spionageweiterleitung
  4602. getUnitInputs();
  4603. setTimeout(function(){
  4604. setChangeUnitInputs("def");
  4605. }, 100);
  4606.  
  4607. $('#select_insert_units').change(function(){
  4608. var side = $(this).find('option:selected').val();
  4609. setTimeout(function(){
  4610. getUnitInputs();
  4611. if(side === "att" || side === "def"){
  4612. setChangeUnitInputs(side);
  4613. }
  4614. }, 200);
  4615. });
  4616. }
  4617.  
  4618. function getUnitInputs(){
  4619. $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').each(function(){
  4620. name = $(this).attr("name").replace(/\]/g, "").split("[");
  4621. var str = this;
  4622. var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2],
  4623. val, e;
  4624. val = parseInt($(str).val(), 10);
  4625. val = val || 0;
  4626. if(unit_type === "ground"){
  4627. unitsGround[name[2]][name[3]] = val;
  4628. } else {
  4629. var att = 0, def = 0;
  4630. unitsNaval[name[2]][name[3]] = val;
  4631. }
  4632. });
  4633. }
  4634.  
  4635. function setChangeUnitInputs(side){
  4636. $('.place_insert_field[name="sim[units][' + side + '][godsent]"]').change();
  4637. setTimeout(function(){
  4638. $('.place_insert_field[name="sim[units][' + side + '][colonize_ship]"]').change();
  4639. }, 100);
  4640. }
  4641.  
  4642. /*******************************************************************************************************************************
  4643. * Defense form
  4644. * ----------------------------------------------------------------------------------------------------------------------------
  4645. * | ● Adds a defense form to the bbcode bar
  4646. * ----------------------------------------------------------------------------------------------------------------------------
  4647. *******************************************************************************************************************************/
  4648.  
  4649. // Funktion aufteilen...
  4650. function addForm(e){
  4651. var textareaId = "", bbcodeBarId = "";
  4652.  
  4653. switch (e) {
  4654. case "/alliance_forum/forum":
  4655. textareaId = "#forum_post_textarea";
  4656. bbcodeBarId = "#forum";
  4657. break;
  4658. case "/message/forward":
  4659. textareaId = "#message_message";
  4660. bbcodeBarId = "#message_bbcodes";
  4661. break;
  4662. case "/message/new":
  4663. textareaId = "#message_new_message";
  4664. bbcodeBarId = "#message_bbcodes";
  4665. break;
  4666. case "/message/view":
  4667. textareaId = "#message_reply_message";
  4668. bbcodeBarId = "#message_bbcodes";
  4669. break;
  4670. case "/player_memo/load_memo_content":
  4671. textareaId = "#memo_text_area";
  4672. bbcodeBarId = "#memo_edit";
  4673. break;
  4674. }
  4675.  
  4676. $('<a title="Verteidigungsformular" href="#" class="dio_bbcode_option def_form" name="def_form"></a>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
  4677.  
  4678. $('.def_form_button').css({
  4679. cursor: 'pointer',
  4680. marginTop:'3px'
  4681. });
  4682.  
  4683. $(bbcodeBarId + ' .dio_bbcode_option').css({
  4684. background: 'url("http://s14.directupload.net/images/140126/lt3hyb8j.png")',
  4685. display: 'block',
  4686. float: 'left',
  4687. width: '22px',
  4688. height: '23px',
  4689. margin: '0 3px 0 0',
  4690. position: 'relative',
  4691. });
  4692. $(bbcodeBarId + ' .def_form').css({
  4693. backgroundPosition: '-89px 0px'
  4694. });
  4695. var imgArray = {
  4696. wall: 'https://gpall.innogamescdn.com/images/game/main/wall.png',
  4697. tower: 'https://gpall.innogamescdn.com/images/game/main/tower.png',
  4698. hide: 'https://gpall.innogamescdn.com/images/game/main/hide.png',
  4699.  
  4700. spy: 'http://s7.directupload.net/images/140114/yr993xwc.png',
  4701. pop: 'http://s7.directupload.net/images/140114/4d6xktxm.png',
  4702.  
  4703. rev1: 'http://s7.directupload.net/images/140115/9cv6otiu.png',
  4704. rev0: 'http://s7.directupload.net/images/140115/aue4rg6i.png',
  4705. eo1: 'http://s1.directupload.net/images/140115/fkzlipyh.png',
  4706. eo0: 'http://s1.directupload.net/images/140115/hs2kg59c.png',
  4707. att: 'http://s1.directupload.net/images/140115/3t6uy4te.png',
  4708. sup: 'http://s7.directupload.net/images/140115/ty6szerx.png',
  4709.  
  4710. zeus: 'http://s1.directupload.net/images/140114/cdxecrpu.png',
  4711. hera: 'http://s1.directupload.net/images/140114/mve54v2o.png',
  4712. athena: 'http://s14.directupload.net/images/140114/kyqyedhe.png',
  4713. poseidon: 'http://s7.directupload.net/images/140114/tusr9oyi.png',
  4714. hades: 'http://s7.directupload.net/images/140114/huins2gn.png',
  4715. artemis: 'http://s7.directupload.net/images/140114/kghjhko8.png',
  4716. nogod: 'http://s1.directupload.net/images/140114/e7vmvfap.png',
  4717.  
  4718. captain: 'http://s14.directupload.net/images/140114/88gg75rc.png',
  4719. commander: 'http://s14.directupload.net/images/140114/slbst52o.png',
  4720. priest: 'http://s1.directupload.net/images/140114/glptekkx.png',
  4721.  
  4722. phalanx: 'http://s7.directupload.net/images/140114/e97wby6z.png',
  4723. ram: 'http://s7.directupload.net/images/140114/s854ds3w.png',
  4724.  
  4725. militia: 'http://wiki.en.grepolis.com/images/9/9b/Militia_40x40.png',
  4726. sword: 'http://wiki.en.grepolis.com/images/9/9c/Sword_40x40.png',
  4727. slinger: 'http://wiki.en.grepolis.com/images/d/dc/Slinger_40x40.png',
  4728. archer: 'http://wiki.en.grepolis.com/images/1/1a/Archer_40x40.png',
  4729. hoplite: 'http://wiki.en.grepolis.com/images/b/bd/Hoplite_40x40.png',
  4730. rider: 'http://wiki.en.grepolis.com/images/e/e9/Rider_40x40.png',
  4731. chariot: 'http://wiki.en.grepolis.com/images/b/b8/Chariot_40x40.png',
  4732. catapult: 'http://wiki.en.grepolis.com/images/f/f0/Catapult_40x40.png',
  4733. godsent: 'http://wiki.de.grepolis.com/images/6/6e/Grepolis_Wiki_225.png',
  4734.  
  4735. def_sum: 'http://s14.directupload.net/images/140127/6cxnis9r.png',
  4736.  
  4737. minotaur: 'http://wiki.de.grepolis.com/images/7/70/Minotaur_40x40.png',
  4738. manticore: 'http://wiki.de.grepolis.com/images/5/5e/Manticore_40x40.png',
  4739. zyclop: 'http://wiki.de.grepolis.com/images/6/66/Zyklop_40x40.png',
  4740. sea_monster:'http://wiki.de.grepolis.com/images/7/70/Sea_monster_40x40.png',
  4741. harpy: 'http://wiki.de.grepolis.com/images/8/80/Harpy_40x40.png',
  4742. medusa: 'http://wiki.de.grepolis.com/images/d/db/Medusa_40x40.png',
  4743. centaur: 'http://wiki.de.grepolis.com/images/5/53/Centaur_40x40.png',
  4744. pegasus: 'http://wiki.de.grepolis.com/images/5/54/Pegasus_40x40.png',
  4745. cerberus: 'http://wiki.de.grepolis.com/images/6/67/Zerberus_40x40.png',
  4746. fury: 'http://wiki.de.grepolis.com/images/6/67/Erinys_40x40.png',
  4747. griffin: 'http://wiki.de.grepolis.com/images/d/d1/Unit_greif.png',
  4748. calydonian_boar: 'http://wiki.de.grepolis.com/images/9/93/Unit_eber.png',
  4749.  
  4750. big_transporter: 'http://wiki.en.grepolis.com/images/0/04/Big_transporter_40x40.png',
  4751. bireme: 'http://wiki.en.grepolis.com/images/4/44/Bireme_40x40.png',
  4752. attack_ship: 'http://wiki.en.grepolis.com/images/e/e6/Attack_ship_40x40.png',
  4753. demolition_ship: 'http://wiki.en.grepolis.com/images/e/ec/Demolition_ship_40x40.png',
  4754. small_transporter: 'http://wiki.en.grepolis.com/images/8/85/Small_transporter_40x40.png',
  4755. trireme: 'http://wiki.en.grepolis.com/images/a/ad/Trireme_40x40.png',
  4756. colonize_ship: 'http://wiki.en.grepolis.com/images/d/d1/Colonize_ship_40x40.png',
  4757.  
  4758. move_icon: 'http://de.cdn.grepolis.com/images/game/unit_overview/',
  4759.  
  4760. bordure: 'http://s1.directupload.net/images/140126/8y6pmetk.png'
  4761. };
  4762.  
  4763. $('<div class="bb_def_chooser">'+
  4764. '<div class="bbcode_box middle_center">'+
  4765. '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div>'+
  4766. '<div class="bbcode_box top_center"></div><div class="bbcode_box bottom_center"></div>'+
  4767. '<div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>'+
  4768. '<div class="bbcode_box middle_left"></div><div class="bbcode_box middle_right"></div>'+
  4769. '<div class="bbcode_box content clearfix" style="padding:5px">'+
  4770. '<div id="f_uni" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("labels", "det") +'</div></div><br><br>'+
  4771. '<div id="f_prm" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("labels", "prm") +'</div></div><br><br>'+
  4772. '<div id="f_sil" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("labels", "sil") +'</div></div><br><br>'+
  4773. '<div id="f_mov" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">'+ getText("labels", "mov") +'</div></div><br><br>'+
  4774. '<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>'+
  4775. '</div></div></div>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
  4776.  
  4777. $('.bb_def_chooser').css({
  4778. display: 'none',
  4779. top: '38px',
  4780. left: '510px',
  4781. position: 'absolute',
  4782. width: '190px',
  4783. zIndex: 10000
  4784. });
  4785.  
  4786. $(bbcodeBarId + " .bb_def_chooser .checkbox_new").click(function () {
  4787. $(this).toggleClass("checked");
  4788. });
  4789.  
  4790. $(bbcodeBarId + ' .def_form').toggle(function(){
  4791. $(this).parent().find(".bb_def_chooser").get(0).style.display = "block";
  4792. }, function(){
  4793. $(this).parent().find(".bb_def_chooser").get(0).style.display = "none";
  4794. });
  4795.  
  4796. $(bbcodeBarId + ' #dio_insert').click(function(){
  4797. var textarea = $(textareaId).get(0), text = $(textarea).val(), troop_table = "", troop_img = "", troop_count = "", separator = "", move_table = "", landunit_sum = 0;
  4798.  
  4799. $('.def_form').click();
  4800.  
  4801. if($('#f_uni').hasClass("checked")){
  4802. $('.units_land .unit, .units_naval .unit').each(function(){
  4803. troop_img += separator + '[img]' + imgArray[this.className.split(" ")[1]] + '[/img]';
  4804. troop_count += separator + '[center]' + $(this).find(".value").get(0).innerHTML + '[/center]';
  4805. separator = "[||]";
  4806. });
  4807. } else {
  4808. $('.units_land .unit').each(function(){
  4809. 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);
  4810. if(def > 10){
  4811. landunit_sum += parseInt($(this).find(".value").get(0).innerHTML, 10) * uw.GameData.units[a].population * ((def > 20) ? 2 : 1);
  4812. }
  4813. });
  4814. landunit_sum = (landunit_sum > 10000) ? ((Math.round(landunit_sum / 100))/10) + "k" : landunit_sum;
  4815.  
  4816. troop_img += '[img]'+ imgArray.def_sum +'[/img]';
  4817. troop_count += '[center]'+ landunit_sum +'[/center]';
  4818. separator = "[||]";
  4819. $('.units_naval .unit').each(function(){
  4820. troop_img += separator + '[img]' + imgArray[this.className.split(" ")[1]] + '[/img]';
  4821. troop_count += separator + '[center]' + $(this).find(".value").get(0).innerHTML + '[/center]';
  4822. });
  4823. }
  4824. if(troop_img !== ""){ troop_table = "\n[table][**]" + troop_img + "[/**][**]" + troop_count + "[/**][/table]\n"; }
  4825.  
  4826. var str = '[img]'+ imgArray.bordure + '[/img]'+
  4827. '\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'+
  4828. //'[table][**][img]'+ imgArray.sup +'[/img][||]'+
  4829. '[size=12][town]' + uw.ITowns.getTown(uw.Game.townId).getId() + '[/town] ([player]'+ uw.Game.player_name +'[/player])[/size]'+
  4830. //'[||][img]'+ imgArray['rev' + (uw.ITowns.getTown(uw.Game.townId).hasConqueror()?1:0)] +'[/img][/**][/table]'+
  4831. '\n\n[i][b]'+ getText("labels", "inf") +'[/b][/i]' + troop_table +
  4832. '[table][*]'+
  4833. '[img]'+ imgArray.wall +'[/img][|]\n'+
  4834. '[img]'+ imgArray.tower +'[/img][|]\n'+
  4835. '[img]'+ imgArray.phalanx +'[/img][|]\n'+
  4836. '[img]'+ imgArray.ram +'[/img][|]\n'+
  4837. ($('#f_prm').hasClass("checked") ? '[img]'+ imgArray.commander +'[/img][|]\n' : ' ')+
  4838. ($('#f_prm').hasClass("checked") ? '[img]'+ imgArray.captain +'[/img][|]\n' : ' ')+
  4839. ($('#f_prm').hasClass("checked") ? '[img]'+ imgArray.priest +'[/img][|]\n' : ' ')+
  4840. ($('#f_sil').hasClass("checked") ? '[center][img]'+imgArray.spy+'[/img][/center][|]\n' : ' ')+
  4841. '[img]'+ imgArray.pop +'[/img][|]\n'+
  4842. '[img]'+ imgArray[(uw.ITowns.getTown(uw.Game.townId).god() || "nogod")] +'[/img][/*]\n'+
  4843. '[**][center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("wall")+ '[/center][||]'+
  4844. '[center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("tower")+ '[/center][||]'+
  4845. '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.phalanx? '+' : '-') + '[/center][||]'+
  4846. '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.ram? '+' : '-')+ '[/center][||]'+
  4847. ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.commander >= uw.Timestamp.now())? '+' : '-') + '[/center][||]' : ' ')+
  4848. ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.captain >= uw.Timestamp.now())? '+' : '-')+ '[/center][||]' : ' ')+
  4849. ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.priest >= uw.Timestamp.now())? '+' : '-') + '[/center][||]' : ' ')+
  4850. ($('#f_sil').hasClass("checked") ? '[center]' + Math.round(uw.ITowns.getTown(uw.Game.townId).getEspionageStorage()/1000) + 'k[/center][||]': ' ')+
  4851. '[center]' + uw.ITowns.getTown(uw.Game.townId).getAvailablePopulation() + '[/center][||]'+
  4852. '[center]' + $('.gods_favor_amount').get(0).innerHTML + '[/center]'+
  4853. '[/**][/table]';
  4854.  
  4855. var bb_count_str = parseInt(str.match(/\[/g).length, 10), bb_count_move = 0;
  4856.  
  4857. var i = 0;
  4858. if($('#f_mov').hasClass("checked")){
  4859. move_table += '\n[i][b]'+ getText("labels", "mov") +'[/b][/i]\n[table]';
  4860.  
  4861. $('#toolbar_activity_commands').mouseover();
  4862.  
  4863. $('#toolbar_activity_commands_list .content .command').each(function(){
  4864. var cl = $(this).children()[0].className.split(" ");
  4865. 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)) {
  4866. move_table += (i%1) ? "" : "[**]";
  4867. i++;
  4868. move_table += "[img]" + imgArray.move_icon + cl[2] + ".png[/img][||]";
  4869. move_table += getArrivalTime($(this).children()[1].innerHTML) + (uw.Game.market_id === "de" ? " Uhr[||]" : " [||]");
  4870. move_table += "[town]" + JSON.parse(atob($(this).children()[2].firstChild.href.split("#")[1])).id + "[/town]";
  4871. move_table += (i%1) ? "[||]" : "[/**]";
  4872. }
  4873. bb_count_move = parseInt(move_table.match(/\[/g).length, 10);
  4874. });
  4875. if((bb_count_str + bb_count_move) > 480){
  4876. move_table += '[**]...[/**]';
  4877. }
  4878.  
  4879. $('#toolbar_activity_commands').mouseout();
  4880.  
  4881. //console.log((bb_count_str + bb_count_move));
  4882. move_table += (i%1) ? "[/**]" : "";
  4883. move_table += "[*][|][color=#800000][size=6][i] ("+ getText("labels", "dev") +": ±1s)[/i][/size][/color][/*][/table]\n";
  4884. }
  4885.  
  4886. str += move_table + '[img]'+ imgArray.bordure + '[/img]';
  4887.  
  4888.  
  4889.  
  4890. $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + str + text.substring($(textarea).get(0).selectionEnd));
  4891. });
  4892. }
  4893.  
  4894. function getArrivalTime(duration_time){
  4895. /*
  4896. var server_time = new Date((uw.Timestamp.server() + 7200) * 1000);
  4897.  
  4898. duration_time = duration_time.split(":");
  4899.  
  4900. s = server_time.getUTCSeconds() + parseInt(duration_time[2], 10);
  4901. m = server_time.getUTCMinutes() + parseInt(duration_time[1], 10) + ((s>=60)? 1 : 0);
  4902. h = server_time.getUTCHours() + parseInt(duration_time[0], 10) + ((m>=60)? 1 : 0);
  4903. */
  4904.  
  4905. var server_time = $('.server_time_area').get(0).innerHTML.split(" ")[0].split(":"), arrival_time, s, m, h;
  4906. duration_time = duration_time.split(":");
  4907.  
  4908. s = parseInt(server_time[2], 10) + parseInt(duration_time[2], 10);
  4909. m = parseInt(server_time[1], 10) + parseInt(duration_time[1], 10) + ((s>=60)? 1 : 0);
  4910. h = parseInt(server_time[0], 10) + parseInt(duration_time[0], 10) + ((m>=60)? 1 : 0);
  4911.  
  4912. s = s%60; m = m%60; h = h%24;
  4913.  
  4914. s = ((s<10) ? "0" : "") + s;
  4915. m = ((m<10) ? "0" : "") + m;
  4916. h = ((h<10) ? "0" : "") + h;
  4917.  
  4918. arrival_time = h + ":" + m + ":" + s;
  4919.  
  4920. return arrival_time;
  4921. }
  4922.  
  4923.  
  4924. /*******************************************************************************************************************************
  4925. * Smiley box
  4926. * ----------------------------------------------------------------------------------------------------------------------------
  4927. * | ● Display of a smiley selection box for text input fields (forum, messages, notes):
  4928. * | ● Used smileys: http://www.greensmilies.com/smilie-album/
  4929. * | + Own Grepolis smileys
  4930. * ----------------------------------------------------------------------------------------------------------------------------
  4931. *******************************************************************************************************************************/
  4932.  
  4933. var smileyArray = { "standard": {}, "nature": {}, "grepolis": {}, "people": {}, "other":{} };
  4934.  
  4935. // smiley categories
  4936. smileyArray.button = [ "rollsmiliey", "smile" ];
  4937.  
  4938. smileyArray.standard = [
  4939. "smilenew", "i/cnfy7elqh8dotnsdp", "lol", "neutral_new", "afraid", "freddus_pacman", "auslachen2", "kolobok-sanduhr", "bussi2", "winken4", "flucht2", "panik4", "ins-auge-stechen",
  4940. "seb_zunge", "fluch4_GREEN", "baby_junge2", "blush-reloaded6", "frown", "verlegen", "blush-pfeif", "stevieh_rolleyes", "daumendreh2", "baby_taptap",
  4941. "sadnew", "hust", "confusednew", "idea2", "irre", "irre4", "sleep", "candle", "nicken", "no_sad",
  4942. "thumbs-up_new", "thumbs-down_new", "bravo2", "oh-no2", "kaffee2", "drunk", "saufen", "freu-dance", "hecheln", "headstand", "rollsmiliey", "eazy_cool01", "motz", "cuinlove", "biggrin"
  4943. ];
  4944. smileyArray.nature = [
  4945. "dinosaurier07", "flu-super-gau", "ben_cat", "schwein", "hundeleine01", "blume", "ben_sharky", "ben_cow", "charly_bissig", "gehirnschnecke_confused", "mttao_fische", "mttao_angler",
  4946. "insel", "fliegeschnappen", "i/cifohy0y1cl7nckzw", /* Spinne */ "i/cifogx34asrswrcjw", /* Schiffbrüchiger */ "plapperhase", "ben_dumbo"
  4947. ];
  4948. smileyArray.grepolis = [
  4949. "mttao_wassermann", "i/cigrmpfofys5xtiks", /* Hera */ "i/cifvfsu3e2sdiipn0", /* Medusa */ "i/cigmv8wnffb3v0ifg", /* Mantikor */ "i/cigrqlp2odi2kqo24", /* Zyklop */
  4950. "i/cj1l9gndtu3nduyvi", /* Minotaurus */ "i/cj2byjendffymp88t", /* Pegasus */ "i/cj2ccmi2x8mhcoikd", /* Hydra */
  4951. "silvester_cuinlove", "mttao_schuetze", "kleeblatt2", "wallbash", /* "glaskugel4", */ "musketiere_fechtend", /* "krone-hoch",*/ "i/cifojb85jytq5h07g", // Wikinger
  4952. "mttao_waage2", "steckenpferd", /* "kinggrin_anbeten2", */ "i/cifohielywpedbyh8", /* Grepo Love */ "skullhaufen", "pferdehaufen" // "i/ckajscggscw4s2u60"
  4953. ];
  4954. smileyArray.people = [
  4955. "seb_hut5", "opa_boese2", "star-wars-yoda1-gruen", "hexefliegend", "snob", "seb_detektiv_ani", "seb_cowboy", "devil", "segen", "pirat5", "borg", "hexe3b",
  4956. "i/cifoqe3geok0jco5o", // Ägypter
  4957. "i/ciforgs313z0ae1cc", // Hippie
  4958. "eazy_polizei", "stars_elvis", "mttao_chefkoch", "nikolaus", "pirate3_biggrin", "batman_skeptisch", "tubbie1", "tubbie2", "tubbie3", "tubbie4"
  4959. ];
  4960. smileyArray.other = [
  4961. "steinwerfen", "herzen02", "scream-if-you-can", "kolobok", "headbash", "liebeskummer", "bussi", "brautpaar-reis", "grab-schaufler2", "boxen2", "aufsmaul",
  4962. "sauf", "mttao_kehren", "sm", "weckruf", "klugscheisser2", "karte2_rot", "dagegen", "party","dafuer", "outofthebox", "pokal_gold", "koepfler", "transformer"
  4963. ];
  4964.  
  4965. // Forum: extra smiley
  4966. if($(".editor_textbox_container").get(0)){
  4967. smileyArray.grepolis.push("i/ckajscggscw4s2u60"); // Pacman
  4968. smileyArray.grepolis.push("i/cowqyl57t5o255zli"); // Bugpolis
  4969. smileyArray.grepolis.push("i/cowquq2foog1qrbee"); // Inno
  4970. }
  4971.  
  4972. var id = 0, error_count = 0;
  4973.  
  4974. var er = false;
  4975. // preload images
  4976. function loadSmileys(){
  4977. // Replace german sign smilies
  4978. if(LID !== "de"){
  4979. smileyArray.other[17] = "dagegen2";
  4980. smileyArray.other[19] = "dafuer2";
  4981. }
  4982.  
  4983. for(var e in smileyArray){
  4984. if(smileyArray.hasOwnProperty(e)) {
  4985. for(var f in smileyArray[e]){
  4986. if(smileyArray[e].hasOwnProperty(f)) {
  4987. var src = smileyArray[e][f];
  4988. smileyArray[e][f] = new Image();
  4989. smileyArray[e][f].className = "smiley" + (id++);
  4990. smileyArray[e][f].style.margin = '3px';
  4991. smileyArray[e][f].style.maxHeight = '35px';
  4992. smileyArray[e][f].style.cursor = 'pointer';
  4993. if(src.substring(0,2) == "i/" ) {
  4994. smileyArray[e][f].src = "http://666kb.com/" + src + ".gif";
  4995. } else {
  4996. if(er == false){
  4997. smileyArray[e][f].src = "http://www.greensmilies.com/smile/smiley_emoticons_" + src + ".gif";
  4998. } else {
  4999. smileyArray[e][f].src = 'http://s1.directupload.net/images/140128/93x3p4co.gif';
  5000. }
  5001. }
  5002. smileyArray[e][f].onerror = function () {
  5003. this.src = 'http://s1.directupload.net/images/140128/93x3p4co.gif';
  5004. };
  5005. }
  5006. }
  5007. }
  5008. }
  5009. }
  5010.  
  5011. // Forum smilies
  5012.  
  5013.  
  5014. function changeForumEditorLayout(){
  5015. $('.blockrow').css({ border: "none" });
  5016.  
  5017. // Subject/Title
  5018. $($('.section div label[for="title"]').parent()).css({ float:"left", width:"36%", marginRight: "20px"});
  5019. $($('.section div label[for="subject"]').parent()).css({ float:"left", width:"36%", marginRight: "20px"});
  5020.  
  5021. $('.section div input').eq(0).css({ marginBottom: "-10px", marginTop: "10px"});
  5022. $('#display_posticon').remove();
  5023.  
  5024. // Posticons
  5025. $('.posticons table').css({ width: "50%", /*marginTop: "-16px"*/});
  5026. $('.posticons').css({ marginBottom: "-16px" });
  5027. $('.posticons').insertAfter($('.section div label[for="title"]').parent());
  5028. $('.posticons').insertAfter($('.section div label[for="subject"]').parent());
  5029. // Posticons hint
  5030. $('.posticons p').remove();
  5031. // Posticons: No Icon - radio button
  5032. $(".posticons [colspan='14']").parent().replaceWith($(".posticons [colspan='14']"));
  5033. $(".posticons [colspan='14']").children().wrap("<nobr></nobr>");
  5034. $(".posticons [colspan='14']").appendTo('.posticons tr:eq(0)');
  5035. $(".posticons [colspan='4']").remove();
  5036. }
  5037.  
  5038. function addSmileyBoxForum(){
  5039. $('<div class="smiley_box"><div>'+
  5040. '<div align="center" style="float:left">'+
  5041. '<a class="group" name="standard">'+ getText("labels", "std") +' </a>'+
  5042. '<a class="group" name="grepolis">'+ getText("labels", "gre") +' </a>'+
  5043. '<a class="group" name="nature">'+ getText("labels", "nat") +' </a>'+
  5044. '<a class="group" name="people">'+ getText("labels", "ppl") +' </a>'+
  5045. '<a class="group" name="other">'+ getText("labels", "oth") +' </a>'+
  5046. '</div><div align="right" style="margin-top:2px;"><a class="smiley_link" href="http://adf.ly/eDbBl" target="_blank">WWW.GREENSMILIES.COM</a></div>'+
  5047. '<hr class="smiley_hr">'+
  5048. '<div class="smiley_box_cont" style="overflow: hidden;"><hr class="smiley_hr"></div>'+
  5049. '</div></div><br>').insertAfter(".texteditor");
  5050.  
  5051. addSmileys("standard", "");
  5052.  
  5053. $('.smiley_hr').css({ margin: '3px 0px 0px 0px', color: '#086b18', border: '1px solid' });
  5054. $('.smiley_link').css({ color: '#0c450c' });
  5055. $('.smiley_link').hover(
  5056. function(){$(this).css({ color: '#14999E' });},
  5057. function(){$(this).css({ color: '#0c450c' });}
  5058. );
  5059. $('.smiley_box').css({ maxHeight: '90px', marginLeft: "5px", width: "99%", minHeight:"10px" });
  5060. $('.smiley_box_cont').css({ overflow: 'overlay', minHeight: '70px', marginBottom: '10px' });
  5061.  
  5062. $('.group').css({ color:'#0c450c', marginRight: '10px', cursor:"pointer"}); $('.group[name="standard"]').css({ color:'#089421' });
  5063.  
  5064. $('.group').click(function(){
  5065. $('.group').each(function(){
  5066. $(this).get(0).style.color = '#0c450c';
  5067. });
  5068. $(this).get(0).style.color = '#089421';
  5069. // change smiley group
  5070. addSmileys($(this).get(0).name, "");
  5071. });
  5072. }
  5073.  
  5074. // add smiley box
  5075. function addSmileyBox(e){
  5076. var bbcodeBarId = "";
  5077. switch (e) {
  5078. case "/alliance_forum/forum": bbcodeBarId = "#forum";
  5079. break;
  5080. case "/message/forward": bbcodeBarId = "#message_bbcodes";
  5081. break;
  5082. case "/message/new": bbcodeBarId = "#message_bbcodes";
  5083. break;
  5084. case "/message/view": bbcodeBarId = "#message_bbcodes";
  5085. break;
  5086. case "/player_memo/load_memo_content": bbcodeBarId = "#memo_edit";
  5087. break;
  5088. }
  5089. if(($(bbcodeBarId + ' #emots_popup_7').get(0) || $(bbcodeBarId + ' #emots_popup_15').get(0)) && PID == 84367){
  5090. $(bbcodeBarId + " .bb_button_wrapper").get(0).lastChild.remove();
  5091. }
  5092. $('<img class="smiley_button" src="http://www.greensmilies.com/smile/smiley_emoticons_smile.gif">').appendTo(bbcodeBarId + ' .bb_button_wrapper');
  5093.  
  5094. $('<div class="smiley_box">'+
  5095. '<div class="bbcode_box middle_center"><div class="bbcode_box middle_right"></div><div class="bbcode_box middle_left"></div>'+
  5096. '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div><div class="bbcode_box top_center"></div>'+
  5097. '<div class="bbcode_box bottom_center"></div><div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>'+
  5098. '<div align="center" style="width:100%;">'+
  5099. '<a class="group" name="standard" href="">'+ getText("labels", "std") +' </a>'+
  5100. '<a class="group" name="grepolis" href="">'+ getText("labels", "gre") +' </a>'+
  5101. '<a class="group" name="nature" href="">'+ getText("labels", "nat") +' </a>'+
  5102. '<a class="group" name="people" href="">'+ getText("labels", "ppl") +' </a>'+
  5103. '<a class="group" name="other" href="">'+ getText("labels", "oth") +' </a>'+
  5104. '</div>'+
  5105. '<hr class="smiley_hr">'+
  5106. '<div class="smiley_box_cont" style="overflow: hidden;"></div>'+
  5107. '<hr class="smiley_hr">'+
  5108. '<div align="center" style="margin-top:2px;"><a href="http://www.greensmilies.com/smilie-album/" target="_blank"><span class="smiley_link">WWW.GREENSMILIES.COM</span></a></div>'+
  5109. '</div>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
  5110.  
  5111. $(bbcodeBarId + ' .smiley_button').css({
  5112. cursor: 'pointer',
  5113. margin:'3px 2px 2px 2px'
  5114. });
  5115. $(bbcodeBarId + ' .smiley_box').css({
  5116. zIndex: '5000',
  5117. position: 'absolute',
  5118. top: '27px',
  5119. left: '430px',
  5120. width: '300px',
  5121. display: 'none'
  5122. });
  5123. $(bbcodeBarId + ' .smiley_link').css({
  5124. color: '#086b18',
  5125. fontSize: '0.6em'
  5126. });
  5127. $(bbcodeBarId + ' .smiley_hr').css({
  5128. margin: '3px 0px 0px 0px',
  5129. color: '#086b18',
  5130. border: '1px solid'
  5131. });
  5132. $(bbcodeBarId + ' .group').css({
  5133. color:'#0c450c'
  5134. });
  5135. $(bbcodeBarId + ' .group[name="standard"]').css({
  5136. color:'#089421'
  5137. });
  5138. $(bbcodeBarId + ' .group').click(function(){
  5139. $("#"+ $(this).closest('.bb_button_wrapper').parent().get(0).id +' .group').each(function(){
  5140. $(this).get(0).style.color = '#0c450c';
  5141. });
  5142. $(this).get(0).style.color = '#089421';
  5143. // change smiley group
  5144. addSmileys($(this).get(0).name, "#"+ $(this).closest('.bb_button_wrapper').parent().get(0).id);
  5145. });
  5146.  
  5147. addSmileys("standard", bbcodeBarId);
  5148.  
  5149. // smiley box toggle
  5150. $(bbcodeBarId + " .smiley_button").toggle(
  5151. function(){
  5152. $(this).get(0).src = smileyArray.button[0].src;
  5153. $(this).closest('.bb_button_wrapper').find(".smiley_box").get(0).style.display = "block";
  5154. },
  5155. function(){
  5156. $(this).get(0).src = smileyArray.button[1].src;
  5157. $(this).closest('.bb_button_wrapper').find(".smiley_box").get(0).style.display = "none";
  5158. }
  5159. );
  5160. }
  5161.  
  5162. if($(".editor_textbox_container").get(0)){
  5163. loadSmileys();
  5164. changeForumEditorLayout();
  5165. addSmileyBoxForum();
  5166. }
  5167.  
  5168.  
  5169. // insert smileys from arrays into smiley box
  5170. function addSmileys(type, bbcodeBarId){
  5171. // reset smilies
  5172. if($(bbcodeBarId + " .smiley_box_cont").get(0)) {$(bbcodeBarId + " .smiley_box_cont").get(0).innerHTML='';}
  5173. // add smilies
  5174. for(var e in smileyArray[type]){
  5175. if(smileyArray[type].hasOwnProperty(e)) {
  5176. //$(smileyArray[type][e]).clone();
  5177. $('<img src="' + smileyArray[type][e].src + '" class="smiley">').appendTo(bbcodeBarId + " .smiley_box_cont");
  5178. }
  5179. }
  5180. $('.smiley').css({ margin:'3px', maxHeight:'35px', cursor:'pointer' });
  5181.  
  5182. $(bbcodeBarId + " .smiley_box_cont .smiley").click(function(){
  5183. var textarea;
  5184. if(uw.location.pathname === "/game/index"){
  5185. // hide smiley box
  5186. $(this).closest('.bb_button_wrapper').find(".smiley_button").click();
  5187. // find textarea
  5188. textarea = $(this).closest('.gpwindow_content').find("textarea").get(0);
  5189. } else {
  5190.  
  5191. if($('.editor_textbox_container').get(0)) {
  5192. textarea = $('.editor_textbox_container .cke_contents textarea').get(0);
  5193. } else {
  5194. $(this).appendTo('iframe .forum');
  5195. }
  5196. //$(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + "[img]"+ $(this).get(0).src + "[/img]" + text.substring($(textarea).get(0).selectionEnd));
  5197. }
  5198. var text = $(textarea).val();
  5199. $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + "[img]"+ $(this).get(0).src + "[/img]" + text.substring($(textarea).get(0).selectionEnd));
  5200. });
  5201. }
  5202.  
  5203.  
  5204. /*******************************************************************************************************************************
  5205. * Biremes counter
  5206. * ----------------------------------------------------------------------------------------------------------------------------
  5207. * | ● Incremental update when calling a city (experimental, especially intended for siege worlds)
  5208. * ----------------------------------------------------------------------------------------------------------------------------
  5209. * *****************************************************************************************************************************/
  5210. var count, townId;
  5211.  
  5212. function updateBiriCount(){
  5213. var sum =0, e;
  5214. for(e in biriArray) {
  5215. if(biriArray.hasOwnProperty(e)) {
  5216. if(!uw.ITowns.getTown(e)) { // town is no longer in possession of user
  5217. delete biriArray[e];
  5218. saveBiri();
  5219. } else {
  5220. sum += parseInt(biriArray[e], 10);
  5221. }
  5222. }
  5223. }
  5224. if(DATA.options.bir){
  5225. sum = sum.toString();
  5226. var str ="", fsize = ['1.4em', '1.2em', '1.15em', '1.1em', '1.0em'], i;
  5227.  
  5228. for(i = 0; i<sum.length; i++){
  5229. str += "<span style='font-size:" + fsize[i] + "'>" + sum[i] + "</span>";
  5230. }
  5231. $('#bi_count').get(0).innerHTML = "<b>" + str + "</b>";
  5232. }
  5233. }
  5234.  
  5235. function getBiri(){
  5236. var biremeIn = parseInt(uw.ITowns.getTown(uw.Game.townId).units().bireme, 10),
  5237. biremeOut = parseInt(uw.ITowns.getTown(uw.Game.townId).unitsOuter().bireme, 10);
  5238. if(isNaN(biremeIn)) biremeIn = 0;
  5239. if(isNaN(biremeOut)) biremeOut = 0;
  5240. if(!biriArray[uw.Game.townId] || biriArray[uw.Game.townId] < (biremeIn + biremeOut)) {
  5241. biriArray[uw.Game.townId] = biremeIn;
  5242. }
  5243. updateBiriCount();
  5244. saveBiri();
  5245. }
  5246.  
  5247. function getBiriDocks(){
  5248. var windowID = uw.BuildingWindowFactory.getWnd().getID(),
  5249. biremeTotal = parseInt($('#gpwnd_' + windowID + ' #unit_order_tab_bireme .unit_order_total').get(0).innerHTML, 10);
  5250.  
  5251. if(!isNaN(biremeTotal)) biriArray[uw.Game.townId] = biremeTotal;
  5252. updateBiriCount();
  5253. saveBiri();
  5254. }
  5255.  
  5256. function getBiriAgora(){
  5257. var biremeTotal = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().bireme, 10);
  5258. if(isNaN(biremeTotal)) biremeTotal = 0;
  5259.  
  5260. $('#units_beyond_list .bireme').each(function(){
  5261. biremeTotal += parseInt($(this).get(0).children[0].innerHTML, 10);
  5262. });
  5263. biriArray[uw.Game.townId] = biremeTotal;
  5264. updateBiriCount();
  5265. saveBiri();
  5266. }
  5267.  
  5268. function saveBiri(){
  5269. saveValue(WID + "_biremes", JSON.stringify(biriArray));
  5270. }
  5271.  
  5272. function initBiri() {
  5273. $(".picomap_container").prepend("<div id='unit_count'><div id='bi_count'></div></div>");
  5274.  
  5275. updateBiriCount();
  5276.  
  5277. $('#unit_count').css({
  5278. background: 'url(https://gpall.innogamescdn.com/images/game/units/units_sprite_90x90_compressed.jpg)',
  5279. height: '90px',
  5280. width: '90px',
  5281. position: 'relative',
  5282. margin: '5px 28px 0px 28px',
  5283. backgroundPosition: '-270px 0px'
  5284. });
  5285. $('#bi_count').css({
  5286. color: '#826021',
  5287. position: 'relative',
  5288. top: '28px',
  5289. fontStyle: 'italic',
  5290. width: '79px'
  5291. });
  5292. $('.picomap_overlayer').tooltip(getText("options", "bir")[0]);
  5293.  
  5294. // Set Sea-ID beside the bull eye
  5295. $('#sea_id').prependTo('#ui_box');
  5296. $('#sea_id').css({
  5297. background: 'none',
  5298. fontSize: '25px',
  5299. cursor: 'default',
  5300. height: '50px',
  5301. width: '50px',
  5302. position: 'absolute',
  5303. top: '70px',
  5304. left: '157px',
  5305. zIndex: 30
  5306. });
  5307.  
  5308. }
  5309.  
  5310. /*******************************************************************************************************************************
  5311. * Popups
  5312. * ----------------------------------------------------------------------------------------------------------------------------
  5313. * | ● Available units (no supporting or outer units)
  5314. * | ● Improved favor
  5315. * | ● getTownTypes
  5316. * ----------------------------------------------------------------------------------------------------------------------------
  5317. *******************************************************************************************************************************/
  5318. var groupUnitArray = {};
  5319. // TODO: split Function (getUnits, calcUnitsSum, availableUnits, countBiremes, getTownTypes)?
  5320. function getAllUnits(){
  5321. try {
  5322. var townArray = uw.ITowns.getTowns(), groupArray = uw.ITowns.townGroups.getGroupsDIO(),
  5323.  
  5324. unitArray = {"sword":0, "archer":0, "hoplite":0, "chariot":0, "godsent":0, "rider":0, "slinger":0, "catapult":0, "small_transporter":0, "big_transporter":0,
  5325. "manticore":0, "harpy":0, "pegasus":0, "cerberus":0, "minotaur":0, "medusa":0, "zyklop":0, "centaur":0, "fury":0, "sea_monster":0 },
  5326.  
  5327. unitArraySea = {"bireme":0, "trireme":0, "attack_ship":0, "demolition_ship":0, "colonize_ship":0 };
  5328.  
  5329. if(uw.Game.hasArtemis){
  5330. unitArray = $.extend(unitArray, {"griffin":0, "calydonian_boar":0});
  5331. }
  5332. unitArray = $.extend(unitArray, unitArraySea);
  5333.  
  5334. for(var group in groupArray){
  5335. if(groupArray.hasOwnProperty(group)){
  5336. // clone Object "unitArray"
  5337. groupUnitArray[group] = Object.create(unitArray);
  5338.  
  5339. for(var town in groupArray[group].towns){
  5340. if(groupArray[group].towns.hasOwnProperty(town)){
  5341. var type = { lo: 0, ld: 0, so: 0, sd: 0, fo: 0, fd: 0 }; // Type for TownList
  5342.  
  5343. for(var unit in unitArray){
  5344. if(unitArray.hasOwnProperty(unit)){
  5345. // All Groups: Available units
  5346. var tmp = parseInt(uw.ITowns.getTown(town).units()[unit], 10);
  5347. groupUnitArray[group][unit] += tmp || 0;
  5348. // Only for group "All"
  5349. if(group == -1){
  5350. //Bireme counter
  5351. if( unit === "bireme" && ((biriArray[townArray[town].id] || 0) < (tmp || 0))) {
  5352. biriArray[townArray[town].id] = tmp;
  5353. }
  5354. //TownTypes
  5355. if(!uw.GameData.units[unit].is_naval){
  5356. if(uw.GameData.units[unit].flying){
  5357. type.fd += ((uw.GameData.units[unit].def_hack + uw.GameData.units[unit].def_pierce + uw.GameData.units[unit].def_distance)/3 * (tmp || 0));
  5358. type.fo += (uw.GameData.units[unit].attack * (tmp || 0));
  5359. } else {
  5360. type.ld += ((uw.GameData.units[unit].def_hack + uw.GameData.units[unit].def_pierce + uw.GameData.units[unit].def_distance)/3 * (tmp || 0));
  5361. type.lo += (uw.GameData.units[unit].attack * (tmp || 0));
  5362. }
  5363. } else {
  5364. type.sd += (uw.GameData.units[unit].defense * (tmp || 0));
  5365. type.so += (uw.GameData.units[unit].attack * (tmp || 0));
  5366. }
  5367. }
  5368. }
  5369. }
  5370. // Only for group "All"
  5371. if(group == -1){
  5372. // Icon: DEF or OFF?
  5373. var z = ((type.sd + type.ld + type.fd) <= (type.so + type.lo + type.fo)) ? "o" : "d",
  5374. temp = 0;
  5375.  
  5376. for(var t in type){
  5377. if(type.hasOwnProperty(t)){
  5378. // Icon: Land/Sea/Fly (t[0]) + OFF/DEF (z)
  5379. if(temp < type[t]){
  5380. autoTownTypes[townArray[town].id] = t[0] + z;
  5381. temp = type[t];
  5382. }
  5383. // Icon: Troops Outside (overwrite)
  5384. if(temp < 1000){
  5385. autoTownTypes[townArray[town].id] = "no";
  5386. }
  5387. }
  5388. }
  5389. // Icon: Empty Town (overwrite)
  5390. var popBuilding = 0, buildVal = uw.GameData.buildings, levelArray = townArray[town].buildings().getLevels(),
  5391. popMax = Math.floor(buildVal.farm.farm_factor * Math.pow(townArray[town].buildings().getBuildingLevel("farm"), buildVal.farm.farm_pow)), // Population from farm level
  5392. popPlow = townArray[town].researches().attributes.plow ? 200 : 0,
  5393. popFactor = townArray[town].buildings().getBuildingLevel("thermal") ? 1.1 : 1.0, // Thermal
  5394. popExtra = townArray[town].getPopulationExtra();
  5395.  
  5396. for(var b in levelArray){
  5397. if(levelArray.hasOwnProperty(b)){
  5398. popBuilding += Math.round(buildVal[b].pop * Math.pow(levelArray[b], buildVal[b].pop_factor));
  5399. }
  5400. }
  5401. population[town] = {};
  5402.  
  5403. population[town].max = popMax * popFactor + popPlow + popExtra;
  5404. population[town].buildings = popBuilding;
  5405. population[town].units = parseInt((population[town].max - (popBuilding + townArray[town].getAvailablePopulation()) ), 10);
  5406.  
  5407. if(population[town].units < 300){
  5408. autoTownTypes[townArray[town].id] = "po";
  5409. }
  5410.  
  5411. population[town].percent = Math.round(100/(population[town].max - popBuilding) * population[town].units);
  5412. }
  5413. }
  5414. }
  5415. }
  5416. }
  5417. updateBiriCount();
  5418. saveBiri();
  5419. updateAvailableUnitsBox(groupUnitArray[-1]);
  5420. } catch(error){
  5421. errorHandling(error, "getAllUnits"); // TODO: Eventueller Fehler in Funktion
  5422. }
  5423. }
  5424.  
  5425. function addFunctionToITowns(){
  5426. // Copy function and prevent an error
  5427. uw.ITowns.townGroups.getGroupsDIO = function(){
  5428. var town_groups_towns, town_groups, groups = {};
  5429.  
  5430. // #Grepolis-Fix: 2.75 -> 2.76
  5431. if(MM.collections){
  5432. town_groups_towns = MM.collections.TownGroupTown[0];
  5433. town_groups = MM.collections.TownGroup[0];
  5434. } else {
  5435. town_groups_towns = MM.getCollections().TownGroupTown[0];
  5436. town_groups = MM.getCollections().TownGroup[0];
  5437. }
  5438.  
  5439. town_groups_towns.each(function(town_group_town){
  5440. var gid=town_group_town.getGroupId(),
  5441. group=groups[gid],
  5442. town_id=town_group_town.getTownId();
  5443.  
  5444. if(!group){
  5445. groups[gid] = group = {
  5446. id:gid,
  5447. //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
  5448. towns:{}
  5449. };
  5450. }
  5451.  
  5452. group.towns[town_id]={id:town_id};
  5453. //groups[gid].towns[town_id]={id:town_id};
  5454. });
  5455. //console.log(groups);
  5456. return groups;
  5457. };
  5458. }
  5459.  
  5460.  
  5461. function addAvailableUnitsBox(){
  5462. try {
  5463. var groupArray = uw.ITowns.townGroups.getGroupsDIO(),
  5464. default_title = DM.getl10n("place", "support_overview").options.troop_count + " ("+ DM.getl10n("hercules2014", "available")+")";
  5465.  
  5466. if(default_title.length >= 20){
  5467. default_title = default_title.substr(0, default_title.indexOf("("));
  5468. }
  5469.  
  5470. $('<div id="available_units_box" class="ui-dialog">'+
  5471. '<div class="bbcode_box middle_center"><div class="bbcode_box middle_right"></div><div class="bbcode_box middle_left"></div>'+
  5472. '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div><div class="bbcode_box top_center"></div>'+
  5473. '<div class="bbcode_box bottom_center"></div><div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>'+
  5474. '<h4><nobr>'+ (LANG.hasOwnProperty(LID) ? getText("labels", "uni") : default_title) + '</nobr></h4>'+
  5475. '<div class="drop_box">'+
  5476. '<div class="drop_group dropdown default">'+
  5477. '<div class="border-left"></div><div class="border-right"></div>'+
  5478. '<div class="caption" name="'+ groupArray[-1].id +'">'+ ITowns.town_groups._byId[groupArray[-1].id].attributes.name +'</div>'+
  5479. '<div class="arrow"></div>'+
  5480. '</div>'+
  5481. '<div class="select_group dropdown-list default active"><div class="item-list"></div></div>'+
  5482. '</div><hr>'+
  5483. '<div class="box_content"></div>'+
  5484. '</div>').appendTo('body');
  5485.  
  5486. for(var group in groupArray){
  5487. if(groupArray.hasOwnProperty(group)){
  5488. var group_name = ITowns.town_groups._byId[group].attributes.name;
  5489. $('<div class="option'+ (group == -1 ? " sel" : "") +'" name="'+ group +'">'+ group_name +'</div>').appendTo('#available_units_box .item-list');
  5490. }
  5491. }
  5492.  
  5493. // Styles
  5494. $('#available_units_box .drop_box').css({
  5495. float: 'left',
  5496. position: 'absolute',
  5497. top: '1px',
  5498. right: '0px',
  5499. width: '90px',
  5500. zIndex: '1'
  5501. });
  5502. $('#available_units_box h4').css({
  5503. color: 'rgb(128, 64, 0)',
  5504. width: '10px',
  5505. height: '25px',
  5506. marginLeft: '4px',
  5507. lineHeight: '1.9'
  5508. });
  5509. $('#available_units_box .drop_group').css({
  5510. width: '84px'
  5511. });
  5512. $('#available_units_box .select_group').css({
  5513. position: 'absolute',
  5514. width: '80px',
  5515. display: "none",
  5516. right: '3px'
  5517. });
  5518. //$('#available_units_box .item-list').css({ maxHeight: '400px', maxWidth: '200px', align: "right" });
  5519.  
  5520. $('#available_units_box .arrow').css({
  5521. width: '18px',
  5522. height: '18px',
  5523. background: 'url('+ drop_out.src +') no-repeat -1px -1px',
  5524. position: 'absolute'
  5525. });
  5526.  
  5527. // hover effects of the elements in the drop menu
  5528. $('#available_units_box .option').hover(
  5529. function(){ $(this).css({color: '#fff', background: "#328BF1"}); },
  5530. function(){ $(this).css({color: '#000', background: "#FFEEC7"}); }
  5531. );
  5532.  
  5533. // click events of the drop menu
  5534. $('#available_units_box .select_group .option').each(function(){
  5535. $(this).click(function(e){
  5536. $(this).parent().find(".sel").toggleClass("sel");
  5537. $(this).toggleClass("sel");
  5538.  
  5539. $('#available_units_box .drop_group .caption').attr("name", $(this).attr("name"));
  5540. $('#available_units_box .drop_group .caption').get(0).innerHTML = $(this).get(0).innerHTML;
  5541. $('#available_units_box .select_group')[0].style.display = "none";
  5542.  
  5543. updateAvailableUnitsBox(groupUnitArray[$(this).attr("name")]);
  5544. //$('#available_units_box .drop_group .caption').change();
  5545. });
  5546. });
  5547. // show & hide drop menu on click
  5548. $('#available_units_box .drop_group').click(function(){
  5549. if($('#available_units_box .select_group')[0].style.display === "none"){
  5550. $('#available_units_box .select_group')[0].style.display = "block";
  5551. } else {
  5552. $('#available_units_box .select_group')[0].style.display = "none";
  5553. }
  5554. });
  5555.  
  5556. $('#available_units_box').click(function(e){
  5557. var clicked = $(e.target);
  5558. if(!(clicked[0].parentNode.className.split(" ")[1] === "dropdown")){
  5559. $('#available_units_box .select_group').get(0).style.display = "none";
  5560. }
  5561. });
  5562.  
  5563. // hover arrow change
  5564. $('#available_units_box .dropdown').hover(function(e){
  5565. $(e.target)[0].parentNode.childNodes[3].style.background = "url('"+ drop_over.src +"') no-repeat -1px -1px";
  5566. }, function(e){
  5567. $(e.target)[0].parentNode.childNodes[3].style.background = "url('"+ drop_out.src +"') no-repeat -1px -1px";
  5568. });
  5569.  
  5570. //$("#available_units_box .drop_group .caption").attr("name", "All");
  5571. //$('#available_units_box .drop_group').tooltip();
  5572.  
  5573. $('#available_units_box').draggable({
  5574. containment: "body",
  5575. snap: "body",
  5576. });
  5577. $('#available_units_box').css({
  5578. color: 'rgb(12, 69, 12)',
  5579. position: 'absolute',
  5580. top: '100px',
  5581. left: '200px',
  5582. zIndex: getMaxZIndex() + 1,
  5583. display: 'none'
  5584. });
  5585. $('#available_units_box .box_content').css({
  5586. background: 'url(http://s1.directupload.net/images/140206/8jd9d3ec.png) 94% 94% no-repeat',
  5587. backgroundSize: '140px'
  5588. });
  5589.  
  5590. $('#available_units_box').bind("mousedown",function(){
  5591. $(this).get(0).style.zIndex = getMaxZIndex() + 1;
  5592. });
  5593.  
  5594. $('#available_units_box hr').css({ margin: '3px 0px 0px', border: '1px solid', color: 'rgb(128, 64, 0)'});
  5595. } catch(error){
  5596. errorHandling(error, "addAvailableUnitsBox");
  5597. }
  5598. }
  5599.  
  5600. function updateAvailableUnitsBox(unitArray){
  5601. var i = 0, content = '<table><tr><td>', ttpArray = {};
  5602. for(var u in unitArray){
  5603. if(unitArray.hasOwnProperty(u)){
  5604. if(((i%5 == 0) && (i!== 25)) || u == "bireme") {
  5605. content += "</td></tr><tr><td>";
  5606. }
  5607. content += '<div class="unit index_unit bold unit_icon40x40 ' + u + ' " ><span style="font-size:0.9em">' + unitArray[u] + '</span></div> ';
  5608. ttpArray[u] = GameData.units[u].name;
  5609. i++;
  5610. }
  5611. }
  5612. content += '</td></tr></table>';
  5613. $('#available_units_box .box_content').get(0).innerHTML = "";
  5614. $('#available_units_box .box_content').append(content);
  5615.  
  5616.  
  5617. // Unit name tooltips
  5618. for(var o in ttpArray){
  5619. if(ttpArray.hasOwnProperty(o)){
  5620. $("#available_units_box ."+ o).tooltip(ttpArray[o]);
  5621. }
  5622. }
  5623. }
  5624.  
  5625. function unbindFavorPopup(){
  5626. //$('.gods_favor_button_area, #favor_circular_progress').mouseover();
  5627. //$('.gods_favor_button_area, #favor_circular_progress').mouseout();
  5628.  
  5629. $('.gods_favor_button_area, #favor_circular_progress').bind('mouseover mouseout', function(){
  5630. return false;
  5631. });
  5632. $('.gods_area').bind('mouseover', function(){
  5633. setFavorPopup();
  5634. });
  5635. }
  5636.  
  5637. var godArray = {
  5638. zeus: ' 0px', //'http://s1.directupload.net/images/140116/mkhzwush.png',
  5639. hera: '-152px', //'http://s1.directupload.net/images/140116/58ob8z82.png',
  5640. poseidon: '-101px', //'http://s1.directupload.net/images/140116/dkfxrw2f.png',
  5641. athena: ' -50px', //'http://s14.directupload.net/images/140116/iprgopak.png',
  5642. hades: '-203px', //'http://s14.directupload.net/images/140116/c9juk95y.png',
  5643. artemis: '-305px', //'http://s14.directupload.net/images/140116/pdc8vxe2.png'
  5644. };
  5645.  
  5646. var godImg = new Image(); godImg.src = "https://diotools.pf-control.de/images/game/gods.png";
  5647.  
  5648. function setFavorPopup(){
  5649. var pic_row = "",
  5650. fav_row = "",
  5651. prod_row = "";
  5652.  
  5653. for(var g in godArray){
  5654. if(godArray.hasOwnProperty(g)){
  5655. if(uw.ITowns.player_gods.attributes.temples_for_gods[g]){
  5656. pic_row += '<td><div style="width:50px;height:51px;background:url('+ godImg.src +');background-position: 0px '+ godArray[g] +';"></td>';
  5657. fav_row += '<td class="bold" style="color:blue">'+ uw.ITowns.player_gods.attributes[g + "_favor"] +'</td>';
  5658. prod_row += '<td class="bold">'+ uw.ITowns.player_gods.attributes.production_overview[g].production +'</td>';
  5659. }
  5660. }
  5661. }
  5662. var tool_element = $('<table><tr><td></td>'+ pic_row +'</tr>'+
  5663. '<tr align="center"><td><img src="https://gpall.innogamescdn.com/images/game/res/favor.png"></td>'+ fav_row +'</tr>'+
  5664. '<tr align="center"><td>+</td>'+ prod_row +'</tr>'+
  5665. '</table>');
  5666.  
  5667. $('.gods_favor_button_area, #favor_circular_progress').tooltip(tool_element);
  5668. }
  5669.  
  5670.  
  5671. /*******************************************************************************************************************************
  5672. * GUI Optimization
  5673. * ----------------------------------------------------------------------------------------------------------------------------
  5674. * | ● Modified spell box (smaller, moveable & position memory)
  5675. * | ● Larger taskbar and minimize daily reward-window on startup
  5676. * | ● Modify chat
  5677. * | ● Improved display of troops and trade activity boxes (movable with position memory on startup)
  5678. * ----------------------------------------------------------------------------------------------------------------------------
  5679. *******************************************************************************************************************************/
  5680.  
  5681. // Spell box
  5682. function catchSpellBox(){
  5683. $.Observer(uw.GameEvents.ui.layout_gods_spells.rendered).subscribe('DIO_SPELLBOX_CHANGE_OPEN', function () {
  5684. if(spellbox.show == false) {
  5685. spellbox.show = true;
  5686. saveValue("spellbox", JSON.stringify(spellbox));
  5687. }
  5688.  
  5689. changeSpellBox();
  5690. });
  5691. $.Observer(uw.GameEvents.ui.layout_gods_spells.state_changed).subscribe('DIO_SPELLBOX_CLOSE', function () {
  5692. spellbox.show = false;
  5693. saveValue("spellbox", JSON.stringify(spellbox));
  5694. });
  5695. }
  5696.  
  5697. function initSpellBox(){
  5698. try {
  5699. $('<style type="text/css">'+
  5700. '.gods_spells_active .nui_right_box {'+
  5701. 'overflow: visible !important;'+
  5702. '</style>').appendTo('head');
  5703.  
  5704. $(".gods_spells_menu").css({
  5705. width: "134px"
  5706. });
  5707.  
  5708. $("#ui_box .gods_area .gods_spells_menu .content").css({
  5709. background: "url(https://gpall.innogamescdn.com/images/game/layout/power_tile.png) 1px 4px",
  5710. overflow: "auto",
  5711. margin: "0 0 0px 0px",
  5712. border: "3px inset rgb(16, 87, 19)",
  5713. borderRadius: "10px"
  5714. });
  5715.  
  5716. $('.nui_units_box').css({
  5717. display: 'block',
  5718. marginTop: '-8px',
  5719. position: 'relative'
  5720. });
  5721. $('.nui_units_box .bottom_ornament').css({
  5722. marginTop: '-28px',
  5723. position: 'relative'
  5724. });
  5725.  
  5726. $('.gods_area').css({
  5727. height: '150px'
  5728. });
  5729.  
  5730. if($(".gods_spells_menu .left").get(0)){
  5731. $(".gods_spells_menu .left").remove(); $(".gods_spells_menu .right").remove();
  5732. $(".gods_spells_menu .top").remove(); $(".gods_spells_menu .bottom").remove();
  5733. }
  5734.  
  5735. $(".gods_spells_menu").draggable({
  5736. containment: "body",
  5737. distance: 10 ,
  5738. snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, #island_quests_overview",
  5739. opacity: 0.7,
  5740. stop : function(){
  5741. spellbox.top = this.style.top;
  5742. spellbox.left = this.style.left;
  5743.  
  5744. saveValue("spellbox", JSON.stringify(spellbox));
  5745. }
  5746. });
  5747. $(".gods_area .gods_spells_menu").before($('.nui_units_box'));
  5748.  
  5749.  
  5750. // Position
  5751. $('.gods_spells_menu').css({
  5752. position: 'absolute',
  5753. left: spellbox.left,
  5754. top: spellbox.top,
  5755. zIndex: '5000',
  5756. padding: '30px 0px 0px -4px'
  5757. });
  5758.  
  5759. // Active at game start?
  5760. if(spellbox.show) {
  5761. $('.btn_gods_spells').click();
  5762. }
  5763. } catch(error){
  5764. errorHandling(error, "initSpellBox");
  5765. }
  5766.  
  5767. }
  5768.  
  5769. function changeSpellBox(){
  5770. try {
  5771. $(".gods_spells_menu").css({
  5772. //height: "300px"
  5773. //height: $(".nui_units_box").height() + "px"
  5774. });
  5775. //console.log($(".nui_units_box").height());
  5776.  
  5777. $('.god_container[data-god_id="zeus"]').css({
  5778. //float: 'left'
  5779. });
  5780. $('.powers_container').css({
  5781. background: 'none'
  5782. });
  5783. $('.god_container').css({
  5784. float: 'left'
  5785. });
  5786. $('.god_container[data-god_id="zeus"], .god_container[data-god_id="athena"]').css({
  5787. float: 'none'
  5788. });
  5789. $('.content .title').each(function(){
  5790. $(this).get(0).style.display = "none";
  5791. });
  5792.  
  5793. $('.god_container[data-god_id="poseidon"]').prependTo('.gods_spells_menu .content');
  5794. $('.god_container[data-god_id="athena"]').appendTo('.gods_spells_menu .content');
  5795. $('.god_container[data-god_id="artemis"]').appendTo('.gods_spells_menu .content');
  5796.  
  5797. if($('.bolt').get(0)) { $('.bolt').remove(); }
  5798. if($('.earthquake').get(0)) { $('.earthquake').remove(); }
  5799. if($('.pest').get(0)) { $('.pest').remove(); }
  5800. } catch(error){
  5801. errorHandling(error, "changeSpellBox");
  5802. }
  5803. }
  5804.  
  5805. // Minimize Daily reward window on startup
  5806. function minimizeDailyReward(){
  5807. /*
  5808. $.Observer(uw.GameEvents.window.open).subscribe('DIO_WINDOW', function(u,dato){});
  5809. $.Observer(uw.GameEvents.window.reload).subscribe('DIO_WINDOW2', function(f){});
  5810. */
  5811. if(MutationObserver) {
  5812. var startup = new MutationObserver(function(mutations) {
  5813. mutations.forEach(function(mutation) {
  5814. if(mutation.addedNodes[0]){
  5815. if($('.daily_login').get(0)){ // && !uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).isMinimized()
  5816. $('.daily_login').find(".minimize").click();
  5817. //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).minimize();
  5818. }
  5819. }
  5820. });
  5821. });
  5822. startup.observe($('body').get(0), { attributes: false, childList: true, characterData: false});
  5823.  
  5824. setTimeout(function(){ startup.disconnect();}, 3000);
  5825. }
  5826. }
  5827.  
  5828. // Larger taskbar
  5829. function scaleTaskbar(){
  5830. $('.minimized_windows_area').get(0).style.width= "150%";
  5831. $('.minimized_windows_area').get(0).style.left= "-25%";
  5832. }
  5833. // hide fade out buttons => only for myself
  5834. function hideNavElements() {
  5835. if(uw.Game.premium_features.curator<=uw.Timestamp.now()){
  5836. $('.nav').each(function() {
  5837. $(this).get(0).style.display = "none";
  5838. });
  5839. }
  5840. }
  5841.  
  5842. /*******************************************************************************************************************************
  5843. * Modify Chat
  5844. *******************************************************************************************************************************/
  5845. function popupChatUser(){ // not used yet
  5846. setTimeout(function(){
  5847. GM_xmlhttpRequest({
  5848. method: "POST",
  5849. url: "http://wwwapi.iz-smart.net/modules.php?name=Chaninfo&file=nicks&chan=Grepolis"+ uw.Game.market_id.toUpperCase(),
  5850. onload: function(response) {
  5851. //$('.nui_main_menu .chat .indicator').get(0).innerHTML =
  5852. //console.log(response.responseText);
  5853. //$('.nui_main_menu .chat .indicator').get(0).style.display = 'inline';
  5854. }
  5855. });
  5856. }, 0);
  5857. }
  5858.  
  5859. function initChatUser(){
  5860. $('.nui_main_menu .chat .button, .nui_main_menu .chat .name_wrapper').css({
  5861. filter: 'url(#Hue1)',
  5862. WebkitFilter: 'hue-rotate(65deg)'
  5863. });
  5864. updateChatUser();
  5865. setInterval(function(){ updateChatUser(); }, 300000);
  5866. $('.nui_main_menu .chat').mouseover(function(){
  5867. //popupChatUser();
  5868. });
  5869. if($('.nui_main_menu .chat').hasClass('disabled')){ $('.nui_main_menu .chat').removeClass('disabled');}
  5870. }
  5871.  
  5872. function updateChatUser(){
  5873. var market = uw.Game.market_id;
  5874. if(gm){
  5875. // GM-BROWSER:
  5876. chatUserRequest();
  5877. } else {
  5878. // SAFARI:
  5879. $.ajax({
  5880. url:"https://diotools.pf-control.de/game/chatuser_count.php?chan=Grepo"+ (market === "de" ? "lisDE" : ""),
  5881. dataType : 'text',
  5882. success: function(text) {
  5883. $('.nui_main_menu .chat .indicator').get(0).innerHTML = text;
  5884. $('.nui_main_menu .chat .indicator').get(0).style.display = 'block';
  5885. },
  5886. error: function (xhr, ajaxOptions, thrownError) {
  5887. $('.nui_main_menu .chat .indicator').get(0).style.display = 'none';
  5888. }
  5889. });
  5890. }
  5891. }
  5892.  
  5893.  
  5894. $('<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>').appendTo('head');
  5895.  
  5896. // Modify chat window
  5897. function modifyChat() {
  5898. var host = { fr: 'irc.quakenet.org', def: 'flash.afterworkchat.de'},
  5899. market = uw.Game.market_id, select_nick = false, chatwnd_id,
  5900. nickname = uw.Game.player_name;
  5901.  
  5902. setTimeout(function(){ updateChatUser(); }, 10000); setTimeout(function(){ updateChatUser(); }, 30000);
  5903.  
  5904. //uw.GPWindowMgr.Create(uw.Layout.wnd.TYPE_CHAT);
  5905.  
  5906. //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).setWidth(600);
  5907. //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).setHeight(300);
  5908. //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).setPosition([0,'bottom']);
  5909.  
  5910. //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT));
  5911.  
  5912. chatwnd_id = '#gpwnd_' + uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).getID();
  5913.  
  5914. $('#chat').get(0).innerHTML = "";
  5915. //$(chatwnd_id).parent().children('.gpwindow_left').remove();
  5916. //$(chatwnd_id).parent().children('.gpwindow_right').remove();
  5917. //$(chatwnd_id).parent().children('.gpwindow_top').remove();
  5918. //$(chatwnd_id).parent().children('.gpwindow_bottom').remove();
  5919. //$(chatwnd_id).parent().parent().children('.ui-dialog-titlebar').remove();
  5920.  
  5921. var replaceArray = {
  5922. // Russian:
  5923. "Ё":"YO","Й":"I","Ц":"TS","У":"U","К":"K","Е":"E","Н":"N","Г":"G","Ш":"SH","Щ":"SCH","З":"Z","Х":"H","Ъ":"'",
  5924. "ё":"yo","й":"i","ц":"ts","у":"u","к":"k","е":"e","н":"n","г":"g","ш":"sh","щ":"sch","з":"z","х":"h","ъ":"'",
  5925. "Ф":"F","Ы":"I","В":"V","А":"a","П":"P","Р":"R","О":"O","Л":"L","Д":"D","Ж":"ZH","Э":"E",
  5926. "ф":"f","ы":"i","в":"v","а":"a","п":"p","р":"r","о":"o","л":"l","д":"d","ж":"zh","э":"e",
  5927. "Я":"Ya","Ч":"CH","С":"S","М":"M","И":"I","Т":"T","Ь":"'","Б":"B","Ю":"YU",
  5928. "я":"ya","ч":"ch","с":"s","м":"m","и":"i","т":"t","ь":"'","б":"b","ю":"yu",
  5929.  
  5930. // Greek:
  5931. 'Α':'A','Β':'B','Γ':'G','Δ':'D','Ε':'E','Ζ':'Z','Η':'H','Θ':'Th','Ι':'I','Κ':'K','Λ':'L','Μ':'M','Ν':'N','Ξ':'J','Ο':'O','Π':'P','Ρ':'R','Σ':'S',
  5932. 'Τ':'T','Υ':'U','Φ':'F','Χ':'Ch','Ψ':'Ps','Ω':'W','Ά':'A','Έ':'E','Ή':'H','Ί':'I','Ό':'O','Ύ':'U','Ώ':'W','Ϊ':'I',
  5933. 'α':'a','β':'b','γ':'g','δ':'d','ε':'e','ζ':'z','η':'h','θ':'th','ι':'i','κ':'k','λ':'l','μ':'m','ν':'n','ξ':'j','ο':'o','π':'p','ρ':'r','ς':'s',
  5934. 'σ':'s','τ':'t','υ':'u','φ':'f','χ':'ch','ψ':'ps','ω':'w','ά':'a','έ':'e','ή':'h','ί':'i','ό':'o','ύ':'u','ώ':'w','ϊ':'i','ΐ':'i'
  5935. };
  5936.  
  5937. function replaceNick(word){
  5938. var temp = "", temp2 = "";
  5939. // Step 1: Replace Special and some german chars
  5940. word = word.replace(/[.,:,+,*]/g,"").replace(/[=,\ ,\-]/g,"_").replace(/ö/gi,"oe").replace(/ä/gi,"ae").replace(/ü/gi,"ue").replace(/ß/g,"ss");
  5941. // Step 2: Replace russian and greek chars
  5942. if(!word.match(/^[a-zA-Z0-9_]+$/)){
  5943. temp = word.split('').map(function (char) {
  5944. var ch = "";
  5945. ch = replaceArray[char] || char;
  5946. return ch;
  5947. }).join("");
  5948. // Step 3: Delete all other special chars
  5949. if(!temp.match(/^[a-zA-Z0-9_]+$/)){
  5950. for(var c = 0; c < temp.length; c++){
  5951. if(temp[c].match(/^[a-zA-Z0-9_]+$/)){
  5952. temp2 += temp[c];
  5953. }
  5954. }
  5955. select_nick = true;
  5956. temp = temp2;
  5957. }
  5958. word = temp;
  5959. }
  5960. return word;
  5961. }
  5962. //nickname = "kνnmδενεί-ναισυνδεδ*εμένος_Ιππέας"; // greek test nickname
  5963. nickname = replaceNick(nickname);
  5964.  
  5965. if(PID == 84367){ nickname = "DionY_"; }
  5966.  
  5967. $('<iframe src="https://diotools.pf-control.de/chat/lightIRC.swf'+ //'+ //http://flash.afterworkchat.de/1.0/FlashChat.swf
  5968. '?host=irc.todochat.org'+//irc.lightirc.com'+ //flash.afterworkchat.de'+
  5969. //'?languagePath=http://flash.afterworkchat.de/1.0/language/'+
  5970. '&port=6667'+
  5971. '&ssl=true'+
  5972. '&policyPort=8002'+
  5973. '&styleURL=https://diotools.pf-control.de/css/green3.css'+
  5974. '&emoticonPath=https://diotools.pf-control.de/chat/emoticons/'+
  5975. '&emoticonList='+
  5976. ':)->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,'+
  5977. ':$->blush.swf,:]->lol.swf,:*->bussi.swf,:[->fluch.swf'+
  5978. //'&accessKey=54a2846a460ae1703ac690d21551b997'+
  5979. '&nick='+ nickname +
  5980. '&nickAlternate='+ nickname +'_'+
  5981. '&autojoin=%23GREPO,%23Grepolis'+ market.toUpperCase() +
  5982. '&showNickSelection='+ select_nick +
  5983. '&showNavigation=true'+
  5984. '&navigationPosition=top'+
  5985. '&showNickSelection=false'+
  5986. '&showIdentifySelection=false'+
  5987. '&language='+ LID +
  5988. '&quitMessage=CYA'+
  5989. '&showChannelHeader=false'+
  5990. //'&useUserListIcons=true'+
  5991. '&userListWidth=100'+
  5992. '&soundAlerts=true'+
  5993. '&soundOnNewChannelMessage=true'+
  5994. '&showServerWindow=false'+
  5995. '&fontSize=9'+
  5996. '&showJoinPartMessages=false'+
  5997. '&showMenuButton=false'+
  5998. '&showTranslationButton=false'+
  5999. '&showTimestamps=true'+
  6000. //'&showInfoMessages=false'+
  6001. '&showRegisterNicknameButton=false'+
  6002. '&showRichTextControls=false'+
  6003. //'&useUserListIcons=true'+
  6004. '&showUserListInformationPopup=false'+
  6005. '&showNickChangeButton=false'+
  6006. '&showChannelCentral=false'+
  6007. '&showOptionsButton=false'+
  6008. '&showEmoticonsButton=true'+
  6009. '&rememberNickname=false'+
  6010. '" style="width:518px; height:357px; border:0px;"></iframe>').appendTo("#chat");
  6011.  
  6012. /*
  6013. $('<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>'+
  6014. '<script type="text/javascript">'+
  6015. 'var params = {};'+
  6016. 'params.languagePath = "http://flash.afterworkchat.de/1.0/language/";'+
  6017. 'params.host = "flash.afterworkchat.de";'+
  6018. 'params.port = 6667;'+
  6019. 'params.policyPort = 9000;'+
  6020. //'params.accessKey = "54a2846a460ae1703ac690d21551b997";'+
  6021. 'params.styleURL = "http://diotools.pf-control.de/css/green2.css";'+
  6022. 'params.emoticonPath = "http://diotools.pf-control.de/chat/emoticons/";'+
  6023. '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,'+
  6024. ':$->blush.swf,:]->lol.swf,:*->bussi.swf,:[->fluch.swf";'+
  6025. 'params.nick = "'+ nickname + '";' +
  6026. 'params.autojoin = "%23GREPO,%23Grepolis'+ market.toUpperCase() + '";' +
  6027. 'params.showNickSelection = ' + select_nick + ';'+
  6028. 'params.showIdentifySelection = false;'+
  6029. 'params.language = "'+ LID +'";'+
  6030. 'params.soundAlerts = true;'+
  6031. 'params.fontSize = "10";'+
  6032. 'params.navigationPosition = "top";'+
  6033. 'params.showJoinPartMessages = false;'+
  6034. 'params.showTimestamps = true;'+
  6035. 'params.showRegisterNicknameButton = false;'+
  6036. 'params.showNickChangeButton = true;'+
  6037. 'params.showOptionsButton = true;'+
  6038. 'params.showServerWindow = false;'+
  6039. 'params.showOptionsButton = false;'+
  6040. 'params.showMenuButton = false;'+
  6041. 'params.showTranslationButton = false;'+
  6042. 'params.showRichTextControls = false;'+
  6043. 'params.showChannelHeader = false;'+
  6044. 'params.rememberNickname = false;'+
  6045. 'params.userListWidth = 100;' +
  6046. 'params.soundAlerts = true;'+
  6047. 'params.soundOnNewChannelMessage = false;'+
  6048. '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"});'+
  6049. '</script></body></html>').appendTo("#chat");
  6050. */
  6051. }
  6052.  
  6053. /*******************************************************************************************************************************
  6054. * Activity boxes
  6055. * ----------------------------------------------------------------------------------------------------------------------------
  6056. * | ● Show troops and trade activity boxes
  6057. * | ● Boxes are magnetic & movable (position memory)
  6058. * ----------------------------------------------------------------------------------------------------------------------------
  6059. *******************************************************************************************************************************/
  6060. var mut_toolbar, mut_command, mut_trade;
  6061. function checkToolbarAtStart(){
  6062. if(parseInt($('.toolbar_activities .commands .count').get(0).innerHTML, 10) > 0){
  6063. $('#toolbar_activity_commands_list').get(0).style.display = "block";
  6064. } else {
  6065. $('#toolbar_activity_commands_list').get(0).style.display = "none";
  6066. }
  6067. if(parseInt($('.toolbar_activities .trades .count').get(0).innerHTML, 10) > 0){
  6068. $('#toolbar_activity_trades_list').get(0).style.display = "block";
  6069. } else {
  6070. $('#toolbar_activity_trades_list').get(0).style.display = "none";
  6071. }
  6072. }
  6073.  
  6074. function catchToolbarEvents(){
  6075. mut_toolbar = new MutationObserver(function(mutations) {
  6076. mutations.forEach(function(mutation) {
  6077. if(mutation.addedNodes[0]){
  6078. //console.log(mutation);
  6079. if(mutation.target.id === "toolbar_activity_trades_list"){
  6080. draggableTradeBox();
  6081. } else {
  6082. draggableCommandBox();
  6083. }
  6084. mutation.addedNodes[0].remove();
  6085. }
  6086. });
  6087. });
  6088. mut_command = new MutationObserver(function(mutations) {
  6089. mutations.forEach(function(mutation) {
  6090. if(mutation.addedNodes[0]){
  6091. if(mutation.addedNodes[0].nodeValue > 0){
  6092. $('#toolbar_activity_commands_list').get(0).style.display = "block";
  6093. } else {
  6094. $('#toolbar_activity_commands_list').get(0).style.display = "none";
  6095. }
  6096. }
  6097. });
  6098. });
  6099. mut_trade = new MutationObserver(function(mutations) {
  6100. mutations.forEach(function(mutation) {
  6101. if(mutation.addedNodes[0]){
  6102. if(mutation.addedNodes[0].nodeValue > 0){
  6103. $('#toolbar_activity_trades_list').get(0).style.display = "block";
  6104. } else {
  6105. $('#toolbar_activity_trades_list').get(0).style.display = "none";
  6106. }
  6107. }
  6108. });
  6109. });
  6110. }
  6111. // moveable boxes
  6112. function draggableTradeBox(){
  6113. $("#toolbar_activity_trades_list").draggable({
  6114. containment: "body",
  6115. distance: 20,
  6116. snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, .nui_left_box",
  6117. opacity: 0.7,
  6118. start : function () {
  6119. $("#fix_trade").remove();
  6120. },
  6121. stop : function () {
  6122. var pos = $('#toolbar_activity_trades_list').position();
  6123. tradebox.left = pos.left;
  6124.  
  6125. saveValue("tradebox", JSON.stringify(tradebox));
  6126.  
  6127.  
  6128. $('<style id="fix_trade" type="text/css">'+
  6129. '#toolbar_activity_trades_list {'+
  6130. 'left:' + tradebox.left + 'px !important;'+
  6131. 'top: ' + tradebox.top + 'px !important}'+
  6132. '</style>').appendTo('head');
  6133. }
  6134. });
  6135. }
  6136.  
  6137. function draggableCommandBox(){
  6138. $("#toolbar_activity_commands_list").draggable({
  6139. containment: "body",
  6140. distance: 20,
  6141. snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, .nui_left_box",
  6142. opacity: 0.7,
  6143. stop : function () {
  6144. var pos = $('#toolbar_activity_commands_list').position();
  6145. commandbox.left = pos.left;
  6146. commandbox.top = pos.top;
  6147.  
  6148. saveValue("commandbox", JSON.stringify(commandbox));
  6149. }
  6150. });
  6151. }
  6152.  
  6153. function showActivityBoxes(){
  6154. var observe_options = { attributes: false, childList: true, characterData: false};
  6155.  
  6156. catchToolbarEvents();
  6157.  
  6158. mut_toolbar.observe($('#toolbar_activity_commands_list').get(0), observe_options );
  6159. mut_toolbar.observe($('#toolbar_activity_trades_list').get(0), observe_options );
  6160.  
  6161. mut_command.observe($('.toolbar_activities .commands .count').get(0), observe_options );
  6162. mut_trade.observe($('.toolbar_activities .trades .count').get(0), observe_options );
  6163.  
  6164. $('#toolbar_activity_commands').mouseover();
  6165. $('#toolbar_activity_trades').mouseover();
  6166. $('#toolbar_activity_commands, #toolbar_activity_trades').unbind("mouseover");
  6167. $('#toolbar_activity_commands, #toolbar_activity_commands_list, #toolbar_activity_trades, #toolbar_activity_trades_list').unbind("mouseout");
  6168. $('#toolbar_activity_trades_list').unbind("click");
  6169.  
  6170. checkToolbarAtStart();
  6171.  
  6172. $('#toolbar_activity_commands_list').css({
  6173. left: commandbox.left + "px",
  6174. top: commandbox.top + "px"
  6175. });
  6176.  
  6177. $('<style id="fix_lists" type="text/css">'+
  6178. '#toolbar_activity_commands_list, #toolbar_activity_trades_list { width: 160px}'+
  6179. '.dropdown-list .content { max-height: 329px}'+
  6180. '</style>'+
  6181. '<style id="fix_trade" type="text/css">'+
  6182. '#toolbar_activity_trades_list {'+
  6183. 'left:' + tradebox.left + 'px !important;'+
  6184. 'top: ' + tradebox.top + 'px !important}'+
  6185. '</style>').appendTo('head');
  6186.  
  6187. draggableCommandBox();
  6188. draggableTradeBox();
  6189.  
  6190. $('.toolbar_activities .commands').mouseover(function(){
  6191. $('#toolbar_activity_commands_list').get(0).style.display = "block";
  6192. });
  6193. $('.toolbar_activities .trades').mouseover(function(){
  6194. $('#toolbar_activity_trades_list').get(0).style.display = "block";
  6195. });
  6196. }
  6197.  
  6198. /*******************************************************************************************************************************
  6199. * Other stuff
  6200. *******************************************************************************************************************************/
  6201.  
  6202. function counter(time){
  6203. var type = "", today, counted, year, month, day;
  6204. if(uw.Game.market_id !== "zz"){
  6205. counted = DATA.count;
  6206. today = new Date((time + 7200) * 1000);
  6207. year = today.getUTCFullYear();
  6208. month = ((today.getUTCMonth()+1) < 10 ? "0" : "") + (today.getUTCMonth()+1);
  6209. day = (today.getUTCDate() < 10 ? "0" : "") + today.getUTCDate();
  6210. today = year + month + day;
  6211. //console.log(today);
  6212. if(counted[0] !== today){type += "d"; }
  6213. if(counted[1] == false){ type += "t"; }
  6214. if((counted[2] == undefined) || (counted[2] == false)){ type += "b"; }
  6215. if(type !== ""){
  6216. $.ajax({
  6217. type: "GET",
  6218. url: "https://diotools.pf-control.de/game/count.php?type="+ type + "&market="+ uw.Game.market_id + "&date="+ today + "&browser="+ getBrowser(),
  6219. dataType : 'text',
  6220. success: function (text) {
  6221. if(text.indexOf("dly") > -1){
  6222. counted[0] = today;
  6223. }
  6224. if(text.indexOf("tot") > -1){
  6225. counted[1] = true;
  6226. }
  6227. if(text.indexOf("bro") > -1){
  6228. counted[2] = true;
  6229. }
  6230. saveValue("dio_count", JSON.stringify(counted));
  6231. }
  6232. });
  6233. }
  6234.  
  6235. }
  6236. }
  6237.  
  6238. /*
  6239. function xmas(){
  6240. $('<a href="http://www.greensmilies.com/smilie-album/" target="_blank"><div id="xmas"></div></a>').appendTo('#ui_box');
  6241. $('#xmas').css({
  6242. background: 'url("http://www.greensmilies.com/smile/smiley_emoticons_weihnachtsmann_nordpol.gif") no-repeat',
  6243. height: '51px',
  6244. width: '61px',
  6245. position:'absolute',
  6246. bottom:'10px',
  6247. left:'60px',
  6248. zIndex:'2000'
  6249. });
  6250. $('#xmas').tooltip("HO HO HO, Frohe Weihnachten!");
  6251. }
  6252.  
  6253. function silvester(){
  6254. $('<a href="http://www.greensmilies.com/smilie-album/" target="_blank"><div id="silv">'+
  6255. '<img src="http://www.greensmilies.com/smile/sign2_2.gif">'+
  6256. '<img src="http://www.greensmilies.com/smile/sign2_0.gif">'+
  6257. '<img src="http://www.greensmilies.com/smile/sign2_1.gif">'+
  6258. '<img src="http://www.greensmilies.com/smile/sign2_4.gif">'+
  6259. '</div></a>').appendTo('#ui_box');
  6260. $('#silv').css({
  6261. //background: 'url("http://www.greensmilies.com/smile/buchstaben_0.gif") no-repeat',
  6262. //height: '57px',
  6263. //width: '34px',
  6264. position:'absolute',
  6265. bottom:'10px',
  6266. left:'70px',
  6267. zIndex:'10'
  6268. });
  6269. $('#silv').tooltip("Frohes Neues!");
  6270. }
  6271.  
  6272. function joke(){
  6273. setTimeout(function(){
  6274. if($('#grcgrc').get(0)){
  6275. $('<a href="http://www.greensmilies.com/smilie-album/" target="_blank"><div id="fight"></div></a>').appendTo('#ui_box');
  6276. $('#fight').css({
  6277. background: 'url("http://www.greensmilies.com/smile/smiley_emoticons_hoplit_speer4.gif") no-repeat',
  6278. height: '51px',
  6279. width: '61px',
  6280. position:'absolute',
  6281. bottom:'10px',
  6282. left:'39px',
  6283. zIndex:'2000'
  6284. });
  6285. $('#fight').tooltip("WWW.GREENSMILIES.COM");
  6286. }
  6287. }, 5000);
  6288. }
  6289. */
  6290.  
  6291. }

QingJ © 2025

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