DIO-TOOLS

DIO-Tools is a small extension for the browser game Grepolis. (unit counter, unit strength, smiley box, trade options, improved boxes (commands, trades & spells), ww share & changes to the UI)

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

  1. // ==UserScript==
  2. // @name DIO-TOOLS
  3. // @namespace DIO
  4. // @version 0.211
  5. // @description DIO-Tools is a small extension for the browser game Grepolis. (unit counter, unit strength, smiley box, trade options, improved boxes (commands, trades & spells), ww share & changes to the UI)
  6. // @include http://*.grepolis.com/game*
  7. // @include http://*forum.*.grepolis.com/*.php*
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
  9.  
  10. // @icon http://s7.directupload.net/images/140128/vqchpigi.gif
  11. // @iconURL http://s7.directupload.net/images/140128/vqchpigi.gif
  12. // @copyright 2013+, DIONY
  13. // ==/UserScript==
  14.  
  15.  
  16. //http://de44.grepolis.com/cache/js/libs/jquery-1.10.2.min.js
  17.  
  18.  
  19. /*******************************************************************************************************************************
  20. * Changes
  21. * ----------------------------------------------------------------------------------------------------------------------------
  22. * | ● TradeButton erscheint nichtmehr während der Bauphase eines WW's
  23. * | ● Layoutänderungen im Forum für die Smileybox im Editor angepasst (gab Probleme bei anderen Märkten)
  24. * | ● Ausnahme: Deutsche Schildersmileys (Dafuer/Dagegen) werden in anderen Märkten durch englische Pendants ersetzt
  25. * | ● Extrasmiley im Forum hinzugefügt
  26. * | ● Kontextmenü: Vertauscht die Positionen von "Stadtübersicht" und "Stadt selektieren"
  27. * | ● Extrasmiley im Forum hinzugefügt
  28. * | ● Verteidigungsformular: Ohne "Uhr" bei anderen Märkten
  29. * ----------------------------------------------------------------------------------------------------------------------------
  30. *******************************************************************************************************************************/
  31.  
  32. /*******************************************************************************************************************************
  33. * Bugs / TODOs
  34. * ----------------------------------------------------------------------------------------------------------------------------
  35. * | ● Beim WW Garten wird der Next-Button falsch positioniert
  36. * | ● Aktivitätsbox für Angriffe blendet nicht aus
  37. * | ● Smileys verschwinden manchmal? -> bisher nicht reproduzierbar
  38. * | ● Stadticons werden nicht sofort geladen
  39. * | ● ...
  40. * ----------------------------------------------------------------------------------------------------------------------------
  41. *******************************************************************************************************************************/
  42.  
  43. /*******************************************************************************************************************************
  44. * Global stuff
  45. *******************************************************************************************************************************/
  46. var uw = unsafeWindow || window, data; // data??
  47.  
  48. var $ = uw.jQuery || jQuery; // (Game || Forum)
  49.  
  50. // Game values
  51. var LID = "en", WID = "", AID = 0, PID = 0;
  52. if(uw.location.pathname === "/game/index"){
  53. LID = uw.Game.locale_lang.split("_")[0];
  54. WID = uw.Game.world_id;
  55. AID = uw.Game.alliance_id;
  56. PID = uw.Game.player_id;
  57. var unitVal; // unit values
  58. var autoTownTypes = {}; // town type (ld, lo, sd, so, fd, fo)
  59. var manuTownTypes = JSON.parse(GM_getValue("town_types", "{}"));
  60. var townPopulation = {};
  61. $.prototype.reverseList = [].reverse;
  62. }
  63.  
  64. //console.log((new Date()).getTime());
  65.  
  66. //console.log(GM_listValues());
  67.  
  68. //console.log(GM_getValue("de48_ratio"));
  69.  
  70. //console.log(GM_getValue("de44_ratio"));
  71.  
  72. /*******************************************************************************************************************************
  73. * Images
  74. *******************************************************************************************************************************/
  75. var img = "data:image/png;base64,"+
  76. "iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhU"+
  77. "IIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/S"+
  78. "MBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFA"+
  79. "FgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCR"+
  80. "FRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf"+
  81. "14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c"+
  82. "93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRBy"+
  83. "AgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cw"+
  84. "wOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUM"+
  85. "yJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6"+
  86. "WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9r"+
  87. "kZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX"+
  88. "836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/V"+
  89. "HDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostq"+
  90. "i2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9"+
  91. "JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9j"+
  92. "L5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5"+
  93. "pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwv"+
  94. "SFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlh"+
  95. "bL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1r"+
  96. "gV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi"+
  97. "8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZ"+
  98. "zG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7v"+
  99. "DvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9q"+
  100. "wHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8"+
  101. "o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl";
  102. var img_small_transp = img +
  103. "/FRgAAA/1JREFUeNqsk0mMVFUUhv9733313quxu6qosrppGpqhuwkyCKh02oEYp8REEVwYExOXxrhyZ3RtdGPc6cKdCcbEEOMYjEENoiBGwiw0Kj1QFFVd45vvu/e4kBA1ATae7cn5c875/"+
  104. "h8AGP6nMm7VvPfpZ9fsqKmXjaDTbbrUuJ2YAABh5yqV6Y1PViY3m0wYi9XpLTxdGhNXvtm/jwvxECPKVoeseqMbNW8rxhjX1fWbiqlM/qVus8HjKOHF6ijLj64pxPVjh3uhPhxr/czaWubj"+
  105. "S3WvccszTcuJimOr62Lx5H2PPLD9znO/L3HTQObiVx/1OudPdlsh5nu+dk2DnqoOW2c6bjK4qZiSIfXqC/FI0Zl8/ZXnd96zrmRsykaM+22v3nYLVqYwAcYnu31/a+QnU9xgjURj6b/wbgB"+
  106. "I4kgHYYSpqQ079+15rrpuImfsmt3hPPr47vxjD8/WZnZtHV81Pko9P9hSr7dmGHCMgKs3fWC5PPzgh/vf/pNomWRwiig5T0RzRDRHMjxD/f5Z+fPxz4P7Z7afFsC7I8PW+D/G2Y3NVpas7O"+
  107. "ja9XvefOPVPaaZ8NBzAQAyjiEjiSROoJKEV8tDBuP88qFvfziYNvXKXMaKvFCtJsJVMbuxzEHYvbDs7i3msw9ImTIcJEjn8mg1mohjhSCIAAJKpSEIYbHKisqIZsJd7nuLts1eY4zNAXTcG"+
  108. "AQy1fPlC5WC/WLgetXvjhxlCF04Th6FfAGkOWzbgtLAocO/4tgvp/HZgS8yFy5cnPJjPZNxxHqt9TtS0WVRyttkm5w2TwzbCw0PBw58jYUzx7F9x12Y3LwNjAiDKEGrNcCJn75HNaOgk9go"+
  109. "ZsW0ECw0DPZ+KZ864jdDsJGiY5gm2z09Vvhg1Yp09dx8H3NLHTAGtAOBUhqwbY5V5SwmKja8QOLaIMGlhocwlgeTBHuXB9IFAHGlHSjOcKIziC/nttWqW9YV4dgC7V6IUqKRcwRGS2nYKQY"+
  110. "Fjt8aIRabPsB0q+/J9yIJ99/ZdNKulMGpk3+07h73s7hjyMGGWuZv3gwIIoWOK+EGMTwvAtNy0JXGWyJb/ASdNq6blwwuhGM5dsXK5UWgMeV6QTmICR0/QdtXuDaI0RzE8EKF+ZaLpU4cpo"+
  111. "bLX4rs0KdMK6ZUorXWMQASpu3UrHJtr1WpPcFEquxGATq+BzABbtgAAdxiIBVDlhM4Y+mU6aRnhZJrZbf1Y0K0nzqdo0opLQiATqJl7Q/Omla6Y3Oec3J5RpwbjDHBGDMAKCKeQBMxQOvQj"+
  112. "bQMmxQG80SUXI+lZJwbtkiZOWHbQ8IUWW7wFMA5A+OMEQdjDACISIGICNCktVRSeSqM+rGMBkqpAETJXwMA90ECQGSWVcUAAAAASUVORK5CYII=";
  113. var img_big_transp = img +
  114. "/FRgAABHZJREFUeNp0lMtv1FUcxc+9v3t/j3l0Xm2npaXYkhKshVJBBFMSQiAaTXRlTDQaSdSdf4s740ZdmJCoGxcEDQsT0LhQCcQHFpRpqS10Hp2Zzvzev3vv1wViXMBZndUnn805DACkV"+
  115. "xyfP/3CO/lq9VWVZguTyyfs8UMnsHn5c+R/+TJo3LrzcTOWF1zJrm+0oxSPiQUARqWBCv3vm43b30b9btvJj/hMiBt687ev5+j+VYupn1q72SLAKtWCvdYPMvMoGHtYJDBqgCUNDESxvGa7"+
  116. "bjRTUGPnDlVev9sMvvju97bxbOtt1+bXiOjSWjPKHmkGQJY8+cZLT9Y/M8asBP6wGvr+RKcf1rf74dLte2Gr76c3GLAqLXaWMeb2A3XnsbCyJ46fPzp95rknatO1gnNquuSeMYSnh4Fe0Mo"+
  117. "sJ9rUE2Xag0jtELAyWXWpH2R3HwWjRBntSf7kywv12ZmSh2enS87S5MjY4XqxvDCen8k7cqVoi1cAzA5iHSpjTk5UnN6IJzcGoQIAiH9hJjPYaAfZjtYGRARLcEyVHMyVXQQp4dhMxY4yM9"+
  118. "nohpOrLf/oxVutr3aj7FQ5J/MALgEAf6hoW6wwlrcrBEAZQphp+CkhIUJiNCwO5B2GQ/UCXlucGD0+VfJ2A/VNmpkjzxyonP2/GUYccez0XG051kCgCC5/AB0SEKUKUUYAEWJFqBdtPl/L7"+
  119. "b2y1l0fL+c+nd9TfN9zxIIAkJMWP1f0xHthqmtbgwSkNSyLI9EGXHHEmhBrgs0ZCIS1bohGNxwRgh+fmxzpONJif2wMppjjOAdreXZx72huf6cb08n9NVZ3BKqejYpnQzAgMQZ+oujPls/6"+
  120. "scKmH2M7TIeuK+5MlD2xujn8udWPzossTag8PpKf3VNAYydkV9Z7mB3LgakhCoyTNtiKU309NmrJNzRjOxaYZ2G+ViqWPXnk1lYfrX50FQDEvn37mrY1uLyn4r11bLaCa3/1MIgz7AwS3O9"+
  121. "FSmXUAGM3F2dLiyeeGkXBlSBDaHZjNPuR6fnZRc7YBUMExhjjoyP2u4dnSx/tHctjN0ixvZOAC4ZUG600tSbKXnpgujCttbHudSK4jsDqeh+NVvBDmOg3U2UaACCIyLR3k9s317tJ3ubOeM"+
  122. "WDKwVcycE5WYyxSVda6PQibO1EEBbHrp9gu+dv9AP1AYDGfwvgnDOLs9h15HQcxQejKLEEMxAgWGSgjUYQJhgMYpAxGCsK/N0OO83AfKiJf8I4N0TEAEBYtqw65epBXSx1ulyZ1AToBRy2y"+
  123. "cHJuSAikCbELAOXGjsRw4Ysaj7lloqJ/2LYbv1qwnCdAC28YnHMLldX7NGJZZL2YBjH2jeKaelxSMk5MUaSjBbKMJ0BjJMsOVYO5vm036mpKAyyON4krbWI/GDXsM6PJsuG0nEqhksHDBZY"+
  124. "aAGQxDgDYCwYRYYIBA1msjiOhmngN7Io2qKH52gJYQnHEYzBllI63LIsBsbBiDjADdiDA2VEMMwARForMtrEBKRpnGiVZRpE5p8BAORgaeW/uJkgAAAAAElFTkSuQmCC";
  125.  
  126. var alarmSound = "data:application/octet-stream;base64,"+
  127. "//uAxAAAA6QBc/QAACRUQu0/NZIICWYFd2cBkIlwJxYfn1AhOS5/5f/P/5/iN/8u//S2LGQbkFAAgAAAAAAEx/AAao4WFY+iAytfRdMVkAhsZAOhkDjwkbbZWmFl0mRpXvytOG2luIw1Z6b"+
  128. "yPt6H2urgQns4a0CxzGUCGEJsSlT2l5EhzFHSiIky7CQgICLz0t+afZ3mcRhyG0hlORTCHH8RUr2u4XqXknUrLvpns0Z+XgwWkgY0tg6gF3X534ZjLN25ls0w1Tqbw2ilEZXLJyOQ9duT8p"+
  129. "13mv/3Idic5hhn3+08Yxs5WsbtWk1vW9f/ce/n+Hecx3vP995bv7+xeh9g76Uq83W/////+au0vMv/9c7nyVxuL3GsQ47CpIDcPB35BXcv//////////////+b5j///////////////wIsS"+
  130. "Qbaw1yEKuZ6uWRzZAQwAAEAAClP6ACxBNO8DILOgFPgZSwkDBhYhBSQgAj/+4DEEoAa3d9p+akAAiazrP+wgASoRIaEvusJEkRNw+yAni0JSLbD5FaEaRRE+LOApYbAICkMFhDLJMFgihFC"+
  131. "wK8J4IaWRvJEkaEwkeJonyUKzkAFwGxoKTOjJFsmiXJtEihkorICMBCVEV4d46CmTRMk8Q0xJ1EiRqXSTIw6ocokCKopMjmRBlPds0QOstJHTU1O6C1up1fW6vfV+vUidLyiuXR3N/cySWY"+
  132. "omKX/XZIwRGVOkQdAmzf///l1jSbKMv/WKkwOuS5GiKRAAgr9BAJIMAAOlNBGVxEq1TvC87sPxE4KlkYwkXBu7wL40b0Wr2g+RgJDDXWYJVkTeeap6iPs4WRbXhSVs44ptoPNLJKegayMQW"+
  133. "Ie2aBjlNY//7+f4SqQo5BlpSDuUfZLGkXDjoduLWpeXi3g6ebsY3///HDd9/Q86zoNWmVJGWHWY3jqrIYiJFAgWSl+zWciOCsCL7LzKFOIdGyJRtUVl//7YMQOAA21lW3sDFVqH7Rt/YQWt"+
  134. "B4hfbP9ugq0k/3/5F7FvGNu7ISvYkrZhFiMDX/+lciJYpkfTmd7HRtwo5V7qTuc9bKv/9HWepHktZXV3X3fZEZG1rR9rI5F//b0sylszUEk4GXzoAkiEILRU1ZcwKrD8DBEMEJhbpuLPnuW"+
  135. "4/0Fx/t2RRRhcMNzkDgTMMWb1DFqW6DcSCjY1BDxxdA3Pe0ZKJYU315shrUl7Ue8P8u40u0QYRHQKJNogUinsWKcTlC5Z3Yw1kj33so1Vce9CNv08/p//fS1mQnvq+ZiOlzIRXD4uqkA63c"+
  136. "edUFKe5YwMQEAGiXu2cGIgZoOyvYqkQCrXf/7YMQLABERn3PsGLdhhhvvvYMNvIS2ZblPPsAoYftdtUMdpeWt5U03HH5a3CqlWxdwQhByksIXUrQQett2Q6CEmV0Ydxnqrs+/WbaJ1JI0Kz"+
  137. "LS0MfBRyoQ09ksmSp3O/r8s6lnu39PX29/6mklYks/rV2LNac6uPOKBZBIilBjCIkYWESCvrn9xFIjEAm2p+5UZXn+4ktRURoUFQQPSs5grIpFZzFDXIIlnt/SJpWHEguMZszc8edW092js"+
  138. "/7jFfMbGaPndttgrSSdvLdwBzMJD9aV7QzHJucJ2///kNHf8cIAcQZRNmwZfLk5BjEAkmF8X1CyiYYIAkSHfKBDIXIZizp4yv/7YMQOAAzs+XfsMEvhyDHuPYYV5GOhPsdtPWX70s2QlpMc"+
  139. "WJBKbQgPur3zvE35Mt91bLkOtglnPVlKeKCiSBhbSoMwhjvTtOtUNlMuyIli9/pcgkRv///Ox//w64xpVbW1LkAAIAAgHsFtQZFqIOm1ELlVuWiu9bz3T9DCbTN6XMmqdXvd+9c4KIcjMjm"+
  140. "hcMnxwDsI/TlL7KdE2sMIJwEGIc6VWgiySkzELqj4wSBxEsJB1itJM0hWkdzz3vdpDSH2W6+5rf///+n///lFthAO8rW/23kyIgIbSeyHCjkFKBeIyYcYRJXAyGyw91JLZj8In69G0uIOuP"+
  141. "9X+vaI7QmfSQekfP/7UMQZAA4tkXnsLFHh0J6ufYYZdDT2PvXZR93N3dUfp5+jfbFxV3L9i7/qFjl1sL9Nj4UXqSiIKrGHdHclFe0zr///////shnP9fT3qzUfkgrRcfXZqOoAAABAroltS"+
  142. "EoR1e4hUIKAyJQR0GftDlhYXGJ0M6vtAXD8pOwfse1bWQggTDl5xoR3lh4ojfucSu7/d3ZQWNCiot/t5cZjv67Muik3/Rl/KS9lhLq1S2j42Z/n75UKBAs8APv//9bvqa1wsIjqGyIold+4"+
  143. "U0AAAAD/+2DEA4AQwZFv7DBR4cAyLv2ElXQAdknSpAyqEDSQIUSiOrpc7xRGBqdz529AcIeNx1tt+PS4WvlusK1QSWDgO03OQDkuIBmJJ9+T9YYn52aT+Sk81lR8UN7t5LVMvTK2vfL/SB2"+
  144. "dtGno3c060Zz1f/RZBmYrmN0faroqf///7/6NIl7EUxBBxAIzQooLJBAQ/taT3siHMgAACUX8kWTU1N4sIWHUATkway3BmjfxDsJEJZsU0CYWmn/PdySNGIVXQpDkUDGj0VmlK5+6qx5ziA"+
  145. "0oBB5Ss7nEEbvNYwM45nU7MZRooWU7lGKyqb8l0RK/+n///7vvMn+/6t1IyKNQSNPf6c//+2DEAIAO/PV17BkS4aea7z2EoVzbc3EAAAlJ+pDAa6omAqvOBFo0rBShkbe6nn5hXfnYhBFh5"+
  146. "2FyORVE+kzo/lWDIGLlxQPoQtK2nSvLR3dJKSWpAOh+J6dEq2iJWpmrRRYaYSpA9qQdVEK10o9qvip3vU8EX7nMIa//MsKHOpdNosIwVDwM0Q0/0b+1EsgAICaU+IEUhsNnJELVEZExk4WS"+
  147. "tNdl2UJoTskJEmcGBOIQeZXJVHirqMYIcRzBrMQgxzFiPSZpIaiKsWgG8W1MY8VpLTFVwKbHMMsakhq40sUHhMNgc4ZSB1ipn//8y44z/XcbIl3fyacxAAAAJeZBhhHkJBH/+2DEB4AOQYd"+
  148. "z7KBTocSwrn2EFqyoaKFWEhmUqFKWPZDGUHz2XKC9QwVCoJZ+/NsGgwNEtKuId6AseqENpSZMDodVzPP+/Vpbig9GuGoWneL3WEiK+DQ/WIQQwVFRiMhBnungQswZWPT/////++b/X/93YI"+
  149. "tb05qvyHhEAAAABVhSVARpGIeAkQJU3q33fa03rvyuDLNPeppI48Qj1luzNMonBVm9OQsPFkAqLaGVbJIzxkw38jb0um02kdj36b9mlllIOPiELHi24CKR1LGnchr29ZnRtf/////6uj2//"+
  150. "b1nSLIEYJRqCyq9/HZTAAACBPhCwwtQD4ZqDViFSNsGR9YjaS//+2DEDYAPhZ9z7CRR4cie7r2WDXyWNZlMbiMzTRSGohMLCMTGJhuCmzndznELMIEDGoDGEIgMrr192ePg3U9jWVCUJLTv"+
  151. "LjClT9+VStikmYZeUqEjEABFbf9mBgIcAQz1vN////87FbU//znrPuudXdW+CKX03vyzKgAAAIB0IkSIgjuGMsUZBEYidaClEtptXlWIEUbpdKYdJOeu6fHhuVnIufmuXyz9XtUrY6NwmJ7"+
  152. "fJwy81hnQzWmzIzsQJnZSf2yNm1IrRQ4s1xQOln/0v3wYYS0///mkHepaDyhQ0skWCjTxQXCias/XaFYAAAEA9kAqGvyZAZxILUQoQHM3YtOuSwD/+2DEDgAO3YVx7KC1oZCXLr2WFSzGJw"+
  153. "NUmquUdyvS6CIamJuHYdu+R0TVW5krOhLGMKH31OvUr9V15J4oO7lEpoqvuKbptTz0iQwIU2Zqnfz1/cBSxEUOyv9vL3///6tucn/qtcw+5yCB0VAScmzXV5TOrgAAEorpF+SMcwxEFhQpU"+
  154. "qPBduqyMYDnQJDYvri5rJBRvGxIjOj2OCy6qk63O6qKIIihla2zfIpxcaOD4YVJTCTuln7FEBWPFrVFhIkXAdqCwheHNf//9qI3Qx6MYVAra+/XiWcAAlpufQRigiIICLKQUFSJOpS3zUWl"+
  155. "uxQSXkZldn61PUOMC2TuH/8zuNj0gCD/+1DEGIBOoY957JhR4bwZ7fmWDTgZJTHu51bv//vT76bErUdZF93v/r5/7iTz3ZrBtelMRTOIIooIYZ02eq6mbt/////8zbFX3RZ0qejKjGZAIju"+
  156. "ggEQ9jN+nZUUAAJwVybG4LqB8yxwMKz0RiS1jQOHw8OtkRcV6kdcFJgbliT2x12/m/bcWLcNh/UWUKCzEmRl+yCAOj2k6FOFncjNDY8Fmklo5bAAM6MHQVUPP7nHgqG///yyVje54KiJqA+"+
  157. "sgZA7HqIq/jL64Y3QAABBJ//tgxAQADsGHc+wwqeG4sO69lgk8fMkaMoHxHNoqUeUoOl4l41gYsE42JbLsLyd37yt57si2Cae1TkozWrVr03Lq5KpGoPFw6pujqX6Krqoku0eNO6ILlOgQC"+
  158. "IwzGQ1Ts/0uQVIYm7mXNde6J//f06ucrm/oqZnMpnFR9CiDjgwzDgze2miFEiAJRXzDoRcwMqdJAOz1CyH2fvcB8eWmTE+MSYvPVdl8D1bUZp+X9ooVLZySJlq2V+l0K7BmM7qzKsjEarlY"+
  159. "nTTckhwEUlC3Y90UlWX8spDHMyN71ev/6f1rRzrqf/e6WpLuGASB8HL0y9XM2ZeUNSAcan8IXihGoIJkKlpK//tgxAmADvmPd+wgU+HIsS79hIltIMOUPcNzqCJuxG4xf+AZRTUVDduV5gc"+
  160. "ts4wJAvh8Xcf9xtwsiIpRZpIrETPu7uQSbDKNR6+OKqLOuFz76eID+mFaShpMVXp+COYl5tkPW/+/9OnvSczOdf7MtS5OtAkroGIi769/9iGUVAJRufUJQX2FuDVi7oigWTbOsAulm8zA+B"+
  161. "zIj1CzWJ4sntRpVSKRprCOHLKvNgRgdlqzVSc8IHKo51IjpuU8yoisdHBuV2EkDqCFuRxVmaum9lFmIrX/////s7k6Nf6rDIqEdmOVUKgyNTLosCTPqJgxAACSbm1CmgUNNo0NbXUDA0Yiw"+
  162. "K2Z//tgxAyAD3Gfa+yMtwn2MKv9kwrInsFLtzhEgoKCtMX9f+8+61qOtfdZvm97nXGg2xMZtgxbKqnpSB7jB0vd7ReVB9J4Cu6MGEB0Mw7VAghiEIRqMSbtvKc56f/////vIQhaa806vU53"+
  163. "OZRc7GFEQ4oJmMclh7ka+odDAAAAgAyExhBi84wDrKLPKO0gEBXhPNNmYFf+Dn+d5u2Fqdk+Oqan1BgUGh1hwODQCr9f2J1PWswit2F0fvmoSqvBBTMme5newNhVLm2cilI7BqyFspUUEqr"+
  164. "fmPQ1byv/+n+//6FpaZyEN0szPdWWVbRQsDo3PSyLD2vf64hUQgBjberJABdIGuyw//tgxAgADhGFb+wgUenMsW39gYq11oVqSQEhtzVTgZ5YkyjGAcbmd2gv05jYwAwCoUIEAczX8aGNaH"+
  165. "8I9O68Z6zddrU20F9RDM1d91bxA9qVhK0TFKUSKVg7OeTR6ylKMQU+Tt7V///+lVltv7JItFWncZLyXO25dEUgRmbftNF0EIheXDRVL9DQH4mVeSduEViEYhV/kluZ5a5ndieTzX4dBqrsZ"+
  166. "xRFBHod0+KQV6EBGhBQguSrxynWJ+xG6SvMXZoZltNTJ37f56vcDNDlVEbf0yv///bJy79mciULc1UQ9xglITcFrYV/uEYDIAAMkn8FGS8xpcZVEGmRKjkkZkBkp0CG//tgxA4ADlTDY+ww"+
  167. "acnPLG19hIlthHi6kaemPo9Ko/DMvC88RNXYh9tHWuzPnyGcKM8IWBl5cQYmK55mZZGfgiooKuY7c8aXAlyW7MfDSAzujQ7w3L///OBPSUe8qWlUfu2uJ0FH+UsCnb/mf1QxsZADJE9YO9E"+
  168. "DjLsGkVrV2WSUPbCzOKKmDAOxERKlCCbdnhA9z+ekrsy6dljdFnggID2NeR4Upyo+UG5SFOx2Y/VqK1lRiI4Q5hQMwIehBTCJzLrkHASGfZfJ7N6r7/80qH25mh4x/EyJ5ZPOz1Xrv6rf2Y"+
  169. "Y4QQDtjv9A9Gnm6A8eARgoTiaby6thcEwqrzLte32ChQK8//tgxBKADlWLa+w8ZWHVLm09hg01HAVJISJBRxmIG5BvsOsqkVOOQL1V9SZCM6Rc9fQ+u65w2rCVYIsQQoC0VPM4SJDUz9/89"+
  170. "/9fX/Tn+nyX3emzfbspX6fa2cFzCoEcI51N90OjSQgHdXPqBBl9jwPBwQQBYVdlEzEXD8EpUfPhIgqhHQsSupq/mavLhb/u8hQWnVzmZIbVXCHrnoQtmPZVPYlNWKd/5bN9jQdyCoCY1gM3"+
  171. "0Js7pDMjDZVzLll/LL//8+wvzl/ukz/SFrMd3EGjjEiJ/ub7z9pmaDEArrL9ZSPcE0i60a0pCZ733W5tI0FB3ZJAq4VriSPZ76jBMiT3f3UA//tQxBaADe2DaewkS2ncM+y9hgz1fzulwdU"+
  172. "R1UqEOqIrAhgTJPR3MJVzpO6KyKh7hWKSbCLSxSNB41iOjr3tlfZJzehLro3+2h1g9tS/fN1Epgs9XmzEN70IsKRgZdHPacElzi1A98BCQdcdopOCEDb5mWS1VkrmY+sll38eeXFH/EgRPs"+
  173. "FDUqx12q4KESrzGkdAtSG8DVGVaYmBYdtbSrn84ycHBD3Uuf55sJFEMRQnp0yf1LkiHn//P//+2WT/8+r8Hh7/mfNSfYiKGJSqbv/7cMQAgA+dj1/sDLfp1jHrfaYM9PtDVBICZI5dRRyAU"+
  174. "yvcUtKIKl4UcIkpk411/IDjX0UxK7eFm5S1LWOqPc7Z7Vw7osyJvsJSjxIpLGRjhmt9WcnFSEjLz3kCkFJwfYBvkSmQk2HzIvKa6aneGZfnG6x9dFkYtmn9kH1i767dVSiIVUVchHaGEUOq"+
  175. "KpjN4hdXasiGICDG05IAZIcJByJrLQg4I6qWgGwiGTKY5A8V4DpK63ZfHu7QkkptTb8ZypRtUVzVWEoZeLkyXhmoKRSpbTn/7hvSr3WtWFOYLNJA55KR45ORL5MxHeNuXP8+pw8pWa+S6Wc"+
  176. "1+EZvDOIxll40Un6KOaU1n8lqdDMG7tZdzEBoZ1anA5xfZc5AVcruuNF7kmcqm7QyTl3QvH3PiLITZzTrJfxua0P/+1DEGQAPKY9h7Bix6cSvaz2WDVVj7TTMn4/fYn5CQq62LfTWZOG13Z"+
  177. "vCToOjubSUqjZzo/N0+tVEaon6LrdkUo+/u7RVi2+ZqGvQWIQo5ild5lQIsJzC8+mE4m810ZmIgDjaVkbYARE1z+q0FgtcSsbII41JyFwQbxlAvc5VQI3nA6BDSGehEZOpnVQJWpelkITbV"+
  178. "rVUi3Mzp7+ebLIVpyFgobZTYvLv+00nCNURwA9TarCX7TIjnx49/83zM/y79PO7Qx+dpSdKU54nSs/8//tgxAEADnjXW+0waOnjMWs9h4zlZ0dDBytyWw1CkwQE4KowJ4CihVWAASvFvN+G"+
  179. "JE0iNj8VyocrKLt2QpYpRwVIjHY1Iq+1TDXnqbwvkdzY7qYJR4dBk57xiDXc1JVzFli0O++PygtDVMuwu2MM4lMlyEm7Avl29fUvu1+8O2xrJGb/n9du7uWR3NAbscltWqAjCbYAaCNBByX"+
  180. "ZGiSwp7Ip+f6NhyPGO/dBgnuvQxhvIhLUGRijIZyEkbptyhiPrvUpBl4e8I2EuVU0oR1j6fFKBR22JS6XHciUz6m28cRZoju70ZCRHfMnhpzcuZXRD79Wn8U6R++h1BaPTMGiepu4NqYE//"+
  181. "tgxAKADgkxU+wwammzGen9hgzlJJtNuM2Ef0AtaQlUh8W/aNMN0ZM0gSjIFLMlcNaQuXJgdMBd0ahQpzqs58I8iUy4bVk+qRriHw0CNdhE+ZE0FhDm0FohJsTVfbOfs2vMyvz/JjTpUalvA"+
  182. "wXH3jGF8cjva5+u26nsdxp9f+nnKdVNTIEjCSkiRYYsmIBwwsClWCb8hgDATPWBh77qvcbUEolOrsHCibNKtko66feYMYxIYEDGVwu5wowx25KsL/P6xZehsRilMG/WS1Pf5HMcV0bu/p5i"+
  183. "H6tNen2+3/Ul0rvyzRUlD+9t9v6le5hWRSIAYWYSij2Byj4CYzIUrX19VNc9//tgxAwADcUPScwwaumwG+k5hI0VODzRVWmDK1dFFXEzzaWGq04vClhnCU7mhohpfQjUVsaGpuRSsZk8MyI"+
  184. "zPaHPfDEpxNvMs5SSysrzqpmRCPJWCva2t9dX/6E5at1ueNXtG/35covQteFNTMISGQWyzRZVSBUaxBjQ4ZU6bsRVsBoRgMvT0FhIhBQale6imMUOMMGO0My3mtw5bXBifujMZd5q9KF+G2"+
  185. "4ap/mRBkIlM02yFd2oxwKfcBFO+qfWWjriFvpig+PAppu//T++Xrbq/1pcsv7VepqIZVULoWYeqghM5DUctE7SWaFyDrJyQF6pwRj5+zLklYUvBypGEBChyqFh//tgxBaADkWfR8wwaOnmt"+
  186. "Gf9gw44lDmxOhUzD5LE9lpHCv9PbPeIghFpk+q7KXD3SXKzQrqRZKRxDdYjkxJXLYy6UPLsP53mn8n+t7b9/K5Hl/0m6XLCUw7zpEsiopEASRSiai7yB4i6gcsGJUCX60hsrUZPATyw0/VJ"+
  187. "SZVqutJb8jFvclS0M9Vn87or89TZs74mY5cTXqfO7jvUF0w95x6zWt0fOY0z2hEfzl5rmAhjwsVy6OONDjMZ7X//87J9LMvNfLfI8/lu3M51dShysVXCHBlZqGZkQxCTTjkCEMuAiwAlHUv"+
  188. "nASj7S29hbyz7+znakagcEYrZdEO46+reOBtXpKRW//twxBiADuWjQfWEAALlI2c/MvAAzT1FJwYfSxS8VTXa8DuKofjbqrRY65v5uri2mFfS5iab5S++o9de7/n/f40/mu9opevueOH476"+
  189. "uofRevuJiv65q5eJmKxjKju8K5sxIxmscVr1kaTBQLQiao5DnCQAyAgxqVXhbhXYYQmK6TV2BM7TiVO5SrxR0QpKnMfr5RlomE4xppTwZcJJxQbiciVVKgSa7fNC+qWeC+UacX1mymguL1d"+
  190. "I8yVldEqqu2KZLzPGJbjw2VzTdFOkILIp2BkkY4jXCRDBA0sQswYMGDFwrlczUrm2t6pne65mx9V986i+NYkGhMpAIDQfmHLmxC5jix4kQW8UFRfQhI9H/5Z//9Km3NrpPr47bZJJa0kUAH"+
  191. "qoVrKyvnyBEODlHzBbWgqSDaYSfLoP/7YMQSABTBLTW494ABmxNmdxjAAB/NE/kuhbmphdBOQ0XiGopwen7MkCsJar1W1qhbR7AzKU1iwmjRMq1XTwYLc3ba0+/nVD9040aHOGsoc+YZXiv"+
  192. "v3r+sS8VRu6RMbXL5Wtz3wpvPaFLH38WvTe8S01muN6tvV66zX5x97+90x8YxGEJ4JHQaSpcxKeoclKj0k3Qj/+1Ftx26XX+f761uNsAgCnVrEdzQ5afA/ShkfD/gjiXtUZINxEJkDK0GGa"+
  193. "oO46nLS4yXhQTDwSzM/A4JByYnuef3fA4eIiWfr+llpcZMrZuvfmCADD4SDs8fWfDG9YKiI9HOgg7/8EJOYFAoHAwGA//7EMQDgAk4zaG41vAAAAA0g4AABIGAYCAIAACojw8C6JngXQX/w"+
  194. "AmgRrwR0ewnv5BLqjP/JIaQtJ0YX/xmDkjxSMhhv/zZaLTIvf/+Yh1YK//JEmf/6qpMQU1FMy45OC4yqqqqqqqq//sQxAgDwAABpAAAACAAADSAAAAEqqqqqqqqqqqqqqqqqqqqqqqqqqqq"+
  195. "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqr/+xDEMYPAAAGkAAAAIAAANIAAAASqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"+
  196. "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqv/7EMRbA8AAAaQAAAAgAAA0gAAABKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"+
  197. "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq//sQxISDwAABpAAAACAAADSAAAAEqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"+
  198. "qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqo=";
  199.  
  200.  
  201. /*******************************************************************************************************************************
  202. * Graphic filters
  203. *******************************************************************************************************************************/
  204. if(uw.location.pathname === "/game/index"){
  205. $('<svg width="0%" height="0%">'+
  206. '<filter id="GrayScale">'+
  207. '<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">'+
  208. '</filter>'+
  209. '<filter id="Sepia">'+
  210. '<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">'+
  211. '</filter>'+
  212. '<filter id="Saturation"><feColorMatrix type="saturate" values="0.2"></filter>'+
  213. '<filter id="Hue1"><feColorMatrix type="hueRotate" values= "65"></filter>'+
  214. '<filter id="Hue2"><feColorMatrix type="hueRotate" values="150"></filter>'+
  215. '<filter id="Hue3"><feColorMatrix type="hueRotate" values="-65"></filter>'+
  216. '</svg>').appendTo('#ui_box');
  217. }
  218. /*******************************************************************************************************************************
  219. * Language version (german and english)
  220. *******************************************************************************************************************************/
  221. if(!(uw.location.pathname === "/game/index")){
  222. LID = uw.location.host.split(".")[1];
  223. }
  224. // English => default
  225. if((LID !== "de") && (LID !== "fr")&& (LID !== "ru")){ LID = "en"; }
  226.  
  227. if(PID == 84367){ LID = "de"; }
  228.  
  229. // Language Array
  230. var LANG = {
  231. de : {
  232. set : {
  233. txt: {
  234. dsc: "DIO-Tools bietet unter anderem einige Anzeigen, eine Smileyauswahlbox,<br>Handelsoptionen und einige Veränderungen des Layouts.",
  235. act: "Funktionen der Toolsammlung aktivieren/deaktivieren:",
  236. prv: "Vorschau einzelner Funktionen:",
  237. },
  238. // opt: [label, tooltip]
  239. bir: [ "Biremenzähler", "Zählt die jeweiligen Biremen einer Stadt und summiert diese. (Anzeige im Minimap-Bullauge links oben)" ],
  240. sml: [ "Smileys", "Erweitert die BBCode-Leiste um eine Smileybox" ],
  241. str: [ "Einheitenstärke", "Fügt mehrere Einheitenstärketabellen in verschiedenen Bereichen hinzu" ],
  242. trd: [ "Handel", "Erweitert das Handelsfenster um einen Prozentualer Handel, einen Rekrutierungshandel und Limitmarker für Stadtfeste" ],
  243. cnt: [ "EO-Zähler", "Zählt die ATT/UT-Anzahl im EO-Fenster (bisher nur bei eigenen Eroberungen)" ],
  244. way: [ "Laufzeit", "Zeigt im ATT/UT-Fenster die Laufzeit bei Verbesserter Truppenbewegung an" ],
  245. wwc: [ "Weltwunder", "Anteilsrechner & Rohstoffzähler + Vor- & Zurück-Buttons bei fertiggestellten WW's (momentan nicht deaktivierbar!)" ],
  246. sim: [ "Simulator", "Anpassung des Simulatorlayouts & permanente Anzeige der Erweiterten Modifikatorbox" ],
  247. spl: [ "Zauberbox", "Komprimierte verschiebbare & magnetische Zauberbox (Positionsspeicherung)" ],
  248. mov: [ "Aktivitätsboxen", "Verbesserte Anzeige der Handels- und Truppenaktivitätsboxen (Positionsspeicherung)" ],
  249. pop: [ "Popup", 'Ändert Gunst-Popup' ],
  250. tsk: [ "Taskleiste", 'Vergrößert die Taskleiste und minimiert das "Tägliche Belohnung"-Fenster beim Start' ],
  251. irc: [ "Chat", "Ersetzt den Allianzchat durch einen IRC-Chat" ],
  252. bbc: [ "BBCode-Leiste", "Erweitert BBCode-Leiste um ein automatisches DEF-Formular" ],
  253. com: [ "Vergleich", "Fügt Einheitenvergleichstabellen hinzu" ],
  254. twn: [ "Stadticons", "Fügt Stadttyp-Icons zur Stadtliste hinzu" ],
  255. con: [ "Kontextmenu", 'Vertauscht "Stadt selektieren" und "Stadtübersicht" im Kontextmenu'],
  256. sen: [ "Abgeschickt", 'Zeigt im Angriffs-/Unterstützungsfenster abgeschickte Einheiten an'],
  257. tov: [ "Stadtübersicht", 'Ersetzt die neue Stadtansicht mit der alten Fensteransicht'],
  258. scr: [ "Mausrad", 'Man kann mit dem Mausrad die Übersichten wechseln'],
  259. sav_btn: "Speichern", don_btn: "http://s7.directupload.net/images/140131/ctahnu2q.png",
  260. },
  261. sml : { std: "Standard ", gre: "Grepolis ", nat: "Natur ", ppl: "Leute ", oth: "Sonstige " },
  262. uni : "Verfügbare Einheiten",
  263. bbc : {
  264. ttl: "Übersicht: Stadtverteidigung", inf: "Informationen zur Stadt:", mov: "Truppenbewegungen:", dev: "Abweichung", but: "Einfügen",
  265. sel: [ "Detailierte Landeinheiten", "Premiumboni", "Silberstand", "Truppenbewegungen" ]
  266. },
  267. wwc : { leg: "WW-Anteil", stg: "Stufe", tot: "Gesamt"},
  268. sim : { str: "Einheitenstärke", los: "Verluste", mod: "ohne Modifikatoreinfluss" },
  269. com : {
  270. dsc: "Einheitenvergleich", hck: "Schlag", prc: "Stich", dst: "Distanz", sea: "See", att: "Angriff", def: "Verteidigung", spd: "Geschwindigkeit",
  271. bty: "Beute (Rohstoffe)", cap: "Transportkapazität", res: "Baukosten (Rohstoffe)", fav: "Gunst", tim: "Bauzeit (s)"
  272. },
  273. trd : { uni: "Ressourcenverhältnis eines Einheitentyps", rat: "Anteil an der Lagerkapazität der Zielstadt", prc: "Prozentualer Handel"},
  274. sen : { rst: "Zurücksetzen", lab: "Abgeschickt" },
  275. con : "Selektieren"
  276. },
  277. en : {
  278. set : {
  279. txt: {
  280. dsc: "DIO-Tools offers, among other things, some displays, a smiley box,<br>trade options and some changes to the layout.",
  281. act: "Activate/deativate features of the toolset:",
  282. prv: "Preview of several features:",
  283. },
  284. // opt: [label, tooltip]
  285. bir: [ "Bireme counter", "Counts the biremes of a city and sums these" ],
  286. sml: [ "Smilies", "Extends the bbcode bar by a smiley box" ],
  287. str: [ "Unit strength", "Adds unit strength tables in various areas" ],
  288. trd: [ "Trade", "Extends the trade window by a percentage trade, a recruitment trade and limit markers for city festivals" ],
  289. cnt: [ "Conquests", "Counts the attacks/supports in the conquest window (only own conquests yet)" ],
  290. way: [ "Troop speed", "Displays improved troop speed in the attack/support window" ],
  291. wwc: [ "World wonder", "Share calculation & resources counter + previous & next buttons on finished world wonders (currently not deactivatable!)" ],
  292. sim: [ "Simulator", "Adaptation of the simulator layout & permanent display of the extended modifier box" ],
  293. spl: [ "Spell box", "Compressed sliding & magnetic spell box (position memory)" ],
  294. mov: [ "Activity boxes", "Improved display of trade and troop activity boxes (position memory)" ],
  295. pop: [ "Popup", "Changes the favor popup" ],
  296. tsk: [ "Taskbar", "Increases the taskbar and minimizes the daily reward window on startup" ],
  297. irc: [ "Chat", 'Replaced the alliance chat by an irc chat. (FlashPlayer required)' ],
  298. bbc: [ "BBCode bar", "Extends the bbcode bar by an automatic defense form" ],
  299. com: [ "Comparison", "Adds unit comparison tables" ],
  300. twn: [ "Town icons", "Adds town type icons to the town list" ],
  301. con: [ "Context menu", 'Swaps "Select town" and "City overview" in the context menu'],
  302. sen: [ "Sent units", 'Shows sent units in the attack/support window'],
  303. tov: [ "Town overview", 'Replaces the new town overview with the old window style'],
  304. scr: [ "Mouse wheel", 'You can change the views with the mouse wheel'],
  305. sav_btn: "Save", don_btn: "https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif",
  306. },
  307. sml : { std: "Standard ", gre: "Grepolis ", nat: "Nature ", ppl: "People ", oth: "Other " },
  308. uni : "Available Units",
  309. bbc : {
  310. ttl: "Overview: Town defense", inf: "Town information:", mov: "Troop movements:", dev: "Deviation", but: "Insert",
  311. sel: [ "Detailed land units", "Premium bonuses", "Silver volume", "Troop movements" ]
  312. },
  313. wwc : { leg: "WW Share", stg: "Stage", tot: "Total"},
  314. sim : { str: "Unit strength", los: "Loss", mod: "without modificator influence" },
  315. com : {
  316. dsc: "Unit comparison", hck: "Blunt", prc: "Sharp", dst: "Distance", sea: "Sea", att: "Offensive", def: "Defensive", spd: "Speed",
  317. bty: "Booty (resources)", cap: "Transport capacity", res: "Costs (resources)", fav: "Favor", tim: "Recruiting time (s)"
  318. },
  319. trd : { uni: "Resource ratio of an unit type", rat: "Share of the storage capacity of the target city", prc: "Percentage trade"},
  320. sen : { rst: "Reset", lab: "Sent units" },
  321. con : "Select town"
  322. },
  323. ///////////////////////////////////
  324. // French Translation by eclat49 //
  325. ///////////////////////////////////
  326. fr : {
  327. set : {
  328. txt: {
  329. 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.",
  330. act: "Activation/Désactivation des fonctions:",
  331. prv: "Aperçu des fonctions séparées:",
  332. },
  333. // opt: [label, tooltip]
  334. bir: [ "<nobr>Compteur de birèmes&nbsp;&nbsp;</nobr>", "Totalise l'ensemble des birèmes présentent en villes et les résume. (Remplace la mini carte dans le cadran)" ],
  335. sml: [ "Smileys", "Rajoutes une boite de smilies à la boite de bbcode" ],
  336. str: [ "Force unitaire", "Ajoutes des tableaux de force unitaire dans les différentes armes" ],
  337. trd: [ "Commerce", "Ajout d'une option par pourcentage, par troupes pour le commerce, ainsi qu'un affichage des limites pour les festivals" ],
  338. cnt: [ "<nobr>Compteur conquête</nobr>", "Comptabilise le nombre d'attaque et de soutien dans la fenêtre de conquête (valable que pour ses propre conquêtes)" ],
  339. way: [ "<nobr>Vitesse des troupes&nbsp;&nbsp;</nobr>", "Rajoutes le temps de trajet avec le bonus accélération" ],
  340. wwc: [ "<nobr>Merveille du monde</nobr>", "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)" ],
  341. sim: [ "Simulateur", "Modification de la présentation du simulateur et affichage permanent des options premium" ],
  342. spl: [ "<nobr>Boîte de magie</nobr>", "Boîte de sort cliquable et positionnable" ],
  343. mov: [ "<nobr>Boîte d'activité</nobr>", "Présentation améliorée du commerce et des mouvement de troupes (mémoire de position)" ],
  344. pop: [ "Popup", 'Change la popup de faveur' ],
  345. tsk: [ "<nobr>Barre de tâches&nbsp;&nbsp;</nobr>", "La barre de tâches augmente et minimise le fenêtre de bonus journalier" ],
  346. irc: [ "Chat", "Remplace le chat de l'alliance à travers un chat IRC. (FlashPlayer requis)" ],
  347. bbc: [ "<nobr>Barre de BBCode</nobr>", "Ajout d'un bouton dans la barre BBCode pour un formulaire de défense automatique" ],
  348. com: [ "Comparaison", "Ajoutes des tableaux de comparaison des unités" ],
  349. twn: [ "<nobr>Icônes des villes</nobr>", "Ajoutes desicônes de type de ville à la liste de ville" ],
  350. con: [ "Menu contextuel", 'Swaps "Sélectionner ville" et "Aperçu de la ville" dans le menu contextuel'],
  351. sen: [ "Unités envoyées", 'Affiche unités envoyées dans la fenêtre attaque/support'],
  352. tov: [ "Aperçu de ville", "Remplace la nouvelle aperçu de la ville avec l'ancien style de fenêtre"],
  353. scr: [ "Molette de la souris", 'Avec la molette de la souris vous pouvez changer les vues'],
  354. sav_btn: "Sauver", don_btn: "http://s7.directupload.net/images/140131/ctahnu2q.png",
  355. },
  356. sml : { std: "Standard ", gre: "Grepolis ", nat: "Nature ", ppl: "Gens ", oth: "Autres " },
  357. uni : "Unités disponibles",
  358. bbc : {
  359. ttl: "Aperçu: Défense de ville", inf: "Renseignements sur la ville:", mov: "Mouvements de troupes:", dev: "Différence", but: "Insertion",
  360. sel: [ "Unités terrestres détaillées", "Bonus premium", "Remplissage de la grotte", "Mouvements de troupes" ]
  361. },
  362. wwc : { leg: "Participation", stg: "Niveau", tot: "Total"},
  363. sim : { str: "Force unitaire", los: "Pertes", mod: "sans influence de modificateur" },
  364. com : {
  365. dsc: "Comparaison des unités", hck: "Contond.", prc: "Blanche", dst: "Jet", sea: "Navale", att: "Attaque", def: "Défense", spd: "Vitesse",
  366. bty: "Butin", cap: "Capacité de transport", res: "Coût de construction", fav: "Faveur", tim: "Temps de construction (s)"
  367. },
  368. trd : { uni: "Ratio des ressources d'un type d'unité", rat: "Part de la capacité de stockage de la ville cible", prc: "Commerce de pourcentage"},
  369. sen : { rst: "Remettre", lab: "Envoyée" },
  370. con : "Sélectionner"
  371. },
  372. ///////////////////////////////////
  373. // Russian Translation by MrBobr //
  374. ///////////////////////////////////
  375. ru : {
  376. set : {
  377. txt: {
  378. dsc: "DIO-Tools изменяет некоторые окна, добавляет новые смайлы, отчёты,<br>улучшеные варианты торговли и другие функции.",
  379. act: "Включение/выключение функций:",
  380. prv: "Примеры внесённых изменений:",
  381. },
  382. // opt: [label, tooltip]
  383. bir: [ "Счётчик бирем", "Показывает число бирем во всех городах" ],
  384. sml: [ "Смайлы", "Добавляет кнопку для вставки смайлов в сообщения" ],
  385. str: [ "Сила отряда", "Добавляет таблицу общей силы отряда в некоторых окнах" ],
  386. trd: [ "Торговля", "Добавляет маркеры и отправку недостающих ресурсов, необходимых для фестиваля. Инструменты для долевой торговли" ],
  387. cnt: [ "Завоевания", "Отображение общего числа атак/подкреплений в окне завоевания города (only own conquests yet)" ],
  388. way: [ "30% ускорение", "Отображает примерное время движения отряда с 30% бонусом" ],
  389. wwc: [ "Чудо света", "Share calculation & resources counter + previous & next buttons on finished world wonders (currently not deactivatable!)" ],
  390. sim: [ "Симулятор", "Изменение интерфейса симулятора, добавление новых функций" ],
  391. spl: [ "Заклинания", "Изменяет положение окна заклинаний" ],
  392. mov: [ "Перемещения", "Показывает окна пересылки ресурсов и перемещения войск" ],
  393. pop: [ "Благосклонность", "Отображение окна с уровнем благосклонности богов" ],
  394. tsk: [ "Таскбар", "Увеличение ширины таскбара и сворачивание окна ежедневной награды при входе в игру" ],
  395. irc: [ "Чат", 'Замена чата игры на irc-чат' ],
  396. bbc: [ "BB-коды", "Добавляет кнопку для вставки в сообщение отчёта о городе" ],
  397. com: [ "Сравнение юнитов", "Добавляет окно сравнения юнитов" ],
  398. twn: [ "Типы городов", "Добавляет иконку к городу в списке" ],
  399. con: [ "Context menu", 'Swaps "Select town" and "City overview" in the context menu'],
  400. sen: [ "Sent units", 'Shows sent units in the attack/support window'],
  401. tov: [ "Обзор Город", 'Заменяет новый обзор города с старом стиле окна'], // ?
  402. scr: [ "Колесо мыши", 'С помощью колеса мыши вы можете изменить взгляды'], // ?
  403. sav_btn: "Сохраниить", don_btn: "https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif",
  404. },
  405. sml : { std: "Standard ", gre: "Grepolis ", nat: "Nature ", ppl: "People ", oth: "Other " },
  406. uni : "Доступные войска",
  407. bbc : {
  408. ttl: "Обзор: Отчёт о городе", inf: "Информация о войсках и постройках:", mov: "Перемещения:", dev: "Отклонение", but: "Вставка",
  409. sel: [ "Детальный отчёт", "Премиум-бонусы", "Серебро в пещере", "Перемещения" ]
  410. },
  411. wwc : { leg: "WW Share", stg: "Stage", tot: "Total"},
  412. sim : { str: "Сила войск", los: "Потери", mod: "без учёта заклинаний, бонусов, исследований", att: "Обычная атака"},
  413. com : {
  414. dsc: "Сравнение юнитов", hck: "Ударное", prc: "Колющее", dst: "Дальнего боя", sea: "Морские", att: "Атака", def: "Защита", spd: "Скорость",
  415. bty: "Добыча (ресурсы)", cap: "Вместимость транспортов", res: "Стоимость (ресурсы)", fav: "Благосклонность", tim: "Время найма (с)"
  416. },
  417. trd : { uni: "Resource ratio of an unit type", rat: "Share of the storage capacity of the target city", prc: "Percentage trade"},
  418. sen : { rst: "Сброс", lab: "Отправлено" },
  419. con : "выбирать"
  420. },
  421. ////////////////////////////////
  422. // Polish Translation by anpu //
  423. ////////////////////////////////
  424. pl : {
  425. set : {
  426. txt: {
  427. dsc: "DIO-Tools oferuje (między innymi) poprawione widoki, nowe uśmieszki,<br>opcje handlu i zmiany w wyglądzie.",
  428. act: "Włącz/wyłącz funkcje skryptu:",
  429. prv: "podgląd poszczególnych opcji:",
  430. },
  431. // opt: [label, tooltip]
  432. bir: [ "Licznik birem", "Zlicza i sumuje biremy z miast" ],
  433. sml: [ "Emotki", "Dodaje dodatkowe (zielone) emotikonki" ],
  434. str: [ "Siła jednostek", "dodaje tabelki z siłą jednostek w różnych miejscach gry" ],
  435. trd: [ "Handel", "Rozszerza okno handlu o handel procentowy, proporcje surowców wg jednostek, dodaje znaczniki dla festynów" ],
  436. cnt: [ "Podboje", "Zlicza wsparcia/ataki w oknie podboju (tylko własne podboje)" ],
  437. way: [ "Prędkość wojsk", "Wyświetla dodatkowo czas jednostek dla bonusu przyspieszone ruchy wojsk" ],
  438. 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)" ],
  439. sim: [ "Symulator", "Dostosowanie wyglądu symulatora oraz dodanie szybkich pól wyboru" ],
  440. spl: [ "Ramka czarów", "Kompaktowa pływająca ramka z czarami (można umieścić w dowolnym miejscu ekranu. Zapamiętuje położenie.)" ],
  441. 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.)" ],
  442. pop: [ "Łaski", "Zmienia wygląd ramki informacyjnej o ilości produkowanych łask" ],
  443. tsk: [ "Pasek skrótów", "Powiększa pasek skrótów i minimalizuje okienko z bonusem dziennym" ],
  444. irc: [ "Czat", 'Zastępuje standardowy Chat chatem IRC (wymagany FlashPlayer)' ],
  445. bbc: [ "Pasek BBCode", "Rozszerza pasek skrótów BBcode o generator raportów obronnych" ],
  446. com: [ "Porównianie", "Dodaje tabelki z porównaniem jednostek" ],
  447. twn: [ "Oznaczanie miast", "Możliwość oznaczania ikonami miast na liście" ],
  448. con: [ "menu kontekstowe", 'Zamiemia miejcami przycisk "wybierz miasto" z przyciskiem "podgląd miasta" po kliknięciu miasta na mapie'],
  449. sen: [ "Wysłane jednostki", 'Pokaż wysłane jednostki w oknie wysyłania ataków/wsparć'],
  450. tov: [ "Podgląd miasta", 'Zastępuje nowy podgląd miasta starym'],
  451. scr: [ "Zoom", 'Możesz zmienić poziom przybliżenia mapy kółkiem myszy'],
  452. sav_btn: "Zapisz", don_btn: "https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif",
  453. },
  454. sml : { std: "Standardowe ", gre: "Grepolis ", nat: "Przyroda ", ppl: "Ludzie ", oth: "Inne " },
  455. uni : "Dostępne jednostki",
  456. bbc : {
  457. ttl: "Podgląd: Obrona miasta", inf: "Informacje o mieście:", mov: "Ruchy wojsk:", dev: "Ochyłka", but: "Wstaw",
  458. sel: [ "jednostki lądowe", "opcje Premium", "Ilość srebra", "Ruchy wojsk" ]
  459. },
  460. wwc : { leg: "Udział w Cudzie", stg: "Poziom", tot: "Łącznie"},
  461. sim : { str: "Siła jednostek", los: "Straty", mod: "bez modyfikatorów" },
  462. com : {
  463. dsc: "Porównianie jednostek", hck: "Obuchowa", prc: "Tnąca", dst: "Dystansowa", sea: "Morskie", att: "Offensywne", def: "Defensywne", spd: "Prędkość",
  464. bty: "Łup (surowce)", cap: "Pojemność transportu", res: "Koszta (surowce)", fav: "Łaski", tim: "Czas rekrutacji (s)"
  465. },
  466. trd : { uni: "Stosunek surowców dla wybranej jednostki", rat: "procent zapełnienia magazynu w docelowym mieście", prc: "Handel procentowy"},
  467. sen : { rst: "Anuluj", lab: "Wysłane jednostki" },
  468. con : "Wybierz miasto"
  469. },
  470. };
  471.  
  472. /*******************************************************************************************************************************
  473. * Settings
  474. *******************************************************************************************************************************/
  475. // (De)activation of the features
  476. var options, options_def = {
  477. bir : true, // Biremes counter
  478. sml : true, // Smileys
  479. str : true, // Unit strength
  480. trd : true, // Trade options
  481. way : true, // Troop speed
  482. cnt : true, // Attack/support counter
  483. sim : true, // Simulator
  484. spl : true, // Spell box
  485. mov : false,// Activity boxes
  486. tsk : true, // Task bar
  487. irc : true, // IRC-Chat
  488. pop : true, // Favor popup
  489. wwc : true, // World wonder
  490. bbc : true, // BBCode bar
  491. com : true, // Unit comparison
  492. twn : true, // Town icons
  493. con : true, // Context menu
  494. sen : true, // Sent units
  495. tov : true, // Town overview
  496. scr : true, // Mausrad
  497. };
  498.  
  499. // Get options
  500. if(uw.location.pathname === "/game/index"){
  501. // join GM variables and delete old ones (transitional)
  502. var GM_list = GM_listValues(), op;
  503. GM_list.forEach(function(op) {
  504. if(op.substring(0,3) === "set"){
  505. GM_deleteValue(op);
  506. }
  507. });
  508. // Check default options
  509. options = JSON.parse(GM_getValue("options", JSON.stringify(options_def)));
  510. for(var opt in options_def){
  511. if(options_def.hasOwnProperty(opt)){
  512. if(options[opt] == undefined) {
  513. options[opt] = options_def[opt];
  514. }
  515. }
  516. }
  517. }
  518.  
  519. //console.log(options);
  520. var firstLoad = true;
  521. function loadSettingImages(){
  522. if(firstLoad){
  523. $('<style type="text/css"> .dio_tools_bg { background:url(http://s1.directupload.net/images/140422/4hotfxip.png) 320px 10px no-repeat;} </style>').appendTo('head');
  524. var bg_medusa = new Image(); bg_medusa.src = 'http://s7.directupload.net/images/140202/dz8ziycu.png';
  525. var img_bi = new Image(); img_bi.src = 'http://i.imgur.com/94m7Gg8.png';
  526. var img_sm = new Image(); img_sm.src = 'http://i.imgur.com/Y3BsENb.png';
  527. var img_un = new Image(); img_un.src = 'http://i.imgur.com/LXkSxsS.png';
  528. firstLoad = false;
  529. }
  530. }
  531.  
  532. // Add DIO-Tools to grepo settings
  533. function settings() {
  534. var wid = $(".settings-menu").get(0).parentNode.id;
  535. if(!$("#dio_tools").get(0)){
  536. $(".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>');
  537. if($('#RepConvSetupLink').get(0)) { $('#RepConvSetupLink').before('<img id="grc_icon" src="http://grepolis.potusek.eu/img/octopus.png"> '); }
  538. $('#dio_icon').css({ width: '15px', verticalAlign: 'middle', marginTop: '-2px' });
  539. // icon adaption of other scripts
  540. setTimeout(function(){
  541. $('#quackicon, #grc_icon').css({
  542. width: '15px',
  543. verticalAlign: 'middle',
  544. marginTop: '-2px'
  545. });
  546. $('#quackicon').css({
  547. height:'12px'
  548. });
  549. }, 1);
  550. }
  551. $(".settings-link").click(function () {
  552. $('.section').each(function(){
  553. $(this).get(0).style.display = "block";
  554. });
  555. $('.settings-container').removeClass("dio_tools_bg");
  556. if($('#dio_settings').get(0)) { $('#dio_settings').get(0).style.display = "none"; }
  557. });
  558. $("#dio_tools").click(function () {
  559. if($('.email').get(0)) { $('.settings-container').removeClass("email"); }
  560. $('.settings-container').addClass("dio_tools_bg");
  561. //console.log(GM_info);
  562. if(!$('#dio_settings').get(0)){
  563. $('.settings-container').append(
  564. '<div id="dio_settings" class="player_settings section"><div class="game_header bold">'+
  565. '<a href="http://adf.ly/eDM1y" target="_blank" style="color:white">DIO-Tools (v'+ GM_info.script.version +')</a></div>'+
  566. '<p>' + LANG[LID].set.txt.dsc + '</p>'+
  567. '<p class="bold"><u>'+ LANG[LID].set.txt.act + '</u></p>'+
  568. '<table width="100%" style=" font-size: 0.8em;"><tr><td width="24%">'+
  569. '<div id="bir" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.bir[0] +'</div></div><br><br>'+
  570. '<div id="sml" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.sml[0] +'</div></div><br><br>'+
  571. '<div id="str" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.str[0] +'</div></div><br><br>'+
  572. '<div id="bbc" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.bbc[0] +'</div></div><br><br>'+
  573. '<div id="con" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.con[0] +'</div></div><br><br>'+
  574. '</td><td width="21%">'+
  575. '<div id="trd" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.trd[0] +'</div></div><br><br>'+
  576. '<div id="cnt" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.cnt[0] +'</div></div><br><br>'+
  577. '<div id="way" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.way[0] +'</div></div><br><br>'+
  578. '<div id="wwc" class="checkbox_new disabled"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.wwc[0] +'</div></div><br><br>'+
  579. '<div id="sen" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.sen[0] +'</div></div><br><br>'+
  580. '</td><td width="20%">'+
  581. '<div id="sim" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.sim[0] +'</div></div><br><br>'+
  582. '<div id="spl" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.spl[0] +'</div></div><br><br>'+
  583. '<div id="tsk" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.tsk[0] +'</div></div><br><br>'+
  584. '<div id="twn" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.twn[0] +'</div></div><br><br>'+
  585. '<div id="tov" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.tov[0] +'</div></div><br><br>'+
  586. '</td><td>'+
  587. '<div id="mov" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.mov[0] +'</div></div><br><br>'+
  588. '<div id="com" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.com[0] +'</div></div><br><br>'+
  589. '<div id="pop" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.pop[0] +'</div></div><br><br>'+
  590. '<div id="irc" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.irc[0] +'</div></div><br><br>'+
  591. '<div id="scr" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].set.scr[0] +'</div></div><br><br>'+
  592. '</td></tr>'+
  593. '</table>'+
  594. '<div><a class="button" id="dio_save" href="#">'+
  595. '<span class="left"><span class="right"><span class="middle"><small>' + LANG[LID].set.sav_btn + '</small></span></span></span><span></span>'+
  596. '</a></div>'+
  597. '<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">'+
  598. '<img alt="Donate" src="' + LANG[LID].set.don_btn + '"></a></div>'+
  599. '<p class="bold"><u>'+ LANG[LID].set.txt.prv + '</u></p>'+
  600. '<table><tr>'+
  601. '<td><img id="bi_img" src="http://i.imgur.com/94m7Gg8.png"></td>'+
  602. '<td><img id="sm_img" src="http://i.imgur.com/Y3BsENb.png"></td>'+
  603. '<td><img id="un_img" src="http://i.imgur.com/LXkSxsS.png"></td>'+
  604. '</tr></table></div></div>');
  605. $("#bi_img").tooltip(LANG[LID].set.bir[0]); $("#sm_img").tooltip(LANG[LID].set.sml[0]); $("#un_img").tooltip(LANG[LID].set.str[0]);
  606. $("#bir").tooltip(LANG[LID].set.bir[1]); $("#sml").tooltip(LANG[LID].set.sml[1] + "<br><br><img src='http://666kb.com/i/ckajscggscw4s2u60.gif'>");
  607. $("#str").tooltip(LANG[LID].set.str[1]); $("#bbc").tooltip(LANG[LID].set.bbc[1]);
  608. $("#con").tooltip(LANG[LID].set.con[1]);
  609. $("#trd").tooltip(LANG[LID].set.trd[1]); $("#cnt").tooltip(LANG[LID].set.cnt[1]); $("#way").tooltip(LANG[LID].set.way[1]); $("#wwc").tooltip(LANG[LID].set.wwc[1]);
  610. $("#sen").tooltip(LANG[LID].set.sen[1]);
  611. $("#sim").tooltip(LANG[LID].set.sim[1]); $("#spl").tooltip(LANG[LID].set.spl[1]); $("#mov").tooltip(LANG[LID].set.mov[1]); $("#com").tooltip(LANG[LID].set.com[1]);
  612. $("#tov").tooltip(LANG[LID].set.tov[1]);
  613. $("#pop").tooltip(LANG[LID].set.pop[1]); $("#tsk").tooltip(LANG[LID].set.tsk[1]); $("#irc").tooltip(LANG[LID].set.irc[1]); $("#twn").tooltip(LANG[LID].set.twn[1]);
  614. $("#scr").tooltip(LANG[LID].set.scr[1]);
  615. $("#dio_settings .checkbox_new").click(function () {
  616. $(this).toggleClass("checked");
  617. });
  618. for(var e in options) {
  619. if(options.hasOwnProperty(e)){
  620. if (options[e] == true) {
  621. $("#" + e).addClass("checked");
  622. }
  623. }
  624. }
  625. $('#dio_save').click(function(){
  626. $('#dio_settings .checkbox_new').each(function(){
  627. var act = false;
  628. if ($("#" + this.id).hasClass("checked")) {
  629. act = true;
  630. }
  631. options[this.id] = act;
  632. });
  633. setTimeout(function(){
  634. GM_setValue("options", JSON.stringify(options));
  635. window.location.reload();
  636. }, 0);
  637. });
  638. }
  639. $('.section').each(function(){
  640. $(this).get(0).style.display = "none";
  641. });
  642. $('#dio_settings').get(0).style.display = "block";
  643. });
  644. }
  645.  
  646. function addSettingsButton(){
  647. $('<div class="btn_settings circle_button dio_settings"><div class="dio_icon js-caption"></div></div>').appendTo(".gods_area");
  648. $('.dio_settings').css({
  649. top: '95px',
  650. right: '103px',
  651. zIndex: '10'
  652. });
  653. $('.dio_settings .dio_icon').css({
  654. margin: '7px 0px 0px 4px', width: '24px', height: '24px',
  655. background: 'url(http://666kb.com/i/cifvfsu3e2sdiipn0.gif) no-repeat 0px 0px',
  656. backgroundSize: "100%"
  657. });
  658. $('.dio_settings').on('mouseup', function(){
  659. $('.dio_icon').get(0).style.marginTop = "7px";
  660. });
  661. $('.dio_settings').on('mousedown', function(){
  662. $('.dio_icon').get(0).style.marginTop = "8px";
  663. });
  664. $('.dio_settings').tooltip("DIO-Tools");
  665. $('.dio_settings').click(function(){
  666. clickDioSettings();
  667. });
  668. }
  669.  
  670. function clickDioSettings(){
  671. var dioset;
  672. dioset = new MutationObserver(function(mutations) {
  673. mutations.forEach(function(mutation) {
  674. if(mutation.addedNodes[0]){
  675. if(mutation.addedNodes[0].id === "dio_li"){
  676. dioset.disconnect();
  677. $('#dio_tools').click();
  678. }
  679. }
  680. });
  681. });
  682. dioset.observe($('body').get(0), { attributes: false, childList: true, characterData: false, subtree: true});
  683. uw.Layout.wnd.Create(uw.GPWindowMgr.TYPE_PLAYER_SETTINGS,'Settings');
  684. }
  685.  
  686. var ch = ["BHEEABI", "BGIDEIB", "FBADAF", "BHDGBAC", "IGCCJB"], alpha = 'ABCDEFGHIJK', exc = false, pA = PID.toString(), pB = "", sum = 0; //BAEHGJ
  687.  
  688. for(var c in pA){ if(pA.hasOwnProperty(c)){ pB += alpha[pA[parseInt(c, 10)]];}}
  689.  
  690. function a(){
  691. for(var b in ch){
  692. if(ch.hasOwnProperty(b)){
  693. if(!(pB === ch[b])){exc = true;} else {exc = false; return;}
  694. for(var s in ch[b]){if(ch[b].hasOwnProperty(s)){sum += alpha.indexOf(ch[b][s]); }}
  695. }
  696. }
  697. }
  698. /*******************************************************************************************************************************
  699. * GM variables
  700. *******************************************************************************************************************************/
  701. if(uw.location.pathname === "/game/index"){
  702. // delete old GM variables
  703. GM_deleteValue(WID + "_AP");
  704. // get point ratio for ww share
  705. var ratio = GM_getValue(WID + "_ratio", getPointRatioFromGS());
  706. a();
  707. }
  708. /*******************************************************************************************************************************
  709. * HTTP-Requests
  710. *******************************************************************************************************************************/
  711. if(uw.location.pathname === "/game/index"){
  712. $(document).ajaxComplete(function (e, xhr, opt) {
  713. var url = opt.url.split("?"), action = url[0].substr(5) + "/" + url[1].split(/&/)[1].substr(7);
  714. //console.log(action);
  715. if((ch.length == 5) && exc && (sum == 118)){
  716. switch (action) {
  717. case "/data/get":
  718. if(options.tsk) {minimizeDailyReward();}
  719. if(options.com) {addComparisonButton();}
  720. if(options.spl) {catchSpellBox(); initSpellBox();}
  721. if(options.bir) {initBiri();}
  722. if(options.tsk) {scaleTaskbar();}
  723. if(options.irc) {hideNavElements();}
  724. if(options.pop) {unbindFavorPopup();}
  725. addSettingsButton();
  726. addAvailableUnitsBox();
  727. addAvailableUnitsButton();
  728. //addStatsButton();
  729. if(options.con){swapContextMenu();}
  730. if(options.twn || options.con || options.tov) {bodyHandler(); }
  731. if(options.tov){
  732. var ui_box = new MutationObserver(function(mutations) {
  733. mutations.forEach(function(mutation) {
  734. //console.log($('#ui_box').attr("class"));
  735. if($('#ui_box').attr("class") === "city-overview-enabled"){
  736. $("#ui_box .bull_eye_buttons .island_view").click();
  737. ui_box.disconnect();
  738. uw.GPWindowMgr.Create(uw.Layout.wnd.TYPE_TOWNINDEX, "City view - "+ uw.ITowns.getTown(uw.Game.townId).name);
  739. }
  740. });
  741. });
  742. ui_box.observe($('#ui_box').get(0), { attributes: true, childList: false, characterData: false, attributeFilter: ["class"] });
  743. setTimeout(function(){
  744. ui_box.disconnect();
  745. }, 60000);
  746. }
  747. break;
  748. case "/debug/log_startup_time":
  749. //Notification
  750. setTimeout(function(){
  751. var notif = GM_getValue('DIO-Notification', 0); notif = parseInt(notif, 10);
  752. if(notif <= 3){
  753. //newFeatureNotification(1, 'Swap context menu buttons ("Select town" and "City overview")');
  754. //newFeatureNotification(2, 'Town overview (old window mode)');
  755. newFeatureNotification(3, 'Mouse wheel: You can change the views with the mouse wheel');
  756. $('.notification').each(function(){
  757. $(this).click(function(){
  758. clickDioSettings();
  759. $(this).find(".close").click();
  760. });
  761. });
  762. $('.systemmessage').css({
  763. cursor: "pointer"
  764. });
  765. }
  766. GM_setValue('DIO-Notification', 4);
  767. },0);
  768. getUnitValues();
  769. if(options.mov) {showCommandsAndTrades();}
  770. if(options.str) {addStrengthMenu(); setStrengthMenu();}
  771. getAllUnits();
  772. setInterval(function(){
  773. getAllUnits();
  774. },1800000);
  775. if(options.twn) {setTownList(); addTownIcon(); }
  776. //messageSound();
  777. //test();
  778. if(options.com) {addComparisonBox();}
  779. if(options.sml) {loadSmileys();}
  780. if(options.irc) {initChatUser(); }
  781. if(options.tov) {setCityWindowButton();}
  782. if(options.scr){scrollViews();}
  783. setTownIconsOnMap();
  784. counter(uw.Game.server_time);
  785. setInterval(function(){ counter(uw.Game.server_time);}, 21600000);
  786. break;
  787. case "/player/index":
  788. loadSettingImages();
  789. settings();
  790. break;
  791. case "/index/switch_town":
  792. var start = (new Date()).getTime();
  793. if(options.str) {setStrengthMenu();}
  794. if(options.bir) {getBiri();}
  795. if(options.twn) {changeTownIcon();}
  796. var end = (new Date()).getTime();
  797. console.log(uw.Game.server_time);
  798. //console.log(end-start +"ms");
  799. //test();
  800. break;
  801. case "/building_docks/index":
  802. if(options.bir) {getBiriDocks();}
  803. break;
  804. case "/building_place/units_beyond":
  805. if(options.bir) {getBiriAgora();}
  806. break;
  807. case "/building_place/simulator":
  808. if(options.sim) {changeSimulatorLayout(); }
  809. break;
  810. case "/building_place/simulate":
  811. if(options.sim) {afterSimulation();}
  812. break;
  813. case "/alliance_forum/forum": case "/message/new": case "/message/forward": case "/message/view": case "/player_memo/load_memo_content":
  814. if(options.sml){addSmileyBox(action); }
  815. if(options.bbc){addForm(action); }
  816. break;
  817. case "/wonders/index":
  818. if(options.trd){WWTradeHandler(); }
  819. getResWW();
  820. break;
  821. case "/wonders/send_resources":
  822. getResWW();
  823. break;
  824. case "/ranking/alliance": case "/ranking/wonder_alliance":
  825. getPointRatioFromAllianceRanking();
  826. break;
  827. case "/alliance/members_show":
  828. getPointRatioFromAllianceMembers();
  829. break;
  830. case "/town_info/trading":
  831. if(options.trd){addTradeMarks(15, 18, 15, "red"); TownTabHandler(action.split("/")[2]); }
  832. break;
  833. case "/farm_town_overviews/get_farm_towns_for_town":
  834. changeResColor();
  835. break;
  836. case "/command_info/conquest_info":
  837. if(options.str) {addStrengthConquest();}
  838. break;
  839. case "/command_info/conquest_movements": case "/conquest_info/getinfo":
  840. if(options.cnt) {countMovements();}
  841. break;
  842. case "/building_barracks/index": case "/building_barracks/build":
  843. if(options.str) {setStrengthBarracks();}
  844. break;
  845. case "/town_info/attack": case "/town_info/support":
  846. TownTabHandler(action.split("/")[2]);
  847. break;
  848. case "/report/index":
  849. changeDropDownButton();
  850. loadFilter();
  851. saveFilter();
  852. //removeReports();
  853. break;
  854. case "/message/default": case "/message/index":
  855. break;
  856. case "/chat/init":
  857. if(options.irc) {modifyChat();}
  858. break;
  859. case "/town_info/go_to_town":
  860. /*
  861. console.log(uw.Layout.wnd);
  862. var windo = uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).getID();
  863. console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX));
  864. uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).setPosition([100,400]);
  865. console.log(windo);
  866. console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).getPosition());
  867. //gpwnd_1001
  868. */
  869. break;
  870. }
  871. }
  872. });
  873. }
  874.  
  875. // Notification
  876. function newFeatureNotification(nid, feature){
  877. $('<style type="text/css"> #notification_area .systemmessage .icon { background: url(http://666kb.com/i/cifvfsu3e2sdiipn0.gif) 4px 7px no-repeat !important;} </style>').appendTo('head');
  878. uw.Layout.notify(nid, uw.NotificationType.SYSTEMMESSAGE,
  879. "<span style='color:rgb(8, 207, 0)'><b><u>New Feature!</u></b></span>"+ feature +
  880. "<span class='small notification_date'>DIO-Tools: v"+ GM_info.script.version +"</span>");
  881. }
  882.  
  883. // Scroll trough the 2-3 views
  884. function scrollViews(){
  885. var scroll = 2;
  886. $('#main_area, .ui_city_overview').bind('mousewheel', function(e){
  887. if($('.island_view').hasClass('checked')){
  888. scroll = 2;
  889. } else if($('.strategic_map').hasClass('checked')){
  890. scroll = 1;
  891. } else {
  892. scroll = 3;
  893. }
  894. var delta = 0;
  895. if (e.originalEvent.wheelDelta) {
  896. if(e.originalEvent.wheelDelta < 0) { delta = -1;} else { delta = 1; }
  897. }
  898. else if (e.originalEvent.detail) {
  899. if(e.originalEvent.detail < 0) { delta = 1;} else { delta = -1; }
  900. }
  901. if(delta < 0) {
  902. scroll -= 1;
  903. if(scroll < 1) { scroll = 1; }
  904. }else {
  905. scroll += 1;
  906. if(scroll > 2 && options.tov) { scroll = 2; }
  907. if(scroll > 3) { scroll = 3; }
  908. }
  909. switch(scroll){
  910. case 1: $('.strategic_map').get(0).click(); break;
  911. case 2: $('.island_view').get(0).click(); break;
  912. case 3: $('.city_overview').get(0).click(); break;
  913. }
  914. //prevent page fom scrolling
  915. return false;
  916. });
  917. }
  918.  
  919.  
  920.  
  921.  
  922.  
  923. // New Message Signal
  924. function catchNewMessages(){
  925. var message = new MutationObserver(function(mutations) {
  926. mutations.forEach(function(mutation) {
  927. if(mutation.addedNodes[0]){
  928. $("#alarm_sound").trigger('play');
  929. }
  930. });
  931. });
  932. message.observe($('.nui_main_menu .messages .indicator').get(0), { attributes: false, childList: true, characterData: false});
  933. message.observe($('.nui_main_menu .reports .indicator').get(0), { attributes: false, childList: true, characterData: false});
  934. }
  935.  
  936. function messageSound(){
  937. var audioElement = '<audio id="alarm_sound"><source src="' + alarmSound + '" type="audio/mpeg" /></audio>';
  938. $('body').append(audioElement);
  939. $("#alarm_sound").get(0).volume=0.05;
  940. catchNewMessages();
  941. }
  942.  
  943.  
  944. function test(){
  945. //http://gpde.innogamescdn.com/images/game/temp/island.png
  946. //console.log(uw.WMap);
  947. //console.log(uw.WMap.getSea(uw.WMap.getXCoord(), uw.WMap.getYCoord()));
  948. console.log(uw.ITowns.townGroups.getGroups());
  949. console.log(uw.Game);
  950. //console.log(uw.GameControllers.LayoutToolbarActivitiesController().prototype.getActivityTypes());
  951. //console.log(uw.GameViews);
  952. console.log(uw.GameViews.BarracksUnitDetails());
  953. //,span.countdown(MenuBubbleMovement.unit_movements[i].arrival_at,{
  954. //console.log(uw.ITowns.getTown(uw.Game.townId).unitsOuter().sword);
  955. //console.log(uw.ITowns.getCurrentTown().unitsOuter().sword);
  956. //console.log(uw.ITowns.getTown(uw.Game.townId).researches().attributes);
  957. //console.log(uw.ITowns.getTown(uw.Game.townId).hasConqueror());
  958. //console.log(uw.ITowns.getTown(uw.Game.townId).allUnits());
  959. //console.log(uw.ITowns.all_units.fragments[uw.Game.townId]._byId);
  960. //console.log("Zeus: " + uw.ITowns.player_gods.zeus_favor_delta_property.lastTriggeredVirtualPropertyValue);
  961. //console.log(uw.ITowns.player_gods.attributes);
  962. //console.log(uw.ITowns.getTown('5813').createTownLink());
  963. //console.log(uw.GameControllers);
  964. //console.log(uw.GameControllers.LayoutToolbarActivitiesController.prototype);
  965. //console.log(uw.GameControllers.LayoutToolbarActivitiesController.prototype.getActivityTypes());//alliance_id: 69
  966. //console.log(uw.ITowns.getTown(5813).unitsOuterTown);
  967. //console.log(uw.ITowns.getTown(uw.Game.townId).getLinkFragment());
  968. //var favor = JSON.parse();
  969. //console.log(uw.ITowns.getTown(uw.Game.townId).allGodsFavors());
  970. }
  971.  
  972. /*******************************************************************************************************************************
  973. * Statistics
  974. * ----------------------------------------------------------------------------------------------------------------------------
  975. * | ● Expansion of towns?
  976. * | ● Occupancy of the farms?
  977. * | ● Mouseclick-Counter?
  978. * | ● Resource distribution (%)?
  979. * | ● Building level counter ?
  980. * ----------------------------------------------------------------------------------------------------------------------------
  981. *******************************************************************************************************************************/
  982.  
  983. function addStatsButton(){
  984. $('<div class="btn_statistics circle_button"><div class="ico_statistics js-caption"></div></div>').appendTo(".gods_area");
  985. $('.btn_statistics').css({
  986. top: '56px',
  987. left: '-4px',
  988. zIndex: '10',
  989. position: 'absolute'
  990. });
  991. $('.btn_statistics .ico_statistics').css({
  992. margin: '7px 0px 0px 8px', width: '17px', height: '17px',
  993. 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
  994. backgroundSize: "100%",
  995. //WebkitFilter: 'hue-rotate(100deg)',
  996. //filter: 'url(#Hue3)'
  997. });
  998. mouseclickCounter();
  999. $('.btn_statistics').on('mousedown', function(){
  1000. $('.ico_statistics').get(0).style.marginTop = "8px";
  1001. });
  1002. $('.btn_statistics').toggle(function(){
  1003. $('.btn_statistics').addClass("checked");
  1004. $('.ico_statistics').get(0).style.marginTop = "8px";
  1005. //console.log(click_cnt);
  1006. $('#statistics_box').get(0).style.display = "block";
  1007. $('#statistics_box').get(0).style.zIndex = getMaxZIndex() + 1;
  1008. }, function(){
  1009. $('.btn_statistics').removeClass("checked");
  1010. $('.ico_statistics').get(0).style.marginTop = "7px";
  1011. $('#statistics_box').get(0).style.display = "none";
  1012. });
  1013. $('.btn_statistics').tooltip(LANG[LID].uni);
  1014. }
  1015.  
  1016. var click_cnt = 0;
  1017. function mouseclickCounter(){
  1018. // TODO: start date and reset button
  1019. $('body').click(function(){
  1020. click_cnt++;
  1021. });
  1022. }
  1023.  
  1024. /*******************************************************************************************************************************
  1025. * Body Handler
  1026. * ----------------------------------------------------------------------------------------------------------------------------
  1027. * | ● Town icon
  1028. * | ● Town list: Adds town type to the town list
  1029. * | ● Swap Context Icons
  1030. * | ● City overview
  1031. * ----------------------------------------------------------------------------------------------------------------------------
  1032. *******************************************************************************************************************************/
  1033.  
  1034. var townTypeIcon = {
  1035. 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
  1036. ld: "http://s7.directupload.net/images/140129/zwts6zz8.png", // blue: http://s1.directupload.net/images/140129/oua87w9q.png
  1037. so: "http://s7.directupload.net/images/140129/674supp9.png", // smaller: http://s14.directupload.net/images/140129/x7jv2kc9.png
  1038. sd: "http://s14.directupload.net/images/140129/aseivxpl.png",
  1039. fo: "http://s14.directupload.net/images/140129/j9mwfuu4.png", // bright: http://s1.directupload.net/images/140129/7ueia7ja.png
  1040. fd: "http://s7.directupload.net/images/140129/lwtlj9ej.png", // bright: http://s1.directupload.net/images/140129/4an4dhr7.png
  1041. 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
  1042. po: "http://gpde.innogamescdn.com/images/game/res/pop.png",
  1043. no: "http://s7.directupload.net/images/140129/t8tjs543.png", // green: http://s7.directupload.net/images/140129/zneb6f3m.png
  1044. // 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
  1045. // Manual Icons
  1046. fa: "http://s7.directupload.net/images/140404/xt839us6.png", // "http://s7.directupload.net/images/140404/xifwkdqy.png",
  1047. re: "http://s14.directupload.net/images/140404/b4n3tyjh.png",
  1048. di: "http://s14.directupload.net/images/140404/nvqxx5j7.png",
  1049. sh: "http://s1.directupload.net/images/140404/mbvpptpg.png",
  1050. lu: "http://s1.directupload.net/images/140404/38n97lp5.png",
  1051. // ro: "http://s14.directupload.net/images/140404/9o22obra.png",
  1052. dp: "http://s1.directupload.net/images/140404/95cgvzcp.png",
  1053. ha: "http://s1.directupload.net/images/140404/9om7bf4m.png",
  1054. si: "http://s1.directupload.net/images/140404/b5eumrw7.png",
  1055. ra: "http://s14.directupload.net/images/140404/3qofe863.png",
  1056. ch: "http://s7.directupload.net/images/140404/jrthehnw.png",
  1057. ti: "http://s7.directupload.net/images/140404/u2a5x7as.png", // "http://s1.directupload.net/images/140404/ceubhq4f.png",
  1058. 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",
  1059. wd: "http://s7.directupload.net/images/140404/te9zldjx.png",
  1060. wo: "http://s1.directupload.net/images/140404/cxbjhapw.png",
  1061. bo: "http://s14.directupload.net/images/140404/ki4gwd7x.png",
  1062. gr: "http://s14.directupload.net/images/140404/n7bq4ixc.png",
  1063. st: "http://s1.directupload.net/images/140404/zwc8ctqh.png",
  1064. is: "http://s1.directupload.net/images/140404/48nlm7xd.png",
  1065. he: "http://s7.directupload.net/images/140404/uldko8rb.png",
  1066. 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" //
  1067. };
  1068.  
  1069. function setTownIconsOnMap(){
  1070. var style_str = "'<style type='text/css'>"
  1071. for(var e in autoTownTypes){
  1072. if(autoTownTypes.hasOwnProperty(e)){
  1073. style_str += ""
  1074. if($('#mini_t'+ e).get(0)){
  1075. $('#mini_t'+ e).get(0).innerHTML = "";
  1076. $('#mini_t'+ e).css({
  1077. height: '18px',
  1078. width: '18px',
  1079. borderRadius: '11px',
  1080. border: '2px solid rgb(16, 133, 0)',
  1081. margin: '-3px',
  1082. background: 'rgb(255, 187, 0) url(http://s7.directupload.net/images/140129/zwts6zz8.png) 2px 1px no-repeat',
  1083. backgroundSize: '15px',
  1084. });
  1085. //$('#mini_t'+ e).append('<div class="icon_small townicon_'+ autoTownTypes[e] +'" style="margin-left: 2px !important; background-size: 15px !important"></div>');
  1086. }
  1087. }
  1088. }
  1089. style_str += "</style>"
  1090. $('<style type="text/css">.m_town { height: 18px; width: 18px; border-radius: 11px; border: 2px solid rgb(16, 133, 0); margin: -3px; background-size: 15px; fontSize: 0em;} </style>').appendTo('head');
  1091. var map = new MutationObserver(function(mutations) {
  1092. mutations.forEach(function(mutation) {
  1093. //console.log(mutation);
  1094. if(mutation.removedNodes[0] || mutation.addedNodes[0]){
  1095. for(var e in autoTownTypes){
  1096. if(autoTownTypes.hasOwnProperty(e)){
  1097. if($('#mini_t'+ e).get(0)){
  1098. //$('#mini_t'+ e).get(0).innerHTML = "";
  1099. $('#mini_t'+ e).css({
  1100. height: '18px',
  1101. width: '18px',
  1102. borderRadius: '11px',
  1103. border: '2px solid rgb(16, 133, 0)',
  1104. margin: '-3px',
  1105. background: 'rgb(255, 187, 0) url(http://s7.directupload.net/images/140129/zwts6zz8.png) 2px 1px no-repeat',
  1106. backgroundSize: '15px',
  1107. fontSize: '0em'
  1108. });
  1109. //$('#mini_t'+ e).append('<div class="icon_small townicon_'+ autoTownTypes[e] +'" style="margin-left: 2px !important; background-size: 15px !important"></div>');
  1110. }
  1111. }
  1112. }
  1113. for(var e in manuTownTypes){
  1114. if(manuTownTypes.hasOwnProperty(e)){
  1115. //console.log(e);
  1116. if($('#mini_t'+ e).get(0)){
  1117. /*
  1118. $('#mini_t'+ e).get(0).innerHTML = "";
  1119. $('#mini_t'+ e).css({
  1120. backgroundColor: 'rgb(255, 187, 0)',
  1121. height: '18px',
  1122. width: '18px',
  1123. borderRadius: '11px',
  1124. border: '2px solid rgb(16, 133, 0)',
  1125. margin: '-3px -3px'
  1126. });
  1127. */
  1128. //$('#mini_t'+ e).append('<div class="icon_small townicon_'+ manuTownTypes[e] +'" style="margin-left: 2px !important; background-size: 15px !important"></div>');
  1129. }
  1130. }
  1131. }
  1132. //var autoTownTypes = {}; // town type (ld, lo, sd, so, fd, fo)
  1133. //appendTo()
  1134. //mini_t45738
  1135. }
  1136. });
  1137. });
  1138. map.observe($('#map_towns').get(0), { attributes: false, childList: true, characterData: false});
  1139. }
  1140.  
  1141.  
  1142. for(var s in townTypeIcon){
  1143. if(townTypeIcon.hasOwnProperty(s)){
  1144. $('<style type="text/css">.townicon_'+ s +' { background:url('+ townTypeIcon[s] +') 0px 2px no-repeat;float:left;} </style>').appendTo('head');
  1145. }
  1146. }
  1147.  
  1148.  
  1149. // City overview
  1150. function setCityWindowContext(){
  1151. // $.each($("#goToTown").data("events"), function(i, e) { console.log(i); });
  1152. $('#goToTown').unbind("mousedown");
  1153. $('#goToTown').on("mousedown", function(){
  1154. uw.GPWindowMgr.Create(uw.Layout.wnd.TYPE_TOWNINDEX, "City view - "+ uw.ITowns.getTown(uw.Game.townId).name);
  1155. if($('#select_town').get(0)) {$('#select_town').mousedown(); }
  1156. var town = setInterval(function(){
  1157. if($('#town_background').get(0)){
  1158. document.getSelection().removeAllRanges();
  1159. clearInterval(town);
  1160. }
  1161. }, 50);
  1162. });
  1163. }
  1164. function setCityWindowButton(){
  1165. $("#ui_box .bull_eye_buttons .city_overview").appendTo('#ui_box .bull_eye_buttons');
  1166. $("#ui_box .bull_eye_buttons .city_overview").css({
  1167. left: '18px',
  1168. top: '3px'
  1169. });
  1170. $('.bull_eye_buttons .city_overview').on("click", function(){
  1171. uw.GPWindowMgr.Create(uw.Layout.wnd.TYPE_TOWNINDEX, "City view - "+ uw.ITowns.getTown(uw.Game.townId).name);
  1172. });
  1173. }
  1174.  
  1175. var i = 0;
  1176. function bodyHandler(){
  1177. var town_list = new MutationObserver(function(mutations) {
  1178. mutations.forEach(function(mutation) {
  1179. if(mutation.addedNodes[0]){
  1180. if(mutation.addedNodes[0].className.split(" ")[2] === "town_groups_list"){
  1181. changeTownList();
  1182. }
  1183. }
  1184. });
  1185. });
  1186. var body = new MutationObserver(function(mutations) {
  1187. //console.log(mutations);
  1188. mutations.forEach(function(mutation) {
  1189. if(mutation.addedNodes[0]){
  1190. // Town list
  1191. if(mutation.addedNodes[0].id === "town_groups_list" && options.twn){
  1192. changeTownList();
  1193. town_list.observe($('#town_groups_list').get(0), { attributes: false, childList: true, characterData: false});
  1194. }
  1195. // Context menu
  1196. if(mutation.addedNodes[0].id === "context_menu"){
  1197. // Swap context menu buttons
  1198. if(options.con && $('#context_menu').children().length == 4){
  1199. $('#context_menu div#goToTown').css({
  1200. left: '0px',
  1201. top: '0px',
  1202. WebkitAnimation: 'A 0s linear',
  1203. animation: 'B 0s linear'
  1204. });
  1205. }
  1206. if(LID === "de" && $('#select_town').get(0)){
  1207. $("#select_town .text").get(0).innerHTML = "Selektieren<span class='bottom'></span>";
  1208. }
  1209. // Set goToTown button
  1210. if(options.tov && $('#goToTown').get(0)){
  1211. setCityWindowContext();
  1212. }
  1213. }
  1214. }
  1215. });
  1216. });
  1217. body.observe($('body').get(0), { attributes: false, childList: true, characterData: false});
  1218. }
  1219.  
  1220. function swapContextMenu(){
  1221. if(!$('#select_town').get(0) && !$('#espionage').get(0)){
  1222. var ani_duration = 0;
  1223. $('<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);
  1224. $('<style id="dio_context" type="text/css"> #context_menu div#goToTown { left: 30px; top: -51px; '+
  1225. '-webkit-animation: A 0.115s linear; animation: B 0.2s;} '+
  1226. '@-webkit-keyframes A { from {left: 0px; top: 0px;} to {left: 30px; top: -51px;} }'+
  1227. '@keyframes B { from {left: 0px; top: 0px;} to {left: 30px; top: -51px;} }'+
  1228. '</style>').appendTo('head');
  1229. $('<style type="text/css"> img { '+
  1230. '-moz-user-select: -moz-none;'+
  1231. '-khtml-user-select: none;'+
  1232. '-webkit-user-select: none;} '+
  1233. '</style>').appendTo('head');
  1234. }
  1235. }
  1236.  
  1237. function setTownList(){
  1238. $('<style type="text/css"> #town_groups_list .item { text-align: left; padding-left:35px;} </style>').appendTo('head');
  1239. //$('<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');
  1240. $('<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');
  1241. $('<style type="text/css"> .island_quest_icon { float: right; margin: 3px 10px;} </style>').appendTo('head');
  1242. $('<style type="text/css"> #town_groups_list .jump_town { right: 30px !important;} </style>').appendTo('head');
  1243. $('<style type="text/css"> .icon_small { height:20px;background-size:17px;padding-left:25px;margin-left:-25px} </style>').appendTo('head');
  1244. }
  1245.  
  1246. function changeTownList(){
  1247. var town_id;
  1248. $("#town_groups_list .item").each(function() {
  1249. town_id = $(this).attr('name');
  1250. var str = $(this).get(0).innerHTML;
  1251. if (!(str.indexOf("townicon") >= 0)){
  1252. $(this).get(0).innerHTML = '<div class="icon_small townicon_'+ (manuTownTypes[town_id] || autoTownTypes[town_id] || "no") +'"></div>'+ $(this).get(0).innerHTML;
  1253. }
  1254. $(this).unbind();
  1255. $(this).click(function(e){
  1256. uw.Layout.contextMenu(e, 'determine', {"id":7407,"name":"K4 Asura"});
  1257. });
  1258. });
  1259. }
  1260.  
  1261. function addTownIcon(){
  1262. // Quickbar modification
  1263. $('.ui_quickbar .left,.ui_quickbar .right').css({ width: '46%' });
  1264. //<div id="town_iconv"></div>
  1265. $('<div id="town_icon"><div class="icon_big townicon_'+
  1266. (manuTownTypes[uw.Game.town_id] || ((autoTownTypes[uw.Game.townId] || "no") + " auto")) + '"></div></div>').appendTo('.town_name_area');
  1267. //http://s1.directupload.net/images/140325/pkyqax3q.png
  1268. $('.icon_big').removeClass().addClass('icon_big townicon_'+ (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")) + " auto"));
  1269. $('.town_name_area').css({ zIndex: 11, left: '52%' }); // because of Kapsonfires Script and Beta Worlds bug report bar
  1270. $('#town_icon').css({
  1271. background: 'url(http://s7.directupload.net/images/140325/nrdm9fm9.png) 0 0 no-repeat', // http://s1.directupload.net/images/140325/pkyqax3q.png
  1272. position: 'absolute',
  1273. width: '69px',
  1274. height: '61px',
  1275. left: '-47px',
  1276. top: '0px',
  1277. zIndex: 10
  1278. });
  1279. $('.town_name_area .left').css({
  1280. zIndex: 20,
  1281. left: '-39px'
  1282. });
  1283. $('#town_iconv').css({
  1284. background: 'url(http://s1.directupload.net/images/140325/5wen8bb2.png) 0 0 no-repeat', // http://s1.directupload.net/images/140325/pkyqax3q.png
  1285. position: 'absolute',
  1286. width: '63px',
  1287. height: '38px',
  1288. left: '73px',
  1289. top: '54px'
  1290. });
  1291. $('.icon_big').css({
  1292. position: 'absolute',
  1293. left: '35px',
  1294. top: '11px',
  1295. backgroundSize: '100%',
  1296. height: '27px',
  1297. width: '25px'
  1298. });
  1299. //var icoArray = [ 'ko', 'wd', 'bo', 'gr', 'st', 'lu','dp','ha','si','ra','ch','ti','un','fa', 're', 'di', 'sh', 'ld', 'lo', 'bu', 'sd', 'so', 'po', 'fd', 'fo', 'no'];
  1300. var icoArray = ['ld', 'lo', 'sh', 'di', 'un',
  1301. 'sd', 'so', 'ko', 'ti', 'gr',
  1302. 'fd', 'fo', 'dp', 'no','po',
  1303. 're', 'wd', 'st', 'si', 'bu',
  1304. 'he', 'ch', 'bo', 'fa', 'wo'];
  1305. // Select boxes for unit and ratio
  1306. $('<div class="select_town_icon dropdown-list default active">'+
  1307. '<div class="item-list">'+
  1308. '</div></div>').appendTo("#town_icon");
  1309. for(var i in icoArray){
  1310. if(icoArray.hasOwnProperty(i)){
  1311. $('.select_town_icon .item-list').append('<div class="option_s icon_small townicon_'+ icoArray[i] +'" name="'+ icoArray[i] +'"></div>');
  1312. }
  1313. }
  1314. $('<hr style="color:black; border:1px dashed black; float: left; width: 140px; margin: 0px 0px 7px 0px; position: relative;top: 3px;">'+
  1315. '<div class="option_s auto_s" name="auto"><b>Auto</b></div>').appendTo('.select_town_icon .item-list');
  1316. $('<style type="text/css"> #town_icon .sel {border: 2px solid rgba(0,0,0,0.2)} </style>').appendTo('head');
  1317. // Styles
  1318. $('.select_town_icon').css({
  1319. position: 'absolute',
  1320. top: '47px',
  1321. left: '23px',
  1322. width: '140px',
  1323. display: "none",
  1324. padding: '2px',
  1325. border: '3px inset rgb(7, 99, 12)',
  1326. boxShadow: 'rgba(0, 0, 0, 0.5) 4px 4px 6px',
  1327. borderRadius: '0px 10px 10px 10px',
  1328. background: "url(http://gpde.innogamescdn.com/images/game/popup/middle_middle.png)"
  1329. });
  1330. $('#town_icon .item-list').css({ maxHeight: '400px', maxWidth: '200px', align: "right", overflowX: 'hidden' });
  1331. $('#town_icon .option_s').css({
  1332. //WebkitFilter: "sepia(40%)",
  1333. //filter: "url(#GrayScale)",
  1334. cursor: 'pointer',
  1335. color: 'black',
  1336. float: 'left',
  1337. width: '20px',
  1338. height: '20px',
  1339. margin: '0px',
  1340. padding: '2px',
  1341. border: '2px solid rgba(0,0,0,0.0)',
  1342. borderRadius: "5px",
  1343. backgroundPosition: "4px 4px"
  1344. });
  1345. $('#town_icon .auto_s').css({
  1346. float: 'left',
  1347. paddingTop:'2px',
  1348. width: '132px',
  1349. border:'2px solid rgba(0,0,0,0.0)',
  1350. borderRadius: '5px',
  1351. height: '15px',
  1352. lineHeight: 1
  1353. });
  1354. // hover effects of the elements in the drop menu
  1355. $('#town_icon .option_s').hover(
  1356. function(){
  1357. $(this).css({"-webkit-filter" : "grayscale(0%) sepia(0%) brightness(1.3)", "filter": "none"});
  1358. $(this).get(0).style.border = "2px solid rgba(50, 80, 70, 0.6)";
  1359. },
  1360. function(){
  1361. $('#town_icon .option_s').css({"-webkit-filter" : "grayscale(0%) sepia(0%) brightness(1.0)", "filter": "none"});
  1362. $('#town_icon .option_s').css({ border: "2px solid rgba(0,0,0,0.0)"});
  1363. $('#town_icon .sel').css({ border: "2px solid rgba(0,0,0,0.2)"});
  1364. }
  1365. );
  1366. $('#town_icon .option_s').each(function(){
  1367. $(this).click(function(){
  1368. $(".select_town_icon .sel").toggleClass("sel");
  1369. $(this).addClass("sel");
  1370. if($(this).attr("name") === "auto"){
  1371. delete manuTownTypes[uw.Game.townId];
  1372. } else {
  1373. manuTownTypes[uw.Game.townId] = $(this).attr("name");
  1374. }
  1375. setTimeout(function(){
  1376. GM_setValue("town_types", JSON.stringify(manuTownTypes));
  1377. }, 0);
  1378. changeTownIcon();
  1379. });
  1380. });
  1381. // show & hide drop menus on click
  1382. $('#town_icon').click(function(){
  1383. if($('.select_town_icon').get(0).style.display === "none"){
  1384. $('.select_town_icon').get(0).style.display = "block";
  1385. } else {
  1386. $('.select_town_icon').get(0).style.display = "none";
  1387. }
  1388. });
  1389. $('#town_icon .select_town_icon [name="'+ (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" :"" )) +'"]').addClass("sel").css({border: '2px solid rgba(0,0,0,0.2)'});
  1390. }
  1391.  
  1392. function changeTownIcon(){
  1393. $('.icon_big').removeClass().addClass('icon_big townicon_'+ (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no") + " auto")));
  1394. $('#town_icon .sel').removeClass("sel").css({border: '2px solid rgba(0,0,0,0.0)'});
  1395. $('#town_icon .select_town_icon [name="'+ (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" :"" )) +'"]').addClass("sel").css({border: '2px solid rgba(0,0,0,0.2)'});
  1396. }
  1397.  
  1398.  
  1399.  
  1400. /*******************************************************************************************************************************
  1401. * Helping functions
  1402. * ----------------------------------------------------------------------------------------------------------------------------
  1403. * | ● getUnitValues: Get unit values and overwrite some wrong values
  1404. * | ● getMaxZIndex: Get the highest z-index of "ui-dialog"-class elements
  1405. * ----------------------------------------------------------------------------------------------------------------------------
  1406. *******************************************************************************************************************************/
  1407.  
  1408. function getUnitValues(){
  1409. unitVal = uw.GameData.units;
  1410. // fix grepolis buggy values
  1411. unitVal.small_transporter.attack = unitVal.big_transporter.attack = unitVal.demolition_ship.attack = unitVal.militia.attack = 0;
  1412. unitVal.small_transporter.defense = unitVal.big_transporter.defense = unitVal.demolition_ship.defense = unitVal.colonize_ship.defense = 0;
  1413. }
  1414.  
  1415. function getMaxZIndex(){
  1416. var maxZ = Math.max.apply(null,$.map($("div[class^='ui-dialog']"), function(e,n){
  1417. if($(e).css('position')=='absolute'){
  1418. return parseInt($(e).css('z-index'), 10) || 1000;
  1419. }
  1420. }));
  1421. return (maxZ !== -Infinity)? maxZ + 1 : 1000;
  1422. }
  1423.  
  1424. /*******************************************************************************************************************************
  1425. * DIO-Menu (old)
  1426. * ----------------------------------------------------------------------------------------------------------------------------
  1427. * | ● Unit value comparison table: Compares the units values of each type
  1428. * | ● spell box
  1429. * ----------------------------------------------------------------------------------------------------------------------------
  1430. *******************************************************************************************************************************/
  1431.  
  1432. // DIO-Menu (old)
  1433. function addDIOMenu(){
  1434. $('<div class="DIO_MENU"><div class="m_left"></div>'+
  1435. '<div class="m_middle"><img class="m_cont" id="m_uni" src="http://666kb.com/i/cjq6cxia4ms8mn95r.png"></div>'+
  1436. '<div class="m_div"></div>'+
  1437. //'<div class="m_middle"><img class="m_cont" id="m_tim" src="http://wiki.en.grepolis.com/images/0/08/Time.png"></div>'+
  1438. //'<div class="m_div"></div>'+
  1439. //'<div class="m_middle"><img class="m_cont" id="m_hid" src="http://666kb.com/i/cjq6behmpr6ez3qjj.png"></div>'+
  1440. //'<div class="m_div"></div>'+
  1441. //'<div class="m_middle"><img class="m_cont" id="m_com" src="http://s7.directupload.net/images/140120/9zvc3s5z.png"></div>'+
  1442. //'<div class="m_div"></div>'+
  1443. //'<div class="m_middle"><img class="m_cont" id="m_trd" src="http://666kb.com/i/cjq6d72qk521ig1zz.png"></div>'+
  1444. //'<div class="m_div"></div>'+
  1445. '<div class="m_middle"><img class="m_cont" id="m_fav" src="http://s14.directupload.net/images/140120/tvfuuhep.png"></div>'+
  1446. //'<div class="m_middle"><img class="m_cont" id="m_def" src="http://wiki.en.grepolis.com/images/0/0e/Def_distance.png"></div>'+
  1447. '<div class="m_right"></div></div>').appendTo('.nui_toolbar .middle');
  1448. $('.DIO_MENU').css({
  1449. margin: '2px',
  1450. height: '30px',
  1451. width: '250px',
  1452. position: 'relative',
  1453. left: '0px',
  1454. float: 'left',
  1455. });
  1456. $('.m_left').css({
  1457. height: '27px',
  1458. width: '26px',
  1459. background:'url(http://gpde.innogamescdn.com/images/game/layout/layout_2.51_compressed.png) no-repeat -513px -127px',
  1460. float: 'left',
  1461. });
  1462. $('.m_right').css({
  1463. height: '27px',
  1464. width: '26px',
  1465. background:'url(http://gpde.innogamescdn.com/images/game/layout/layout_2.51_compressed.png) no-repeat -570px -127px', //
  1466. float: 'left',
  1467. });
  1468. $('.m_div').css({
  1469. height: '27px',
  1470. width: '2px',
  1471. background:'url(http://gpde.innogamescdn.com/images/game/layout/layout_2.51_compressed.png) no-repeat -567px -127px',
  1472. float: 'left',
  1473. });
  1474. $('.m_middle').css({
  1475. background:'url(http://gpde.innogamescdn.com/images/game/layout/layout_2.51_compressed.png) no-repeat -540px -127px',
  1476. height: '27px',
  1477. width: '26px',
  1478. float: 'left',
  1479. });
  1480. $('.m_cont').css({
  1481. margin: '2px',
  1482. height: '90%',
  1483. width: '90%',
  1484. WebkitFilter: 'hue-rotate(-60deg)',
  1485. filter: 'url(#Hue3)'
  1486. });
  1487. $('.m_cont').hover(
  1488. function() {
  1489. $(this).parent().css('background','url(http://gpde.innogamescdn.com/images/game/layout/layout_2.51_compressed.png) no-repeat -29px -307px');
  1490. $(this).css('cursor','pointer');
  1491. $(this).css({
  1492. WebkitFilter: 'hue-rotate(150deg)',
  1493. filter: 'url(#Hue2)'
  1494. });
  1495. }, function(){
  1496. $(this).parent().css('background','url(http://gpde.innogamescdn.com/images/game/layout/layout_2.51_compressed.png) no-repeat -540px -127px');
  1497. if($(this).hasClass('active')) {
  1498. $(this).css({
  1499. WebkitFilter: 'hue-rotate(60deg)',
  1500. filter: 'url(#Hue1)',
  1501. });
  1502. } else {
  1503. $(this).css({
  1504. WebkitFilter: 'hue-rotate(-60deg)',
  1505. filter: 'url(#Hue3)',
  1506. });
  1507. }
  1508. }
  1509. );
  1510. $('.m_cont').toggle(
  1511. function(){
  1512. $(this).toggleClass('active');
  1513. $(this).css('WebkitFilter','hue-rotate(60deg)');
  1514. switch(this.id){
  1515. case 'm_uni':
  1516. $('#unit_box').get(0).style.display = "block";
  1517. $('#unit_box').get(0).style.zIndex = getMaxZIndex() + 1;
  1518. break;
  1519. case 'm_fav': if(!$('.btn_gods_spells').hasClass("active")) {$('.btn_gods_spells').get(0).click(); } break;
  1520. }
  1521. }, function(){
  1522. $(this).toggleClass('active');
  1523. $(this).css('WebkitFilter','hue-rotate(-60deg)');
  1524. if(this.id === 'm_uni') $('#unit_box').get(0).style.display = "none";
  1525. if(this.id === 'm_fav') {if($('.btn_gods_spells').hasClass("active")) {$('.btn_gods_spells').get(0).click();}}
  1526. }
  1527. );
  1528. }
  1529.  
  1530. /*******************************************************************************************************************************
  1531. * Available units
  1532. * ----------------------------------------------------------------------------------------------------------------------------
  1533. * | ● Shows all available units
  1534. * ----------------------------------------------------------------------------------------------------------------------------
  1535. *******************************************************************************************************************************/
  1536. function addAvailableUnitsButton(){
  1537. $('<div class="btn_available_units circle_button"><div class="ico_available_units js-caption"></div></div>').appendTo(".bull_eye_buttons");
  1538. $('.btn_available_units').css({
  1539. top: '86px',
  1540. left: '119px',
  1541. zIndex: '10',
  1542. position: 'absolute'
  1543. });
  1544. $('.btn_available_units .ico_available_units').css({
  1545. margin: '5px 0px 0px 4px', width: '24px', height: '24px',
  1546. background: 'url(http://s1.directupload.net/images/140323/w4ekrw8b.png) no-repeat 0px 0px', //http://gpde.innogamescdn.com/images/game/res/unit.png
  1547. backgroundSize: "100%",
  1548. WebkitFilter: 'hue-rotate(100deg)',
  1549. filter: 'url(#Hue3)'
  1550. });
  1551. $('.btn_available_units').on('mousedown', function(){
  1552. $('.ico_available_units').get(0).style.marginTop = "6px";
  1553. });
  1554. $('.btn_available_units').toggle(function(){
  1555. $('#available_units_box').get(0).style.display = "block";
  1556. $('#available_units_box').get(0).style.zIndex = getMaxZIndex() + 1;
  1557. $('.btn_available_units').addClass("checked");
  1558. $('.ico_available_units').get(0).style.marginTop = "6px";
  1559. }, function(){
  1560. $('#available_units_box').get(0).style.display = "none";
  1561. $('.btn_available_units').removeClass("checked");
  1562. $('.ico_available_units').get(0).style.marginTop = "5px";
  1563. });
  1564. $('.btn_available_units').tooltip(LANG[LID].uni);
  1565. }
  1566.  
  1567. /*******************************************************************************************************************************
  1568. * Comparison
  1569. * ----------------------------------------------------------------------------------------------------------------------------
  1570. * | ● Compares the units of each unit type
  1571. * ----------------------------------------------------------------------------------------------------------------------------
  1572. *******************************************************************************************************************************/
  1573. function addComparisonButton(){
  1574. $('<div class="btn_comparison circle_button"><div class="ico_comparison js-caption"></div></div>').appendTo(".bull_eye_buttons");
  1575. $('.btn_comparison').css({
  1576. top: '51px',
  1577. left: '120px',
  1578. zIndex: '10',
  1579. position: 'absolute'
  1580. });
  1581. $('.btn_comparison .ico_comparison').css({
  1582. margin: '5px 0px 0px 4px', width: '24px', height: '24px',
  1583. background: 'url(http://666kb.com/i/cjq6cxia4ms8mn95r.png) no-repeat 0px 0px',
  1584. backgroundSize: "100%",
  1585. WebkitFilter: 'hue-rotate(60deg)',
  1586. filter: 'url(#Hue1)'
  1587. });
  1588. $('.btn_comparison').on('mousedown', function(){
  1589. $('.ico_comparison').get(0).style.marginTop = "6px";
  1590. });
  1591. $('.btn_comparison').toggle(function(){
  1592. $('#unit_box').get(0).style.display = "block";
  1593. $('#unit_box').get(0).style.zIndex = getMaxZIndex() + 1;
  1594. $('.btn_comparison').addClass("checked");
  1595. $('.ico_comparison').get(0).style.marginTop = "6px";
  1596. }, function(){
  1597. $('#unit_box').get(0).style.display = "none";
  1598. $('.btn_comparison').removeClass("checked");
  1599. $('.ico_comparison').get(0).style.marginTop = "5px";
  1600. });
  1601. $('.btn_comparison').tooltip(LANG[LID].com.dsc);
  1602. }
  1603.  
  1604. function addComparisonBox(){
  1605. var pos = {
  1606. att: { hack: "36%", pierce: "27%", distance: "45.5%", ship: "72.5%" },
  1607. def: { hack: "18%", pierce: "18%", distance: "18%", ship: "81.5%" }
  1608. };
  1609. var unitIMG = "http://de.cdn.grepolis.com/images/game/units/units_info_sprite2.51.png";
  1610. $('<div id="unit_box" class="ui-dialog">'+
  1611. '<div class="bbcode_box middle_center"><div class="bbcode_box middle_right"></div><div class="bbcode_box middle_left"></div>'+
  1612. '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div><div class="bbcode_box top_center"></div>'+
  1613. '<div class="bbcode_box bottom_center"></div><div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>'+
  1614. '<div style="height:20px; margin-left:35px;">'+
  1615. '<a class="hack" href="#" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att.hack +';">'+
  1616. '<span style="margin-left:20px">'+ LANG[LID].com.hck +'</span></a>'+
  1617. '<a class="pierce" href="#" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att.pierce +';">'+
  1618. '<span style="margin-left:20px">'+ LANG[LID].com.prc +'</span></a>'+
  1619. '<a class="distance" href="#" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att.distance +';">'+
  1620. '<span style="margin-left:20px">'+ LANG[LID].com.dst +'</span></a>'+
  1621. '<a class="ship" href="#" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att.ship +';">'+
  1622. '<span style="margin-left:20px">'+ LANG[LID].com.sea +'</span></a>'+
  1623. '</div><hr>'+
  1624. '<div class="box_content"></div></div>').appendTo('body');
  1625. $('#unit_box a').css({
  1626. float: 'left',
  1627. backgroundRepeat: 'no-repeat',
  1628. backgroundSize: '25px',
  1629. lineHeight: '2',
  1630. marginRight:'10px'
  1631. });
  1632. $('#unit_box span').css({
  1633. marginLeft: '27px',
  1634. });
  1635. $('#unit_box').draggable({
  1636. containment: "body",
  1637. snap: "body",
  1638. });
  1639. $('#unit_box').css({
  1640. position: 'absolute',
  1641. top: '100px',
  1642. left: '200px',
  1643. zIndex: getMaxZIndex() + 1,
  1644. display: 'none'
  1645. });
  1646. $('#unit_box .box_content').css({
  1647. background: 'url(http://s1.directupload.net/images/140206/8jd9d3ec.png) 94% 94% no-repeat',
  1648. backgroundSize: '140px'
  1649. });
  1650. $('#unit_box').bind("mousedown",function(){
  1651. $(this).get(0).style.zIndex = getMaxZIndex() + 1;
  1652. });
  1653. addComparisonTable("hack");
  1654. addComparisonTable("pierce");
  1655. addComparisonTable("distance");
  1656. addComparisonTable("ship");
  1657. $('#unit_box .t_hack').get(0).style.display = "block";
  1658. switchComparisonTables();
  1659. $('#unit_box hr').css({ border: '1px solid', color: '#804000', float:'none' });
  1660. }
  1661.  
  1662. function switchComparisonTables(){
  1663. $('#unit_box .hack, #unit_box .pierce, #unit_box .distance, #unit_box .ship').click(function(){
  1664. $('#unit_box [class^="t_"]').css({ display : "none" });
  1665. $('#unit_box .t_'+this.className).get(0).style.display = "block";
  1666. });
  1667. }
  1668.  
  1669. var ttpArray = [], t = 0;
  1670. function addComparisonTable(type){
  1671. var pos = {
  1672. att: { hack: "36%", pierce: "27%", distance: "45.5%", ship: "72.5%" },
  1673. def: { hack: "18%", pierce: "18%", distance: "18%", ship: "81.5%" }
  1674. };
  1675. var unitIMG = "http://de.cdn.grepolis.com/images/game/units/units_info_sprite2.51.png";
  1676. var strArray = [
  1677. "<td></td>",
  1678. '<td><div class="bla" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.att[type] +';"></div></td>',
  1679. '<td><div class="bla" style="background: url('+ unitIMG +'); background-position: 0% '+ pos.def[type] +';"></div></td>',
  1680. '<td><div class="bla" style="background: url('+ unitIMG +'); background-position: 0% 63%;"></div></td>',
  1681. (type !== "ship") ? '<td><div class="booty"></div></td>' : '<td><div class="bla" style="background-image: url('+ unitIMG +'); background-position: 0% 91%;"></div></td>',
  1682. '<td><div class="bla" style="background: url('+ unitIMG +'); background-position: 0% 54%;"></div></td>',
  1683. '<td><div class="bla" style="background: url(http://de.cdn.grepolis.com/images/game/res/favor.png)"></div></td>',
  1684. '<td><div class="bla" style="background: url(http://de.cdn.grepolis.com/images/game/res/time.png);"></div></td>'
  1685. ];
  1686. for(var e in unitVal){
  1687. if(unitVal.hasOwnProperty(e)){
  1688. var valArray = [];
  1689. if(type === (unitVal[e].attack_type || "ship") && (e !== "militia")) {
  1690. valArray.att = Math.round(unitVal[e].attack*10 / unitVal[e].population) / 10;
  1691. valArray.def = Math.round(((unitVal[e].def_hack + unitVal[e].def_pierce + unitVal[e].def_distance)*10)/(3*unitVal[e].population)) / 10;
  1692. valArray.def = valArray.def || Math.round(unitVal[e].defense*10/unitVal[e].population) / 10;
  1693. valArray.speed = unitVal[e].speed;
  1694. valArray.booty = Math.round(((unitVal[e].booty)*10) / unitVal[e].population) / 10;
  1695. valArray.booty = valArray.booty || Math.round(((unitVal[e].capacity ? unitVal[e].capacity + 6 : 0)*10) / unitVal[e].population) / 10;
  1696. valArray.favor = Math.round((unitVal[e].favor *10)/ unitVal[e].population) / 10;
  1697. valArray.res = Math.round((unitVal[e].resources.wood + unitVal[e].resources.stone + unitVal[e].resources.iron)/(unitVal[e].population));
  1698. valArray.time = Math.round(unitVal[e].build_time / unitVal[e].population);
  1699. valArray.hero = (!uw.Game.is_hero_world && ((e === "griffin") || (e === "calydonian_boar")))? "-webkit-filter:grayscale(100%); filter: url(#GrayScale)": "";
  1700. strArray[0] += '<td class="un'+ (t) +'"><div class="unit index_unit unit_icon40x40 ' + e + '" style="'+ valArray.hero +'"></div></td>';
  1701. strArray[1] += '<td class="bold" style="color:'+ ((valArray.att>19)?'green':((valArray.att<10 && valArray.att!=0 )?'red':'black')) +';">'+ valArray.att +'</td>';
  1702. strArray[2] += '<td class="bold" style="color:'+ ((valArray.def>19)?'green':((valArray.def<10 && valArray.def!=0 )?'red':'black')) +';">'+ valArray.def +'</td>';
  1703. strArray[3] += '<td class="bold">'+ valArray.speed +'</td>';
  1704. strArray[4] += '<td class="bold">'+ valArray.booty +'</td>';
  1705. strArray[5] += '<td class="bold">'+ valArray.res +'</td>';
  1706. strArray[6] += '<td class="bold" style="color:'+ ((valArray.favor>0)?'rgb(0, 0, 214)':'black') +';">'+ valArray.favor +'</td>';
  1707. strArray[7] += '<td class="bold">'+ valArray.time +'</td>';
  1708. ttpArray[t] = unitVal[e].name; t++;
  1709. }
  1710. }
  1711. }
  1712. $('<table class="t_'+ type +'" cellpadding="1px" style="display:none">'+
  1713. '<tr>'+ strArray[0] +'</tr>'+
  1714. '<tr class="tr_att">'+ strArray[1] +'</tr><tr class="tr_def">'+ strArray[2] +'</tr>'+
  1715. '<tr class="tr_spd">'+ strArray[3] +'</tr><tr class="tr_bty_'+ type +'">'+ strArray[4] +'</tr>'+
  1716. '<tr class="tr_res">'+ strArray[5] +'</tr><tr class="tr_fav">'+ strArray[6] +'</tr><tr class="tr_tim">'+ strArray[7] +'</tr>'+
  1717. '</table>').appendTo('#unit_box .box_content');
  1718. for(var i = 0; i <= t; i++){
  1719. $('.un'+i).tooltip(ttpArray[i]);
  1720. }
  1721. $('.tr_att').tooltip(LANG[LID].com.att);
  1722. $('.tr_def').tooltip(LANG[LID].com.def + " (Ø)");
  1723. $('.tr_spd').tooltip(LANG[LID].com.spd);
  1724. $('.tr_bty_'+ type).tooltip(((type!=="ship")? LANG[LID].com.bty : LANG[LID].com.cap));
  1725. $('.tr_res').tooltip(LANG[LID].com.res);
  1726. $('.tr_fav').tooltip(LANG[LID].com.fav);
  1727. $('.tr_tim').tooltip(LANG[LID].com.tim);
  1728. //$('#unit_box .box_content').css({ position: 'relative' });
  1729. $('#unit_box .bla').css({
  1730. height: '25px',
  1731. width: '25px',
  1732. backgroundSize: '100%',
  1733. float: 'left'
  1734. });
  1735. $('#unit_box .booty').css({
  1736. width: '25px',
  1737. height: '25px',
  1738. background: 'url(http://de.cdn.grepolis.com/images/game/layout/layout_2.56_compressed.png)',
  1739. backgroundSize: '3400%',
  1740. backgroundPosition: '0% 58.5%'
  1741. });
  1742. }
  1743.  
  1744. /*******************************************************************************************************************************
  1745. * Reports and Messages
  1746. * ----------------------------------------------------------------------------------------------------------------------------
  1747. * | ● Storage of the selected filter (only in German Grepolis yet)
  1748. * ----------------------------------------------------------------------------------------------------------------------------
  1749. *******************************************************************************************************************************/
  1750.  
  1751. var filter = "all";
  1752. function saveFilter(){
  1753. $('#dd_filter_type_list .item-list div').each(function(){
  1754. $(this).click(function(){
  1755. filter = $(this).attr("name");
  1756. });
  1757. });
  1758. /*
  1759. var i = 0;
  1760. $("#report_list a").each(function () {
  1761. console.log((i++) +" = " + $(this).attr('data-reportid'));
  1762. });
  1763. */
  1764. }
  1765.  
  1766. function loadFilter(){
  1767. if(!($('#dd_filter_type_list .selected').attr("name") === filter)){
  1768. $('#dd_filter_type .caption').get(0).click();
  1769. $('#dd_filter_type_list .item-list div[name='+ filter +']').get(0).click();
  1770. }
  1771. }
  1772.  
  1773. function removeReports(){
  1774. $("#report_list li:contains('spioniert')").each(function () {
  1775. //$(this).remove();
  1776. });
  1777. }
  1778.  
  1779.  
  1780. var zut = 0;
  1781. var messageArray = {};
  1782. function filterPlayer(){
  1783. if(!$('#message_filter_list').get(0)) {
  1784. $('<div id="message_filter_list" style="height:300px;overflow-y:scroll; width: 790px;"></div>').appendTo('#folder_container');
  1785. $("#message_list").get(0).style.display = "none";
  1786. }
  1787. if(zut < parseInt($('.es_last_page').get(0).value, 10)-1){
  1788. $('.es_page_input').get(0).value = zut++;
  1789. $('.jump_button').get(0).click();
  1790. $("#message_list li:contains('')").each(function () {
  1791. $(this).appendTo('#message_filter_list');
  1792. });
  1793. } else {
  1794. zut = 1;
  1795. }
  1796. }
  1797.  
  1798.  
  1799. /*******************************************************************************************************************************
  1800. * World Wonder
  1801. * ----------------------------------------------------------------------------------------------------------------------------
  1802. * | ● click adjustment
  1803. * | ● Share calculation (= ratio of player points to alliance points)
  1804. * | ● Resources calculation & counter (stores amount)
  1805. * | ● Adds missing previous & next buttons on finished world wonders (better browsing through world wonders)
  1806. * ----------------------------------------------------------------------------------------------------------------------------
  1807. *******************************************************************************************************************************/
  1808.  
  1809. // getPointRatio: Default
  1810. function getPointRatioFromGS(){
  1811. var gs = 0, AP = 0;
  1812. setTimeout(function(){
  1813. GM_xmlhttpRequest({
  1814. method: "GET",
  1815. url: "http://de.grepostats.com/world/" + WID + "/alliance/" + AID,
  1816. onload: function(response) {
  1817. gs = response.responseText;
  1818. gs = gs.substr(gs.indexOf("Punkte"));
  1819. gs = gs.substr(gs.indexOf("<td>")+4);
  1820. gs = gs.substr(0, gs.indexOf("</td>"));
  1821. AP = parseInt(gs.replace(/\,/g, ''), 10);
  1822. //console.log("Allianzpunkte: " + AP);
  1823. ratio = 100 / AP * uw.Game.player_points;
  1824. GM_setValue(WID + "_ratio", ratio);
  1825. }
  1826. });
  1827. }, 0);
  1828. }
  1829.  
  1830. function getPointRatioFromAllianceRanking(){
  1831. ratio = 100 / parseInt($('.current_player .r_points').get(0).innerHTML, 10) * uw.Game.player_points;
  1832. setTimeout(function(){
  1833. GM_setValue(WID + "_ratio", ratio);
  1834. },0);
  1835. }
  1836.  
  1837. function getPointRatioFromAllianceMembers(){
  1838. var points = 0;
  1839. $('#ally_members_body tr').each(function(){
  1840. points += parseInt($(this).children().eq(2).text(), 10) || 0;
  1841. });
  1842. ratio = 100 / points * uw.Game.player_points;
  1843. setTimeout(function(){
  1844. GM_setValue(WID + "_ratio", ratio);
  1845. },0);
  1846. }
  1847.  
  1848. if(uw.location.pathname === "/game/index"){
  1849. var ww_res = JSON.parse(GM_getValue(WID + "_ww_res", '{}'));
  1850. }
  1851.  
  1852. // TODO: Split function...
  1853. function getResWW(){
  1854. var wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_WONDERS);
  1855. for(var e in wndArray){
  1856. if(wndArray.hasOwnProperty(e)){
  1857. var wndID = "#gpwnd_" + wndArray[e].getID() + " ";
  1858. if(!$(wndID + '.wonder_finished').get(0)){
  1859. var res = 0,
  1860. ww_share = {total: {share:0, sum:0}, stage: {share:0, sum:0}},
  1861. ww_type = $(wndID + '.finished_image_small').attr('src').split("/")[6].split("_")[0], // Which world wonder?
  1862. res_stages = [ 2, 4, 6, 10, 16, 28, 48, 82, 140, 238], // Rohstoffmenge pro Rohstofftyp in 100.000 Einheiten
  1863. stage = parseInt($(wndID + '.wonder_expansion_stage span').get(0).innerHTML.split("/")[0], 10) + 1, // Derzeitige Füllstufe
  1864. speed = uw.Game.game_speed;
  1865. ww_res[ww_type] = ww_res[ww_type] || {};
  1866. ww_res[ww_type][stage] = ww_res[ww_type][stage] || 0;
  1867. if(!$(wndID + '.ww_ratio').get(0)) {
  1868. $('<fieldset class="ww_ratio"></fieldset>').appendTo(wndID + '.wonder_res_container .trade');
  1869. $(wndID + '.wonder_header').prependTo(wndID + '.wonder_progress');
  1870. $(wndID + '.wonder_res_container .send_res').insertBefore(wndID + '.wonder_res_container .next_level_res');
  1871. }
  1872. $(wndID + '.wonder_progress').css({
  1873. margin: '0 auto 5px'
  1874. });
  1875. $(wndID + '.wonder_header').css({
  1876. textAlign: 'left',
  1877. margin: '10px -8px 12px 3px'
  1878. });
  1879. $(wndID + '.build_wonder_icon').css({
  1880. top: '25px',
  1881. });
  1882. $(wndID + '.wonder_progress_bar').css({
  1883. top: '54px',
  1884. });
  1885. $(wndID + '.wonder_controls').css({
  1886. height: '380px',
  1887. });
  1888. $(wndID + '.trade fieldset').css({
  1889. float: 'right',
  1890. });
  1891. $(wndID + '.wonder_res_container').css({
  1892. right: '29px'
  1893. });
  1894. $(wndID + '.ww_ratio').css({
  1895. position: 'relative',
  1896. height: 'auto'
  1897. });
  1898. $(wndID + 'fieldset').css({
  1899. height: 'auto'
  1900. });
  1901. $(wndID + '.town-capacity-indicator').css({
  1902. marginTop: '0px'
  1903. });
  1904. for(var d in res_stages){
  1905. if(res_stages.hasOwnProperty(d)){
  1906. ww_share.total.sum += res_stages[d];
  1907. }
  1908. }
  1909. ww_share.total.sum *= speed * 300000;
  1910. ww_share.total.share = parseInt(ratio * (ww_share.total.sum / 100), 10);
  1911. ww_share.stage.sum = speed * res_stages[stage-1] * 300000;
  1912. ww_share.stage.share = parseInt(ratio * (ww_share.stage.sum / 100), 10); // ( 3000 = 3 Rohstofftypen * 100000 Rohstoffe / 100 Prozent)
  1913. setResWW(stage, ww_type, ww_share, wndID);
  1914. $(wndID + '.wonder_res_container .send_resources_btn').click(function(){
  1915. ww_res[ww_type][stage] += parseInt($(wndID + '#ww_trade_type_wood input:text').get(0).value, 10);
  1916. ww_res[ww_type][stage] += parseInt($(wndID + '#ww_trade_type_stone input:text').get(0).value, 10);
  1917. ww_res[ww_type][stage] += parseInt($(wndID + '#ww_trade_type_iron input:text').get(0).value, 10);
  1918. //console.log(ww_res[ww_type][stage]);
  1919. setResWW(stage, ww_type, ww_share, wndID);
  1920. setTimeout(function(){
  1921. GM_setValue(WID + "_ww_res", JSON.stringify(ww_res));
  1922. }, 0);
  1923. });
  1924. } else {
  1925. $('<div class="prev_ww pos_Y"></div><div class="next_ww pos_Y"></div>').appendTo(wndID + '.wonder_controls');
  1926. $(wndID + '.pos_Y').css({
  1927. top: '-266px',
  1928. });
  1929. }
  1930. }
  1931. }
  1932. }
  1933.  
  1934. function setResWW(stage, ww_type, ww_share, wndID){
  1935. //console.log(ww_res);
  1936. var width_stage, width_total, res_total = 0, disp_stage = "none", disp_total = "none";
  1937. for(var z in ww_res[ww_type]){
  1938. if(ww_res[ww_type].hasOwnProperty(z)){
  1939. res_total += ww_res[ww_type][z];
  1940. }
  1941. }
  1942. if(ww_share.stage.share > ww_res[ww_type][stage]){
  1943. width_stage = (242 / ww_share.stage.share) * ww_res[ww_type][stage];
  1944. } else {
  1945. width_stage = 0;
  1946. disp_stage = "block";
  1947. }
  1948. if(ww_share.total.share > res_total){
  1949. width_total = (242 / ww_share.total.share) * res_total;
  1950. } else {
  1951. width_total = 0;
  1952. disp_total = "block";
  1953. }
  1954. //console.log(ratio);
  1955. $(wndID + '.ww_ratio').get(0).innerHTML = "";
  1956. $(wndID + '.ww_ratio').append('<legend>'+ LANG[LID].wwc.leg +' (<span style="color:#090">'+ (Math.round(ratio * 100) / 100) +'%</span>):</legend>'+
  1957. '<div class="town-capacity-indicator">'+
  1958. '<div class="icon all_res"></div>'+
  1959. '<div id="ww_town_capacity_stadium" class="tripple-progress-progressbar">'+
  1960. '<div class="border_l"></div><div class="border_r"></div><div class="body"></div>'+
  1961. '<div class="progress overloaded">'+
  1962. '<div class="indicator3" style="left: 0px; width:'+ width_stage +'px"></div>'+
  1963. '<span class="ww_perc">' + Math.round(ww_res[ww_type][stage]/ww_share.stage.share*100) + '%</span>'+
  1964. '<div class="indicator4" style="left: 0px; display:'+ disp_stage +'"></div>'+
  1965. '</div>'+
  1966. '<div class="amounts">'+ LANG[LID].wwc.stg +': <span class="curr">'+ pointNumber(ww_res[ww_type][stage]) +'</span> / '+
  1967. '<span class="max">'+ pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) +'</span></div>'+
  1968. '</div></div>'+
  1969. '<div class="town-capacity-indicator">'+
  1970. '<div class="icon all_res"></div>'+
  1971. '<div id="ww_town_capacity_total" class="tripple-progress-progressbar">'+
  1972. '<div class="border_l"></div><div class="border_r"></div><div class="body"></div>'+
  1973. '<div class="progress overloaded">'+
  1974. '<div class="indicator3" style="left: 0px; width:'+ width_total +'px;"></div>'+
  1975. '<span class="ww_perc">'+ Math.round(res_total/ww_share.total.share*100) +'%</span>'+
  1976. '<div class="indicator4" style="left: 0px; display:'+ disp_total +'"></div>'+
  1977. '</div>'+
  1978. '<div class="amounts">'+ LANG[LID].wwc.tot +': <span class="curr">'+ pointNumber(res_total) +'</span> / '+
  1979. '<span class="max">'+ pointNumber((Math.round(ww_share.total.share / 1000) * 1000)) +'</span></div>'+
  1980. '</div></div>');
  1981. $('.ww_ratio .progress').css({
  1982. //position: 'absolute',
  1983. //textAlign: 'center',
  1984. lineHeight: '1',
  1985. color: 'white',
  1986. fontSize: '0.8em'
  1987. });
  1988. $(wndID + '.ww_perc').css({
  1989. position:'absolute',
  1990. width:'242px',
  1991. textAlign: 'center'
  1992. });
  1993. $(wndID + '.indicator4').css({
  1994. background: 'url(http://gpde.innogamescdn.com/images/game/layout/progressbars-sprite_2.53.png) no-repeat 0 0',
  1995. backgroundPosition: '0px -355px',
  1996. height: '10px',
  1997. zIndex: '13000',
  1998. width: '242px'
  1999. });
  2000. $(wndID + '.all_res').css({
  2001. background: 'url(http://de.cdn.grepolis.com/images/game/layout/resources_2.32.png) no-repeat 0 -90px',
  2002. width: '30px',
  2003. height: '30px',
  2004. margin: '0 auto',
  2005. marginLeft: '5px'
  2006. });
  2007. $(wndID + '.town-capacity-indicator').css({
  2008. marginTop: '0px'
  2009. });
  2010. $(wndID + '.ww_ratio').tooltip("<table style='border-spacing:0px; text-align:right' cellpadding='5px'><tr>"+
  2011. "<td align='right' style='border-right: 1px solid;border-bottom: 1px solid'></td>"+
  2012. "<td style='border-right: 1px solid; border-bottom: 1px solid'><span class='bbcodes_player bold'>("+ (Math.round((ratio) * 100) / 100) +"%)</span></td>"+
  2013. "<td style='border-bottom: 1px solid'><span class='bbcodes_ally bold'>(100%)</span></td></tr>"+
  2014. "<tr><td class='bold' style='border-right:1px solid;text-align:center'>"+ LANG[LID].wwc.stg + "&nbsp;" + stage +"</td>"+
  2015. "<td style='border-right: 1px solid'>"+ pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) +"</td>"+
  2016. "<td>" + pointNumber(Math.round(ww_share.stage.sum / 1000) * 1000) + "</td></tr>"+
  2017. "<tr><td class='bold' style='border-right:1px solid;text-align:center'>"+ LANG[LID].wwc.tot +"</td>"+
  2018. "<td style='border-right: 1px solid'>"+ pointNumber(Math.round(ww_share.total.share / 1000) * 1000) +"</td>"+
  2019. "<td>"+ pointNumber(Math.round(ww_share.total.sum / 1000) * 1000) +"</td>"+
  2020. "</tr></table>");
  2021. }
  2022.  
  2023. // Adds points to numbers
  2024. function pointNumber(number) {
  2025. var sep; if(LID === "de"){ sep = "."; } else { sep = ",";}
  2026. number = number.toString();
  2027. if (number.length > 3) {
  2028. var mod = number.length % 3;
  2029. var output = (mod > 0 ? (number.substring(0,mod)) : '');
  2030. for (var i=0 ; i < Math.floor(number.length / 3); i++) {
  2031. if ((mod == 0) && (i == 0)) {
  2032. output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
  2033. } else {
  2034. output+= sep + number.substring(mod + 3 * i, mod + 3 * i + 3);
  2035. }
  2036. }
  2037. number = output;
  2038. }
  2039. return number;
  2040. }
  2041.  
  2042. /*******************************************************************************************************************************
  2043. * Farming Village Overview
  2044. * ----------------------------------------------------------------------------------------------------------------------------
  2045. * | ● Color change on possibility of city festivals
  2046. * ----------------------------------------------------------------------------------------------------------------------------
  2047. *******************************************************************************************************************************/
  2048.  
  2049. function changeResColor(){
  2050. var res, res_min, i = 0;
  2051. $('#fto_town_list .fto_resource_count :last-child').reverseList().each(function(){
  2052. if($(this).parent().hasClass("stone")){
  2053. res_min = 18000;
  2054. } else {
  2055. res_min = 15000;
  2056. }
  2057. res = parseInt($(this).get(0).innerHTML, 10);
  2058. if((res >= res_min) && !($(this).hasClass("town_storage_full"))){
  2059. $(this).get(0).style.color = '#0A0';
  2060. }
  2061. if(res < res_min){
  2062. $(this).get(0).style.color = '#000';
  2063. }
  2064. });
  2065. }
  2066.  
  2067. /*******************************************************************************************************************************
  2068. * Conquest Info
  2069. * -----------------------------------------------------------------------------------------------------------------------------
  2070. * | ● Amount of supports und attacks in the conquest window
  2071. * | ● Layout adjustment (for reasons of clarity)
  2072. * | - TODO: conquest window of own cities
  2073. * -----------------------------------------------------------------------------------------------------------------------------
  2074. *******************************************************************************************************************************/
  2075.  
  2076. function countMovements(){
  2077. var i = 0, a = 0;
  2078. $('#unit_movements .support').each(function(){
  2079. i++;
  2080. });
  2081. $('#unit_movements .attack_land, #unit_movements .attack_sea, #unit_movements .attack_takeover').each(function(){
  2082. a++;
  2083. });
  2084. var str = "<div style='position: absolute;width: 100px;margin-top: -16px;left: 40%;'><div style='float:left;margin-right:5px;'></div>"+
  2085. "<div class='troops' id='count_def'></div>"+
  2086. "<div class='troops' style='color:green;'> " + i + "</div>"+
  2087. "<div class='troops' id='count_off'> </div>"+
  2088. "<div style='color:red;'> " + a + "</div></div>"+
  2089. "<hr class='move_hr'>";
  2090. if($('.gpwindow_content .tab_content .bold').get(0)){
  2091. $('.gpwindow_content .tab_content .bold').append(str);
  2092. } else {
  2093. $('.gpwindow_content h4:eq(1)').append(str);
  2094. // TODO: set player link ?
  2095. /*
  2096. $('#unit_movements li div').each(function(){
  2097. //console.log($(this).get(0).innerHTML);
  2098. });
  2099. */
  2100. }
  2101. $('.move_hr').css({
  2102. margin: '7px 0px 0px 0px',
  2103. backgroundColor: '#5F5242',
  2104. height: '2px',
  2105. border: '0px solid'
  2106. });
  2107. // smaller movements
  2108. $('#unit_movements').css({
  2109. fontSize: '0.80em'
  2110. });
  2111. $('.incoming').css({
  2112. width: '150px',
  2113. height: '45px',
  2114. float: 'left'
  2115. });
  2116. $('#unit_movements div').each(function(){
  2117. if($(this).attr('class') === "unit_movements_arrow"){
  2118. // delete placeholder for arrow of outgoing movements (there are no outgoing movements)
  2119. if(!$(this).get(0).style.background) { $(this).get(0).remove(); }
  2120. } else {
  2121. // realign texts
  2122. $(this).css({
  2123. margin: '3px',
  2124. paddingLeft: '3px'
  2125. });
  2126. }
  2127. });
  2128. $('.troops').css({
  2129. float: 'left',
  2130. margin: '0px 5px 0px 0px',
  2131. height:'18px',
  2132. width:'18px',
  2133. position: 'relative'
  2134. });
  2135. $('#count_def').css({
  2136. background: 'url(http://de.cdn.grepolis.com/images/game/place/losts.png)',
  2137. backgroundPosition: '0 -36px'
  2138. });
  2139. $('#count_off').css({
  2140. background: 'url(http://de.cdn.grepolis.com/images/game/place/losts.png)',
  2141. backgroundPosition: '0 0px'
  2142. });
  2143. }
  2144.  
  2145. /*******************************************************************************************************************************
  2146. * Town window
  2147. * ----------------------------------------------------------------------------------------------------------------------------
  2148. * | ● TownTabHandler (trade, attack, support,...)
  2149. * | ● Sent units box
  2150. * | ● Short duration: Display of 30% troop speed improvement in attack/support tab
  2151. * | ● Trade options:
  2152. * | - Ressource marks on possibility of city festivals
  2153. * | - Percentual Trade: Trade button
  2154. * | - Recruiting Trade: Selection boxes (ressource ratio of unit type + share of the warehouse capacity of the target town)
  2155. * ----------------------------------------------------------------------------------------------------------------------------
  2156. *******************************************************************************************************************************/
  2157.  
  2158. // TODO: Change both functions in MultipleWindowHandler()
  2159. function TownTabHandler(action){
  2160. var wndArray, wndID, wndA;
  2161. wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_TOWN);
  2162. for(var e in wndArray){
  2163. if(wndArray.hasOwnProperty(e)){
  2164. wndA = wndArray[e].getAction(); wndID = "#gpwnd_" + wndArray[e].getID() + " ";
  2165. if(wndA === action){
  2166. switch(action){
  2167. case "trading":
  2168. if(!$(wndID + '.rec_trade').get(0)){
  2169. addRecTrade(wndID);
  2170. }
  2171. if(!($(wndID + '.btn_trade').get(0))){
  2172. addPercentTrade(wndID, false);
  2173. }
  2174. //addTradeMarks(wndID, 15, 18, 15, "red"); // town festival
  2175. break;
  2176. case "support": case "attack":
  2177. if(options.way && !($('.js-casted-powers-viewport .unit_movement_boost').get(0) || $(wndID + '.short_duration').get(0))){
  2178. addShortDuration(wndID);
  2179. }
  2180. if(options.sen) {
  2181. addSentUnitsBox(wndID, action);
  2182. }
  2183. break;
  2184. case "rec_mark":
  2185. //addTradeMarks(wndID, 15, 18, 15, "lime");
  2186. break;
  2187. }
  2188. }
  2189. }
  2190. }
  2191. }
  2192.  
  2193. function WWTradeHandler(){
  2194. var wndArray, wndID, wndA;
  2195. wndArray = uw.GPWindowMgr.getOpen(uw.GPWindowMgr.TYPE_WONDERS);
  2196. for(var e in wndArray){
  2197. if(wndArray.hasOwnProperty(e)){
  2198. wndID = "#gpwnd_" + wndArray[e].getID() + " ";
  2199. if(!($(wndID + '.btn_trade').get(0) || $(wndID +'.next_building_phase').get(0) || $(wndID +'#ww_time_progressbar').get(0))){
  2200. addPercentTrade(wndID, true);
  2201. }
  2202. }
  2203. }
  2204. }
  2205.  
  2206. /*******************************************************************************************************************************
  2207. * ● Sent units box
  2208. *******************************************************************************************************************************/
  2209. var sentUnitsArray = JSON.parse(GM_getValue(WID +"_sentUnitsArray", '{ "attack": {}, "support": {} }'));
  2210.  
  2211. function addSentUnitsBox(wndID, action){
  2212. if(!$(wndID + '.sent_units_box').get(0)){
  2213. var selectedUnitsArray = {};
  2214. $('<div class="game_inner_box sent_units_box"><div class="game_border ">'+
  2215. '<div class="game_border_top"></div><div class="game_border_bottom"></div><div class="game_border_left"></div><div class="game_border_right"></div>'+
  2216. '<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>'+
  2217. '<div class="game_header bold">'+
  2218. '<div class="icon_sent townicon_'+ (action == "attack" ? "lo" : "ld") +'"></div><span>'+ LANG[LID].sen.lab +' ('+ (action == "attack" ? "OFF" : "DEF") +')</span>'+
  2219. '</div>'+
  2220. '<div class="troops"><div class="units_list"></div><hr style="width: 172px;border: 1px solid rgb(185, 142, 93);margin: 3px 0px 2px -1px;">'+
  2221. '<div id="btn_sent_units_reset" class="button_new">'+
  2222. '<div class="left"></div>'+
  2223. '<div class="right"></div>'+
  2224. '<div class="caption js-caption">'+ LANG[LID].sen.rst +'<div class="effect js-effect"></div></div>'+
  2225. '</div>'+
  2226. '</div></div>').appendTo(wndID + '.attack_support_window');
  2227. /* New-Feature Info
  2228. $('<div style="width:130px; margin-bottom: 10px">'+
  2229. '<div style="margin: -4px 0px 0px 4px; float:left; width: 24px; height: 24px; background-image: url(http://666kb.com/i/cifvfsu3e2sdiipn0.gif); background-size: 100%; background-position: 0px 0px; background-repeat: no-repeat no-repeat;"></div>'+
  2230. '<div style="color: green;line-height:1;"><b><nobr>&nbsp;New Feature!</nobr></b></div></div>').prependTo(wndID + '.sent_units_box');
  2231. */
  2232. updateSentUnitsBox(wndID, action);
  2233. $(wndID + '.icon_sent').css({
  2234. height: '20px',
  2235. marginTop: '-2px',
  2236. width: '20px',
  2237. backgroundSize: '17px',
  2238. paddingLeft: '0px',
  2239. marginLeft: '0px'
  2240. });
  2241. $(wndID + '.sent_units_box').css({
  2242. position: 'absolute',
  2243. right: '0px',
  2244. bottom: '16px',
  2245. width: '192px',
  2246. //border: '2px solid green',
  2247. //borderRadius: '5px',
  2248. //padding: '5px'
  2249. });
  2250. $(wndID + '.troops').css({ padding: '6px 0px 6px 6px' });
  2251. setTimeout(function(){
  2252. $(wndID +'.send_units_form a').each(function(){
  2253. $(this).click(function(){
  2254. selectedUnitsArray = getSelectUnits(wndID);
  2255. });
  2256. });
  2257. },10);
  2258. $(wndID + '.unit_input').on("blur", function(){
  2259. selectedUnitsArray = getSelectUnits(wndID);
  2260. });
  2261. /*
  2262. $(wndID + '.unit_container a').on("click", function(){
  2263. selectedUnitsArray[$(this).attr("id")] = $(wndID + '.unit_type_'+ $(this).attr("id")).val();
  2264. console.log($(this).attr("id"));
  2265. console.log(selectedUnitsArray);
  2266. });
  2267. */
  2268. $(wndID + '#btn_sent_units_reset').click(function(){
  2269. // Overwrite old array
  2270. sentUnitsArray[action] = {}; updateSentUnitsBox(wndID, action);
  2271. });
  2272. $(wndID + '.attack_support_window .button').click(function(){
  2273. getSentUnits(wndID, action, selectedUnitsArray);
  2274. });
  2275. $(wndID + '#btn_attack_town').click(function(){
  2276. getSentUnits(wndID, action, selectedUnitsArray);
  2277. });
  2278. }
  2279. }
  2280.  
  2281. function getSelectUnits(wndID){
  2282. var selectedUnitsArray = {};
  2283. for(var u in unitVal){
  2284. if(unitVal.hasOwnProperty(u)){
  2285. var a = parseInt($(wndID + '.unit_type_'+ u).val(), 10);
  2286. if(a > 0){ selectedUnitsArray[u] = parseInt(a, 10); } else { delete selectedUnitsArray[u]; }
  2287. }
  2288. }
  2289. return selectedUnitsArray;
  2290. }
  2291.  
  2292. function getSentUnits(wndID, action, selectedUnitsArray){
  2293. var sentSuccess = true, capaShip = 0, capaUnit = 0, popUnit = 0, seaMovement = false;
  2294. var u = 0;
  2295. if(!$('#human_message').get(0)){
  2296. $('body').append('<div id="human_message" class="human_message human_message_success" style="display: none; opacity: 0;"></div>');
  2297. }
  2298. // check if sending was successful
  2299. var human_message = new MutationObserver(function(mutations) {
  2300. mutations.forEach(function(mutation) {
  2301. if(u == 0){
  2302. if($('#human_message').attr("class").split(" ")[1] === "human_message_success"){
  2303. // Add selected units to sent units
  2304. for(var t in selectedUnitsArray){
  2305. if(selectedUnitsArray.hasOwnProperty(t)){
  2306. sentUnitsArray[action][t] = sentUnitsArray[action][t] || 0;
  2307. sentUnitsArray[action][t] += selectedUnitsArray[t];
  2308. }
  2309. }
  2310. updateSentUnitsBox(wndID, action);
  2311. }
  2312. }
  2313. u++; human_message.disconnect();
  2314. });
  2315. });
  2316. human_message.observe($('#human_message').get(0), { attributes: true, childList: false, characterData: false, attributeFilter: ["style"] });
  2317. }
  2318.  
  2319. function updateSentUnitsBox(wndID, action){
  2320. // Remove old unit list
  2321. $(wndID +'.sent_units_box .units_list').get(0).innerHTML = "";
  2322. // Add new unit list
  2323. for(var x in sentUnitsArray[action]){
  2324. if(sentUnitsArray[action].hasOwnProperty(x)){
  2325. if((sentUnitsArray[action][x] || 0) > 0){
  2326. $('<div class="unit_icon25x25 '+ x + (sentUnitsArray[action][x] >= 1000 ? (sentUnitsArray[action][x] >= 10000 ? " five_digit_number" : " four_digit_number") : "") +'">'+
  2327. '<span class="count text_shadow">'+ sentUnitsArray[action][x] +'</span>'+
  2328. '</div>').appendTo(wndID +'.sent_units_box .units_list');
  2329. }
  2330. }
  2331. }
  2332. setTimeout(function(){
  2333. GM_setValue(WID +"_sentUnitsArray", JSON.stringify(sentUnitsArray));
  2334. }, 0);
  2335. }
  2336.  
  2337. /*******************************************************************************************************************************
  2338. * ● Short duration
  2339. *******************************************************************************************************************************/
  2340. function addShortDuration(wndID){
  2341. $(wndID + '.way_duration').after('<span class="short_duration">0:00:00</span>');
  2342. /*
  2343. $(wndID + '.arrival_time').after('<span class="short_arrival">'+ $('.server_time_area').get(0).innerHTML.split(" ")[0] +'</span>');
  2344. setInterval(function(){
  2345. var t = $(wndID + '.short_arrival').get(0).innerHTML.split(":"), s, m, h;
  2346. s = parseInt((parseInt(t[2], 10) + 1) % 60, 10);
  2347. m = parseInt((parseInt(t[1], 10) + (parseInt(t[2],10) + 1) / 60) % 60, 10);
  2348. h = parseInt((parseInt(t[0], 10) + (parseInt(t[1], 10) + (parseInt(t[2],10) + 1) / 60) / 60) % 24, 10);
  2349. $(wndID + '.short_arrival').get(0).innerHTML = h + ":" + m + ":" + s;
  2350. }, 1000);
  2351. */
  2352. $(wndID + '.short_duration').tooltip("Verbesserte Truppenbewegung");
  2353. changeShortDuration(wndID);
  2354. // Style
  2355. $(wndID + '.duration_container').css({
  2356. width:'390px'
  2357. });
  2358. $(wndID + '.short_duration').css({
  2359. position: 'relative',
  2360. float: 'left',
  2361. color: 'darkgreen',
  2362. padding: '6px 3px 6px 30px',
  2363. background: 'url(http://666kb.com/i/ck2c7eohpyfa3yczt.png) no-repeat',
  2364. backgroundSize: '28px',
  2365. backgroundPosition: '4px 2px'
  2366. });
  2367. }
  2368.  
  2369. function changeShortDuration(wndID){
  2370. var duration = new MutationObserver(function(mutations) {
  2371. mutations.forEach(function(mutation) {
  2372. if(mutation.addedNodes[0]){
  2373. calcShortDuration(wndID);
  2374. }
  2375. });
  2376. });
  2377. duration.observe($(wndID + '.way_duration').get(0), { attributes: false, childList: true, characterData: false});
  2378. }
  2379.  
  2380. function calcShortDuration(wndID){
  2381. var speed = uw.Game.game_speed, setupTime = 900/speed,
  2382. time = $(wndID + '.duration_container .way_duration').get(0).innerHTML.replace("~","").split(":"),
  2383. h,m,s;
  2384. time = (((parseInt(time[0], 10)*60 + parseInt(time[1], 10))*60 + parseInt(time[2], 10) - setupTime) / 1.3) + setupTime;
  2385. h = Math.floor(time/3600);
  2386. m = Math.floor((time - h*3600)/60);
  2387. s = Math.floor(time - h*3600 - m*60);
  2388. if(m < 10) { m = "0" + m; }
  2389. if(s < 10) { s = "0" + s; }
  2390. $(wndID + '.short_duration').get(0).innerHTML = "[~"+ h +":" + m + ":" + s + "]";
  2391. }
  2392.  
  2393. /*******************************************************************************************************************************
  2394. * ● Dropdown menu
  2395. *******************************************************************************************************************************/
  2396.  
  2397. // Preload images for drop down arrow buttons
  2398. var drop_over = new Image(); drop_over.src = "http://s7.directupload.net/images/140107/hna95u8a.png";
  2399. var drop_out = new Image(); drop_out.src = "http://s14.directupload.net/images/140107/ppsz5mxk.png";
  2400.  
  2401. function changeDropDownButton(){
  2402. /*
  2403. $('<style type="text/css">' +
  2404. '#dd_filter_type .arrow, .select_rec_unit .arrow {' +
  2405. 'width: 18px !important; height: 17px !important; background: url("http://s14.directupload.net/images/140107/ppsz5mxk.png") no-repeat 0px -1px !important;' +
  2406. 'position: absolute; top: 2px !important; right: 3px;' +
  2407. '</style>').appendTo('head');
  2408. */
  2409. $('.arrow').css({
  2410. width: '18px',
  2411. height: '17px',
  2412. background: 'url('+ drop_out.src +') no-repeat -1px -1px',
  2413. position: 'absolute',
  2414. top: '2px',
  2415. right: '3px'
  2416. });
  2417. }
  2418.  
  2419. var o = 1;
  2420.  
  2421. /*******************************************************************************************************************************
  2422. * ● Recruiting Trade
  2423. *******************************************************************************************************************************/
  2424. var trade_count = 0, unit = "FS", percent = "0.0"; // Recruiting Trade
  2425.  
  2426. function addRecTrade(wndID){
  2427. var max_amount;
  2428. $('<div class="rec_trade">'+
  2429. // DropDown-Button for unit
  2430. '<div class="drop_rec_unit dropdown default">'+
  2431. '<div class="border-left"></div>'+
  2432. '<div class="border-right"></div>'+
  2433. '<div class="caption" name="'+ unit +'">'+ unit +'</div>'+
  2434. '<div class="arrow"></div>'+
  2435. '</div>'+
  2436. '<div class="drop_rec_perc dropdown default">'+
  2437. // DropDown-Button for ratio
  2438. '<div class="border-left"></div>'+
  2439. '<div class="border-right"></div>'+
  2440. '<div class="caption" name="'+ percent +'">'+ Math.round(percent * 100)+'%</div>'+
  2441. '<div class="arrow"></div>'+
  2442. '</div></div><span class="rec_count" style="top:30px">('+ trade_count +')</span>').appendTo(wndID + ".content");
  2443. // Select boxes for unit and ratio
  2444. $('<div class="select_rec_unit dropdown-list default active">'+
  2445. '<div class="item-list">'+
  2446. '<div class="option_s unit index_unit unit_icon40x40 attack_ship" name="FS"></div>'+
  2447. '<div class="option_s unit index_unit unit_icon40x40 bireme" name="BI"></div>'+
  2448. '<div class="option_s unit index_unit unit_icon40x40 sword" name="SK"></div>'+
  2449. '<div class="option_s unit index_unit unit_icon40x40 slinger" name="SL"></div>'+
  2450. '<div class="option_s unit index_unit unit_icon40x40 archer" name="BS"></div>'+
  2451. '<div class="option_s unit index_unit unit_icon40x40 hoplite" name="HO"></div>'+
  2452. '<div class="option_s unit index_unit unit_icon40x40 rider" name="RE"></div>'+
  2453. '<div class="option_s unit index_unit unit_icon40x40 chariot" name="SW"></div>'+
  2454. '</div></div>').appendTo(wndID + ".rec_trade");
  2455. $('<div class="select_rec_perc dropdown-list default inactive">'+
  2456. '<div class="item-list">'+
  2457. '<div class="option sel" name="0.0">&nbsp;&nbsp;0%</div>'+
  2458. '<div class="option" name="0.05">&nbsp;&nbsp;5%</div>'+
  2459. '<div class="option" name="0.1">10%</div>'+
  2460. '<div class="option" name="0.16666">17%</div>'+
  2461. '<div class="option" name="0.2">20%</div>'+
  2462. '<div class="option" name="0.25">25%</div>'+
  2463. '<div class="option" name="0.33">33%</div>'+
  2464. '<div class="option" name="0.5">50%</div>'+
  2465. '</div></div>').appendTo(wndID + ".rec_trade");
  2466. $(wndID + ".rec_trade [name='"+ unit +"']").toggleClass("sel");
  2467. // Styles
  2468. $(wndID + '.rec_trade').css({ position: 'absolute', left: '30px', top: '70px' });
  2469. $(wndID + '.select_rec_unit').css({
  2470. position: 'absolute',
  2471. top: '20px',
  2472. width: '84px',
  2473. display: "none"
  2474. });
  2475. $(wndID + '.select_rec_perc').css({
  2476. position: 'absolute',
  2477. left: '50px',
  2478. top: '20px',
  2479. width: '50px',
  2480. display: "none"
  2481. });
  2482. $(wndID + '.item-list').css({ maxHeight: '400px', maxWidth: '200px', align: "right" });
  2483. $(wndID + '.arrow').css({
  2484. width: '18px',
  2485. height: '18px',
  2486. background: 'url('+ drop_out.src +') no-repeat -1px -1px',
  2487. position: 'absolute',
  2488. });
  2489. $(wndID + '.option_s').css({
  2490. WebkitFilter: "grayscale(100%)",
  2491. filter: "url(#GrayScale)",
  2492. cursor: 'pointer',
  2493. color: 'black',
  2494. lineHeight: '14px',
  2495. float: 'left',
  2496. position: 'relative',
  2497. width: '40px',
  2498. margin: '0px',
  2499. padding: '0px'
  2500. });
  2501. $('.select_rec_unit .sel').css({"-webkit-filter" : "sepia(100%)", "filter": "url(#Sepia)"});
  2502. // hover effects of the elements in the drop menus
  2503. $(wndID + '.option_s').hover(
  2504. function(){
  2505. //console.log(this.className);
  2506. $(this).css({"-webkit-filter" : "grayscale(0%) sepia(0%)", "filter": "none"});
  2507. if(!($(this).hasClass("sel"))){
  2508. $('.option_s .sel').css({"-webkit-filter" : "grayscale(0%) sepia(100%)", "filter": "url(#Sepia)"});
  2509. }
  2510. },
  2511. function(){
  2512. $('.select_rec_unit .option_s').css({"-webkit-filter" : "grayscale(100%) sepia(0%)", "filter": "url(#GrayScale)"});
  2513. $('.select_rec_unit .sel').css({"-webkit-filter" : "grayscale(0%) sepia(100%)", "filter": "url(#Sepia)"});
  2514. }
  2515. );
  2516. $(wndID + '.option').hover(
  2517. function(){ $(this).css({color: '#fff', background: "#328BF1"}); },
  2518. function(){ $(this).css({color: '#000', background: "#FFEEC7"}); }
  2519. );
  2520. // click events of the drop menu
  2521. $(wndID + ' .select_rec_unit .option_s').each(function(){
  2522. $(this).click(function(e){
  2523. $(".select_rec_unit .sel").toggleClass("sel");
  2524. $("." + this.className.split(" ")[4]).toggleClass("sel");
  2525. unit = $(this).attr("name");
  2526. $('.drop_rec_unit .caption').attr("name", unit);
  2527. $('.drop_rec_unit .caption').each(function(){
  2528. $(this).get(0).innerHTML = unit;
  2529. });
  2530. $(this).parent().parent().get(0).style.display = "none";
  2531. $('.drop_rec_unit .caption').change();
  2532. });
  2533. });
  2534. $(wndID + ' .select_rec_perc .option').each(function(){
  2535. $(this).click(function(e){
  2536. $(this).parent().find(".sel").toggleClass("sel");
  2537. $(this).toggleClass("sel");
  2538. percent = $(this).attr("name");
  2539. $('.drop_rec_perc .caption').attr("name", percent);
  2540. $('.drop_rec_perc .caption').each(function(){
  2541. $(this).get(0).innerHTML = Math.round(percent * 100)+"%";
  2542. });
  2543. $(this).parent().parent().get(0).style.display = "none";
  2544. $('.drop_rec_perc .caption').change();
  2545. });
  2546. });
  2547. // show & hide drop menus on click
  2548. $(wndID + '.drop_rec_perc').click(function(e){
  2549. if($(e.target)[0].parentNode.parentNode.childNodes[3].style.display === "none"){
  2550. $(e.target)[0].parentNode.parentNode.childNodes[3].style.display = "block";
  2551. $(e.target)[0].parentNode.parentNode.childNodes[2].style.display = "none";
  2552. } else {
  2553. $(e.target)[0].parentNode.parentNode.childNodes[3].style.display = "none";
  2554. }
  2555. });
  2556. $(wndID + '.drop_rec_unit').click(function(e){
  2557. if($(e.target)[0].parentNode.parentNode.childNodes[2].style.display === "none"){
  2558. $(e.target)[0].parentNode.parentNode.childNodes[2].style.display = "block";
  2559. $(e.target)[0].parentNode.parentNode.childNodes[3].style.display = "none";
  2560. } else {
  2561. $(e.target)[0].parentNode.parentNode.childNodes[2].style.display = "none";
  2562. }
  2563. });
  2564. $(wndID).click(function(e){
  2565. var clicked = $(e.target);
  2566. if(!(clicked[0].parentNode.className.split(" ")[1] === "dropdown")){
  2567. $('#' + this.id + ' .select_rec_unit').get(0).style.display = "none";
  2568. }
  2569. });
  2570. // hover arrow change
  2571. $(wndID + '.dropdown').hover(function(e){
  2572. $(e.target)[0].parentNode.childNodes[3].style.background = "url('"+ drop_over.src +"') no-repeat -1px -1px";
  2573. }, function(e){
  2574. $(e.target)[0].parentNode.childNodes[3].style.background = "url('"+ drop_out.src +"') no-repeat -1px -1px";
  2575. });
  2576. $(wndID + ".drop_rec_unit .caption").attr("name", unit);
  2577. $(wndID + ".drop_rec_perc .caption").attr("name",percent);
  2578. $(wndID + '.drop_rec_unit').tooltip(LANG[LID].trd.uni);
  2579. $(wndID + '.drop_rec_perc').tooltip(LANG[LID].trd.rat);
  2580. var ratio = {NO: {w:0, s: 0, i: 0 },
  2581. FS: {w:1, s: 0.2308, i: 0.6154 },
  2582. BI: {w:1, s: 0.8750, i: 0.2250 },
  2583. SL: {w:0.55, s: 1, i: 0.4 },
  2584. RE: {w:0.6666, s: 0.3333, i: 1 },
  2585. SK: {w:1, s: 0, i: 0.8947 },
  2586. HO: {w:0, s: 0.5, i: 1 },
  2587. BS: {w:1, s: 0, i: 0.6250 },
  2588. SW: {w:0.4545, s: 1, i: 0.7273 }
  2589. };
  2590. if($('#town_capacity_wood .max').get(0)){
  2591. max_amount = parseInt($('#town_capacity_wood .max').get(0).innerHTML, 10);
  2592. } else {
  2593. max_amount = 25500;
  2594. }
  2595. $(wndID + '.caption').change(function(e){
  2596. //console.log($(this).attr('name') + ", " + unit + "; " + percent);
  2597. if(!(($(this).attr('name') === unit) || ($(this).attr('name') === percent))){
  2598. //trade_count = 0;
  2599. $('.rec_count').get(0).innerHTML = "(" + trade_count + ")";
  2600. }
  2601. var tmp = $(this).attr('name');
  2602. if($(this).parent().attr('class').split(" ")[0] === "drop_rec_unit"){
  2603. unit = tmp;
  2604. } else {
  2605. percent = tmp;
  2606. }
  2607. var max = (max_amount - 100)/1000;
  2608. addTradeMarks(max * ratio[unit].w, max * ratio[unit].s, max * ratio[unit].i, "lime");
  2609. 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)
  2610. var rArray = uw.ITowns.getTown(uw.Game.townId).getCurrentResources();
  2611. var tradeCapacity = uw.ITowns.getTown(uw.Game.townId).getAvailableTradeCapacity();
  2612. var wood = ratio[unit].w * part;
  2613. var stone= ratio[unit].s * part;
  2614. var iron = ratio[unit].i * part;
  2615. if((wood > rArray.wood) || (stone > rArray.stone) || (iron > rArray.iron) || ( (wood + stone + iron) > tradeCapacity)) {
  2616. wood = stone = iron = 0;
  2617. $('.drop_rec_perc .caption').css({color:'#f00'});
  2618. //$('.' + e.target.parentNode.parentNode.className + ' .select_rec_perc .sel').css({color:'#f00'});
  2619. //$('.select_rec_perc .sel').css({color:'#f00'});
  2620. } else {
  2621. $('.' + e.target.parentNode.parentNode.className + ' .drop_rec_perc .caption').css({color:'#000'});
  2622. }
  2623. $("#trade_type_wood [type='text']").select().val(wood).blur();
  2624. $("#trade_type_stone [type='text']").select().val(stone).blur();
  2625. $("#trade_type_iron [type='text']").select().val(iron).blur();
  2626. });
  2627. $('#trade_button').click(function(){
  2628. trade_count++;
  2629. $('.rec_count').get(0).innerHTML = "(" + trade_count + ")";
  2630. });
  2631. $(wndID + '.rec_count').css({
  2632. position: 'absolute',
  2633. display: 'block',
  2634. left: '33px',
  2635. top: '95px',
  2636. width: '20px'
  2637. });
  2638. $(wndID + '.drop_rec_unit').css({
  2639. position: 'absolute',
  2640. display: 'block',
  2641. width: '50px',
  2642. overflow: 'visible'
  2643. });
  2644. $(wndID + '.drop_rec_perc').css({
  2645. position: 'absolute',
  2646. display: 'block',
  2647. left: '49px',
  2648. width: '55px',
  2649. color:'#000'
  2650. });
  2651. $(wndID + '.drop_rec_perc .caption').change();
  2652. }
  2653. /*******************************************************************************************************************************
  2654. * ● Ressources marks
  2655. *******************************************************************************************************************************/
  2656. function addTradeMarks(woodmark, stonemark, ironmark, color){
  2657. var max_amount, limit, wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_TOWN), wndID;
  2658. for(var e in wndArray){
  2659. if(wndArray.hasOwnProperty(e)){
  2660. wndID = "#gpwnd_" + wndArray[e].getID() + " ";
  2661. if($(wndID + '.town-capacity-indicator').get(0)){
  2662. max_amount = $(wndID + '.amounts .max').get(0).innerHTML;
  2663. $('#trade_tab .c_'+ color).each(function(){
  2664. $(this).get(0).remove();
  2665. });
  2666. $('#trade_tab .progress').each(function(){
  2667. if($("p", this).length < 3) {
  2668. if($(this).parent().get(0).id != "big_progressbar"){
  2669. limit = 1000 * (242 / parseInt(max_amount, 10));
  2670. switch($(this).parent().get(0).id.split("_")[2]){
  2671. case "wood": limit = limit * woodmark; break;
  2672. case "stone": limit = limit * stonemark; break;
  2673. case "iron": limit = limit * ironmark; break;
  2674. }
  2675. $('<p class="c_'+ color +'"style="position:absolute;left: '+ limit +'px; background:'+ color +';width:2px;height:100%;margin:0px"></p>').appendTo(this);
  2676. }
  2677. }
  2678. });
  2679. }
  2680. }
  2681. }
  2682. }
  2683.  
  2684. /*******************************************************************************************************************************
  2685. * ● Percentual Trade
  2686. *******************************************************************************************************************************/
  2687. var rest_count = 0;
  2688.  
  2689. function addPercentTrade(wndID, ww){
  2690. var a = ""; var content = wndID + ".content";
  2691. if(ww) {
  2692. a = "ww_";
  2693. content = wndID + '.trade .send_res';
  2694. }
  2695. $('<div class="btn btn_trade"><a class="button" href="#">'+
  2696. '<span class="left"><span class="right">'+
  2697. '<span class="middle mid">'+
  2698. '<span class="img_trade"></span></span></span></span>'+
  2699. '<span style="clear:both;"></span>'+
  2700. '</a></div>').prependTo(content);
  2701. $(wndID + '.btn_trade').tooltip(LANG[LID].trd.prc);
  2702. setPercentTrade(wndID, ww);
  2703. $(wndID + '.btn').css({ width: '20px', overflow: 'visible', position: 'absolute', display: 'block' });
  2704. if(!ww){ $(wndID + '.content').css({ height: '320px' }); }
  2705. if(ww){
  2706. $(wndID + '.btn_trade').css({ left: '678px', top: '154px' });
  2707. } else {
  2708. $(wndID + '.btn_trade').css({ left: '336px', top: '135px' });
  2709. }
  2710. $(wndID + '.mid').css({ minWidth: '26px' });
  2711. $(wndID + '.img_trade').css({
  2712. width: '27px',
  2713. height: '27px',
  2714. top: '-3px',
  2715. float: 'left',
  2716. position: 'relative',
  2717. background: 'url("http://666kb.com/i/cjq6d72qk521ig1zz.png") no-repeat'
  2718. });
  2719. }
  2720.  
  2721. var res = {};
  2722. function setPercentTrade(wndID, ww){
  2723. var a = ""; if(ww) a = "ww_";
  2724. $(wndID + '.btn_trade').toggle(function(){
  2725. res.wood = {}; res.stone = {}; res.iron = {}; res.sum = {};
  2726. res.sum.amount = 0;
  2727. // Rohstoffmenge 0 setzen
  2728. setAmount(true, a, wndID);
  2729. // Rohstoffmenge insgesamt // TODO: ITowns.getTown(Game.townId).getCurrentResources(); ?
  2730. for(var e in res){
  2731. if(res.hasOwnProperty(e) && e != "sum") {
  2732. res[e].rest = false;
  2733. res[e].amount = parseInt($('.ui_resources_bar .'+ e +' .amount').get(0).innerHTML, 10);
  2734. res.sum.amount += res[e].amount;
  2735. }
  2736. }
  2737. // Prozentualer Anteil der Rohstoffe insgesamt
  2738. res.wood.percent = 100/res.sum.amount * res.wood.amount;
  2739. res.stone.percent = 100/res.sum.amount * res.stone.amount;
  2740. res.iron.percent = 100/res.sum.amount * res.iron.amount;
  2741. // Handelsmenge insgesamt
  2742. res.sum.cur = parseInt($(wndID + '#' + a + 'big_progressbar .caption .curr').get(0).innerHTML, 10);
  2743. res.sum.max = parseInt($(wndID + '#' + a + 'big_progressbar .caption .max').get(0).innerHTML, 10) - res.sum.cur;
  2744. // Menge der Rohstoffe am prozentualen Anteil der Handelsmenge (%)
  2745. res.wood.part = parseInt(res.sum.max/100 * res.wood.percent, 10);
  2746. res.stone.part = parseInt(res.sum.max/100 * res.stone.percent, 10);
  2747. res.iron.part = parseInt(res.sum.max/100 * res.iron.percent, 10);
  2748. for(var f in res){
  2749. if(res.hasOwnProperty(f) && f != "sum") {
  2750. if(!ww){
  2751. var i = 0;
  2752. $(wndID + '#town_capacity_'+ f +' .amounts span').each(function(){
  2753. res[f][i] = parseInt(this.innerHTML.replace('+', '').trim(), 10);
  2754. if(isNaN(res[f][i])) { res[f][i] = 0; }
  2755. i++;
  2756. });
  2757. res[f].cur = res[f][0] + res[f][1];
  2758. res[f].max = res[f][3] - res[f].cur;
  2759. if(res[f].max < 0) { res[f].max = 0; }
  2760. } else {
  2761. res[f].max = 30000;
  2762. }
  2763. }
  2764. }
  2765. // Rest von Bruchrechnung (0-2 Einheiten) zur Steinmenge addieren
  2766. res.stone.part += res.sum.max - (res.wood.part + res.stone.part + res.iron.part);
  2767. res.sum.rest = 0;
  2768. rest_count = 0;
  2769. calcRestAmount();
  2770. setAmount(false, a, wndID);
  2771. }, function(){
  2772. setAmount(true, a, wndID);
  2773. });
  2774. }
  2775.  
  2776. function calcRestAmount(){
  2777. // Rest aufteilen
  2778. if(res.sum.rest > 0){
  2779. for(var e in res){
  2780. if(res.hasOwnProperty(e) && e != "sum" && res[e].rest != true) {
  2781. res[e].part += res.sum.rest/(3 - rest_count);
  2782. }
  2783. }
  2784. res.sum.rest = 0;
  2785. }
  2786. // neuen Rest berechnen
  2787. for(var f in res){
  2788. if(res.hasOwnProperty(f) && f != "sum" && res[f].rest != true) {
  2789. if(res[f].max <= res[f].part) {
  2790. res[f].rest = true;
  2791. res.sum.rest += res[f].part - res[f].max;
  2792. rest_count += 1;
  2793. res[f].part = res[f].max;
  2794. }
  2795. }
  2796. }
  2797. // Rekursion
  2798. if(res.sum.rest > 0 && rest_count < 3){
  2799. calcRestAmount();
  2800. }
  2801. }
  2802.  
  2803. function setAmount(clear, a, wndID){
  2804. for(var e in res){
  2805. if(res.hasOwnProperty(e) && e != "sum") {
  2806. if(clear == true) { res[e].part = 0; }
  2807. $(wndID + "#" + a + "trade_type_" + e + ' [type="text"]').select().val(res[e].part).blur();
  2808. }
  2809. }
  2810. }
  2811.  
  2812. /*******************************************************************************************************************************
  2813. * Unit strength (blunt/sharp/distance) and Transport Capacity
  2814. * ----------------------------------------------------------------------------------------------------------------------------
  2815. * | ● Unit strength: Unit menu
  2816. * | - Switching of def/off display with buttons
  2817. * | - Possible Selection of certain unit types
  2818. * | ● Unit strength: Siege
  2819. * | ● Unit strength: Barracks
  2820. * | ● Transport capacity: Unit menu
  2821. * | - Switching of transporter speed (+/- big transporter)
  2822. * ----------------------------------------------------------------------------------------------------------------------------
  2823. *******************************************************************************************************************************/
  2824.  
  2825. var def = true, blunt = 0, sharp = 0, dist = 0, shipsize = false;
  2826.  
  2827. function getSelectedUnitsMenu(){
  2828. var units = [];
  2829. if($(".units_land .units_wrapper .selected").length > 0){
  2830. $(".units_land .units_wrapper .selected").each(function(){
  2831. units[$(this).get(0).className.split(" ")[1]] = $(this).get(0).children[0].innerHTML;
  2832. });
  2833. } else {
  2834. $(".units_land .units_wrapper .unit").each(function(){
  2835. units[$(this).get(0).className.split(" ")[1]] = $(this).get(0).children[0].innerHTML;
  2836. });
  2837. }
  2838. return units;
  2839. }
  2840.  
  2841. // Calculate defensive strength
  2842. function calcDef(units){
  2843. var e; blunt = sharp = dist = 0;
  2844. for(e in units) {
  2845. if(units.hasOwnProperty(e)) {
  2846. blunt += units[e] * unitVal[e].def_hack;
  2847. sharp += units[e] * unitVal[e].def_pierce;
  2848. dist += units[e] * unitVal[e].def_distance;
  2849. }
  2850. }
  2851. }
  2852. // Calculate offensive strength
  2853. function calcOff(units, selectedUnits){
  2854. var e; blunt = sharp = dist = 0;
  2855. for(e in selectedUnits) {
  2856. if(selectedUnits.hasOwnProperty(e)) {
  2857. var attack = (units[e] || 0) * unitVal[e].attack;
  2858. switch(unitVal[e].attack_type){
  2859. case 'hack': blunt += attack; break;
  2860. case 'pierce': sharp += attack; break;
  2861. case 'distance':dist += attack; break;
  2862. }
  2863. }
  2864. }
  2865. }
  2866.  
  2867. /*******************************************************************************************************************************
  2868. * ● Unit strength: Unit menu
  2869. *******************************************************************************************************************************/
  2870. function setStrengthMenu() {
  2871. var unitsIn = uw.ITowns.getTown(uw.Game.townId).units(),
  2872. e, units = getSelectedUnitsMenu();
  2873. // Calculation
  2874. if(def==true){
  2875. calcDef(units);
  2876. } else {
  2877. calcOff(unitsIn, units);
  2878. }
  2879. $('#blunt').get(0).innerHTML = blunt;
  2880. $('#sharp').get(0).innerHTML = sharp;
  2881. $('#dist').get(0).innerHTML = dist;
  2882. setTransportCapacity(units);
  2883. }
  2884.  
  2885. function addStrengthMenu(){
  2886. $('<hr><div id="strength" class="cont_left"><span id="str_font" class="bold text_shadow" style="color:#FFCC66;font-size: 0.8em;">'+
  2887. '<table style="margin:0px;">'+
  2888. '<tr><td><div class="ico units_info_sprite img_hack"></td><td id="blunt">0</td></tr>'+
  2889. '<tr><td><div class="ico units_info_sprite img_pierce"></td><td id="sharp">0</td></tr>'+
  2890. '<tr><td><div class="ico units_info_sprite img_dist"></td><td id="dist">0</td></tr>'+
  2891. '</table>'+
  2892. '</span></div>'+
  2893. '<div class="cont_right">'+
  2894. '<img id="def" class="img" src="http://de.cdn.grepolis.com/images/game/unit_overview/support.png">'+
  2895. '<img id="off" class="img" src="http://de.cdn.grepolis.com/images/game/unit_overview/attack.png">'+
  2896. '</div>').appendTo('.units_land .content');
  2897. // transporter display
  2898. $('<div id="transporter" class="cont" style="height:25px;">'+
  2899. '<table style=" margin:0px;"><tr align="center" >'+
  2900. '<td><img id="ship_img" class="ico" src="' + img_small_transp + '"></td>'+
  2901. '<td><span id="ship" class="bold text_shadow" style="color:#FFCC66;font-size: 10px;"></span></td>'+
  2902. '</tr></table>'+
  2903. '</div>').appendTo('.units_naval .content');
  2904. // Styles
  2905. $('.ico').css({
  2906. height: '20px',
  2907. width: '20px'
  2908. });
  2909. $('.units_info_sprite').css({
  2910. background: 'url(http://de.cdn.grepolis.com/images/game/units/units_info_sprite2.51.png)',
  2911. backgroundSize: '100%'
  2912. });
  2913. $('.img_pierce').css({ backgroundPosition: '0px -20px' });
  2914. $('.img_dist').css({ backgroundPosition: '0px -40px' });
  2915. $('hr').css({
  2916. margin: '0px',
  2917. backgroundColor: '#5F5242',
  2918. height: '2px',
  2919. border: '0px solid'
  2920. });
  2921. $('.cont_left').css({
  2922. background: 'url(http://de.cdn.grepolis.com/images/game/layout/layout_units_nav_border.png)',
  2923. width:'65%',
  2924. display: 'table-cell'
  2925. });
  2926. $('.cont').css({
  2927. background:'url("http://gpde.innogamescdn.com/images/game/layout/layout_2.56_compressed.png") no-repeat -270px -354px'
  2928. });
  2929. $('.cont_right').css({
  2930. background:'url(http://de.cdn.grepolis.com/images/game/layout/layout_units_nav_border.png)',
  2931. width:'30%',
  2932. display: 'table-cell',
  2933. verticalAlign:'middle'
  2934. });
  2935. $('.img').css({
  2936. float:'right',
  2937. background:'none',
  2938. margin:'2px 8px 2px 0px'
  2939. });
  2940. $('.units_land .units_wrapper, .btn_gods_spells .checked').click(function(){
  2941. setTimeout(function(){
  2942. setStrengthMenu();
  2943. }, 100);
  2944. });
  2945. $('#off').css({"-webkit-filter" : "grayscale(80%)",
  2946. "filter": "url(#GrayScale)"});
  2947. // Buttons
  2948. $('#off').click(function(){
  2949. $('#strength .img_hack').get(0).style.backgroundPosition = '0% 36%';
  2950. $('#strength .img_pierce').get(0).style.backgroundPosition = '0% 27%';
  2951. $('#strength .img_dist').get(0).style.backgroundPosition = '0% 45%';
  2952. $('#str_font').get(0).style.color = "#edb";
  2953. // TODO: doesn't work in FF yet
  2954. $(this).css({"-webkit-filter" : "grayscale(0%)",
  2955. "filter": "none",
  2956. });
  2957. $('#def').css({"-webkit-filter" : "grayscale(80%)",
  2958. "filter": "url(#GrayScale)",
  2959. });
  2960. def = false;
  2961. setStrengthMenu();
  2962. });
  2963. $('#def').click(function(){
  2964. $('#strength .img_hack').get(0).style.backgroundPosition = '0% 0%';
  2965. $('#strength .img_pierce').get(0).style.backgroundPosition = '0% 9%';
  2966. $('#strength .img_dist').get(0).style.backgroundPosition = '0% 18%';
  2967. $('#str_font').get(0).style.color = "#fc6";
  2968. $(this).css({"-webkit-filter" : "grayscale(0%)",
  2969. "filter": "none"
  2970. });
  2971. $('#off').css({"-webkit-filter" : "grayscale(80%)",
  2972. "filter": "url(#GrayScale)",
  2973. });
  2974. def = true;
  2975. setStrengthMenu();
  2976. });
  2977. $('#def,#off,#transporter').hover(function() {
  2978. $(this).css('cursor','pointer');
  2979. });
  2980. $('#transporter').toggle(
  2981. function(){
  2982. $('#ship_img').get(0).src = img_big_transp;
  2983. shipsize = !shipsize;
  2984. setStrengthMenu();
  2985. },
  2986. function(){
  2987. $('#ship_img').get(0).src = img_small_transp;
  2988. shipsize = !shipsize;
  2989. setStrengthMenu();
  2990. }
  2991. );
  2992. data = uw.GameData;
  2993. unitVal = data.units;
  2994. }
  2995.  
  2996. /*******************************************************************************************************************************
  2997. * ● Unit strength: Siege
  2998. *******************************************************************************************************************************/
  2999. function addStrengthConquest(){
  3000. var units = [], str;
  3001. // units of the siege
  3002. $('#conqueror_units_in_town .unit').each(function(){
  3003. str = $(this).attr("class").split(" ")[4];
  3004. if(!unitVal[str].is_naval){
  3005. units[str] = parseInt($(this).get(0).children[0].innerHTML, 10);
  3006. //console.log($(this).attr("class").split(" ")[4]);
  3007. }
  3008. });
  3009. // calculation
  3010. calcDef(units);
  3011. $('<div id="strength_eo" class="game_border" style="width:90px; margin: 20px; align:center;">'+
  3012. '<div class="game_border_top"></div><div class="game_border_bottom"></div>'+
  3013. '<div class="game_border_left"></div><div class="game_border_right"></div>'+
  3014. '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>'+
  3015. '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>'+
  3016. '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">'+
  3017. '<tr><td width="1%"><div class="ico units_info_sprite img_hack"></div></td><td id="bl" align="center" width="100%">0</td></tr>'+
  3018. '<tr><td><div class="ico units_info_sprite img_pierce"></div></td><td id="sh" align="center">0</td></tr>'+
  3019. '<tr><td><div class="ico units_info_sprite img_dist"></div></td><td id="di" align="center">0</td></tr>'+
  3020. '</table></span>'+
  3021. '</div>').appendTo('#conqueror_units_in_town');
  3022. $('#strength_eo').tooltip('Gesamteinheitenstärke der Belagerungstruppen');
  3023. $('#strength_eo .ico').css({
  3024. height: '20px',
  3025. width: '20px'
  3026. });
  3027. $('#strength_eo .units_info_sprite').css({
  3028. background: 'url(http://de.cdn.grepolis.com/images/game/units/units_info_sprite2.51.png)',
  3029. backgroundSize: '100%'
  3030. });
  3031. $('#strength_eo .img_pierce').css({ backgroundPosition: '0% 9%' });
  3032. $('#strength_eo .img_dist').css({ backgroundPosition: '0% 18%' });
  3033. $('#bl').get(0).innerHTML = blunt;
  3034. $('#sh').get(0).innerHTML = sharp;
  3035. $('#di').get(0).innerHTML = dist;
  3036. }
  3037.  
  3038. /*******************************************************************************************************************************
  3039. * ● Unit strength: Barracks
  3040. *******************************************************************************************************************************/
  3041. function setStrengthBarracks(){
  3042. if(!$('#strength_baracks').get(0)){
  3043. var units = [], pop = 0;
  3044. // whole units of the town
  3045. $('#units .unit_order_total').each(function(){
  3046. units[$(this).parent().parent().attr("id")] = $(this).get(0).innerHTML;
  3047. });
  3048. // calculation
  3049. calcDef(units);
  3050. // population space of the units
  3051. for(var e in units) {
  3052. if(units.hasOwnProperty(e)) {
  3053. pop += units[e] * unitVal[e].population;
  3054. }
  3055. }
  3056. $('<div id="strength_baracks" class="game_border" style="float:right; width:70px; align:center;">'+
  3057. '<div class="game_border_top"></div><div class="game_border_bottom"></div>'+
  3058. '<div class="game_border_left"></div><div class="game_border_right"></div>'+
  3059. '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>'+
  3060. '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>'+
  3061. '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">'+
  3062. '<tr><td width="1%"><div class="ico units_info_sprite img_hack"></div></td><td id="b" align="center" width="100%">0</td></tr>'+
  3063. '<tr><td><div class="ico units_info_sprite img_pierce"></div></td><td id="s" align="center">0</td></tr>'+
  3064. '<tr><td><div class="ico units_info_sprite img_dist"></div></td><td id="d" align="center">0</td></tr>'+
  3065. '</table></span>'+
  3066. '</div>').appendTo('.ui-dialog #units');
  3067. $('<div id="pop_baracks" class="game_border" style="float:right; width:60px; align:center;">'+
  3068. '<div class="game_border_top"></div><div class="game_border_bottom"></div>'+
  3069. '<div class="game_border_left"></div><div class="game_border_right"></div>'+
  3070. '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>'+
  3071. '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>'+
  3072. '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">'+
  3073. '<tr><td width="1%"><img class="ico" src="http://de.cdn.grepolis.com/images/game/res/pop.png"></td><td id="p" align="center" width="100%">0</td></tr>'+
  3074. '</table></span>'+
  3075. '</div>').appendTo('.ui-dialog #units');
  3076. $('.ui-dialog #units .ico').css({
  3077. height: '20px',
  3078. width: '20px'
  3079. });
  3080. $('.ui-dialog #units .units_info_sprite').css({
  3081. background: 'url(http://de.cdn.grepolis.com/images/game/units/units_info_sprite2.51.png)',
  3082. backgroundSize: '100%'
  3083. });
  3084. $('.ui-dialog #units .img_pierce').css({ backgroundPosition: '0% 9%' });
  3085. $('.ui-dialog #units .img_dist').css({ backgroundPosition: '0% 18%' });
  3086. $('#pop_baracks').tooltip('Bevölkerungszahl aller Landeinheiten der Stadt');
  3087. $('#strength_baracks').tooltip('Gesamteinheitenstärke stadteigener Truppen');
  3088. $('#b').get(0).innerHTML = blunt;
  3089. $('#s').get(0).innerHTML = sharp;
  3090. $('#d').get(0).innerHTML = dist;
  3091. $('#p').get(0).innerHTML = pop;
  3092. }
  3093. }
  3094.  
  3095. /*******************************************************************************************************************************
  3096. * ● Transporter capacity
  3097. *******************************************************************************************************************************/
  3098. function setTransportCapacity(){
  3099. var bigTransp = 0, smallTransp = 0, pop = 0, ship = 0, unit, berth, units = [];
  3100. // Ship space (available)
  3101. smallTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().small_transporter, 10);
  3102. if(isNaN(smallTransp)) smallTransp = 0;
  3103. if(shipsize){
  3104. bigTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().big_transporter, 10);
  3105. if(isNaN(bigTransp)) bigTransp = 0;
  3106. }
  3107. // Checking: Research berth
  3108. berth = 0;
  3109. if(uw.ITowns.getTown(uw.Game.townId).researches().hasBerth()){
  3110. berth = 6;
  3111. }
  3112. ship = bigTransp*(20 + berth) + smallTransp*(10 + berth);
  3113. units = uw.ITowns.getTown(uw.Game.townId).units();
  3114. // Ship space (required)
  3115. for(var e in units) {
  3116. if(units.hasOwnProperty(e)) {
  3117. if(unitVal[e]){ // without Heroes
  3118. if(!(unitVal[e].is_naval || unitVal[e].flying)){
  3119. pop += units[e] * unitVal[e].population;
  3120. }
  3121. }
  3122. }
  3123. }
  3124. $('#ship').get(0).innerHTML = pop + "/" + ship;
  3125. }
  3126.  
  3127.  
  3128. /*******************************************************************************************************************************
  3129. * Simulator
  3130. * ----------------------------------------------------------------------------------------------------------------------------
  3131. * | ● Layout adjustment
  3132. * | ● Permanent display of the extended modifier box
  3133. * | ● Unit strength for entered units (without modificator influence yet)
  3134. * ----------------------------------------------------------------------------------------------------------------------------
  3135. *******************************************************************************************************************************/
  3136.  
  3137. function changeSimulatorLayout(){
  3138. $('#place_simulator .game_body').css({
  3139. height: '457px'
  3140. });
  3141. // AutoFillIn
  3142. $('.place_insert_field[name="sim[mods][att][luck]"]').get(0).value = 0;
  3143. //$('.place_insert_field[name="sim[mods][att][morale]"]').get(0).value = 100;
  3144. // Mods
  3145. $('.place_sim_bonuses_heroes h4').prependTo('.place_sim_wrap_mods');
  3146. $('.place_sim_wrap_mods').css({
  3147. position: 'absolute',
  3148. right: '-17px'
  3149. });
  3150. $('.place_sim_wrap_mods .place_simulator_table .left_border').css({
  3151. width: '47px'
  3152. });
  3153. // Erweiterte Modulator-Box
  3154. $('.place_sim_wrap_mods_extended').removeClass().addClass("place_sim_wrap_mods_extend");
  3155. $('.place_sim_wrap_mods_extend').appendTo('.place_sim_wrap_mods');
  3156. $('.place_sim_wrap_mods_extend').css({
  3157. display: 'table',
  3158. position: 'relative',
  3159. width: '100px',
  3160. paddingTop: '6px'
  3161. });
  3162. $('.place_sim_bonuses_more_confirm').parent().get(0).style.display = "none";
  3163. $('.place_sim_showhide').remove();
  3164. $('.place_image').css({
  3165. width: '20px',
  3166. height:'20px',
  3167. backgroundSize: '100%',
  3168. margin: '1px'
  3169. });
  3170. $('.place_sim_wrap_mods_extend .place_image').each(function(){
  3171. var s = parseInt($(this).css('backgroundPosition').replace("px", "").split(" ")[1], 10)/2;
  3172. $(this).get(0).style.backgroundPosition = '0px '+s+'px';
  3173. });
  3174. $('.place_checkbox_field').each(function(){
  3175. $(this).click(function(){
  3176. $('.place_sim_bonuses_more_confirm').get(0).click();
  3177. });
  3178. });
  3179. // Einheitencontainer
  3180. $('#simulator_body .unit_container').css({
  3181. height: '50px',
  3182. width: '50px',
  3183. margin: '0px 3px 0px 1px'
  3184. });
  3185. $('.place_simulator_odd, .place_simulator_even').css({
  3186. textAlign: 'center'
  3187. });
  3188. $('.place_insert_field').css({
  3189. margin: '0px'
  3190. });
  3191. // Seeeinheiten-Box
  3192. $('.place_sim_sea_wrap h4').css({
  3193. float: 'left'
  3194. });
  3195. $('.place_sim_select_strategies').prependTo('.place_sim_sea_wrap');
  3196. $('.place_sim_select_strategies select').css({
  3197. width: '95px'
  3198. });
  3199. $('.place_sim_sea_wrap h4').prependTo('.place_sim_sea_wrap');
  3200. $('.place_sim_select_strategies select').get(0).children[0].innerHTML ="Standard";
  3201. $('.place_sim_select_strategies select').get(0).children[2].remove();
  3202. $('.place_sim_select_strategies').css({
  3203. marginLeft: '99px'
  3204. });
  3205. // Einheiten-Box
  3206. $('<div id="place_sim_wrap_units"></div>').appendTo('#simulator_body');
  3207. $('#place_sim_wrap_units').css({
  3208. position: 'absolute',
  3209. bottom: '35px'
  3210. });
  3211. $('#place_simulator h4:last, .place_sim_select_gods_wrap').appendTo('#place_sim_wrap_units');
  3212. $('#place_sim_ground_units').appendTo('#place_sim_wrap_units');
  3213. $('#place_sim_wrap_units h4').prependTo('.place_sim_select_gods_wrap');
  3214. $('#place_sim_wrap_units h4').css({
  3215. float: 'left'
  3216. });
  3217. // Selectboxen
  3218. $('.place_sim_select_gods select').each(function(){
  3219. //$(this).get(0)[0].innerHTML = "Gottheit";
  3220. });
  3221. $('.place_sim_select_gods').css({
  3222. width: '105px'
  3223. });
  3224. $('.place_sim_select_gods select').css({
  3225. width: '80px'
  3226. });
  3227. $('.place_sim_select_gods_wrap').css({
  3228. padding: '0px'
  3229. });
  3230. $('#select_insert_units').css({
  3231. width: '130px'
  3232. });
  3233. //$('#select_insert_units').get(0)[1].innerHTML ="Angriff";
  3234. //$('#select_insert_units').get(0)[2].innerHTML ="Verteidigung";
  3235. $('.place_sim_select_gods_wrap .place_symbol, .place_sim_select_strategies .place_symbol').css({
  3236. margin: '3px 2px 0px 5px'
  3237. });
  3238. $('.place_sim_insert_units .place_symbol').css({
  3239. background: 'url(http://de.cdn.grepolis.com/images/game/towninfo/traveltime.png)',
  3240. backgroundSize: '140%',
  3241. backgroundPositionY: '-4px'
  3242. });
  3243. $('.place_attack').css({
  3244. float: 'left'
  3245. });
  3246. $('#simulator_body .att').css({
  3247. marginLeft: '19px'
  3248. });
  3249. // -> Heldenwelt
  3250. if(uw.Game.is_hero_world){
  3251. $('.place_sim_wrap_mods_extend tr').each(function(){
  3252. $(this).get(0).children[1].style.borderLeft = "none";
  3253. $(this).get(0).children[0].remove();
  3254. });
  3255. $('.place_sim_wrap_mods_extend').get(0).style.left = "-29px";
  3256. }
  3257. // -> Helden
  3258. if($('.place_sim_heroes_container').get(0)){
  3259. $('.place_sim_heroes_container').appendTo(".place_sim_wrap_mods");
  3260. $('#place_simulator h4:eq(2)').get(0).remove();
  3261. //$('<tr></tr>').appendTo(".place_sim_heroes_container tbody");
  3262. //$('.place_sim_heroes_container td:eq(2), .place_sim_heroes_container td:eq(3)').appendTo(".place_sim_heroes_container tr:eq(1)");
  3263. $('.place_sim_heroes_container').css({
  3264. position: 'absolute',
  3265. right: '26px',
  3266. paddingTop: '6px'
  3267. });
  3268. }
  3269. $('<style type="text/css"> #q_place_sim_lost_res { display: none; } </style>').appendTo('head');
  3270. setStrengthSimulator();
  3271. }
  3272.  
  3273. function afterSimulation(){
  3274. var lossArray = { att : { res: 0, fav: 0, pop: 0 }, def : { res: 0, fav: 0, pop: 0 } };
  3275. $('#place_sim_wrap_units .place_losses, #place_sim_naval_units .place_losses').each(function(){
  3276. var loss = parseInt($(this).get(0).innerHTML, 10) || 0;
  3277. if(loss > 0){
  3278. var unit = this.id.substring(26);
  3279. var side = this.id.split("_")[2];
  3280. lossArray[side].res += loss *(unitVal[unit].resources.wood + unitVal[unit].resources.stone + unitVal[unit].resources.iron);
  3281. lossArray[side].fav += loss * unitVal[unit].favor;
  3282. lossArray[side].pop += loss * unitVal[unit].population;
  3283. }
  3284. });
  3285. for(var x in lossArray){
  3286. if(lossArray.hasOwnProperty(x)){
  3287. for(var z in lossArray[x]){
  3288. if(lossArray[x].hasOwnProperty(z)){
  3289. $("#"+ x +"_"+ z).get(0).innerHTML = ((z === "res") && (lossArray[x][z] > 10000))? (Math.round(lossArray[x][z]/1000)+"k"):lossArray[x][z];
  3290. }
  3291. }
  3292. }
  3293. }
  3294. }
  3295.  
  3296. // Stärkeanzeige: Simulator
  3297. var unitsGround = { att: {}, def: {} }, unitsNaval = { att: {}, def: {} }, name ="";
  3298.  
  3299. function setStrengthSimulator() {
  3300. $('<div id="simu_table" style="position:relative; align:center;font-size: 0.8em; margin-top:6px; margin-right:39%;">'+
  3301. '<div style="float:left; margin-right:12px;"><h4>'+ LANG[LID].sim.str +'</h4>'+
  3302. '<table class="place_simulator_table strength" cellpadding="0px" cellspacing="0px" style="align:center;">'+
  3303. '<tr>'+
  3304. '<td class="place_simulator_even"></td>'+
  3305. '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_hack"></div></td>'+
  3306. '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_pierce"></div></td>'+
  3307. '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_dist"></div></td>'+
  3308. '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_ship"></div></td>'+
  3309. '</tr><tr>'+
  3310. '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>'+
  3311. '<td class="left_border place_simulator_odd" id="att_b">0</td>'+
  3312. '<td class="left_border place_simulator_even" id="att_s">0</td>'+
  3313. '<td class="left_border place_simulator_odd" id="att_d">0</td>'+
  3314. '<td class="left_border place_simulator_even" id="att_ship">0</td>'+
  3315. '</tr><tr>'+
  3316. '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>'+
  3317. '<td class="left_border place_simulator_odd" id="def_b">0</td>'+
  3318. '<td class="left_border place_simulator_even" id="def_s">0</td>'+
  3319. '<td class="left_border place_simulator_odd" id="def_d">0</td>'+
  3320. '<td class="left_border place_simulator_even" id="def_ship">0</td>'+
  3321. '</tr>'+
  3322. '</table>'+
  3323. '</div><div><h4>'+ LANG[LID].sim.los +'</h4>'+
  3324. '<table class="place_simulator_table loss" cellpadding="0px" cellspacing="0px" style="align:center;">'+
  3325. '<tr>'+
  3326. '<td class="place_simulator_even"></td>'+
  3327. '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_res"></div></td>'+
  3328. '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_fav"></div></td>'+
  3329. '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_pop"></div></td>'+
  3330. '</tr><tr>'+
  3331. '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>'+
  3332. '<td class="left_border place_simulator_odd" id="att_res">0</td>'+
  3333. '<td class="left_border place_simulator_even" id="att_fav">0</td>'+
  3334. '<td class="left_border place_simulator_odd" id="att_pop">0</td>'+
  3335. '</tr><tr>'+
  3336. '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>'+
  3337. '<td class="left_border place_simulator_odd" id="def_res">0</td>'+
  3338. '<td class="left_border place_simulator_even" id="def_fav">0</td>'+
  3339. '<td class="left_border place_simulator_odd" id="def_pop">0</td>'+
  3340. '</tr>'+
  3341. '</table>'+
  3342. '</div></div>').appendTo('#simulator_body');
  3343. $('#simu_table .ico').css({
  3344. height: '20px',
  3345. width: '20px'
  3346. });
  3347. $('#simu_table .units_info_sprite').css({
  3348. background: 'url(http://de.cdn.grepolis.com/images/game/units/units_info_sprite2.51.png)',
  3349. backgroundSize: '100%'
  3350. });
  3351. $('#simu_table .img_hack').css({ backgroundPosition: '0% 36%' });
  3352. $('#simu_table .img_pierce').css({ backgroundPosition: '0% 27%' });
  3353. $('#simu_table .img_dist').css({ backgroundPosition: '0% 45%' });
  3354. $('#simu_table .img_ship').css({ backgroundPosition: '0% 72%' });
  3355. $('#simu_table .img_fav').css({ background: 'url(http://gpde.innogamescdn.com/images/game/res/favor.png)', backgroundSize: '100%' });
  3356. $('#simu_table .img_res').css({ background: 'url(http://de.cdn.grepolis.com/images/game/units/units_info_sprite2.51.png) 0% 54%', backgroundSize: '100%' });
  3357. $('#simu_table .img_pop').css({ background: 'url(http://gpde.innogamescdn.com/images/game/res/pop.png)', backgroundSize: '100%' });
  3358. $('#simu_table .left_border').css({
  3359. width: '54px'
  3360. });
  3361. $('#simu_table .left_border').each(function(){
  3362. $(this)[0].align = 'center';
  3363. });
  3364. $('#simu_table .strength').tooltip(LANG[LID].sim.str + " (" + LANG[LID].sim.mod +")");
  3365. $('#simu_table .loss').tooltip(LANG[LID].sim.los);
  3366. // Klick auf Einheitenbild
  3367. $('.index_unit').click(function(){
  3368. var type = $(this).attr('class').split(" ")[4];
  3369. $('.place_insert_field[name="sim[units][att]['+type+']"]').change();
  3370. });
  3371. $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').on('input change', function(){
  3372. name = $(this).attr("name").replace(/\]/g, "").split("[");
  3373. var str = this;
  3374. //console.log(str);
  3375. setTimeout(function(){
  3376. var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2],
  3377. val, e;
  3378. val = parseInt($(str).val(), 10);
  3379. val = val || 0;
  3380. if(unit_type == "ground"){
  3381. unitsGround[name[2]][name[3]] = val;
  3382. if(name[2] == "def"){
  3383. calcDef(unitsGround.def);
  3384. } else {
  3385. calcOff(unitsGround.att, unitsGround.att);
  3386. }
  3387. $('#' + name[2] + '_b').get(0).innerHTML = blunt;
  3388. $('#' + name[2] + '_s').get(0).innerHTML = sharp;
  3389. $('#' + name[2] + '_d').get(0).innerHTML = dist;
  3390. } else {
  3391. var att = 0, def = 0;
  3392. unitsNaval[name[2]][name[3]] = val;
  3393. if(name[2] == "def"){
  3394. for(e in unitsNaval.def) {
  3395. if(unitsNaval.def.hasOwnProperty(e)) {
  3396. def += unitsNaval.def[e] * unitVal[e].defense;
  3397. }
  3398. }
  3399. $('#def_ship').get(0).innerHTML = def;
  3400. } else {
  3401. for(e in unitsNaval.att) {
  3402. if(unitsNaval.att.hasOwnProperty(e)) {
  3403. att += unitsNaval.att[e] * unitVal[e].attack;
  3404. }
  3405. }
  3406. $('#att_ship').get(0).innerHTML = att;
  3407. }
  3408. }
  3409. }, 100);
  3410. });
  3411. // Abfrage wegen eventueller Spionageweiterleitung
  3412. getUnitInputs();
  3413. setTimeout(function(){
  3414. setChangeUnitInputs("def");
  3415. }, 100);
  3416. $('#select_insert_units').change(function(){
  3417. var side = $(this).find('option:selected').val();
  3418. setTimeout(function(){
  3419. getUnitInputs();
  3420. if(side === "att" || side === "def"){
  3421. setChangeUnitInputs(side);
  3422. }
  3423. }, 200);
  3424. });
  3425. }
  3426.  
  3427. function getUnitInputs(){
  3428. $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').each(function(){
  3429. name = $(this).attr("name").replace(/\]/g, "").split("[");
  3430. var str = this;
  3431. var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2],
  3432. val, e;
  3433. val = parseInt($(str).val(), 10);
  3434. val = val || 0;
  3435. if(unit_type === "ground"){
  3436. unitsGround[name[2]][name[3]] = val;
  3437. } else {
  3438. var att = 0, def = 0;
  3439. unitsNaval[name[2]][name[3]] = val;
  3440. }
  3441. });
  3442. }
  3443.  
  3444. function setChangeUnitInputs(side){
  3445. $('.place_insert_field[name="sim[units][' + side + '][godsent]"]').change();
  3446. setTimeout(function(){
  3447. $('.place_insert_field[name="sim[units][' + side + '][colonize_ship]"]').change();
  3448. }, 100);
  3449. }
  3450.  
  3451. /*******************************************************************************************************************************
  3452. * Defensive form
  3453. * ----------------------------------------------------------------------------------------------------------------------------
  3454. * | ● Adds a defensive form to the bbcode bar
  3455. * ----------------------------------------------------------------------------------------------------------------------------
  3456. *******************************************************************************************************************************/
  3457.  
  3458. // Funktion aufteilen...
  3459. function addForm(e){
  3460. var textareaId = "", bbcodeBarId = "";
  3461. switch (e) {
  3462. case "/alliance_forum/forum":
  3463. textareaId = "#forum_post_textarea";
  3464. bbcodeBarId = "#forum";
  3465. break;
  3466. case "/message/forward":
  3467. textareaId = "#message_message";
  3468. bbcodeBarId = "#message_bbcodes";
  3469. break;
  3470. case "/message/new":
  3471. textareaId = "#message_new_message";
  3472. bbcodeBarId = "#message_bbcodes";
  3473. break;
  3474. case "/message/view":
  3475. textareaId = "#message_reply_message";
  3476. bbcodeBarId = "#message_bbcodes";
  3477. break;
  3478. case "/player_memo/load_memo_content":
  3479. textareaId = "#memo_text_area";
  3480. bbcodeBarId = "#memo_edit";
  3481. break;
  3482. }
  3483. $('<a title="Verteidigungsformular" href="#" class="dio_bbcode_option def_form" name="def_form"></a>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
  3484. $('.def_form_button').css({
  3485. cursor: 'pointer',
  3486. marginTop:'3px'
  3487. });
  3488. $(bbcodeBarId + ' .dio_bbcode_option').css({
  3489. background: 'url("http://s14.directupload.net/images/140126/lt3hyb8j.png")',
  3490. display: 'block',
  3491. float: 'left',
  3492. width: '22px',
  3493. height: '23px',
  3494. margin: '0 3px 0 0',
  3495. position: 'relative',
  3496. });
  3497. $(bbcodeBarId + ' .def_form').css({
  3498. backgroundPosition: '-89px 0px'
  3499. });
  3500. var imgArray = {
  3501. wall: 'http://de.cdn.grepolis.com/images/game/main/wall.png',
  3502. tower: 'http://de.cdn.grepolis.com/images/game/main/tower.png',
  3503. hide: 'http://de.cdn.grepolis.com/images/game/main/hide.png',
  3504. spy: 'http://s7.directupload.net/images/140114/yr993xwc.png',
  3505. pop: 'http://s7.directupload.net/images/140114/4d6xktxm.png',
  3506. rev1: 'http://s7.directupload.net/images/140115/9cv6otiu.png',
  3507. rev0: 'http://s7.directupload.net/images/140115/aue4rg6i.png',
  3508. eo1: 'http://s1.directupload.net/images/140115/fkzlipyh.png',
  3509. eo0: 'http://s1.directupload.net/images/140115/hs2kg59c.png',
  3510. att: 'http://s1.directupload.net/images/140115/3t6uy4te.png',
  3511. sup: 'http://s7.directupload.net/images/140115/ty6szerx.png',
  3512. zeus: 'http://s1.directupload.net/images/140114/cdxecrpu.png',
  3513. hera: 'http://s1.directupload.net/images/140114/mve54v2o.png',
  3514. athena: 'http://s14.directupload.net/images/140114/kyqyedhe.png',
  3515. poseidon: 'http://s7.directupload.net/images/140114/tusr9oyi.png',
  3516. hades: 'http://s7.directupload.net/images/140114/huins2gn.png',
  3517. artemis: 'http://s7.directupload.net/images/140114/kghjhko8.png',
  3518. nogod: 'http://s1.directupload.net/images/140114/e7vmvfap.png',
  3519. captain: 'http://s14.directupload.net/images/140114/88gg75rc.png',
  3520. commander: 'http://s14.directupload.net/images/140114/slbst52o.png',
  3521. priest: 'http://s1.directupload.net/images/140114/glptekkx.png',
  3522. phalanx: 'http://s7.directupload.net/images/140114/e97wby6z.png',
  3523. ram: 'http://s7.directupload.net/images/140114/s854ds3w.png',
  3524. militia: 'http://wiki.en.grepolis.com/images/9/9b/Militia_40x40.png',
  3525. sword: 'http://wiki.en.grepolis.com/images/9/9c/Sword_40x40.png',
  3526. slinger: 'http://wiki.en.grepolis.com/images/d/dc/Slinger_40x40.png',
  3527. archer: 'http://wiki.en.grepolis.com/images/1/1a/Archer_40x40.png',
  3528. hoplite: 'http://wiki.en.grepolis.com/images/b/bd/Hoplite_40x40.png',
  3529. rider: 'http://wiki.en.grepolis.com/images/e/e9/Rider_40x40.png',
  3530. chariot: 'http://wiki.en.grepolis.com/images/b/b8/Chariot_40x40.png',
  3531. catapult: 'http://wiki.en.grepolis.com/images/f/f0/Catapult_40x40.png',
  3532. godsent: 'http://wiki.de.grepolis.com/images/6/6e/Grepolis_Wiki_225.png',
  3533. def_sum: 'http://s14.directupload.net/images/140127/6cxnis9r.png',
  3534. minotaur: 'http://wiki.de.grepolis.com/images/7/70/Minotaur_40x40.png',
  3535. manticore: 'http://wiki.de.grepolis.com/images/5/5e/Manticore_40x40.png',
  3536. zyclop: 'http://wiki.de.grepolis.com/images/6/66/Zyklop_40x40.png',
  3537. sea_monster:'http://wiki.de.grepolis.com/images/7/70/Sea_monster_40x40.png',
  3538. harpy: 'http://wiki.de.grepolis.com/images/8/80/Harpy_40x40.png',
  3539. medusa: 'http://wiki.de.grepolis.com/images/d/db/Medusa_40x40.png',
  3540. centaur: 'http://wiki.de.grepolis.com/images/5/53/Centaur_40x40.png',
  3541. pegasus: 'http://wiki.de.grepolis.com/images/5/54/Pegasus_40x40.png',
  3542. cerberus: 'http://wiki.de.grepolis.com/images/6/67/Zerberus_40x40.png',
  3543. fury: 'http://wiki.de.grepolis.com/images/6/67/Erinys_40x40.png',
  3544. griffin: 'http://wiki.de.grepolis.com/images/d/d1/Unit_greif.png',
  3545. calydonian_boar: 'http://wiki.de.grepolis.com/images/9/93/Unit_eber.png',
  3546. big_transporter: 'http://wiki.en.grepolis.com/images/0/04/Big_transporter_40x40.png',
  3547. bireme: 'http://wiki.en.grepolis.com/images/4/44/Bireme_40x40.png',
  3548. attack_ship: 'http://wiki.en.grepolis.com/images/e/e6/Attack_ship_40x40.png',
  3549. demolition_ship: 'http://wiki.en.grepolis.com/images/e/ec/Demolition_ship_40x40.png',
  3550. small_transporter: 'http://wiki.en.grepolis.com/images/8/85/Small_transporter_40x40.png',
  3551. trireme: 'http://wiki.en.grepolis.com/images/a/ad/Trireme_40x40.png',
  3552. colonize_ship: 'http://wiki.en.grepolis.com/images/d/d1/Colonize_ship_40x40.png',
  3553. move_icon: 'http://de.cdn.grepolis.com/images/game/unit_overview/',
  3554. bordure: 'http://s1.directupload.net/images/140126/8y6pmetk.png'
  3555. };
  3556. $('<div class="bb_def_chooser">'+
  3557. '<div class="bbcode_box middle_center">'+
  3558. '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div>'+
  3559. '<div class="bbcode_box top_center"></div><div class="bbcode_box bottom_center"></div>'+
  3560. '<div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>'+
  3561. '<div class="bbcode_box middle_left"></div><div class="bbcode_box middle_right"></div>'+
  3562. '<div class="bbcode_box content clearfix" style="padding:5px">'+
  3563. '<div id="f_uni" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].bbc.sel[0] +'</div></div><br><br>'+
  3564. '<div id="f_prm" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].bbc.sel[1] +'</div></div><br><br>'+
  3565. '<div id="f_sil" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].bbc.sel[2] +'</div></div><br><br>'+
  3566. '<div id="f_mov" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">'+ LANG[LID].bbc.sel[3] +'</div></div><br><br>'+
  3567. '<div><a class="button" id="dio_insert" href="#"><span class="left"><span class="right"><span class="middle"><small>'+ LANG[LID].bbc.but +'</small></span></span></span><span></span></a></div>'+
  3568. '</div></div></div>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
  3569. $('.bb_def_chooser').css({
  3570. display: 'none',
  3571. top: '38px',
  3572. left: '510px',
  3573. position: 'absolute',
  3574. width: '190px',
  3575. zIndex: 10000
  3576. });
  3577. $(bbcodeBarId + " .bb_def_chooser .checkbox_new").click(function () {
  3578. $(this).toggleClass("checked");
  3579. });
  3580. $(bbcodeBarId + ' .def_form').toggle(function(){
  3581. $(this).parent().find(".bb_def_chooser").get(0).style.display = "block";
  3582. }, function(){
  3583. $(this).parent().find(".bb_def_chooser").get(0).style.display = "none";
  3584. });
  3585. $(bbcodeBarId + ' #dio_insert').click(function(){
  3586. var textarea = $(textareaId).get(0), text = $(textarea).val(), troop_table = "", troop_img = "", troop_count = "", separator = "", move_table = "", landunit_sum = 0;
  3587. $('.def_form').get(0).click();
  3588. if($('#f_uni').hasClass("checked")){
  3589. $('.units_land .unit, .units_naval .unit').each(function(){
  3590. troop_img += separator + '[img]' + imgArray[this.className.split(" ")[1]] + '[/img]';
  3591. troop_count += separator + '[center]' + $(this).find(".value").get(0).innerHTML + '[/center]';
  3592. separator = "[||]";
  3593. });
  3594. } else {
  3595. $('.units_land .unit').each(function(){
  3596. var a = this.className.split(" ")[1], def = (unitVal[a].def_hack + unitVal[a].def_pierce + unitVal[a].def_distance)/(3 * unitVal[a].population);
  3597. if(def > 10){
  3598. landunit_sum += parseInt($(this).find(".value").get(0).innerHTML, 10) * unitVal[a].population * ((def > 20) ? 2 : 1);
  3599. }
  3600. });
  3601. landunit_sum = (landunit_sum > 10000) ? ((Math.round(landunit_sum / 100))/10) + "k" : landunit_sum;
  3602. troop_img += '[img]'+ imgArray.def_sum +'[/img]';
  3603. troop_count += '[center]'+ landunit_sum +'[/center]';
  3604. separator = "[||]";
  3605. $('.units_naval .unit').each(function(){
  3606. troop_img += separator + '[img]' + imgArray[this.className.split(" ")[1]] + '[/img]';
  3607. troop_count += separator + '[center]' + $(this).find(".value").get(0).innerHTML + '[/center]';
  3608. });
  3609. }
  3610. if(troop_img !== ""){ troop_table = "\n[table][**]" + troop_img + "[/**][**]" + troop_count + "[/**][/table]\n"; }
  3611. var str = '[img]'+ imgArray.bordure + '[/img]'+
  3612. '\n\n[color=#006B00][size=12][u][b]'+ LANG[LID].bbc.ttl +' ([url="http://adf.ly/eDM1y"]©DIO-Tools[/url])[/b][/u][/size][/color]\n\n'+
  3613. //'[table][**][img]'+ imgArray.sup +'[/img][||]'+
  3614. '[size=12][town]' + uw.ITowns.getTown(uw.Game.townId).getId() + '[/town] ([player]'+ uw.Game.player_name +'[/player])[/size]'+
  3615. //'[||][img]'+ imgArray['rev' + (uw.ITowns.getTown(uw.Game.townId).hasConqueror()?1:0)] +'[/img][/**][/table]'+
  3616. '\n\n[i][b]'+ LANG[LID].bbc.inf +'[/b][/i]' + troop_table +
  3617. '[table][*]'+
  3618. '[img]'+ imgArray.wall +'[/img][|]\n'+
  3619. '[img]'+ imgArray.tower +'[/img][|]\n'+
  3620. '[img]'+ imgArray.phalanx +'[/img][|]\n'+
  3621. '[img]'+ imgArray.ram +'[/img][|]\n'+
  3622. ($('#f_prm').hasClass("checked") ? '[img]'+ imgArray.commander +'[/img][|]\n' : ' ')+
  3623. ($('#f_prm').hasClass("checked") ? '[img]'+ imgArray.captain +'[/img][|]\n' : ' ')+
  3624. ($('#f_prm').hasClass("checked") ? '[img]'+ imgArray.priest +'[/img][|]\n' : ' ')+
  3625. ($('#f_sil').hasClass("checked") ? '[center][img]'+imgArray.spy+'[/img][/center][|]\n' : ' ')+
  3626. '[img]'+ imgArray.pop +'[/img][|]\n'+
  3627. '[img]'+ imgArray[(uw.ITowns.getTown(uw.Game.townId).god() || "nogod")] +'[/img][/*]\n'+
  3628. '[**][center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("wall")+ '[/center][||]'+
  3629. '[center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("tower")+ '[/center][||]'+
  3630. '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.phalanx? '+' : '-') + '[/center][||]'+
  3631. '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.ram? '+' : '-')+ '[/center][||]'+
  3632. ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.commander >= uw.Timestamp.now())? '+' : '-') + '[/center][||]' : ' ')+
  3633. ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.captain >= uw.Timestamp.now())? '+' : '-')+ '[/center][||]' : ' ')+
  3634. ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.priest >= uw.Timestamp.now())? '+' : '-') + '[/center][||]' : ' ')+
  3635. ($('#f_sil').hasClass("checked") ? '[center]' + Math.round(uw.ITowns.getTown(uw.Game.townId).getEspionageStorage()/1000) + 'k[/center][||]': ' ')+
  3636. '[center]' + uw.ITowns.getTown(uw.Game.townId).getAvailablePopulation() + '[/center][||]'+
  3637. '[center]' + $('.gods_favor_amount').get(0).innerHTML + '[/center]'+
  3638. '[/**][/table]';
  3639. var bb_count_str = parseInt(str.match(/\[/g).length, 10), bb_count_move = 0;
  3640. var i = 0;
  3641. if($('#f_mov').hasClass("checked")){
  3642. move_table += '\n[i][b]'+ LANG[LID].bbc.mov +'[/b][/i]\n[table]';
  3643. $('#toolbar_activity_commands').mouseover();
  3644. $('#toolbar_activity_commands_list .content .command').each(function(){
  3645. var cl = $(this).children()[0].className.split(" ");
  3646. 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)) {
  3647. move_table += (i%1) ? "" : "[**]";
  3648. i++;
  3649. move_table += "[img]" + imgArray.move_icon + cl[2] + ".png[/img][||]";
  3650. move_table += getArrivalTime($(this).children()[1].innerHTML) + (uw.Game.market_id === "de" ? " Uhr[||]" : " [||]");
  3651. move_table += "[town]" + JSON.parse(atob($(this).children()[2].firstChild.href.split("#")[1])).id + "[/town]";
  3652. move_table += (i%1) ? "[||]" : "[/**]";
  3653. }
  3654. bb_count_move = parseInt(move_table.match(/\[/g).length, 10);
  3655. });
  3656. if((bb_count_str + bb_count_move) > 480){
  3657. move_table += '[**]...[/**]';
  3658. }
  3659. $('#toolbar_activity_commands').mouseout();
  3660. //console.log((bb_count_str + bb_count_move));
  3661. move_table += (i%1) ? "[/**]" : "";
  3662. move_table += "[*][|][color=#800000][size=6][i] ("+ LANG[LID].bbc.dev +": ±1s)[/i][/size][/color][/*][/table]\n";
  3663. }
  3664. str += move_table + '[img]'+ imgArray.bordure + '[/img]';
  3665. $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + str + text.substring($(textarea).get(0).selectionEnd));
  3666. });
  3667. }
  3668.  
  3669. function getArrivalTime(duration_time){
  3670. var server_time = $('.server_time_area').get(0).innerHTML.split(" ")[0].split(":"), arrival_time, s, m, h;
  3671. duration_time = duration_time.split(":");
  3672. s = parseInt(server_time[2], 10) + parseInt(duration_time[2], 10);
  3673. m = parseInt(server_time[1], 10) + parseInt(duration_time[1], 10) + ((s>=60)? 1 : 0);
  3674. h = parseInt(server_time[0], 10) + parseInt(duration_time[0], 10) + ((m>=60)? 1 : 0);
  3675. s = s%60; m = m%60; h = h%24;
  3676. s = ((s<10) ? "0" : "") + s;
  3677. m = ((m<10) ? "0" : "") + m;
  3678. h = ((h<10) ? "0" : "") + h;
  3679. arrival_time = h + ":" + m + ":" + s;
  3680. return arrival_time;
  3681. }
  3682.  
  3683.  
  3684. /*******************************************************************************************************************************
  3685. * Smiley box
  3686. * ----------------------------------------------------------------------------------------------------------------------------
  3687. * | ● Display of a smiley selection box for text input fields (forum, messages, notes):
  3688. * | ● Used smileys: http://www.greensmilies.com/smilie-album/
  3689. * | + Own Grepolis smileys
  3690. * ----------------------------------------------------------------------------------------------------------------------------
  3691. *******************************************************************************************************************************/
  3692.  
  3693. var smileyArray = { "standard": {}, "nature": {}, "grepolis": {}, "people": {}, "other":{} };
  3694.  
  3695. // smiley categories
  3696. smileyArray.button = [ "rollsmiliey", "smile" ];
  3697.  
  3698. smileyArray.standard = [
  3699. "smilenew", "i/cnfy7elqh8dotnsdp", "lol", "neutral_new", "afraid", "freddus_pacman", "auslachen2", "kolobok-sanduhr", "bussi2", "winken4", "flucht2", "panik4", "ins-auge-stechen",
  3700. "seb_zunge", "fluch4_GREEN", "baby_junge2", "blush-reloaded6", "frown", "verlegen", "blush-pfeif", "stevieh_rolleyes", "daumendreh2", "baby_taptap",
  3701. "sadnew", "hust", "confusednew", "idea2", "irre", "irre4", "sleep", "candle", "nicken", "no_sad",
  3702. "thumbs-up_new", "thumbs-down_new", "bravo2", "oh-no2", "kaffee2", "drunk", "saufen", "freu-dance", "hecheln", "headstand", "rollsmiliey", "eazy_cool01", "motz", "cuinlove", "biggrin"
  3703. ];
  3704. smileyArray.nature = [
  3705. "dinosaurier07", "flu-super-gau", "ben_cat", "schwein", "hundeleine01", "blume", "ben_sharky", "ben_cow", "charly_bissig", "gehirnschnecke_confused", "mttao_fische", "mttao_angler",
  3706. "insel", "fliegeschnappen", "i/cifohy0y1cl7nckzw", /* Spinne */ "i/cifogx34asrswrcjw", /* Schiffbrüchiger */ "plapperhase", "ben_dumbo"
  3707. ];
  3708. smileyArray.grepolis = [
  3709. "mttao_wassermann", "i/cigrmpfofys5xtiks", /* Hera */ "i/cifvfsu3e2sdiipn0", /* Medusa */ "i/cigmv8wnffb3v0ifg", /* Mantikor */ "i/cigrqlp2odi2kqo24", /* Zyklop */
  3710. "i/cj1l9gndtu3nduyvi", /* Minotaurus */ "i/cj2byjendffymp88t", /* Pegasus */ "i/cj2ccmi2x8mhcoikd", /* Hydra */
  3711. "silvester_cuinlove", "mttao_schuetze", "kleeblatt2", "wallbash", /* "glaskugel4", */ "musketiere_fechtend", /* "krone-hoch",*/ "i/cifojb85jytq5h07g", // Wikinger
  3712. "mttao_waage2", "steckenpferd", /* "kinggrin_anbeten2", */ "i/cifohielywpedbyh8", /* Grepo Love */ "skullhaufen", "pferdehaufen" // "i/ckajscggscw4s2u60"
  3713. ];
  3714. smileyArray.people = [
  3715. "seb_hut5", "opa_boese2", "star-wars-yoda1-gruen", "hexefliegend", "snob", "seb_detektiv_ani", "seb_cowboy", "devil", "segen", "pirat5", "borg", "hexe3b",
  3716. "i/cifoqe3geok0jco5o", // Ägypter
  3717. "i/ciforgs313z0ae1cc", // Hippie
  3718. "eazy_polizei", "stars_elvis", "mttao_chefkoch", "nikolaus", "pirate3_biggrin", "batman_skeptisch", "tubbie1", "tubbie2", "tubbie3", "tubbie4"
  3719. ];
  3720. smileyArray.other = [
  3721. "steinwerfen", "herzen02", "scream-if-you-can", "kolobok", "headbash", "liebeskummer", "bussi", "brautpaar-reis", "grab-schaufler2", "boxen2", "aufsmaul",
  3722. "sauf", "mttao_kehren", "sm", "weckruf", "klugscheisser2", "karte2_rot", "dagegen", "party","dafuer", "outofthebox", "pokal_gold", "koepfler", "transformer"
  3723. ];
  3724.  
  3725. // Replace german sign smilies
  3726. if(LID !== "de"){
  3727. smileyArray.other[17] = "dagegen2";
  3728. smileyArray.other[19] = "dafuer2";
  3729. }
  3730. // Forum: extra smiley
  3731. if($(".editor_textbox_container").get(0)){
  3732. smileyArray.grepolis.push("i/ckajscggscw4s2u60");
  3733. }
  3734.  
  3735. var id = 0, error_count = 0;
  3736.  
  3737. var er = false;
  3738. // preload images
  3739. function loadSmileys(){
  3740. for(var e in smileyArray){
  3741. if(smileyArray.hasOwnProperty(e)) {
  3742. for(var f in smileyArray[e]){
  3743. if(smileyArray[e].hasOwnProperty(f)) {
  3744. var src = smileyArray[e][f];
  3745. smileyArray[e][f] = new Image();
  3746. smileyArray[e][f].className = "smiley" + (id++);
  3747. smileyArray[e][f].style.margin = '3px';
  3748. smileyArray[e][f].style.maxHeight = '35px';
  3749. smileyArray[e][f].style.cursor = 'pointer';
  3750. if(src.substring(0,2) == "i/" ) {
  3751. smileyArray[e][f].src = "http://666kb.com/" + src + ".gif";
  3752. } else {
  3753. if(er == false){
  3754. smileyArray[e][f].src = "http://www.greensmilies.com/smile/smiley_emoticons_" + src + ".gif";
  3755. } else {
  3756. smileyArray[e][f].src = 'http://s1.directupload.net/images/140128/93x3p4co.gif';
  3757. }
  3758. }
  3759. smileyArray[e][f].onerror = function () {
  3760. this.src = 'http://s1.directupload.net/images/140128/93x3p4co.gif';
  3761. };
  3762. }
  3763. }
  3764. }
  3765. }
  3766. }
  3767.  
  3768. // Forum smilies
  3769. if($(".editor_textbox_container").get(0)){
  3770. loadSmileys();
  3771. changeForumEditorLayout();
  3772. addSmileyBoxForum();
  3773. }
  3774.  
  3775. function changeForumEditorLayout(){
  3776. $('.blockrow').css({ border: "none" });
  3777. // Subject/Title
  3778. $($('.section div label[for="title"]').parent()).css({ float:"left", width:"36%", marginRight: "20px"});
  3779. $($('.section div label[for="subject"]').parent()).css({ float:"left", width:"36%", marginRight: "20px"});
  3780. $('.section div input').eq(0).css({ marginBottom: "-10px", marginTop: "10px"});
  3781. $('#display_posticon').remove();
  3782. // Posticons
  3783. $('.posticons table').css({ width: "50%", /*marginTop: "-16px"*/});
  3784. $('.posticons').css({ marginBottom: "-16px" });
  3785. $('.posticons').insertAfter($('.section div label[for="title"]').parent());
  3786. $('.posticons').insertAfter($('.section div label[for="subject"]').parent());
  3787. // Posticons hint
  3788. $('.posticons p').remove();
  3789. // Posticons: No Icon - radio button
  3790. $(".posticons [colspan='14']").parent().replaceWith($(".posticons [colspan='14']"));
  3791. $(".posticons [colspan='14']").children().wrap("<nobr></nobr>")
  3792. $(".posticons [colspan='14']").appendTo('.posticons tr:eq(0)');
  3793. $(".posticons [colspan='4']").remove();
  3794. }
  3795.  
  3796. function addSmileyBoxForum(){
  3797. $('<div class="smiley_box"><div>'+
  3798. '<div align="center" style="float:left">'+
  3799. '<a class="group" name="standard">'+ LANG[LID].sml.std +'</a>'+
  3800. '<a class="group" name="grepolis">'+ LANG[LID].sml.gre +'</a>'+
  3801. '<a class="group" name="nature">'+ LANG[LID].sml.nat +'</a>'+
  3802. '<a class="group" name="people">'+ LANG[LID].sml.ppl +'</a>'+
  3803. '<a class="group" name="other">'+ LANG[LID].sml.oth +'</a>'+
  3804. '</div><div align="right" style="margin-top:2px;"><a class="smiley_link" href="http://adf.ly/eDbBl" target="_blank">WWW.GREENSMILIES.COM</a></div>'+
  3805. '<hr class="smiley_hr">'+
  3806. '<div class="smiley_box_cont" style="overflow: hidden;"><hr class="smiley_hr"></div>'+
  3807. '</div></div><br>').insertAfter(".texteditor");
  3808. addSmileys("standard", "");
  3809. $('.smiley_hr').css({ margin: '3px 0px 0px 0px', color: '#086b18', border: '1px solid' });
  3810. $('.smiley_link').css({ color: '#0c450c' });
  3811. $('.smiley_link').hover(
  3812. function(){$(this).css({ color: '#14999E' });},
  3813. function(){$(this).css({ color: '#0c450c' });}
  3814. );
  3815. $('.smiley_box').css({ maxHeight: '90px', marginLeft: "5px", width: "99%", minHeight:"10px" });
  3816. $('.smiley_box_cont').css({ height: '100px', overflow: 'overlay' });
  3817. $('.group').css({ color:'#0c450c', marginRight: '10px', cursor:"pointer"}); $('.group[name="standard"]').css({ color:'#089421' });
  3818. $('.group').click(function(){
  3819. $('.group').each(function(){
  3820. $(this).get(0).style.color = '#0c450c';
  3821. });
  3822. $(this).get(0).style.color = '#089421';
  3823. // change smiley group
  3824. addSmileys($(this).get(0).name, "");
  3825. });
  3826. }
  3827.  
  3828.  
  3829. // insert smileys from arrays into smiley box
  3830. function addSmileys(type, bbcodeBarId){
  3831. // reset smilies
  3832. if($(bbcodeBarId + " .smiley_box_cont").get(0)) {$(bbcodeBarId + " .smiley_box_cont").get(0).innerHTML='';}
  3833. // add smilies
  3834. for(var e in smileyArray[type]){
  3835. if(smileyArray[type].hasOwnProperty(e)) {
  3836. $(smileyArray[type][e]).clone().appendTo(bbcodeBarId + " .smiley_box_cont");
  3837. $(bbcodeBarId +" ."+ smileyArray[type][e].className).click(function(){
  3838. var textarea;
  3839. if(uw.location.pathname === "/game/index"){
  3840. // hide smiley box
  3841. $(this).closest('.bb_button_wrapper').find(".smiley_button").click();
  3842. // find textarea
  3843. textarea = $(this).closest('.gpwindow_content').find("textarea").get(0);
  3844. } else {
  3845. if($('.editor_textbox_container').get(0)) {
  3846. textarea = $('.editor_textbox_container .cke_contents textarea').get(0);
  3847. } else {
  3848. $(this).appendTo('iframe .forum');
  3849. }
  3850. //$(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + "[img]"+ $(this).get(0).src + "[/img]" + text.substring($(textarea).get(0).selectionEnd));
  3851. }
  3852. var text = $(textarea).val();
  3853. $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + "[img]"+ $(this).get(0).src + "[/img]" + text.substring($(textarea).get(0).selectionEnd));
  3854. });
  3855. }
  3856. }
  3857. }
  3858.  
  3859. // add smiley box
  3860. function addSmileyBox(e){
  3861. var bbcodeBarId = "";
  3862. switch (e) {
  3863. case "/alliance_forum/forum": bbcodeBarId = "#forum";
  3864. break;
  3865. case "/message/forward": bbcodeBarId = "#message_bbcodes";
  3866. break;
  3867. case "/message/new": bbcodeBarId = "#message_bbcodes";
  3868. break;
  3869. case "/message/view": bbcodeBarId = "#message_bbcodes";
  3870. break;
  3871. case "/player_memo/load_memo_content": bbcodeBarId = "#memo_edit";
  3872. break;
  3873. }
  3874. if(($(bbcodeBarId + ' #emots_popup_7').get(0) || $(bbcodeBarId + ' #emots_popup_15').get(0)) && PID == 84367){
  3875. $(bbcodeBarId + " .bb_button_wrapper").get(0).lastChild.remove();
  3876. }
  3877. $('<img class="smiley_button" src="http://www.greensmilies.com/smile/smiley_emoticons_smile.gif">').appendTo(bbcodeBarId + ' .bb_button_wrapper');
  3878. $('<div class="smiley_box">'+
  3879. '<div class="bbcode_box middle_center"><div class="bbcode_box middle_right"></div><div class="bbcode_box middle_left"></div>'+
  3880. '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div><div class="bbcode_box top_center"></div>'+
  3881. '<div class="bbcode_box bottom_center"></div><div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>'+
  3882. '<div align="center" style="width:100%;">'+
  3883. '<a class="group" name="standard" href="">'+ LANG[LID].sml.std +'</a>'+
  3884. '<a class="group" name="grepolis" href="">'+ LANG[LID].sml.gre +'</a>'+
  3885. '<a class="group" name="nature" href="">'+ LANG[LID].sml.nat +'</a>'+
  3886. '<a class="group" name="people" href="">'+ LANG[LID].sml.ppl +'</a>'+
  3887. '<a class="group" name="other" href="">'+ LANG[LID].sml.oth +'</a>'+
  3888. '</div>'+
  3889. '<hr class="smiley_hr">'+
  3890. '<div class="smiley_box_cont" style="overflow: hidden;"></div>'+
  3891. '<hr class="smiley_hr">'+
  3892. '<div align="center" style="margin-top:2px;"><a href="http://adf.ly/eDbBl" target="_blank"><span class="smiley_link">WWW.GREENSMILIES.COM</span></a></div>'+
  3893. '</div>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
  3894. $(bbcodeBarId + ' .smiley_button').css({
  3895. cursor: 'pointer',
  3896. margin:'3px 2px 2px 2px'
  3897. });
  3898. $(bbcodeBarId + ' .smiley_box').css({
  3899. zIndex: '5000',
  3900. position: 'absolute',
  3901. top: '27px',
  3902. left: '430px',
  3903. width: '300px',
  3904. display: 'none'
  3905. });
  3906. $(bbcodeBarId + ' .smiley_link').css({
  3907. color: '#086b18',
  3908. fontSize: '0.6em'
  3909. });
  3910. $(bbcodeBarId + ' .smiley_hr').css({
  3911. margin: '3px 0px 0px 0px',
  3912. color: '#086b18',
  3913. border: '1px solid'
  3914. });
  3915. $(bbcodeBarId + ' .group').css({
  3916. color:'#0c450c'
  3917. });
  3918. $(bbcodeBarId + ' .group[name="standard"]').css({
  3919. color:'#089421'
  3920. });
  3921. $(bbcodeBarId + ' .group').click(function(){
  3922. $("#"+ $(this).closest('.bb_button_wrapper').parent().get(0).id +' .group').each(function(){
  3923. $(this).get(0).style.color = '#0c450c';
  3924. });
  3925. $(this).get(0).style.color = '#089421';
  3926. // change smiley group
  3927. addSmileys($(this).get(0).name, "#"+ $(this).closest('.bb_button_wrapper').parent().get(0).id);
  3928. });
  3929. addSmileys("standard", bbcodeBarId);
  3930. // smiley box toggle
  3931. $(bbcodeBarId + " .smiley_button").toggle(
  3932. function(){
  3933. $(this).get(0).src = smileyArray.button[0].src;
  3934. $(this).closest('.bb_button_wrapper').find(".smiley_box").get(0).style.display = "block";
  3935. },
  3936. function(){
  3937. $(this).get(0).src = smileyArray.button[1].src;
  3938. $(this).closest('.bb_button_wrapper').find(".smiley_box").get(0).style.display = "none";
  3939. }
  3940. );
  3941. }
  3942.  
  3943.  
  3944. /*******************************************************************************************************************************
  3945. * Biremes counter
  3946. * ----------------------------------------------------------------------------------------------------------------------------
  3947. * | ● Incremental update when calling a city (experimental, especially intended for siege worlds)
  3948. * ----------------------------------------------------------------------------------------------------------------------------
  3949. *******************************************************************************************************************************/
  3950. var count, townId, biriArray = JSON.parse(GM_getValue(WID + "_biri_data", "{}"));
  3951.  
  3952. function updateBiriCount(){
  3953. var sum =0, e;
  3954. for(e in biriArray) {
  3955. if(biriArray.hasOwnProperty(e)) {
  3956. sum += parseInt(biriArray[e], 10);
  3957. }
  3958. }
  3959. if(options.bir){
  3960. sum = sum.toString();
  3961. var str ="", fsize = ['1.4em', '1.2em', '1.15em', '1.1em', '1.0em'], i;
  3962. for(i = 0; i<sum.length; i++){
  3963. str += "<span style='font-size:" + fsize[i] + "'>" + sum[i] + "</span>";
  3964. }
  3965. $('#bi_count').get(0).innerHTML = "<b>" + str + "</b>";
  3966. }
  3967. }
  3968.  
  3969. function getBiri(){
  3970. var biremeIn = parseInt(uw.ITowns.getTown(uw.Game.townId).units().bireme, 10),
  3971. biremeOut = parseInt(uw.ITowns.getTown(uw.Game.townId).unitsOuter().bireme, 10);
  3972. if(isNaN(biremeIn)) biremeIn = 0;
  3973. if(isNaN(biremeOut)) biremeOut = 0;
  3974. if(!biriArray[uw.Game.townId] || biriArray[uw.Game.townId] < (biremeIn + biremeOut)) {
  3975. biriArray[uw.Game.townId] = biremeIn;
  3976. }
  3977. updateBiriCount();
  3978. saveBiri();
  3979. }
  3980.  
  3981. function getBiriDocks(){
  3982. var windowID = uw.BuildingWindowFactory.getWnd().getID(),
  3983. biremeTotal = parseInt($('#gpwnd_' + windowID + ' #unit_order_tab_bireme .unit_order_total').get(0).innerHTML, 10);
  3984. if(!isNaN(biremeTotal)) biriArray[uw.Game.townId] = biremeTotal;
  3985. updateBiriCount();
  3986. saveBiri();
  3987. }
  3988.  
  3989. function getBiriAgora(){
  3990. var biremeTotal = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().bireme, 10);
  3991. if(isNaN(biremeTotal)) biremeTotal = 0;
  3992. $('#units_beyond_list .bireme').each(function(){
  3993. biremeTotal += parseInt($(this).get(0).children[0].innerHTML, 10);
  3994. });
  3995. biriArray[uw.Game.townId] = biremeTotal;
  3996. updateBiriCount();
  3997. saveBiri();
  3998. }
  3999.  
  4000. function saveBiri(){
  4001. setTimeout(function(){
  4002. GM_setValue(WID + "_biri_data", JSON.stringify(biriArray));
  4003. }, 0);
  4004. }
  4005.  
  4006. function initBiri() {
  4007. $(".picomap_container").prepend("<div id='unit_count'><div id='bi_count'></div></div>");
  4008. updateBiriCount();
  4009. $('#unit_count').css({
  4010. background: 'url(http://de.cdn.grepolis.com/images/game/units/units_sprite_90x90_compressed.jpg)',
  4011. height: '90px',
  4012. width: '90px',
  4013. position: 'relative',
  4014. margin: '5px 28px 0px 28px',
  4015. backgroundPosition: '-270px 0px'
  4016. });
  4017. $('#sea_id').css({
  4018. background: 'none',
  4019. fontSize: '25px',
  4020. cursor: 'auto',
  4021. height: '50px',
  4022. width: '50px',
  4023. position: 'relative'
  4024. });
  4025. if($('#tutorial_quest_container').get(0)){
  4026. $('#sea_id').prependTo('#tutorial_quest_container');
  4027. } else {
  4028. $('#sea_id').appendTo('#ui_box');
  4029. $('#sea_id').css({
  4030. position: 'absolute',
  4031. top: '75px',
  4032. left: '157px'
  4033. });
  4034. }
  4035. $('#bi_count').css({
  4036. color: '#826021',
  4037. position: 'relative',
  4038. top: '28px',
  4039. fontStyle: 'italic',
  4040. width: '79px'
  4041. });
  4042. $('.picomap_overlayer').tooltip(LANG[LID].set.bir[0]);
  4043. }
  4044.  
  4045.  
  4046. /*******************************************************************************************************************************
  4047. * Popups
  4048. * ----------------------------------------------------------------------------------------------------------------------------
  4049. * | ● Available units (no supporting or outer units)
  4050. * | ● Improved favor
  4051. * | ● getTownTypes
  4052. * ----------------------------------------------------------------------------------------------------------------------------
  4053. *******************************************************************************************************************************/
  4054. var groupUnitArray = {};
  4055. // TODO: split Function (getUnits, calcUnitsSum, availableUnits, countBiremes, getTownTypes)?
  4056. function getAllUnits(){
  4057. var townArray = uw.ITowns.getTowns(), groupArray = uw.ITowns.townGroups.getGroups(),
  4058. unitArray = {"sword":0, "archer":0, "hoplite":0, "chariot":0, "godsent":0, "rider":0, "slinger":0, "catapult":0, "small_transporter":0, "big_transporter":0,
  4059. "manticore":0, "harpy":0, "pegasus":0, "cerberus":0, "minotaur":0, "medusa":0, "zyklop":0, "centaur":0, "fury":0, "sea_monster":0 },
  4060. unitArraySea = {"bireme":0, "trireme":0, "attack_ship":0, "demolition_ship":0, "colonize_ship":0 };
  4061. if(uw.Game.is_hero_world){
  4062. unitArray = $.extend(unitArray, {"griffin":0, "calydonian_boar":0});
  4063. }
  4064. unitArray = $.extend(unitArray, unitArraySea);
  4065. for(var group in groupArray){
  4066. if(groupArray.hasOwnProperty(group)){
  4067. // clone Object "unitArray"
  4068. groupUnitArray[group] = Object.create(unitArray);
  4069. for(var town in groupArray[group]["towns"]){
  4070. if(groupArray[group]["towns"].hasOwnProperty(town)){
  4071. var type = { lo: 0, ld: 0, so: 0, sd: 0, fo: 0, fd: 0 }; // Type for TownList
  4072. for(var unit in unitArray){
  4073. if(unitArray.hasOwnProperty(unit)){
  4074. // All Groups: Available units
  4075. var tmp = parseInt(uw.ITowns.getTown(town).units()[unit], 10);
  4076. groupUnitArray[group][unit] += tmp || 0;
  4077. // Only for group "All"
  4078. if(group == -1){
  4079. //Bireme counter
  4080. if( unit === "bireme" && ((biriArray[townArray[town].id] || 0) < (tmp || 0))) {
  4081. biriArray[townArray[town].id] = tmp;
  4082. }
  4083. //TownTypes
  4084. if(!unitVal[unit].is_naval){
  4085. if(unitVal[unit].flying){
  4086. type.fd += ((unitVal[unit].def_hack + unitVal[unit].def_pierce + unitVal[unit].def_distance)/3 * (tmp || 0));
  4087. type.fo += (unitVal[unit].attack * (tmp || 0));
  4088. } else {
  4089. type.ld += ((unitVal[unit].def_hack + unitVal[unit].def_pierce + unitVal[unit].def_distance)/3 * (tmp || 0));
  4090. type.lo += (unitVal[unit].attack * (tmp || 0));
  4091. }
  4092. } else {
  4093. type.sd += (unitVal[unit].defense * (tmp || 0));
  4094. type.so += (unitVal[unit].attack * (tmp || 0));
  4095. }
  4096. }
  4097. }
  4098. }
  4099. // Only for group "All"
  4100. if(group == -1){
  4101. // Icon: DEF or OFF?
  4102. var z = ((type.sd + type.ld + type.fd) <= (type.so + type.lo + type.fo)) ? "o" : "d",
  4103. temp = 0;
  4104. for(var t in type){
  4105. if(type.hasOwnProperty(t)){
  4106. // Icon: Land/Sea/Fly (t[0]) + OFF/DEF (z)
  4107. if(temp < type[t]){
  4108. autoTownTypes[townArray[town].id] = t[0] + z;
  4109. temp = type[t];
  4110. }
  4111. // Icon: Troops Outside (overwrite)
  4112. if(temp < 1000){
  4113. autoTownTypes[townArray[town].id] = "no";
  4114. }
  4115. }
  4116. }
  4117. // Icon: Empty Town (overwrite)
  4118. var popBuilding = 0, buildVal = uw.GameData.buildings, levelArray = townArray[town].buildings().getLevels(),
  4119. popTotal = Math.floor(buildVal.farm.farm_factor * Math.pow(townArray[town].buildings().getBuildingLevel("farm"), buildVal.farm.farm_pow)), // Population from farm level
  4120. popPlow = townArray[town].researches().attributes.plow ? 200 : 0,
  4121. popFactor = townArray[town].buildings().getBuildingLevel("thermal") ? 1.1 : 1.0, // Thermal
  4122. popExtra = townArray[town].getPopulationExtra();
  4123. for(var b in levelArray){
  4124. if(levelArray.hasOwnProperty(b)){
  4125. popBuilding += Math.round(buildVal[b].pop * Math.pow(townArray[town].buildings().getBuildingLevel(b), buildVal[b].pop_factor));
  4126. }
  4127. }
  4128. townPopulation[town] = popTotal * popFactor + popPlow + popExtra - (popBuilding + townArray[town].getAvailablePopulation());
  4129. if((popTotal * popFactor + popPlow + popExtra - (popBuilding + townArray[town].getAvailablePopulation())) < 300){
  4130. autoTownTypes[townArray[town].id] = "po";
  4131. }
  4132. // Icon: Farm Incomplete
  4133. if(townArray[town].buildings().getBuildingLevel("farm") < 40){
  4134. //autoTownTypes[townArray[town].id] = "bu";
  4135. }
  4136. }
  4137. }
  4138. }
  4139. }
  4140. }
  4141. updateBiriCount();
  4142. saveBiri();
  4143. //if(options.pop) {
  4144. updateAvailableUnitsBox(groupUnitArray[-1]);
  4145. //}
  4146. }
  4147.  
  4148. function addAvailableUnitsBox(){
  4149. var groupArray = uw.ITowns.townGroups.getGroups();
  4150. $('<div id="available_units_box" class="ui-dialog">'+
  4151. '<div class="bbcode_box middle_center"><div class="bbcode_box middle_right"></div><div class="bbcode_box middle_left"></div>'+
  4152. '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div><div class="bbcode_box top_center"></div>'+
  4153. '<div class="bbcode_box bottom_center"></div><div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>'+
  4154. '<h4><nobr>'+ LANG[LID].uni + '</nobr></h4>'+
  4155. '<div class="drop_box">'+
  4156. '<div class="drop_group dropdown default">'+
  4157. '<div class="border-left"></div><div class="border-right"></div>'+
  4158. '<div class="caption" name="'+ groupArray[-1].id +'">'+ groupArray[-1].name +'</div>'+
  4159. '<div class="arrow"></div>'+
  4160. '</div>'+
  4161. '<div class="select_group dropdown-list default active"><div class="item-list"></div></div>'+
  4162. '</div><hr>'+
  4163. '<div class="box_content"></div>'+
  4164. '</div>').appendTo('body');
  4165. for(var group in groupArray){
  4166. if(groupArray.hasOwnProperty(group)){
  4167. $('<div class="option'+ (group == -1 ? " sel" : "") +'" name="'+ group +'">'+ groupArray[group].name +'</div>').appendTo('#available_units_box .item-list');
  4168. }
  4169. }
  4170. // Styles
  4171. $('#available_units_box .drop_box').css({
  4172. float: 'left',
  4173. position: 'absolute',
  4174. top: '1px',
  4175. right: '0px',
  4176. width: '90px',
  4177. zIndex: '1'
  4178. });
  4179. $('#available_units_box h4').css({
  4180. color: 'rgb(128, 64, 0)',
  4181. width: '10px',
  4182. height: '25px',
  4183. marginLeft: '4px',
  4184. lineHeight: '1.9'
  4185. });
  4186. $('#available_units_box .drop_group').css({
  4187. width: '84px'
  4188. });
  4189. $('#available_units_box .select_group').css({
  4190. position: 'absolute',
  4191. width: '80px',
  4192. display: "none",
  4193. right: '3px'
  4194. });
  4195. //$('#available_units_box .item-list').css({ maxHeight: '400px', maxWidth: '200px', align: "right" });
  4196. $('#available_units_box .arrow').css({
  4197. width: '18px',
  4198. height: '18px',
  4199. background: 'url('+ drop_out.src +') no-repeat -1px -1px',
  4200. position: 'absolute'
  4201. });
  4202. // hover effects of the elements in the drop menu
  4203. $('#available_units_box .option').hover(
  4204. function(){ $(this).css({color: '#fff', background: "#328BF1"}); },
  4205. function(){ $(this).css({color: '#000', background: "#FFEEC7"}); }
  4206. );
  4207. // click events of the drop menu
  4208. $('#available_units_box .select_group .option').each(function(){
  4209. $(this).click(function(e){
  4210. $(this).parent().find(".sel").toggleClass("sel");
  4211. $(this).toggleClass("sel");
  4212. $('#available_units_box .drop_group .caption').attr("name", $(this).attr("name"));
  4213. $('#available_units_box .drop_group .caption').get(0).innerHTML = $(this).get(0).innerHTML;
  4214. $('#available_units_box .select_group')[0].style.display = "none";
  4215. updateAvailableUnitsBox(groupUnitArray[$(this).attr("name")]);
  4216. //$('#available_units_box .drop_group .caption').change();
  4217. });
  4218. });
  4219. // show & hide drop menu on click
  4220. $('#available_units_box .drop_group').click(function(){
  4221. if($('#available_units_box .select_group')[0].style.display === "none"){
  4222. $('#available_units_box .select_group')[0].style.display = "block";
  4223. } else {
  4224. $('#available_units_box .select_group')[0].style.display = "none";
  4225. }
  4226. });
  4227. $('#available_units_box').click(function(e){
  4228. var clicked = $(e.target);
  4229. if(!(clicked[0].parentNode.className.split(" ")[1] === "dropdown")){
  4230. $('#available_units_box .select_group').get(0).style.display = "none";
  4231. }
  4232. });
  4233. // hover arrow change
  4234. $('#available_units_box .dropdown').hover(function(e){
  4235. $(e.target)[0].parentNode.childNodes[3].style.background = "url('"+ drop_over.src +"') no-repeat -1px -1px";
  4236. }, function(e){
  4237. $(e.target)[0].parentNode.childNodes[3].style.background = "url('"+ drop_out.src +"') no-repeat -1px -1px";
  4238. });
  4239. //$("#available_units_box .drop_group .caption").attr("name", "All");
  4240. //$('#available_units_box .drop_group').tooltip();
  4241. $('#available_units_box').draggable({
  4242. containment: "body",
  4243. snap: "body",
  4244. });
  4245. $('#available_units_box').css({
  4246. color: 'rgb(12, 69, 12)',
  4247. position: 'absolute',
  4248. top: '100px',
  4249. left: '200px',
  4250. zIndex: getMaxZIndex() + 1,
  4251. display: 'none'
  4252. });
  4253. $('#available_units_box .box_content').css({
  4254. background: 'url(http://s1.directupload.net/images/140206/8jd9d3ec.png) 94% 94% no-repeat',
  4255. backgroundSize: '140px'
  4256. });
  4257. $('#available_units_box').bind("mousedown",function(){
  4258. $(this).get(0).style.zIndex = getMaxZIndex() + 1;
  4259. });
  4260. $('#available_units_box hr').css({ margin: '3px 0px 0px', border: '1px solid', color: 'rgb(128, 64, 0)'});
  4261. }
  4262.  
  4263. function updateAvailableUnitsBox(unitArray){
  4264. var i = 0, content = '<table><tr><td>';
  4265. for(var u in unitArray){
  4266. if(unitArray.hasOwnProperty(u)){
  4267. if(((i%5 == 0) && (i!== 25)) || u == "bireme") {
  4268. content += "</td></tr><tr><td>";
  4269. }
  4270. content += '<div class="unit index_unit bold unit_icon40x40 ' + u + ' " ><span style="font-size:0.9em">' + unitArray[u] + '</span></div> ';
  4271. i++;
  4272. }
  4273. }
  4274. content += '</td></tr></table>';
  4275. $('#available_units_box .box_content').get(0).innerHTML = "";
  4276. $('#available_units_box .box_content').append(content);
  4277. /*
  4278. $('#united_units').css({
  4279. height: '300px',
  4280. width: '300px',
  4281. position: 'relative'
  4282. });
  4283. */
  4284. }
  4285.  
  4286. function unbindFavorPopup(){
  4287. $('.gods_favor_button_area, #favor_circular_progress').mouseover();
  4288. $('.gods_favor_button_area, #favor_circular_progress').bind('mouseover mouseout', function(){
  4289. return false;
  4290. });
  4291. $('.gods_area').bind('mouseover', function(){
  4292. setFavorPopup();
  4293. });
  4294. }
  4295.  
  4296. var godArray = {
  4297. zeus: ' 0px', //'http://s1.directupload.net/images/140116/mkhzwush.png',
  4298. hera: '-152px', //'http://s1.directupload.net/images/140116/58ob8z82.png',
  4299. poseidon: '-101px', //'http://s1.directupload.net/images/140116/dkfxrw2f.png',
  4300. athena: ' -50px', //'http://s14.directupload.net/images/140116/iprgopak.png',
  4301. hades: '-203px', //'http://s14.directupload.net/images/140116/c9juk95y.png',
  4302. artemis: '-305px', //'http://s14.directupload.net/images/140116/pdc8vxe2.png'
  4303. };
  4304.  
  4305. var godImg = new Image(); godImg.src = "http://s7.directupload.net/images/140118/j5gzsghx.png";
  4306.  
  4307. function setFavorPopup(){
  4308. var pic_row = "",
  4309. fav_row = "",
  4310. prod_row = "";
  4311. for(var g in godArray){
  4312. if(godArray.hasOwnProperty(g)){
  4313. if(uw.ITowns.player_gods.attributes.temples_for_gods[g]){
  4314. pic_row += '<td><div style="width:50px;height:51px;background:url('+ godImg.src +');background-position: 0px '+ godArray[g] +';"></td>';
  4315. fav_row += '<td class="bold" style="color:blue">'+ uw.ITowns.player_gods.attributes[g + "_favor"] +'</td>';
  4316. prod_row += '<td class="bold">'+ uw.ITowns.player_gods.attributes.production_overview[g].production +'</td>';
  4317. }
  4318. }
  4319. }
  4320. var tool_element = $('<table><tr><td></td>'+ pic_row +'</tr>'+
  4321. '<tr align="center"><td><img src="http://de.cdn.grepolis.com/images/game/res/favor.png"></td>'+ fav_row +'</tr>'+
  4322. '<tr align="center"><td>+</td>'+ prod_row +'</tr>'+
  4323. '</table>');
  4324. $('.gods_favor_button_area, #favor_circular_progress').tooltip(tool_element);
  4325. }
  4326.  
  4327.  
  4328. /*******************************************************************************************************************************
  4329. * GUI Optimization
  4330. * ----------------------------------------------------------------------------------------------------------------------------
  4331. * | ● Modified spell box (smaller, moveable & position memory)
  4332. * | ● Larger taskbar and minimize daily reward-window on startup
  4333. * | ● Modify chat
  4334. * | ● Improved display of troops and trade activity boxes (movable with position memory on startup)
  4335. * ----------------------------------------------------------------------------------------------------------------------------
  4336. *******************************************************************************************************************************/
  4337.  
  4338. // Spell box
  4339. function catchSpellBox(){
  4340. var spellbox = new MutationObserver(function(mutations) {
  4341. mutations.forEach(function(mutation) {
  4342. //console.log(mutation);
  4343. if(mutation.addedNodes[0]){
  4344. //console.log(mutation.addedNodes[0] + " " + mutation.attributeName);
  4345. changeSpellBox();
  4346. }
  4347. });
  4348. });
  4349. spellbox.observe($('.gods_spells_menu .content').get(0), { attributes: false, childList: true, characterData: false });
  4350. }
  4351.  
  4352. function initSpellBox(){
  4353. var spellbox_top, spellbox_left, spellbox_show;
  4354. $('<style type="text/css">'+
  4355. '.gods_spells_active .nui_right_box {'+
  4356. 'height: 158px !important;'+
  4357. '</style>').appendTo('head');
  4358. $(".gods_spells_menu").css({
  4359. height: $(".nui_units_box").height() +"px"
  4360. });
  4361. console.log($(".nui_units_box").height());
  4362. setTimeout(function(){
  4363. spellbox_show = GM_getValue("spellbox_show", false);
  4364. // Timeout nicht optimal!!!
  4365. setTimeout(function(){
  4366. if(spellbox_show) {
  4367. $('.btn_gods_spells').click();
  4368. }
  4369. }, 2500);
  4370. }, 0);
  4371. $('.btn_gods_spells').click(function(){
  4372. spellbox_show = !spellbox_show;
  4373. setTimeout(function(){
  4374. GM_setValue("spellbox_show", spellbox_show);
  4375. }, 0);
  4376. });
  4377. $('.nui_units_box').css({
  4378. display: 'block',
  4379. marginTop: '-8px',
  4380. position: 'relative'
  4381. });
  4382. $('.nui_right_box').css({
  4383. height: '158px'
  4384. });
  4385. $('.nui_units_box .bottom_ornament').css({
  4386. marginTop: '-28px',
  4387. position: 'relative'
  4388. });
  4389. $('.gods_spells_menu .top').css({
  4390. //marginTop: '-28px',
  4391. //backgroundPosition: 'right -232px'
  4392. });
  4393. $('.gods_area').css({
  4394. height: '170px'
  4395. });
  4396. $(".gods_spells_menu").draggable({
  4397. containment: "body",
  4398. distance: 10 ,
  4399. snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, #island_quests_overview",
  4400. opacity: 0.7,
  4401. stop : function(){
  4402. spellbox_top = this.style.top;
  4403. spellbox_left = this.style.left;
  4404. setTimeout(function(){
  4405. GM_setValue("spellbox_top", spellbox_top);
  4406. GM_setValue("spellbox_left", spellbox_left);
  4407. }, 0);
  4408. //console.log(spellbox_top + " " + spellbox_left);
  4409. }
  4410. });
  4411. $(".gods_area .gods_spells_menu").before($('.nui_units_box'));
  4412. setTimeout(function(){
  4413. spellbox_top = GM_getValue("spellbox_top", "23%");
  4414. spellbox_left = GM_getValue("spellbox_left", "-150%");
  4415. //console.log(spellbox_top + " " + spellbox_left);
  4416. $('.gods_spells_menu').css({
  4417. position: 'absolute',
  4418. left: spellbox_left,
  4419. top: spellbox_top,
  4420. zIndex: '5000',
  4421. padding: '30px 0px 0px -4px'
  4422. });
  4423. }, 0);
  4424. }
  4425. function changeSpellBox(){
  4426. $(".gods_spells_menu").css({
  4427. height: $(".nui_units_box").height() + "px"
  4428. });
  4429. console.log($(".nui_units_box").height());
  4430. $('.god_container[data-god_id="zeus"]').css({
  4431. width: '43px',
  4432. float: 'left'
  4433. });
  4434. $('.god_container[data-god_id="zeus"] .powers_container').css({
  4435. background: 'none'
  4436. });
  4437. $('.god_container[data-god_id="athena"]').css({
  4438. width: '85px',
  4439. float: 'left'
  4440. });
  4441. $('.god_container[data-god_id="athena"] .powers_container').css({
  4442. background: 'none'
  4443. });
  4444. $('.content .title').each(function(){
  4445. $(this).get(0).remove();
  4446. });
  4447. //$('.gods_spells_menu .god_container[data-god_id="zeus"]').before('.god_container[data-god_id="poseidon"]');
  4448. if($('.bolt').get(0)) $('.bolt').get(0).remove();
  4449. if($('.earthquake').get(0)) $('.earthquake').get(0).remove();
  4450. if($('.pest').get(0)) $('.pest').get(0).remove();
  4451. }
  4452.  
  4453. // Minimize Daily reward window on startup
  4454. function minimizeDailyReward(){
  4455. var startup, daily_reward_minimized = false, town_window = false;
  4456. startup = new MutationObserver(function(mutations) {
  4457. mutations.forEach(function(mutation) {
  4458. if(mutation.addedNodes[0]){
  4459. if($('#new_daily_reward').get(0) && !uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).isMinimized()){
  4460. uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).minimize();
  4461. }
  4462. }
  4463. });
  4464. });
  4465. startup.observe($('body').get(0), { attributes: false, childList: true, characterData: false});
  4466. setTimeout(function(){ startup.disconnect();}, 3000);
  4467. }
  4468.  
  4469. // Larger taskbar
  4470. function scaleTaskbar(){
  4471. $('.minimized_windows_area').get(0).style.width= "150%";
  4472. $('.minimized_windows_area').get(0).style.left= "-25%";
  4473. }
  4474. // hide fade out buttons => only for myself
  4475. function hideNavElements() {
  4476. if((PID == 84367) && (uw.Game.premium_features.curator<=uw.Timestamp.now())){
  4477. $('.nav').each(function() {
  4478. $(this).get(0).style.display = "none";
  4479. });
  4480. }
  4481. }
  4482.  
  4483. /*******************************************************************************************************************************
  4484. * Modify Chat
  4485. *******************************************************************************************************************************/
  4486. function popupChatUser(){
  4487. setTimeout(function(){
  4488. GM_xmlhttpRequest({
  4489. method: "POST",
  4490. url: "http://wwwapi.iz-smart.net/modules.php?name=Chaninfo&file=nicks&chan=Grepolis"+ uw.Game.market_id.toUpperCase(),
  4491. onload: function(response) {
  4492. //$('.nui_main_menu .chat .indicator').get(0).innerHTML =
  4493. //console.log(response.responseText);
  4494. //$('.nui_main_menu .chat .indicator').get(0).style.display = 'inline';
  4495. }
  4496. });
  4497. }, 0);
  4498. }
  4499.  
  4500. function initChatUser(){
  4501. $('.nui_main_menu .chat .button, .nui_main_menu .chat .name_wrapper').css({
  4502. WebkitFilter: 'hue-rotate(65deg)',
  4503. filter: 'url(#Hue1)'
  4504. });
  4505. updateChatUser();
  4506. setInterval(function(){ updateChatUser(); }, 300000);
  4507. $('.nui_main_menu .chat').mouseover(function(){
  4508. //popupChatUser();
  4509. });
  4510. if($('.nui_main_menu .chat').hasClass('disabled')){ $('.nui_main_menu .chat').removeClass('disabled');}
  4511. }
  4512.  
  4513. function updateChatUser(){
  4514. var market = uw.Game.market_id;
  4515. //if(uw.Game.market_id !== 'fr'){
  4516. setTimeout(function(){
  4517. GM_xmlhttpRequest({
  4518. method: "POST",
  4519. url: "http://api.relay-chat.de/compteur_js.php?chan="+ (market === "de" ? "Grepolis" + uw.Game.market_id.toUpperCase() : "GREPO"),
  4520. onload: function(response) {
  4521. $('.nui_main_menu .chat .indicator').get(0).innerHTML = response.responseText.split("'")[1];
  4522. $('.nui_main_menu .chat .indicator').get(0).style.display = 'inline';
  4523. }
  4524. });
  4525. }, 0);
  4526. //}
  4527. }
  4528.  
  4529. // Modify chat window
  4530. var chat_is_hidden = false, chatwnd_id;
  4531. function modifyChat() {
  4532. var host = { fr: 'irc.quakenet.org', def: 'flash.afterworkchat.de'}, market = uw.Game.market_id;
  4533. setTimeout(function(){ updateChatUser(); }, 10000); setTimeout(function(){ updateChatUser(); }, 30000);
  4534. //uw.GPWindowMgr.Create(uw.Layout.wnd.TYPE_CHAT);
  4535. //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).setWidth(300);
  4536. //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).setHeight(0);
  4537. //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).setPosition([0,'bottom']);
  4538. //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT));
  4539. chatwnd_id = '#gpwnd_' + uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).getID();
  4540. //$(chatwnd_id).parent().children('.gpwindow_left').remove();
  4541. //$(chatwnd_id).parent().children('.gpwindow_right').remove();
  4542. //$(chatwnd_id).parent().children('.gpwindow_top').remove();
  4543. //$(chatwnd_id).parent().children('.gpwindow_bottom').remove();
  4544. //$(chatwnd_id).parent().parent().children('.ui-dialog-titlebar').remove();
  4545. var nickname = uw.Game.player_name.replace(/[.,:,+,*]/g,"").replace(/[=,\ ,-]/g,"_").replace(/ö/gi,"oe").replace(/ä/gi,"ae").replace(/ü/gi,"ue").replace(/ß/g,"ss");
  4546. nickname = "kνnm";
  4547. $('#chat').get(0).innerHTML = "";
  4548. $('<iframe src="http://flash.afterworkchat.de/1.0/FlashChat.swf'+ //http://grepodio.heliohost.org/lightIRC/index.php'+
  4549. '?host='+ host.def + //( market === 'fr' ? host.fr : host.def ) +
  4550. '&policyPort=9000'+
  4551. '&charset=utf-8'+
  4552. //'&port=6667'+
  4553. '&languagePath=http://flash.afterworkchat.de/1.0/language/'+
  4554. '&styleURL=http://grepodio.heliohost.org/lightIRC/css/green2.css'+ //http://grepodio.heliohost.org/style.css'+ //
  4555. '&emoticonPath=http://grepodio.heliohost.org/lightIRC/emoticons/'+ //http://www.greensmilies.com/smile/smiley_emoticons_'+
  4556. '&emoticonList='+
  4557. ':)->happy.png,'+
  4558. ':(->sad.png,'+
  4559. ':O->baby2.swf,'+
  4560. //';)->thumbs-up_new.gif,'+
  4561. ':D->biggrin.png,'+
  4562. '~D->coffee2.swf,'+
  4563. ':P->tongue.swf,'+
  4564. '8)->cool.png,'+
  4565. ':|->neutral.png,'+
  4566. 'X)->drunk.swf,'+
  4567. '%5e%5e->grins.png,'+
  4568. ':{->frown2.swf,'+
  4569. ':S->verlegen.png,'+
  4570. ':$->blush.swf,'+
  4571. ////':S->unsure.gif,'+
  4572. ':]->lol2.swf,'+
  4573. ':*->bussi.swf,'+
  4574. ':[->fluch.swf'+
  4575. '&accessKey=54a2846a460ae1703ac690d21551b997'+
  4576. '&nick='+ nickname +
  4577. '&nickAlternate='+ nickname +'_'+
  4578. '&autojoin='+ (market === "de" ? '%23GREPO,%23' + uw.Game.world_id + ',%23Grepolis'+ market.toUpperCase() : '%23Grepolis'+ market.toUpperCase() + ",%23GREPO") +
  4579. //( market === 'fr' ? '%23Grepolis.fr' : '%23Grepolis'+ market.toUpperCase() ) +
  4580. '&showNavigation=true'+
  4581. '&navigationPosition=top'+
  4582. '&showNickSelection=true'+
  4583. '&showIdentifySelection=false'+
  4584. '&language='+ market +
  4585. '&quitMessage=CYA'+
  4586. '&showChannelHeader=false'+
  4587. //'&useUserListIcons=true'+
  4588. '&userListWidth=100'+
  4589. '&soundAlerts=true'+
  4590. '&soundOnNewChannelMessage=false'+
  4591. '&showServerWindow=false'+
  4592. '&fontSize=9'+
  4593. '&showJoinPartMessages=false'+
  4594. '&showMenuButton=false'+
  4595. '&showTranslationButton=false'+
  4596. '&showTimestamps=true'+
  4597. //'&showInfoMessages=false'+
  4598. '&showRegisterNicknameButton=false'+
  4599. '&showRichTextControls=false'+
  4600. //'&useUserListIcons=true'+
  4601. '&showUserListInformationPopup=false'+
  4602. '&showNickChangeButton=false'+
  4603. '&showChannelCentral=false'+
  4604. '&showOptionsButton=false'+
  4605. '&showEmoticonsButton=true'+
  4606. '&rememberNickname=false'+
  4607. '" style="width:518px; height:357px; border:0px;"></iframe>').appendTo("#chat");
  4608. //$('<iframe name="web" src="http://webchat.quakenet.org/?nick=Diony&channels=GrepolisDE&uio=Mz1mYWxzZSY5PXRydWUmMTA9dHJ1ZSYxMT00MSYxMz1mYWxzZQf0" width="500" height="400"></iframe>').appendTo("#chat");
  4609. //$('<iframe src="http://flash.afterworkchat.de/1.0/FlashChat.swf?host=flash.afterworkchat.de&languagePath=http://flash.afterworkchat.de/1.0/language/&emoticonPath=http://flash.afterworkchat.de/1.0/emoticons/&accessKey=54a2846a460ae1703ac690d21551b997&policyPort=9000&nick=Chat-Besucher%25&realname=http://www.AfterWorkChat.de&autojoin=%23GrepolisDE&showNickSelection=false&showIdentifySelection=false&language=de&quitMessage=&soundAlerts=false&fontSize=9&showJoinPartMessages=false&showTimestamps=true&showRegisterNicknameButton=false&showNickChangeButton=false&showOptionsButton=false&rememberNickname=false&styleURL=http://flash.afterworkchat.de/1.0/css/black.css" style="width:800px; height:400px;"></iframe>').appendTo("#chat");
  4610. //$('<style type="text/css"> #ircui { background-color: black !important;} </style>').appendTo('head');
  4611. /*
  4612. setTimeout(function(){
  4613. console.log("bla");
  4614. window.frames[0].document.getElementById('ircui').append("I was modified by JS!");
  4615. //$("iframe").contents().find("body").append("I was modified by JS!");
  4616. console.log(document.getElementById('web'));
  4617. console.log(document.getElementById('ircui'));
  4618. var li = document.createElement('li');
  4619.  
  4620. }, 5000);
  4621. */
  4622. /*
  4623. $('.chat_left').css({
  4624. height: '190px',
  4625. width: '20px',
  4626. position: 'absolute',
  4627. right: '0px',
  4628. //background: 'url(http://s7.directupload.net/images/140410/m8n9eafe.png) no-repeat 2px 50%',
  4629. //backgroundSize: '19px 130%'
  4630. });
  4631. */
  4632. //$(chatwnd_id).animate({ width: "300px"}, 800);
  4633. //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).setHeight(200);
  4634. //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).setPosition([0,'bottom']);
  4635. //$('#chat_controls').remove();
  4636. /*
  4637. $('.btn_hide_chat').toggle(function(){
  4638. $(chatwnd_id).parent().parent().animate({ width: "140px", left: "-120px"}, 800);
  4639. $(chatwnd_id).animate({ width: "140px"}, 800);
  4640. setTimeout(function(){
  4641. $('.btn_hide_chat').removeClass('left'); $('.btn_hide_chat').addClass('right');
  4642. }, 800);
  4643. chat_is_hidden = true;
  4644. }, function(){
  4645. $(chatwnd_id).parent().parent().animate({ width: "300px", left:"0px"}, 800);
  4646. $(chatwnd_id).animate({ width: "300px"}, 800);
  4647. setTimeout(function(){
  4648. $('.btn_hide_chat').removeClass('right'); $('.btn_hide_chat').addClass('left');
  4649. }, 800);
  4650. chat_is_hidden = false;
  4651. });
  4652. */
  4653. //appendTo('.chat_elements');
  4654. /*
  4655. $('<style type="text/css"> '+ chatwnd_id +' { left: 0px !important;top: 0px;overflow: visible;right: -15px;top: 0px;} </style>').appendTo('head');
  4656. $('<style type="text/css"> #chat_roominfo { width: 25% !important; font-size: 0.8em;right:20px;overflow: hidden; border-right: 1px solid #D1BF91;} </style>').appendTo('head');
  4657. $('<style type="text/css"> #chat_history_bg, #chat_message_text { width: 68% !important; font-size: 0.7em;} </style>').appendTo('head');
  4658. $('<style type="text/css"> #chat_history_bg { bottom: 20px !important;} </style>').appendTo('head');
  4659. $('<style type="text/css"> #chat { background: url(http://gpde.innogamescdn.com/images/game/layout/gpwindow_bg.jpg) 0 0 repeat; border: 4px inset rgb(109, 87, 59); overflow: hidden !important;border: 3px inset rgb(59, 109, 59);border-radius: 10px;} </style>').appendTo('head');
  4660. $('<style type="text/css"> #chat_history .chat_line_date { position: relative !important; float: left; margin: 2px 5px 0px -2px !important; font-size: 0.8em !important;} </style>').appendTo('head');
  4661. $('<style type="text/css"> #chat_history .chat_line { padding: 1px 0px 0px 0px;} </style>').appendTo('head');
  4662. $('<style type="text/css"> #chat_history .chat_line_sender { color: #0A5700 !important;} </style>').appendTo('head');
  4663. //$('<style type="text/css"> #chat_history { word-break: break-all;} </style>').appendTo('head');
  4664. $('<style type="text/css"> #chat_history .chat_line_notification .chat_line_message { margin: 0px 0px 0px 0px !important; color: rgb(68, 0, 0);} </style>').appendTo('head');
  4665. $('<style type="text/css"> #chat_message_text { height: 16px !important;} </style>').appendTo('head');
  4666. */
  4667. //uw.Layout.playerProfile.open('Diony');
  4668. //uw.Layout.allianceProfile.open(69);
  4669. // Hide Chat in the menu
  4670. /*
  4671. setTimeout(function(){
  4672. $('.chat').get(0).remove();
  4673. $('.nui_main_menu .content ul').get(0).style.height = ($('.nui_main_menu .content ul').height() - 34) + "px";
  4674. },0);
  4675. */
  4676. }
  4677.  
  4678. /*
  4679. $(window).resize(function() {
  4680. //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_CHAT).setPosition(['0px','bottom']);
  4681. if(chat_is_hidden){
  4682. //$(chatwnd_id).parent().parent().css({ left:"-120px"});
  4683. } else {
  4684. //$(chatwnd_id).parent().parent().css({ left:"0px"});
  4685. }
  4686. });
  4687. */
  4688.  
  4689. /*******************************************************************************************************************************
  4690. * Activity boxes
  4691. * ----------------------------------------------------------------------------------------------------------------------------
  4692. * | ● Show troops and trade activity boxes
  4693. * | ● Boxes are magnetic & movable (position memory)
  4694. * ----------------------------------------------------------------------------------------------------------------------------
  4695. *******************************************************************************************************************************/
  4696.  
  4697. var box_standard = { trade: { top: 55, left: 450 }, commands : { top: 55, left: 250 } }, mut_toolbar, mut_command, mut_trade;
  4698.  
  4699. box = JSON.parse(GM_getValue("box", JSON.stringify(box_standard)));
  4700.  
  4701. function checkToolbarAtStart(){
  4702. if(parseInt($('.toolbar_activities .commands .count').get(0).innerHTML, 10) > 0){
  4703. $('#toolbar_activity_commands_list').get(0).style.display = "block";
  4704. } else {
  4705. $('#toolbar_activity_commands_list').get(0).style.display = "none";
  4706. }
  4707. if(parseInt($('.toolbar_activities .trades .count').get(0).innerHTML, 10) > 0){
  4708. $('#toolbar_activity_trades_list').get(0).style.display = "block";
  4709. } else {
  4710. $('#toolbar_activity_trades_list').get(0).style.display = "none";
  4711. }
  4712. }
  4713.  
  4714. function catchToolbarEvents(){
  4715. mut_toolbar = new MutationObserver(function(mutations) {
  4716. mutations.forEach(function(mutation) {
  4717. if(mutation.addedNodes[0]){
  4718. //console.log(mutation);
  4719. if(mutation.target.id === "toolbar_activity_trades_list"){
  4720. draggableTradeBox();
  4721. } else {
  4722. draggableCommandBox();
  4723. }
  4724. mutation.addedNodes[0].remove();
  4725. }
  4726. });
  4727. });
  4728. mut_command = new MutationObserver(function(mutations) {
  4729. mutations.forEach(function(mutation) {
  4730. if(mutation.addedNodes[0]){
  4731. if(mutation.addedNodes[0].nodeValue > 0){
  4732. $('#toolbar_activity_commands_list').get(0).style.display = "block";
  4733. } else {
  4734. $('#toolbar_activity_commands_list').get(0).style.display = "none";
  4735. }
  4736. }
  4737. });
  4738. });
  4739. mut_trade = new MutationObserver(function(mutations) {
  4740. mutations.forEach(function(mutation) {
  4741. if(mutation.addedNodes[0]){
  4742. if(mutation.addedNodes[0].nodeValue > 0){
  4743. $('#toolbar_activity_trades_list').get(0).style.display = "block";
  4744. } else {
  4745. $('#toolbar_activity_trades_list').get(0).style.display = "none";
  4746. }
  4747. }
  4748. });
  4749. });
  4750. }
  4751.  
  4752. // moveable boxes
  4753. function draggableTradeBox(){
  4754. $("#toolbar_activity_trades_list").draggable({
  4755. containment: "body",
  4756. distance: 20,
  4757. snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, .nui_left_box",
  4758. opacity: 0.7,
  4759. start : function () {
  4760. $("#fix_trade").remove();
  4761. },
  4762. stop : function () {
  4763. var pos = $('#toolbar_activity_trades_list').position();
  4764. box.trade.left = pos.left;
  4765. box.trade.top = pos.top;
  4766. setTimeout(function(){
  4767. GM_setValue("box", JSON.stringify(box));
  4768. }, 0);
  4769. $('<style id="fix_trade" type="text/css">'+
  4770. '#toolbar_activity_trades_list {'+
  4771. 'left:' + box.trade.left + 'px !important;'+
  4772. 'top: ' + box.trade.top + 'px !important}'+
  4773. '</style>').appendTo('head');
  4774. }
  4775. });
  4776. }
  4777.  
  4778. function draggableCommandBox(){
  4779. $("#toolbar_activity_commands_list").draggable({
  4780. containment: "body",
  4781. distance: 20,
  4782. snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, .nui_left_box",
  4783. opacity: 0.7,
  4784. stop : function () {
  4785. var pos = $('#toolbar_activity_commands_list').position();
  4786. box.commands.left = pos.left;
  4787. box.commands.top = pos.top;
  4788. setTimeout(function(){
  4789. GM_setValue("box", JSON.stringify(box));
  4790. }, 0);
  4791. }
  4792. });
  4793. }
  4794.  
  4795. function showCommandsAndTrades(){
  4796. var observe_options = { attributes: false, childList: true, characterData: false};
  4797. catchToolbarEvents();
  4798. mut_toolbar.observe($('#toolbar_activity_commands_list').get(0), observe_options );
  4799. mut_toolbar.observe($('#toolbar_activity_trades_list').get(0), observe_options );
  4800. mut_command.observe($('.toolbar_activities .commands .count').get(0), observe_options );
  4801. mut_trade.observe($('.toolbar_activities .trades .count').get(0), observe_options );
  4802. $('#toolbar_activity_commands').mouseover();
  4803. $('#toolbar_activity_trades').mouseover();
  4804. $('#toolbar_activity_commands, #toolbar_activity_trades').unbind("mouseover");
  4805. $('#toolbar_activity_commands, #toolbar_activity_commands_list, #toolbar_activity_trades, #toolbar_activity_trades_list').unbind("mouseout");
  4806. $('#toolbar_activity_trades_list').unbind("click");
  4807. checkToolbarAtStart();
  4808. $('#toolbar_activity_commands_list').css({
  4809. left: box.commands.left + "px",
  4810. top: box.commands.top + "px"
  4811. });
  4812. $('<style id="fix_lists" type="text/css">'+
  4813. '#toolbar_activity_commands_list, #toolbar_activity_trades_list { width: 160px}'+
  4814. '.dropdown-list .content { max-height: 329px}'+
  4815. '</style>'+
  4816. '<style id="fix_trade" type="text/css">'+
  4817. '#toolbar_activity_trades_list {'+
  4818. 'left:' + box.trade.left + 'px !important;'+
  4819. 'top: ' + box.trade.top + 'px !important}'+
  4820. '</style>').appendTo('head');
  4821. draggableCommandBox();
  4822. draggableTradeBox();
  4823. $('.toolbar_activities .commands').mouseover(function(){
  4824. $('#toolbar_activity_commands_list').get(0).style.display = "block";
  4825. });
  4826. $('.toolbar_activities .trades').mouseover(function(){
  4827. $('#toolbar_activity_trades_list').get(0).style.display = "block";
  4828. });
  4829. }
  4830.  
  4831. /*******************************************************************************************************************************
  4832. * Other stuff
  4833. *******************************************************************************************************************************/
  4834.  
  4835. function counter(time){
  4836. var type = "", today, counted, year, month, day;
  4837. if(uw.Game.market_id !== "zz"){
  4838. setTimeout(function(){
  4839. counted = JSON.parse(GM_getValue("Counter",'[ "00000000", false ]'));
  4840. today = new Date((time + 7200) * 1000);
  4841. year = today.getUTCFullYear();
  4842. month = ((today.getUTCMonth()+1) < 10 ? "0" : "") + (today.getUTCMonth()+1);
  4843. day = (today.getUTCDate() < 10 ? "0" : "") + today.getUTCDate();
  4844. today = year + month + day;
  4845. console.log(today);
  4846. if(counted[0] !== today){type += "d"; }
  4847. if(counted[1] == false){ type += "t"; }
  4848. if(type !== ""){
  4849. setTimeout(function(){
  4850. GM_xmlhttpRequest({
  4851. method: "GET",
  4852. url: "http://grepodio.heliohost.org/count.php?type="+ type + "&market="+ uw.Game.market_id + "&date="+ today,
  4853. onload: function(response) {
  4854. //console.log(response.responseText);
  4855. if(response.responseText.indexOf("tot") > -1){
  4856. counted[1] = true;
  4857. }
  4858. if(response.responseText.indexOf("dly") > -1){
  4859. counted[0] = today;
  4860. }
  4861. setTimeout(function(){
  4862. GM_setValue("Counter", JSON.stringify(counted));
  4863. }, 0);
  4864. }
  4865. });
  4866. }, 0);
  4867. }
  4868. },0);
  4869. }
  4870. }
  4871.  
  4872. /*
  4873. function xmas(){
  4874. $('<a href="http://www.greensmilies.com/smilie-album/" target="_blank"><div id="xmas"></div></a>').appendTo('#ui_box');
  4875. $('#xmas').css({
  4876. background: 'url("http://www.greensmilies.com/smile/smiley_emoticons_weihnachtsmann_nordpol.gif") no-repeat',
  4877. height: '51px',
  4878. width: '61px',
  4879. position:'absolute',
  4880. bottom:'10px',
  4881. left:'60px',
  4882. zIndex:'2000'
  4883. });
  4884. $('#xmas').tooltip("HO HO HO, Frohe Weihnachten!");
  4885. }
  4886.  
  4887. function silvester(){
  4888. $('<a href="http://www.greensmilies.com/smilie-album/" target="_blank"><div id="silv">'+
  4889. '<img src="http://www.greensmilies.com/smile/sign2_2.gif">'+
  4890. '<img src="http://www.greensmilies.com/smile/sign2_0.gif">'+
  4891. '<img src="http://www.greensmilies.com/smile/sign2_1.gif">'+
  4892. '<img src="http://www.greensmilies.com/smile/sign2_4.gif">'+
  4893. '</div></a>').appendTo('#ui_box');
  4894. $('#silv').css({
  4895. //background: 'url("http://www.greensmilies.com/smile/buchstaben_0.gif") no-repeat',
  4896. //height: '57px',
  4897. //width: '34px',
  4898. position:'absolute',
  4899. bottom:'10px',
  4900. left:'70px',
  4901. zIndex:'10'
  4902. });
  4903. $('#silv').tooltip("Frohes Neues!");
  4904. }
  4905.  
  4906. function joke(){
  4907. setTimeout(function(){
  4908. if($('#grcgrc').get(0)){
  4909. $('<a href="http://www.greensmilies.com/smilie-album/" target="_blank"><div id="fight"></div></a>').appendTo('#ui_box');
  4910. $('#fight').css({
  4911. background: 'url("http://www.greensmilies.com/smile/smiley_emoticons_hoplit_speer4.gif") no-repeat',
  4912. height: '51px',
  4913. width: '61px',
  4914. position:'absolute',
  4915. bottom:'10px',
  4916. left:'39px',
  4917. zIndex:'2000'
  4918. });
  4919. $('#fight').tooltip("WWW.GREENSMILIES.COM");
  4920. }
  4921. }, 5000);
  4922. }
  4923. */

QingJ © 2025

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