· 5 years ago · Mar 10, 2020, 01:06 AM
1// ==UserScript==
2// @name DIO-TOOLS
3// @namespace DIO
4// @version 3.19
5// @author Diony
6// @description DIO-Tools is a small extension for the browser game Grepolis. (counter, displays, smilies, trade options, changes to the layout)
7// @include http://de.grepolis.com/game*
8// @include /http[s]{0,1}://[a-z]{2}[0-9]{1,2}\.grepolis\.com/game*/
9// @include https://*.forum.grepolis.com/*
10// @include http://diotools.de/*
11// @require http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
12// @icon http://s7.directupload.net/images/140128/vqchpigi.gif
13// @icon64 http://diotools.de/images/icon_dio_64x64.png
14// @copyright 2013+, DIONY
15// @grant GM_info
16// @grant GM_setValue
17// @grant GM_getValue
18// @grant GM_deleteValue
19// @grant GM_xmlhttpRequest
20// @grant GM_getResourceURL
21// ==/UserScript==
22
23var version = '3.19';
24
25//if(unsafeWindow.DM) console.dir(unsafeWindow.DM.status('l10n'));
26//console.dir(DM.status('templates'));
27
28//http://s7.directupload.net/images/140128/vqchpigi.gif - DIO-Tools-Smiley
29
30//http://de44.grepolis.com/cache/js/libs/jquery-1.10.2.min.js
31
32
33//console.log(JSON.stringify(DM.getl10n()));
34
35
36//// console.log(GM_getResourceText("dio_sprite"));
37
38/*******************************************************************************************************************************
39 * Changes
40 * ----------------------------------------------------------------------------------------------------------------------------
41 * | ● Einstellungen und auch das ganze Script komplett überarbeitet
42 * | ● Features können nun ohne Refresh deaktiviert/aktiviert werden
43 * | ● Einzelne Features sind unabhängiger voneinander und somit auch fehlerresistenter (einzelne Features können sich bei Fehlerauftreten durch Grepolis-Updates nicht mehr gegenseitig blockieren)
44 * | ● Fehlerhafter Biremenzähler als Kompromiss für die Erweiterung der "Verfügbare Einheiten"-Anzeige entfernt: es kann nun jede Einheit im Bullauge angezeigt werden
45 * | ● EO-Zähler hat ATT/UT's doppelt gezählt, wenn nebenher der veröffentlichte Belagerungsbericht im Forum offen war
46 * | ● 3 kleine Layoutfehler beim EO-Zähler behoben
47 * | ● Wenn Zauberfenster und Zauberbox gleichzeitig offen waren, kam es zu einem Layoutfehler
48 * | ● Fehler beim Mausrad-Zoom behoben
49 * | ● Fehler bei der Transporteranzeige behoben: die Kapazität der großen Transporter wurde durch das Rebalancing nichtmehr korrekt berechnet
50 * | ● Smileybox etwas verbessert
51 * | ● Weihnachtssmileys hinzugefügt
52 * | ● Kontextmenü der Stadticons auf der strategischen Karte konnte im Nachtmodus nicht geöffnet werden
53 * | ● Grüner Fortschrittsbalken beim Weltwunderzähler wurde nicht angezeigt
54 * | ● Fenster wurden angepasst (Verfügbare Einheiten und Einheitenvergleich)
55 * ----------------------------------------------------------------------------------------------------------------------------
56 *******************************************************************************************************************************/
57
58/*******************************************************************************************************************************
59 * Bugs / TODOs
60 * ----------------------------------------------------------------------------------------------------------------------------
61 * | ● Aktivitätsbox für Angriffe blendet nicht aus
62 * | ● Smileys verschwinden manchmal? -> bisher nicht reproduzierbar
63 * | ● Performanceeinbruch nach dem Switchen des WW-Fensters
64 * | ● keine Smileys im Grepoforum mit Safari (fehlendes jQuery)
65 * ----------------------------------------------------------------------------------------------------------------------------
66 *******************************************************************************************************************************/
67
68/*******************************************************************************************************************************
69 * Global stuff
70 *******************************************************************************************************************************/
71var uw = unsafeWindow || window, $ = uw.jQuery || jQuery, DATA, GM;
72
73// GM-API?
74GM = (typeof GM_info === 'object');
75
76console.log('%c|= DIO-Tools is active =|', 'color: green; font-size: 1em; font-weight: bolder; ');
77
78function loadValue(name, default_val){
79 var value;
80 if(GM){
81 value = GM_getValue(name, default_val);
82 } else {
83 value = localStorage.getItem(name) || default_val;
84 }
85
86 if(typeof(value) === "string"){
87 value = JSON.parse(value)
88 }
89 return value;
90}
91
92// LOAD DATA
93if(GM && (uw.location.pathname.indexOf("game") >= 0)){
94 var WID = uw.Game.world_id, MID = uw.Game.market_id, AID = uw.Game.alliance_id;
95
96 //GM_deleteValue(WID + "_bullseyeUnit");
97
98 DATA = {
99 // GLOBAL
100 options : loadValue("options", "{}"),
101
102 user : loadValue("dio_user", "{}"),
103 count: loadValue("dio_count", "[]"),
104
105 notification : loadValue('notif', '0'),
106
107 error: loadValue('error', '{}'),
108
109 spellbox : loadValue("spellbox", '{ "top":"23%", "left": "-150%", "show": false }'),
110 commandbox: loadValue("commandbox" , '{ "top":55, "left": 250 }'),
111 tradebox : loadValue("tradebox", '{ "top":55, "left": 450 }'),
112
113 // WORLD
114 townTypes : loadValue(WID + "_townTypes", "{}"),
115 sentUnits : loadValue(WID + "_sentUnits", '{ "attack": {}, "support": {} }'),
116
117 biremes : loadValue(WID + "_biremes", "{}"), //old
118 bullseyeUnit : loadValue(WID + "_bullseyeUnit", '{ "current_group" : -1 }'), // new
119
120 worldWonder : loadValue(WID + "_wonder", '{ "ratio": {}, "storage": {}, "map": {} }'),
121
122 clickCount : loadValue(WID + "_click_count", '{}'), // old
123 statistic : loadValue(WID + "_statistic", '{}'), // new
124
125 // MARKET
126 worldWonderTypes : loadValue(MID + "_wonderTypes", '{}')
127 };
128
129 if(!DATA.worldWonder.map) {
130 DATA.worldWonder.map = {};
131 }
132
133 // Temporary:
134 if(typeof DATA.options.trd == 'boolean') {
135 DATA.options.per = DATA.options.rec = DATA.options.trd; delete DATA.options.trd;
136 }
137 if(typeof DATA.options.mov == 'boolean') {
138 DATA.options.act = DATA.options.mov; delete DATA.options.mov;
139 }
140 if(typeof DATA.options.twn == 'boolean') {
141 DATA.options.tic = DATA.options.til = DATA.options.tim = DATA.options.twn; delete DATA.options.twn;
142 }
143 if(GM) GM_deleteValue("notification");
144}
145
146// GM: EXPORT FUNCTIONS
147uw.saveValueGM = function(name, val){
148 setTimeout(function(){
149 GM_setValue(name, val);
150 }, 0);
151};
152
153uw.deleteValueGM = function(name){
154 setTimeout(function(){
155 GM_deleteValue(name);
156 },0);
157};
158
159uw.getImageDataFromCanvas = function(x, y){
160
161 // console.debug("HEY", document.getElementById('canvas_picker').getContext('2d').getImageData(x, y, 1, 1));
162};
163uw.calculateConcaveHull = function() {
164 var contour = [
165 new poly2tri.Point(100, 100),
166 new poly2tri.Point(100, 300),
167 new poly2tri.Point(300, 300),
168 new poly2tri.Point(300, 100)
169 ];
170
171 var swctx = new poly2tri.SweepContext(contour);
172
173 swctx.triangulate();
174 var triangles = swctx.getTriangles();
175
176 // console.debug(triangles);
177
178 return triangles;
179};
180
181if(typeof exportFunction == 'function'){
182 // Firefox > 30
183 //uw.DATA = cloneInto(DATA, unsafeWindow);
184 exportFunction(uw.saveValueGM, unsafeWindow, {defineAs: "saveValueGM"});
185 exportFunction(uw.deleteValueGM, unsafeWindow, {defineAs: "deleteValueGM"});
186 exportFunction(uw.calculateConcaveHull, unsafeWindow, {defineAs: "calculateConcaveHull"});
187 exportFunction(uw.getImageDataFromCanvas, unsafeWindow, {defineAs: "getImageDataFromCanvas"});
188} else {
189 // Firefox < 30, Chrome, Opera, ...
190 //uw.DATA = DATA;
191}
192
193var time_a, time_b;
194
195// APPEND SCRIPT
196function appendScript(){
197 //console.log("GM-API: " + gm_bool);
198 if(document.getElementsByTagName('body')[0]){
199 var dioscript = document.createElement('script');
200 dioscript.type ='text/javascript';
201 dioscript.id = 'diotools';
202
203 time_a = uw.Timestamp.client();
204 dioscript.textContent = DIO_GAME.toString().replace(/uw\./g, "") + "\n DIO_GAME('"+ version +"', "+ GM +", '" + JSON.stringify(DATA).replace(/'/g, "##") + "', "+ time_a +");";
205 document.body.appendChild(dioscript);
206 } else {
207 setTimeout(function(){
208 appendScript();
209 }, 500);
210 }
211}
212
213if(location.host === "diotools.de"){
214 // PAGE
215 DIO_PAGE();
216}
217else if((uw.location.pathname.indexOf("game") >= 0) && GM){
218 // GAME
219 appendScript();
220}
221else {
222 DIO_FORUM();
223}
224
225function DIO_PAGE(){
226 if(typeof GM_info == 'object') {
227 setTimeout(function() {
228 dio_user = JSON.parse(loadValue("dio_user", ""));
229 console.log(dio_user);
230 uw.dio_version = parseFloat(version);
231 }, 0);
232 } else {
233 dio_user = localStorage.getItem("dio_user") || "";
234
235 dio_version = parseFloat(version);
236 }
237}
238function DIO_FORUM(){
239 var smileyArray = [];
240
241 var _isSmileyButtonClicked = false;
242
243 smileyArray.standard = [
244 "smilenew", "grin", "lol", "neutral_new", "afraid", "freddus_pacman", "auslachen2", "kolobok-sanduhr", "bussi2", "winken4", "flucht2", "panik4", "ins-auge-stechen",
245 "seb_zunge", "fluch4_GREEN", "baby_junge2", "blush-reloaded6", "frown", "verlegen", "blush-pfeif", "stevieh_rolleyes", "daumendreh2", "baby_taptap",
246 "sadnew", "hust", "confusednew", "idea2", "irre", "irre4", "sleep", "candle", "nicken", "no_sad",
247 "thumbs-up_new", "thumbs-down_new", "bravo2", "oh-no2", "kaffee2", "drunk", "saufen", "freu-dance", "hecheln", "headstand", "rollsmiliey", "eazy_cool01", "motz", "cuinlove", "biggrin"
248 ];
249 smileyArray.grepolis = [
250 "mttao_wassermann", "hera", /* Hera */ "medusa", /* Medusa */ "manticore", /* Mantikor */ "cyclops", /* Zyklop */
251 "minotaur", /* Minotaurus */ "pegasus", /* Pegasus */ "hydra", /* Hydra */
252 "silvester_cuinlove", "mttao_schuetze", "kleeblatt2", "wallbash", /* "glaskugel4", */ /* "musketiere_fechtend",*/ /* "krone-hoch",*/ "viking", // Wikinger
253 /* "mttao_waage2", */ "steckenpferd", /* "kinggrin_anbeten2", */ "grepolove", /* Grepo Love */ "skullhaufen", "grepo_pacman" /*, "pferdehaufen" */ // "i/ckajscggscw4s2u60"
254 ];
255
256 var ForumObserver = new MutationObserver(function (mutations) {
257 mutations.forEach(function (mutation) {
258
259 if (mutation.addedNodes[0]) {
260
261 //console.debug("Added Nodes", mutation.addedNodes[0]);
262
263 // Message Box geladen
264 if(mutation.addedNodes[0].className === "redactor_box"){
265
266 //console.debug("Message Box geladen");
267
268 ForumObserver.observe($(".redactor_box").get(0), {
269 attributes: false,
270 childList: true,
271 characterData: false,
272 subtree:true
273 });
274 }
275
276 // Toolbar der Message Box geladen
277 if(_isSmileyButtonClicked === false && mutation.addedNodes[0].className === "redactor_toolbar") {
278 $(".redactor_btn_smilies").click();
279
280 // Soll sich nicht wieder deaktivieren
281 _isSmileyButtonClicked = true;
282 }
283
284 // Smileybar der Toolbar geladen
285 if(mutation.addedNodes[0].className === "redactor_smilies") {
286
287 // Observer soll nicht mehr feuern, wenn die Smileys hinzugefügt werden
288 ForumObserver.disconnect();
289
290 // Hässliche Smileys entfernen
291 $(".smilieCategory ul").empty();
292
293 // Greensmileys hinzufügen
294 for(var smiley in smileyArray.standard){
295 if(smileyArray.standard.hasOwnProperty(smiley)){
296 $(".smilieCategory ul").append(
297 '<li class="Smilie" data-text="">'+
298 '<img src="https://diotools.de/images/smileys/standard/smiley_emoticons_'+ smileyArray.standard[smiley] +'.gif" title="" alt="" data-smilie="yes">'+
299 '</li>'
300 );
301 }
302 }
303
304 $(".smilieCategory ul").append("<br><br>");
305
306 for(var smiley in smileyArray.grepolis){
307 if(smileyArray.grepolis.hasOwnProperty(smiley)){
308 $(".smilieCategory ul").append(
309 '<li class="Smilie" data-text="">'+
310 '<img src="https://diotools.de/images/smileys/grepolis/smiley_emoticons_'+ smileyArray.grepolis[smiley] +'.gif" title="" alt="" data-smilie="yes">'+
311 '</li>'
312 );
313 }
314 }
315
316 _isSmileyBarOpened = true;
317 }
318 }
319 });
320 });
321
322 // Smiley-Button aktivieren, um die Smiley-Toolbar zu öffnen
323 if($(".redactor_btn_smilies").get(0)){
324 $(".redactor_btn_smilies").click();
325
326 _isSmileyButtonClicked = true;
327 }
328
329 // Observer triggern
330 if($("#QuickReply").get(0)) {
331 ForumObserver.observe($("#QuickReply div").get(0), {
332 attributes: false,
333 childList: true,
334 characterData: false,
335 subtree:true
336 });
337 }
338 else if($("#ThreadReply").get(0)) {
339 ForumObserver.observe($("#ThreadReply div").get(0), {
340 attributes: false,
341 childList: true,
342 characterData: false,
343 subtree:true
344 });
345 }
346 /*
347 else if($("#ThreadCreate").get(0)) {
348 ForumObserver.observe($("#ThreadCreate fieldset .ctrlUnit dd div").get(0), {
349 attributes: false,
350 childList: true,
351 characterData: false
352 });
353 }
354 */
355
356 // Threaderstellung, Signatur bearbeiten, Beitrag bearbeiten
357 else if($("form.Preview").get(0)) {
358
359 ForumObserver.observe($("form.Preview .ctrlUnit dd div").get(0), {
360 attributes: false,
361 childList: true,
362 characterData: false
363 });
364 }
365 else if(typeof($("form.AutoValidator").get(0)) !== "undefined") {
366
367 ForumObserver.observe($("form.AutoValidator .messageContainer div").get(0), {
368 attributes: false,
369 childList: true,
370 characterData: false
371 });
372 }
373
374 // TODO: Bearbeiten, Nachrichten
375}
376
377
378
379function DIO_GAME(version, gm, DATA, time_a) {
380 var MutationObserver = uw.MutationObserver || window.MutationObserver,
381
382 WID, MID, AID, PID, LID,
383
384 dio_sprite = "http://666kb.com/i/d9xuhtcctx5fdi8i6.png"; // http://abload.de/img/dio_spritejmqxp.png, http://img1.myimg.de/DIOSPRITEe9708.png -> Forbidden!?
385
386 if (uw.location.pathname.indexOf("game") >= 0) {
387 DATA = JSON.parse(DATA.replace(/##/g, "'"));
388
389 WID = uw.Game.world_id;
390 MID = uw.Game.market_id;
391 AID = uw.Game.alliance_id;
392 PID = uw.Game.player_id;
393 LID = uw.Game.locale_lang.split("_")[0]; // LID ="es";
394
395 // World with Artemis ??
396 Game.hasArtemis = true; //Game.constants.gods.length == 6;
397 }
398
399 $.prototype.reverseList = [].reverse;
400
401 // Implement old jQuery method (version < 1.9)
402 $.fn.toggleClick = function () {
403 var methods = arguments; // Store the passed arguments for future reference
404 var count = methods.length; // Cache the number of methods
405
406 // Use return this to maintain jQuery chainability
407 // For each element you bind to
408 return this.each(function (i, item) {
409 // Create a local counter for that element
410 var index = 0;
411
412 // Bind a click handler to that element
413 $(item).on('click', function () {
414 // That when called will apply the 'index'th method to that element
415 // the index % count means that we constrain our iterator between 0
416 // and (count-1)
417 return methods[index++ % count].apply(this, arguments);
418 });
419 });
420 };
421
422 function saveValue(name, val) {
423 if (gm) {
424 saveValueGM(name, val);
425 } else {
426 localStorage.setItem(name, val);
427 }
428 }
429
430 function deleteValue(name) {
431 if (gm) {
432 deleteValueGM(name);
433 } else {
434 localStorage.removeItem(name);
435 }
436 }
437
438 /*******************************************************************************************************************************
439 * Graphic filters
440 *******************************************************************************************************************************/
441 if (uw.location.pathname.indexOf("game") >= 0) {
442 $('<svg width="0%" height="0%">' +
443 // GREYSCALE
444 '<filter id="GrayScale">' +
445 '<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">' +
446 '</filter>' +
447 // SEPIA
448 '<filter id="Sepia">' +
449 '<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">' +
450 '</filter>' +
451 // SATURATION
452 '<filter id="Saturation"><feColorMatrix type="saturate" values="0.2"></filter>' +
453 '<filter id="Saturation1"><feColorMatrix type="saturate" values="1"></filter>' +
454 '<filter id="Saturation2"><feColorMatrix type="saturate" values="2"></filter>' +
455 // HUE
456 '<filter id="Hue1"><feColorMatrix type="hueRotate" values= "65"></filter>' +
457 '<filter id="Hue2"><feColorMatrix type="hueRotate" values="150"></filter>' +
458 '<filter id="Hue3"><feColorMatrix type="hueRotate" values="-65"></filter>' +
459 // BRIGHTNESS
460 '<filter id="Brightness15">' +
461 '<feComponentTransfer><feFuncR type="linear" slope="1.5"/><feFuncG type="linear" slope="1.5"/><feFuncB type="linear" slope="1.5"/></feComponentTransfer>' +
462 '</filter>' +
463 '<filter id="Brightness12">' +
464 '<feComponentTransfer><feFuncR type="linear" slope="1.2"/><feFuncG type="linear" slope="1.2"/><feFuncB type="linear" slope="1.2"/></feComponentTransfer>' +
465 '</filter>' +
466 '<filter id="Brightness11">' +
467 '<feComponentTransfer><feFuncR type="linear" slope="1.1"/><feFuncG type="linear" slope="1.1"/><feFuncB type="linear" slope="1.1"/></feComponentTransfer>' +
468 '</filter>' +
469 '<filter id="Brightness10">' +
470 '<feComponentTransfer><feFuncR type="linear" slope="1.0"/><feFuncG type="linear" slope="1.0"/><feFuncB type="linear" slope="1.0"/></feComponentTransfer>' +
471 '</filter>' +
472 '<filter id="Brightness07">' +
473 '<feComponentTransfer><feFuncR type="linear" slope="0.7"/><feFuncG type="linear" slope="0.7"/><feFuncB type="linear" slope="0.7"/></feComponentTransfer>' +
474 '</filter>' +
475 '</svg>').appendTo('#ui_box');
476 }
477
478 /*******************************************************************************************************************************
479 * Language versions: german, english, french, russian, polish, spanish
480 *******************************************************************************************************************************/
481 var LANG = {
482 de: {
483 settings: {
484 dsc: "DIO-Tools bietet unter anderem einige Anzeigen, eine Smileyauswahlbox,<br>Handelsoptionen und einige Veränderungen des Layouts.",
485 act: "Funktionen der Toolsammlung aktivieren/deaktivieren:",
486 prv: "Vorschau einzelner Funktionen:",
487
488 version_old: "DIO-Tools-Version ist nicht aktuell",
489 version_new: "DIO-Tools-Version ist aktuell",
490 version_dev: "DIO-Tools-Entwicklerversion",
491
492 version_update: "Aktualisieren",
493
494 link_forum: "http://forum.de.grepolis.com/showthread.php?28838&goto=newpost", //"http://forum.de.grepolis.com/showthread.php?28838"
495 link_contact: "http://forum.de.grepolis.com/private.php?do=newpm&u=10548",
496
497 forum: "Forum",
498 author: "Autor",
499
500 cat_units: "Einheiten",
501 cat_icons: "Stadticons",
502 cat_forum: "Forum",
503 cat_trade: "Handel",
504 cat_wonders: "Weltwunder",
505 cat_layout: "Layout",
506 cat_other: "Sonstiges"
507 },
508 options: {
509 //bir: ["Biremenzähler", "Zählt die jeweiligen Biremen einer Stadt und summiert diese.<br><br>Anzeige im Minimap-Bullauge oben links"],
510 ava: ["Einheitenübersicht", "Zeigt die Einheiten aller Städte an"],
511 sml: ["Smileys", "Erweitert die BBCode-Leiste um eine Smileybox"],
512 str: ["Einheitenstärke", "Fügt mehrere Einheitenstärketabellen in verschiedenen Bereichen hinzu"],
513 tra: ["Transportkapazität", "Zeigt die belegte und verfügbare Transportkapazität im Einheitenmenu an"],
514 per: ["Prozentualer Handel", "Erweitert das Handelsfenster um einen Prozentualer Handel"],
515 rec: ["Rekrutierungshandel", "Erweitert das Handelsfenster um einen Rekrutierungshandel"],
516 cnt: ["EO-Zähler", "Zählt die ATT/UT-Anzahl im EO-Fenster"],
517 way: ["Laufzeit", "Zeigt im ATT/UT-Fenster die Laufzeit bei Verbesserter Truppenbewegung an"],
518 sim: ["Simulator", "Anpassung des Simulatorlayouts & permanente Anzeige der Erweiterten Modifikatorbox"],
519 spl: ["Zauberbox", "Komprimierte verschiebbare & magnetische Zauberbox (Positionsspeicherung)"],
520 act: ["Aktivitätsboxen", "Verbesserte Anzeige der Handels- und Truppenaktivitätsboxen (Positionsspeicherung)"],
521 pop: ["Gunst-Popup", 'Ändert das Aussehen des Gunst-Popups'],
522 tsk: ["Taskleiste", 'Vergrößert die Taskleiste und minimiert das "Tägliche Belohnung"-Fenster beim Start'],
523 cha: ["Chat", "Ersetzt den Allianzchat durch einen Welten-Chat"],
524 bbc: ["DEF-Formular", "Erweitert die BBCode-Leiste um ein automatisches DEF-Formular"],
525 com: ["Einheitenvergleich", "Fügt Einheitenvergleichstabellen hinzu"],
526 tic: ["Stadticons", "Jede Stadt erhält ein Icon für den Stadttyp (Automatische Erkennung)", "Zusätzliche Icons stehen bei der manuellen Auswahl zur Verfügung"],
527 til: ["Stadtliste", "Fügt die Stadticons zur Stadtliste hinzu"],
528 tim: ["Karte", "Setzt die Stadticons auf die strategische Karte"],
529 wwc: ["Anteil", "Anteilsrechner & Rohstoffzähler + Vor- & Zurück-Buttons bei fertiggestellten WW's (momentan nicht deaktivierbar!)"],
530 wwr: ["Rangliste", "Überarbeitete Weltwunderrangliste"],
531 wwi: ["Icons", 'Fügt Weltwundericons auf der strategischen Karte hinzu'],
532 con: ["Kontextmenu", 'Vertauscht "Stadt selektieren" und "Stadtübersicht" im Kontextmenu'],
533 sen: ["Abgeschickte Einheiten", 'Zeigt im Angriffs-/Unterstützungsfenster abgeschickte Einheiten an'],
534 tov: ["Stadtübersicht", 'Ersetzt die neue Stadtansicht mit der alten Fensteransicht'],
535 scr: ["Mausrad-Zoom", 'Man kann mit dem Mausrad die 3 Ansichten wechseln'],
536
537 err: ["Automatische Fehlerberichte senden", "Wenn du diese Option aktivierst, kannst du dabei helfen Fehler zu identifizieren."],
538 her: ["Thrakische Eroberung", "Verkleinerung der Karte der Thrakischen Eroberung."]
539 },
540 labels: {
541 uni: "Einheitenübersicht",
542 total: "Gesamt",
543 available: "Verfügbar",
544 outer: "Außerhalb",
545 con: "Selektieren",
546 // Smileys
547 std: "Standard",
548 gre: "Grepolis",
549 nat: "Natur",
550 ppl: "Leute",
551 oth: "Sonstige",
552 // Defense form
553 ttl: "Übersicht: Stadtverteidigung",
554 inf: "Informationen zur Stadt:",
555 dev: "Abweichung",
556 det: "Detailierte Landeinheiten",
557 prm: "Premiumboni",
558 sil: "Silberstand",
559 mov: "Truppenbewegungen:",
560 // WW
561 leg: "WW-Anteil",
562 stg: "Stufe",
563 tot: "Gesamt",
564 // Simulator
565 str: "Einheitenstärke",
566 los: "Verluste",
567 mod: "ohne Modifikatoreinfluss",
568 // Comparison box
569 dsc: "Einheitenvergleich",
570 hck: "Schlag",
571 prc: "Stich",
572 dst: "Distanz",
573 sea: "See",
574 att: "Angriff",
575 def: "Verteidigung",
576 spd: "Geschwindigkeit",
577 bty: "Beute (Rohstoffe)",
578 cap: "Transportkapazität",
579 res: "Baukosten (Rohstoffe)",
580 fav: "Gunst",
581 tim: "Bauzeit (s)",
582 // Trade
583 rat: "Ressourcenverhältnis eines Einheitentyps",
584 shr: "Anteil an der Lagerkapazität der Zielstadt",
585 per: "Prozentualer Handel",
586 // Sent units box
587 lab: "Abgeschickt",
588 improved_movement: "Verbesserte Truppenbewegung"
589 },
590 buttons: {
591 sav: "Speichern", ins: "Einfügen", res: "Zurücksetzen"
592 }
593 },
594
595 en: {
596 settings: {
597 dsc: "DIO-Tools offers, among other things, some displays, a smiley box,<br>trade options and some changes to the layout.",
598 act: "Activate/deactivate features of the toolset:",
599 prv: "Preview of several features:",
600
601 version_old: "Version is not up to date",
602 version_new: "Version is up to date",
603 version_dev: "Developer version",
604
605 version_update: "Update",
606
607 link_forum: "http://forum.en.grepolis.com/showthread.php?52104&goto=newpost",
608 link_contact: "http://forum.en.grepolis.com/private.php?do=newpm&u=46211",
609
610 forum: "Forum",
611 author: "Author",
612
613 cat_units: "Units",
614 cat_icons: "Town icons",
615 cat_forum: "Forum",
616 cat_trade: "Trade",
617 cat_wonders: "World wonder",
618 cat_layout: "Layout",
619 cat_other: "Miscellaneous"
620 },
621 options: {
622 //bir: ["Bireme counter", "Counts the biremes of a city and sums these"],
623 ava: ["Units overview", "Counts the units of all cities"],
624 sml: ["Smilies", "Extends the bbcode bar by a smiley box"],
625 str: ["Unit strength", "Adds unit strength tables in various areas"],
626 tra: ["Transport capacity", "Shows the occupied and available transport capacity in the unit menu"],
627 per: ["Percentual trade", "Extends the trade window by a percentual trade"],
628 rec: ["Recruiting trade", "Extends the trade window by a recruiting trade"],
629 cnt: ["Conquests", "Counts the attacks/supports in the conquest window"],
630 way: ["Troop speed", "Displays improved troop speed in the attack/support window"],
631 sim: ["Simulator", "Adaptation of the simulator layout & permanent display of the extended modifier box"],
632 spl: ["Spell box", "Compressed movable & magnetic spell box (position memory)"],
633 act: ["Activity boxes", "Improved display of trade and troop activity boxes (position memory)"],
634 pop: ["Favor popup", "Changes the favor popup"],
635 tsk: ["Taskbar", "Increases the taskbar and minimizes the daily reward window on startup"],
636 cha: ["Chat", 'Replaced the alliance chat by an world chat. (FlashPlayer required)'],
637 bbc: ["Defense form", "Extends the bbcode bar by an automatic defense form"],
638 com: ["Unit Comparison", "Adds unit comparison tables"],
639 tic: ["Town icons", "Each city receives an icon for the town type (automatic detection)", "Additional icons are available for manual selection"],
640 til: ["Town list", "Adds the town icons to the town list"],
641 tim: ["Map", "Sets the town icons on the strategic map"],
642 wwc: ["Calculator", "Share calculation & resources counter + previous & next buttons on finished world wonders (currently not deactivatable!)"],
643 wwr: ["Ranking", "Redesigned world wonder rankings"],
644 wwi: ["Icons", 'Adds world wonder icons on the strategic map'],
645 con: ["Context menu", 'Swaps "Select town" and "City overview" in the context menu'],
646 sen: ["Sent units", 'Shows sent units in the attack/support window'],
647 tov: ["Town overview", 'Replaces the new town overview with the old window style'],
648 scr: ["Mouse wheel", 'You can change the views with the mouse wheel'],
649
650 err: ["Send bug reports automatically", "If you activate this option, you can help identify bugs."],
651 her: ["Thracian Conquest", "Downsizing of the map of the Thracian conquest."]
652 },
653 labels: {
654 uni: "Units overview",
655 total: "Total",
656 available: "Available",
657 outer: "Outside",
658 con: "Select town",
659 // Smileys
660 std: "Standard",
661 gre: "Grepolis",
662 nat: "Nature",
663 ppl: "People",
664 oth: "Other",
665 hal: "Halloween",
666 xma: "Xmas",
667 // Defense form
668 ttl: "Overview: Town defense",
669 inf: "Town information:",
670 dev: "Deviation",
671 det: "Detailed land units",
672 prm: "Premium bonuses",
673 sil: "Silver volume",
674 mov: "Troop movements:",
675 // WW
676 leg: "WW Share",
677 stg: "Stage",
678 tot: "Total",
679 // Simulator
680 str: "Unit strength",
681 los: "Loss",
682 mod: "without modificator influence",
683 // Comparison box
684 dsc: "Unit comparison",
685 hck: "Blunt",
686 prc: "Sharp",
687 dst: "Distance",
688 sea: "Sea",
689 att: "Offensive",
690 def: "Defensive",
691 spd: "Speed",
692 bty: "Booty (resources)",
693 cap: "Transport capacity",
694 res: "Costs (resources)",
695 fav: "Favor",
696 tim: "Recruiting time (s)",
697 // Trade
698 rat: "Resource ratio of an unit type",
699 shr: "Share of the storage capacity of the target city",
700 per: "Percentage trade",
701 // Sent units box
702 lab: "Sent units",
703 improved_movement: "Improved troop movement"
704 },
705 buttons: {
706 sav: "Save", ins: "Insert", res: "Reset"
707 }
708 },
709 //////////////////////////////////////////////
710 // French Translation by eclat49 //
711 //////////////////////////////////////////////
712 fr: {
713 settings: {
714 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.",
715 act: "Activation/Désactivation des fonctions:",
716 prv: "Aperçu des fonctions séparées:"
717 },
718 options: {
719 //bir: ["Compteur de birèmes ", "Totalise l'ensemble des birèmes présentent en villes et les résume. (Remplace la mini carte dans le cadran)"],
720 ava: ["Présentation des unités", "Indique les unités de toutes les villes."],
721 sml: ["Smileys", "Rajoutes une boite de smilies à la boite de bbcode"],
722 str: ["Force unitaire", "Ajoutes des tableaux de force unitaire dans les différentes armes"],
723 //trd: [ "Commerce", "Ajout d'une option par pourcentage, par troupes pour le commerce, ainsi qu'un affichage des limites pour les festivals" ],
724 per: ["Commerce de pourcentage", ""],
725 rec: ["Commerce de recrutement", ""],
726 cnt: ["Compteur conquête", "Comptabilise le nombre d'attaque et de soutien dans la fenêtre de conquête"],
727 way: ["Vitesse des troupes ", "Rajoutes le temps de trajet avec le bonus accélération"],
728 sim: ["Simulateur", "Modification de la présentation du simulateur et affichage permanent des options premium"],
729 spl: ["Boîte de magie", "Boîte de sort cliquable et positionnable"],
730 act: ["Boîte d'activité", "Présentation améliorée du commerce et des mouvement de troupes (mémoire de position)"],
731 pop: ["Popup de faveur", 'Change la popup de faveur'],
732 tsk: ["Barre de tâches ", "La barre de tâches augmente et minimise le fenêtre de bonus journalier"],
733 cha: ["Chat", "Remplace le chat de l'alliance à travers un chat monde."],
734 bbc: ["Formulaire de défense", "Ajout d'un bouton dans la barre BBCode pour un formulaire de défense automatique"],
735 com: ["Comparaison des unités", "Ajoutes des tableaux de comparaison des unités"],
736 tic: ["Icônes des villes", "Chaque ville reçoit une icône pour le type de ville (détection automatique)", "Des icônes supplémentaires sont disponibles pour la sélection manuelle"],
737 til: ["Liste de ville", "Ajoute les icônes de la ville à la liste de la ville"],
738 tim: ["Carte", "Définit les icônes de la ville sur la carte stratégique"],
739 wwc: ["Merveille du monde", "Compteur de ressource et calcul d'envoi + bouton précédent et suivant sur les merveilles finies(ne peut être désactivé pour le moment)"],
740 wwr: ["", ""],
741 //wwi: [ "Icônes",'Adds world wonder icons on the strategic map' ],
742 con: ["Menu contextuel", 'Swaps "Sélectionner ville" et "Aperçu de la ville" dans le menu contextuel'],
743 sen: ["Unités envoyées", 'Affiche unités envoyées dans la fenêtre attaque/support'],
744 tov: ["Aperçu de ville", "Remplace la nouvelle aperçu de la ville avec l'ancien style de fenêtre"],
745 scr: ["Molette de la souris", 'Avec la molette de la souris vous pouvez changer les vues'],
746
747 err: ["Envoyer des rapports de bogues automatiquement", "Si vous activez cette option, vous pouvez aider à identifier les bugs."]
748 },
749 labels: {
750 uni: "Présentation des unités",
751 total: "Global",
752 available: "Disponible",
753 outer: "Extérieur",
754 con: "Sélectionner",
755 // Smileys
756 std: "Standard",
757 gre: "Grepolis",
758 nat: "Nature",
759 ppl: "Gens",
760 oth: "Autres",
761 // Defense form
762 ttl: "Aperçu: Défense de ville",
763 inf: "Renseignements sur la ville:",
764 dev: "Différence",
765 det: "Unités terrestres détaillées",
766 prm: "Bonus premium",
767 sil: "Remplissage de la grotte",
768 mov: "Mouvements de troupes:",
769 // WW
770 leg: "Participation",
771 stg: "Niveau",
772 tot: "Total",
773 // Simulator
774 str: "Force unitaire",
775 los: "Pertes",
776 mod: "sans influence de modificateur",
777 // Comparison box
778 dsc: "Comparaison des unités",
779 hck: "Contond.",
780 prc: "Blanche",
781 dst: "Jet",
782 sea: "Navale",
783 att: "Attaque",
784 def: "Défense",
785 spd: "Vitesse",
786 bty: "Butin",
787 cap: "Capacité de transport",
788 res: "Coût de construction",
789 fav: "Faveur",
790 tim: "Temps de construction (s)",
791 // Trade
792 rat: "Ratio des ressources d'un type d'unité",
793 shr: "Part de la capacité de stockage de la ville cible",
794 per: "Commerce de pourcentage",
795 // Sent units box
796 lab: "Envoyée",
797 improved_movement: "Mouvement des troupes amélioré"
798 },
799 buttons: {
800 sav: "Sauver", ins: "Insertion", res: "Remettre"
801 }
802 },
803 //////////////////////////////////////////////
804 // Russian Translation by MrBobr //
805 //////////////////////////////////////////////
806 ru: {
807 settings: {
808 dsc: "DIO-Tools изменяет некоторые окна, добавляет новые смайлы, отчёты,<br>улучшеные варианты торговли и другие функции.",
809 act: "Включение/выключение функций:",
810 prv: "Примеры внесённых изменений:"
811 },
812 options: {
813 //bir: ["Счётчик бирем", "Показывает число бирем во всех городах"],
814 ava: ["Обзор единиц", "Указывает единицы всех городов"], // ?
815 sml: ["Смайлы", "Добавляет кнопку для вставки смайлов в сообщения"],
816 str: ["Сила отряда", "Добавляет таблицу общей силы отряда в некоторых окнах"],
817 //trd: [ "Торговля", "Добавляет маркеры и отправку недостающих ресурсов, необходимых для фестиваля. Инструменты для долевой торговли" ],
818 per: ["Процент торговля", ""],
819 rec: ["Рекрутинг торговля", ""],
820 cnt: ["Завоевания", "Отображение общего числа атак/подкреплений в окне завоевания города"],
821 way: ["30% ускорение", "Отображает примерное время движения отряда с 30% бонусом"],
822 sim: ["Симулятор", "Изменение интерфейса симулятора, добавление новых функций"],
823 spl: ["Заклинания", "Изменяет положение окна заклинаний"],
824 act: ["Перемещения", "Показывает окна пересылки ресурсов и перемещения войск"],
825 pop: ["Благосклонность", "Отображение окна с уровнем благосклонности богов"],
826 tsk: ["Таскбар", "Увеличение ширины таскбара и сворачивание окна ежедневной награды при входе в игру"],
827 // cha: ["Чат", 'Замена чата игры на irc-чат'],
828 bbc: ["Форма обороны", "Добавляет кнопку для вставки в сообщение отчёта о городе"], // Beschreibung passt nicht ganz
829 com: ["Сравнение юнитов", "Добавляет окно сравнения юнитов"],
830 tic: ["Типы городов", "Каждый город получает значок для городского типа (автоматическое определение)", "Дополнительные иконки доступны для ручного выбора"], // ?
831 til: ["Список город", "Добавляет значки городские в список города"], // ?
832 tim: ["Карта", "Устанавливает городские иконки на стратегической карте"], // ?
833 wwc: ["Чудо света", "Share calculation & resources counter + previous & next buttons on finished world wonders (currently not deactivatable!)"],
834 wwr: ["", ""],
835 //wwi: [ "World wonder icons",'Adds world wonder icons on the strategic map' ],
836 //con: [ "Context menu", 'Swaps "Select town" and "City overview" in the context menu'],
837 //sen: [ "Sent units", 'Shows sent units in the attack/support window'],
838 tov: ["Обзор Город", 'Заменяет новый обзор города с старом стиле окна'], // ?
839 scr: ["Колесо мыши", 'С помощью колеса мыши вы можете изменить взгляды'], // ?
840
841 err: ["Отправить сообщения об ошибках автоматически", "Если вы включите эту опцию, вы можете помочь идентифицировать ошибки"]
842 },
843
844 labels: {
845 uni: "Обзор единиц",
846 total: "Oбщий",
847 available: "доступный",
848 outer: "вне",
849 con: "выбирать",
850 // Smileys
851 std: "",
852 gre: "",
853 nat: "",
854 ppl: "",
855 oth: "",
856 // Defense form
857 ttl: "Обзор: Отчёт о городе",
858 inf: "Информация о войсках и постройках:",
859 dev: "Отклонение",
860 det: "Детальный отчёт",
861 prm: "Премиум-бонусы",
862 sil: "Серебро в пещере",
863 mov: "Перемещения",
864 // WW
865 leg: "",
866 stg: "",
867 tot: "",
868 // Simulator
869 str: "Сила войск",
870 los: "Потери",
871 mod: "без учёта заклинаний, бонусов, исследований",
872 // Comparison box
873 dsc: "Сравнение юнитов",
874 hck: "Ударное",
875 prc: "Колющее",
876 dst: "Дальнего боя",
877 sea: "Морские",
878 att: "Атака",
879 def: "Защита",
880 spd: "Скорость",
881 bty: "Добыча (ресурсы)",
882 cap: "Вместимость транспортов",
883 res: "Стоимость (ресурсы)",
884 fav: "Благосклонность",
885 tim: "Время найма (с)",
886 // Trade
887 rat: "",
888 shr: "",
889 per: "",
890 // Sent units box
891 lab: "Отправлено",
892 improved_movement: "Улучшенная перемещение войск"
893 },
894
895 buttons: {
896 sav: "Сохраниить", ins: "Вставка", res: "Сброс"
897 }
898 },
899 //////////////////////////////////////////////
900 // Polish Translation by anpu //
901 //////////////////////////////////////////////
902 pl: {
903 settings: {
904 dsc: "DIO-Tools oferuje (między innymi) poprawione widoki, nowe uśmieszki,<br>opcje handlu i zmiany w wyglądzie.",
905 act: "Włącz/wyłącz funkcje skryptu:",
906 prv: "podgląd poszczególnych opcji:"
907 },
908 options: {
909 //bir: ["Licznik birem", "Zlicza i sumuje biremy z miast"],
910 ava: ["Przegląd jednostek", "Wskazuje jednostki wszystkich miast"], // ?
911 sml: ["Emotki", "Dodaje dodatkowe (zielone) emotikonki"],
912 str: ["Siła jednostek", "dodaje tabelki z siłą jednostek w różnych miejscach gry"],
913 //trd: [ "Handel", "Rozszerza okno handlu o handel procentowy, proporcje surowców wg jednostek, dodaje znaczniki dla festynów" ],
914 per: ["Handel procentowy", ""],
915 rec: ["Handel rekrutacyjne", ""],
916 cnt: ["Podboje", "Zlicza wsparcia/ataki w oknie podboju (tylko własne podboje)"],
917 way: ["Prędkość wojsk", "Wyświetla dodatkowo czas jednostek dla bonusu przyspieszone ruchy wojsk"],
918 sim: ["Symulator", "Dostosowanie wyglądu symulatora oraz dodanie szybkich pól wyboru"],
919 spl: ["Ramka czarów", "Kompaktowa pływająca ramka z czarami (można umieścić w dowolnym miejscu ekranu. Zapamiętuje położenie.)"],
920 act: ["Ramki aktywności", "Ulepszony podgląd ruchów wojsk i handlu (można umieścić w dowolnym miejscu ekranu. Zapamiętuje położenie.)"],
921 pop: ["Łaski", "Zmienia wygląd ramki informacyjnej o ilości produkowanych łask"],
922 tsk: ["Pasek skrótów", "Powiększa pasek skrótów i minimalizuje okienko z bonusem dziennym"],
923 // cha: ["Czat", 'Zastępuje standardowy Chat chatem IRC'],
924 bbc: ["Raportów obronnych", "Rozszerza pasek skrótów BBcode o generator raportów obronnych"],
925 com: ["Porównianie", "Dodaje tabelki z porównaniem jednostek"],
926 tic: ["Ikony miasta", "Każde miasto otrzyma ikonę typu miasta (automatyczne wykrywanie)", "Dodatkowe ikony są dostępne dla ręcznego wyboru"], // ?
927 til: ["Lista miasto", "Dodaje ikony miasta do listy miasta"], // ?
928 tim: ["Mapa", "Zestawy ikon miasta na mapie strategicznej"], // ?
929 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)"],
930 wwr: ["", ""],
931 //wwi: [ "World wonder icons",'Adds world wonder icons on the strategic map' ],
932 con: ["menu kontekstowe", 'Zamiemia miejcami przycisk "wybierz miasto" z przyciskiem "podgląd miasta" po kliknięciu miasta na mapie'],
933 sen: ["Wysłane jednostki", 'Pokaż wysłane jednostki w oknie wysyłania ataków/wsparć'],
934 tov: ["Podgląd miasta", 'Zastępuje nowy podgląd miasta starym'],
935 scr: ["Zoom", 'Możesz zmienić poziom przybliżenia mapy kółkiem myszy'],
936
937 err: ["Automatycznie wysyłać raporty o błędach", "Jeśli włączysz tę opcję, możesz pomóc zidentyfikować błędy"]
938
939 },
940 labels: {
941 uni: "Przegląd jednostek",
942 total: "Ogólny",
943 available: "Dostępny",
944 outer: "Na zewnątrz",
945 con: "Wybierz miasto",
946 // Smileys
947 std: "Standard" /* "Standardowe" */,
948 gre: "Grepolis",
949 nat: "Przyroda",
950 ppl: "Ludzie",
951 oth: "Inne",
952 // Defense form
953 ttl: "Podgląd: Obrona miasta",
954 inf: "Informacje o mieście:",
955 dev: "Ochyłka",
956 det: "jednostki lądowe",
957 prm: "opcje Premium",
958 sil: "Ilość srebra",
959 mov: "Ruchy wojsk",
960 // WW
961 leg: "Udział w Cudzie",
962 stg: "Poziom",
963 tot: "Łącznie",
964 // Simulator
965 str: "Siła jednostek",
966 los: "Straty",
967 mod: "bez modyfikatorów",
968 // Comparison box
969 dsc: "Porównianie jednostek",
970 hck: "Obuchowa",
971 prc: "Tnąca",
972 dst: "Dystansowa",
973 sea: "Morskie",
974 att: "Offensywne",
975 def: "Defensywne",
976 spd: "Prędkość",
977 bty: "Łup (surowce)",
978 cap: "Pojemność transportu",
979 res: "Koszta (surowce)",
980 fav: "Łaski",
981 tim: "Czas rekrutacji (s)",
982 // Trade
983 rat: "Stosunek surowców dla wybranej jednostki",
984 shr: "procent zapełnienia magazynu w docelowym mieście",
985 per: "Handel procentowy",
986 // Sent units box
987 lab: "Wysłane jednostki",
988 improved_movement: "Przyspieszone ruchy wojsk"
989 },
990 buttons: {
991 sav: "Zapisz", ins: "Wstaw", res: "Anuluj"
992 }
993 },
994 //////////////////////////////////////////////
995 // Spanish Translation by Juana de Castilla //
996 //////////////////////////////////////////////
997 es: {
998 settings: {
999 dsc: "DIO-Tools ofrece, entre otras cosas, varias pantallas, ventana de <br>emoticones, opciones de comercio y algunos cambios en el diseño.",
1000 act: "Activar/desactivar características de las herramientas:",
1001 prv: "Vista previa de varias características:"
1002 },
1003 options: {
1004 //bir: ["Contador de birremes", "Cuenta los birremes de una ciudad y los suma"],
1005 ava: ["Información general unidades", "Indica las unidades de todas las ciudades"], // ?
1006 sml: ["Emoticones", "Código BB para emoticones"],
1007 str: ["Fortaleza de la Unidad", "Añade tabla de fortalezas de cada unidad en varias zonas"],
1008 //trd: [ "Comercio", "Añade en la pestaña de comercio un porcentaje de comercio y reclutamiento y limitadores de Mercado por cada ciudad" ],
1009 per: ["Comercio de porcentual", ""],
1010 rec: ["Comercio de reclutamiento", ""],
1011 cnt: ["Conquistas", "contador de ataques y refuerzos en la pestaña de conquista"],
1012 way: ["Velocidad de tropas", "Muestra movimiento de tropas mejorado en la ventana de ataque/refuerzo"],
1013 sim: ["Simulador", "Adaptación de la ventana del simulador incluyendo recuadro de modificadores"],
1014 spl: ["Ventana de hechizos", "Ventana deslizante y comprimida de los hechizos (memoria posicional)"],
1015 act: ["Ventana de actividad", "Mejora las ventanas de comercio y movimiento de tropas (memoria posicional)"],
1016 pop: ["Popup", "Cambia el popup de favores"],
1017 tsk: ["Barra de tareas", "aumenta la barra de tareas y minimice la recompensa al aparecer"],
1018 // cha: ["Chat", 'Sustituye el chat de la alianza con un irc chat.'],
1019 bbc: ["Formulario de defensa", "Añade en la barra de códigos bb un formulario de defensa"],
1020 com: ["Comparación", "añade ventana de comparación de unidades"],
1021 tic: ["Iconos de la ciudad", "Cada ciudad recibe un icono para el tipo de la ciudad (detección automática)", "Iconos adicionales están disponibles para la selección manual"],
1022 til: ["Lista de la ciudad", "Agrega los iconos de la ciudad a la lista de la ciudad"],
1023 tim: ["Map", "Establece los iconos de la ciudad en el mapa estratégico"],
1024 wwc: ["Maravillas", "Calcula participación & contador de recursos + antes y después teclas de maravillas terminadas (no desactibable ahora!)"],
1025 wwr: ["", ""],
1026 //wwi: [ "World wonder icons",'Adds world wonder icons on the strategic map' ],
1027 con: ["menú contextual", 'Cambia "Elegir ciudad" y "vista de la ciudad" en el menú contextual '],
1028 sen: ["Unidades enviadas", 'Muestra las unidades enviadas en la ventana de ataque/refuerzos'],
1029 tov: ["Información de la ciudad", 'sustituye la vista nueva de ciudad por la ventana antigua'],
1030 scr: ["Rueda raton", 'Puede cambiar las vistas con la rueda del raton'],
1031
1032 err: ["Enviar informes de errores automáticamente", "Si se activa esta opción, puede ayudar a identificar errores."]
1033 },
1034 labels: {
1035 uni: "Información general unidades",
1036 total: "Total",
1037 available: "Disponible",
1038 outer: "Fuera",
1039 con: "Escoger ciudad",
1040 // Smileys
1041 std: "Standard",
1042 gre: "Grepolis",
1043 nat: "Natura",
1044 ppl: "Gente",
1045 oth: "Otros",
1046 // Defense form
1047 ttl: "Vista general: Defensa de la ciudad",
1048 inf: "Información de la ciudad:",
1049 dev: "Desviación",
1050 det: "Unidades de tierra detalladas",
1051 prm: "Bonos Premium",
1052 sil: "Volumen de plata",
1053 mov: "Movimientos de tropas:",
1054 // WW
1055 leg: "WW cuota",
1056 stg: "Nivel",
1057 tot: "Total",
1058 // Simulator
1059 str: "Fortaleza de la Unidad",
1060 los: "Perdida",
1061 mod: "sin influencia del modificador",
1062 // Comparison box
1063 dsc: "Comparación de Unidades",
1064 hck: "Contundente",
1065 prc: "Punzante",
1066 dst: "Distancia",
1067 sea: "Mar",
1068 att: "Ataque",
1069 def: "Defensa",
1070 spd: "Velocidad",
1071 bty: "Botín (recursos)",
1072 cap: "Capacidad de transporte",
1073 res: "Costes (recursos)",
1074 fav: "Favor",
1075 tim: "Tiempo de reclutamiento (s)",
1076 // Trade
1077 rat: "Proporción de recursos de un tipo de unidad",
1078 shr: "Porcentaje de la capacidad de almacenamiento de la ciudad destino",
1079 per: "Porcentaje de comercio",
1080 // Sent units box
1081 lab: "Unidades enviadas",
1082 improved_movement: "Movimiento de tropas mejorados"
1083 },
1084 buttons: {
1085 sav: "Guardar", ins: "Insertar", res: "Reinicio"
1086 }
1087 },
1088 ar: {},
1089 //////////////////////////////////////////////
1090 // Portuguese (BR) Translation by HELL //
1091 //////////////////////////////////////////////
1092 br: {
1093 settings: {
1094 dsc: "DIO-Tools oferece, entre outras coisas, algumas telas, uma caixa de smiley, opções de comércio <br> e algumas alterações no layout.",
1095 act: "Ativar/desativar recursos do conjunto de ferramentas:",
1096 prv: "Pré-visualização de vários recursos:",
1097
1098 version_old: "Versão não está atualizada",
1099 version_new: "Versão está atualizada",
1100 version_dev: "Versão do desenvolvedor",
1101
1102 version_update: "Atualização",
1103
1104 link_forum: "http://forum.en.grepolis.com/showthread.php?52104&goto=newpost",
1105 link_contact: "http://forum.en.grepolis.com/private.php?do=newpm&u=46211",
1106
1107 forum: "Forum",
1108 author: "Autor",
1109
1110 cat_units: "Unidades",
1111 cat_icons: "Ícones nas Cidades",
1112 cat_forum: "Forum",
1113 cat_trade: "Comércio",
1114 cat_wonders: "Maravilhas do Mundo",
1115 cat_layout: "Layout",
1116 cat_other: "Outros"
1117 },
1118 options: {
1119 // bir: ["Contador de Birremes", "Conta as biremes da cidade na cidade"],
1120 ava: ["Visão Geral da unidade", "Indica as unidades de todas as cidades"], // ?
1121 sml: ["Smilies", "Estende o bbcode com uma caixa de smiley"],
1122 str: ["Força das Tropas", "Adiciona quadros de força das tropas em diversas áreas"],
1123 tra: ["Capacidade de Transporte", "Mostra a capacidade de transporte ocupado e disponível no menu de unidades"],
1124 per: ["Percentual de comércio", "Estende-se a janela de comércio com um percentual de comércio"],
1125 rec: ["Comércio para recrutamento", "Estende-se a janela de comércio com um comércio de recrutamento"],
1126 cnt: ["Conquistas", "Conta os ataques/apoios na janela de conquista"],
1127 way: ["Velocidade da Tropa", "Displays mostram a possivél velocidade de tropa na janela de ataque/suporte"],
1128 sim: ["Simulador", "Adaptação do layout simulador & exposição permanente da caixa poderes estendida"],
1129 spl: ["Caixa de Poderes Divinos", "Pequena caixa móvel & magnética de poderes divinos (com memória de posição) "],
1130 act: ["Ativar caixas suspensas de comércio e ataque", "Melhorias da exibição de caixas de comércio e atividade tropa (com memória de posição)"],
1131 pop: ["Caixa de favores divino", "Altera a caixa de favores divino por um novo layout"],
1132 tsk: ["Barra de tarefas", "Aumenta a barra de tarefas e minimiza a janela recompensa diária no inicio"],
1133 // cha: ["Chat", 'Substituiu o da bate-papo por um bate-papo IRC.'],
1134 bbc: ["Pedido de Apoio", "Estende a barra de bbcode com uma forma de Pedido de Apoio Automática"],
1135 com: ["Comparação de Unidades", "Adiciona tabelas de comparação de unidade"],
1136 tic: ["Ícones nas Cidades", "Cada cidade recebe um ícone para o tipo de tropas na cidade (detecção automática) "," Ícones adicionais estão disponíveis para seleção manual"],
1137 til: ["Lista das Cidades", "Adiciona os ícones da cidade na lista de cidades"],
1138 tim: ["Mapa", "Mostra os ícones das cidades no mapa estratégico"],
1139 wwc: ["Calculadora de WW", "Cálculo compartilhado & contador de recursos + botões anterior e próxima maravilhas do mundo (atualmente não desactivável!)"],
1140 wwr: ["Classificação", "Classificação das maravilha do mundo redesenhadas"],
1141 wwi: ["Icones", 'Adiciona ícones nas maravilha do mundo no mapa estratégico'],
1142 con: ["Menu de Contexto", 'Troca da "Selecione cidade" e "Visão Geral da Cidade" no menu de contexto'],
1143 sen: ["Unidades Enviadas", 'Shows sent units in the attack/support window'],
1144 tov: ["Visão da Cidade", 'Substitui o novo panorama da cidade, com o estilo da janela antiga'],
1145 scr: ["Roda do Mouse", 'Você pode alterar os pontos de vista com a roda do mouse'],
1146
1147 err: ["Enviar automaticamente relatórios de erros", "Se você ativar essa opção, você pode ajudar a identificar erros."],
1148 her: ["Conquista Thracian", "Redução de tamanho do mapa da conquista Thracian."]
1149 },
1150 labels: {
1151 uni: "Visão Geral da unidade",
1152 total: "Global",
1153 available: "Disponível",
1154 outer: "Fora",
1155 con: "Selecionar cidade",
1156 // Smileys
1157 std: "Padrão",
1158 gre: "Grepolis",
1159 nat: "Natural",
1160 ppl: "Popular",
1161 oth: "Outros",
1162 hal: "Halloween",
1163 xma: "Natal",
1164 // Defense form
1165 ttl: "Pedido de Apoio",
1166 inf: "Informação da cidade:",
1167 dev: "Desvio",
1168 det: "Unidades Detalhadas",
1169 prm: "Bônus Premium",
1170 sil: "Prata na Gruta",
1171 mov: "Movimentação de Tropas:",
1172 // WW
1173 leg: "WW Maravilhas",
1174 stg: "Level",
1175 tot: "Total",
1176 // Simulator
1177 str: "Força das Unidades",
1178 los: "Perdas",
1179 mod: "Sem modificador de influência",
1180 // Comparison box
1181 dsc: "Comparação de unidades",
1182 hck: "Impacto",
1183 prc: "Corte",
1184 dst: "Arremço",
1185 sea: "Naval",
1186 att: "Ofensivo",
1187 def: "Defensivo",
1188 spd: "Velocidade",
1189 bty: "Saque (recursos)",
1190 cap: "Capacidade de trasporte",
1191 res: "Custo (recursos)",
1192 fav: "Favor",
1193 tim: "Tempo de recrutamento (s)",
1194 // Trade
1195 rat: "Proporção de recursos de um tipo de unidade",
1196 shr: "A partir do armazenamento sobre a cidade de destino",
1197 per: "Percentual de comércio",
1198 // Sent units box
1199 lab: "Unidades enviadas",
1200 improved_movement: "Movimentação de tropas com ajuste de bônus"
1201 },
1202 buttons: {
1203 sav: "Salvar", ins: "Inserir", res: "Resetar"
1204 }
1205 },
1206 pt : {},
1207 //////////////////////////////////////////////
1208 // Czech Translation by Piwus //
1209 //////////////////////////////////////////////
1210 cz: {
1211 settings: {
1212 dsc: "DIO-Tools nabízí,mimo jiné,některá nová zobrazení,okénko smajlíků,<br>obchodní možnosti a některé změny v rozložení panelů.",
1213 act: "Aktivovat/Deaktivovat funkce sady nástrojů:",
1214 prv: "Ukázka několika funkcí:",
1215
1216 version_old: "Verze je zastaralá",
1217 version_new: "Verze je aktuální",
1218 version_dev: "Vývojářská verze",
1219
1220 version_update: "Aktualizovat",
1221
1222 link_forum: "http://forum.en.grepolis.com/showthread.php?52104&goto=newpost",
1223 link_contact: "http://forum.en.grepolis.com/private.php?do=newpm&u=46211",
1224
1225 forum: "Forum",
1226 author: "Autor",
1227
1228 cat_units: "Jednotky",
1229 cat_icons: "Ikony měst",
1230 cat_forum: "Forum",
1231 cat_trade: "Obchod",
1232 cat_wonders: "Div světa",
1233 cat_layout: "Okna",
1234 cat_other: "Ostatní"
1235 },
1236 options: {
1237 // bir: ["Počítadlo birém", "Spočítá každé birémy ve městech a sečte je."],
1238 ava: ["Jednotky Přehled", "Označuje jednotky všemi městy"], // ?
1239 sml: ["Smajlíci", "Rozšiřuje panel BBkodů okénkem smajlíků"],
1240 str: ["Síla jednotek", "Přidává tabulku sil jednotek v různých oblastech"],
1241 tra: ["Transportní kapacita", "Zobrazuje obsazenou a dostupnou transportní kapacitu v nabídce jednotek"],
1242 per: ["Procentuální obchod", "Rozšiřuje obchodní okno možností procentuálního obchodu"],
1243 rec: ["Obchod rekrutace", "Rozšiřuje obchodní okno možností obchodem pro rekrutaci"],
1244 cnt: ["Dobývání", "Počítá Útok/Obrana v okně dobývání (pouze vlastní dobývání zatím)"],
1245 way: ["Rychlost vojsk", "Zobrazuje vylepšenou rychlost vojsk v okně útoku/obrany"],
1246 sim: ["Simulátor", "Přizpůsobení rozložení simulátoru & permanentní zobrazování rozšířeného okna modifikátoru"],
1247 spl: ["Okénko kouzel", "Stlačené klouzání oken & magnetické okénko kouzel (pozice paměti)"],
1248 act: ["Aktivní okénka", "Zlepšený zobrazení obchodů a vojsk aktivními okénky (pozice paměti)"],
1249 pop: ["Vyskakovací okénko přízně", "Změní vyskakovací okno seznamu přízní"],
1250 tsk: ["Hlavní panel", "Zvyšuje hlavní panel a minimalizuje bonus denní odměny po přihlášení"],
1251 // cha: ["Chat", 'Nahrazen alianční chat chatem IRC.'],
1252 bbc: ["Obranné hlášení", "Rozšiřuje panel BBkodů automatickém hlášení obrany města"],
1253 com: ["Porovnání jednotek", "Přidává tabulku porovnání jednotek"],
1254 tic: ["Ikony měst", "Každé město dostává svojí ikonku dle typu města (automatická detekce)", "Další ikonky jsou k dispozici manuálně"],
1255 til: ["Seznam měst", "Přidává ikony měst do seznamu měst"],
1256 tim: ["Mapa", "Přidává ikony měst na stategickou mapu"],
1257 wwc: ["Kalkulačka", "Výpočet podílu & počítadlo surovin + předchozí & další tlačítka na dokončených divech světa (aktuálně nelze deaktivovat!)"],
1258 wwr: ["Žebříček", "Předělaný žebříček divů světa"],
1259 wwi: ["Ikony", 'Přídává ikony divů světa na strategickou mapu'],
1260 con: ["Kontextové menu", 'Vyměňuje "Vybrat město" a "Přehled města" v kontextovém menu'],
1261 sen: ["Odeslané jednotky", 'Zobrazuje odeslané jednotky útoku/obrany v okně'],
1262 tov: ["Přehled města", 'Nahrazuje nový přehled měst starším stylem okna'],
1263 scr: ["Kolečko myši", 'Můžeš změnit pohledy s kolečkem myši'],
1264
1265 err: ["Hlásit chyby automaticky", "Pokud aktivuješ tuto možnost,pomůžeš nám identifikovat chyby."],
1266 her: ["Thrácké dobývání", "Redukuje mapy Thráckého dobývání."]
1267 },
1268 labels: {
1269 uni: "Jednotky Přehled",
1270 total: "Celkový",
1271 available: "K dispozici",
1272 outer: "Vně",
1273 con: "Zvolit město",
1274 // Smileys
1275 std: "Standartní",
1276 gre: "Grepolis",
1277 nat: "Příroda",
1278 ppl: "Lidi",
1279 oth: "Ostatní",
1280 hal: "Halloween",
1281 xma: "Vánoce",
1282 // Defense form
1283 ttl: "Přehled: Obrana města",
1284 inf: "Informace o městě:",
1285 dev: "Odchylka",
1286 det: "Podrobné pozemní jednotky",
1287 prm: "Prémiové bonusy",
1288 sil: "Objem stříbra",
1289 mov: "Pohyby vojsk:",
1290 // WW
1291 leg: "Podíl divu světa",
1292 stg: "Stupeň",
1293 tot: "Celkem",
1294 // Simulator
1295 str: "Síla jednotek",
1296 los: "Ztráta",
1297 mod: "bez vlivu modifikátoru",
1298 // Comparison box
1299 dsc: "Porovnání jednotek",
1300 hck: "Sečné",
1301 prc: "Bodné",
1302 dst: "Střelné",
1303 sea: "Moře",
1304 att: "Útočné",
1305 def: "Obranné",
1306 spd: "Rychlost",
1307 bty: "Kořist (suroviny)",
1308 cap: "Transportní kapacita",
1309 res: "Náklady (suroviny)",
1310 fav: "Přízeň",
1311 tim: "Doba rekrutování (s)",
1312 // Trade
1313 rat: "Poměr surovin typu jednotky",
1314 shr: "Podíl na úložné kapacitě cílového města",
1315 per: "Procentuální obchod",
1316 // Sent units box
1317 lab: "Odeslané jednotky",
1318 improved_movement: "Vylepšený pohyb jednotek"
1319 },
1320 buttons: {
1321 sav: "Uložit", ins: "Vložit", res: "Resetovat"
1322 }
1323 }
1324 };
1325
1326 LANG.ar = LANG.es;
1327 LANG.pt = LANG.br;
1328 LANG.cs = LANG.cz;
1329
1330 // Create JSON
1331 // console.log(JSON.stringify(LANG.en));
1332
1333 // Forum: Choose language
1334 if (!(uw.location.pathname.indexOf("game") >= 0)) {
1335 LID = uw.location.host.split(".")[1];
1336 }
1337
1338 console.debug("SPRACHE", LID);
1339 // Translation GET
1340 function getText(category, name) {
1341 var txt = "???";
1342 if (LANG[LID]) {
1343 if (LANG[LID][category]) {
1344 if (LANG[LID][category][name]) {
1345 txt = LANG[LID][category][name];
1346 } else {
1347 if (LANG.en[category]) {
1348 if (LANG.en[category][name]) {
1349 txt = LANG.en[category][name];
1350 }
1351 }
1352 }
1353 } else {
1354 if (LANG.en[category]) {
1355 if (LANG.en[category][name]) {
1356 txt = LANG.en[category][name];
1357 }
1358 }
1359 }
1360 } else {
1361 if (LANG.en[category]) {
1362 if (LANG.en[category][name]) {
1363 txt = LANG.en[category][name];
1364 }
1365 }
1366 }
1367 return txt;
1368 }
1369
1370 /*******************************************************************************************************************************
1371 * Settings
1372 *******************************************************************************************************************************/
1373
1374 // (De)activation of the features
1375 var options_def = {
1376 bir: true, // Biremes counter
1377 ava: true, // Available units
1378 sml: true, // Smileys
1379 str: true, // Unit strength
1380 tra: true, // Transport capacity
1381 per: true, // Percentual Trade
1382 rec: true, // Recruiting Trade
1383 way: true, // Troop speed
1384 cnt: true, // Attack/support counter
1385 sim: true, // Simulator
1386 spl: true, // Spell box
1387 act: false,// Activity boxes
1388 tsk: true, // Task bar
1389 cha: true, // Chat
1390 pop: true, // Favor popup
1391 bbc: true, // BBCode bar
1392 com: true, // Unit comparison
1393 tic: true, // Town icons
1394 til: true, // Town icons: Town list
1395 tim: true, // Town icons: Map
1396 wwc: true, // World wonder counter
1397 wwr: true, // World wonder ranking
1398 wwi: true, // World wonder icons
1399 con: true, // Context menu
1400 sen: true, // Sent units
1401 tov: false,// Town overview
1402 scr: true, // Mausrad,
1403
1404 err: false,// Error Reports
1405 her: true // Thrakische Eroberung
1406 };
1407
1408 if (uw.location.pathname.indexOf("game") >= 0) {
1409 for (var opt in options_def) {
1410 if (options_def.hasOwnProperty(opt)) {
1411 if (DATA.options[opt] === undefined) {
1412 DATA.options[opt] = options_def[opt];
1413 }
1414 }
1415 }
1416 }
1417
1418 var version_text = '', version_color = 'black';
1419
1420 function getLatestVersion() {
1421 $('<style id="dio_version">' +
1422 '#version_info .version_icon { background: url(http://666kb.com/i/ct1etaz0uyohw402i.png) -50px -50px no-repeat; width:25px; height:25px; float:left; } ' +
1423 '#version_info .version_icon.red { filter:hue-rotate(-100deg); -webkit-filter: hue-rotate(-100deg); } ' +
1424 '#version_info .version_icon.green { filter:hue-rotate(0deg); -webkit-filter: hue-rotate(0deg); } ' +
1425 '#version_info .version_icon.blue { filter:hue-rotate(120deg); -webkit-filter: hue-rotate(120deg); } ' +
1426 '#version_info .version_text { line-height: 2; margin: 0px 6px 0px 6px; float: left;} ' +
1427 '</style>').appendTo("head");
1428
1429 var v_info = $('#version_info');
1430 if (version_text === '') {
1431 $.ajax({
1432 type: "GET", url: "https://diotools.de/scripts/version.php",
1433 success: function (response) {
1434 var latest_version = parseFloat(response),
1435 current_version = parseFloat(version);
1436
1437 if (current_version < latest_version) {
1438 version_text = "<div class='version_icon red'></div><div class='version_text'>" + getText('settings', 'version_old') + "</div><div class='version_icon red'></div>" +
1439 '<a class="version_text" href="https://diotools.de/downloads/DIO-TOOLS.user.js" target="_blank">--> Update</a>';
1440 version_color = 'crimson';
1441 } else if (current_version == latest_version) {
1442 version_text = "<div class='version_icon green'></div><div class='version_text'>" + getText('settings', 'version_new') + "</div><div class='version_icon green'></div>";
1443 version_color = 'darkgreen';
1444 } else {
1445 version_text = "<div class='version_icon blue'></div><div class='version_text'>" + getText('settings', 'version_dev') + "</div><div class='version_icon blue'></div>";
1446 version_color = 'darkblue';
1447 }
1448 v_info.html(version_text).css({color: version_color});
1449 }
1450 });
1451 } else {
1452 v_info.html(version_text).css({color: version_color});
1453 }
1454 }
1455
1456 // Add DIO-Tools to grepo settings
1457 function settings() {
1458 var wid = $(".settings-menu").get(0).parentNode.id;
1459
1460 if (!$("#dio_tools").get(0)) {
1461 $(".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>');
1462 }
1463
1464 $(".settings-link").click(function () {
1465 $('.section').each(function () {
1466 this.style.display = "block";
1467 });
1468 $('.settings-container').removeClass("dio_overflow");
1469
1470 $('#dio_bg_medusa').css({display: "none"});
1471
1472 if ($('#dio_settings').get(0)) {
1473 $('#dio_settings').get(0).style.display = "none";
1474 }
1475 });
1476
1477 $("#dio_tools").click(function () {
1478 if ($('.email').get(0)) {
1479 $('.settings-container').removeClass("email");
1480 }
1481
1482 $('.settings-container').addClass("dio_overflow");
1483
1484 $('#dio_bg_medusa').css({display: "block"});
1485
1486 if (!$('#dio_settings').get(0)) {
1487 // Styles
1488 $('<style id="dio_settings_style">' +
1489 // Chrome Scroollbar Style
1490 '#dio_settings ::-webkit-scrollbar { width: 13px; } ' +
1491 '#dio_settings ::-webkit-scrollbar-track { background-color: rgba(130, 186, 135, 0.5); border-top-right-radius: 4px; border-bottom-right-radius: 4px; } ' +
1492 '#dio_settings ::-webkit-scrollbar-thumb { background-color: rgba(87, 121, 45, 0.5); border-radius: 3px; } ' +
1493 '#dio_settings ::-webkit-scrollbar-thumb:hover { background-color: rgba(87, 121, 45, 0.8); } ' +
1494
1495 '#dio_settings table tr :first-child { text-align:center; vertical-align:top; } ' +
1496
1497 '#dio_settings #version_info { font-weight:bold;height: 35px;margin-top:-5px; } ' +
1498 '#dio_settings #version_info img { margin:-1px 2px -8px 0px; } ' +
1499
1500 '#dio_settings .icon_types_table { font-size:0.7em; line-height:2.5; border:1px solid green; border-spacing:10px 2px; border-radius:5px; } ' +
1501 '#dio_settings .icon_types_table td { text-align:left; } ' +
1502
1503 '#dio_settings table p { margin:0.2em 0em; } ' +
1504
1505 '#dio_settings .checkbox_new .cbx_caption { white-space:nowrap; margin-right:10px; font-weight:bold; } ' +
1506
1507 '#dio_settings .dio_settings_tabs {width:auto; border:2px solid darkgreen; background:#2B241A; padding:1px 1px 0px 1px; right:auto; border-top-left-radius:5px; border-top-right-radius:5px; border-bottom:0px;} ' +
1508
1509 '#dio_settings .dio_settings_tabs li { float:left; } ' +
1510
1511 '#dio_settings .icon_small { margin:0px; } ' +
1512
1513 '#dio_settings img { max-width:90px; max-height:90px; margin-right:10px; } ' +
1514
1515 '#dio_settings .content { border:2px solid darkgreen; border-radius:5px; border-top-left-radius:0px; background:rgba(31, 25, 12, 0.1); top:23px; position:relative; padding:10px; height:350px; overflow-y:auto; } ' +
1516 '#dio_settings .content .content_category { display:none; border-spacing:5px; } ' +
1517
1518 '#dio_settings .dio_options_table legend { font-weight:bold; } ' +
1519 '#dio_settings .dio_options_table p { margin:0px; } ' +
1520 '#dio_settings #donate_btn { filter: hue-rotate(45deg); -webkit-filter: hue-rotate(45deg); } ' +
1521
1522 '#donate_btn { background: url(' + dio_sprite + '); width:100px; height:26px; background-position: 0px -300px; } ' +
1523 '#donate_btn.de { background-position: 0px -250px; } ' +
1524 '#donate_btn.en { background-position: 0px -300px; } ' +
1525
1526 '#dio_hall table { border-spacing: 9px 3px; } ' +
1527 '#dio_hall table th { text-align:left !important;color:green;text-decoration:underline;padding-bottom:10px; } ' +
1528 '#dio_hall table td.value { text-align: right; } ' +
1529
1530 '#dio_hall table td.laurel.green { background: url("/images/game/ally/founder.png") no-repeat; height:18px; width:18px; background-size:100%; } ' +
1531 '#dio_hall table td.laurel.bronze { background: url("https://diotools.de/images/game/laurel_sprite.png") no-repeat 25%; height:18px; width:18px; } ' +
1532 '#dio_hall table td.laurel.silver { background: url("https://diotools.de/images/game/laurel_sprite.png") no-repeat 50%; height:18px; width:18px; } ' +
1533 '#dio_hall table td.laurel.gold { background: url("https://diotools.de/images/game/laurel_sprite.png") no-repeat 75%; height:18px; width:18px; } ' +
1534 '#dio_hall table td.laurel.blue { background: url("https://diotools.de/images/game/laurel_sprite.png") no-repeat 100%; height:18px; width:18px; } ' +
1535 '</style>').appendTo('head');
1536
1537
1538 $('.settings-container').append(
1539 '<div id="dio_settings" class="player_settings section"><div id="dio_bg_medusa"></div>' +
1540 '<div class="game_header bold"><a href="#" target="_blank" style="color:white">DIO-Tools (v' + version + ')</a></div>' +
1541
1542 // Check latest version
1543 '<div id="version_info"><img src="http://666kb.com/i/csmicltyu4zhiwo5b.gif" /></div>' +
1544
1545 // Donate button
1546 '<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">' +
1547 '<div id="donate_btn" class="' + LID + '" alt="Donate"></div></a></div>' +
1548
1549 // Settings navigation
1550 '<ul class="menu_inner dio_settings_tabs">' +
1551 '<li><a class="submenu_link active" href="#" id="dio_units"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_units") + '</span></span></span></a></li>' +
1552 '<li><a class="submenu_link" href="#" id="dio_icons"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_icons") + '</span></span></span></a></li>' +
1553 '<li><a class="submenu_link" href="#" id="dio_forum"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_forum") + '</span></span></span></a></li>' +
1554 '<li><a class="submenu_link" href="#" id="dio_trade"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_trade") + '</span></span></span></a></li>' +
1555 '<li><a class="submenu_link" href="#" id="dio_wonder"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_wonders") + '</span></span></span></a></li>' +
1556 '<li><a class="submenu_link" href="#" id="dio_layout"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_layout") + '</span></span></span></a></li>' +
1557 '<li><a class="submenu_link" href="#" id="dio_other"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_other") + '</span></span></span></a></li>' +
1558 '</ul>' +
1559
1560 // Settings content
1561 '<DIV class="content">' +
1562
1563 // Units tab
1564 '<table id="dio_units_table" class="content_category visible"><tr>' +
1565 '<td><img src="https://diotools.de/images/game/settings/units/available_units.png" alt="" /></td>' +
1566 '<td><div id="ava" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "ava")[0] + '</div></div>' +
1567 '<p>' + getText("options", "ava")[1] + '</p></td>' +
1568 '</tr><tr>' +
1569 '<td><img src="https://diotools.de/images/game/settings/units/sent_units.png" alt="" /></td>' +
1570 '<td><div id="sen" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "sen")[0] + '</div></div>' +
1571 '<p>' + getText("options", "sen")[1] + '</p></td>' +
1572 '</tr><tr>' +
1573 '<td><img src="https://diotools.de/images/game/settings/units/unit_strength.png" alt="" /></td>' +
1574 '<td><div id="str" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "str")[0] + '</div></div>' +
1575 '<p>' + getText("options", "str")[1] + '</p></td>' +
1576 '</tr><tr>' +
1577 '<td><img src="https://diotools.de/images/game/settings/units/transport_capacity.png" alt="" /></td>' +
1578 '<td><div id="tra" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "tra")[0] + '</div></div>' +
1579 '<p>' + getText("options", "tra")[1] + '</p></td>' +
1580 '</tr><tr>' +
1581 '<td><img src="https://diotools.de/images/game/settings/units/unit_comparison.png" alt="" /></td>' +
1582 '<td><div id="com" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "com")[0] + '</div></div>' +
1583 '<p>' + getText("options", "com")[1] + '</p></td>' +
1584 '</tr></table>' +
1585
1586 // Icons tab
1587 '<table id="dio_icons_table" class="content_category"><tr>' +
1588 '<td><img src="https://diotools.de/images/game/settings/townicons/townicons.png" alt="" /></td>' +
1589 '<td><div id="tic" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "tic")[0] + '</div></div>' +
1590 '<p>' + getText("options", "tic")[1] + '</p>' +
1591 '<table class="icon_types_table">' +
1592 '<tr><td style="width:115px"><div class="icon_small townicon_lo"></div> Land Offensive</td>' + '<td><div class="icon_small townicon_fo"></div> Fly Offensive</td></tr>' +
1593 '<tr><td><div class="icon_small townicon_ld"></div> Land Defensive</td>' + '<td><div class="icon_small townicon_fd"></div> Fly Defensive</td></tr>' +
1594 '<tr><td><div class="icon_small townicon_so"></div> Navy Offensive</td>' + '<td><div class="icon_small townicon_no"></div> Outside</td></tr>' +
1595 '<tr><td><div class="icon_small townicon_sd"></div> Navy Defensive</td>' + '<td><div class="icon_small townicon_po"></div> Empty</td></tr>' +
1596 '</table><br>' +
1597 '<p>' + getText("options", "tic")[2] + ':</p>' +
1598 '<div class="icon_small townicon_sh"></div><div class="icon_small townicon_di"></div><div class="icon_small townicon_un"></div><div class="icon_small townicon_ko"></div>' +
1599 '<div class="icon_small townicon_ti"></div><div class="icon_small townicon_gr"></div><div class="icon_small townicon_dp"></div><div class="icon_small townicon_re"></div>' +
1600 '<div class="icon_small townicon_wd"></div><div class="icon_small townicon_st"></div><div class="icon_small townicon_si"></div><div class="icon_small townicon_bu"></div>' +
1601 '<div class="icon_small townicon_he"></div><div class="icon_small townicon_ch"></div><div class="icon_small townicon_bo"></div><div class="icon_small townicon_fa"></div>' +
1602 '<div class="icon_small townicon_wo"></div>' +
1603 '</td>' +
1604 '</tr><tr>' +
1605 '<td><img src="https://diotools.de/images/game/settings/townicons/townlist.png" alt="" style="border: 1px solid rgb(158, 133, 78);" /></td>' +
1606 '<td><div id="til" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "til")[0] + '</div></div>' +
1607 '<p>' + getText("options", "til")[1] + '</p></td>' +
1608 '</tr><tr>' +
1609 '<td><img src="https://diotools.de/images/game/settings/townicons/map.png" alt="" /></td>' +
1610 '<td><div id="tim" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "tim")[0] + '</div></div>' +
1611 '<p>' + getText("options", "tim")[1] + '</p></td>' +
1612 '</tr></table>' +
1613
1614 // Forum tab
1615 '<table id="dio_forum_table" class="content_category"><tr>' +
1616 '<td><img src="https://diotools.de/images/game/settings/forum/smiley_box.png" alt="" /></td>' +
1617 '<td><div id="sml" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "sml")[0] + '</div></div>' +
1618 '<p>' + getText("options", "sml")[1] + '</p>' +
1619 '<img src="http://www.greensmilies.com/smile/smiley_emoticons_mttao_wassermann.gif" /> <img src="http://666kb.com/i/cigrqlp2odi2kqo24.gif" /> ' +
1620 '<img src="http://666kb.com/i/cifvfsu3e2sdiipn0.gif" alt="" /> <img src="http://666kb.com/i/cigmv8wnffb3v0ifg.gif" /> ' +
1621 '<img src="http://666kb.com/i/cj2byjendffymp88t.gif" alt="" /> <img src="http://666kb.com/i/cj1l9gndtu3nduyvi.gif" /> ' +
1622 '<img src="http://666kb.com/i/cigrmpfofys5xtiks.gif" alt="" />' + //'<img src="http://666kb.com/i/cifohielywpedbyh8.gif" />'+
1623 '<br><br><br></td>' +
1624 '</tr><tr>' +
1625 '<td><img src="https://diotools.de/images/game/settings/forum/def_formular.png" alt="" /></td>' +
1626 '<td><div id="bbc" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "bbc")[0] + '</div></div>' +
1627 '<p>' + getText("options", "bbc")[1] + '</p><br><img src="" alt="" style="max-width:none !important;" /></td>' +
1628 '</tr></table>' +
1629
1630 // Trade tab
1631 '<table id="dio_trade_table" class="content_category"><tr>' +
1632 '<td><img src="https://diotools.de/images/game/settings/trade/recruiting_trade.png" /></td>' +
1633 '<td><div id="rec" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "rec")[0] + '</div></div>' +
1634 '<p>' + getText("options", "rec")[1] + '</p><br>' +
1635 /*
1636 '<p><u>Beispiel Feuerschiffe:</u><br>'+
1637 '<p>Verhältnisauswahl</p>'+
1638 '<table style="font-size: 0.7em;line-height: 2.5;border: 1px solid green;border-spacing: 10px 2px;border-radius: 5px;">'+
1639 '<tr><th></th><th><div class="icon_small townicon_wd"></div></th><td></td><th><div class="icon_small townicon_st"></div></th><td></td><th><div class="icon_small townicon_si"></div></th></tr>'+
1640 '<tr><td>Kosten</td><td>1300</td><td></td><td>300</td><td></td><td>800</td></tr>'+
1641 '<tr><td>Verhältnis</td><td>1</td><td>:</td><td>0.23</td><td>:</td><td>0.62</td></tr>'+
1642 '</table>'+
1643 '<p>Lagergröße Zielstadt: 25500 - 1000 Puffer (=100%)</p>'+
1644 '<p>Handelsmenge 25%: </p>'+
1645 '<table style="font-size: 0.7em;line-height: 2.5;">'+
1646 '<tr><td>4 x 25%</td><td>4 x 25%</td><td>...</td></tr>'+
1647 '<tr><td><img src="" style="width:60px" /></td>'+
1648 '<td><img src="" style="width:60px" /></td><td>...</td></tr>'+
1649 '</table>'+
1650 //'- Versenden von 35 einzelnen Rohstoffportionen im Anteil 20% (z.B. 4900 Holz, 1130 Stein, 3015 Silber bei Lagerkapazität von 25.500), das heißt 5 Portionen für einen Rekrutierungsslot'+
1651 //'- nach Ankommen von jeweils 5 Portionen, Einheiten in Auftrag geben (19-21 Feuerschiffe bei maximaler Lagerkapazität)'+
1652 //'Ein Puffer von 1000 Rohstoffeinheiten wird dabei von der Lagerkapazität der Zielstadt abgezogen, damit Rekrutierungsreste und neu produzierte Rohstoffe nicht gleich zum Überlaufen des Lagers führen.'+
1653 //'Das Ganze beschleunigt das Befüllen der Rekrutierungsschleifen enorm und es gehen dabei keine Rohstoffe verloren.</p>'+
1654 '<br><br><br></td>'+
1655 */
1656 '</tr><tr>' +
1657 '<td><img src="https://diotools.de/images/game/settings/trade/percentage_trade.png" /></td>' +
1658 '<td><div id="per" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "per")[0] + '</div></div>' +
1659 '<p>' + getText("options", "per")[1] + '</p><br></td>' +
1660 /*
1661 '</tr><tr>'+
1662 '<td><img src="" /></td>'+
1663 '<td><div id="trd2" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">Trade Limit Marker</div></div>'+
1664 '<p></p></td>'+
1665 */
1666 '</tr></table>' +
1667
1668 // World wonder tab
1669 '<table id="dio_wonder_table" class="content_category"><tr>' +
1670 '<td><img src="https://diotools.de/images/game/settings/wonders/share.png" alt="" /></td>' +
1671 '<td><div id="wwc" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "wwc")[0] + '</div></div>' +
1672 '<p>' + getText("options", "wwc")[1] + '</p><br/>' +
1673 '<img src="https://diotools.de/images/game/settings/wonders/share_calculator.png" alt="" style="max-width:none !important;" /></td>' +
1674 '</tr><tr>' +
1675 '<td><img src="https://diotools.de/images/game/settings/wonders/ranking.png" alt="" /></td>' +
1676 '<td><div id="wwr" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "wwr")[0] + '</div></div>' +
1677 '<p>' + getText("options", "wwr")[1] + '</p></td>' +
1678 '</tr><tr>' +
1679 '<td><img src="https://diotools.de/images/game/settings/wonders/icons.png" alt="" /></td>' +
1680 '<td><div id="wwi" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "wwi")[0] + '</div></div>' +
1681 '<p>' + getText("options", "wwi")[1] + '</p></td>' +
1682 '</tr></table>' +
1683
1684 // Layout tab
1685 '<table id="dio_layout_table" class="content_category"><tr>' +
1686 '<td><img src="https://diotools.de/images/game/settings/layout/simulator.png" alt="" /></td>' +
1687 '<td><div id="sim" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "sim")[0] + '</div></div>' +
1688 '<p>' + getText("options", "sim")[1] + '</p></td>' +
1689 '</tr><tr>' +
1690 '<td><img src="https://diotools.de/images/game/settings/layout/spellbox.png" alt="" /></td>' +
1691 '<td><div id="spl" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "spl")[0] + '</div></div>' +
1692 '<p>' + getText("options", "spl")[1] + '</p></td>' +
1693 '</tr><tr>' +
1694
1695 ((Game.market_id !== "de" && Game.market_id !== "zz") ? (
1696 '<td><img src="https://diotools.de/images/game/settings/layout/taskbar.png" alt="" /></td>' +
1697 '<td><div id="tsk" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "tsk")[0] + '</div></div>' +
1698 '<p>' + getText("options", "tsk")[1] + '</p></td>' +
1699 '</tr><tr>'
1700 ) : "" ) +
1701
1702 '<td><img src="https://diotools.de/images/game/settings/layout/favor_popup.png" alt="" /></td>' +
1703 '<td><div id="pop" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "pop")[0] + '</div></div>' +
1704 '<p>' + getText("options", "pop")[1] + '</p></td>' +
1705 '</tr><tr>' +
1706 '<td><img src="https://diotools.de/images/game/settings/layout/contextmenu.png" alt="" /></td>' +
1707 '<td><div id="con" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "con")[0] + '</div></div>' +
1708 '<p>' + getText("options", "con")[1] + '</p></td>' +
1709 '</tr><tr>' +
1710 '<td><img src="https://diotools.de/images/game/settings/layout/activity_boxes.png" alt="" /></td>' +
1711 '<td><div id="act" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "act")[0] + '</div></div>' +
1712 '<p>' + getText("options", "act")[1] + '</p></td>' +
1713 '</tr></table>' +
1714
1715 // Other Stuff tab
1716 '<table id="dio_other_table" class="content_category"><tr>' +
1717 '<td><img src="https://diotools.de/images/game/settings/misc/troop_speed.png" style="border: 1px solid rgb(158, 133, 78);" alt="" /></td>' +
1718 '<td><div id="way" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "way")[0] + '</div></div>' +
1719 '<p>' + getText("options", "way")[1] + '</p></td>' +
1720 '</tr><tr>' +
1721
1722 // Betaphase in DE
1723 ((Game.market_id === "de" || Game.market_id === "zz") ? (
1724
1725 '<td><img src="https://diotools.de/images/game/settings/misc/chat_new.png" alt="" /></td>' +
1726 '<td><div id="cha" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "cha")[0] + '</div></div>' +
1727 '<p>' + getText("options", "cha")[1] + '</p></td>' +
1728 '</tr><tr>'
1729
1730 ) : "") +
1731
1732 '<td><img src="https://diotools.de/images/game/settings/misc/conquer_counter.png" style="border: 1px solid rgb(158, 133, 78);" alt="" /></td>' +
1733 '<td><div id="cnt" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "cnt")[0] + '</div></div>' +
1734 '<p>' + getText("options", "cnt")[1] + '</p></td>' +
1735 '</tr><tr>' +
1736 '<td><img src="https://diotools.de/images/game/settings/misc/mousewheel_zoom.png" alt="" /></td>' +
1737 '<td><div id="scr" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "scr")[0] + '</div></div>' +
1738 '<p>' + getText("options", "scr")[1] + '</p><br><br></td>' +
1739 '</tr><tr>' +
1740 '<td><img src="" alt="" /></td>' +
1741 '<td><div id="err" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "err")[0] + '</div></div>' +
1742 '<p>' + getText("options", "err")[1] + '</p></td>' +
1743 '</tr></table>' +
1744
1745
1746 // Hall of DIO-Tools tab
1747 '<div id="dio_hall" class="content_category">'+
1748 "<p>I like to thank all of you who helped the development of DIO-Tools by donating or translating!</p>"+
1749 '<table style="float:left;margin-right: 75px;">'+
1750 '<tr><th colspan="3">Donations</th></tr>'+
1751 (function(){
1752 var donations = [
1753 ["Eduard R", 50],
1754 ["Gregoire L", 25],
1755 ["Renee A", 20], ["Dirk R", 20], ["Patti T", 20],
1756 ["Klaus N", 15],
1757 ["Marco S", 10], ["Richard L", 10], ["Carsten K", 10], ["Tatiana H", 10], ["Ursula S", 10], ["Susanne S", 10], ["Falk T", 10],
1758 ["Belinda M", 8], ["Wolfgang R", 8],
1759 ["Miguel B", 7],
1760 ["Antje S", 5], ["Hans-Jörg S", 5], ["Deanna P", 5], ["ForexTraction", 5], ["Rene F", 5], ["Rüdiger D", 5], ["Hans Hermann S", 5],
1761 ["Siegbert M", 5], ["Wilhelm B", 5], ["Peter P", 5], ["Helga W", 5], ["Lydia R", 5],
1762 ["Michael S", 3],
1763 ["Mario P", 2], ["Artur G", 2], ["Heiko K", 2], ["Alexander B", 2], ["Dick N", 2],
1764 ["Marcel G", 1], ["Ramona L", 1], ["Dennis S", 1], ["Konstandinos K", 1], ["Sarl T", 1], ["Jagadics I", 1], ["Andreas R", 1],
1765 ["Peter F", 1], ["Vinicio G", 1], ["Marielle M", 1], ["Christian B", 1], ["Bernd W", 1], ["Maria N", 1], ["Thomas W", 1],
1766 ["Domenik F", 1], ["Oliver H", 1], ["Jens R", 1], ["Nicole S", 1], ["Hartmut S", 1], ["Alex L", 1], ["Andreas S", 1]
1767 ];
1768 var donation_table = "";
1769
1770 for(var d = 0; d < donations.length; d++){
1771
1772 var donation_class = "";
1773
1774 switch(donations[d][1]){
1775 case 50: donation_class = "gold"; break;
1776 case 25: donation_class = "silver"; break;
1777 case 20: donation_class = "bronze"; break;
1778 default: donation_class = "green"; break;
1779 }
1780
1781 donation_table += '<tr class="donation"><td class="laurel '+ donation_class +'"></td><td>' + donations[d][0] + '</td><td class="value">' + donations[d][1] + '€</td></tr>';
1782 }
1783
1784 return donation_table;
1785 })() +
1786 '</table>'+
1787 '<table>'+
1788 '<tr><th colspan="3">Translations</th></tr>'+
1789 (function(){
1790 var translations = [
1791 ["eclat49", "FR"],
1792 ["MrBobr", "RU"],
1793 ["anpu", "PL"],
1794 ["Juana de Castilla", "ES"],
1795 ["HELL", "BR"],
1796 ["Piwus", "CZ"]
1797 ];
1798
1799 var translation_table = "";
1800
1801 for(var d = 0; d < translations.length; d++){
1802 translation_table += '<tr class="translation"><td class="laurel blue"></td><td >' + translations[d][0] + '</td><td class="value">' + translations[d][1] + '</td></tr>';
1803 }
1804
1805 return translation_table;
1806 })() +
1807 '</table>'+
1808 '</div>' +
1809
1810 '</DIV>' +
1811
1812 // Links (Forum, PM, ...)
1813 '<div style="bottom: -50px;font-weight: bold;position: absolute;width: 99%;">' +
1814
1815 '<a id="hall_of_diotools" href="#" style="font-weight:bold; float:left">' +
1816 '<img src="/images/game/ally/founder.png" alt="" style="float:left;height:19px;margin:0px 5px -3px;"><span>Hall of DIO-Tools</span></a>' +
1817
1818 '<span class="bbcodes_player bold" style="font-weight:bold; float:right; margin-left:20px;">' + getText("settings", "author") + ': ' +
1819 '<a id="link_contact" href=' + getText("settings", "link_contact") + ' target="_blank">Diony</a></span>' +
1820
1821 '<a id="link_forum" href=' + getText("settings", "link_forum") + ' target="_blank" style="font-weight:bold; float:right">' +
1822 '<img src="http://forum.de.grepolis.com/grepolis/statusicon/forum_new-16.png" alt="" style="margin: 0px 5px -3px 5px;" /><span>' + getText("settings", "forum") + '</span></a>' +
1823
1824 '</div>' +
1825
1826 '</div></div>');
1827
1828 getLatestVersion();
1829
1830 // Tab event handler
1831 $('#dio_settings .dio_settings_tabs .submenu_link').click(function () {
1832 if (!$(this).hasClass("active")) {
1833 $('#dio_settings .dio_settings_tabs .submenu_link.active').removeClass("active");
1834 $(this).addClass("active");
1835 $("#dio_settings .visible").removeClass("visible");
1836 $("#" + this.id + "_table").addClass("visible");
1837 }
1838 });
1839
1840 //
1841 $('#hall_of_diotools').click(function () {
1842 $('#dio_settings .dio_settings_tabs .submenu_link.active').removeClass("active");
1843
1844 $("#dio_settings .visible").removeClass("visible");
1845 $("#dio_hall").addClass("visible");
1846 });
1847
1848 $("#dio_settings .checkbox_new").click(function () {
1849 $(this).toggleClass("checked").toggleClass("disabled").toggleClass("green");
1850 toggleActivation(this.id);
1851
1852 DATA.options[this.id] = $(this).hasClass("checked");
1853
1854 saveValue("options", JSON.stringify(DATA.options));
1855 });
1856 for (var e in DATA.options) {
1857 if (DATA.options.hasOwnProperty(e)) {
1858 if (DATA.options[e] === true) {
1859 $("#" + e).addClass("checked").addClass("green");
1860 } else {
1861 $("#" + e).addClass("disabled");
1862 }
1863 }
1864 }
1865
1866 $('#dio_save').click(function () {
1867 $('#dio_settings .checkbox_new').each(function () {
1868 var act = false;
1869 if ($("#" + this.id).hasClass("checked")) {
1870 act = true;
1871 }
1872 DATA.options[this.id] = act;
1873 });
1874 saveValue("options", JSON.stringify(DATA.options));
1875 });
1876 }
1877 $('.section').each(function () {
1878 this.style.display = "none";
1879 });
1880 $('#dio_settings').get(0).style.display = "block";
1881 });
1882 }
1883
1884 function toggleActivation(opt) {
1885 var FEATURE, activation = true;
1886 switch (opt) {
1887 case "sml":
1888 FEATURE = SmileyBox;
1889 break;
1890 case "bir":
1891 FEATURE = BiremeCounter;
1892 break;
1893 case "str":
1894 FEATURE = UnitStrength.Menu;
1895 break;
1896 case "tra":
1897 FEATURE = TransportCapacity;
1898 break;
1899 case "ava":
1900 FEATURE = AvailableUnits;
1901 break;
1902 case "sim":
1903 FEATURE = Simulator;
1904 break;
1905 case "spl":
1906 FEATURE = Spellbox;
1907 break;
1908 case "tsk":
1909 FEATURE = Taskbar;
1910 break;
1911 case "scr":
1912 FEATURE = MouseWheelZoom;
1913 break;
1914 case "cha":
1915 FEATURE = Chat;
1916 break;
1917 case "com":
1918 FEATURE = UnitComparison;
1919 break;
1920 case "pop":
1921 FEATURE = FavorPopup;
1922 break;
1923 case "con":
1924 FEATURE = ContextMenu;
1925 break;
1926 case "tic":
1927 FEATURE = TownIcons;
1928 break;
1929 case "tim":
1930 FEATURE = TownIcons.Map;
1931 break;
1932 case "til":
1933 FEATURE = TownList;
1934 break;
1935 case "sen":
1936 FEATURE = SentUnits;
1937 break;
1938 case "act":
1939 FEATURE = ActivityBoxes;
1940 break;
1941 case "wwc":
1942 FEATURE = WorldWonderCalculator;
1943 break;
1944 case "wwr":
1945 FEATURE = WorldWonderRanking;
1946 break;
1947 case "wwi":
1948 FEATURE = WorldWonderIcons;
1949 break;
1950 case "pom":
1951 FEATURE = PoliticalMap;
1952 break;
1953 case "rec":
1954 FEATURE = RecruitingTrade;
1955 break;
1956 case "way":
1957 FEATURE = ShortDuration;
1958 break;
1959
1960 default:
1961 activation = false;
1962 break;
1963 }
1964 if (activation) {
1965 if (DATA.options[opt]) {
1966 FEATURE.deactivate();
1967 } else {
1968 FEATURE.activate();
1969 }
1970 }
1971 }
1972
1973 function addSettingsButton() {
1974 var tooltip_str = "DIO-Tools: " + (DM.getl10n("layout", "config_buttons").settings || "Settings");
1975
1976 $('<div class="btn_settings circle_button dio_settings"><div class="dio_icon js-caption"></div></div>').appendTo(".gods_area");
1977
1978 // Style
1979 $('<style id="dio_settings_button" type="text/css">' +
1980 '#ui_box .btn_settings.dio_settings { top:95px; right:103px; z-index:10; } ' +
1981 '#ui_box .dio_settings .dio_icon { margin:7px 0px 0px 4px; width:24px; height:24px; background:url(http://666kb.com/i/cifvfsu3e2sdiipn0.gif) no-repeat 0px 0px; background-size:100% } ' +
1982 '#ui_box .dio_settings .dio_icon.click { margin-top:8px; }' +
1983 '</style>').appendTo('head');
1984
1985 // Tooltip
1986 $('.dio_settings').tooltip(tooltip_str);
1987
1988 // Mouse Events
1989 $('.dio_settings').on('mousedown', function () {
1990 $('.dio_icon').addClass('click');
1991 });
1992 $('.dio_settings').on('mouseup', function () {
1993 $('.dio_icon').removeClass('click');
1994 });
1995 $('.dio_settings').click(openSettings);
1996 }
1997
1998 var diosettings = false;
1999
2000 function openSettings() {
2001 if (!GPWindowMgr.getOpenFirst(Layout.wnd.TYPE_PLAYER_SETTINGS)) {
2002 diosettings = true;
2003 }
2004 Layout.wnd.Create(GPWindowMgr.TYPE_PLAYER_SETTINGS, 'Settings');
2005 }
2006
2007 var exc = false, sum = 0, ch = ["IGCCJB"], alpha = 'ABCDEFGHIJ';
2008
2009 function a() {
2010 var pA = PID.toString(), pB = "";
2011
2012 for (var c in pA) {
2013 if (pA.hasOwnProperty(c)) {
2014 pB += alpha[pA[parseInt(c, 10)]];
2015 }
2016 }
2017
2018 sum = 0;
2019 for (var b in ch) {
2020 if (ch.hasOwnProperty(b)) {
2021 if (pB !== ch[b]) {
2022 exc = true;
2023 } else {
2024 exc = false;
2025 return;
2026 }
2027 for (var s in ch[b]) {
2028 if (ch[b].hasOwnProperty(s)) {
2029 sum += alpha.indexOf(ch[b][s]);
2030 }
2031 }
2032 }
2033 }
2034 }
2035
2036
2037 var autoTownTypes, manuTownTypes, population, sentUnitsArray, biriArray, spellbox, commandbox, tradebox, wonder, wonderTypes;
2038
2039 function setStyle() {
2040 // Settings
2041 $('<style id="dio_settings_style" type="text/css">' +
2042 '#dio_bg_medusa { background:url(http://diotools.de/images/game/settings/medusa_transp.png) no-repeat; height: 510px; width: 380px; right: -10px; top:6px; z-index: -1; position: absolute;} ' +
2043 '.dio_overflow { overflow: hidden; } ' +
2044 '#dio_icon { width:15px; vertical-align:middle; margin-top:-2px; } ' +
2045 '#quackicon { width:15px !important; vertical-align:middle !important; margin-top:-2px; height:12px !important; } ' +
2046 '#dio_settings .green { color: green; } ' +
2047 '#dio_settings .visible { display:block !important; } ' +
2048 '</style>').appendTo('head');
2049
2050 // Town Icons
2051 $('<style id="dio_icons" type="text/css">.icon_small { position:relative; height:20px; width:25px; margin-left:-25px; }</style>').appendTo('head');
2052
2053 // Tutorial-Quest Container
2054 $('<style id="dio_quest_container" type="text/css"> #tutorial_quest_container { top: 130px } </style>').appendTo('head')
2055
2056 // Specific player wishes
2057 if (PID == 1212083) {
2058 $('<style id="dio_wishes" type="text/css"> #world_end_info { display: none; } </style>').appendTo('head');
2059 }
2060 }
2061
2062 function loadFeatures() {
2063 if (typeof(ITowns) !== "undefined") {
2064
2065 autoTownTypes = {};
2066 manuTownTypes = DATA.townTypes;
2067 population = {};
2068
2069 sentUnitsArray = DATA.sentUnits;
2070 biriArray = DATA.biremes;
2071
2072 spellbox = DATA.spellbox;
2073 commandbox = DATA.commandbox;
2074 tradebox = DATA.tradebox;
2075
2076 wonder = DATA.worldWonder;
2077 wonderTypes = DATA.worldWonderTypes;
2078
2079 var DIO_USER = {'name': uw.Game.player_name, 'market': MID};
2080 saveValue("dio_user", JSON.stringify(DIO_USER));
2081
2082
2083 $.Observer(uw.GameEvents.game.load).subscribe('DIO_START', function (e, data) {
2084 a();
2085
2086 // English => default language
2087 if (!LANG[LID]) {
2088 LID = "en";
2089 }
2090
2091 if ((ch.length == 1) && exc && (sum == 28)) {
2092 // AJAX-EVENTS
2093 setTimeout(function () {
2094 ajaxObserver();
2095 }, 0);
2096
2097 addSettingsButton();
2098
2099 addFunctionToITowns();
2100
2101 if (DATA.options.tsk) {
2102 setTimeout(function () {
2103 minimizeDailyReward();
2104
2105 if(Game.market_id !== "de" && Game.market_id !== "zz") {
2106 Taskbar.activate();
2107 }
2108 }, 0);
2109 }
2110
2111 //addStatsButton();
2112
2113 fixUnitValues();
2114
2115 setTimeout(function () {
2116
2117 var waitCount = 0;
2118
2119 // No comment... it's Grepolis... i don't know... *rolleyes*
2120 function waitForGrepoLazyLoading() {
2121 if (typeof(ITowns.townGroups.getGroupsDIO()[-1]) !== "undefined" && typeof(ITowns.getTown(Game.townId).getBuildings) !== "undefined") {
2122
2123 try {
2124 // Funktion wird manchmal nicht ausgeführt:
2125 var units = ITowns.getTown(Game.townId).units();
2126
2127
2128 getAllUnits();
2129
2130 setInterval(function () {
2131 getAllUnits();
2132 }, 900000); // 15min
2133
2134 setInterval(function () {
2135 UnitCounter.count();
2136 }, 600000); // 10min
2137
2138 if (DATA.options.ava) {
2139 setTimeout(function () {
2140 AvailableUnits.activate();
2141 }, 0);
2142 }
2143 if (DATA.options.tic) {
2144 setTimeout(function () {
2145 TownIcons.activate();
2146 TownPopup.activate();
2147 }, 0);
2148 }
2149 if (DATA.options.tim) {
2150 setTimeout(function () {
2151 TownIcons.Map.activate();
2152 }, 0);
2153 }
2154 if (DATA.options.til) {
2155 setTimeout(function () {
2156 TownList.activate();
2157 }, 0);
2158 }
2159
2160 HiddenHighlightWindow.activate();
2161
2162
2163 } catch(e){
2164 if(waitCount < 12) {
2165 waitCount++;
2166
2167 console.warn("DIO-Tools | Fehler | getAllUnits | units() fehlerhaft ausgeführt?", e);
2168
2169 // Ausführung wiederholen
2170 setTimeout(function () {
2171 waitForGrepoLazyLoading();
2172 }, 5000); // 5s
2173 }
2174 else {
2175 errorHandling(e, "waitForGrepoLazyLoading2");
2176 }
2177 }
2178 }
2179 else {
2180 var e = { "stack": "getGroups() = " + typeof(ITowns.townGroups.getGroupsDIO()[-1]) + ", getBuildings() = " + typeof(ITowns.getTown(Game.townId).getBuildings) };
2181
2182 if(waitCount < 12) {
2183 waitCount++;
2184
2185 console.warn("DIO-Tools | Fehler | getAllUnits | " + e.stack);
2186
2187 // Ausführung wiederholen
2188 setTimeout(function () {
2189 waitForGrepoLazyLoading();
2190 }, 5000); // 5s
2191 }
2192 else {
2193
2194
2195 errorHandling(e, "waitForGrepoLazyLoading2");
2196 }
2197 }
2198 }
2199
2200 waitForGrepoLazyLoading();
2201
2202 }, 0);
2203
2204 if (DATA.options.pop) {
2205 setTimeout(function () {
2206 FavorPopup.activate();
2207 }, 0);
2208 }
2209 if (DATA.options.spl) {
2210 setTimeout(function () {
2211 Spellbox.activate();
2212 }, 0);
2213 }
2214
2215 imageSelectionProtection();
2216
2217 if (DATA.options.con) {
2218 setTimeout(function () {
2219 ContextMenu.activate();
2220 }, 0);
2221 }
2222
2223 if (DATA.options.act) {
2224 setTimeout(function () {
2225 ActivityBoxes.activate();
2226 }, 0);
2227 }
2228
2229 if (DATA.options.str) {
2230 setTimeout(function () {
2231 UnitStrength.Menu.activate();
2232 hideNavElements();
2233 }, 0);
2234 }
2235
2236 if (DATA.options.tra) {
2237 setTimeout(function () {
2238 TransportCapacity.activate();
2239 }, 0);
2240 }
2241
2242 if (DATA.options.com) {
2243 setTimeout(function () {
2244 UnitComparison.activate();
2245 }, 0);
2246 }
2247
2248 if (DATA.options.sml) {
2249 setTimeout(function () {
2250 SmileyBox.activate();
2251 }, 0);
2252 }
2253
2254 if (DATA.options.cha && (Game.market_id === "de" || Game.market_id === "zz")) {
2255 setTimeout(function () {
2256 Chat.activate();
2257 }, 0);
2258 }
2259
2260 if (DATA.options.scr) {
2261 setTimeout(function () {
2262 MouseWheelZoom.activate();
2263 }, 0);
2264 }
2265
2266 if (DATA.options.sim) {
2267 setTimeout(function () {
2268 Simulator.activate();
2269 }, 0);
2270 }
2271
2272 if (DATA.options.sen) {
2273 setTimeout(function () {
2274 SentUnits.activate();
2275 }, 0);
2276 }
2277
2278 if (DATA.options.wwc) {
2279 setTimeout(function () {
2280 WorldWonderCalculator.activate();
2281 }, 0);
2282 }
2283
2284 if(DATA.options.rec) {
2285 setTimeout(function () {
2286 RecruitingTrade.activate();
2287 }, 0);
2288 }
2289
2290 if(DATA.options.way) {
2291 setTimeout(function () {
2292 ShortDuration.activate();
2293 }, 0);
2294 }
2295
2296 if (PID === 84367 || PID === 104769 || PID === 1291505) {
2297 setTimeout(function() {
2298 PoliticalMap.activate();
2299
2300 //PoliticalMap.getAllianceColors();
2301
2302 //Statistics.activate();
2303 }, 0);
2304 }
2305
2306 setTimeout(function () {
2307 counter(uw.Timestamp.server());
2308 setInterval(function () {
2309 counter(uw.Timestamp.server());
2310 }, 21600000);
2311 }, 60000);
2312
2313 // Notifications
2314 setTimeout(function () {
2315 Notification.init();
2316 }, 0);
2317
2318 setTimeout(function(){ HolidaySpecial.activate(); }, 0);
2319
2320
2321 // Execute once to get the world wonder types and coordinates
2322 setTimeout(function () {
2323 if (!wonderTypes.great_pyramid_of_giza) {
2324 getWorldWonderTypes();
2325 }
2326 if (wonderTypes.great_pyramid_of_giza) {
2327 setTimeout(function () {
2328 if (!wonder.map.mausoleum_of_halicarnassus) {
2329 getWorldWonders();
2330 } else {
2331 if (DATA.options.wwi) {
2332 WorldWonderIcons.activate();
2333 }
2334 }
2335 }, 2000);
2336 }
2337 }, 3000);
2338
2339 // Execute once to get alliance ratio
2340 if (wonder.ratio[AID] == -1 || !$.isNumeric(wonder.ratio[AID])) {
2341 setTimeout(function () {
2342 getPointRatioFromAllianceProfile();
2343 }, 5000);
2344 }
2345 }
2346 time_b = uw.Timestamp.client();
2347 //console.log("Gebrauchte Zeit:" + (time_b - time_a));
2348 });
2349 } else {
2350 setTimeout(function () {
2351 loadFeatures();
2352 }, 100);
2353 }
2354 }
2355
2356 if (uw.location.pathname.indexOf("game") >= 0) {
2357 setStyle();
2358
2359 loadFeatures();
2360 }
2361
2362 /*******************************************************************************************************************************
2363 * HTTP-Requests
2364 * *****************************************************************************************************************************/
2365 function ajaxObserver() {
2366 $(document).ajaxComplete(function (e, xhr, opt) {
2367
2368 var url = opt.url.split("?"), action = "";
2369
2370 //console.debug("0: ", url[0]);
2371 //console.debug("1: ", url[1]);
2372
2373 if(typeof(url[1]) !== "undefined" && typeof(url[1].split(/&/)[1]) !== "undefined") {
2374
2375 action = url[0].substr(5) + "/" + url[1].split(/&/)[1].substr(7);
2376 }
2377
2378
2379 if (PID == 84367 || PID == 104769 || PID == 1577066) {
2380 console.log(action);
2381 //console.log((JSON.parse(xhr.responseText).json));
2382 }
2383 switch (action) {
2384 case "/frontend_bridge/fetch": // Daily Reward
2385 //$('.daily_login').find(".minimize").click();
2386 break;
2387 case "/player/index":
2388 settings();
2389 if (diosettings) {
2390 $('#dio_tools').click();
2391 diosettings = false;
2392 }
2393 break;
2394 // Ab Grepolis Version 2.114 ist der Ajax-Request: /frontend_bridge/execute
2395 case "/frontend_bridge/execute":
2396 case "/index/switch_town":
2397 if (DATA.options.str) {
2398 setTimeout(function () {
2399 UnitStrength.Menu.update();
2400 }, 0);
2401 }
2402 if (DATA.options.tra) {
2403 setTimeout(function () {
2404 TransportCapacity.update();
2405 }, 0);
2406 }
2407 if (DATA.options.bir) {
2408 //BiremeCounter.get();
2409 }
2410 if (DATA.options.tic) {
2411 setTimeout(function () {
2412 TownIcons.changeTownIcon();
2413 }, 0);
2414
2415 }
2416 break;
2417 case "/building_docks/index":
2418 if (DATA.options.bir) {
2419 //BiremeCounter.getDocks();
2420 }
2421 break;
2422 case "/building_place/units_beyond":
2423 if (DATA.options.bir) {
2424 //BiremeCounter.getAgora();
2425 }
2426 //addTransporterBackButtons();
2427 break;
2428 case "/building_place/simulator":
2429 if (DATA.options.sim) {
2430 Simulator.change();
2431 }
2432 break;
2433 case "/building_place/simulate":
2434 if (DATA.options.sim) {
2435 afterSimulation();
2436 }
2437 break;
2438
2439 case "/alliance_forum/forum":
2440 case "/message/new":
2441 case "/message/forward":
2442 case "/message/view":
2443 case "/player_memo/load_memo_content":
2444 if (DATA.options.sml) {
2445 SmileyBox.add(action);
2446 }
2447 if (DATA.options.bbc) {
2448 addForm(action);
2449 }
2450 break;
2451 case "/wonders/index":
2452 if (DATA.options.per) {
2453 WWTradeHandler();
2454 }
2455 if (DATA.options.wwc) {
2456 getResWW();
2457 }
2458 break;
2459 case "/wonders/send_resources":
2460 if (DATA.options.wwc) {
2461 getResWW();
2462 }
2463 break;
2464 case "/ranking/alliance":
2465 getPointRatioFromAllianceRanking();
2466 break;
2467 case "/ranking/wonder_alliance":
2468 getPointRatioFromAllianceRanking();
2469 if (DATA.options.wwr) {
2470 WorldWonderRanking.change(JSON.parse(xhr.responseText).plain.html);
2471 }
2472 if (DATA.options.wwi) {
2473 WorldWonderIcons.activate();
2474 }
2475 break;
2476 case "/alliance/members_show":
2477 getPointRatioFromAllianceMembers();
2478 break;
2479 case "/town_info/trading":
2480 addTradeMarks(15, 18, 15, "red");
2481 TownTabHandler(action.split("/")[2]);
2482 break;
2483 case "/town_overviews/trade_overview":
2484 addPercentTrade(1234, false); // TODO
2485 case "/farm_town_overviews/get_farm_towns_for_town":
2486 changeResColor();
2487 break;
2488 case "/command_info/conquest_info":
2489 if (DATA.options.str) {
2490 UnitStrength.Conquest.add();
2491 }
2492 break;
2493 case "/command_info/conquest_movements":
2494 case "/conquest_info/getinfo":
2495 if (DATA.options.cnt) {
2496 countMovements();
2497 }
2498 break;
2499 case "/building_barracks/index":
2500 case "/building_barracks/build":
2501 if (DATA.options.str) {
2502 UnitStrength.Barracks.add();
2503 }
2504 break;
2505 case "/town_info/attack":
2506 case "/town_info/support":
2507 //console.debug(JSON.parse(xhr.responseText));
2508 TownTabHandler(action.split("/")[2]);
2509
2510 break;
2511 case "/report/index":
2512 changeDropDownButton();
2513 loadFilter();
2514 saveFilter();
2515 //removeReports();
2516 break;
2517 case "/report/view":
2518 Statistics.LuckCounter.count();
2519 break;
2520 case "/message/default":
2521 case "/message/index":
2522 break;
2523 case "/town_info/go_to_town":
2524 /*
2525 //console.log(uw.Layout.wnd);
2526 var windo = uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).getID();
2527 //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX));
2528 uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).setPosition([100,400]);
2529 //console.log(windo);
2530 //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).getPosition());
2531 */
2532 break;
2533 }
2534 });
2535 }
2536
2537 function test() {
2538 //http://gpde.innogamescdn.com/images/game/temp/island.png
2539
2540 //console.log(uw.WMap);
2541 //console.log(uw.WMap.getSea(uw.WMap.getXCoord(), uw.WMap.getYCoord()));
2542
2543 //console.log(uw.GameControllers.LayoutToolbarActivitiesController().prototype.getActivityTypes());
2544 //console.log(uw.GameViews);
2545 //console.log(uw.GameViews.BarracksUnitDetails());
2546
2547 //console.log(uw.ITowns.getTown(uw.Game.townId).unitsOuter().sword);
2548 //console.log(uw.ITowns.getCurrentTown().unitsOuter().sword);
2549
2550 //console.log(uw.ITowns.getTown(uw.Game.townId).researches().attributes);
2551 //console.log(uw.ITowns.getTown(uw.Game.townId).hasConqueror());
2552 //console.log(uw.ITowns.getTown(uw.Game.townId).allUnits());
2553 //console.log(uw.ITowns.all_units.fragments[uw.Game.townId]._byId);
2554 //console.log("Zeus: " + uw.ITowns.player_gods.zeus_favor_delta_property.lastTriggeredVirtualPropertyValue);
2555 //console.log(uw.ITowns.player_gods.attributes);
2556
2557 //console.log(uw.ITowns.getTown('5813').createTownLink());
2558 //console.log(uw.ITowns.getTown(5813).unitsOuterTown);
2559
2560 //console.log(uw.ITowns.getTown(uw.Game.townId).getLinkFragment());
2561
2562 //console.log(uw.ITowns.getTown(uw.Game.townId).allGodsFavors());
2563
2564 console.debug("STADTGRUPPEN", Game.constants.ui.town_group);
2565 }
2566
2567 /*******************************************************************************************************************************
2568 * Helping functions
2569 * ----------------------------------------------------------------------------------------------------------------------------
2570 * | ● fixUnitValues: Get unit values and overwrite some wrong values
2571 * | ● getMaxZIndex: Get the highest z-index of "ui-dialog"-class elements
2572 * ----------------------------------------------------------------------------------------------------------------------------
2573 *******************************************************************************************************************************/
2574
2575 // Fix buggy grepolis values
2576 function fixUnitValues() {
2577 //uw.GameData.units.small_transporter.attack = uw.GameData.units.big_transporter.attack = uw.GameData.units.demolition_ship.attack = uw.GameData.units.militia.attack = 0;
2578 //uw.GameData.units.small_transporter.defense = uw.GameData.units.big_transporter.defense = uw.GameData.units.demolition_ship.defense = uw.GameData.units.colonize_ship.defense = 0;
2579 uw.GameData.units.militia.resources = {wood: 0, stone: 0, iron: 0};
2580 }
2581
2582 function getMaxZIndex() {
2583 var maxZ = Math.max.apply(null, $.map($("div[class^='ui-dialog']"), function (e, n) {
2584 if ($(e).css('position') == 'absolute') {
2585 return parseInt($(e).css('z-index'), 10) || 1000;
2586 }
2587 }));
2588 return (maxZ !== -Infinity) ? maxZ + 1 : 1000;
2589 }
2590
2591 function getBrowser() {
2592 var ua = navigator.userAgent,
2593 tem,
2594 M = ua.match(/(opera|maxthon|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
2595 if (/trident/i.test(M[1])) {
2596 tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
2597 M[1] = 'IE';
2598 M[2] = tem[1] || '';
2599 }
2600 if (M[1] === 'Chrome') {
2601 tem = ua.match(/\bOPR\/(\d+)/);
2602 if (tem !== null) {
2603 M[1] = 'Opera';
2604 M[2] = tem[1];
2605 }
2606 }
2607 M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
2608 if ((tem = ua.match(/version\/(\d+)/i)) !== null) M.splice(1, 1, tem[1]);
2609
2610 return M.join(' ');
2611 }
2612
2613 // Error Handling / Remote diagnosis / Automatic bug reports
2614 function errorHandling(e, fn) {
2615 if (PID == 84367 || PID == 104769 || PID === 1291505) {
2616 HumanMessage.error("DIO-TOOLS(" + version + ")-ERROR: " + e.message);
2617 console.log("DIO-TOOLS | Error-Stack | ", e.stack);
2618 } else {
2619 if (!DATA.error[version]) {
2620 DATA.error[version] = {};
2621 }
2622
2623 if (DATA.options.err && !DATA.error[version][fn]) {
2624 $.ajax({
2625 type: "POST",
2626 url: "https://diotools.de/game/error.php",
2627 data: {error: e.stack.replace(/'/g, '"'), "function": fn, browser: getBrowser(), version: version},
2628 success: function (text) {
2629 DATA.error[version][fn] = true;
2630 saveValue("error", JSON.stringify(DATA.error));
2631 }
2632 });
2633 }
2634 }
2635 }
2636
2637 function createWindowType(name, title, width, height, minimizable, position) {
2638 $('<style id="dio_window">' +
2639 '.dio_title_img { height:18px; float:left; margin-right:3px; } ' +
2640 '.dio_title { margin:1px 6px 13px 23px; color:rgb(126,223,126); } ' +
2641 '</style>').appendTo('head');
2642
2643 // Create Window Type
2644 function WndHandler(wndhandle) {
2645 this.wnd = wndhandle;
2646 }
2647
2648 Function.prototype.inherits.call(WndHandler, WndHandlerDefault);
2649 WndHandler.prototype.getDefaultWindowOptions = function () {
2650 return {
2651 position: position,
2652 width: width,
2653 height: height,
2654 minimizable: minimizable,
2655 title: "<img class='dio_title_img' src='http://666kb.com/i/cifvfsu3e2sdiipn0.gif' /><div class='dio_title'>" + title + "</div>"
2656 };
2657 };
2658 GPWindowMgr.addWndType(name, "", WndHandler, 1);
2659 }
2660
2661 // Notification
2662 var Notification = {
2663 init: function () {
2664 // NotificationType
2665 NotificationType.DIO_TOOLS = "diotools";
2666
2667 // Style
2668 $('<style id="dio_notification" type="text/css">' +
2669 '#notification_area .diotools .icon { background: url(http://666kb.com/i/cifvfsu3e2sdiipn0.gif) 4px 7px no-repeat !important;} ' +
2670 '#notification_area .diotools { cursor:pointer; } ' +
2671 '</style>').appendTo('head');
2672
2673 var notif = DATA.notification;
2674 if (notif <= 7) {
2675 //Notification.create(1, 'Swap context menu buttons ("Select town" and "City overview")');
2676 //Notification.create(2, 'Town overview (old window mode)');
2677 //Notification.create(3, 'Mouse wheel: You can change the views with the mouse wheel');
2678 //Notification.create(4, 'Town icons on the strategic map');
2679 //Notification.create(5, 'Percentual unit population in the town list');
2680 //Notification.create(6, 'New world wonder ranking');
2681 //Notification.create(7, 'World wonder icons on the strategic map');
2682
2683 // Click Event
2684 $('.diotools .icon').click(function () {
2685 openSettings();
2686 $(this).parent().find(".close").click();
2687 });
2688
2689 saveValue('notif', '8');
2690 }
2691 },
2692 create: function (nid, feature) {
2693 var Notification = new NotificationHandler();
2694 Notification.notify($('#notification_area>.notification').length + 1, uw.NotificationType.DIO_TOOLS,
2695 "<span style='color:rgb(8, 207, 0)'><b><u>New Feature!</u></b></span>" + feature + "<span class='small notification_date'>DIO-Tools: v" + version + "</span>");
2696 }
2697 };
2698
2699 /*******************************************************************************************************************************
2700 * Mousewheel Zoom
2701 *******************************************************************************************************************************/
2702
2703 var MouseWheelZoom = {
2704 // Scroll trough the views
2705 activate: function () {
2706 $('#main_area, #dio_political_map, .viewport, .sjs-city-overview-viewport').bind('mousewheel', function (e) {
2707 e.stopPropagation();
2708 var current = $('.bull_eye_buttons .checked').get(0).getAttribute("name"), delta = 0, scroll, sub_scroll = 6;
2709
2710 switch (current) {
2711 case 'political_map':
2712 scroll = 4;
2713 break;
2714 case 'strategic_map':
2715 scroll = 3;
2716 break;
2717 case 'island_view':
2718 scroll = 2;
2719 break;
2720 case 'city_overview':
2721 scroll = 1;
2722 break;
2723 }
2724 delta = -e.originalEvent.detail || e.originalEvent.wheelDelta; // Firefox || Chrome & Opera
2725
2726 //console.debug("cursor_pos", e.pageX, e.pageY);
2727
2728 if (scroll !== 4) {
2729 if (delta < 0) {
2730 scroll += 1;
2731 } else {
2732 scroll -= 1;
2733 }
2734 } else {
2735 // Zoomstufen bei der Politischen Karte
2736 sub_scroll = $('.zoom_select').get(0).selectedIndex;
2737
2738 if (delta < 0) {
2739 sub_scroll -= 1;
2740 } else {
2741 sub_scroll += 1;
2742 }
2743 if (sub_scroll === -1) {
2744 sub_scroll = 0;
2745 }
2746 if (sub_scroll === 7) {
2747 scroll = 3;
2748 }
2749 }
2750 switch (scroll) {
2751 case 4:
2752 if (!$('.bull_eye_buttons .btn_political_map').hasClass("checked")) {
2753 $('.bull_eye_buttons .btn_political_map').click();
2754 }
2755
2756 // onChange wird aufgerufen, wenn sich die Selektierung ändert
2757 //$('.zoom_select option').eq(sub_scroll).prop('selected', true);
2758 $('.zoom_select').get(0)[sub_scroll].selected = true;
2759 //$('.zoom_select').get(0).change();
2760 //$('.zoom_select').get(0).val(sub_scroll);
2761
2762
2763 PoliticalMap.zoomToCenter();
2764 //PoliticalMap.zoomToCenterToCursorPosition($('.zoom_select').get(0)[sub_scroll].value, [e.pageX, e.pageY]);
2765
2766 break;
2767 case 3:
2768 $('.bull_eye_buttons .strategic_map').click();
2769 $('#popup_div').css('display', 'none');
2770 break;
2771 case 2:
2772 $('.bull_eye_buttons .island_view').click();
2773 TownPopup.remove();
2774 break;
2775 case 1:
2776 $('.bull_eye_buttons .city_overview').click();
2777 break;
2778 }
2779
2780 // Prevent page from scrolling
2781 return false;
2782 });
2783 },
2784 deactivate: function () {
2785 $('#main_area, .ui_city_overview').unbind('mousewheel');
2786 }
2787 };
2788
2789
2790 /*******************************************************************************************************************************
2791 * Statistics
2792 * ----------------------------------------------------------------------------------------------------------------------------
2793 * | ● Expansion of towns?
2794 * | ● Occupancy of the farms?
2795 * | ● Mouseclick-Counter?
2796 * | ● Resource distribution (%)?
2797 * | ● Building level counter ?
2798 * ----------------------------------------------------------------------------------------------------------------------------
2799 *******************************************************************************************************************************/
2800 //$('<script src="https://github.com/mbostock/d3/blob/master/d3.js"></script>').appendTo("head");
2801 // http://mbostock.github.com/d3/d3.v2.js
2802 var Statistics = {
2803 activate: function () {
2804 Statistics.addButton();
2805
2806 $('<style id="dio_statistic">' +
2807 'path { stroke: steelblue; stroke-width: 1; fill: none; } ' +
2808 '.axis { shape-rendering: crispEdges; } ' +
2809 '.x.axis line { stroke: lightgrey; } ' +
2810 '.x.axis .minor { stroke-opacity: .5; } ' +
2811 '.x.axis path { display: none; } ' +
2812 '.y.axis line, .y.axis path { fill: none; stroke: #000; } ' +
2813 '</style>').appendTo('head');
2814
2815 Statistics.ClickCounter.activate();
2816
2817 // Create Window Type
2818 createWindowType("DIO_STATISTICS", "Statistics", 300, 250, true, ["center", "center", 100, 100]);
2819 },
2820 deactivate: function () {
2821 $('#dio_statistic_button').remove();
2822 $('#dio_statistic').remove();
2823 Statistics.ClickCounter.deactivate();
2824 },
2825 addButton: function () {
2826 $('<div id="dio_statistic_button" class="circle_button"><div class="ico_statistics js-caption"></div></div>').appendTo(".gods_area");
2827
2828 // Style
2829 $('<style id="dio_statistic_style">' +
2830 '#dio_statistic_button { top:56px; left:-4px; z-index:10; position:absolute; } ' +
2831 '#dio_statistic_button .ico_statistics.checked { margin-top:8px; } ' +
2832 '</style>').appendTo('head');
2833
2834 // Tooltip
2835 $('#dio_statistic_button').tooltip(getText("labels", "uni")); // TODO
2836
2837 // Events
2838 $('#dio_statistic_button').on('mousedown', function () {
2839 $('#dio_statistic_button, .ico_statistics').addClass("checked");
2840 }).on('mouseup', function () {
2841 $('#dio_statistic_button, .ico_statistics').removeClass("checked");
2842 });
2843
2844 $('#dio_statistic_button').click(function () {
2845 if (!Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_STATISTICS)) {
2846 Statistics.openWindow();
2847 $('#dio_statistic_button, .ico_statistics').addClass("checked");
2848 } else {
2849 Statistics.closeWindow();
2850 $('#dio_statistic_button, .ico_statistics').removeClass("checked");
2851 }
2852 });
2853 },
2854 openWindow: function () {
2855 var content =
2856 '<div id="dio_mouseclicks" style="margin-bottom:5px; font-style:italic;">' +
2857 '<span style="text-decoration:underline;">Insgesamt:</span> <span></span>' +
2858 '<span style="float:right;"></span><span style="text-decoration:underline;float:right;">Heute:</span> ' +
2859 '</div><canvas id="dio_graph" width="290" height="150" style="margin-top:15px;"></canvas>';
2860
2861 Layout.wnd.Create(GPWindowMgr.TYPE_DIO_STATISTICS).setContent(content);
2862
2863 Statistics.ClickCounter.onOpenWindow();
2864
2865 // Draw diagram
2866 var graph, xPadding = 35, yPadding = 25;
2867
2868 var data = {values: [{X: "Jan", Y: 0}]};
2869
2870 //console.log(DATA.clickCount);
2871 for (var o in DATA.clickCount) {
2872 data.values.push({X: "opp", Y: DATA.clickCount[o]});
2873 }
2874
2875 function getMaxY() {
2876 var max = 0;
2877 for (var i = 0; i < data.values.length; i++) {
2878 if (data.values[i].Y > max) {
2879 max = data.values[i].Y;
2880 }
2881 }
2882 max += 10 - max % 10;
2883 return max + 10;
2884 }
2885
2886 function getXPixel(val) {
2887 return ((graph.width() - xPadding) / data.values.length) * val + (xPadding + 10);
2888 }
2889
2890 function getYPixel(val) {
2891 return graph.height() - (((graph.height() - yPadding) / getMaxY()) * val) - yPadding;
2892 }
2893
2894 graph = $('#dio_graph');
2895 var c = graph[0].getContext('2d');
2896
2897 c.lineWidth = 2;
2898 c.strokeStyle = '#333';
2899 c.font = 'italic 8pt sans-serif';
2900 c.textAlign = "center";
2901
2902 // Axis
2903 c.beginPath();
2904 c.moveTo(xPadding, 0);
2905 c.lineTo(xPadding, graph.height() - yPadding);
2906 c.lineTo(graph.width(), graph.height() - yPadding);
2907 c.stroke();
2908
2909 // X-Axis caption
2910 for (var x = 0; x < data.values.length; x++) {
2911 c.fillText(data.values[x].X, getXPixel(x), graph.height() - yPadding + 20);
2912 }
2913
2914 // Y-Axis caption
2915 c.textAlign = "right";
2916 c.textBaseline = "middle";
2917
2918 var maxY = getMaxY(), maxYscala = Math.ceil(maxY / 1000) * 1000;
2919 //console.log(maxY);
2920 for (var y = 0; y < maxY; y += maxYscala / 10) {
2921 c.fillText(y, xPadding - 10, getYPixel(y));
2922 }
2923
2924 // Graph
2925 c.strokeStyle = 'rgb(0,150,0)';
2926 c.beginPath();
2927 c.moveTo(getXPixel(0), getYPixel(data.values[0].Y));
2928
2929 for (var i = 1; i < data.values.length; i++) {
2930 c.lineTo(getXPixel(i), getYPixel(data.values[i].Y));
2931 }
2932 c.stroke();
2933
2934 // Points
2935 c.fillStyle = '#333';
2936
2937 for (var p = 0; p < data.values.length; p++) {
2938 c.beginPath();
2939 c.arc(getXPixel(p), getYPixel(data.values[p].Y), 2, 0, Math.PI * 2, true);
2940 c.fill();
2941 }
2942 },
2943 closeWindow: function () {
2944 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_STATISTICS).close();
2945 },
2946
2947 ClickCounter: {
2948 today: "00000000",
2949 activate: function () {
2950 Statistics.ClickCounter.updateDate();
2951
2952 $(document).on("mousedown", function () {
2953 DATA.clickCount[Statistics.ClickCounter.today]++;
2954 });
2955
2956 window.onbeforeunload = function () {
2957 Statistics.ClickCounter.save();
2958 };
2959
2960 // TODO: Update date
2961 setTimeout(function () {
2962 Statistics.ClickCounter.updateDate();
2963 }, 0);
2964 },
2965 deactivate: function () {
2966 $(document).off("mousedown");
2967 },
2968 save: function () {
2969 saveValue(WID + "_click_count", JSON.stringify(DATA.clickCount));
2970 },
2971 updateDate: function () {
2972 var today = new Date((window.Timestamp.server() + 7200) * 1000);
2973
2974 Statistics.ClickCounter.today = today.getUTCFullYear() + ((today.getUTCMonth() + 1) < 10 ? "0" : "") + (today.getUTCMonth() + 1) + (today.getUTCDate() < 10 ? "0" : "") + today.getUTCDate();
2975
2976 DATA.clickCount[Statistics.ClickCounter.today] = DATA.clickCount[Statistics.ClickCounter.today] || 0;
2977 },
2978 onOpenWindow: function () {
2979 $('#dio_mouseclicks span:eq(2)').get(0).innerHTML = DATA.clickCount[Statistics.ClickCounter.today];
2980 $(document).off("mousedown");
2981 $(document).on("mousedown", function () {
2982 if ($('#dio_mouseclicks').get(0)) {
2983 $('#dio_mouseclicks span:eq(2)').get(0).innerHTML = ++DATA.clickCount[Statistics.ClickCounter.today];
2984 } else {
2985 DATA.clickCount[Statistics.ClickCounter.today]++;
2986 $(document).off("mousedown");
2987 $(document).on("mousedown", function () {
2988 DATA.clickCount[Statistics.ClickCounter.today]++;
2989 });
2990 }
2991 });
2992 }
2993 },
2994 LuckCounter: {
2995 luckArray: {},
2996 count: function () {
2997 if ($('.fight_bonus.luck').get(0)) {
2998 var report_id = $('#report_report_header .game_arrow_delete').attr("onclick").split(",")[1].split(")")[0].trim(),
2999 luck = parseInt($('.fight_bonus.luck').get(0).innerHTML.split(":")[1].split("%")[0].trim(), 10);
3000
3001 Statistics.LuckCounter.luckArray[report_id] = luck;
3002
3003 //console.log(Statistics.LuckCounter.calcAverage());
3004 }
3005 },
3006 calcAverage: function () {
3007 var sum = 0, count = 0;
3008 for (var report_id in Statistics.LuckCounter.luckArray) {
3009 if (Statistics.LuckCounter.luckArray.hasOwnProperty(report_id)) {
3010 sum += parseInt(Statistics.LuckCounter.luckArray[report_id], 10);
3011 count++;
3012 }
3013 }
3014 return (parseFloat(sum) / parseFloat(count));
3015 }
3016 }
3017 };
3018
3019 /*******************************************************************************************************************************
3020 * Body Handler
3021 * ----------------------------------------------------------------------------------------------------------------------------
3022 * | ● Town icon
3023 * | ● Town list: Adds town type to the town list
3024 * | ● Swap Context Icons
3025 * | ● City overview
3026 * ----------------------------------------------------------------------------------------------------------------------------
3027 *******************************************************************************************************************************/
3028
3029 function imageSelectionProtection() {
3030 $('<style id="dio_image_selection" type="text/css"> img { -moz-user-select: -moz-none; -khtml-user-select: none; -webkit-user-select: none;} </style>').appendTo('head');
3031 }
3032
3033 var worldWonderIcon = {
3034 colossus_of_rhodes: "url(https://gpall.innogamescdn.com/images/game/map/wonder_colossus_of_rhodes.png) 38px -1px;",
3035 great_pyramid_of_giza: "url(https://gpall.innogamescdn.com/images/game/map/wonder_great_pyramid_of_giza.png) 34px -6px;",
3036 hanging_gardens_of_babylon: "url(https://gpall.innogamescdn.com/images/game/map/wonder_hanging_gardens_of_babylon.png) 34px -5px;",
3037 lighthouse_of_alexandria: "url(https://gpall.innogamescdn.com/images/game/map/wonder_lighthouse_of_alexandria.png) 37px -1px;",
3038 mausoleum_of_halicarnassus: "url(https://gpall.innogamescdn.com/images/game/map/wonder_mausoleum_of_halicarnassus.png) 37px -4px;",
3039 statue_of_zeus_at_olympia: "url(https://gpall.innogamescdn.com/images/game/map/wonder_statue_of_zeus_at_olympia.png) 36px -3px;",
3040 temple_of_artemis_at_ephesus: "url(https://gpall.innogamescdn.com/images/game/map/wonder_temple_of_artemis_at_ephesus.png) 34px -5px;"
3041 };
3042
3043 var WorldWonderIcons = {
3044 activate: function () {
3045 try {
3046 if (!$('#dio_wondericons').get(0)) {
3047 var color = "orange";
3048
3049 // style for world wonder icons
3050 var style_str = "<style id='dio_wondericons' type='text/css'>";
3051 for (var ww_type in wonder.map) {
3052 if (wonder.map.hasOwnProperty(ww_type)) {
3053 for (var ww in wonder.map[ww_type]) {
3054 if (wonder.map[ww_type].hasOwnProperty(ww)) {
3055 /*
3056 if(wonder.map[ww_type][ww] !== AID){
3057 color = "rgb(192, 109, 54)";
3058 } else {
3059 color = "orange";
3060 }
3061 */
3062 style_str += "#mini_i" + ww + ":before {" +
3063 "content: '';" +
3064 "background:" + color + " " + worldWonderIcon[ww_type] +
3065 "background-size: auto 97%;" +
3066 "padding: 8px 16px;" +
3067 "top: 50px;" +
3068 "position: relative;" +
3069 "border-radius: 40px;" +
3070 "z-index: 200;" +
3071 "cursor: pointer;" +
3072 "box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5);" +
3073 "border: 2px solid green; } " +
3074 "#mini_i" + ww + ":hover:before { z-index: 201; " +
3075 "filter: url(#Brightness12);" +
3076 "-webkit-filter: brightness(1.2); } ";
3077 }
3078 }
3079 }
3080 }
3081 $(style_str + "</style>").appendTo('head');
3082
3083 // Context menu on mouseclick
3084 $('#minimap_islands_layer').on('click', '.m_island', function (e) {
3085 var ww_coords = this.id.split("i")[3].split("_");
3086 uw.Layout.contextMenu(e, 'wonder', {ix: ww_coords[0], iy: ww_coords[1]});
3087 });
3088
3089
3090 }
3091 } catch (error) {
3092 errorHandling(error, "setWonderIconsOnMap");
3093 }
3094 },
3095 deactivate: function () {
3096 $('#dio_wondericons').remove();
3097 }
3098 };
3099
3100 var TownIcons = {
3101 types: {
3102 // Automatic Icons
3103 lo: 0,
3104 ld: 3,
3105 so: 6,
3106 sd: 7,
3107 fo: 10,
3108 fd: 9,
3109 bu: 14, /* Building */
3110 po: 22,
3111 no: 12,
3112
3113 // Manual Icons
3114 fa: 20, /* Favor */
3115 re: 15, /* Resources */
3116 di: 2, /* Distance */
3117 sh: 1, /* Pierce */
3118 lu: 13, /* ?? */
3119 dp: 11, /* Diplomacy */
3120 ha: 15, /* ? */
3121 si: 18, /* Silber */
3122 ra: 17,
3123 ch: 19, /* Research */
3124 ti: 23, /* Time */
3125 un: 5,
3126 wd: 16, /* Wood */
3127 wo: 24, /* World */
3128 bo: 13, /* Booty */
3129 gr: 21, /* Lorbeer */
3130 st: 17, /* Stone */
3131 is: 26, /* ?? */
3132 he: 4, /* Helmet */
3133 ko: 8 /* Kolo */
3134
3135 },
3136 deactivate: function () {
3137 $('#town_icon').remove();
3138 $('#dio_townicons_field').remove();
3139
3140 TownPopup.deactivate();
3141 },
3142 activate: function () {
3143 try {
3144 $('<div id="town_icon"><div class="town_icon_bg"><div class="icon_big townicon_' +
3145 (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no") + " auto")) + '"></div></div></div>').appendTo('.town_name_area');
3146
3147 // Town Icon Style
3148 $('#town_icon .icon_big').css({
3149 backgroundPosition: TownIcons.types[(manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")))] * -25 + 'px 0px'
3150 });
3151 //console.debug(dio_sprite);
3152 $('<style id="dio_townicons_field" type="text/css">' +
3153 '#town_icon { background:url(' + dio_sprite + ') 0 -125px no-repeat; position:absolute; width:69px; height:61px; left:-47px; top:0px; z-index: 10; } ' +
3154 '#town_icon .town_icon_bg { background:url(' + dio_sprite + ') -76px -129px no-repeat; width:43px; height:43px; left:25px; top:4px; cursor:pointer; position: relative; } ' +
3155 '#town_icon .town_icon_bg:hover { filter:url(#Brightness11); -webkit-filter:brightness(1.1); box-shadow: 0px 0px 15px rgb(1, 197, 33); } ' +
3156 '#town_icon .icon_big { position:absolute; left:9px; top:9px; height:25px; width:25px; } ' +
3157
3158 '#town_icon .select_town_icon {position: absolute; top:47px; left:23px; width:145px; display:none; padding:2px; border:3px inset rgb(7, 99, 12); box-shadow:rgba(0, 0, 0, 0.5) 4px 4px 6px; border-radius:0px 10px 10px 10px;' +
3159 'background:url(https://gpall.innogamescdn.com/images/game/popup/middle_middle.png); } ' +
3160 '#town_icon .item-list { max-height:400px; max-width:200px; align:right; overflow-x:hidden; } ' +
3161
3162 '#town_icon .option_s { cursor:pointer; width:20px; height:20px; margin:0px; padding:2px 2px 3px 3px; border:2px solid rgba(0,0,0,0); border-radius:5px; background-origin:content-box; background-clip:content-box;} ' +
3163 '#town_icon .option_s:hover { border: 2px solid rgb(59, 121, 81) !important;-webkit-filter: brightness(1.3); } ' +
3164 '#town_icon .sel { border: 2px solid rgb(202, 176, 109); } ' +
3165 '#town_icon hr { width:145px; margin:0px 0px 7px 0px; position:relative; top:3px; border:0px; border-top:2px dotted #000; float:left} ' +
3166 '#town_icon .auto_s { width:136px; height:16px; float:left} ' +
3167
3168 // Quickbar modification
3169 '.ui_quickbar .left, .ui_quickbar .right { width:46%; } ' +
3170
3171 // because of Kapsonfires Script and Beta Worlds bug report bar:
3172 '.town_name_area { z-index:11; left:52%; } ' +
3173 '.town_name_area .left { z-index:20; left:-39px; } ' +
3174 '</style>').appendTo('head');
3175
3176
3177 var icoArray = ['ld', 'lo', 'sh', 'di', 'un',
3178 'sd', 'so', 'ko', 'ti', 'gr',
3179 'fd', 'fo', 'dp', 'no', 'po',
3180 're', 'wd', 'st', 'si', 'bu',
3181 'he', 'ch', 'bo', 'fa', 'wo'];
3182
3183 // Fill select box with town icons
3184 $('<div class="select_town_icon dropdown-list default active"><div class="item-list"></div></div>').appendTo("#town_icon");
3185 for (var i in icoArray) {
3186 if (icoArray.hasOwnProperty(i)) {
3187 $('.select_town_icon .item-list').append('<div class="option_s icon_small townicon_' + icoArray[i] + '" name="' + icoArray[i] + '"></div>');
3188 }
3189 }
3190 $('<hr><div class="option_s auto_s" name="auto"><b>Auto</b></div>').appendTo('.select_town_icon .item-list');
3191
3192 $('#town_icon .option_s').click(function () {
3193 $("#town_icon .sel").removeClass("sel");
3194 $(this).addClass("sel");
3195
3196 if ($(this).attr("name") === "auto") {
3197 delete manuTownTypes[uw.Game.townId];
3198 } else {
3199 manuTownTypes[uw.Game.townId] = $(this).attr("name");
3200 }
3201 TownIcons.changeTownIcon();
3202
3203 // Update town icons on the map
3204 TownIcons.Map.activate(); //setOnMap();
3205
3206 saveValue(WID + "_townTypes", JSON.stringify(manuTownTypes));
3207 });
3208
3209 // Show & hide drop menus on click
3210 $('#town_icon .town_icon_bg').click(function () {
3211 var el = $('#town_icon .select_town_icon').get(0);
3212 if (el.style.display === "none") {
3213 el.style.display = "block";
3214 } else {
3215 el.style.display = "none";
3216 }
3217 });
3218
3219 $('#town_icon .select_town_icon [name="' + (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" : "" )) + '"]').addClass("sel");
3220
3221 } catch (error) {
3222 errorHandling(error, "addTownIcon");
3223 }
3224 },
3225 changeTownIcon: function () {
3226 var townType = (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")));
3227 $('#town_icon .icon_big').removeClass().addClass('icon_big townicon_' + townType + " auto");
3228 $('#town_icon .sel').removeClass("sel");
3229 $('#town_icon .select_town_icon [name="' + (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" : "" )) + '"]').addClass("sel");
3230
3231 $('#town_icon .icon_big').css({
3232 backgroundPosition: TownIcons.types[townType] * -25 + 'px 0px'
3233 });
3234
3235 $('#town_icon .select_town_icon').get(0).style.display = "none";
3236 },
3237 Map: {
3238 // TODO: activate aufspliten in activate und add
3239 activate: function () {
3240 try {
3241 // if town icon changed
3242 if ($('#dio_townicons_map').get(0)) {
3243 $('#dio_townicons_map').remove();
3244 }
3245
3246 // Style for own towns (town icons)
3247 var start = (new Date()).getTime(), end, style_str = "<style id='dio_townicons_map' type='text/css'>";
3248 for (var e in autoTownTypes) {
3249 if (autoTownTypes.hasOwnProperty(e)) {
3250 style_str += "#mini_t" + e + ", #town_flag_"+ e + " .flagpole {"+
3251 "background: rgb(255, 187, 0) url(" + dio_sprite + ") " + (TownIcons.types[(manuTownTypes[e] || autoTownTypes[e])] * -25) + "px -27px repeat !important; } ";
3252 }
3253 }
3254
3255 style_str += ".own_town .flagpole, #main_area .m_town.player_"+ PID +" { z-index: 100 !important; cursor: pointer; width:19px; height:19px; border-radius: 11px; border: 2px solid rgb(16, 133, 0); margin: -4px !important; font-size: 0em !important; box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5); } ";
3256
3257 // Mouseover Effect
3258 style_str += ".own_town .flagpole:hover, .m_town:hover { z-index: 101 !important; filter: brightness(1.2); -webkit-filter: brightness(1.2); font-size: 2em; margin-top: -1px; } ";
3259
3260
3261 // Context menu on mouse click
3262 style_str += "#minimap_islands_layer .m_town { z-index: 99; cursor: pointer; } ";
3263
3264 $('#minimap_islands_layer').off('click', '.m_town');
3265 $('#minimap_islands_layer').on('click', '.m_town', function (z) {
3266 var id = parseInt(this.id.substring(6), 10);
3267
3268 // Town names of foreign towns are unknown
3269 if(typeof(uw.ITowns.getTown(id)) !== "undefined") {
3270 Layout.contextMenu(z, 'determine', {"id": id, "name": uw.ITowns.getTown(id).name});
3271 }
3272 else {
3273 // No town name in the title of the window
3274 Layout.contextMenu(z, 'determine', {"id": id });
3275 }
3276
3277 // Prevent parent world wonder event
3278 z.stopPropagation();
3279 });
3280
3281 $('#minimap_islands_layer').off("mousedown");
3282 $('#minimap_islands_layer').on("mousedown", function(){
3283
3284 if(typeof($('#context_menu').get(0)) !== "undefined"){
3285 $('#context_menu').get(0).remove();
3286 }
3287 });
3288
3289
3290 // Town Popup for own towns
3291 style_str += "#dio_town_popup .count { position: absolute; bottom: 1px; right: 1px; font-size: 10px; } ";
3292
3293 // Town Popups on Strategic map
3294 $('#minimap_islands_layer').off('mouseout', '.m_town');
3295 $('#minimap_islands_layer').on('mouseout', '.m_town', function () {
3296 TownPopup.remove();
3297 });
3298 $('#minimap_islands_layer').off('mouseover', '.m_town');
3299 $('#minimap_islands_layer').on('mouseover', '.m_town', function () {
3300 TownPopup.add(this);
3301 });
3302
3303 // Town Popups on island view
3304 $('#map_towns').off('mouseout', '.own_town .flagpole');
3305 $('#map_towns').on('mouseout', '.own_town .flagpole', function () {
3306 TownPopup.remove();
3307 });
3308 $('#map_towns').off('mouseover', '.own_town .flagpole');
3309 $('#map_towns').on('mouseover', '.own_town .flagpole', function () {
3310 TownPopup.add(this);
3311 });
3312
3313
3314 // Style for foreign cities (shadow)
3315 style_str += "#minimap_islands_layer .m_town { text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.7); } ";
3316
3317 // Style for night mode
3318 style_str += "#minimap_canvas.expanded.night, #map.night .flagpole { filter: brightness(0.7); -webkit-filter: brightness(0.7); } ";
3319 style_str += "#minimap_click_layer { display:none; }";
3320
3321 style_str += "</style>";
3322 $(style_str).appendTo('head');
3323
3324
3325 } catch (error) {
3326 errorHandling(error, "TownIcons.Map.activate");
3327 }
3328 },
3329 deactivate: function () {
3330 $('#dio_townicons_map').remove();
3331
3332 // Events entfernen
3333 $('#minimap_islands_layer').off('click', '.m_town');
3334 $('#minimap_islands_layer').off("mousedown");
3335
3336 $('#minimap_islands_layer').off('mouseout', '.m_town');
3337 $('#minimap_islands_layer').off('mouseover', '.m_town');
3338 }
3339 }
3340 };
3341
3342 var TownPopup = {
3343 activate : function(){
3344
3345 $('<style id="dio_town_popup_style" type="text/css">' +
3346 '#dio_town_popup { position:absolute; z-index:99;max-width: 173px;} ' +
3347
3348 '#dio_town_popup .title { margin:5px;font-weight: bold; } ' +
3349
3350 '#dio_town_popup .dio_branding { position:absolute; right:12px; top:8px; height: 20px; filter:sepia(1); -webkit-filter:sepia(1); opacity:0.5; } ' +
3351
3352 '#dio_town_popup .unit_content, ' +
3353 '#dio_town_popup .spy_content, ' +
3354 '#dio_town_popup .god_content, ' +
3355 '#dio_town_popup .resources_content { background-color: #ffe2a1; border: 1px solid #e1af55; margin-top:2px; padding: 4px; font-family: Arial;font-weight: 700;font-size: 0.8em; } ' +
3356 '#dio_town_popup .resources_content { text-align: right; margin-top:3px; } ' +
3357
3358 '#dio_town_popup .resources_content table { min-width:95% } ' +
3359
3360 '#dio_town_popup .footer_content { margin-top:3px; } ' +
3361 '#dio_town_popup .footer_content table { width:100%; } ' +
3362
3363 '#dio_town_popup .spy_content { height:25px; margin-right:3px; } ' +
3364 '#dio_town_popup .god_content { width:24px; } ' +
3365
3366 '#dio_town_popup .god_mini { height: 25px; width: 32px; background-size: 75%; background-position: 0px -122px; margin-right: -8px; } ' +
3367
3368 // God Icon
3369 '#dio_town_popup .god_mini.zeus { background-position: 0px 0px; } ' +
3370 '#dio_town_popup .god_mini.athena { background-position: 0px -24px; } ' +
3371 '#dio_town_popup .god_mini.poseidon { background-position: 0px -49px; } ' +
3372 '#dio_town_popup .god_mini.hera { background-position: 0px -73px; } ' +
3373 '#dio_town_popup .god_mini.hades { background-position: 0px -98px; } ' +
3374 '#dio_town_popup .god_mini.artemis { background-position: 0px -146px; } ' +
3375
3376 '#dio_town_popup .count { position: absolute; bottom: -2px; right: 2px; font-size: 10px; font-family: Verdana,Arial,Helvetica,sans-serif; } ' +
3377 '#dio_town_popup .four_digit_number .count { font-size:8px !important; } ' +
3378 '#dio_town_popup .unit_icon25x25 { border: 1px solid #6e4b0b; margin: 1px; } ' +
3379 '#dio_town_popup .wall { width:25px; height:25px; background-image:url(https://gpde.innogamescdn.com/images/game/main/wall.png); border: 1px solid #6e4b0b; margin: 1px; display: inline-block; vertical-align: middle; background-size: 100%; } ' +
3380
3381 // Spy Icon
3382 '#dio_town_popup .support_filter { margin: 0px 4px 0px 0px; float:left; } ' +
3383 '#dio_town_popup .spy_text { line-height: 2.3em; float:left; } ' +
3384
3385 // Bei langen Stadtnamen wird sonst der Rand abgeschnitten:
3386 '#dio_town_popup .popup_middle_right { min-width: 11px; } ' +
3387
3388 '</style>').appendTo('head');
3389
3390 },
3391 deactivate : function(){
3392 $("#dio_town_popup_style").remove();
3393 },
3394 add : function(that){
3395 var townID = 0;
3396 //console.debug("TOWN", $(that).offset(), that.id);
3397
3398 if(that.id === ""){
3399 // Island view
3400 townID = parseInt($(that).parent()[0].id.substring(10), 10);
3401 }
3402 else {
3403 // Strategic map
3404 townID = parseInt(that.id.substring(6), 10);
3405 }
3406
3407 // Own town?
3408 if (typeof(uw.ITowns.getTown(townID)) !== "undefined") {
3409
3410 var units = ITowns.getTowns()[townID].units();
3411
3412 TownPopup.remove();
3413
3414 // var popup = "<div id='dio_town_popup' style='left:" + ($(that).offset().left + 20) + "px; top:" + ($(that).offset().top + 20) + "px; '>";
3415 var popup = "<table class='popup' id='dio_town_popup' style='left:" + ($(that).offset().left + 20) + "px; top:" + ($(that).offset().top + 20) + "px; ' cellspacing='0px' cellpadding='0px'>";
3416
3417 popup += "<tr class='popup_top'><td class='popup_top_left'></td><td class='popup_top_middle'></td><td class='popup_top_right'></td></tr>";
3418
3419 popup += "<tr><td class='popup_middle_left'> </td><td style='width: auto;' class='popup_middle_middle'>";
3420
3421 // Title (town name)
3422 popup += "<h4><span style='white-space: nowrap;margin-right:35px;'>" + uw.ITowns.getTown(townID).name + "</span><img class='dio_branding' src='http://666kb.com/i/cifvfsu3e2sdiipn0.gif'></h4>";
3423
3424 // Unit Container
3425 popup += "<div class='unit_content'>";
3426 if(!$.isEmptyObject(units)) {
3427
3428 for (var unit_id in units) {
3429 if (units.hasOwnProperty(unit_id)) {
3430
3431 var classSize = "";
3432
3433 if(units[unit_id] > 1000){
3434 classSize = "four_digit_number";
3435 }
3436
3437 // Unit
3438 popup += '<div class="unit_icon25x25 ' + unit_id + ' '+ classSize +'"><span class="count text_shadow">' + units[unit_id] + '</span></div>';
3439 }
3440 }
3441 }
3442
3443 // - Wall
3444 var wallLevel = ITowns.getTowns()[townID].getBuildings().attributes.wall;
3445 popup += '<div class="wall image bold"><span class="count text_shadow">'+ wallLevel +'</span></div>';
3446
3447 popup += "</div>";
3448
3449 // Resources Container
3450 popup += "<div class='resources_content'><table cellspacing='2px' cellpadding='0px'><tr>";
3451
3452 var resources = ITowns.getTowns()[townID].resources();
3453 var storage = ITowns.getTowns()[townID].getStorage();
3454
3455 // - Wood
3456 var textColor = (resources.wood === storage) ? textColor = "color:red;" : textColor = "";
3457 popup += '<td class="resources_small wood"></td><td style="'+ textColor +'; width:1%;">' + resources.wood + '</td>';
3458
3459 popup += '<td style="min-width:15px;"></td>';
3460
3461 // - Population
3462 popup += '<td class="resources_small population"></td><td style="width:1%">' + resources.population + '</td>';
3463
3464 popup += '</tr><tr>';
3465
3466 // - Stone
3467 textColor = (resources.stone === storage) ? textColor = "color:red;" : textColor = "";
3468 popup += '<td class="resources_small stone"></td><td style="'+ textColor +'">' + resources.stone + '</td>';
3469
3470 popup += '</tr><tr>';
3471
3472 // - Iron
3473 textColor = (resources.iron === storage) ? textColor = "color:red;" : textColor = "";
3474 popup += '<td class="resources_small iron"></td><td style="'+ textColor +'">' + resources.iron + '</td>';
3475
3476
3477 popup += "</tr></table></div>";
3478
3479 // console.debug("TOWNINFO", ITowns.getTowns()[townID]);
3480
3481 // Spy and God Container
3482 popup += "<div class='footer_content'><table cellspacing='0px'><tr>";
3483
3484 var spy_storage = ITowns.getTowns()[townID].getEspionageStorage();
3485
3486 // - Spy content
3487 popup += "<td class='spy_content'>";
3488 popup += '<div class="support_filter attack_spy"></div><div class="spy_text">'+ pointNumber(spy_storage) +'</div>';
3489 popup += "</td>";
3490
3491 popup += "<td></td>";
3492
3493 // - God Content
3494 var god = ITowns.getTowns()[townID].god();
3495
3496 popup += "<td class='god_content'>";
3497 popup += '<div class="god_mini '+ god +'"></div>';
3498 popup += "</td>";
3499
3500 popup += "</tr></table></div>";
3501
3502
3503
3504 popup += "</td><td class='popup_middle_right'> </td></tr>";
3505
3506 popup += "<tr class='popup_bottom'><td class='popup_bottom_left'></td><td class='popup_bottom_middle'></td><td class='popup_bottom_right'></td></tr>";
3507
3508 popup += "</table>";
3509
3510 $(popup).appendTo("#popup_div_curtain");
3511 }
3512 },
3513 remove : function(){
3514 $('#dio_town_popup').remove();
3515 }
3516 };
3517
3518 // Style for town icons
3519 var style_str = '<style id="dio_townicons" type="text/css">';
3520 for (var s in TownIcons.types) {
3521 if (TownIcons.types.hasOwnProperty(s)) {
3522 style_str += '.townicon_' + s + ' { background:url(' + dio_sprite + ') ' + (TownIcons.types[s] * -25) + 'px -26px repeat;float:left;} ';
3523 }
3524 }
3525 style_str += '</style>';
3526 $(style_str).appendTo('head');
3527
3528
3529 var ContextMenu = {
3530 activate: function () {
3531 // Set context menu event handler
3532 $.Observer(uw.GameEvents.map.context_menu.click).subscribe('DIO_CONTEXT', function (e, data) {
3533 if (DATA.options.con && $('#context_menu').children().length == 4) {
3534 // Clear animation
3535 $('#context_menu div#goToTown').css({
3536 left: '0px',
3537 top: '0px',
3538 WebkitAnimation: 'none', //'A 0s linear',
3539 animation: 'none' //'B 0s linear'
3540 });
3541 }
3542 // Replace german label of 'select town' button
3543 if (LID === "de" && $('#select_town').get(0)) {
3544 $("#select_town .caption").get(0).innerHTML = "Selektieren";
3545 }
3546 });
3547
3548 // Set context menu animation
3549 $('<style id="dio_context_menu" type="text/css">' +
3550 // set fixed position of 'select town' button
3551 '#select_town { left: 0px !important; top: 0px !important; z-index: 6; } ' +
3552 // set animation of 'goToTown' button
3553 '#context_menu div#goToTown { left: 30px; top: -51px; ' +
3554 '-webkit-animation: A 0.115s linear; animation: B 0.2s;} ' +
3555 '@-webkit-keyframes A { from {left: 0px; top: 0px;} to {left: 30px; top: -51px;} }' +
3556 '@keyframes B { from {left: 0px; top: 0px;} to {left: 30px; top: -51px;} }' +
3557 '</style>').appendTo('head');
3558 },
3559 deactivate: function () {
3560 $.Observer(uw.GameEvents.map.context_menu.click).unsubscribe('DIO_CONTEXT');
3561
3562 $('#dio_context_menu').remove();
3563 }
3564 };
3565
3566
3567 var TownList = {
3568 activate: function () {
3569 // Style town list
3570 $('<style id="dio_town_list" type="text/css">' +
3571 '#town_groups_list .item { text-align: left; padding-left:35px; } ' +
3572 '#town_groups_list .inner_column { border: 1px solid rgba(100, 100, 0, 0.3);margin: -2px 0px 0px 2px; } ' +
3573 '#town_groups_list .island_quest_icon { position: absolute; right: 37px; top: 3px; } ' +
3574 '#town_groups_list .island_quest_icon.hidden_icon { display:none; } ' +
3575 // Quacks Zentrier-Button verschieben
3576 '#town_groups_list .jump_town { right: 37px !important; } ' +
3577 // Population percentage
3578 '#town_groups_list .pop_percent { position: absolute; right: 7px; top:0px; font-size: 0.7em; display:block !important;} ' +
3579 '#town_groups_list .full { color: green; } ' +
3580 '#town_groups_list .threequarter { color: darkgoldenrod; } ' +
3581 '#town_groups_list .half { color: darkred; } ' +
3582 '#town_groups_list .quarter { color: red; } ' +
3583 '</style>').appendTo('head');
3584
3585
3586 // Open town list: hook to grepolis function render()
3587 var i = 0;
3588 while (uw.layout_main_controller.sub_controllers[i].name != 'town_name_area') {
3589 i++;
3590 }
3591
3592 uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render_old = uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render;
3593
3594 uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render = function () {
3595 uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render_old();
3596 TownList.change();
3597 };
3598
3599 // Town List open?
3600 if ($('#town_groups_list').get(0)) {
3601 TownList.change();
3602 }
3603 },
3604 deactivate: function () {
3605 var i = 0;
3606 while (uw.layout_main_controller.sub_controllers[i].name != 'town_name_area') {
3607 i++;
3608 }
3609
3610 layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render = layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render_old;
3611
3612 $('#dio_town_list').remove();
3613
3614 $('#town_groups_list .small_icon, #town_groups_list .pop_percent').css({display: 'none'});
3615
3616 //$.Observer(uw.GameEvents.town.town_switch).unsubscribe('DIO_SWITCH_TOWN');
3617
3618 $("#town_groups_list .town_group_town").unbind('mouseenter mouseleave');
3619 },
3620 change: function () {
3621 if (!$('#town_groups_list .icon_small').get(0) && !$('#town_groups_list .pop_percent').get(0)) {
3622 $("#town_groups_list .town_group_town").each(function () {
3623 try {
3624 var town_item = $(this), town_id = town_item.attr('name'), townicon_div, percent_div = "", percent = -1, pop_space = "full";
3625
3626 if (population[town_id]) {
3627 percent = population[town_id].percent;
3628 }
3629 if (percent < 75) {
3630 pop_space = "threequarter";
3631 }
3632 if (percent < 50) {
3633 pop_space = "half";
3634 }
3635 if (percent < 25) {
3636 pop_space = "quarter";
3637 }
3638
3639 if (!town_item.find('icon_small').length) {
3640 townicon_div = '<div class="icon_small townicon_' + (manuTownTypes[town_id] || autoTownTypes[town_id] || "no") + '"></div>';
3641 // TODO: Notlösung...
3642 if (percent != -1) {
3643 percent_div = '<div class="pop_percent ' + pop_space + '">' + percent + '%</div>';
3644 }
3645 town_item.prepend(townicon_div + percent_div);
3646 }
3647
3648 // opening context menu
3649 /*
3650 $(this).click(function(e){
3651 console.log(e);
3652 uw.Layout.contextMenu(e, 'determine', {"id": town_id,"name": uw.ITowns[town_id].getName()});
3653 });
3654 */
3655
3656 } catch (error) {
3657 errorHandling(error, "TownList.change");
3658 }
3659 });
3660
3661 }
3662
3663 // Hover Effect for Quacks Tool:
3664 $("#town_groups_list .town_group_town").hover(function () {
3665 $(this).find('.island_quest_icon').addClass("hidden_icon");
3666 }, function () {
3667 $(this).find('.island_quest_icon').removeClass("hidden_icon");
3668 });
3669
3670 // Add change town list event handler
3671 //$.Observer(uw.GameEvents.town.town_switch).subscribe('DIO_SWITCH_TOWN', function () {
3672 //TownList.change();
3673 //});
3674 }
3675 };
3676
3677 var HiddenHighlightWindow = {
3678 activate : function(){
3679 // Style town list
3680 $('<style id="dio_hidden_highlight_window" type="text/css">' +
3681 '.strategic_map_filter { display:none !important; } ' +
3682 '</style>').appendTo('head');
3683 },
3684 deactivate : function (){
3685 $('#dio_hidden_highlight_window').remove();
3686 }
3687 };
3688
3689 /*******************************************************************************************************************************
3690 * Available units
3691 * ----------------------------------------------------------------------------------------------------------------------------
3692 * | ● GetAllUnits
3693 * | ● Shows all available units
3694 * ----------------------------------------------------------------------------------------------------------------------------
3695 *******************************************************************************************************************************/
3696 var groupUnitArray = {};
3697 // TODO: split Function (getUnits, calcUnitsSum, availableUnits, countBiremes, getTownTypes)?
3698
3699 // Alter Einheitenzähler
3700 function getAllUnits() {
3701 try {
3702 var townArray = uw.ITowns.getTowns(), groupArray = uw.ITowns.townGroups.getGroupsDIO(),
3703
3704 unitArray = {
3705 "sword": 0,
3706 "archer": 0,
3707 "hoplite": 0,
3708 "chariot": 0,
3709 "godsent": 0,
3710 "rider": 0,
3711 "slinger": 0,
3712 "catapult": 0,
3713 "small_transporter": 0,
3714 "big_transporter": 0,
3715 "manticore": 0,
3716 "harpy": 0,
3717 "pegasus": 0,
3718 "cerberus": 0,
3719 "minotaur": 0,
3720 "medusa": 0,
3721 "zyklop": 0,
3722 "centaur": 0,
3723 "fury": 0,
3724 "sea_monster": 0
3725 },
3726
3727 unitArraySea = {"bireme": 0, "trireme": 0, "attack_ship": 0, "demolition_ship": 0, "colonize_ship": 0};
3728
3729 //console.debug("DIO-TOOLS | getAllUnits | GROUP ARRAY", groupArray);
3730
3731
3732 if (uw.Game.hasArtemis) {
3733 unitArray = $.extend(unitArray, {"griffin": 0, "calydonian_boar": 0});
3734 }
3735 unitArray = $.extend(unitArray, unitArraySea);
3736
3737 for (var group in groupArray) {
3738 if (groupArray.hasOwnProperty(group)) {
3739 // Clone Object "unitArray"
3740 groupUnitArray[group] = Object.create(unitArray);
3741
3742 for (var town in groupArray[group].towns) {
3743 if (groupArray[group].towns.hasOwnProperty(town)) {
3744 var type = {lo: 0, ld: 0, so: 0, sd: 0, fo: 0, fd: 0}; // Type for TownList
3745
3746 for (var unit in unitArray) {
3747 if (unitArray.hasOwnProperty(unit)) {
3748 // All Groups: Available units
3749 var tmp = parseInt(uw.ITowns.getTown(town).units()[unit], 10);
3750 groupUnitArray[group][unit] += tmp || 0;
3751 // Only for group "All"
3752 if (group == -1) {
3753 // Bireme counter // old
3754 if (unit === "bireme" && ((biriArray[townArray[town].id] || 0) < (tmp || 0))) {
3755 biriArray[townArray[town].id] = tmp;
3756 }
3757 //TownTypes
3758 if (!uw.GameData.units[unit].is_naval) {
3759 if (uw.GameData.units[unit].flying) {
3760 type.fd += ((uw.GameData.units[unit].def_hack + uw.GameData.units[unit].def_pierce + uw.GameData.units[unit].def_distance) / 3 * (tmp || 0));
3761 type.fo += (uw.GameData.units[unit].attack * (tmp || 0));
3762 } else {
3763 type.ld += ((uw.GameData.units[unit].def_hack + uw.GameData.units[unit].def_pierce + uw.GameData.units[unit].def_distance) / 3 * (tmp || 0));
3764 type.lo += (uw.GameData.units[unit].attack * (tmp || 0));
3765 }
3766 } else {
3767 type.sd += (uw.GameData.units[unit].defense * (tmp || 0));
3768 type.so += (uw.GameData.units[unit].attack * (tmp || 0));
3769 }
3770 }
3771 }
3772 }
3773 // Only for group "All"
3774 if (group == -1) {
3775 // Icon: DEF or OFF?
3776 var z = ((type.sd + type.ld + type.fd) <= (type.so + type.lo + type.fo)) ? "o" : "d",
3777 temp = 0;
3778
3779 for (var t in type) {
3780 if (type.hasOwnProperty(t)) {
3781 // Icon: Land/Sea/Fly (t[0]) + OFF/DEF (z)
3782 if (temp < type[t]) {
3783 autoTownTypes[townArray[town].id] = t[0] + z;
3784 temp = type[t];
3785 }
3786 // Icon: Troops Outside (overwrite)
3787 if (temp < 1000) {
3788 autoTownTypes[townArray[town].id] = "no";
3789 }
3790 }
3791 }
3792 // Icon: Empty Town (overwrite)
3793 var popBuilding = 0, buildVal = uw.GameData.buildings, levelArray = townArray[town].buildings().getLevels(),
3794 popMax = Math.floor(buildVal.farm.farm_factor * Math.pow(townArray[town].buildings().getBuildingLevel("farm"), buildVal.farm.farm_pow)), // Population from farm level
3795 popPlow = townArray[town].getResearches().attributes.plow ? 200 : 0,
3796 popFactor = townArray[town].getBuildings().getBuildingLevel("thermal") ? 1.1 : 1.0, // Thermal
3797 popExtra = townArray[town].getPopulationExtra();
3798
3799 for (var b in levelArray) {
3800 if (levelArray.hasOwnProperty(b)) {
3801 popBuilding += Math.round(buildVal[b].pop * Math.pow(levelArray[b], buildVal[b].pop_factor));
3802 }
3803 }
3804 population[town] = {};
3805
3806 population[town].max = popMax * popFactor + popPlow + popExtra;
3807 population[town].buildings = popBuilding;
3808 population[town].units = parseInt((population[town].max - (popBuilding + townArray[town].getAvailablePopulation()) ), 10);
3809
3810 if (population[town].units < 300) {
3811 autoTownTypes[townArray[town].id] = "po";
3812 }
3813
3814 population[town].percent = Math.round(100 / (population[town].max - popBuilding) * population[town].units);
3815 }
3816 }
3817 }
3818 }
3819 }
3820
3821 // Update Available Units
3822 AvailableUnits.updateBullseye();
3823 if (GPWindowMgr.TYPE_DIO_UNITS) {
3824 if (Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS)) {
3825 AvailableUnits.updateWindow();
3826 }
3827 }
3828 } catch (error) {
3829 errorHandling(error, "getAllUnits"); // TODO: Eventueller Fehler in Funktion
3830 }
3831 }
3832
3833 function addFunctionToITowns() {
3834 // Copy function and prevent an error
3835 uw.ITowns.townGroups.getGroupsDIO = function () {
3836 var town_groups_towns, town_groups, groups = {};
3837
3838 // #Grepolis Fix: 2.75 -> 2.76
3839 if (MM.collections) {
3840 town_groups_towns = MM.collections.TownGroupTown[0];
3841 town_groups = MM.collections.TownGroup[0];
3842 } else {
3843 town_groups_towns = MM.getCollections().TownGroupTown[0];
3844 town_groups = MM.getCollections().TownGroup[0];
3845 }
3846
3847 town_groups_towns.each(function (town_group_town) {
3848 var gid = town_group_town.getGroupId(),
3849 group = groups[gid],
3850 town_id = town_group_town.getTownId();
3851
3852 if (!group) {
3853 groups[gid] = group = {
3854 id: gid,
3855 //name: town_groups.get(gid).getName(), // hier tritt manchmal ein Fehler auf: TypeError: Cannot read property "getName" of undefined at http://_.grepolis.com/cache/js/merged/game.js?1407322916:8298:525
3856 towns: {}
3857 };
3858 }
3859
3860 group.towns[town_id] = {id: town_id};
3861 //groups[gid].towns[town_id]={id:town_id};
3862 });
3863 //console.log(groups);
3864 return groups;
3865 };
3866 }
3867
3868
3869 // Neuer Einheitenzähler
3870 var UnitCounter = {
3871 units : {"total":{}, "available":{}, "outer":{}, "foreign":{}},
3872
3873 count : function(){
3874 var tooltipHelper = require("helpers/units_tooltip_helper");
3875
3876 var groups = uw.ITowns.townGroups.getGroupsDIO();
3877
3878 for (var groupId in groups) {
3879 if (groups.hasOwnProperty(groupId)) {
3880
3881 UnitCounter.units.total[groupId] = {};
3882 UnitCounter.units.available[groupId] = {};
3883 UnitCounter.units.outer[groupId] = {};
3884
3885
3886 for (var townId in groups[groupId].towns) {
3887 if (groups[groupId].towns.hasOwnProperty(townId)) {
3888
3889 // Einheiten gesamt
3890 UnitCounter.units.total[groupId][townId] = ITowns.towns[townId].units();
3891
3892 // Einheiten verfügbar
3893 UnitCounter.units.available[groupId][townId] = ITowns.towns[townId].units();
3894
3895 // Einheiten außerhalb
3896 UnitCounter.units.outer[groupId][townId] = {};
3897
3898 var supports = tooltipHelper.getDataForSupportingUnitsInOtherTownFromCollection(MM.getTownAgnosticCollectionsByName("Units")[1].fragments[townId], MM.getOnlyCollectionByName("Town"));
3899
3900 for (var supportId in supports) {
3901 if (supports.hasOwnProperty(supportId)) {
3902
3903 for (var attributeId in supports[supportId].attributes) {
3904 if (supports[supportId].attributes.hasOwnProperty(attributeId)) {
3905
3906 // Attribut ist eine Einheit?
3907 if (typeof(GameData.units[attributeId]) !== "undefined" && supports[supportId].attributes[attributeId] > 0) {
3908
3909 UnitCounter.units.outer[groupId][townId][attributeId] = (UnitCounter.units.outer[groupId][townId][attributeId] || 0) + supports[supportId].attributes[attributeId];
3910
3911 UnitCounter.units.total[groupId][townId][attributeId] = (UnitCounter.units.total[groupId][townId][attributeId] || 0) + supports[supportId].attributes[attributeId];
3912 }
3913 }
3914 }
3915 }
3916 }
3917 }
3918 }
3919
3920 // Summen aller Städte berechnen
3921 UnitCounter.summarize(groupId);
3922 }
3923 }
3924
3925 return UnitCounter.units;
3926 },
3927
3928 summarize : function(groupId){
3929 var tooltipHelper = require("helpers/units_tooltip_helper");
3930
3931 UnitCounter.units.total[groupId]["all"] = {};
3932 UnitCounter.units.available[groupId]["all"] = {};
3933 UnitCounter.units.outer[groupId]["all"] = {};
3934
3935 for(var townId in UnitCounter.units.total[groupId]){
3936 if(UnitCounter.units.total[groupId].hasOwnProperty(townId) && townId !== "all"){
3937
3938 // Einheiten gesamt
3939 for(var unitId in UnitCounter.units.total[groupId][townId]){
3940 if(UnitCounter.units.total[groupId][townId].hasOwnProperty(unitId)){
3941
3942 UnitCounter.units.total[groupId]["all"][unitId] = (UnitCounter.units.total[groupId]["all"][unitId] || 0) + UnitCounter.units.total[groupId][townId][unitId];
3943 }
3944 }
3945
3946 // Einheiten verfügbar
3947 for(var unitId in UnitCounter.units.available[groupId][townId]){
3948 if(UnitCounter.units.available[groupId][townId].hasOwnProperty(unitId)){
3949
3950 UnitCounter.units.available[groupId]["all"][unitId] = (UnitCounter.units.available[groupId]["all"][unitId] || 0) + UnitCounter.units.available[groupId][townId][unitId];
3951 }
3952 }
3953
3954 // Einheiten außerhalb
3955 for(var unitId in UnitCounter.units.outer[groupId][townId]){
3956 if(UnitCounter.units.outer[groupId][townId].hasOwnProperty(unitId)){
3957
3958 UnitCounter.units.outer[groupId]["all"][unitId] = (UnitCounter.units.outer[groupId]["all"][unitId] || 0) + UnitCounter.units.outer[groupId][townId][unitId];
3959 }
3960 }
3961 }
3962 }
3963 }
3964 };
3965
3966
3967 var AvailableUnits = {
3968 activate: function () {
3969 var default_title = DM.getl10n("place", "support_overview").options.troop_count + " (" + DM.getl10n("hercules2014", "available") + ")";
3970
3971 $(".picomap_container").prepend("<div id='available_units_bullseye' class='unit_icon90x90 " + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme") + "'><div class='amount'></div></div>");
3972
3973 $('.picomap_overlayer').tooltip(getText("options", "ava")[0]);
3974
3975 // Ab version 2.115
3976 if($(".topleft_navigation_area").get(0)) {
3977
3978 $(".topleft_navigation_area").prepend("<div id='available_units_bullseye_addition' class='picomap_area'><div class='picomap_container'><div id='available_units_bullseye' class='unit_icon90x90 " + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme") + "'><div class='amount'></div></div></div><div class='picomap_overlayer'></div></div>");
3979
3980 $('<style id="dio_available_units_style_addition">' +
3981 '.coords_box { top: 117px !important; } ' +
3982 '.nui_grepo_score { top: 150px !important; } ' +
3983 '.nui_left_box { top: 102px !important; } ' +
3984 '.nui_main_menu { top: 293px !important; }' +
3985 '#grcrt_mnu_list .nui_main_menu {top: 0px !important; }'+
3986 '.bull_eye_buttons, .rb_map { height:38px !important; }' +
3987
3988 '#ui_box .btn_change_colors { top: 31px !important; }' +
3989
3990 '.picomap_area { position: absolute; overflow: visible; top: 0; left: 0; width: 156px; height: 161px; z-index: 5; }' +
3991 '.picomap_area .picomap_container, .picomap_area .picomap_overlayer { position: absolute; top: 33px; left: -3px; width: 147px; height: 101px; }' +
3992 //'.picomap_area .picomap_overlayer { background: url(https://gpde.innogamescdn.com/images/game/autogenerated/layout/layout_2.107.png) -145px -208px no-repeat; width: 147px; height: 101px; z-index: 5;} '+
3993 '.picomap_area .picomap_overlayer { background: url(' + dio_sprite + '); background-position: 473px 250px; width: 147px; height: 101px; z-index: 5;} ' +
3994 '</style>').appendTo('head');
3995 }
3996
3997 // Style
3998 $('<style id="dio_available_units_style">' +
3999
4000 '@-webkit-keyframes Z { 0% { opacity: 0; } 100% { opacity: 1; } } ' +
4001 '@keyframes Z { 0% { opacity: 0; } 100% { opacity: 1; } } ' +
4002
4003 '@-webkit-keyframes blurr { 0% { -webkit-filter: blur(5px); } 100% { -webkit-filter: blur(0px); } } ' +
4004
4005 '.picomap_overlayer { cursor:pointer; } ' +
4006
4007 '.picomap_area .bull_eye_buttons { height: 55px; } ' +
4008
4009 '#sea_id { background: none; font-size:25px; cursor:default; height:50px; width:50px; position:absolute; top:70px; left:157px; z-index: 30; } ' +
4010
4011 // Available bullseye unit
4012 '#available_units_bullseye { margin: 5px 28px 0px 28px; -webkit-animation: blur 2s; animation: Z 1s; } ' +
4013
4014 '#available_units_bullseye .amount { color:#826021; position:relative; top:28px; font-style:italic; width:79px; font-weight: bold; text-shadow: 0px 0px 2px black, 1px 1px 2px black, 0px 2px 2px black; -webkit-animation: blur 3s; } ' +
4015
4016 '#available_units_bullseye.big_number { font-size: 0.90em; line-height: 1.4; } ' +
4017
4018 '#available_units_bullseye.blur { -webkit-animation: blurr 0.6s; } ' +
4019
4020
4021
4022 // Land units
4023 '#available_units_bullseye.sword .amount { color:#E2D9C1; top:57px; width:90px; } ' +
4024 '#available_units_bullseye.hoplite .amount { color:#E2D9C1; top:57px; width:90px; } ' +
4025 '#available_units_bullseye.archer .amount { color:#E2D0C1; top:47px; width:70px; } ' +
4026 '#available_units_bullseye.chariot { margin-top: 15px; } ' +
4027 '#available_units_bullseye.chariot .amount { color:#F5E8B4; top:38px; width:91px; } ' +
4028 '#available_units_bullseye.rider .amount { color:#DFCC6C; top:52px; width:105px; } ' +
4029 '#available_units_bullseye.slinger .amount { color:#F5E8B4; top:53px; width:91px; } ' +
4030 '#available_units_bullseye.catapult .amount { color:#F5F6C5; top:36px; width:87px; } ' +
4031 '#available_units_bullseye.godsent .amount { color:#F5F6C5; top:57px; width:92px; } ' +
4032
4033 // Mythic units
4034 '#available_units_bullseye.medusa .amount { color:#FBFFBB; top:50px; width:65px; } ' +
4035 '#available_units_bullseye.manticore .amount { color:#ECD181; top:50px; width:55px; } ' +
4036 '#available_units_bullseye.pegasus { margin-top: 16px; } ' +
4037 '#available_units_bullseye.pegasus .amount { color:#F7F8E3; top:36px; width:90px; } ' +
4038 '#available_units_bullseye.minotaur { margin-top: 10px; } ' +
4039 '#available_units_bullseye.minotaur .amount { color:#EAD88A; top:48px; width:78px; } ' +
4040 '#available_units_bullseye.zyklop { margin-top: 3px; } '+
4041 '#available_units_bullseye.zyklop .amount { color:#EDE0B0; top:50px; width:95px; } ' +
4042 '#available_units_bullseye.harpy { margin-top: 16px; } ' +
4043 '#available_units_bullseye.harpy .amount { color:#E7DB79; top:30px; width:78px; } ' +
4044 '#available_units_bullseye.sea_monster .amount { color:#D8EA84; top:58px; width:91px; } ' +
4045 '#available_units_bullseye.cerberus .amount { color:#EC7445; top:25px; width:101px; } ' +
4046 '#available_units_bullseye.centaur { margin-top: 15px; } ' +
4047 '#available_units_bullseye.centaur .amount { color:#ECE0A8; top:29px; width:83px; } ' +
4048 '#available_units_bullseye.fury .amount { color:#E0E0BC; top:57px; width:95px; } ' +
4049 '#available_units_bullseye.griffin { margin-top: 15px; } ' +
4050 '#available_units_bullseye.griffin .amount { color:#FFDC9D; top:40px; width:98px; } ' +
4051 '#available_units_bullseye.calydonian_boar .amount { color:#FFDC9D; top:17px; width:85px; } ' +
4052
4053 // Naval units
4054 '#available_units_bullseye.attack_ship .amount { color:#FFCB00; top:26px; width:99px; } ' +
4055 '#available_units_bullseye.bireme .amount { color:#DFC677; color:azure; top:28px; width:79px; } ' +
4056 '#available_units_bullseye.trireme .amount { color:#F4FFD4; top:24px; width:90px; } ' +
4057 '#available_units_bullseye.small_transporter .amount { color:#F5F6C5; top:26px; width:84px; } ' +
4058 '#available_units_bullseye.big_transporter .amount { color:#FFDC9D; top:27px; width:78px; } ' +
4059 '#available_units_bullseye.colonize_ship .amount { color:#F5F6C5; top:29px; width:76px; } ' +
4060 '#available_units_bullseye.colonize_ship .amount { color:#F5F6C5; top:29px; width:76px; } ' +
4061 '#available_units_bullseye.demolition_ship .amount { color:#F5F6C5; top:35px; width:90px; } ' +
4062
4063 // Available units window
4064 '#available_units { overflow: auto; } ' +
4065 '#available_units .unit { margin: 5px; cursor:pointer; overflow:visible; } ' +
4066 '#available_units .unit.active { border: 2px solid #7f653a; border-radius:30px; margin:4px; } ' +
4067 '#available_units .unit span { text-shadow: 1px 1px 1px black, 1px 1px 2px black;} ' +
4068 '#available_units hr { margin: 5px 0px 5px 0px; } ' +
4069 '#available_units .drop_box .option { float: left; margin-right: 30px; width:100%; } ' +
4070 '#available_units .drop_box { position:absolute; top: -38px; right: 83px; width:90px; z-index:10; } ' +
4071 '#available_units .drop_box .drop_group { width: 120px; } ' +
4072 '#available_units .drop_box .select_group.open { display:block; } ' +
4073 '#available_units .drop_box .item-list { overflow: auto; overflow-x: hidden; } ' +
4074 '#available_units .drop_box .arrow { width:18px; height:18px; background:url(' + drop_out.src + ') no-repeat -1px -1px; position:absolute; } ' +
4075
4076 // Available units button
4077 '#btn_available_units { top:86px; left:119px; z-index:10; position:absolute; } ' +
4078 '#btn_available_units .ico_available_units { margin:5px 0px 0px 4px; width:24px; height:24px; ' +
4079 'background:url() no-repeat 0px 0px;background-size:100%; filter:url(#Hue1); -webkit-filter:hue-rotate(100deg); } ' +
4080
4081 '</style>').appendTo('head');
4082
4083 createWindowType("DIO_UNITS", (LANG.hasOwnProperty(LID) ? getText("options", "ava")[0] : default_title), 365, 310, true, [240, 70]);
4084
4085 // Set Sea-ID beside the bull eye
4086 $('#sea_id').prependTo('#ui_box');
4087
4088 AvailableUnits.addButton();
4089
4090 UnitCounter.count();
4091 AvailableUnits.updateBullseye();
4092 },
4093 deactivate: function () {
4094 $('#available_units_bullseye').remove();
4095 $('#available_units_bullseye_addition').remove();
4096
4097 $('#dio_available_units_style').remove();
4098 $('#dio_available_units_style_addition').remove();
4099
4100 $('#btn_available_units').remove();
4101
4102 if (Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS)) {
4103 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS).close();
4104 }
4105
4106 $('.picomap_overlayer').unbind();
4107
4108 $('#sea_id').appendTo('.picomap_container')
4109 },
4110 addButton: function () {
4111 var default_title = DM.getl10n("place", "support_overview").options.troop_count + " (" + DM.getl10n("hercules2014", "available") + ")";
4112
4113 $('<div id="btn_available_units" class="circle_button"><div class="ico_available_units js-caption"></div></div>').appendTo(".bull_eye_buttons");
4114
4115 // Events
4116 $('#btn_available_units').on('mousedown', function () {
4117 $('#btn_available_units, .ico_available_units').addClass("checked");
4118 }).on('mouseup', function () {
4119 $('#btn_available_units, .ico_available_units').removeClass("checked");
4120 });
4121
4122 $('#btn_available_units, .picomap_overlayer').click(function () {
4123 if (!Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS)) {
4124 AvailableUnits.openWindow();
4125 $('#btn_available_units, .ico_available_units').addClass("checked");
4126 } else {
4127 AvailableUnits.closeWindow();
4128 $('#btn_available_units, .ico_available_units').removeClass("checked");
4129 }
4130 });
4131
4132 // Tooltip
4133 $('#btn_available_units').tooltip(LANG.hasOwnProperty(LID) ? getText("labels", "uni") : default_title);
4134 },
4135 openWindow: function () {
4136 var groupArray = uw.ITowns.townGroups.getGroupsDIO(),
4137
4138 unitArray = {
4139 "sword": 0,
4140 "archer": 0,
4141 "hoplite": 0,
4142 "slinger": 0,
4143 "rider": 0,
4144 "chariot": 0,
4145 "catapult": 0,
4146 "godsent": 0,
4147 "manticore": 0,
4148 "harpy": 0,
4149 "pegasus": 0,
4150 "griffin": 0,
4151 "cerberus": 0,
4152 "minotaur": 0,
4153 "medusa": 0,
4154 "zyklop": 0,
4155 "centaur": 0,
4156 "calydonian_boar": 0,
4157 "fury": 0,
4158 "sea_monster": 0,
4159 "small_transporter": 0,
4160 "big_transporter": 0,
4161 "bireme": 0,
4162 "attack_ship": 0,
4163 "trireme": 0,
4164 "demolition_ship": 0,
4165 "colonize_ship": 0
4166 };
4167
4168 if (!uw.Game.hasArtemis) {
4169 delete unitArray.calydonian_boar;
4170 delete unitArray.griffin;
4171 }
4172
4173 var land_units_str = "", content =
4174 '<div id="available_units">' +
4175 // Dropdown menu
4176 '<div class="drop_box">' +
4177 '<div class="drop_group dropdown default">' +
4178 '<div class="border-left"></div><div class="border-right"></div>' +
4179 '<div class="caption" name="' + groupArray[DATA.bullseyeUnit.current_group].id + '">' + ITowns.town_groups._byId[groupArray[DATA.bullseyeUnit.current_group].id].attributes.name + '</div>' +
4180 '<div class="arrow"></div>' +
4181 '</div>' +
4182 '<div class="select_group dropdown-list default active"><div class="item-list"></div></div>' +
4183 '</div>' +
4184 '<table width="100%" class="radiobutton horizontal rbtn_visibility"><tr>'+
4185 '<td width="40%"><div class="option js-option" name="total"><div class="pointer"></div>'+ getText("labels", "total") +'</div></td>'+
4186 '<td width="40%"><div class="option js-option" name="available"><div class="pointer"></div>'+ getText("labels", "available") +'</div></td>'+
4187 '<td width="20%"><div class="option js-option" name="outer"><div class="pointer"></div>'+ getText("labels", "outer") +'</div></td>'+
4188 '</tr></table>'+
4189 '<hr>'+
4190 // Content
4191 '<div class="box_content">';
4192
4193 for (var unit in unitArray) {
4194 if (unitArray.hasOwnProperty(unit)) {
4195 land_units_str += '<div class="unit index_unit bold unit_icon40x40 ' + unit + '"></div>';
4196 if (unit == "sea_monster") {
4197 land_units_str += '<div style="clear:left;"></div>'; // break
4198 }
4199 }
4200 }
4201 content += land_units_str + '</div></div>';
4202
4203 AvailableUnits.wnd = Layout.wnd.Create(GPWindowMgr.TYPE_DIO_UNITS);
4204
4205 AvailableUnits.wnd.setContent(content);
4206
4207 if (Game.premium_features.curator <= Timestamp.now()) {
4208 $('#available_units .drop_box').css({display: 'none'});
4209 DATA.bullseyeUnit.current_group = -1;
4210 }
4211
4212 // Add groups to dropdown menu
4213 for (var group in groupArray) {
4214 if (groupArray.hasOwnProperty(group)) {
4215 var group_name = ITowns.town_groups._byId[group].attributes.name;
4216 $('<div class="option' + (group == -1 ? " sel" : "") + '" name="' + group + '">' + group_name + '</div>').appendTo('#available_units .item-list');
4217 }
4218 }
4219
4220 // Set active mode
4221 if(typeof(DATA.bullseyeUnit.mode) !== "undefined"){
4222 $('.radiobutton .option[name="'+ DATA.bullseyeUnit.mode +'"]').addClass("checked");
4223 }
4224 else{
4225 $('.radiobutton .option[name="available"]').addClass("checked");
4226 }
4227
4228 // Update
4229 AvailableUnits.updateWindow();
4230
4231 // Dropdown menu Handler
4232 $('#available_units .drop_group').click(function () {
4233 $('#available_units .select_group').toggleClass('open');
4234 });
4235 // Change group
4236 $('#available_units .select_group .option').click(function () {
4237 DATA.bullseyeUnit.current_group = $(this).attr("name");
4238 $('#available_units .select_group').removeClass('open');
4239 $('#available_units .select_group .option.sel').removeClass("sel");
4240 $(this).addClass("sel");
4241
4242 $('#available_units .drop_group .caption').attr("name", DATA.bullseyeUnit.current_group);
4243 $('#available_units .drop_group .caption').get(0).innerHTML = this.innerHTML;
4244
4245 $('#available_units .unit.active').removeClass("active");
4246 $('#available_units .unit.' + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme")).addClass("active");
4247
4248 UnitCounter.count();
4249
4250 AvailableUnits.updateWindow();
4251 AvailableUnits.updateBullseye();
4252 AvailableUnits.save();
4253 });
4254
4255 // Change mode (total, available, outer)
4256 $('.radiobutton .option').click(function(){
4257
4258 DATA.bullseyeUnit.mode = $(this).attr("name");
4259
4260 $('.radiobutton .option.checked').removeClass("checked");
4261 $(this).addClass("checked");
4262
4263 UnitCounter.count();
4264
4265 AvailableUnits.updateWindow();
4266 AvailableUnits.updateBullseye();
4267 AvailableUnits.save();
4268 });
4269
4270 // Set active bullseye unit
4271 $('#available_units .unit.' + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme")).addClass("active");
4272
4273 // Change bullseye unit
4274 $('#available_units .unit').click(function () {
4275 DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] = this.className.split(" ")[4].trim();
4276
4277 $('#available_units .unit.active').removeClass("active");
4278 $(this).addClass("active");
4279
4280 AvailableUnits.updateBullseye();
4281 AvailableUnits.save();
4282
4283 });
4284
4285 // Close button event - uncheck available units button
4286 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS).getJQCloseButton().get(0).onclick = function () {
4287 $('#btn_available_units, .ico_available_units').removeClass("checked");
4288 };
4289 },
4290 closeWindow: function () {
4291 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS).close();
4292 },
4293 save: function () {
4294 // console.debug("BULLSEYE SAVE", DATA.bullseyeUnit);
4295
4296 saveValue(WID + "_bullseyeUnit", JSON.stringify(DATA.bullseyeUnit));
4297 },
4298 updateBullseye: function () {
4299
4300 var sum = 0, str = "", fsize = ['1.4em', '1.2em', '1.15em', '1.1em', '1.0em', '0.95em'], i;
4301
4302 if ($('#available_units_bullseye').get(0)) {
4303 $('#available_units_bullseye').get(0).className = "unit_icon90x90 " + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme");
4304
4305 if (UnitCounter.units[DATA.bullseyeUnit.mode || "available"][DATA.bullseyeUnit.current_group]) {
4306 sum = UnitCounter.units[DATA.bullseyeUnit.mode || "available"][DATA.bullseyeUnit.current_group]["all"][(DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme" )] || 0;
4307 }
4308 sum = sum.toString();
4309
4310 for (i = 0; i < sum.length; i++) {
4311 str += "<span style='font-size:" + fsize[i] + "'>" + sum[i] + "</span>";
4312 }
4313 $('#available_units_bullseye .amount').get(0).innerHTML = str;
4314
4315 if (sum >= 100000) {
4316 $('#available_units_bullseye').addClass("big_number");
4317 } else {
4318 $('#available_units_bullseye').removeClass("big_number");
4319 }
4320 }
4321 },
4322 updateWindow: function () {
4323
4324 $('#available_units .box_content .unit').each(function () {
4325 var unit = this.className.split(" ")[4];
4326
4327 // TODO: Alte Variante entfernen
4328 // Alte Variante:
4329 //this.innerHTML = '<span style="font-size:0.9em">' + groupUnitArray[DATA.bullseyeUnit.current_group][unit] + '</span>';
4330
4331 // Neue Variante
4332 this.innerHTML = '<span style="font-size:0.9em">' + (UnitCounter.units[DATA.bullseyeUnit.mode || "available"][DATA.bullseyeUnit.current_group]["all"][unit] || 0) + '</span>';
4333 });
4334 }
4335 };
4336
4337 /*******************************************************************************************************************************
4338 * Comparison box
4339 * ----------------------------------------------------------------------------------------------------------------------------
4340 * | ● Compares the units of each unit type
4341 * ----------------------------------------------------------------------------------------------------------------------------
4342 *******************************************************************************************************************************/
4343 var UnitComparison = {
4344 activate: function () {
4345 //UnitComparison.addBox();
4346 UnitComparison.addButton();
4347
4348 // Create Window Type
4349 createWindowType("DIO_COMPARISON", getText("labels", "dsc"), 480, 315, true, ["center", "center", 100, 100]);
4350
4351 // Style
4352 $('<style id="dio_comparison_style"> ' +
4353
4354 // Button
4355 '#dio_comparison_button { top:51px; left:120px; z-index:10; position:absolute; } ' +
4356 '#dio_comparison_button .ico_comparison { margin:5px 0px 0px 4px; width:24px; height:24px; ' +
4357 'background:url(http://666kb.com/i/cjq6cxia4ms8mn95r.png) no-repeat 0px 0px; background-size:100%; filter:url(#Hue1); -webkit-filter:hue-rotate(60deg); } ' +
4358 '#dio_comparison_button.checked .ico_comparison { margin-top:6px; } ' +
4359
4360 // Window
4361 '#dio_comparison a { float:left; background-repeat:no-repeat; background-size:25px; line-height:2; margin-right:10px; } ' +
4362 '#dio_comparison .box_content { text-align:center; font-style:normal; } ' +
4363
4364 // Menu tabs
4365 '#dio_comparison_menu .tab_icon { left: 23px;} ' +
4366 '#dio_comparison_menu .tab_label { margin-left: 18px; } ' +
4367
4368 // Content
4369 '#dio_comparison .hidden { display:none; } ' +
4370 '#dio_comparison table { width:480px; } ' +
4371 '#dio_comparison .hack .t_hack, #dio_comparison .pierce .t_pierce, #dio_comparison .distance .t_distance, #dio_comparison .sea .t_sea { display:inline-table; } ' +
4372
4373 '#dio_comparison .box_content { background:url() 94% 94% no-repeat; background-size:140px; } ' +
4374
4375 '#dio_comparison .compare_type_icon { height:25px; width:25px; background:url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png); background-size:100%; } ' +
4376 '#dio_comparison .compare_type_icon.time { background:url(https://gpall.innogamescdn.com/images/game/res/time.png); background-size:100%; } ' +
4377 '#dio_comparison .compare_type_icon.favor { background:url(https://gpall.innogamescdn.com/images/game/res/favor.png); background-size:100%; } ' +
4378 '</style>').appendTo("head");
4379 },
4380 deactivate: function () {
4381 $('#dio_comparison_button').remove();
4382 $('#dio_comparison_style').remove();
4383
4384 if (Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON)) {
4385 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON).close();
4386 }
4387 },
4388 addButton: function () {
4389 $('<div id="dio_comparison_button" class="circle_button"><div class="ico_comparison js-caption"></div></div>').appendTo(".bull_eye_buttons");
4390
4391 // Events
4392 /*
4393 $('#dio_comparison_button').on('mousedown', function(){
4394 $('#dio_comparison_button').addClass("checked");
4395 }, function(){
4396 $('#dio_comparison_button').removeClass("checked");
4397 });
4398 */
4399 $('#dio_comparison_button').on('click', function () {
4400 if (!Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON)) {
4401 UnitComparison.openWindow();
4402 $('#dio_comparison_button').addClass("checked");
4403 } else {
4404 UnitComparison.closeWindow();
4405 $('#dio_comparison_button').removeClass("checked");
4406 }
4407 });
4408
4409 // Tooltip
4410 $('#dio_comparison_button').tooltip(getText("labels", "dsc"));
4411 },
4412 openWindow: function () {
4413 var content =
4414 // Title tabs
4415 '<ul id="dio_comparison_menu" class="menu_inner" style="top: -36px; right: 35px;">' +
4416 '<li><a class="submenu_link sea" href="#"><span class="left"><span class="right"><span class="middle">' +
4417 '<span class="tab_icon icon_small townicon_so"></span><span class="tab_label">' + getText("labels", "sea") + '</span>' +
4418 '</span></span></span></a></li>' +
4419 '<li><a class="submenu_link distance" href="#"><span class="left"><span class="right"><span class="middle">' +
4420 '<span class="tab_icon icon_small townicon_di"></span><span class="tab_label">' + getText("labels", "dst") + '</span>' +
4421 '</span></span></span></a></li>' +
4422 '<li><a class="submenu_link pierce" href="#"><span class="left"><span class="right"><span class="middle">' +
4423 '<span class="tab_icon icon_small townicon_sh"></span><span class="tab_label">' + getText("labels", "prc") + '</span>' +
4424 '</span></span></span></a></li>' +
4425 '<li><a class="submenu_link hack active" href="#"><span class="left"><span class="right"><span class="middle">' +
4426 '<span class="tab_icon icon_small townicon_lo"></span><span class="tab_label">' + getText("labels", "hck") + '</span>' +
4427 '</span></span></span></a></li>' +
4428 '</ul>' +
4429 // Content
4430 '<div id="dio_comparison" style="margin-bottom:5px; font-style:italic;"><div class="box_content hack"></div></div>';
4431
4432 Layout.wnd.Create(GPWindowMgr.TYPE_DIO_COMPARISON).setContent(content);
4433
4434 UnitComparison.addComparisonTable("hack");
4435 UnitComparison.addComparisonTable("pierce");
4436 UnitComparison.addComparisonTable("distance");
4437 UnitComparison.addComparisonTable("sea");
4438
4439 // Tooltips
4440 var labelArray = DM.getl10n("barracks"),
4441 labelAttack = DM.getl10n("context_menu", "titles").attack,
4442 labelDefense = DM.getl10n("place", "tabs")[0];
4443
4444 $('.tr_att').tooltip(labelAttack);
4445 $('.tr_def').tooltip(labelDefense + " (Ø)");
4446 $('.tr_def_sea').tooltip(labelDefense);
4447 $('.tr_spd').tooltip(labelArray.tooltips.speed);
4448 $('.tr_bty').tooltip(labelArray.tooltips.booty.title);
4449 $('.tr_bty_sea').tooltip(labelArray.tooltips.ship_transport.title);
4450 $('.tr_res').tooltip(labelArray.costs + " (" +
4451 labelArray.cost_details.wood + " + " +
4452 labelArray.cost_details.stone + " + " +
4453 labelArray.cost_details.iron + ")"
4454 );
4455 $('.tr_fav').tooltip(labelArray.costs + " (" + labelArray.cost_details.favor + ")");
4456 $('.tr_tim').tooltip(labelArray.cost_details.buildtime_barracks + " (s)");
4457 $('.tr_tim_sea').tooltip(labelArray.cost_details.buildtime_docks + " (s)");
4458
4459 UnitComparison.switchComparisonTables();
4460
4461 // Close button event - uncheck available units button
4462 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON).getJQCloseButton().get(0).onclick = function () {
4463 $('#dio_comparison_button').removeClass("checked");
4464 $('.ico_comparison').get(0).style.marginTop = "5px";
4465 };
4466 },
4467 closeWindow: function () {
4468 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON).close();
4469 },
4470 switchComparisonTables: function () {
4471 $('#dio_comparison_menu .hack, #dio_comparison_menu .pierce, #dio_comparison_menu .distance, #dio_comparison_menu .sea').click(function () {
4472 $('#dio_comparison .box_content').removeClass($('#dio_comparison .box_content').get(0).className.split(" ")[1]);
4473 //console.debug(this.className.split(" ")[1]);
4474 $('#dio_comparison .box_content').addClass(this.className.split(" ")[1]);
4475
4476 $('#dio_comparison_menu .active').removeClass("active");
4477 $(this).addClass("active");
4478 });
4479 },
4480
4481 tooltips: [], t: 0,
4482
4483 addComparisonTable: function (type) {
4484 var pos = {
4485 att: {hack: "36%", pierce: "27%", distance: "45.5%", sea: "72.5%"},
4486 def: {hack: "18%", pierce: "18%", distance: "18%", sea: "81.5%"}
4487 };
4488 var unitIMG = "https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png";
4489 var strArray = [
4490 "<td></td>",
4491 '<td><div class="compare_type_icon" style="background-position: 0% ' + pos.att[type] + ';"></div></td>',
4492 '<td><div class="compare_type_icon" style="background-position: 0% ' + pos.def[type] + ';"></div></td>',
4493 '<td><div class="compare_type_icon" style="background-position: 0% 63%;"></div></td>',
4494 (type !== "sea") ? '<td><div class="compare_type_icon booty"></div></td>' : '<td><div class="compare_type_icon" style="background-position: 0% 91%;"></div></td>',
4495 '<td><div class="compare_type_icon" style="background-position: 0% 54%;"></div></td>',
4496 '<td><div class="compare_type_icon favor"></div></td>',
4497 '<td><div class="compare_type_icon time"></div></td>'
4498 ];
4499
4500 for (var e in uw.GameData.units) {
4501 if (uw.GameData.units.hasOwnProperty(e)) {
4502 var valArray = [];
4503
4504 if (type === (uw.GameData.units[e].attack_type || "sea") && (e !== "militia")) {
4505 valArray.att = Math.round(uw.GameData.units[e].attack * 10 / uw.GameData.units[e].population) / 10;
4506 valArray.def = Math.round(((uw.GameData.units[e].def_hack + uw.GameData.units[e].def_pierce + uw.GameData.units[e].def_distance) * 10) / (3 * uw.GameData.units[e].population)) / 10;
4507 valArray.def = valArray.def || Math.round(uw.GameData.units[e].defense * 10 / uw.GameData.units[e].population) / 10;
4508 valArray.speed = uw.GameData.units[e].speed;
4509 valArray.booty = Math.round(((uw.GameData.units[e].booty) * 10) / uw.GameData.units[e].population) / 10;
4510 valArray.booty = valArray.booty || Math.round(((uw.GameData.units[e].capacity ? uw.GameData.units[e].capacity + 6 : 0) * 10) / uw.GameData.units[e].population) / 10;
4511 valArray.favor = Math.round((uw.GameData.units[e].favor * 10) / uw.GameData.units[e].population) / 10;
4512 valArray.res = Math.round((uw.GameData.units[e].resources.wood + uw.GameData.units[e].resources.stone + uw.GameData.units[e].resources.iron) / (uw.GameData.units[e].population));
4513 valArray.time = Math.round(uw.GameData.units[e].build_time / uw.GameData.units[e].population);
4514
4515 // World without Artemis? -> grey griffin and boar
4516 valArray.heroStyle = "";
4517 valArray.heroStyleIMG = "";
4518
4519 if (!uw.Game.hasArtemis && ((e === "griffin") || (e === "calydonian_boar"))) {
4520 valArray.heroStyle = "color:black;opacity: 0.4;";
4521 valArray.heroStyleIMG = "filter: url(#GrayScale); -webkit-filter:grayscale(100%);";
4522 }
4523
4524 strArray[0] += '<td class="un' + (UnitComparison.t) + '"><span class="unit index_unit unit_icon40x40 ' + e + '" style="' + valArray.heroStyle + valArray.heroStyleIMG + '"></span></td>';
4525 strArray[1] += '<td class="bold" style="color:' + ((valArray.att > 19) ? 'green;' : ((valArray.att < 10 && valArray.att !== 0 ) ? 'red;' : 'black;')) + valArray.heroStyle + '">' + valArray.att + '</td>';
4526 strArray[2] += '<td class="bold" style="color:' + ((valArray.def > 19) ? 'green;' : ((valArray.def < 10 && valArray.def !== 0 ) ? 'red;' : 'black;')) + valArray.heroStyle + '">' + valArray.def + '</td>';
4527 strArray[3] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.speed + '</td>';
4528 strArray[4] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.booty + '</td>';
4529 strArray[5] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.res + '</td>';
4530 strArray[6] += '<td class="bold" style="color:' + ((valArray.favor > 0) ? 'rgb(0, 0, 214);' : 'black;') + valArray.heroStyle + ';">' + valArray.favor + '</td>';
4531 strArray[7] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.time + '</td>';
4532
4533 UnitComparison.tooltips[UnitComparison.t] = uw.GameData.units[e].name;
4534 UnitComparison.t++;
4535 }
4536 }
4537 }
4538
4539 $('<table class="hidden t_' + type + '" cellpadding="1px">' +
4540 '<tr>' + strArray[0] + '</tr>' +
4541 '<tr class="tr_att">' + strArray[1] + '</tr><tr class="tr_def' + (type == "sea" ? "_sea" : "") + '">' + strArray[2] + '</tr>' +
4542 '<tr class="tr_spd">' + strArray[3] + '</tr><tr class="tr_bty' + (type == "sea" ? "_sea" : "") + '">' + strArray[4] + '</tr>' +
4543 '<tr class="tr_res">' + strArray[5] + '</tr><tr class="tr_fav">' + strArray[6] + '</tr><tr class="tr_tim' + (type == "sea" ? "_sea" : "") + '">' + strArray[7] + '</tr>' +
4544 '</table>').appendTo('#dio_comparison .box_content');
4545
4546 for (var i = 0; i <= UnitComparison.t; i++) {
4547 $('.un' + i).tooltip(UnitComparison.tooltips[i]);
4548 }
4549 }
4550 };
4551
4552 /*******************************************************************************************************************************
4553 * Reports and Messages
4554 * ----------------------------------------------------------------------------------------------------------------------------
4555 * | ● Storage of the selected filter (only in German Grepolis yet)
4556 * ----------------------------------------------------------------------------------------------------------------------------
4557 *******************************************************************************************************************************/
4558
4559 var filter = "all";
4560
4561 function saveFilter() {
4562 $('#dd_filter_type_list .item-list div').each(function () {
4563 $(this).click(function () {
4564 filter = $(this).attr("name");
4565 });
4566 });
4567 /*
4568 var i = 0;
4569 $("#report_list a").each(function () {
4570 //console.log((i++) +" = " + $(this).attr('data-reportid'));
4571 });
4572 */
4573 }
4574
4575 function loadFilter() {
4576 if ($('#dd_filter_type_list .selected').attr("name") !== filter) {
4577 $('#dd_filter_type .caption').click();
4578 $('#dd_filter_type_list .item-list div[name=' + filter + ']').click();
4579 }
4580 }
4581
4582 function removeReports() {
4583 $("#report_list li:contains('spioniert')").each(function () {
4584 //$(this).remove();
4585 });
4586 }
4587
4588 var zut = 0;
4589 var messageArray = {};
4590
4591 function filterPlayer() {
4592 if (!$('#message_filter_list').get(0)) {
4593 $('<div id="message_filter_list" style="height:300px;overflow-y:scroll; width: 790px;"></div>').appendTo('#folder_container');
4594 $("#message_list").get(0).style.display = "none";
4595 }
4596 if (zut < parseInt($('.es_last_page').get(0).value, 10) - 1) {
4597 $('.es_page_input').get(0).value = zut++;
4598 $('.jump_button').click();
4599 $("#message_list li:contains('')").each(function () {
4600 $(this).appendTo('#message_filter_list');
4601 });
4602 } else {
4603 zut = 1;
4604 }
4605 }
4606
4607
4608 /*******************************************************************************************************************************
4609 * World Wonder Ranking - Change
4610 *******************************************************************************************************************************/
4611
4612 function getWorldWonderTypes() {
4613 $.ajax({
4614 type: "GET",
4615 url: "/game/alliance?town_id=" + uw.Game.town_id + "&action=world_wonders&h=" + uw.Game.csrfToken + "&json=%7B%22town_id%22%3A" + uw.Game.town_id + "%2C%22nlreq_id%22%3A" + uw.Game.notification_last_requested_id +
4616 "%7D&_=" + uw.Game.server_time,
4617 success: function (text) {
4618 try {
4619 //console.log(JSON.parse(text));
4620 temp = JSON.parse(text).json.data.world_wonders;
4621 for (var t in temp) {
4622 if (temp.hasOwnProperty(t)) {
4623 wonderTypes[temp[t].wonder_type] = temp[t].full_name;
4624 }
4625 }
4626 temp = JSON.parse(text).json.data.buildable_wonders;
4627 for (var x in temp) {
4628 if (temp.hasOwnProperty(x)) {
4629 wonderTypes[x] = temp[x].name;
4630 }
4631 }
4632 saveValue(MID + "_wonderTypes", JSON.stringify(wonderTypes));
4633 } catch (error) {
4634 errorHandling(error, "getWorldWonderTypes");
4635 }
4636 }
4637 });
4638 }
4639
4640 function getWorldWonders() {
4641 $.ajax({
4642 type: "GET",
4643 url: "/game/ranking?town_id=" + uw.Game.town_id + "&action=wonder_alliance&h=" + uw.Game.csrfToken + "&json=%7B%22type%22%3A%22all%22%2C%22town_id%22%3A" + uw.Game.town_id + "%2C%22nlreq_id%22%3A3" + uw.Game.notification_last_requested_id +
4644 "%7D&_=" + uw.Game.server_time
4645 });
4646 }
4647
4648 var WorldWonderRanking = {
4649 activate: function () {
4650 if ($('#dio_wonder_ranking').get(0)) {
4651 $('#dio_wonder_ranking').remove();
4652 }
4653 $('<style id="dio_wonder_ranking" type="text/css"> .wonder_ranking { display: none; } </style>').appendTo('head');
4654 },
4655 deactivate: function () {
4656 if ($('#dio_wonder_ranking').get(0)) {
4657 $('#dio_wonder_ranking').remove();
4658 }
4659 $('<style id="dio_wonder_ranking" type="text/css"> .wonder_ranking { display: block; } </style>').appendTo('head');
4660 },
4661 change: function (html) {
4662 if ($('#ranking_inner tr', html)[0].children.length !== 1) { // world wonders exist?
4663 try {
4664 var ranking = {}, temp_ally, temp_ally_id, temp_ally_link;
4665
4666 // Save world wonder ranking into array
4667 $('#ranking_inner tr', html).each(function () {
4668 try {
4669 if (this.children[0].innerHTML) {
4670 temp_ally = this.children[1].children[0].innerHTML; // das hier
4671
4672 temp_ally_id = this.children[1].children[0].onclick.toString();
4673 temp_ally_id = temp_ally_id.substring(temp_ally_id.indexOf(",") + 1);
4674 temp_ally_id = temp_ally_id.substring(0, temp_ally_id.indexOf(")"));
4675
4676 temp_ally_link = this.children[1].innerHTML;
4677
4678 } else {
4679 //World wonder name
4680 var wonder_name = this.children[3].children[0].innerHTML;
4681
4682 for (var w in wonderTypes) {
4683 if (wonderTypes.hasOwnProperty(w)) {
4684 if (wonder_name == wonderTypes[w]) {
4685 var level = this.children[4].innerHTML, // world wonder level
4686 ww_data = JSON.parse(atob(this.children[3].children[0].href.split("#")[1])), wonder_link;
4687 //console.log(ww_data);
4688
4689 if (!ranking.hasOwnProperty(level)) {
4690 // add wonder types
4691 ranking[level] = {
4692 colossus_of_rhodes: {},
4693 great_pyramid_of_giza: {},
4694 hanging_gardens_of_babylon: {},
4695 lighthouse_of_alexandria: {},
4696 mausoleum_of_halicarnassus: {},
4697 statue_of_zeus_at_olympia: {},
4698 temple_of_artemis_at_ephesus: {}
4699 };
4700 }
4701
4702 if (!ranking[level][w].hasOwnProperty(temp_ally_id)) {
4703 ranking[level][w][temp_ally_id] = {}; // add alliance array
4704 }
4705 // island coordinates of the world wonder:
4706 ranking[level][w][temp_ally_id].ix = ww_data.ix;
4707 ranking[level][w][temp_ally_id].iy = ww_data.iy;
4708 ranking[level][w][temp_ally_id].sea = this.children[5].innerHTML; // world wonder sea
4709
4710 wonder_link = this.children[3].innerHTML;
4711 if (temp_ally.length > 15) {
4712 temp_ally = temp_ally.substring(0, 15) + '.';
4713 }
4714 wonder_link = wonder_link.substr(0, wonder_link.indexOf(">") + 1) + temp_ally + '</a>';
4715
4716 ranking[level][w][temp_ally_id].ww_link = wonder_link;
4717
4718 // other data of the world wonder
4719 ranking[level][w][temp_ally_id].ally_link = temp_ally_link;
4720 ranking[level][w][temp_ally_id].ally_name = temp_ally; // alliance name
4721 ranking[level][w][temp_ally_id].name = wonder_name; // world wonder name
4722
4723 // Save wonder coordinates for wonder icons on map
4724 if (!wonder.map[w]) {
4725 wonder.map[w] = {};
4726 }
4727 wonder.map[w][ww_data.ix + "_" + ww_data.iy] = level;
4728 saveValue(WID + "_wonder", JSON.stringify(wonder));
4729
4730 }
4731 }
4732 }
4733 }
4734 } catch (error) {
4735 errorHandling(error, "WorldWonderRanking.change(function)");
4736 }
4737 });
4738
4739 if ($('#ranking_table_wrapper').get(0)) {
4740 $('#ranking_fixed_table_header').get(0).innerHTML = '<tr>' +
4741 '<td style="width:10px">#</td>' +
4742 '<td>Colossus</td>' +
4743 '<td>Pyramid</td>' +
4744 '<td>Garden</td>' +
4745 '<td>Lighthouse</td>' +
4746 '<td>Mausoleum</td>' +
4747 '<td>Statue</td>' +
4748 '<td>Temple</td>' +
4749 '</tr>';
4750
4751 $('#ranking_fixed_table_header').css({
4752 tableLayout: 'fixed',
4753 width: '100%',
4754 //paddingLeft: '0px',
4755 paddingRight: '15px'
4756 });
4757
4758 var ranking_substr = '', z = 0;
4759 for (var level = 10; level >= 1; level--) {
4760 if (ranking.hasOwnProperty(level)) {
4761 var complete = "";
4762 if (level == 10) {
4763 complete = "background: rgba(255, 236, 108, 0.36);";
4764 }
4765
4766 // Alternate table background color
4767 if (z === 0) {
4768 ranking_substr += '<tr class="game_table_odd" style="' + complete + '"><td style="border-right: 1px solid #d0be97;">' + level + '</td>';
4769 z = 1;
4770 } else {
4771 ranking_substr += '<tr class="game_table_even" style="' + complete + '"><td style="border-right: 1px solid #d0be97;">' + level + '</td>';
4772 z = 0;
4773 }
4774 for (var w in ranking[level]) {
4775 if (ranking[level].hasOwnProperty(w)) {
4776 ranking_substr += '<td>';
4777
4778 for (var a in ranking[level][w]) {
4779 if (ranking[level][w].hasOwnProperty(a)) {
4780 ranking_substr += '<nobr>' + ranking[level][w][a].ww_link + '</nobr><br />'; // ww link
4781 }
4782 }
4783 ranking_substr += '</td>';
4784 }
4785 }
4786 ranking_substr += '</tr>';
4787 }
4788 }
4789
4790 var ranking_str = '<table id="ranking_endless_scroll" class="game_table" cellspacing="0"><tr>' +
4791 '<td style="width:10px;border-right: 1px solid #d0be97;"></td>' +
4792 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.colossus_of_rhodes + ';margin-left:26px"></div></td>' + // Colossus
4793 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.great_pyramid_of_giza + ';margin-left:19px"></div></td>' + // Pyramid
4794 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.hanging_gardens_of_babylon + ';margin-left:19px"></div></td>' + // Garden
4795 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.lighthouse_of_alexandria + ';margin-left:24px"></div></td>' + // Lighthouse
4796 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.mausoleum_of_halicarnassus + ';margin-left:25px"></div></td>' + // Mausoleum
4797 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.statue_of_zeus_at_olympia + ';margin-left:25px"></div></td>' + // Statue
4798 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.temple_of_artemis_at_ephesus + ';margin-left:22px"></div></td>' + // Temple
4799 '</tr>' + ranking_substr + '</table>';
4800
4801 $('#ranking_table_wrapper').get(0).innerHTML = ranking_str;
4802
4803 $('#ranking_endless_scroll .dio_wonder').css({
4804 width: "65px", height: "60px",
4805 backgroundSize: "auto 100%",
4806 backgroundPosition: "64px 0px"
4807 });
4808
4809 $('#ranking_endless_scroll').css({
4810 tableLayout: 'fixed',
4811 width: '100%',
4812 overflowY: 'auto',
4813 overflowX: 'hidden',
4814 fontSize: '0.7em',
4815 lineHeight: '2'
4816 });
4817 $('#ranking_endless_scroll tbody').css({
4818 verticalAlign: 'text-top'
4819 });
4820
4821 $('#ranking_table_wrapper img').css({
4822 width: "60px"
4823 });
4824 $('#ranking_table_wrapper').css({
4825 overflowY: 'scroll'
4826 });
4827 }
4828 } catch (error) {
4829 errorHandling(error, "WorldWonderRanking.change");
4830 }
4831 }
4832 if ($('.wonder_ranking').get(0)) {
4833 $('.wonder_ranking').get(0).style.display = "block";
4834 }
4835 }
4836 };
4837
4838 /*******************************************************************************************************************************
4839 * World Wonder
4840 * ----------------------------------------------------------------------------------------------------------------------------
4841 * | ● click adjustment
4842 * | ● Share calculation (= ratio of player points to alliance points)
4843 * | ● Resources calculation & counter (stores amount)
4844 * | ● Adds missing previous & next buttons on finished world wonders (better browsing through world wonders)
4845 * ----------------------------------------------------------------------------------------------------------------------------
4846 *******************************************************************************************************************************/
4847
4848 // getPointRatio: Default
4849 function getPointRatioFromAllianceProfile() {
4850 if (AID) {
4851 $.ajax({
4852 type: "GET",
4853 url: '/game/alliance?town_id=' + uw.Game.townId + '&action=profile&h=' + uw.Game.csrfToken + '&json=%7B%22alliance_id%22%3A' + AID + '%2C%22town_id%22%3A' + uw.Game.townId +
4854 '%2C%22nlreq_id%22%3A' + uw.Game.notification_last_requested_id + '%7D&_=' + uw.Game.server_time,
4855 success: function (text) {
4856 try {
4857 text = text.substr(text.indexOf("/li") + 14).substr(0, text.indexOf("\ "));
4858 var AP = parseInt(text, 10);
4859 wonder.ratio[AID] = 100 / AP * uw.Game.player_points;
4860 saveValue(WID + "_wonder", JSON.stringify(wonder));
4861 } catch (error) {
4862 errorHandling(error, "getPointRatioFromAllianceProfile");
4863 }
4864 }
4865 });
4866 } else {
4867 wonder.ratio[AID] = -1;
4868 saveValue(WID + "_wonder", JSON.stringify(wonder));
4869 }
4870 }
4871
4872 function getPointRatioFromAllianceRanking() {
4873 try {
4874 if (AID && $('.current_player .r_points').get(0)) {
4875 wonder.ratio[AID] = 100 / parseInt($('.current_player .r_points').get(0).innerHTML, 10) * uw.Game.player_points;
4876 saveValue(WID + "_wonder", JSON.stringify(wonder));
4877 }
4878 } catch (error) {
4879 errorHandling(error, "getPointRatioFromAllianceRaking");
4880 }
4881 }
4882
4883 function getPointRatioFromAllianceMembers() {
4884 try {
4885 var ally_points = 0;
4886 $('#ally_members_body tr').each(function () {
4887 ally_points += parseInt($(this).children().eq(2).text(), 10) || 0;
4888 });
4889 wonder.ratio[AID] = 100 / ally_points * uw.Game.player_points;
4890 saveValue(WID + "_wonder", JSON.stringify(wonder));
4891 } catch (error) {
4892 errorHandling(error, "getPointRatioFromAllianceMembers");
4893 }
4894 }
4895
4896 var WorldWonderCalculator = {
4897 activate: function () {
4898 // Style
4899 $('<style id="dio_wonder_calculator"> ' +
4900 '.wonder_controls { height:380px; } ' +
4901 '.wonder_controls .wonder_progress { margin: 0px auto 5px; } ' +
4902 '.wonder_controls .wonder_header { text-align:left; margin:10px -8px 12px 3px; }' +
4903 '.wonder_controls .build_wonder_icon { top:25px !important; }' +
4904 '.wonder_controls .wonder_progress_bar { top:54px; }' +
4905 '.wonder_controls .trade fieldset { float:right; } ' +
4906 '.wonder_controls .wonder_res_container { right:29px; } ' +
4907 '.wonder_controls .ww_ratio {position:relative; height:auto; } ' +
4908 '.wonder_controls fieldset.next_level_res { height:auto; } ' +
4909 '.wonder_controls .town-capacity-indicator { margin-top:0px; } ' +
4910
4911 '.wonder_controls .ww_ratio .progress { line-height:1; color:white; font-size:0.8em; } ' +
4912 '.wonder_controls .ww_perc { position:absolute; width:242px; text-align:center; } ' +
4913 '.wonder_controls .indicator3 { z-index:0; } ' +
4914 '.wonder_controls .indicator3.red { background-position:right -203px; height:10px; width:242px; } ' +
4915 '.wonder_controls .indicator3.green { background-position:right -355px; height:10px; width:242px; } ' +
4916 '.wonder_controls .all_res { background:url(https://gpall.innogamescdn.com/images/game/layout/resources_2.32.png) no-repeat 0 -90px; width:30px; height:30px; margin:0 auto; margin-left:5px; } ' +
4917 '.wonder_controls .town-capacity-indicator { margin-top:0px; } ' +
4918 '</style>').appendTo('head');
4919 },
4920 deactivate: function () {
4921 $('#dio_wonder_calculator').remove();
4922 }
4923 };
4924
4925 // TODO: Split function...
4926 function getResWW() {
4927 try {
4928 var wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_WONDERS);
4929
4930 for (var e in wndArray) {
4931 if (wndArray.hasOwnProperty(e)) {
4932 var wndID = "#gpwnd_" + wndArray[e].getID() + " ";
4933
4934 if ($(wndID + '.wonder_progress').get(0)) {
4935 var res = 0,
4936 ww_share = {total: {share: 0, sum: 0}, stage: {share: 0, sum: 0}},
4937 ww_type = $(wndID + '.finished_image_small').attr('src').split("/")[6].split("_")[0], // Which world wonder?
4938 res_stages = [2, 4, 6, 10, 16, 28, 48, 82, 140, 238], // Rohstoffmenge pro Rohstofftyp in 100.000 Einheiten
4939 stage = parseInt($(wndID + '.wonder_expansion_stage span').get(0).innerHTML.split("/")[0], 10) + 1, // Derzeitige Füllstufe
4940 speed = uw.Game.game_speed;
4941
4942 wonder.storage[AID] = wonder.storage[AID] || {};
4943
4944 wonder.storage[AID][ww_type] = wonder.storage[AID][ww_type] || {};
4945
4946 wonder.storage[AID][ww_type][stage] = wonder.storage[AID][ww_type][stage] || 0;
4947
4948 if (!$(wndID + '.ww_ratio').get(0)) {
4949 $('<fieldset class="ww_ratio"></fieldset>').appendTo(wndID + '.wonder_res_container .trade');
4950 $(wndID + '.wonder_header').prependTo(wndID + '.wonder_progress');
4951 $(wndID + '.wonder_res_container .send_res').insertBefore(wndID + '.wonder_res_container .next_level_res');
4952 }
4953
4954 for (var d in res_stages) {
4955 if (res_stages.hasOwnProperty(d)) {
4956 ww_share.total.sum += res_stages[d];
4957 }
4958 }
4959
4960 ww_share.total.sum *= speed * 300000;
4961
4962 ww_share.total.share = parseInt(wonder.ratio[AID] * (ww_share.total.sum / 100), 10);
4963
4964 ww_share.stage.sum = speed * res_stages[stage - 1] * 300000;
4965
4966 ww_share.stage.share = parseInt(wonder.ratio[AID] * (ww_share.stage.sum / 100), 10); // ( 3000 = 3 Rohstofftypen * 100000 Rohstoffe / 100 Prozent)
4967 setResWW(stage, ww_type, ww_share, wndID);
4968
4969
4970 $(wndID + '.wonder_res_container .send_resources_btn').click(function (e) {
4971 try {
4972 wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_wood input:text').get(0).value, 10);
4973 wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_stone input:text').get(0).value, 10);
4974 wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_iron input:text').get(0).value, 10);
4975
4976 setResWW(stage, ww_type, ww_share, wndID);
4977 saveValue(WID + "_wonder", JSON.stringify(wonder));
4978 } catch (error) {
4979 errorHandling(error, "getResWW_Click");
4980 }
4981 });
4982
4983 } else {
4984 $('<div class="prev_ww pos_Y"></div><div class="next_ww pos_Y"></div>').appendTo(wndID + '.wonder_controls');
4985
4986 $(wndID + '.wonder_finished').css({width: '100%'});
4987
4988 $(wndID + '.pos_Y').css({
4989 top: '-266px'
4990 });
4991 }
4992 }
4993 }
4994 } catch (error) {
4995 errorHandling(error, "getResWW");
4996 }
4997 }
4998
4999 function setResWW(stage, ww_type, ww_share, wndID) {
5000 try {
5001 var stage_width, total_width, res_total = 0, stage_color = "red", total_color = "red";
5002
5003 for (var z in wonder.storage[AID][ww_type]) {
5004 if (wonder.storage[AID][ww_type].hasOwnProperty(z)) {
5005 res_total += wonder.storage[AID][ww_type][z];
5006 }
5007 }
5008
5009 // Progressbar
5010 if (ww_share.stage.share > wonder.storage[AID][ww_type][stage]) {
5011 stage_width = (242 / ww_share.stage.share) * wonder.storage[AID][ww_type][stage];
5012 stage_color = "red";
5013 } else {
5014 stage_width = 242;
5015 stage_color = "green"
5016 }
5017 if (ww_share.total.share > res_total) {
5018 total_color = "red";
5019 total_width = (242 / ww_share.total.share) * res_total;
5020 } else {
5021 total_width = 242;
5022 total_color = "green"
5023 }
5024
5025 $(wndID + '.ww_ratio').get(0).innerHTML = "";
5026 $(wndID + '.ww_ratio').append(
5027 '<legend>' + getText("labels", "leg") + ' (<span style="color:#090">' + (Math.round(wonder.ratio[AID] * 100) / 100) + '%</span>):</legend>' +
5028 '<div class="town-capacity-indicator">' +
5029 '<div class="icon all_res"></div>' +
5030 '<div id="ww_town_capacity_stadium" class="tripple-progress-progressbar">' +
5031 '<div class="border_l"></div><div class="border_r"></div><div class="body"></div>' +
5032 '<div class="progress overloaded">' +
5033 '<div class="indicator3 ' + stage_color + '" style="width:' + stage_width + 'px"></div>' +
5034 '<span class="ww_perc">' + Math.round(wonder.storage[AID][ww_type][stage] / ww_share.stage.share * 100) + '%</span>' +
5035 '</div>' +
5036 '<div class="amounts">' + getText("labels", "stg") + ': <span class="curr">' + pointNumber(wonder.storage[AID][ww_type][stage]) + '</span> / ' +
5037 '<span class="max">' + pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) + '</span></div>' +
5038 '</div></div>' +
5039 '<div class="town-capacity-indicator">' +
5040 '<div class="icon all_res"></div>' +
5041 '<div id="ww_town_capacity_total" class="tripple-progress-progressbar">' +
5042 '<div class="border_l"></div><div class="border_r"></div><div class="body"></div>' +
5043 '<div class="progress overloaded">' +
5044 '<div class="indicator3 ' + total_color + '" style="width:' + total_width + 'px;"></div>' +
5045 '<span class="ww_perc">' + Math.round(res_total / ww_share.total.share * 100) + '%</span>' +
5046 '</div>' +
5047 '<div class="amounts">' + getText("labels", "tot") + ': <span class="curr">' + pointNumber(res_total) + '</span> / ' +
5048 '<span class="max">' + pointNumber((Math.round(ww_share.total.share / 1000) * 1000)) + '</span></div>' +
5049 '</div></div>');
5050
5051 $(wndID + '.ww_ratio').tooltip(
5052 "<table style='border-spacing:0px; text-align:right' cellpadding='5px'><tr>" +
5053 "<td align='right' style='border-right: 1px solid;border-bottom: 1px solid'></td>" +
5054 "<td style='border-right: 1px solid; border-bottom: 1px solid'><span class='bbcodes_player bold'>(" + (Math.round((wonder.ratio[AID]) * 100) / 100) + "%)</span></td>" +
5055 "<td style='border-bottom: 1px solid'><span class='bbcodes_ally bold'>(100%)</span></td></tr>" +
5056 "<tr><td class='bold' style='border-right:1px solid;text-align:center'>" + getText("labels", "stg") + " " + stage + "</td>" +
5057 "<td style='border-right: 1px solid'>" + pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) + "</td>" +
5058 "<td>" + pointNumber(Math.round(ww_share.stage.sum / 1000) * 1000) + "</td></tr>" +
5059 "<tr><td class='bold' style='border-right:1px solid;text-align:center'>" + getText("labels", "tot") + "</td>" +
5060 "<td style='border-right: 1px solid'>" + pointNumber(Math.round(ww_share.total.share / 1000) * 1000) + "</td>" +
5061 "<td>" + pointNumber(Math.round(ww_share.total.sum / 1000) * 1000) + "</td>" +
5062 "</tr></table>");
5063
5064 } catch (error) {
5065 errorHandling(error, "setResWW");
5066 }
5067 }
5068
5069 // Adds points to numbers
5070 function pointNumber(number) {
5071 var sep;
5072 if (LID === "de") {
5073 sep = ".";
5074 } else {
5075 sep = ",";
5076 }
5077
5078 number = number.toString();
5079 if (number.length > 3) {
5080 var mod = number.length % 3;
5081 var output = (mod > 0 ? (number.substring(0, mod)) : '');
5082
5083 for (var i = 0; i < Math.floor(number.length / 3); i++) {
5084 if ((mod == 0) && (i == 0)) {
5085 output += number.substring(mod + 3 * i, mod + 3 * i + 3);
5086 } else {
5087 output += sep + number.substring(mod + 3 * i, mod + 3 * i + 3);
5088 }
5089 }
5090 number = output;
5091 }
5092 return number;
5093 }
5094
5095 /*******************************************************************************************************************************
5096 * Farming Village Overview
5097 * ----------------------------------------------------------------------------------------------------------------------------
5098 * | ● Color change on possibility of city festivals
5099 * ----------------------------------------------------------------------------------------------------------------------------
5100 * *****************************************************************************************************************************/
5101
5102 function changeResColor() {
5103 var res, res_min, i = 0;
5104 $('#fto_town_list .fto_resource_count :last-child').reverseList().each(function () {
5105 if ($(this).parent().hasClass("stone")) {
5106 res_min = 18000;
5107 } else {
5108 res_min = 15000;
5109 }
5110 res = parseInt(this.innerHTML, 10);
5111 if ((res >= res_min) && !($(this).hasClass("town_storage_full"))) {
5112 this.style.color = '#0A0';
5113 }
5114 if (res < res_min) {
5115 this.style.color = '#000';
5116 }
5117 });
5118 }
5119
5120 /********************************************************************************************************************************
5121 * Conquest Info
5122 * -----------------------------------------------------------------------------------------------------------------------------
5123 * | ● Amount of supports und attacks in the conquest window
5124 * | ● Layout adjustment (for reasons of clarity)
5125 * | - TODO: conquest window of own cities
5126 * -----------------------------------------------------------------------------------------------------------------------------
5127 * ******************************************************************************************************************************/
5128
5129 function countMovements() {
5130 var sup = 0, att = 0;
5131 $('.tab_content #unit_movements .support').each(function () {
5132 sup++;
5133 });
5134 $('.tab_content #unit_movements .attack_land, .tab_content #unit_movements .attack_sea, .tab_content #unit_movements .attack_takeover').each(function () {
5135 att++;
5136 });
5137
5138 var str = "<div id='move_counter' style=''><div style='float:left;margin-right:5px;'></div>" +
5139 "<div class='movement def'></div>" +
5140 "<div class='movement' style='color:green;'> " + sup + "</div>" +
5141 "<div class='movement off'> </div>" +
5142 "<div style='color:red;'> " + att + "</div></div>" +
5143 "<hr class='move_hr'>";
5144
5145 if ($('.gpwindow_content .tab_content .bold').get(0)) {
5146 $('.gpwindow_content .tab_content .bold').append(str);
5147 } else {
5148 $('.gpwindow_content h4:eq(1)').append(str);
5149
5150 // TODO: set player link ?
5151 /*
5152 $('#unit_movements li div').each(function(){
5153
5154 //console.log(this.innerHTML);
5155 });
5156 */
5157 }
5158
5159 $('<style id="dio_conquest"> ' +
5160 '.move_hr { margin:7px 0px 0px 0px; background-color:#5F5242; height:2px; border:0px solid; } ' +
5161 // Smaller movements
5162 '#unit_movements { font-size: 0.80em; } ' +
5163 '#unit_movements .incoming { width:150px; height:45px; float:left; } ' +
5164 // Counter
5165 '#move_counter { position:relative; width:100px; margin-top:-16px; left: 40%; } ' +
5166 '#move_counter .movement { float:left; margin:0px 5px 0px 0px; height:18px; width:18px; position:relative; } ' +
5167 '#move_counter .def { background:url(https://gpall.innogamescdn.com/images/game/place/losts.png); background-position:0 -36px; } ' +
5168 '#move_counter .off { background:url(https://gpall.innogamescdn.com/images/game/place/losts.png); background-position:0 0px; }' +
5169 '</style>').appendTo("head");
5170
5171 /*
5172 $('#unit_movements div').each(function(){
5173 if($(this).attr('class') === "unit_movements_arrow"){
5174 // delete placeholder for arrow of outgoing movements (there are no outgoing movements)
5175 if(!this.style.background) { this.remove(); }
5176 } else {
5177 // realign texts
5178 $(this).css({
5179 margin: '3px',
5180 paddingLeft: '3px'
5181 });
5182 }
5183 });
5184 */
5185 }
5186
5187 /*******************************************************************************************************************************
5188 * Town window
5189 * ----------------------------------------------------------------------------------------------------------------------------
5190 * | ● TownTabHandler (trade, attack, support,...)
5191 * | ● Sent units box
5192 * | ● Short duration: Display of 30% troop speed improvement in attack/support tab
5193 * | ● Trade options:
5194 * | - Ressource marks on possibility of city festivals
5195 * | - Percentual Trade: Trade button
5196 * | - Recruiting Trade: Selection boxes (ressource ratio of unit type + share of the warehouse capacity of the target town)
5197 * ----------------------------------------------------------------------------------------------------------------------------
5198 *******************************************************************************************************************************/
5199 var arrival_interval = {};
5200 // TODO: Change both functions in MultipleWindowHandler()
5201 function TownTabHandler(action) {
5202 var wndArray, wndID, wndA;
5203 wndArray = Layout.wnd.getOpen(uw.Layout.wnd.TYPE_TOWN);
5204 //console.log(wndArray);
5205 for (var e in wndArray) {
5206 if (wndArray.hasOwnProperty(e)) {
5207 //console.log(wndArray[e].getHandler());
5208 wndA = wndArray[e].getAction();
5209 wndID = "#gpwnd_" + wndArray[e].getID() + " ";
5210 if (!$(wndID).get(0)) {
5211 wndID = "#gpwnd_" + (wndArray[e].getID() + 1) + " ";
5212 }
5213 //console.log(wndID);
5214 if (wndA === action) {
5215 switch (action) {
5216 case "trading":
5217 if ($(wndID + '#trade_tab').get(0)) {
5218 if (!$(wndID + '.rec_trade').get(0) && DATA.options.rec) {
5219 RecruitingTrade.add(wndID);
5220 }
5221 //console.log(DATA.options.per);
5222 if (!$(wndID + '.btn_trade').get(0) && DATA.options.per) {
5223 addPercentTrade(wndID, false);
5224 }
5225 }
5226 //addTradeMarks(wndID, 15, 18, 15, "red"); // town festival
5227 break;
5228 case "support":
5229 case "attack":
5230 //if(!arrival_interval[wndID]){
5231 if (DATA.options.way && !($('.js-casted-powers-viewport .unit_movement_boost').get(0) || $(wndID + '.short_duration').get(0))) {
5232 //if(arrival_interval[wndID]) console.log("add " + wndID);
5233 ShortDuration.add(wndID);
5234 }
5235 if (DATA.options.sen) {
5236 SentUnits.add(wndID, action);
5237 }
5238 //}
5239 break;
5240 case "rec_mark":
5241 //addTradeMarks(wndID, 15, 18, 15, "lime");
5242 break;
5243 }
5244 }
5245 }
5246 }
5247 }
5248
5249 function WWTradeHandler() {
5250 var wndArray, wndID, wndA;
5251 wndArray = uw.GPWindowMgr.getOpen(uw.GPWindowMgr.TYPE_WONDERS);
5252 for (var e in wndArray) {
5253 if (wndArray.hasOwnProperty(e)) {
5254 wndID = "#gpwnd_" + wndArray[e].getID() + " ";
5255 if (DATA.options.per && !($(wndID + '.btn_trade').get(0) || $(wndID + '.next_building_phase').get(0) || $(wndID + '#ww_time_progressbar').get(0))) {
5256 addPercentTrade(wndID, true);
5257 }
5258 }
5259 }
5260 }
5261
5262 /*******************************************************************************************************************************
5263 * ● Sent units box
5264 *******************************************************************************************************************************/
5265 var SentUnits = {
5266 activate: function () {
5267 $.Observer(GameEvents.command.send_unit).subscribe('DIO_SEND_UNITS', function (e, data) {
5268 for (var z in data.params) {
5269 if (data.params.hasOwnProperty(z) && (data.sending_type !== "")) {
5270 if (uw.GameData.units[z]) {
5271 sentUnitsArray[data.sending_type][z] = (sentUnitsArray[data.sending_type][z] == undefined ? 0 : sentUnitsArray[data.sending_type][z]);
5272 sentUnitsArray[data.sending_type][z] += data.params[z];
5273 }
5274 }
5275 }
5276 //SentUnits.update(data.sending_type); ????
5277 });
5278 },
5279 deactivate: function () {
5280 $.Observer(GameEvents.command.send_unit).unsubscribe('DIO_SEND_UNITS');
5281 },
5282 add: function (wndID, action) {
5283 if (!$(wndID + '.sent_units_box').get(0)) {
5284 $('<div class="game_inner_box sent_units_box ' + action + '"><div class="game_border ">' +
5285 '<div class="game_border_top"></div><div class="game_border_bottom"></div><div class="game_border_left"></div><div class="game_border_right"></div>' +
5286 '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
5287 '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
5288 '<div class="game_header bold">' +
5289 '<div class="icon_sent townicon_' + (action == "attack" ? "lo" : "ld") + '"></div><span>' + getText("labels", "lab") + ' (' + (action == "attack" ? "OFF" : "DEF") + ')</span>' +
5290 '</div>' +
5291 '<div class="troops"><div class="units_list"></div><hr style="width: 172px;border: 1px solid rgb(185, 142, 93);margin: 3px 0px 2px -1px;">' +
5292 '<div id="btn_sent_units_reset" class="button_new">' +
5293 '<div class="left"></div>' +
5294 '<div class="right"></div>' +
5295 '<div class="caption js-caption">' + getText("buttons", "res") + '<div class="effect js-effect"></div></div>' +
5296 '</div>' +
5297 '</div></div>').appendTo(wndID + '.attack_support_window');
5298
5299 SentUnits.update(action);
5300
5301 $(wndID + '.icon_sent').css({
5302 height: '20px',
5303 marginTop: '-2px',
5304 width: '20px',
5305 backgroundPositionY: '-26px',
5306 paddingLeft: '0px',
5307 marginLeft: '0px'
5308 });
5309
5310 $(wndID + '.sent_units_box').css({
5311 position: 'absolute',
5312 right: '0px',
5313 bottom: '16px',
5314 width: '192px'
5315 });
5316 $(wndID + '.troops').css({padding: '6px 0px 6px 6px'});
5317
5318 $(wndID + '#btn_sent_units_reset').click(function () {
5319 // Overwrite old array
5320 sentUnitsArray[action] = {};
5321
5322 SentUnits.update(action);
5323 });
5324 }
5325 },
5326 update: function (action) {
5327 try {
5328 // Remove old unit list
5329 $('.sent_units_box.' + action + ' .units_list').each(function () {
5330 this.innerHTML = "";
5331 });
5332 // Add new unit list
5333 for (var x in sentUnitsArray[action]) {
5334 if (sentUnitsArray[action].hasOwnProperty(x)) {
5335 if ((sentUnitsArray[action][x] || 0) > 0) {
5336 $('.sent_units_box.' + action + ' .units_list').each(function () {
5337 $(this).append('<div class="unit_icon25x25 ' + x +
5338 (sentUnitsArray[action][x] >= 1000 ? (sentUnitsArray[action][x] >= 10000 ? " five_digit_number" : " four_digit_number") : "") + '">' +
5339 '<span class="count text_shadow">' + sentUnitsArray[action][x] + '</span>' +
5340 '</div>');
5341 });
5342 }
5343 }
5344 }
5345 saveValue(WID + "_sentUnits", JSON.stringify(sentUnitsArray));
5346 } catch (error) {
5347 errorHandling(error, "updateSentUnitsBox");
5348 }
5349 }
5350 };
5351
5352 /*******************************************************************************************************************************
5353 * ● Short duration
5354 *******************************************************************************************************************************/
5355
5356 // TODO: Calculator implementieren
5357 var DurationCalculator = {
5358 activate: function () {
5359 var speedBoosterSprite = "https://diotools.de/images/game/speed_booster.png";
5360
5361 $('<style id="dio_duration_calculator_style">' +
5362 '.dio_speed_booster { border:1px solid #724B08; border-spacing: 0px;} ' +
5363 '.dio_speed_booster td { border:0; padding:2px; } ' +
5364 '.dio_speed_booster .checkbox_new { margin: 4px 0px 1px 3px; } ' +
5365 '.dio_speed_booster .odd { background: url("https://gpall.innogamescdn.com/images/game/border/brown.png") repeat scroll 0% 0% transparent; } ' +
5366 '.dio_speed_booster .even { background: url("https://gpall.innogamescdn.com/images/game/border/odd.png") repeat scroll 0% 0% transparent; } ' +
5367 '.booster_icon { width:20px; height:20px; background-image:url(' + speedBoosterSprite + ');} ' +
5368 '.booster_icon.improved_speed { background-position:0 0; } ' +
5369 '.booster_icon.cartography { background-position:-20px 0; } ' +
5370 '.booster_icon.meteorology { background-position:-40px 0; } ' +
5371 '.booster_icon.lighthouse { background-position:-60px 0; } ' +
5372 '.booster_icon.set_sail { background-position:-80px 0; } ' +
5373 '.booster_icon.atalanta { background-position:-100px 0; } ' +
5374 '</style>').appendTo('head');
5375
5376 $('<table class="dio_speed_booster"><tr>' +
5377 '<td class="odd"><div class="booster_icon improved_speed"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5378 '<td class="even"><div class="booster_icon cartography"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5379 '<td class="odd"><div class="booster_icon meteorology"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5380 '<td class="even"><div class="booster_icon lighthouse"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5381 '<td class="odd"><div class="booster_icon set_sail"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5382 '<td class="even"><div class="booster_icon atalanta"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5383 '</tr></table>').appendTo(wndID + ".duration_container");
5384 },
5385 deactivate: function () {
5386 $('#dio_duration_calculator_style').remove();
5387 },
5388 add: function (wndID, data) {
5389
5390 }
5391 };
5392
5393
5394 var ShortDuration = {
5395 activate: function () {
5396
5397 $('<style id="dio_short_duration_style">' +
5398 '.attack_support_window .tab_type_support .duration_container { top:0px !important; } ' +
5399 //'.attack_support_window .tab_type_attack .duration_container { width:auto; top:10px; } ' +
5400
5401 '.attack_support_window .dio_duration { border-spacing:0px; margin-bottom:2px; text-align:right; } ' +
5402
5403 '.attack_support_window .way_duration, '+
5404 '.attack_support_window .arrival_time { padding:0px 0px 0px 0px; background:none; } ' +
5405
5406 '.attack_support_window .way_icon { padding:30px 0px 0px 30px; background:transparent url(https://gpall.innogamescdn.com/images/game/towninfo/traveltime.png) no-repeat 0 0; } ' +
5407 '.attack_support_window .arrival_icon { padding:30px 0px 0px 30px; background:transparent url(https://gpall.innogamescdn.com/images/game/towninfo/arrival.png) no-repeat 0 0; } ' +
5408 '.attack_support_window .short_icon { padding:20px 0px 0px 30px; background:url(http://666kb.com/i/ck2c7eohpyfa3yczt.png) 11px -1px / 21px no-repeat; filter: hue-rotate(50deg); -webkit-filter: hue-rotate(50deg); } ' +
5409
5410 '.attack_support_window .max_booty { padding:0px 0px 0px 30px; margin:3px 4px 4px 4px; width:auto; } ' +
5411 '.attack_support_window .fight_bonus.morale { margin-top:2px; } ' +
5412
5413 '</style>').appendTo('head');
5414
5415 },
5416 deactivate: function () {
5417 $("#dio_short_duration_style").remove();
5418 },
5419 add: function (wndID) {
5420 //console.log($(wndID + ".duration_container").get(0));
5421 try {
5422 var tooltip = (LANG.hasOwnProperty(LID) ? getText("labels", "improved_movement") : "") + " (+30% " + DM.getl10n("barracks", "tooltips").speed.trim() + ")";
5423
5424 $('<table class="dio_duration">' +
5425 '<tr><td class="way_icon"></td><td class="dio_way"></td><td class="arrival_icon"></td><td class="dio_arrival"></td><td colspan="2" class="dio_night"></td></tr>' +
5426 '<tr class="short_duration_row" style="color:darkgreen">' +
5427 '<td> ╚> </td><td><span class="short_duration">~0:00:00</span></td>' +
5428 '<td> ╚></td><td><span class="short_arrival">~00:00:00</span></td>' +
5429 '<td class="short_icon"></td><td></td></tr>' +
5430 '</table>').prependTo(wndID + ".duration_container");
5431
5432
5433
5434 $(wndID + ".nightbonus").appendTo(wndID + ".dio_night");
5435 $(wndID + '.way_duration').appendTo(wndID + ".dio_way");
5436 $(wndID + ".arrival_time").appendTo(wndID + ".dio_arrival");
5437
5438
5439 // Tooltip
5440 $(wndID + '.short_duration_row').tooltip(tooltip);
5441
5442 // Detection of changes
5443 ShortDuration.change(wndID);
5444 // $(wndID + '.way_duration').bind('DOMSubtreeModified', function(e) { console.log(e); }); // Alternative
5445
5446 } catch (error) {
5447 errorHandling(error, "addShortDuration");
5448 }
5449 },
5450 change: function (wndID) {
5451 var duration = new MutationObserver(function (mutations) {
5452 mutations.forEach(function (mutation) {
5453 if (mutation.addedNodes[0]) {
5454 //console.debug(mutation);
5455 ShortDuration.calculate(wndID);
5456 }
5457 });
5458 });
5459 if ($(wndID + '.way_duration').get(0)) {
5460 duration.observe($(wndID + '.way_duration').get(0), {
5461 attributes: false,
5462 childList: true,
5463 characterData: false
5464 });
5465 }
5466 },
5467 //$('<style> .duration_container { display: block !important } </style>').appendTo("head");
5468 calculate: function (wndID) {
5469 //console.log(wndID);
5470 //console.log($(wndID + '.duration_container .way_duration').get(0));
5471 try {
5472 var setup_time = 900 / Game.game_speed,
5473 duration_time = $(wndID + '.duration_container .way_duration').get(0).innerHTML.replace("~", "").split(":"),
5474 // TODO: hier tritt manchmal Fehler auf TypeError: Cannot read property "innerHTML" of undefined at calcShortDuration (<anonymous>:3073:86)
5475 arrival_time,
5476 h, m, s,
5477 atalanta_factor = 0;
5478
5479 var hasCartography = ITowns.getTown(Game.townId).getResearches().get("cartography");
5480 var hasMeteorology = ITowns.getTown(Game.townId).getResearches().get("meteorology");
5481 var hasSetSail = ITowns.getTown(Game.townId).getResearches().get("set_sail");
5482
5483 var hasLighthouse = ITowns.getTown(Game.townId).buildings().get("lighthouse");
5484
5485 // Atalanta aktiviert?
5486 if ($(wndID + '.unit_container.heroes_pickup .atalanta').get(0)) {
5487 if ($(wndID + '.cbx_include_hero').hasClass("checked")) {
5488 // Beschleunigung hängt vom Level ab, Level 1 = 11%, Level 20 = 30%
5489 var atalanta_level = MM.getCollections().PlayerHero[0].models[1].get("level");
5490
5491 atalanta_factor = (atalanta_level + 10) / 100;
5492 }
5493 }
5494
5495 // Sekunden, Minuten und Stunden zusammenrechnen (-> in Sekunden)
5496 duration_time = ((parseInt(duration_time[0], 10) * 60 + parseInt(duration_time[1], 10)) * 60 + parseInt(duration_time[2], 10));
5497
5498 // Verkürzte Laufzeit berechnen
5499 duration_time = ((duration_time - setup_time) * (1 + atalanta_factor)) / (1 + 0.3 + atalanta_factor) + setup_time;
5500
5501
5502 h = Math.floor(duration_time / 3600);
5503 m = Math.floor((duration_time - h * 3600) / 60);
5504 s = Math.floor(duration_time - h * 3600 - m * 60);
5505
5506 if (m < 10) {
5507 m = "0" + m;
5508 }
5509 if (s < 10) {
5510 s = "0" + s;
5511 }
5512
5513 $(wndID + '.short_duration').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
5514
5515 // Ankunftszeit errechnen
5516 arrival_time = Math.round((Timestamp.server() + Game.server_gmt_offset)) + duration_time;
5517
5518 h = Math.floor(arrival_time / 3600);
5519 m = Math.floor((arrival_time - h * 3600) / 60);
5520 s = Math.floor(arrival_time - h * 3600 - m * 60);
5521
5522 h %= 24;
5523
5524 if (m < 10) {
5525 m = "0" + m;
5526 }
5527 if (s < 10) {
5528 s = "0" + s;
5529 }
5530
5531 $(wndID + '.short_arrival').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
5532
5533 clearInterval(arrival_interval[wndID]);
5534
5535 arrival_interval[wndID] = setInterval(function () {
5536 arrival_time += 1;
5537
5538 h = Math.floor(arrival_time / 3600);
5539 m = Math.floor((arrival_time - h * 3600) / 60);
5540 s = Math.floor(arrival_time - h * 3600 - m * 60);
5541
5542 h %= 24;
5543
5544 if (m < 10) {
5545 m = "0" + m;
5546 }
5547 if (s < 10) {
5548 s = "0" + s;
5549 }
5550
5551 if ($(wndID + '.short_arrival').get(0)) {
5552 $(wndID + '.short_arrival').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
5553 } else {
5554 clearInterval(arrival_interval[wndID]);
5555 }
5556 }, 1000);
5557
5558 } catch (error) {
5559 errorHandling(error, "ShortDuration.calculate");
5560 }
5561 }
5562 };
5563
5564 /*******************************************************************************************************************************
5565 * ● Dropdown menu
5566 *******************************************************************************************************************************/
5567
5568 // TODO: Umstellen!
5569 // Preload images for drop down arrow buttons
5570 var drop_over = new Image();
5571 drop_over.src = "";
5572 var drop_out = new Image();
5573 drop_out.src = "";
5574
5575 function changeDropDownButton() {
5576 $('<style id="dio_style_arrow" type="text/css">' +
5577 '#dd_filter_type .arrow, .select_rec_unit .arrow {' +
5578 'width: 18px !important; height: 17px !important; background: url() no-repeat 0px -1px !important;' +
5579 'position: absolute; top: 2px !important; right: 3px; } ' +
5580 '</style>').appendTo('head');
5581
5582 }
5583
5584 /*******************************************************************************************************************************
5585 * ● Recruiting Trade
5586 * *****************************************************************************************************************************/
5587 var trade_count = 0, unit = "FS", percent = "0.0"; // Recruiting Trade
5588
5589 // TODO: Funktion umformen, Style anpassen!
5590 var RecruitingTrade = {
5591 activate: function () {
5592 $('<style id="dio_style_recruiting_trade" type="text/css">' +
5593 '#dio_recruiting_trade .option_s { filter:grayscale(100%); -webkit-filter:grayscale(100%); margin:0px; cursor:pointer; } ' +
5594 '#dio_recruiting_trade .option_s:hover { filter:unset !important; -webkit-filter:unset !important; } ' +
5595 '#dio_recruiting_trade .select_rec_unit .sel { filter:sepia(100%); -webkit-filter:sepia(100%); } ' +
5596
5597 '#dio_recruiting_trade .option {color:#000; background:#FFEEC7; } ' +
5598 '#dio_recruiting_trade .option:hover {color:#fff; background:#328BF1; } ' +
5599
5600 '#dio_recruiting_trade { position:absolute; left:30px; top:70px; } ' +
5601 '#dio_recruiting_trade .select_rec_unit { position:absolute; top:20px; width:84px; display:none; } ' +
5602 '#dio_recruiting_trade .select_rec_perc { position:absolute; top:20px; width:50px; display:none; left:50px; } ' +
5603
5604 '#dio_recruiting_trade .open { display:block !important; } '+
5605
5606 '#dio_recruiting_trade .item-list { max-height:unset; } ' +
5607
5608 '#dio_recruiting_trade .arrow { width:18px; height:18px; background:url(' + drop_out.src + ') no-repeat -1px -1px; position:absolute; } ' +
5609
5610 '#trade_tab .content { height:320px; } ' +
5611
5612 '#dio_recruiting_trade .rec_count { position:absolute; top:25px; } ' +
5613
5614 '#dio_recruiting_trade .drop_rec_unit { position:absolute; display:block; width:50px; overflow:visible; } ' +
5615 '#dio_recruiting_trade .drop_rec_perc { position:absolute; display:block; width:55px; left:49px; color:#000; } ' +
5616
5617 '</style>').appendTo('head');
5618 },
5619 deactivate: function () {
5620 $('#dio_style_recruiting_trade').remove();
5621 },
5622 add: function (wndID) {
5623 var max_amount;
5624
5625 $('<div id="dio_recruiting_trade" class="rec_trade">' +
5626 // DropDown-Button for unit
5627 '<div class="drop_rec_unit dropdown default">' +
5628 '<div class="border-left"></div>' +
5629 '<div class="border-right"></div>' +
5630 '<div class="caption" name="' + unit + '">' + unit + '</div>' +
5631 '<div class="arrow"></div>' +
5632 '</div>' +
5633 '<div class="drop_rec_perc dropdown default">' +
5634 // DropDown-Button for ratio
5635 '<div class="border-left"></div>' +
5636 '<div class="border-right"></div>' +
5637 '<div class="caption" name="' + percent + '">' + Math.round(percent * 100) + '%</div>' +
5638 '<div class="arrow"></div>' +
5639 '</div><span class="rec_count">(' + trade_count + ')</span></div>').appendTo(wndID + ".content");
5640
5641 // Select boxes for unit and ratio
5642 $('<div class="select_rec_unit dropdown-list default active">' +
5643 '<div class="item-list">' +
5644 '<div class="option_s unit index_unit unit_icon40x40 attack_ship" name="FS"></div>' +
5645 '<div class="option_s unit index_unit unit_icon40x40 bireme" name="BI"></div>' +
5646 '<div class="option_s unit index_unit unit_icon40x40 sword" name="SK"></div>' +
5647 '<div class="option_s unit index_unit unit_icon40x40 slinger" name="SL"></div>' +
5648 '<div class="option_s unit index_unit unit_icon40x40 archer" name="BS"></div>' +
5649 '<div class="option_s unit index_unit unit_icon40x40 hoplite" name="HO"></div>' +
5650 '<div class="option_s unit index_unit unit_icon40x40 rider" name="RE"></div>' +
5651 '<div class="option_s unit index_unit unit_icon40x40 chariot" name="SW"></div>' +
5652 '</div></div>').appendTo(wndID + ".rec_trade");
5653 $('<div class="select_rec_perc dropdown-list default inactive">' +
5654 '<div class="item-list">' +
5655 '<div class="option sel" name="0.0"> 0%</div>' +
5656 '<div class="option" name="0.05"> 5%</div>' +
5657 '<div class="option" name="0.1">10%</div>' +
5658 '<div class="option" name="0.16666">17%</div>' +
5659 '<div class="option" name="0.2">20%</div>' +
5660 '<div class="option" name="0.25">25%</div>' +
5661 '<div class="option" name="0.33">33%</div>' +
5662 '<div class="option" name="0.5">50%</div>' +
5663 '</div></div>').appendTo(wndID + ".rec_trade");
5664
5665 $(wndID + ".rec_trade [name='" + unit + "']").toggleClass("sel");
5666
5667 // click events of the drop menu
5668 $(wndID + ' .select_rec_unit .option_s').each(function () {
5669 $(this).click(function (e) {
5670 $(".select_rec_unit .sel").toggleClass("sel");
5671 $("." + this.className.split(" ")[4]).toggleClass("sel");
5672
5673 unit = $(this).attr("name");
5674 $('.drop_rec_unit .caption').attr("name", unit);
5675 $('.drop_rec_unit .caption').each(function () {
5676 this.innerHTML = unit;
5677 });
5678 $($(this).parent().parent().get(0)).removeClass("open");
5679 $('.drop_rec_unit .caption').change();
5680 });
5681 });
5682 $(wndID + ' .select_rec_perc .option').each(function () {
5683 $(this).click(function (e) {
5684 $(this).parent().find(".sel").toggleClass("sel");
5685 $(this).toggleClass("sel");
5686
5687 percent = $(this).attr("name");
5688 $('.drop_rec_perc .caption').attr("name", percent);
5689 $('.drop_rec_perc .caption').each(function () {
5690 this.innerHTML = Math.round(percent * 100) + "%";
5691 });
5692 $($(this).parent().parent().get(0)).removeClass("open")
5693 $('.drop_rec_perc .caption').change();
5694 });
5695 });
5696
5697 // show & hide drop menus on click
5698 $(wndID + '.drop_rec_perc').click(function (e) {
5699
5700 if (!$($(e.target)[0].parentNode.parentNode.childNodes[4]).hasClass("open")) {
5701 $($(e.target)[0].parentNode.parentNode.childNodes[4]).addClass("open");
5702 $($(e.target)[0].parentNode.parentNode.childNodes[3]).removeClass("open");
5703 } else {
5704 $($(e.target)[0].parentNode.parentNode.childNodes[4]).removeClass("open");
5705 }
5706 });
5707 $(wndID + '.drop_rec_unit').click(function (e) {
5708
5709 if (!$($(e.target)[0].parentNode.parentNode.childNodes[3]).hasClass("open")) {
5710 $($(e.target)[0].parentNode.parentNode.childNodes[3]).addClass("open");
5711 $($(e.target)[0].parentNode.parentNode.childNodes[4]).removeClass("open");
5712 } else {
5713 $($(e.target)[0].parentNode.parentNode.childNodes[3]).removeClass("open");
5714 }
5715 });
5716
5717 $(wndID).click(function (e) {
5718 var clicked = $(e.target), element = $('#' + this.id + ' .dropdown-list.open').get(0);
5719 if ((clicked[0].parentNode.className.split(" ")[1] !== "dropdown") && element) {
5720 $(element).removeClass("open");
5721 }
5722 });
5723
5724 // hover arrow change
5725 $(wndID + '.dropdown').hover(function (e) {
5726 $(e.target)[0].parentNode.childNodes[3].style.background = "url('" + drop_over.src + "') no-repeat -1px -1px";
5727 }, function (e) {
5728 $(e.target)[0].parentNode.childNodes[3].style.background = "url('" + drop_out.src + "') no-repeat -1px -1px";
5729 });
5730
5731 $(wndID + ".drop_rec_unit .caption").attr("name", unit);
5732 $(wndID + ".drop_rec_perc .caption").attr("name", percent);
5733
5734 $(wndID + '.drop_rec_unit').tooltip(getText("labels", "rat"));
5735 $(wndID + '.drop_rec_perc').tooltip(getText("labels", "shr"));
5736
5737 var ratio = {
5738 NO: {w: 0, s: 0, i: 0},
5739 FS: {w: 1, s: 0.2308, i: 0.6154},
5740 BI: {w: 1, s: 0.8750, i: 0.2250},
5741 SL: {w: 0.55, s: 1, i: 0.4},
5742 RE: {w: 0.6666, s: 0.3333, i: 1},
5743 SK: {w: 1, s: 0, i: 0.8947},
5744 HO: {w: 0, s: 0.5, i: 1},
5745 BS: {w: 1, s: 0, i: 0.6250},
5746 SW: {w: 0.4545, s: 1, i: 0.7273}
5747 };
5748
5749
5750 if ($('#town_capacity_wood .max').get(0)) {
5751 max_amount = parseInt($('#town_capacity_wood .max').get(0).innerHTML, 10);
5752 } else {
5753 max_amount = 25500;
5754 }
5755
5756 $(wndID + '.caption').change(function (e) {
5757 //console.log($(this).attr('name') + ", " + unit + "; " + percent);
5758 if (!(($(this).attr('name') === unit) || ($(this).attr('name') === percent))) {
5759 //trade_count = 0;
5760 $('.rec_count').get(0).innerHTML = "(" + trade_count + ")";
5761 }
5762
5763 var tmp = $(this).attr('name');
5764
5765 if ($(this).parent().attr('class').split(" ")[0] === "drop_rec_unit") {
5766 unit = tmp;
5767 } else {
5768 percent = tmp;
5769 }
5770 var max = (max_amount - 100) / 1000;
5771 addTradeMarks(max * ratio[unit].w, max * ratio[unit].s, max * ratio[unit].i, "lime");
5772
5773 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)
5774 var rArray = uw.ITowns.getTown(uw.Game.townId).getCurrentResources();
5775 var tradeCapacity = uw.ITowns.getTown(uw.Game.townId).getAvailableTradeCapacity();
5776
5777 var wood = ratio[unit].w * part;
5778 var stone = ratio[unit].s * part;
5779 var iron = ratio[unit].i * part;
5780
5781 if ((wood > rArray.wood) || (stone > rArray.stone) || (iron > rArray.iron) || ( (wood + stone + iron) > tradeCapacity)) {
5782 wood = stone = iron = 0;
5783 $('.drop_rec_perc .caption').css({color: '#f00'});
5784 //$('.' + e.target.parentNode.parentNode.className + ' .select_rec_perc .sel').css({color:'#f00'});
5785 //$('.select_rec_perc .sel').css({color:'#f00'});
5786 } else {
5787 $('.' + e.target.parentNode.parentNode.className + ' .drop_rec_perc .caption').css({color: '#000'});
5788 }
5789 $("#trade_type_wood [type='text']").select().val(wood).blur();
5790 $("#trade_type_stone [type='text']").select().val(stone).blur();
5791 $("#trade_type_iron [type='text']").select().val(iron).blur();
5792 });
5793
5794 $('#trade_button').click(function () {
5795 trade_count++;
5796 $('.rec_count').get(0).innerHTML = "(" + trade_count + ")";
5797
5798 });
5799
5800 $(wndID + '.drop_rec_perc .caption').change();
5801 }
5802 };
5803
5804 /*******************************************************************************************************************************
5805 * ● Ressources marks
5806 *******************************************************************************************************************************/
5807 function addTradeMarks(woodmark, stonemark, ironmark, color) {
5808 var max_amount, limit, wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_TOWN), wndID;
5809 for (var e in wndArray) {
5810 if (wndArray.hasOwnProperty(e)) {
5811 wndID = "#gpwnd_" + wndArray[e].getID() + " ";
5812 if ($(wndID + '.town-capacity-indicator').get(0)) {
5813
5814 max_amount = $(wndID + '.amounts .max').get(0).innerHTML;
5815
5816 $('#trade_tab .c_' + color).each(function () {
5817 this.remove();
5818 });
5819 $('#trade_tab .progress').each(function () {
5820 if ($("p", this).length < 3) {
5821 if ($(this).parent().get(0).id != "big_progressbar") {
5822 limit = 1000 * (242 / parseInt(max_amount, 10));
5823
5824 switch ($(this).parent().get(0).id.split("_")[2]) {
5825 case "wood":
5826 limit = limit * woodmark;
5827 break;
5828 case "stone":
5829 limit = limit * stonemark;
5830 break;
5831 case "iron":
5832 limit = limit * ironmark;
5833 break;
5834 }
5835 $('<p class="c_' + color + '"style="position:absolute;left: ' + limit + 'px; background:' + color + ';width:2px;height:100%;margin:0px"></p>').appendTo(this);
5836 }
5837 }
5838 });
5839 }
5840 }
5841 }
5842 }
5843
5844 /*******************************************************************************************************************************
5845 * ● Percentual Trade
5846 *******************************************************************************************************************************/
5847 var rest_count = 0;
5848
5849 function addPercentTrade(wndID, ww) {
5850
5851 var a = "";
5852 var content = wndID + ".content";
5853 if (ww) {
5854 a = "ww_";
5855 content = wndID + '.trade .send_res';
5856 }
5857 $('<div class="btn btn_trade"><a class="button" href="#">' +
5858 '<span class="left"><span class="right">' +
5859 '<span class="middle mid">' +
5860 '<span class="img_trade"></span></span></span></span>' +
5861 '<span style="clear:both;"></span>' +
5862 '</a></div>').prependTo(content);
5863
5864 $(wndID + '.btn_trade').tooltip(getText("labels", "per"));
5865
5866 setPercentTrade(wndID, ww);
5867
5868 // Style
5869 $(wndID + '.btn').css({width: '20px', overflow: 'visible', position: 'absolute', display: 'block'});
5870
5871 if (!ww) {
5872 $(wndID + '.content').css({height: '320px'});
5873 }
5874
5875 if (ww) {
5876 $(wndID + '.btn_trade').css({left: '678px', top: '154px'});
5877 } else {
5878 $(wndID + '.btn_trade').css({left: '336px', top: '135px'});
5879 }
5880
5881 $(wndID + '.mid').css({minWidth: '26px'});
5882
5883 $(wndID + '.img_trade').css({
5884 width: '27px',
5885 height: '27px',
5886 top: '-3px',
5887 float: 'left',
5888 position: 'relative',
5889 background: 'url("http://666kb.com/i/cjq6d72qk521ig1zz.png") no-repeat'
5890 });
5891
5892 }
5893
5894 var res = {};
5895
5896 function setPercentTrade(wndID, ww) {
5897 var a = ww ? "ww_" : "", own_town = $(wndID + '.town_info').get(0) ? true : false;
5898
5899 $(wndID + '.btn_trade').toggleClick(function () {
5900 res.wood = {};
5901 res.stone = {};
5902 res.iron = {};
5903 res.sum = {};
5904
5905 res.sum.amount = 0;
5906 // Set amount of resources to 0
5907 setAmount(true, a, wndID);
5908 // Total amount of resources // TODO: ITowns.getTown(Game.townId).getCurrentResources(); ?
5909 for (var e in res) {
5910 if (res.hasOwnProperty(e) && e != "sum") {
5911 res[e].rest = false;
5912 res[e].amount = parseInt($('.ui_resources_bar .' + e + ' .amount').get(0).innerHTML, 10);
5913 res.sum.amount += res[e].amount;
5914 }
5915 }
5916 // Percentage of total resources
5917 res.wood.percent = 100 / res.sum.amount * res.wood.amount;
5918 res.stone.percent = 100 / res.sum.amount * res.stone.amount;
5919 res.iron.percent = 100 / res.sum.amount * res.iron.amount;
5920
5921 // Total trading capacity
5922 res.sum.cur = parseInt($(wndID + '#' + a + 'big_progressbar .caption .curr').get(0).innerHTML, 10);
5923
5924 // Amount of resources on the percentage of trading capacity (%)
5925 res.wood.part = parseInt(res.sum.cur / 100 * res.wood.percent, 10);
5926 res.stone.part = parseInt(res.sum.cur / 100 * res.stone.percent, 10);
5927 res.iron.part = parseInt(res.sum.cur / 100 * res.iron.percent, 10);
5928
5929 // Get rest warehouse capacity of each resource type
5930 for (var f in res) {
5931 if (res.hasOwnProperty(f) && f != "sum") {
5932 if (!ww && own_town) { // Own town
5933 var curr = parseInt($(wndID + '#town_capacity_' + f + ' .amounts .curr').get(0).innerHTML.replace('+', '').trim(), 10) || 0,
5934 curr2 = parseInt($(wndID + '#town_capacity_' + f + ' .amounts .curr2').get(0).innerHTML.replace('+', '').trim(), 10) || 0,
5935 max = parseInt($(wndID + '#town_capacity_' + f + ' .amounts .max').get(0).innerHTML.replace('+', '').trim(), 10) || 0;
5936
5937 res[f].cur = curr + curr2;
5938 res[f].max = max - res[f].cur;
5939
5940 if (res[f].max < 0) {
5941 res[f].max = 0;
5942 }
5943
5944 } else { // World wonder or foreign town
5945 res[f].max = 30000;
5946 }
5947 }
5948 }
5949 // Rest of fraction (0-2 units) add to stone amount
5950 res.stone.part += res.sum.cur - (res.wood.part + res.stone.part + res.iron.part);
5951
5952 res.sum.rest = 0;
5953 rest_count = 0;
5954 calcRestAmount();
5955 setAmount(false, a, wndID);
5956 }, function () {
5957 setAmount(true, a, wndID);
5958 });
5959 }
5960
5961 function calcRestAmount() {
5962 // Subdivide rest
5963 if (res.sum.rest > 0) {
5964 for (var e in res) {
5965 if (res.hasOwnProperty(e) && e != "sum" && res[e].rest != true) {
5966 res[e].part += res.sum.rest / (3 - rest_count);
5967 }
5968 }
5969 res.sum.rest = 0;
5970 }
5971 // Calculate new rest
5972 for (var f in res) {
5973 if (res.hasOwnProperty(f) && f != "sum" && res[f].rest != true) {
5974 if (res[f].max <= res[f].part) {
5975 res[f].rest = true;
5976 res.sum.rest += res[f].part - res[f].max;
5977 rest_count += 1;
5978 res[f].part = res[f].max;
5979 }
5980 }
5981 }
5982 // Recursion
5983 if (res.sum.rest > 0 && rest_count < 3) {
5984 calcRestAmount();
5985 }
5986 }
5987
5988 function setAmount(clear, a, wndID) {
5989 for (var e in res) {
5990 if (res.hasOwnProperty(e) && e != "sum") {
5991 if (clear == true) {
5992 res[e].part = 0;
5993 }
5994 $(wndID + "#" + a + "trade_type_" + e + ' [type="text"]').select().val(res[e].part).blur();
5995 }
5996 }
5997 }
5998
5999 /********************************************************************************************************************************
6000 * Unit strength (blunt/sharp/distance) and Transport Capacity
6001 * ----------------------------------------------------------------------------------------------------------------------------
6002 * | ● Unit strength: Menu
6003 * | - Switching of def/off display with buttons
6004 * | - Possible Selection of certain unit types
6005 * | ● Unit strength: Conquest
6006 * | ● Unit strength: Barracks
6007 * | ● Transport capacity: Menu
6008 * | - Switching of transporter speed (+/- big transporter)
6009 * ----------------------------------------------------------------------------------------------------------------------------
6010 * ******************************************************************************************************************************/
6011
6012 var def = true, blunt = 0, sharp = 0, dist = 0, shipsize = false;
6013
6014 var UnitStrength = {
6015 // Calculate defensive strength
6016 calcDef: function (units) {
6017 var e;
6018 blunt = sharp = dist = 0;
6019 for (e in units) {
6020 if (units.hasOwnProperty(e)) {
6021 blunt += units[e] * uw.GameData.units[e].def_hack;
6022 sharp += units[e] * uw.GameData.units[e].def_pierce;
6023 dist += units[e] * uw.GameData.units[e].def_distance;
6024 }
6025 }
6026 },
6027 // Calculate offensive strength
6028 calcOff: function (units, selectedUnits) {
6029 var e;
6030 blunt = sharp = dist = 0;
6031 for (e in selectedUnits) {
6032 if (selectedUnits.hasOwnProperty(e)) {
6033 var attack = (units[e] || 0) * uw.GameData.units[e].attack;
6034 switch (uw.GameData.units[e].attack_type) {
6035 case 'hack':
6036 blunt += attack;
6037 break;
6038 case 'pierce':
6039 sharp += attack;
6040 break;
6041 case 'distance':
6042 dist += attack;
6043 break;
6044 }
6045 }
6046 }
6047 },
6048 /*******************************************************************************************************************************
6049 * ● Unit strength: Unit menu
6050 *******************************************************************************************************************************/
6051 Menu: {
6052 activate: function () {
6053 $('<div id="strength" class="cont def"><hr>' +
6054 '<span class="bold text_shadow cont_left strength_font">' +
6055 '<table style="margin:0px;">' +
6056 '<tr><td><div class="ico units_info_sprite img_hack"></td><td id="blunt">0</td></tr>' +
6057 '<tr><td><div class="ico units_info_sprite img_pierce"></td><td id="sharp">0</td></tr>' +
6058 '<tr><td><div class="ico units_info_sprite img_dist"></td><td id="dist">0</td></tr>' +
6059 '</table>' +
6060 '</span>' +
6061 '<div class="cont_right">' +
6062 '<img id="def_button" class="active img" src="https://gpall.innogamescdn.com/images/game/unit_overview/support.png">' +
6063 '<img id="off_button" class="img" src="https://gpall.innogamescdn.com/images/game/unit_overview/attack.png">' +
6064 '</div></div>').appendTo('.units_land .content');
6065
6066 // Style
6067 $('<style id="dio_strength_style">' +
6068 '#strength.def #off_button, #strength.off #def_button { filter:url(#Sepia); -webkit-filter:sepia(1); }' +
6069 '#strength.off #off_button, #strength.def #def_button { filter:none; -webkit-filter:none; } ' +
6070
6071 '#strength.off .img_hack { background-position:0% 36%;} ' +
6072 '#strength.def .img_hack { background-position:0% 0%;} ' +
6073 '#strength.off .img_pierce { background-position:0% 27%;} ' +
6074 '#strength.def .img_pierce { background-position:0% 9%;} ' +
6075 '#strength.off .img_dist { background-position:0% 45%;} ' +
6076 '#strength.def .img_dist { background-position:0% 18%;} ' +
6077
6078 '#strength .strength_font { font-size: 0.8em; } ' +
6079 '#strength.off .strength_font { color:#edb;} ' +
6080 '#strength.def .strength_font { color:#fc6;} ' +
6081
6082 '#strength .ico { height:20px; width:20px; } ' +
6083 '#strength .units_info_sprite { background:url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png); background-size:100%; } ' +
6084
6085 '#strength .img_pierce { background-position:0px -20px; } ' +
6086 '#strength .img_dist { background-position:0px -40px; } ' +
6087 '#strength hr { margin:0px; background-color:#5F5242; height:2px; border:0px solid; } ' +
6088 '#strength .cont_left { width:65%; display:table-cell; } ' +
6089
6090 '#strength.cont { background:url(https://gpall.innogamescdn.com/images/game/layout/layout_units_nav_border.png); } ' +
6091
6092 '#strength .cont_right { width:30%; display:table-cell; vertical-align:middle; } ' +
6093 '#strength .img { float:right; background:none; margin:2px 8px 2px 0px; } ' +
6094
6095 '</style>').appendTo("head");
6096
6097 // Button events
6098 $('.units_land .units_wrapper, .btn_gods_spells .checked').click(function () {
6099 setTimeout(function () {
6100 UnitStrength.Menu.update();
6101 }, 100);
6102 });
6103
6104 $('#off_button').click(function () {
6105 $('#strength').addClass('off').removeClass('def');
6106
6107 def = false;
6108 UnitStrength.Menu.update();
6109 });
6110 $('#def_button').click(function () {
6111 $('#strength').addClass('def').removeClass('off');
6112
6113 def = true;
6114 UnitStrength.Menu.update();
6115 });
6116 $('#def_button, #off_button').hover(function () {
6117 $(this).css('cursor', 'pointer');
6118 });
6119
6120 UnitStrength.Menu.update();
6121 },
6122 deactivate: function () {
6123 $('#strength').remove();
6124 $('#dio_strength_style').remove();
6125 },
6126 update: function () {
6127 var unitsIn = uw.ITowns.getTown(uw.Game.townId).units(), units = UnitStrength.Menu.getSelected();
6128
6129 // Calculation
6130 if (def === true) {
6131 UnitStrength.calcDef(units);
6132 } else {
6133 UnitStrength.calcOff(unitsIn, units);
6134 }
6135 $('#blunt').get(0).innerHTML = blunt;
6136 $('#sharp').get(0).innerHTML = sharp;
6137 $('#dist').get(0).innerHTML = dist;
6138 },
6139 getSelected: function () {
6140 var units = [];
6141 if ($(".units_land .units_wrapper .selected").length > 0) {
6142 $(".units_land .units_wrapper .selected").each(function () {
6143 units[this.className.split(" ")[1]] = this.children[0].innerHTML;
6144 });
6145 } else {
6146 $(".units_land .units_wrapper .unit").each(function () {
6147 units[this.className.split(" ")[1]] = this.children[0].innerHTML;
6148 });
6149 }
6150 return units;
6151 }
6152 },
6153 /*******************************************************************************************************************************
6154 * ● Unit strength: Conquest
6155 *******************************************************************************************************************************/
6156 Conquest: {
6157 add: function () {
6158 var units = [], str;
6159
6160 // units of the siege
6161 $('#conqueror_units_in_town .unit').each(function () {
6162 str = $(this).attr("class").split(" ")[4];
6163 if (!uw.GameData.units[str].is_naval) {
6164 units[str] = parseInt(this.children[0].innerHTML, 10);
6165 //console.log($(this).attr("class").split(" ")[4]);
6166 }
6167 });
6168 // calculation
6169 UnitStrength.calcDef(units);
6170
6171 $('<div id="strength_eo" class="game_border" style="width:90px; margin: 20px; align:center;">' +
6172 '<div class="game_border_top"></div><div class="game_border_bottom"></div>' +
6173 '<div class="game_border_left"></div><div class="game_border_right"></div>' +
6174 '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
6175 '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
6176 '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">' +
6177 '<tr><td width="1%"><div class="ico units_info_sprite img_hack"></div></td><td id="bl" align="center" width="100%">0</td></tr>' +
6178 '<tr><td><div class="ico units_info_sprite img_pierce"></div></td><td id="sh" align="center">0</td></tr>' +
6179 '<tr><td><div class="ico units_info_sprite img_dist"></div></td><td id="di" align="center">0</td></tr>' +
6180 '</table></span>' +
6181 '</div>').appendTo('#conqueror_units_in_town');
6182
6183 $('#strength_eo').tooltip('Gesamteinheitenstärke der Belagerungstruppen');
6184
6185 // Veröffentlichung-Button-Text
6186 $('#conqueror_units_in_town .publish_conquest_public_id_wrap').css({
6187 marginLeft: '130px'
6188 });
6189
6190 $('#strength_eo .ico').css({
6191 height: '20px',
6192 width: '20px'
6193 });
6194 $('#strength_eo .units_info_sprite').css({
6195 background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
6196 backgroundSize: '100%'
6197 });
6198 $('#strength_eo .img_pierce').css({backgroundPosition: '0% 9%'});
6199 $('#strength_eo .img_dist').css({backgroundPosition: '0% 18%'});
6200
6201
6202 $('#bl').get(0).innerHTML = blunt;
6203 $('#sh').get(0).innerHTML = sharp;
6204 $('#di').get(0).innerHTML = dist;
6205 }
6206 },
6207 /*******************************************************************************************************************************
6208 * ● Unit strength: Barracks
6209 *******************************************************************************************************************************/
6210 Barracks: {
6211 add: function () {
6212 if (!$('#strength_baracks').get(0)) {
6213 var units = [], pop = 0;
6214
6215 // whole units of the town
6216 $('#units .unit_order_total').each(function () {
6217 units[$(this).parent().parent().attr("id")] = this.innerHTML;
6218 });
6219 // calculation
6220 UnitStrength.calcDef(units);
6221
6222 // population space of the units
6223 for (var e in units) {
6224 if (units.hasOwnProperty(e)) {
6225 pop += units[e] * uw.GameData.units[e].population;
6226 }
6227 }
6228 $('<div id="strength_baracks" class="game_border" style="float:right; width:70px; align:center;">' +
6229 '<div class="game_border_top"></div><div class="game_border_bottom"></div>' +
6230 '<div class="game_border_left"></div><div class="game_border_right"></div>' +
6231 '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
6232 '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
6233 '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">' +
6234 '<tr><td width="1%"><div class="ico units_info_sprite img_hack"></div></td><td id="b" align="center" width="100%">0</td></tr>' +
6235 '<tr><td><div class="ico units_info_sprite img_pierce"></div></td><td id="s" align="center">0</td></tr>' +
6236 '<tr><td><div class="ico units_info_sprite img_dist"></div></td><td id="d" align="center">0</td></tr>' +
6237 '</table></span>' +
6238 '</div>').appendTo('.ui-dialog #units');
6239
6240 $('<div id="pop_baracks" class="game_border" style="float:right; width:60px; align:center;">' +
6241 '<div class="game_border_top"></div><div class="game_border_bottom"></div>' +
6242 '<div class="game_border_left"></div><div class="game_border_right"></div>' +
6243 '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
6244 '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
6245 '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">' +
6246 '<tr><td width="1%"><img class="ico" src="https://gpall.innogamescdn.com/images/game/res/pop.png"></td><td id="p" align="center" width="100%">0</td></tr>' +
6247 '</table></span>' +
6248 '</div>').appendTo('.ui-dialog #units');
6249
6250 $('.ui-dialog #units .ico').css({
6251 height: '20px',
6252 width: '20px'
6253 });
6254 $('.ui-dialog #units .units_info_sprite').css({
6255 background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
6256 backgroundSize: '100%'
6257 });
6258 $('.ui-dialog #units .img_pierce').css({backgroundPosition: '0% 9%'});
6259 $('.ui-dialog #units .img_dist').css({backgroundPosition: '0% 18%'});
6260
6261 //$('#pop_baracks').tooltip('Bevölkerungszahl aller Landeinheiten der Stadt');
6262 //$('#strength_baracks').tooltip('Gesamteinheitenstärke stadteigener Truppen');
6263
6264 $('#b').get(0).innerHTML = blunt;
6265 $('#s').get(0).innerHTML = sharp;
6266 $('#d').get(0).innerHTML = dist;
6267 $('#p').get(0).innerHTML = pop;
6268 }
6269 }
6270 }
6271 };
6272
6273 /*******************************************************************************************************************************
6274 * ● Transporter capacity
6275 *******************************************************************************************************************************/
6276 var TransportCapacity = {
6277 activate: function () {
6278 // transporter display
6279 $('<div id="transporter" class="cont" style="height:25px;">' +
6280 '<table style=" margin:0px;"><tr align="center" >' +
6281 '<td><img id="ship_img" class="ico" src=""></td>' +
6282 '<td><span id="ship" class="bold text_shadow" style="color:#FFCC66;font-size: 10px;line-height: 2.1;"></span></td>' +
6283 '</tr></table>' +
6284 '</div>').appendTo('.units_naval .content');
6285
6286 $('#transporter.cont').css({
6287 background: 'url(https://gpall.innogamescdn.com/images/game/layout/layout_units_nav_border.png)'
6288 });
6289
6290 $('#transporter').hover(function () {
6291 $(this).css('cursor', 'pointer');
6292 });
6293 $('#transporter').toggleClick(
6294 function () {
6295 $('#ship_img').get(0).src = "";
6296 shipsize = !shipsize;
6297 TransportCapacity.update();
6298 },
6299 function () {
6300 $('#ship_img').get(0).src = "";
6301 shipsize = !shipsize;
6302 TransportCapacity.update();
6303 }
6304 );
6305 TransportCapacity.update();
6306 },
6307 deactivate: function () {
6308 $('#transporter').remove();
6309 },
6310 update: function () {
6311 var bigTransp = 0, smallTransp = 0, pop = 0, ship = 0, unit, berth, units = [];
6312 // Ship space (available)
6313 smallTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().small_transporter, 10);
6314 if (isNaN(smallTransp)) smallTransp = 0;
6315 if (shipsize) {
6316 bigTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().big_transporter, 10);
6317 if (isNaN(bigTransp)) bigTransp = 0;
6318 }
6319
6320 // Checking: Research berth
6321 berth = 0;
6322 if (uw.ITowns.getTown(uw.Game.townId).researches().hasBerth()) {
6323 berth = GameData.research_bonus.berth;
6324 }
6325 ship = bigTransp * (GameData.units.big_transporter.capacity + berth) + smallTransp * (GameData.units.small_transporter.capacity + berth);
6326
6327 units = uw.ITowns.getTown(uw.Game.townId).units();
6328
6329 // Ship space (required)
6330 for (var e in units) {
6331 if (units.hasOwnProperty(e)) {
6332 if (uw.GameData.units[e]) { // without Heroes
6333 if (!(uw.GameData.units[e].is_naval || uw.GameData.units[e].flying)) {
6334 pop += units[e] * uw.GameData.units[e].population;
6335 }
6336 }
6337 }
6338 }
6339 $('#ship').get(0).innerHTML = pop + "/" + ship;
6340 }
6341 };
6342
6343
6344 /*******************************************************************************************************************************
6345 * Simulator
6346 * ----------------------------------------------------------------------------------------------------------------------------
6347 * | ● Layout adjustment
6348 * | ● Permanent display of the extended modifier box
6349 * | ● Unit strength for entered units (without modificator influence yet)
6350 * ----------------------------------------------------------------------------------------------------------------------------
6351 *******************************************************************************************************************************/
6352 var Simulator = {
6353 activate: function () {
6354 $('<style id="dio_simulator_style" type="text/css">' +
6355
6356 '#place_simulator { overflow: hidden !important} ' +
6357 '#place_simulator .game_body { height: 417px !important} ' +
6358
6359 '#place_simulator_form h4 { display:none; } '+
6360
6361 '#place_simulator .place_simulator_table { margin: 0px !important } '+
6362
6363 '#place_simulator_form .place_sim_wrap_mods { margin-bottom: 2px; } '+
6364
6365 // Bonus container
6366 '.place_sim_bonuses_heroes { position:absolute; right:3px; top:27px; width: 272px;} ' +
6367 '.place_sim_bonuses_heroes .place_sim_showhide { display:none; } ' + // Hide modifier box button
6368
6369
6370 //'.place_sim_wrap_mods {position: relative; right: -17px !important} '+
6371 '.place_sim_wrap_mods .place_simulator_table :eq(1) { width: 300px;} ' + ////////////// genauer!
6372 '.place_sim_wrap_mods > .place_simulator_table { width: 272px;} ' + ////////////// genauer!
6373
6374 // Wall losses
6375 '.place_sim_wrap_mods tr:last-child { display:none; } ' +
6376
6377 // Extended modifier box
6378 //'@-webkit-keyframes MODBOX { 0% { opacity: 0; } 100% { opacity: 1; } } '+
6379 //'@keyframes MODBOX { 0% { opacity: 0; } 100% { opacity: 1; } } '+
6380
6381 '.place_sim_wrap_mods_extended { display: table-cell !important; -webkit-animation:MODBOX 1s; animation:MODBOX 1s; position: relative; width:272px; opacity: 1 !important; left: 0px; top: 0px} ' +
6382 '.place_sim_wrap_mods_extended table tr td:eq(0) { width: 18px !important } ' +
6383 '.place_sim_wrap_mods_extended td { border:0px; } ' +
6384 '.place_sim_wrap_mods_extended tr td:first-child { border-left:0px; width:19px; padding-left:0px; } ' +
6385 '.place_sim_wrap_mods_extended .place_simulator_table { margin:0px; border-collapse:separate; border:1px solid #724B08; table-layout:fixed; width:100% } ' +
6386
6387 '.place_simulator_table .place_image { display:block; width: 20px; height:20px; background-size:100%; margin:auto; } ' +
6388
6389 '.place_simulator_table .place_image.pa_commander { background: url(https://diotools.de/images/game/advisors/advisors_22.png); background-position: 0px 44px; } ' +
6390 '.place_simulator_table .place_image.pa_captain { background: url(https://diotools.de/images/game/advisors/advisors_22.png); background-position: 0px 88px; } ' +
6391 '.place_simulator_table .place_image.pa_priest { background: url(https://diotools.de/images/game/advisors/advisors_22.png); background-position: 0px 66px; } ' +
6392
6393 '.place_simulator_table .place_image.is_night { background-position: 0px -40px; } ' +
6394 '.place_simulator_table .place_image.research_ram { background-position: 0px -300px; } ' +
6395 '.place_simulator_table .place_image.research_phalanx { background-position: 0px -280px; }' +
6396 '.place_simulator_table .place_image.research_divine_selection { background-position: 0 -600px; }' +
6397
6398 '.place_sim_wrap_mods_extended .place_cross { height:16px; background:none; } ' +
6399 '.place_sim_wrap_mods_extended .place_checkbox_field { display:table-cell; width:13px; height:13px; } ' +
6400
6401 '.place_sim_wrap_mods_extended tr:last-child { display:none;} ' +
6402
6403 '.place_sim_wrap_mods_extended tr:nth-of-type(3) td, .place_sim_wrap_mods_extended tr:nth-of-type(5) td { border-top: 2px solid #BFA978 !important; padding-top: 3px !important} ' +
6404
6405 '.place_sim_wrap_mods_extended .game_border>div { display:none; } ' +
6406 '.place_sim_wrap_mods_extended .game_border { margin:0px; } ' +
6407
6408 '.place_sim_wrap_mods_extended .game_border { height: 139px; overflow-y: auto; overflow-x: hidden; }' + // Größe der Modfikatorbox begrenzen
6409
6410 '#place_simulator .window_inner_curtain { display: none !important } ' + // Hintergrund entfernen bei offener Modifikatorbox
6411
6412 // Unit container
6413 '#simulator_body .unit_container { height: 50px !important; width: 50px !important; margin: 0px 3px 0px 1px !important} ' +
6414 '.place_simulator_odd, .place_simulator_even { text-align: center !important} ' +
6415 '.place_insert_field { margin: 0px !important} ' +
6416
6417 '#place_sim_ground_units { position:absolute; bottom: 35px;} ' +
6418
6419 // Sea unit box
6420 '#place_sim_naval_units { position: absolute; } ' +
6421 '#place_sim_naval_units tbody tr:last-child { height:auto !important; }' +
6422
6423 // Land unit box
6424 '#place_sim_wrap_units { position: absolute !important; bottom: 35px !important} ' +
6425
6426 '#simulator_body>h4 { position:absolute;bottom:188px;} ' +
6427
6428 // Select boxes
6429 '.place_sim_select_gods_wrap { position:absolute; bottom:182px; } ' +
6430
6431 '.place_sim_select_gods_wrap .place_sim_select_gods { width: 150px; } ' +
6432 '.place_sim_select_gods_wrap select { max-width: 120px; } ' +
6433
6434 '.place_sim_select_gods_wrap .place_symbol, .place_sim_select_strategies .place_symbol { margin: 1px 2px 0px 5px !important} ' +
6435 '.place_sim_insert_units .place_symbol { filter: hue-rotate(330deg); -webkit-filter: hue-rotate(330deg);} ' +
6436 '.place_attack { float: left !important} ' +
6437
6438 // Hero box
6439 '.place_sim_heroes_container { position: absolute; right: 0px; z-index: 1; } ' +
6440 '.place_sim_hero_container { width: 45px !important; height: 25px !important} ' +
6441
6442 '#place_simulator .place_sim_bonuses_heroes h4:nth-of-type(2) { display:none; }' + // Heroes title
6443
6444 // - Hero container
6445 '.place_sim_hero_choose, .place_sim_hero_unit_container { height: 26px !important; width: 30px !important} ' +
6446 '#hero_defense_icon, #hero_attack_icon { height: 25px !important; width: 25px !important; margin: 0px !important} ' +
6447 '#hero_defense_dd, #hero_attack_dd { height: 25px !important; width: 25px !important; margin: 1px !important} ' +
6448 '.place_sim_hero_attack, .place_sim_hero_defense { margin-left: 3px !important} ' +
6449 '#hero_attack_text, #hero_defense_text { font-size: 11px !important; bottom: 0px !important} ' +
6450 '.place_sim_heroes_container .plus { left: 2px; top: 2px !important} ' +
6451
6452 '.place_sim_heroes_container .button_new.square { left: 2px !important; } ' +
6453
6454
6455 // - Hero spinner
6456 '.place_sim_heroes_container .spinner { height: 25px !important; width: 40px !important } ' +
6457 '.place_sim_heroes_container td:nth-child(0) { height: 30px !important} ' +
6458 '.place_sim_heroes_container .spinner { height: 24px !important; position:absolute !important; width:12px !important; left:29px !important; '+
6459 'background:url(https://gpall.innogamescdn.com/images/game/border/odd.png) repeat !important; border: 1px solid rgb(107, 107, 107) !important; } ' +
6460 '.place_sim_heroes_container .spinner .button_down, .place_sim_heroes_container .spinner .button_up { bottom: 2px !important; cursor: pointer !important} ' +
6461 '.place_sim_heroes_container .spinner .border_l, .place_sim_heroes_container .spinner .border_r, .place_sim_heroes_container .spinner .body { display:none; } '+
6462
6463 // Quack
6464 '#q_place_sim_lost_res { display: none; } ' +
6465 '</style>').appendTo('head');
6466
6467 if($('#place_simulator').get(0)) {
6468 Simulator.change();
6469 }
6470
6471 SimulatorStrength.activate();
6472
6473 },
6474 deactivate: function () {
6475 $('#dio_simulator_style').remove();
6476 if($('#simu_table').get(0)) {
6477 $('#simu_table').remove();
6478
6479 // Hero box
6480 if ($('.place_sim_heroes_container').get(0)) {
6481 $('.hero_unit').each(function () {
6482 $(this).addClass('unit_icon40x40').removeClass('unit_icon25x25');
6483 });
6484
6485 // Hero spinner
6486 $('.place_sim_heroes_container .spinner').each(function () {
6487 $(this).addClass('place_sim_hero_spinner');
6488 });
6489 }
6490 }
6491
6492 SimulatorStrength.deactivate();
6493 },
6494 change: function () {
6495 // TODO: Durch CSS ersetzen...
6496
6497 // Wall loss
6498 $('.place_sim_wrap_mods tr:eq(1) td:eq(5)').html('<span id="building_place_def_losses_wall_level" class="place_losses bold"></span>');
6499
6500 // Extended modificator box
6501 $('.place_sim_wrap_mods_extended .power').each(function () {
6502 $(this).removeClass("power_icon45x45").addClass("power_icon16x16");
6503 });
6504 $('.place_sim_wrap_mods_extended td:nth-child(even)').each(function () {
6505 $(this).addClass("left_border place_simulator_odd");
6506 });
6507 $('.place_sim_wrap_mods_extended td:nth-child(odd)').each(function () {
6508 $(this).addClass("left_border place_simulator_even");
6509 });
6510
6511 // Border entfernen
6512 $('.place_sim_wrap_mods_extend td:first-child').each(function () {
6513 $(this).removeClass("left_border");
6514 });
6515
6516 // -> Update percentage each time
6517 $('.place_checkbox_field').click(function () {
6518 FightSimulator.closeModsExtended(); //$('.place_sim_bonuses_more_confirm').get(0).click();
6519 });
6520
6521 // Hero world ?
6522 if (uw.Game.hasArtemis) {
6523 $('.place_sim_wrap_mods_extend tr').each(function () {
6524 this.children[1].style.borderLeft = "none";
6525 this.children[0].remove();
6526 });
6527 }
6528
6529 // Hero box
6530 if ($('.place_sim_heroes_container').get(0)) {
6531 $('.hero_unit').each(function () {
6532 $(this).removeClass('unit_icon40x40').addClass('unit_icon25x25');
6533 });
6534
6535 // Hero spinner
6536 $('.place_sim_heroes_container .spinner').each(function () {
6537 $(this).removeClass('place_sim_hero_spinner');
6538 });
6539 }
6540
6541 setStrengthSimulator();
6542 }
6543 };
6544
6545 function afterSimulation() {
6546 var lossArray = {att: {res: 0, fav: 0, pop: 0}, def: {res: 0, fav: 0, pop: 0}},
6547 wall_level = parseInt($('.place_sim_wrap_mods .place_insert_field[name="sim[mods][def][wall_level]"]').val(), 10),
6548 wall_damage = parseInt($('#building_place_def_losses_wall_level').get(0).innerHTML, 10),
6549 wall_iron = [0, 200, 429, 670, 919, 1175, 1435, 1701, 1970, 2242, 2518, 2796, 3077, 3360, 3646, 3933, 4222, 4514, 4807, 5101, 5397, 5695, 5994, 6294, 6596, 6899];
6550
6551 // Calculate unit losses
6552 $('#place_sim_ground_units .place_losses, #place_sim_naval_units .place_losses').each(function () {
6553 var loss = parseInt(this.innerHTML, 10) || 0;
6554 //console.log(this.innerHTML);
6555 if (loss > 0) {
6556 var unit = this.id.substring(26);
6557 var side = this.id.split("_")[2]; // att / def
6558 lossArray[side].res += loss * (uw.GameData.units[unit].resources.wood + uw.GameData.units[unit].resources.stone + uw.GameData.units[unit].resources.iron);
6559 lossArray[side].fav += loss * uw.GameData.units[unit].favor;
6560 lossArray[side].pop += loss * uw.GameData.units[unit].population;
6561 }
6562 });
6563 // Calculate wall resource losses
6564 for (var w = wall_level; w > wall_level - wall_damage; w--) {
6565 lossArray.def.res += 400 + w * 350 + wall_iron[w]; // wood amount is constant, stone amount is multiplicative and iron amount is irregular for wall levels
6566 }
6567
6568 // Insert losses into table
6569 for (var x in lossArray) {
6570 if (lossArray.hasOwnProperty(x)) {
6571 for (var z in lossArray[x]) {
6572 if (lossArray[x].hasOwnProperty(z)) {
6573 //console.log(((z === "res") && (lossArray[x][z] > 10000)) ? (Math.round(lossArray[x][z] / 1000) + "k") : lossArray[x][z]);
6574 $("#" + x + "_" + z).get(0).innerHTML = ((z === "res") && (lossArray[x][z] > 10000)) ? (Math.round(lossArray[x][z] / 1000) + "k") : lossArray[x][z];
6575
6576 }
6577 }
6578 }
6579 }
6580 }
6581
6582 // Stärkeanzeige: Simulator
6583 var unitsGround = {att: {}, def: {}}, unitsNaval = {att: {}, def: {}}, name = "";
6584
6585 var SimulatorStrength = {
6586 unitsGround : {att: {}, def: {}},
6587 unitsNaval : {att: {}, def: {}},
6588
6589 activate : function(){
6590 $('<style id="dio_simulator_strength_style">'+
6591 '#dio_simulator_strength { position:absolute; top:192px; font-size:0.8em; width:63%; } '+
6592 '#dio_simulator_strength .ico { height:20px; width:20px; margin:auto; } '+
6593 '#dio_simulator_strength .units_info_sprite { background:url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png); background-size:100%; } ' +
6594
6595 '#dio_simulator_strength .img_hack { background-position:0% 36%; } '+
6596 '#dio_simulator_strength .img_pierce { background-position:0% 27%; } '+
6597 '#dio_simulator_strength .img_dist { background-position:0% 45% !important; } '+
6598 '#dio_simulator_strength .img_ship { background-position:0% 72%; } '+
6599
6600 '#dio_simulator_strength .img_fav { background: url(https://gpall.innogamescdn.com/images/game/res/favor.png) !important; background-size: 100%; } '+
6601 '#dio_simulator_strength .img_res { background: url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png) 0% 54%; background-size: 100%; } '+
6602 '#dio_simulator_strength .img_pop { background: url(https://gpall.innogamescdn.com/images/game/res/pop.png); background-size:100%; } '+
6603
6604 '#dio_simulator_strength .left_border { width: 54px; } '+
6605 '</style>'
6606 ).appendTo('head');
6607
6608 },
6609 deactivate : function(){
6610 $('#dio_simulator_strength_style').remove();
6611 },
6612 add : function(){
6613 $('<div id="dio_simulator_strength">' +
6614 '<div style="float:left; margin-right:12px;"><h4>' + getText("labels", "str") + '</h4>' +
6615 '<table class="place_simulator_table strength" cellpadding="0px" cellspacing="0px" style="align:center;">' +
6616 '<tr>' +
6617 '<td class="place_simulator_even"></td>' +
6618 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_hack"></div></td>' +
6619 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_pierce"></div></td>' +
6620 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_dist"></div></td>' +
6621 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_ship"></div></td>' +
6622 '</tr><tr>' +
6623 '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>' +
6624 '<td class="left_border place_simulator_odd" id="att_b">0</td>' +
6625 '<td class="left_border place_simulator_even" id="att_s">0</td>' +
6626 '<td class="left_border place_simulator_odd" id="att_d">0</td>' +
6627 '<td class="left_border place_simulator_even" id="att_ship">0</td>' +
6628 '</tr><tr>' +
6629 '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
6630 '<td class="left_border place_simulator_odd" id="def_b">0</td>' +
6631 '<td class="left_border place_simulator_even" id="def_s">0</td>' +
6632 '<td class="left_border place_simulator_odd" id="def_d">0</td>' +
6633 '<td class="left_border place_simulator_even" id="def_ship">0</td>' +
6634 '</tr>' +
6635 '</table>' +
6636 '</div><div><h4>' + getText("labels", "los") + '</h4>' +
6637 '<table class="place_simulator_table loss" cellpadding="0px" cellspacing="0px" style="align:center;">' +
6638 '<tr>' +
6639 '<td class="place_simulator_even"></td>' +
6640 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_res"></div></td>' +
6641 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_fav"></div></td>' +
6642 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_pop"></div></td>' +
6643 '</tr><tr>' +
6644 '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>' +
6645 '<td class="left_border place_simulator_odd" id="att_res">0</td>' +
6646 '<td class="left_border place_simulator_even" id="att_fav">0</td>' +
6647 '<td class="left_border place_simulator_odd" id="att_pop">0</td>' +
6648 '</tr><tr>' +
6649 '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
6650 '<td class="left_border place_simulator_odd" id="def_res">0</td>' +
6651 '<td class="left_border place_simulator_even" id="def_fav">0</td>' +
6652 '<td class="left_border place_simulator_odd" id="def_pop">0</td>' +
6653 '</tr>' +
6654 '</table>' +
6655 '</div></div>').appendTo('#simulator_body');
6656
6657
6658 $('#dio_simulator_strength .left_border').each(function () {
6659 $(this)[0].align = 'center';
6660 });
6661
6662 // Tooltips setzen
6663 $('#dio_simulator_strength .strength').tooltip(getText("labels", "str") + " (" + getText("labels", "mod") + ")");
6664 $('#dio_simulator_strength .loss').tooltip(getText("labels", "los"));
6665
6666 // Klick auf Einheitenbild
6667 $('.index_unit').click(function () {
6668 var type = $(this).attr('class').split(" ")[4];
6669 $('.place_insert_field[name="sim[units][att][' + type + ']"]').change();
6670 });
6671
6672 $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').on('input change', function () {
6673 name = $(this).attr("name").replace(/\]/g, "").split("[");
6674 var str = this;
6675
6676
6677 setTimeout(function () {
6678 var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2],
6679 val, e;
6680
6681 val = parseInt($(str).val(), 10);
6682 val = val || 0;
6683
6684 if (unit_type == "ground") {
6685 unitsGround[name[2]][name[3]] = val;
6686
6687 if (name[2] == "def") {
6688 UnitStrength.calcDef(unitsGround.def);
6689 } else {
6690 UnitStrength.calcOff(unitsGround.att, unitsGround.att);
6691 }
6692 $('#' + name[2] + '_b').get(0).innerHTML = blunt;
6693 $('#' + name[2] + '_s').get(0).innerHTML = sharp;
6694 $('#' + name[2] + '_d').get(0).innerHTML = dist;
6695
6696 } else {
6697 var att = 0, def = 0;
6698 unitsNaval[name[2]][name[3]] = val;
6699
6700 if (name[2] == "def") {
6701 for (e in unitsNaval.def) {
6702 if (unitsNaval.def.hasOwnProperty(e)) {
6703 def += unitsNaval.def[e] * uw.GameData.units[e].defense;
6704 }
6705 }
6706 $('#def_ship').get(0).innerHTML = def;
6707
6708 } else {
6709 for (e in unitsNaval.att) {
6710 if (unitsNaval.att.hasOwnProperty(e)) {
6711 att += unitsNaval.att[e] * uw.GameData.units[e].attack;
6712 }
6713 }
6714 $('#att_ship').get(0).innerHTML = att;
6715 }
6716 }
6717 }, 100);
6718 });
6719
6720 // Abfrage wegen eventueller Spionageweiterleitung
6721 getUnitInputs();
6722 setTimeout(function () {
6723 setChangeUnitInputs("def");
6724 }, 100);
6725
6726 $('#select_insert_units').change(function () {
6727 var side = $(this).find('option:selected').val();
6728
6729 setTimeout(function () {
6730 getUnitInputs();
6731 if (side === "att" || side === "def") {
6732 setChangeUnitInputs(side);
6733 }
6734 }, 200);
6735 });
6736 },
6737
6738 getUnitInputs : function(){
6739 $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').each(function () {
6740 var name = $(this).attr("name").replace(/\]/g, "").split("[");
6741
6742 var str = this;
6743
6744 var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2];
6745
6746 var val = parseInt($(str).val(), 10);
6747
6748 val = val || 0;
6749
6750 if (unit_type === "ground") {
6751 SimulatorStrength.unitsGround[name[2]][name[3]] = val;
6752 } else {
6753 SimulatorStrength.unitsNaval[name[2]][name[3]] = val;
6754 }
6755 });
6756 },
6757
6758 updateStrength : function(){
6759
6760 }
6761 }
6762 function setStrengthSimulator() {
6763 $('<div id="dio_simulator_strength">' +
6764 '<div style="float:left; margin-right:12px;"><h4>' + getText("labels", "str") + '</h4>' +
6765 '<table class="place_simulator_table strength" cellpadding="0px" cellspacing="0px" style="align:center;">' +
6766 '<tr>' +
6767 '<td class="place_simulator_even"></td>' +
6768 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_hack"></div></td>' +
6769 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_pierce"></div></td>' +
6770 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_dist"></div></td>' +
6771 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_ship"></div></td>' +
6772 '</tr><tr>' +
6773 '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>' +
6774 '<td class="left_border place_simulator_odd" id="att_b">0</td>' +
6775 '<td class="left_border place_simulator_even" id="att_s">0</td>' +
6776 '<td class="left_border place_simulator_odd" id="att_d">0</td>' +
6777 '<td class="left_border place_simulator_even" id="att_ship">0</td>' +
6778 '</tr><tr>' +
6779 '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
6780 '<td class="left_border place_simulator_odd" id="def_b">0</td>' +
6781 '<td class="left_border place_simulator_even" id="def_s">0</td>' +
6782 '<td class="left_border place_simulator_odd" id="def_d">0</td>' +
6783 '<td class="left_border place_simulator_even" id="def_ship">0</td>' +
6784 '</tr>' +
6785 '</table>' +
6786 '</div><div><h4>' + getText("labels", "los") + '</h4>' +
6787 '<table class="place_simulator_table loss" cellpadding="0px" cellspacing="0px" style="align:center;">' +
6788 '<tr>' +
6789 '<td class="place_simulator_even"></td>' +
6790 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_res"></div></td>' +
6791 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_fav"></div></td>' +
6792 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_pop"></div></td>' +
6793 '</tr><tr>' +
6794 '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>' +
6795 '<td class="left_border place_simulator_odd" id="att_res">0</td>' +
6796 '<td class="left_border place_simulator_even" id="att_fav">0</td>' +
6797 '<td class="left_border place_simulator_odd" id="att_pop">0</td>' +
6798 '</tr><tr>' +
6799 '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
6800 '<td class="left_border place_simulator_odd" id="def_res">0</td>' +
6801 '<td class="left_border place_simulator_even" id="def_fav">0</td>' +
6802 '<td class="left_border place_simulator_odd" id="def_pop">0</td>' +
6803 '</tr>' +
6804 '</table>' +
6805 '</div></div>').appendTo('#simulator_body');
6806
6807
6808 /*
6809 $('#dio_simulator_strength').css({
6810 position: 'absolute',
6811 top: '192px',
6812 fontSize: '0.8em',
6813 width: '63%'
6814 });
6815 $('#dio_simulator_strength .ico').css({
6816 height: '20px',
6817 width: '20px',
6818 margin: 'auto'
6819 });
6820 $('#dio_simulator_strength .units_info_sprite').css({
6821 background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
6822 backgroundSize: '100%'
6823 });
6824 $('#dio_simulator_strength .img_hack').css({backgroundPosition: '0% 36%'});
6825 $('#dio_simulator_strength .img_pierce').css({backgroundPosition: '0% 27%'});
6826 $('#dio_simulator_strength .img_dist').css({backgroundPosition: '0% 45%'});
6827 $('#dio_simulator_strength .img_ship').css({backgroundPosition: '0% 72%'});
6828
6829 $('#dio_simulator_strength .img_fav').css({
6830 background: 'url(https://gpall.innogamescdn.com/images/game/res/favor.png)',
6831 backgroundSize: '100%'
6832 });
6833 $('#dio_simulator_strength .img_res').css({
6834 background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png) 0% 54%',
6835 backgroundSize: '100%'
6836 });
6837 $('#dio_simulator_strength .img_pop').css({
6838 background: 'url(https://gpall.innogamescdn.com/images/game/res/pop.png)',
6839 backgroundSize: '100%'
6840 });
6841
6842 $('#dio_simulator_strength .left_border').css({
6843 width: '54px'
6844 });
6845 */
6846
6847
6848 $('#dio_simulator_strength .left_border').each(function () {
6849 $(this)[0].align = 'center';
6850 });
6851
6852 $('#dio_simulator_strength .strength').tooltip(getText("labels", "str") + " (" + getText("labels", "mod") + ")");
6853 $('#dio_simulator_strength .loss').tooltip(getText("labels", "los"));
6854
6855 // Klick auf Einheitenbild
6856 $('.index_unit').click(function () {
6857 var type = $(this).attr('class').split(" ")[4];
6858 $('.place_insert_field[name="sim[units][att][' + type + ']"]').change();
6859 });
6860
6861 $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').on('input change', function () {
6862 name = $(this).attr("name").replace(/\]/g, "").split("[");
6863 var str = this;
6864 //console.log(str);
6865 setTimeout(function () {
6866 var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2],
6867 val, e;
6868
6869 val = parseInt($(str).val(), 10);
6870 val = val || 0;
6871
6872 if (unit_type == "ground") {
6873 unitsGround[name[2]][name[3]] = val;
6874
6875 if (name[2] == "def") {
6876 UnitStrength.calcDef(unitsGround.def);
6877 } else {
6878 UnitStrength.calcOff(unitsGround.att, unitsGround.att);
6879 }
6880 $('#' + name[2] + '_b').get(0).innerHTML = blunt;
6881 $('#' + name[2] + '_s').get(0).innerHTML = sharp;
6882 $('#' + name[2] + '_d').get(0).innerHTML = dist;
6883
6884 } else {
6885 var att = 0, def = 0;
6886 unitsNaval[name[2]][name[3]] = val;
6887
6888 if (name[2] == "def") {
6889 for (e in unitsNaval.def) {
6890 if (unitsNaval.def.hasOwnProperty(e)) {
6891 def += unitsNaval.def[e] * uw.GameData.units[e].defense;
6892 }
6893 }
6894 $('#def_ship').get(0).innerHTML = def;
6895
6896 } else {
6897 for (e in unitsNaval.att) {
6898 if (unitsNaval.att.hasOwnProperty(e)) {
6899 att += unitsNaval.att[e] * uw.GameData.units[e].attack;
6900 }
6901 }
6902 $('#att_ship').get(0).innerHTML = att;
6903 }
6904 }
6905 }, 100);
6906 });
6907
6908 // Abfrage wegen eventueller Spionageweiterleitung
6909 getUnitInputs();
6910 setTimeout(function () {
6911 setChangeUnitInputs("def");
6912 }, 100);
6913
6914 $('#select_insert_units').change(function () {
6915 var side = $(this).find('option:selected').val();
6916
6917 setTimeout(function () {
6918 getUnitInputs();
6919 if (side === "att" || side === "def") {
6920 setChangeUnitInputs(side);
6921 }
6922 }, 200);
6923 });
6924 }
6925
6926 function getUnitInputs() {
6927 $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').each(function () {
6928 name = $(this).attr("name").replace(/\]/g, "").split("[");
6929
6930 var str = this;
6931
6932 var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2];
6933
6934 var val = parseInt($(str).val(), 10);
6935
6936 val = val || 0;
6937
6938 if (unit_type === "ground") {
6939 unitsGround[name[2]][name[3]] = val;
6940 } else {
6941 unitsNaval[name[2]][name[3]] = val;
6942 }
6943 });
6944 }
6945
6946 function setChangeUnitInputs(side) {
6947 $('.place_insert_field[name="sim[units][' + side + '][godsent]"]').change();
6948 setTimeout(function () {
6949 $('.place_insert_field[name="sim[units][' + side + '][colonize_ship]"]').change();
6950 }, 100);
6951 }
6952
6953 /*******************************************************************************************************************************
6954 * Defense form
6955 * ----------------------------------------------------------------------------------------------------------------------------
6956 * | ● Adds a defense form to the bbcode bar
6957 * ----------------------------------------------------------------------------------------------------------------------------
6958 *******************************************************************************************************************************/
6959
6960 // Funktion aufteilen...
6961 function addForm(e) {
6962 var textareaId = "", bbcodeBarId = "";
6963
6964 switch (e) {
6965 case "/alliance_forum/forum":
6966 textareaId = "#forum_post_textarea";
6967 bbcodeBarId = "#forum";
6968 break;
6969 case "/message/forward":
6970 textareaId = "#message_message";
6971 bbcodeBarId = "#message_bbcodes";
6972 break;
6973 case "/message/new":
6974 textareaId = "#message_new_message";
6975 bbcodeBarId = "#message_bbcodes";
6976 break;
6977 case "/message/view":
6978 textareaId = "#message_reply_message";
6979 bbcodeBarId = "#message_bbcodes";
6980 break;
6981 case "/player_memo/load_memo_content":
6982 textareaId = "#memo_text_area";
6983 bbcodeBarId = "#memo_edit";
6984 break;
6985 }
6986
6987 $('<a title="Verteidigungsformular" href="#" class="dio_bbcode_option def_form" name="def_form"></a>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
6988
6989 $('.def_form_button').css({
6990 cursor: 'pointer',
6991 marginTop: '3px'
6992 });
6993
6994 $(bbcodeBarId + ' .dio_bbcode_option').css({
6995 background: 'url("http://s14.directupload.net/images/140126/lt3hyb8j.png")',
6996 display: 'block',
6997 float: 'left',
6998 width: '22px',
6999 height: '23px',
7000 margin: '0 3px 0 0',
7001 position: 'relative'
7002 });
7003 $(bbcodeBarId + ' .def_form').css({
7004 backgroundPosition: '-89px 0px'
7005 });
7006 var imgArray = {
7007 wall: 'https://gpall.innogamescdn.com/images/game/main/wall.png',
7008 tower: 'https://gpall.innogamescdn.com/images/game/main/tower.png',
7009 hide: 'https://gpall.innogamescdn.com/images/game/main/hide.png',
7010
7011
7012 militia: 'http://wiki.en.grepolis.com/images/9/9b/Militia_40x40.png',
7013 sword: 'http://wiki.en.grepolis.com/images/9/9c/Sword_40x40.png',
7014 slinger: 'http://wiki.en.grepolis.com/images/d/dc/Slinger_40x40.png',
7015 archer: 'http://wiki.en.grepolis.com/images/1/1a/Archer_40x40.png',
7016 hoplite: 'http://wiki.en.grepolis.com/images/b/bd/Hoplite_40x40.png',
7017 rider: 'http://wiki.en.grepolis.com/images/e/e9/Rider_40x40.png',
7018 chariot: 'http://wiki.en.grepolis.com/images/b/b8/Chariot_40x40.png',
7019 catapult: 'http://wiki.en.grepolis.com/images/f/f0/Catapult_40x40.png',
7020 godsent: 'http://wiki.de.grepolis.com/images/6/6e/Grepolis_Wiki_225.png',
7021
7022 def_sum: '',
7023
7024 minotaur: 'http://wiki.de.grepolis.com/images/7/70/Minotaur_40x40.png',
7025 manticore: 'http://wiki.de.grepolis.com/images/5/5e/Manticore_40x40.png',
7026 zyclop: 'http://wiki.de.grepolis.com/images/6/66/Zyklop_40x40.png',
7027 sea_monster: 'http://wiki.de.grepolis.com/images/7/70/Sea_monster_40x40.png',
7028 harpy: 'http://wiki.de.grepolis.com/images/8/80/Harpy_40x40.png',
7029 medusa: 'http://wiki.de.grepolis.com/images/d/db/Medusa_40x40.png',
7030 centaur: 'http://wiki.de.grepolis.com/images/5/53/Centaur_40x40.png',
7031 pegasus: 'http://wiki.de.grepolis.com/images/5/54/Pegasus_40x40.png',
7032 cerberus: 'http://wiki.de.grepolis.com/images/6/67/Zerberus_40x40.png',
7033 fury: 'http://wiki.de.grepolis.com/images/6/67/Erinys_40x40.png',
7034 griffin: 'http://wiki.de.grepolis.com/images/d/d1/Unit_greif.png',
7035 calydonian_boar: 'http://wiki.de.grepolis.com/images/9/93/Unit_eber.png',
7036
7037 big_transporter: 'http://wiki.en.grepolis.com/images/0/04/Big_transporter_40x40.png',
7038 bireme: 'http://wiki.en.grepolis.com/images/4/44/Bireme_40x40.png',
7039 attack_ship: 'http://wiki.en.grepolis.com/images/e/e6/Attack_ship_40x40.png',
7040 demolition_ship: 'http://wiki.en.grepolis.com/images/e/ec/Demolition_ship_40x40.png',
7041 small_transporter: 'http://wiki.en.grepolis.com/images/8/85/Small_transporter_40x40.png',
7042 trireme: 'http://wiki.en.grepolis.com/images/a/ad/Trireme_40x40.png',
7043 colonize_ship: 'http://wiki.en.grepolis.com/images/d/d1/Colonize_ship_40x40.png',
7044
7045 move_icon: 'https://gpall.innogamescdn.com/images/game/unit_overview/',
7046
7047
7048 };
7049
7050 $('<div class="bb_def_chooser">' +
7051 '<div class="bbcode_box middle_center">' +
7052 '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div>' +
7053 '<div class="bbcode_box top_center"></div><div class="bbcode_box bottom_center"></div>' +
7054 '<div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>' +
7055 '<div class="bbcode_box middle_left"></div><div class="bbcode_box middle_right"></div>' +
7056 '<div class="bbcode_box content clearfix" style="padding:5px">' +
7057 '<div id="f_uni" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "det") + '</div></div><br><br>' +
7058 '<div id="f_prm" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "prm") + '</div></div><br><br>' +
7059 '<div id="f_sil" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "sil") + '</div></div><br><br>' +
7060 '<div id="f_mov" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "mov") + '</div></div><br><br>' +
7061 '<div><a class="button" id="dio_insert" href="#"><span class="left"><span class="right"><span class="middle"><small>' + getText("buttons", "ins") + '</small></span></span></span><span></span></a></div>' +
7062 '</div></div></div>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
7063
7064 $('.bb_def_chooser').css({
7065 display: 'none',
7066 top: '38px',
7067 left: '510px',
7068 position: 'absolute',
7069 width: '190px',
7070 zIndex: 10000
7071 });
7072
7073 $(bbcodeBarId + " .bb_def_chooser .checkbox_new").click(function () {
7074 $(this).toggleClass("checked");
7075 });
7076
7077 $(bbcodeBarId + ' .def_form').toggleClick(function () {
7078 $(this).parent().find(".bb_def_chooser").get(0).style.display = "block";
7079 }, function () {
7080 $(this).parent().find(".bb_def_chooser").get(0).style.display = "none";
7081 });
7082
7083 $(bbcodeBarId + ' #dio_insert').click(function () {
7084 var textarea = $(textareaId).get(0), text = $(textarea).val(), troop_table = "", troop_img = "", troop_count = "", separator = "", move_table = "", landunit_sum = 0;
7085
7086 $('.def_form').click();
7087
7088 if ($('#f_uni').hasClass("checked")) {
7089 $('.units_land .unit, .units_naval .unit').each(function () {
7090 troop_img += separator + '[img]' + imgArray[this.className.split(" ")[1]] + '[/img]';
7091 troop_count += separator + '[center]' + $(this).find(".value").get(0).innerHTML + '[/center]';
7092 separator = "[||]";
7093 });
7094 } else {
7095 $('.units_land .unit').each(function () {
7096 var a = this.className.split(" ")[1], def = (uw.GameData.units[a].def_hack + uw.GameData.units[a].def_pierce + uw.GameData.units[a].def_distance) / (3 * uw.GameData.units[a].population);
7097 if (def > 10) {
7098 landunit_sum += parseInt($(this).find(".value").get(0).innerHTML, 10) * uw.GameData.units[a].population * ((def > 20) ? 2 : 1);
7099 }
7100 });
7101 landunit_sum = (landunit_sum > 10000) ? ((Math.round(landunit_sum / 100)) / 10) + "k" : landunit_sum;
7102
7103 troop_img += '[img]' + imgArray.def_sum + '[/img]';
7104 troop_count += '[center]' + landunit_sum + '[/center]';
7105 separator = "[||]";
7106 $('.units_naval .unit').each(function () {
7107 troop_img += separator + '[img]' + imgArray[this.className.split(" ")[1]] + '[/img]';
7108 troop_count += separator + '[center]' + $(this).find(".value").get(0).innerHTML + '[/center]';
7109 });
7110 }
7111 if (troop_img !== "") {
7112 troop_table = "\n[table][**]" + troop_img + "[/**][**]" + troop_count + "[/**][/table]\n";
7113 }
7114
7115 var str = '[img]' + imgArray.bordure + '[/img]' +
7116 '\n\n[color=#006B00][size=12][u][b]' + getText("labels", "ttl") + ' ([url="http://adf.ly/eDM1y"]©DIO-Tools[/url])[/b][/u][/size][/color]\n\n' +
7117 //'[table][**][img]'+ imgArray.sup +'[/img][||]'+
7118 '[size=12][town]' + uw.ITowns.getTown(uw.Game.townId).getId() + '[/town] ([player]' + uw.Game.player_name + '[/player])[/size]' +
7119 //'[||][img]'+ imgArray['rev' + (uw.ITowns.getTown(uw.Game.townId).hasConqueror()?1:0)] +'[/img][/**][/table]'+
7120 '\n\n[i][b]' + getText("labels", "inf") + '[/b][/i]' + troop_table +
7121 '[table][*]' +
7122 '[img]' + imgArray.wall + '[/img][|]\n' +
7123 '[img]' + imgArray.tower + '[/img][|]\n' +
7124 '[img]' + imgArray.phalanx + '[/img][|]\n' +
7125 '[img]' + imgArray.ram + '[/img][|]\n' +
7126 ($('#f_prm').hasClass("checked") ? '[img]' + imgArray.commander + '[/img][|]\n' : ' ') +
7127 ($('#f_prm').hasClass("checked") ? '[img]' + imgArray.captain + '[/img][|]\n' : ' ') +
7128 ($('#f_prm').hasClass("checked") ? '[img]' + imgArray.priest + '[/img][|]\n' : ' ') +
7129 ($('#f_sil').hasClass("checked") ? '[center][img]' + imgArray.spy + '[/img][/center][|]\n' : ' ') +
7130 '[img]' + imgArray.pop + '[/img][|]\n' +
7131 '[img]' + imgArray[(uw.ITowns.getTown(uw.Game.townId).god() || "nogod")] + '[/img][/*]\n' +
7132 '[**][center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("wall") + '[/center][||]' +
7133 '[center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("tower") + '[/center][||]' +
7134 '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.phalanx ? '+' : '-') + '[/center][||]' +
7135 '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.ram ? '+' : '-') + '[/center][||]' +
7136 ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.commander >= uw.Timestamp.now()) ? '+' : '-') + '[/center][||]' : ' ') +
7137 ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.captain >= uw.Timestamp.now()) ? '+' : '-') + '[/center][||]' : ' ') +
7138 ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.priest >= uw.Timestamp.now()) ? '+' : '-') + '[/center][||]' : ' ') +
7139 ($('#f_sil').hasClass("checked") ? '[center]' + Math.round(uw.ITowns.getTown(uw.Game.townId).getEspionageStorage() / 1000) + 'k[/center][||]' : ' ') +
7140 '[center]' + uw.ITowns.getTown(uw.Game.townId).getAvailablePopulation() + '[/center][||]' +
7141 '[center]' + $('.gods_favor_amount').get(0).innerHTML + '[/center]' +
7142 '[/**][/table]';
7143
7144 var bb_count_str = parseInt(str.match(/\[/g).length, 10), bb_count_move = 0;
7145
7146 var i = 0;
7147 if ($('#f_mov').hasClass("checked")) {
7148 move_table += '\n[i][b]' + getText("labels", "mov") + '[/b][/i]\n[table]';
7149
7150 $('#toolbar_activity_commands').mouseover();
7151
7152 $('#toolbar_activity_commands_list .content .command').each(function () {
7153 var cl = $(this).children()[0].className.split(" ");
7154 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)) {
7155 move_table += (i % 1) ? "" : "[**]";
7156 i++;
7157 move_table += "[img]" + imgArray.move_icon + cl[2] + ".png[/img][||]";
7158 move_table += getArrivalTime($(this).children()[1].innerHTML) + (uw.Game.market_id === "de" ? " Uhr[||]" : " [||]");
7159 move_table += "[town]" + JSON.parse(atob($(this).children()[2].firstChild.href.split("#")[1])).id + "[/town]";
7160 move_table += (i % 1) ? "[||]" : "[/**]";
7161 }
7162 bb_count_move = parseInt(move_table.match(/\[/g).length, 10);
7163 });
7164 if ((bb_count_str + bb_count_move) > 480) {
7165 move_table += '[**]...[/**]';
7166 }
7167
7168 $('#toolbar_activity_commands').mouseout();
7169
7170 //console.log((bb_count_str + bb_count_move));
7171 move_table += (i % 1) ? "[/**]" : "";
7172 move_table += "[*][|][color=#800000][size=6][i] (" + getText("labels", "dev") + ": ±1s)[/i][/size][/color][/*][/table]\n";
7173 }
7174
7175 str += move_table + '[img]' + imgArray.bordure + '[/img]';
7176
7177
7178 $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + str + text.substring($(textarea).get(0).selectionEnd));
7179 });
7180 }
7181
7182 function getArrivalTime(duration_time) {
7183 /*
7184 var server_time = new Date((uw.Timestamp.server() + 7200) * 1000);
7185
7186 duration_time = duration_time.split(":");
7187
7188 s = server_time.getUTCSeconds() + parseInt(duration_time[2], 10);
7189 m = server_time.getUTCMinutes() + parseInt(duration_time[1], 10) + ((s>=60)? 1 : 0);
7190 h = server_time.getUTCHours() + parseInt(duration_time[0], 10) + ((m>=60)? 1 : 0);
7191 */
7192
7193 var server_time = $('.server_time_area').get(0).innerHTML.split(" ")[0].split(":"), arrival_time, s, m, h;
7194 duration_time = duration_time.split(":");
7195
7196 s = parseInt(server_time[2], 10) + parseInt(duration_time[2], 10);
7197 m = parseInt(server_time[1], 10) + parseInt(duration_time[1], 10) + ((s >= 60) ? 1 : 0);
7198 h = parseInt(server_time[0], 10) + parseInt(duration_time[0], 10) + ((m >= 60) ? 1 : 0);
7199
7200 s = s % 60;
7201 m = m % 60;
7202 h = h % 24;
7203
7204 s = ((s < 10) ? "0" : "") + s;
7205 m = ((m < 10) ? "0" : "") + m;
7206 h = ((h < 10) ? "0" : "") + h;
7207
7208 arrival_time = h + ":" + m + ":" + s;
7209
7210 return arrival_time;
7211 }
7212
7213
7214 /*******************************************************************************************************************************
7215 * Smiley box
7216 * ----------------------------------------------------------------------------------------------------------------------------
7217 * | ● Display of a smiley selection box for text input fields (forum, messages, notes):
7218 * | ● Used smileys: http://www.greensmilies.com/smilie-album/
7219 * | + Own Grepolis smileys
7220 * ----------------------------------------------------------------------------------------------------------------------------
7221 *******************************************************************************************************************************/
7222
7223 var smileyArray = {};
7224
7225 var SmileyBox = {
7226 loading_error: false, isHalloween: false, isXmas: false, isForum: $(".editor_textbox_container").get(0),
7227
7228 activate: function () {
7229 $('<style id="dio_smiley">' +
7230 '.smiley_button { cursor:pointer; margin:3px 2px 2px 2px; } ' +
7231
7232 '.smiley_box.game { z-index:5000; position:absolute; top:27px; left:430px; min-width:300px; display:none; } ' +
7233
7234 // Smiley categories
7235 '.smiley_box .box_header { display: table; width: 100%; text-align:center; } ' +
7236 '.smiley_box .group { display:table-cell; color: #0c450c; cursor: pointer; font-weight:bold; padding: 0px 2px 0px 2px; } ' +
7237 '.smiley_box .group.active { color: #089421; text-decoration:underline;} ' +
7238 '.smiley_box .group:hover { color: #14999E; } ' + // #11AD6C
7239
7240 // Special smiley categories
7241 '.smiley_box .halloween { color: #E25E00; } ' +
7242 '.smiley_box .xmas { color: darkred; } ' +
7243
7244 '.smiley_box hr { margin:3px 0px 0px 0px; color:#086b18; border:1px solid; } ' +
7245
7246 // Smilies
7247 '.smiley_box .box_content { overflow: hidden; } ' +
7248 '.smiley_box .box_content .smiley { border: 1px solid rgba(0,0,0,0); border-radius: 5px;} ' +
7249 '.smiley_box .box_content .smiley:hover { background: rgba(8, 148, 77, 0.2); border: 1px solid rgba(0, 128, 0, 0.5); } ' +
7250
7251 // Smiley page link
7252 '.smiley_box .box_footer { text-align:center; margin-top:4px; } ' +
7253 '.smiley_box a:link, .smiley_box a:visited { color: #086b18; font-size: 0.7em; } ' +
7254 '.smiley_box a:hover { color: #14999E; } ' +
7255
7256 // TODO Forum ...
7257 '.smiley_box.forum .box_header_left { float:left; } ' +
7258 //'.smiley_box.forum .group { padding-right: 10px; } '+
7259 '.smiley_box.forum .box_header_right { text-align:right; margin-top:2px; } ' +
7260
7261 '.smiley_box.forum { max-height:90px; margin-left:5px; width:99%; min-height:10px; } ' +
7262 '.smiley_box.forum .box_content { overflow:overlay; min-height:70px; margin-bottom:10px; } ' +
7263
7264 '.smiley_box.forum a:link, .smiley_box.forum a:visited { font-size: 1em; } ' +
7265
7266 '</style>').appendTo('head');
7267
7268
7269 // Smiley categories
7270 smileyArray.button = ["rollsmiliey", "smile"];
7271
7272 smileyArray.standard = [
7273 "smilenew", "grin", "lol", "neutral_new", "afraid", "freddus_pacman", "auslachen2", "kolobok-sanduhr", "bussi2", "winken4", "flucht2", "panik4", "ins-auge-stechen",
7274 "seb_zunge", "fluch4_GREEN", "baby_junge2", "blush-reloaded6", "frown", "verlegen", "blush-pfeif", "stevieh_rolleyes", "daumendreh2", "baby_taptap",
7275 "sadnew", "hust", "confusednew", "idea2", "irre", "irre4", "sleep", "candle", "nicken", "no_sad",
7276 "thumbs-up_new", "thumbs-down_new", "bravo2", "oh-no2", "kaffee2", "drunk", "saufen", "freu-dance", "hecheln", "headstand", "rollsmiliey", "eazy_cool01", "motz", "cuinlove", "biggrin"
7277 ];
7278 smileyArray.nature = [
7279 "dinosaurier07", "flu-super-gau", "ben_cat", "schwein", "hundeleine01", "blume", "ben_sharky", "ben_cow", "charly_bissig", "gehirnschnecke_confused", "mttao_fische", "mttao_angler",
7280 "insel", "fliegeschnappen", "spider", /* Spinne */ "shipwrecked", /* Schiffbrüchiger */ "plapperhase", "ben_dumbo"
7281 ];
7282 smileyArray.grepolis = [
7283 "mttao_wassermann", "hera", /* Hera */ "medusa", /* Medusa */ "manticore", /* Mantikor */ "cyclops", /* Zyklop */
7284 "minotaur", /* Minotaurus */ "pegasus", /* Pegasus */ "hydra", /* Hydra */
7285 "silvester_cuinlove", "mttao_schuetze", "kleeblatt2", "wallbash", /* "glaskugel4", */ "musketiere_fechtend", /* "krone-hoch",*/ "viking", // Wikinger
7286 "mttao_waage2", "steckenpferd", /* "kinggrin_anbeten2", */ "grepolove", /* Grepo Love */ "skullhaufen", "pferdehaufen" // "i/ckajscggscw4s2u60"
7287 ];
7288 smileyArray.people = [
7289 "seb_hut5", "opa_boese2", "star-wars-yoda1-gruen", "hexefliegend", "snob", "seb_detektiv_ani", "seb_cowboy", "devil", "segen", "pirat5", "borg", "hexe3b",
7290 "pharaoh", "hippie", "eazy_polizei", "stars_elvis", "mttao_chefkoch", "nikolaus", "pirate3_biggrin", "batman_skeptisch", "tubbie1", "tubbie2", "tubbie3", "tubbie4"
7291 ];
7292 smileyArray.other = [
7293 "steinwerfen", "herzen02", "scream-if-you-can", "kolobok", "headbash", "liebeskummer", "bussi", "brautpaar-reis", "grab-schaufler2", "boxen2", "aufsmaul",
7294 "sauf", "mttao_kehren", "sm", "weckruf", "klugscheisser2", "karte2_rot", "dagegen", "party", "dafuer", "outofthebox", "pokal_gold", "koepfler", "transformer"
7295 ];
7296
7297 // TODO: HolidayChecker benutzen!
7298 SmileyBox.checkHolidaySeason();
7299
7300 if (SmileyBox.isHalloween) {
7301 smileyArray.halloween = [
7302 "zombies_alien", "zombies_lol", "zombies_rolleyes", "zombie01", "zombies_smile", "zombie02", "zombies_skeptisch", "zombies_eek", "zombies_frown",
7303 "scream-if-you-can", "geistani", "pfeildurchkopf01", "grab-schaufler", "kuerbisleuchten", "mummy3",
7304 "kuerbishaufen", "halloweenskulljongleur", "fledermausvampir", "frankenstein_lol", "halloween_confused", "zombies_razz",
7305 "halloweenstars_freddykrueger", "zombies_cool", "geist2", "fledermaus2", "halloweenstars_dracula"
7306 // "batman" "halloweenstars_lastsummer"
7307 ];
7308 }
7309 if (SmileyBox.isXmas) {
7310 smileyArray.xmas = [
7311 "schneeballwerfen", "schneeball", "xmas4_advent4", "nikolaus", "weihnachtsmann_junge", "schneewerfen_wald", "weihnachtsmann_nordpol", "xmas_kilroy_kamin",
7312 "xmas4_laola", "xmas4_aufsmaul", "xmas3_smile", "xmas4_paketliebe", "mttao_ruprecht_peitsche", "3hlkoenige", "santa", "xmas4_hurra2", "weihnachtsgeschenk2", "fred_weihnachten-ostern"
7313 //"dafuer", "outofthebox", "pokal_gold", "koepfler", "transformer"
7314 ];
7315 }
7316
7317 //smileyArray.other = smileyArray.halloween.slice();
7318
7319 // Forum: Extra smiley
7320 if (SmileyBox.isForum) {
7321 smileyArray.grepolis.push("i/ckajscggscw4s2u60"); // Pacman
7322 smileyArray.grepolis.push("i/cowqyl57t5o255zli"); // Bugpolis
7323 smileyArray.grepolis.push("i/cowquq2foog1qrbee"); // Inno
7324 }
7325
7326 SmileyBox.loadSmileys();
7327 },
7328 deactivate: function () {
7329 $('#dio_smiley').remove();
7330 },
7331 checkHolidaySeason: function () {
7332 // TODO: HolidaySpecial-Klasse stattdessen benutzen
7333 var daystamp = 1000 * 60 * 60 * 24, today = new Date((new Date()) % (daystamp * (365 + 1 / 4))), // without year
7334
7335 // Halloween-Smileys ->15 days
7336 halloween_start = daystamp * 297, // 25. Oktober
7337 halloween_end = daystamp * 321, // 8. November
7338 // Xmas-Smileys -> 28 Tage
7339 xmas_start = daystamp * 334, // 1. Dezember
7340 xmas_end = daystamp * 361; // 28. Dezember
7341
7342 SmileyBox.isHalloween = (today >= halloween_start) ? (today <= halloween_end) : false;
7343
7344 SmileyBox.isXmas = (today >= xmas_start) ? (today <= xmas_end) : false;
7345 },
7346 // preload images
7347 loadSmileys: function () {
7348 // Replace german sign smilies
7349 if (LID !== "de") {
7350 smileyArray.other[17] = "dagegen2";
7351 smileyArray.other[19] = "dafuer2";
7352 }
7353
7354 for (var e in smileyArray) {
7355 if (smileyArray.hasOwnProperty(e)) {
7356 for (var f in smileyArray[e]) {
7357 if (smileyArray[e].hasOwnProperty(f)) {
7358 var src = smileyArray[e][f];
7359
7360 smileyArray[e][f] = new Image();
7361 smileyArray[e][f].className = "smiley";
7362
7363 if (src.substring(0, 2) == "i/") {
7364 smileyArray[e][f].src = "http://666kb.com/" + src + ".gif";
7365 } else {
7366 if (SmileyBox.loading_error == false) {
7367 smileyArray[e][f].src = "https://diotools.de/images/smileys/"+ e +"/smiley_emoticons_" + src + ".gif";
7368 //console.debug("Smiley", e);
7369 } else {
7370 smileyArray[e][f].src = '';
7371 }
7372 }
7373 smileyArray[e][f].onerror = function () {
7374 this.src = '';
7375 };
7376 }
7377 }
7378 }
7379 }
7380 },
7381
7382 // Forum smilies
7383 changeForumEditorLayout: function () {
7384 $('.blockrow').css({border: "none"});
7385
7386 // Subject/Title
7387 $($('.section div label[for="title"]').parent()).css({float: "left", width: "36%", marginRight: "20px"});
7388 $($('.section div label[for="subject"]').parent()).css({float: "left", width: "36%", marginRight: "20px"});
7389
7390 $('.section div input').eq(0).css({marginBottom: "-10px", marginTop: "10px"});
7391 $('#display_posticon').remove();
7392
7393 // Posticons
7394 $('.posticons table').css({width: "50%" /* marginTop: "-16px"*/});
7395 $('.posticons').css({marginBottom: "-16px"});
7396 $('.posticons').insertAfter($('.section div label[for="title"]').parent());
7397 $('.posticons').insertAfter($('.section div label[for="subject"]').parent());
7398 // Posticons hint
7399 $('.posticons p').remove();
7400 // Posticons: No Icon - radio button
7401 $(".posticons [colspan='14']").parent().replaceWith($(".posticons [colspan='14']"));
7402 $(".posticons [colspan='14']").children().wrap("<nobr></nobr>");
7403 $(".posticons [colspan='14']").appendTo('.posticons tr:eq(0)');
7404 $(".posticons [colspan='4']").remove();
7405 },
7406
7407 addForum: function () {
7408 $('<div class="smiley_box forum"><div>' +
7409 '<div class="box_header_left">' +
7410 '<span class="group standard active">' + getText("labels", "std") + '</span>' +
7411 '<span class="group grepolis">' + getText("labels", "gre") + '</span>' +
7412 '<span class="group nature">' + getText("labels", "nat") + '</span>' +
7413 '<span class="group people">' + getText("labels", "ppl") + '</span>' +
7414 '<span class="group other">' + getText("labels", "oth") + '</span>' +
7415 (SmileyBox.isHalloween ? '<span class="group halloween">' + getText("labels", "hal") + '</span>' : '') +
7416 (SmileyBox.isXmas ? '<span class="group xmas">' + getText("labels", "xma") + '</span>' : '') +
7417 '</div>' +
7418 '<div class="box_header_right"><a class="smiley_link" href="http://www.greensmilies.com/smilie-album/" target="_blank">WWW.GREENSMILIES.COM</a></div>' +
7419 '<hr>' +
7420 '<div class="box_content" style="overflow: hidden;"><hr></div>' +
7421 '</div></div><br>').insertAfter(".texteditor");
7422
7423 SmileyBox.addSmileys("standard", "");
7424
7425 $('.group').click(function () {
7426 $('.group.active').removeClass("active");
7427 $(this).addClass("active");
7428 // Change smiley group
7429 SmileyBox.addSmileys(this.className.split(" ")[1], "");
7430 });
7431 },
7432
7433 // add smiley box
7434 add: function (e) {
7435 var bbcodeBarId = "";
7436 switch (e) {
7437 case "/alliance_forum/forum":
7438 bbcodeBarId = "#forum";
7439 break;
7440 case "/message/forward":
7441 bbcodeBarId = "#message_bbcodes";
7442 break;
7443 case "/message/new":
7444 bbcodeBarId = "#message_bbcodes";
7445 break;
7446 case "/message/view":
7447 bbcodeBarId = "#message_bbcodes";//setWonderIconsOnMap
7448 break;
7449 case "/player_memo/load_memo_content":
7450 bbcodeBarId = "#memo_edit"; // old notes
7451 break;
7452 case "/frontend_bridge/fetch":
7453 bbcodeBarId = ".notes_container"; // TODO: new notes
7454 break;
7455 }
7456 if (($(bbcodeBarId + ' #emots_popup_7').get(0) || $(bbcodeBarId + ' #emots_popup_15').get(0)) && PID == 84367) {
7457 $(bbcodeBarId + " .bb_button_wrapper").get(0).lastChild.remove();
7458 }
7459 $('<img class="smiley_button" src="http://www.greensmilies.com/smile/smiley_emoticons_smile.gif">').appendTo(bbcodeBarId + ' .bb_button_wrapper');
7460
7461 $('<div class="smiley_box game">' +
7462 '<div class="bbcode_box middle_center"><div class="bbcode_box middle_right"></div><div class="bbcode_box middle_left"></div>' +
7463 '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div><div class="bbcode_box top_center"></div>' +
7464 '<div class="bbcode_box bottom_center"></div><div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>' +
7465 '<div class="box_header">' +
7466 '<span class="group standard active">' + getText("labels", "std") + '</span>' +
7467 '<span class="group grepolis">' + getText("labels", "gre") + '</span>' +
7468 '<span class="group nature">' + getText("labels", "nat") + '</span>' +
7469 '<span class="group people">' + getText("labels", "ppl") + '</span>' +
7470 '<span class="group ' + (SmileyBox.isHalloween ? 'halloween' : (SmileyBox.isXmas ? 'xmas' : 'other')) + '">' + getText("labels", (SmileyBox.isHalloween ? 'hal' : (SmileyBox.isXmas ? 'xma' : 'oth'))) + '</span>' +
7471 '</div>' +
7472 '<hr>' +
7473 '<div class="box_content"></div>' +
7474 '<hr>' +
7475 '<div class="box_footer"><a href="http://www.greensmilies.com/smilie-album/" target="_blank">WWW.GREENSMILIES.COM</a></div>' +
7476 '</div>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
7477
7478
7479 $(bbcodeBarId + ' .group').click(function () {
7480 $('.group.active').removeClass("active");
7481 $(this).addClass("active");
7482 // Change smiley group
7483 SmileyBox.addSmileys(this.className.split(" ")[1], "#" + $(this).closest('.bb_button_wrapper').parent().get(0).id);
7484 });
7485
7486 SmileyBox.addSmileys("standard", bbcodeBarId);
7487
7488 // smiley box toggle
7489 $(bbcodeBarId + " .smiley_button").toggleClick(
7490 function () {
7491 this.src = smileyArray.button[0].src;
7492 $(this).closest('.bb_button_wrapper').find(".smiley_box").get(0).style.display = "block";
7493 },
7494 function () {
7495 this.src = smileyArray.button[1].src;
7496 $(this).closest('.bb_button_wrapper').find(".smiley_box").get(0).style.display = "none";
7497 }
7498 );
7499 },
7500
7501 // insert smileys from arrays into smiley box
7502 addSmileys: function (type, bbcodeBarId) {
7503 // reset smilies
7504 if ($(bbcodeBarId + " .box_content").get(0)) {
7505 $(bbcodeBarId + " .box_content").get(0).innerHTML = '';
7506 }
7507 // add smilies
7508 for (var e in smileyArray[type]) {
7509 if (smileyArray[type].hasOwnProperty(e)) {
7510 $(smileyArray[type][e]).clone().appendTo(bbcodeBarId + " .box_content");
7511 //$('<img class="smiley" src="' + smileyArray[type][e].src + '" alt="" />').appendTo(bbcodeBarId + " .box_content");
7512 }
7513 }
7514 $('.smiley').css({margin: '0px', padding: '2px', maxHeight: '35px', cursor: 'pointer'});
7515
7516 $(bbcodeBarId + " .box_content .smiley").click(function () {
7517 var textarea;
7518 if (uw.location.pathname.indexOf("game") >= 0) {
7519 // hide smiley box
7520 $(this).closest('.bb_button_wrapper').find(".smiley_button").click();
7521 // find textarea
7522 textarea = $(this).closest('.gpwindow_content').find("textarea").get(0);
7523 } else {
7524
7525 if ($('.editor_textbox_container').get(0)) {
7526 textarea = $('.editor_textbox_container .cke_contents textarea').get(0);
7527 } else {
7528 $(this).appendTo('iframe .forum');
7529 }
7530 }
7531 var text = $(textarea).val();
7532 $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + "[img]" + this.src + "[/img]" + text.substring($(textarea).get(0).selectionEnd));
7533 });
7534 }
7535 };
7536
7537
7538 /*******************************************************************************************************************************
7539 * Biremes counter
7540 * ----------------------------------------------------------------------------------------------------------------------------
7541 * | ● Incremental update when calling a city (experimental, especially intended for siege worlds)
7542 * ----------------------------------------------------------------------------------------------------------------------------
7543 * @deprecated
7544 * *****************************************************************************************************************************/
7545
7546 // TODO: Altes Feature entfernen
7547 var BiremeCounter = {
7548 activate: function () {
7549 $(".picomap_container").prepend("<div id='available_units'><div id='bi_count'></div></div>");
7550
7551 $('.picomap_overlayer').tooltip(getText("options", "bir")[0]);
7552 BiremeCounter.update();
7553
7554 // Style
7555 $('<style id="dio_bireme_counter">' +
7556 '#available_units { background: url(https://gpall.innogamescdn.com/images/game/units/units_sprite_90x90_compressed.jpg); height:90px;' +
7557 'width:90px; position: relative; margin: 5px 28px 0px 28px; background-position: -270px 0px; } ' +
7558 '#bi_count { color:#826021; position:relative; top:28px; font-style:italic; width:79px; } ' +
7559 '#sea_id { background: none; font-size:25px; cursor:default; height:50px; width:50px; position:absolute; top:70px; left:157px; z-index: 30; } ' +
7560 '</style>').appendTo('head');
7561
7562 // fs_count: color: #FFC374;position: relative;top: 30px;font-style: italic;width: 101px;text-shadow: 1px 1px 0px rgb(69, 0, 0);
7563 // manti: background-position: -1350px 180px;
7564 // manti-count: color: #ECD181;position: relative;top: 48px;font-style: italic;width: 52px;text-shadow: 2px 2px 0px rgb(0, 0, 0);
7565 // medusa:-1440px 182px;
7566 // med-count: color: #DEECA4;position: relative;top: 50px;font-style: italic;width: 55px;text-shadow: 2px 2px 0px rgb(0, 0, 0);
7567
7568 // Set Sea-ID beside the bull eye
7569 $('#sea_id').prependTo('#ui_box');
7570 },
7571 deactivate: function () {
7572 $('#available_units').remove();
7573 $('#dio_bireme_counter').remove();
7574 $('#sea_id').appendTo('.picomap_container');
7575 },
7576 save: function () {
7577 saveValue(WID + "_biremes", JSON.stringify(biriArray));
7578 },
7579 update: function () {
7580 var sum = 0, e;
7581 if ($('#bi_count').get(0)) {
7582 for (e in biriArray) {
7583 if (biriArray.hasOwnProperty(e)) {
7584 if (!uw.ITowns.getTown(e)) { // town is no longer in possession of user
7585 delete biriArray[e];
7586 BiremeCounter.save();
7587 } else {
7588 sum += parseInt(biriArray[e], 10);
7589 }
7590 }
7591 }
7592
7593 sum = sum.toString();
7594 var str = "", fsize = ['1.4em', '1.2em', '1.15em', '1.1em', '1.0em'], i;
7595
7596 for (i = 0; i < sum.length; i++) {
7597 str += "<span style='font-size:" + fsize[i] + "'>" + sum[i] + "</span>";
7598 }
7599 $('#bi_count').get(0).innerHTML = "<b>" + str + "</b>";
7600 }
7601 },
7602 get: function () {
7603 var biremeIn = parseInt(uw.ITowns.getTown(uw.Game.townId).units().bireme, 10),
7604 biremeOut = parseInt(uw.ITowns.getTown(uw.Game.townId).unitsOuter().bireme, 10);
7605 if (isNaN(biremeIn)) biremeIn = 0;
7606 if (isNaN(biremeOut)) biremeOut = 0;
7607 if (!biriArray[uw.Game.townId] || biriArray[uw.Game.townId] < (biremeIn + biremeOut)) {
7608 biriArray[uw.Game.townId] = biremeIn;
7609 }
7610 BiremeCounter.update();
7611 BiremeCounter.save();
7612 },
7613 getDocks: function () {
7614 var windowID = uw.BuildingWindowFactory.getWnd().getID(),
7615 biremeTotal = parseInt($('#gpwnd_' + windowID + ' #unit_order_tab_bireme .unit_order_total').get(0).innerHTML, 10);
7616
7617 if (!isNaN(biremeTotal)) biriArray[uw.Game.townId] = biremeTotal;
7618 BiremeCounter.update();
7619 BiremeCounter.save();
7620 },
7621 getAgora: function () {
7622 var biremeTotal = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().bireme, 10);
7623 if (isNaN(biremeTotal)) biremeTotal = 0;
7624
7625 $('#units_beyond_list .bireme').each(function () {
7626 biremeTotal += parseInt(this.children[0].innerHTML, 10);
7627 });
7628 biriArray[uw.Game.townId] = biremeTotal;
7629 BiremeCounter.update();
7630 BiremeCounter.save();
7631 }
7632 };
7633
7634 /*******************************************************************************************************************************
7635 * Favor Popup
7636 * ----------------------------------------------------------------------------------------------------------------------------
7637 * | ● Improved favor popup
7638 * ----------------------------------------------------------------------------------------------------------------------------
7639 *******************************************************************************************************************************/
7640 var FavorPopup = {
7641 godArray: {
7642 zeus: '0px',
7643 hera: '-152px',
7644 poseidon: '-101px',
7645 athena: '-50px',
7646 hades: '-203px',
7647 artemis: '-305px'
7648 }, godImg: (new Image()).src = "https://diotools.de/images/game/gods.png",
7649
7650 activate: function () {
7651 $('.gods_favor_button_area, #favor_circular_progress').bind('mouseover mouseout', function () {
7652 return false;
7653 });
7654 $('.gods_area').bind('mouseover', function () {
7655 FavorPopup.setFavorPopup();
7656 });
7657 },
7658
7659 deactivate: function () {
7660 $('.gods_favor_button_area, #favor_circular_progress').unbind('mouseover mouseout');
7661 $('.gods_area').unbind('mouseover');
7662 },
7663
7664 setFavorPopup: function () {
7665 var pic_row = "", fav_row = "", prod_row = "", tooltip_str;
7666
7667 for (var g in FavorPopup.godArray) {
7668 if (FavorPopup.godArray.hasOwnProperty(g)) {
7669 if (uw.ITowns.player_gods.attributes.temples_for_gods[g]) {
7670 pic_row += '<td><div style="width:50px;height:51px;background:url(' + FavorPopup.godImg + ');background-position: 0px ' + FavorPopup.godArray[g] + ';"></td>';
7671 fav_row += '<td class="bold" style="color:blue">' + uw.ITowns.player_gods.attributes[g + "_favor"] + '</td>';
7672 prod_row += '<td class="bold">' + uw.ITowns.player_gods.attributes.production_overview[g].production + '</td>';
7673 }
7674 }
7675 }
7676 tooltip_str = $('<table><tr><td></td>' + pic_row + '</tr>' +
7677 '<tr align="center"><td><img src="https://gpall.innogamescdn.com/images/game/res/favor.png"></td>' + fav_row + '</tr>' +
7678 '<tr align="center"><td>+</td>' + prod_row + '</tr>' +
7679 '</table>');
7680
7681 $('.gods_favor_button_area, #favor_circular_progress').tooltip(tooltip_str);
7682 }
7683 };
7684
7685 /*******************************************************************************************************************************
7686 * GUI Optimization
7687 * ----------------------------------------------------------------------------------------------------------------------------
7688 * | ● Modified spell box (smaller, moveable & position memory)
7689 * | ● Larger taskbar and minimize daily reward-window on startup
7690 * | ● Modify chat
7691 * | ● Improved display of troops and trade activity boxes (movable with position memory on startup)
7692 * ----------------------------------------------------------------------------------------------------------------------------
7693 *******************************************************************************************************************************/
7694
7695 var Spellbox = {
7696 observe: function () {
7697 $.Observer(uw.GameEvents.ui.layout_gods_spells.rendered).subscribe('DIO_SPELLBOX_CHANGE_OPEN', function () {
7698 if (spellbox.show == false) {
7699 spellbox.show = true;
7700 saveValue("spellbox", JSON.stringify(spellbox));
7701 }
7702 Spellbox.change();
7703 });
7704 $.Observer(uw.GameEvents.ui.layout_gods_spells.state_changed).subscribe('DIO_SPELLBOX_CLOSE', function () {
7705 spellbox.show = false;
7706 saveValue("spellbox", JSON.stringify(spellbox));
7707 });
7708
7709 // GRCRT Bug-Fix
7710 if(typeof(RepConv) !== "undefined") {
7711 $.Observer(uw.GameEvents.ui.layout_gods_spells.rendered).unsubscribe('GRCRT_GRC_ui_layout_gods_spells_rendered');
7712
7713 $.Observer(uw.GameEvents.ui.layout_gods_spells.rendered).subscribe('GRCRT_GRC_ui_layout_gods_spells_rendered', function () {
7714 // PlayerGods doesn't exists at game start and the function would call an error
7715 if (typeof(RepConv.models.PlayerGods) !== "undefined") {
7716 RepConvTool.loadPower();
7717 }
7718 });
7719 }
7720 },
7721
7722 activate: function () {
7723 Spellbox.observe();
7724 Spellbox.change();
7725
7726 $('<style id="dio_spellbox_style" type="text/css">' +
7727 // Don't hide hero box, unit time box and hero coin box from GRC
7728 '#ui_box .nui_right_box { overflow: visible; } ' +
7729 // Hide negative spells
7730 '#ui_box .bolt, #ui_box .earthquake, #ui_box .pest { display: none } ' +
7731 // Change spell order
7732 '#ui_box .god_container { float: left } ' +
7733 '#ui_box .god_container[data-god_id="zeus"], #ui_box .god_container[data-god_id="athena"] { float: none } ' +
7734 // Remove background
7735 '#ui_box .powers_container { background: none !important } ' +
7736 // Hide god titles
7737 '#ui_box .content .title { display: none !important } ' +
7738 // Hide border elements
7739 '#ui_box .gods_spells_menu .left, #ui_box .gods_spells_menu .right, #ui_box .gods_spells_menu .top, #ui_box .gods_spells_menu .bottom { display: none } ' +
7740 // Layout
7741 '#ui_box .gods_area { height:150px } ' +
7742
7743 '#ui_box .gods_spells_menu { width: 134px; position:absolute; z-index:5000; padding:30px 0px 0px -4px } ' +
7744 '#ui_box .gods_spells_menu .content { background:url(https://gpall.innogamescdn.com/images/game/layout/power_tile.png) 1px 4px; overflow:auto; margin:0 0 0px 0px; border:3px inset rgb(16, 87, 19); border-radius:10px } ' +
7745
7746 '#ui_box .nui_units_box { display:block; margin-top:-8px; position:relative } ' +
7747 '#ui_box .nui_units_box .bottom_ornament { margin-top:-28px; position: relative } ' +
7748 '</style>').appendTo('head');
7749
7750 // Draggable Box
7751 $("#ui_box .gods_spells_menu").draggable({
7752 containment: "body",
7753 distance: 10,
7754 snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, #island_quests_overview",
7755 opacity: 0.7,
7756 stop: function () {
7757 spellbox.top = this.style.top;
7758 spellbox.left = this.style.left;
7759
7760 saveValue("spellbox", JSON.stringify(spellbox));
7761 }
7762 });
7763 $("#ui_box .gods_spells_menu").before($('#ui_box .nui_units_box'));
7764
7765 // Position
7766 $('#ui_box .gods_spells_menu').css({
7767 left: spellbox.left,
7768 top: spellbox.top
7769 });
7770
7771 // Active at game start?
7772 if (spellbox.show && !$('#ui_box .btn_gods_spells').hasClass('active')) {
7773 $('#ui_box .btn_gods_spells').click();
7774 }
7775 },
7776 deactivate: function () {
7777 $('#ui_box .gods_spells_menu').draggable('destroy');
7778
7779 // Position
7780 $('#ui_box .gods_spells_menu').css({
7781 left: "auto",
7782 top: "150px"
7783 });
7784
7785 //$("#ui_box .gods_spells_menu").appendTo('gods_area'); // ?
7786
7787 $('#dio_spellbox_style').remove();
7788
7789 $.Observer(GameEvents.ui.layout_gods_spells.rendered).unsubscribe('DIO_SPELLBOX_CHANGE_OPEN');
7790 $.Observer(GameEvents.ui.layout_gods_spells.state_changed).unsubscribe('DIO_SPELLBOX_CLOSE');
7791 },
7792
7793 change: function () {
7794 //console.log("Unitsbox: "+ $(".nui_units_box").height());
7795 //console.log("Spellbox: "+ $(".gods_spells_menu").height());
7796
7797 // Change spell order
7798 $('#ui_box .god_container[data-god_id="poseidon"]').prependTo('#ui_box .gods_spells_menu .content');
7799 $('#ui_box .god_container[data-god_id="athena"]').appendTo('#ui_box .gods_spells_menu .content');
7800 $('#ui_box .god_container[data-god_id="artemis"]').appendTo('#ui_box .gods_spells_menu .content');
7801 }
7802
7803 };
7804
7805
7806 // Minimize Daily reward window on startup
7807 function minimizeDailyReward() {
7808 /*
7809 $.Observer(uw.GameEvents.window.open).subscribe('DIO_WINDOW', function(u,dato){});
7810 $.Observer(uw.GameEvents.window.reload).subscribe('DIO_WINDOW2', function(f){});
7811 */
7812 if (MutationObserver) {
7813 var startup = new MutationObserver(function (mutations) {
7814 mutations.forEach(function (mutation) {
7815 if (mutation.addedNodes[0]) {
7816 if ($('.daily_login').get(0)) { // && !uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).isMinimized()
7817 $('.daily_login').find(".minimize").click();
7818 //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).minimize();
7819 }
7820 }
7821 });
7822 });
7823 startup.observe($('body').get(0), {attributes: false, childList: true, characterData: false});
7824
7825 setTimeout(function () {
7826 startup.disconnect();
7827 }, 3000);
7828 }
7829 }
7830
7831 // Larger taskbar
7832 var Taskbar = {
7833 activate: function () {
7834 $('.minimized_windows_area').get(0).style.width = "150%";
7835 $('.minimized_windows_area').get(0).style.left = "-25%";
7836 },
7837 deactivate: function () {
7838 $('.minimized_windows_area').get(0).style.width = "100%";
7839 $('.minimized_windows_area').get(0).style.left = "0%";
7840 }
7841 };
7842
7843 // Hide fade out buttons
7844 function hideNavElements() {
7845 if (Game.premium_features.curator <= Timestamp.now()) {
7846 $('.nav').each(function () {
7847 this.style.display = "none";
7848 });
7849 }
7850 }
7851
7852 /*******************************************************************************************************************************
7853 * Chat
7854 *******************************************************************************************************************************/
7855
7856 var Chat = {
7857 user_colors : {},
7858
7859 delay : 10000,
7860
7861 timestamp : 0,
7862
7863 isWindowFocused : true,
7864
7865 isActivated : false,
7866
7867 isOpened : false,
7868
7869 activate : function(){
7870
7871 Chat.isActivated = true;
7872
7873 Chat.isOpened = true;
7874
7875 $('<style id="dio_chat_style">'+
7876 '#dio_chat { position: absolute; bottom: 0px; z-index: 4; width: 25%; transition: left 1.3s; left:0; -moz-user-select: text; -webkit-user-select: text; user-select: text; }'+
7877 '#dio_chat.resize { transition: left 0s; }'+
7878
7879 '#dio_chat .slider { width:100%; height: 6px; top:0; right:1px; position:absolute; margin-left:-8px; cursor: row-resize; }'+
7880
7881 '#dio_chat .messagebox { text-shadow: 1px 1px 4px black; overflow-y:hidden; overflow-x:auto; max-height:120px; min-height:30px; width:100%; background: rgba(0, 0, 0, 0.6); color: #aaa; padding: 8px; text-align:left; font-size:11px; border: 1px solid darkgreen; border-left:none; border-bottom:1px solid #575; box-shadow: -3px 2px 3px black; }'+
7882 '#dio_chat .messagebox .time { float:left; color: #686; }'+
7883 '#dio_chat .messagebox .user { float:left; }'+
7884 '#dio_chat .messagebox .text { word-break: break-word; color: #797; }'+
7885
7886 '#dio_chat .messagebox .welcome .text { color: rgb(200,220,200); }'+
7887
7888 '#dio_chat .togglebutton { background: rgba(0,0,0,0.5); width: 24px; height: 100%; position: absolute; top: 0; right: -40px; color: #fc6; opacity:0.75; cursor: pointer; }'+
7889 '#dio_chat .togglebutton .top { height:4px; width:24px; background: url(https://diotools.de/images/game/button_sprite_vertical.png) 0px -1px; position:absolute;}'+
7890 '#dio_chat .togglebutton:hover .top { background-position: -25px -1px; }'+
7891 '#dio_chat .togglebutton .bottom { height:4px; width:24px; background: url(https://diotools.de/images/game/button_sprite_vertical.png) 0px 4px; position:absolute; bottom:0px; }'+
7892 '#dio_chat .togglebutton:hover .bottom { background-position: -25px 4px; }'+
7893 '#dio_chat .togglebutton .middle { height:100%; width:24px; background: url(https://diotools.de/images/game/button_sprite_vertical.png) -50px 0px; }'+
7894 '#dio_chat .togglebutton:hover .middle { background-position: -75px 0px; }'+
7895 '#dio_chat .togglebutton .arrow { position:absolute; left:6px; top:42.5%; }'+
7896
7897 '#dio_chat .icon { position:absolute; right:10px; top:10px; opacity:0.15; width: 31px; height:31px; filter: sepia(0.5); background: url(http://666kb.com/i/d9xuhtcctx5fdi8i6.png) -50px -76px no-repeat; }'+
7898
7899 '#dio_chat input { background: rgba(0, 0, 0, 0.5); color: white; border: 0px none; padding: 8px; width: 100%; border-right: 1px solid darkgreen; }'+
7900 '#dio_chat input:hover { background: rgba(0, 0, 10, 0.4); }'+
7901 '#dio_chat input:focus { background: rgba(0, 0, 10, 0.4); }'+
7902 '#dio_chat input::placeholder, '+
7903 '#dio_chat input::-webkit-input-placeholder, '+
7904 '#dio_chat input::-moz-placeholder, ' +
7905 '#dio_chat input:-ms-input-placeholder, '+
7906 '#dio_chat input:-moz-placeholder { color: black; }'+
7907
7908 // Chat im Menü ausblenden
7909 '.nui_main_menu ul { height:auto !important; }'+
7910 '.nui_main_menu li.chat { display:none !important; }'+
7911
7912 '#grcgrc { display:none }'+
7913
7914 '</style>').appendTo('head');
7915
7916 $('<div id="dio_chat"><div class="icon"></div><div class="messagebox"><div class="slider"></div></div><input type="text" placeholder="Nachricht eingeben..." /></div>').appendTo("#ui_box");
7917
7918 $('<div class="welcome"><div class="time">'+ Chat.formatTime(Timestamp.server()) +': </div><div class="text">Hallo '+ Game.player_name + '! Willkommen im DIO-Tools Weltenchat ('+ Game.world_id +')</div></div>').appendTo("#ui_box .messagebox");
7919
7920 $('<div class="togglebutton"><div class="top"></div><div class="middle"><div class="arrow">◄</div></div><div class="bottom"></div></div>').appendTo("#dio_chat");
7921
7922 // Texteingabe
7923 $('#dio_chat input').keypress(function(e) {
7924
7925 if (e.keyCode === 13) {
7926
7927 var _time = $('.server_time_area').get(0).innerHTML.split(" ")[0];
7928
7929 var _message = $(this).val();
7930
7931 if(_message.length > 0) {
7932
7933 Chat.sendMessage(_message);
7934
7935 $(this).val('');
7936 }
7937
7938 }
7939 });
7940
7941 /*
7942 $('#dio_chat').draggable({
7943 containment: "body",
7944 distance: 10,
7945 snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, #island_quests_overview",
7946 opacity: 0.7,
7947 stop: function () {}
7948 });
7949 */
7950
7951 // Ein-/Ausblenden der Chatbox
7952 $('#dio_chat .togglebutton').toggleClick(
7953 function () {
7954
7955 var x = -($(window).width() * 0.25 + 16);
7956
7957 $('#dio_chat').css("left", x);
7958
7959 setTimeout(function(){
7960 $('#dio_chat .togglebutton .arrow').get(0).innerHTML = "►";
7961 },1300);
7962
7963 // Tooltip
7964 $('#dio_chat .togglebutton').tooltip("Chat öffnen");
7965
7966 },
7967 function (){
7968
7969 $('#dio_chat').css("left", 0);
7970
7971 setTimeout(function(){
7972 $('#dio_chat .togglebutton .arrow').get(0).innerHTML = "◄";
7973 },1300);
7974
7975 // Tooltip
7976 $('#dio_chat .togglebutton').tooltip("Chat schließen");
7977 }
7978 );
7979 // Wenn sich die Fenstergröße ändert
7980
7981 $(window).on("resize.dio", function(){
7982
7983 if($('#dio_chat').css("left") !== "0px"){
7984
7985 var x = -($(window).width() * 0.25 + 16);
7986
7987 $('#dio_chat').addClass("resize");
7988 $('#dio_chat').css("left", x);
7989
7990 setTimeout(function(){
7991 $('#dio_chat').removeClass("resize");
7992 },0);
7993 }
7994 });
7995
7996 // Tooltip
7997 $('#dio_chat .togglebutton').tooltip("Chat schließen");
7998
7999 // Skalierung der Höhe
8000 $('#dio_chat .slider').mousedown(function (e) {
8001 e.preventDefault();
8002
8003 $('#dio_chat .messagebox').css("max-height", "none");
8004
8005 $(document).on("mousemove.dio", function (e) {
8006 e.preventDefault();
8007
8008 var x = $(window).height() - e.pageY - 49;
8009
8010 if (x > 30 && x < $(window).height() - 400) {
8011 $('#dio_chat .messagebox').css("height", x );
8012 }
8013 });
8014 });
8015
8016 $(document).on("mouseup.dio", function (e) {
8017 $(document).off("mousemove.dio");
8018
8019 //$('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollTopMax;
8020 $('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollHeight
8021 });
8022
8023
8024
8025 Chat.timestamp = Timestamp.server();
8026
8027 // Initialer Start
8028 Chat.getMessages();
8029
8030
8031 // Öfter anfragen, wenn man chatten will
8032 $('#dio_chat').hover(function(){
8033
8034 if(Chat.isOpened === true) {
8035 Chat.delay = 3000; // 3s
8036
8037 clearTimeout(Chat.timeout_A);
8038 clearTimeout(Chat.timeout_B);
8039 }
8040
8041 }, function(){
8042
8043 if(Chat.isOpened === true) {
8044
8045 Chat.delay = 10000; // 10s
8046
8047 // Nach 5min nur noch alle 30s
8048 Chat.timeout_A = setTimeout(function () {
8049 Chat.delay = 30000;
8050 }, 300000);
8051
8052 // Nach 15min nur noch alle 60s
8053 Chat.timeout_B = setTimeout(function () {
8054 Chat.delay = 60000;
8055 }, 900000);
8056 }
8057 });
8058
8059 // Nur wenn Grepolis offen ist aktualisieren
8060 $(window).on("focus.dio", function() {
8061 Chat.isWindowFocused = true;
8062
8063 if(Chat.isOpened === true) {
8064
8065 Chat.getMessages();
8066
8067 Chat.delay = 10000; // 10s
8068
8069 clearTimeout(Chat.timeout_A);
8070 clearTimeout(Chat.timeout_B);
8071
8072 // Nach 5min nur noch alle 30s
8073 Chat.timeout_A = setTimeout(function () {
8074 Chat.delay = 30000;
8075 }, 300000);
8076
8077 // Nach 15min nur noch alle 60s
8078 Chat.timeout_B = setTimeout(function () {
8079 Chat.delay = 60000;
8080 }, 900000);
8081 }
8082
8083 }).on("blur.dio", function() {
8084 Chat.isWindowFocused = false;
8085 });
8086 },
8087 deactivate : function(){
8088 Chat.isActivated = false;
8089
8090 $('#dio_chat_style').remove();
8091 $('#dio_chat').remove();
8092
8093 // Events disconnecten
8094 $(document).off('mouseup.dio');
8095 $(window).off('focus.dio');
8096 $(window).off('blur.dio');
8097 $(window).off('resize.dio');
8098 },
8099 sendMessage : function(_message){
8100
8101 _message = encodeURIComponent(_message.replace(/'/g, "'").replace(/ /g, " "));
8102
8103 $.ajax({
8104 type: "GET",
8105 url: "https://diotools.de/php/sendMessage.php?world=" + Game.world_id + "&time=" + Timestamp.server() + "&player="+ Game.player_name +"&message="+ _message,
8106 dataType: 'text',
8107 success: function (response) {
8108 console.debug("Nachricht wurde erfolgreich gesendet");
8109
8110 //$('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollTopMax;
8111 $('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollHeight
8112
8113 Chat.getMessages();
8114 },
8115 error: function (e) {
8116 console.debug("Nachricht konnte nicht gesendet werden", e);
8117 }
8118 });
8119 },
8120 getMessages : function(){
8121
8122 if(Chat.isActivated === true) {
8123
8124 var _currentTimestamp = Timestamp.server();
8125
8126 var _url = "https://diotools.de/php/getMessages.php?world=" + Game.world_id;
8127
8128 if (typeof(Chat.lastID) !== "undefined") {
8129 _url += "&id=" + Chat.lastID;
8130 }
8131 else {
8132 _url += "&time=" + Chat.timestamp;
8133 }
8134
8135 // Eventuell noch nicht gefeuertes Timeout entfernen
8136 clearTimeout(Chat.timeout);
8137
8138 if (Chat.isWindowFocused) {
8139 $.ajax({
8140 type: "GET",
8141 url: _url,
8142 dataType: 'json',
8143 success: function (_messages) {
8144 if(Chat.isActivated === true) {
8145
8146 // Letzte Abfragezeit speichern
8147 Chat.timestamp = _currentTimestamp;
8148
8149 // console.debug("GET MESSAGES", _messages);
8150
8151 /*
8152 var _scrollDown = false;
8153 if ($('#dio_chat .messagebox')[0].scrollTop === $('#dio_chat .messagebox')[0].scrollTopMax) {
8154 _scrollDown = true;
8155 }
8156 */
8157
8158 for (var m in _messages) {
8159 if (_messages.hasOwnProperty(m)) {
8160
8161 if (typeof(_messages[m].last_id) === "undefined") {
8162
8163 // HTML-Tags ersetzen
8164 var _message = _messages[m].message.replace(/</g, '<').replace(/>/g, '>').replace(/'/g, "\'");
8165
8166 $('#dio_chat .messagebox').append(
8167 '<div class="time">' + Chat.formatTime(_messages[m].time) + ': </div>' +
8168 '<div class="user" style="color:' + Chat.getUserColor(_messages[m].player) + '">' + _messages[m].player + ': </div>' +
8169 '<div class="text"> ' + _message + ' </div>'
8170 );
8171 }
8172 else {
8173 Chat.lastID = _messages[m].last_id;
8174 }
8175 }
8176 }
8177
8178 clearTimeout(Chat.timeout);
8179
8180 Chat.timeout = setTimeout(function () {
8181
8182 if (Chat.isWindowFocused) {
8183 Chat.getMessages();
8184 }
8185
8186 }, Chat.delay);
8187
8188 //if(_scrollDown) {
8189 // $('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollTopMax;
8190 $('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollHeight
8191 //}
8192 }
8193 },
8194 error: function (xhr) {
8195 console.debug("Nachrichten konnten nicht geladen werden", xhr);
8196
8197 clearTimeout(Chat.timeout);
8198
8199 Chat.timeout = setTimeout(function () {
8200
8201 Chat.getMessages();
8202
8203 }, Chat.delay);
8204
8205 }
8206 });
8207
8208 }
8209 }
8210 },
8211 getUserColor : function(_user){
8212
8213 if(typeof(Chat.user_colors[_user]) === "undefined") {
8214
8215 var r = Math.floor(Math.random() * 255);
8216 var g = Math.floor(Math.random() * 255);
8217 var b = Math.floor(Math.random() * 255);
8218
8219 // Bei zu dunkler Farbe neue Farbe ermitteln
8220 if (r + g < 200 && r < 130 && g < 130) {
8221
8222 return Chat.getUserColor(_user);
8223 }
8224
8225 Chat.user_colors[_user] = 'rgb(' + r + ',' + g + ',' + b + ')';
8226 }
8227
8228 return Chat.user_colors[_user];
8229 },
8230 formatTime : function(_timestamp){
8231
8232 var date = new Date(_timestamp*1000);
8233
8234 // Hours part from the timestamp
8235 var hours = "0" + date.getHours();
8236 // Minutes part from the timestamp
8237 var minutes = "0" + date.getMinutes();
8238 // Seconds part from the timestamp
8239 var seconds = "0" + date.getSeconds();
8240
8241 // Will display time in 10:30:23 format
8242 return hours.substr(-2) + ':' + minutes.substr(-2) + ':' + seconds.substr(-2);
8243 }
8244 };
8245
8246 /*******************************************************************************************************************************
8247 * Activity boxes
8248 * ----------------------------------------------------------------------------------------------------------------------------
8249 * | ● Show troops and trade activity boxes
8250 * | ● Boxes are magnetic & movable (position memory)
8251 * ----------------------------------------------------------------------------------------------------------------------------
8252 *******************************************************************************************************************************/
8253 var mut_toolbar, mut_command, mut_trade;
8254
8255 var save_command_mouseout,
8256 save_commandlist_mouseout,
8257 save_trade_mouseout,
8258 save_tradelist_mouseout,
8259
8260 save_command_mouseover,
8261 save_trade_mouseover;
8262
8263
8264 var ActivityBoxes = {
8265 activate: function () {
8266 ActivityBoxes.checkToolbarAtStart();
8267
8268 $('#toolbar_activity_commands_list').css({
8269 left: commandbox.left + "px",
8270 top: commandbox.top + "px"
8271 });
8272
8273 $('<style id="fix_lists" type="text/css">' +
8274 '#toolbar_activity_commands_list, #toolbar_activity_trades_list { width: 160px}' +
8275 '.dropdown-list .content { max-height: 329px}' +
8276 '</style>' +
8277 '<style id="dio_fix_trade" type="text/css">' +
8278 '#toolbar_activity_trades_list {' +
8279 'left:' + tradebox.left + 'px !important;' +
8280 'top: ' + tradebox.top + 'px !important}' +
8281 '</style>').appendTo('head');
8282
8283
8284 ActivityBoxes.draggableTradeBox();
8285 ActivityBoxes.draggableCommandBox();
8286
8287 ActivityBoxes.catchToolbarEvents();
8288 },
8289 deactivate: function () {
8290 ActivityBoxes.hideTradeList();
8291 ActivityBoxes.hideCommandList();
8292
8293 mut_toolbar.disconnect();
8294 mut_command.disconnect();
8295 mut_trade.disconnect();
8296 },
8297 showTradeList: function () {
8298 if (!$('#dio_trades_activity_style').get(0)) {
8299 $('#toolbar_activity_trades').mouseover();
8300 $('<style id="dio_trades_activity_style"> #toolbar_activity_trades_list { display: block !important; } </style>').appendTo("head");
8301 }
8302 },
8303 showCommandList: function () {
8304 if (!$('#dio_commands_activity_style').get(0)) {
8305 $('#toolbar_activity_commands').mouseover();
8306 $('<style id="dio_commands_activity_style"> #toolbar_activity_commands_list { ' +
8307 'display:block !important; left:' + commandbox.left + 'px; top:' + commandbox.top + 'px; }' +
8308 '</style>').appendTo("head");
8309 }
8310 },
8311 hideTradeList: function () {
8312 if ($('#dio_trades_activity_style').get(0)) {
8313 $('#dio_trades_activity_style').remove();
8314 $('#toolbar_activity_trades').mouseout();
8315 }
8316 },
8317 hideCommandList: function () {
8318 if ($('#dio_commands_activity_style').get(0)) {
8319 $('#dio_commands_activity_style').remove();
8320 $('#toolbar_activity_commands').mouseout();
8321 }
8322 },
8323 activate2: function () {
8324 var observe_options = {attributes: false, childList: true, characterData: false};
8325
8326 ActivityBoxes.catchToolbarEvents();
8327
8328 mut_command.observe($('.toolbar_activities .commands .count').get(0), observe_options);
8329 mut_trade.observe($('.toolbar_activities .trades .count').get(0), observe_options);
8330
8331 $('<style id="dio_activity_style"> ' +
8332 '#toolbar_activity_commands_list.active { display: block !important; } ' +
8333 '#toolbar_activity_trades_list.active { display: block !important; } ' +
8334 '</style>').appendTo("head");
8335
8336
8337 $('#toolbar_activity_commands').mouseover();
8338 $('#toolbar_activity_trades').mouseover();
8339
8340 $('#toolbar_activity_commands, #toolbar_activity_trades').off("mouseover");
8341
8342 $('#toolbar_activity_commands, #toolbar_activity_commands_list, #toolbar_activity_trades, #toolbar_activity_trades_list').off("mouseout");
8343
8344 $('#toolbar_activity_trades_list').unbind("click");
8345 //console.log($('#toolbar_activity_commands').data('events')["dd:list:show"][0].handler());
8346
8347 ActivityBoxes.checkToolbarAtStart();
8348
8349 $('#toolbar_activity_commands_list').css({
8350 left: commandbox.left + "px",
8351 top: commandbox.top + "px"
8352 });
8353
8354 $('<style id="fix_lists" type="text/css">' +
8355 '#toolbar_activity_commands_list, #toolbar_activity_trades_list { width: 160px}' +
8356 '.dropdown-list .content { max-height: 329px}' +
8357 '</style>' +
8358 '<style id="dio_fix_trade" type="text/css">' +
8359 '#toolbar_activity_trades_list {' +
8360 'left:' + tradebox.left + 'px !important;' +
8361 'top: ' + tradebox.top + 'px !important}' +
8362 '</style>').appendTo('head');
8363
8364 ActivityBoxes.draggableCommandBox();
8365 ActivityBoxes.draggableTradeBox();
8366
8367
8368 /*
8369 $('.toolbar_activities .commands').on("mouseover.bla", function(){
8370 $('#toolbar_activity_commands_list').addClass("active");
8371 });
8372
8373 $('.toolbar_activities .trades').mouseover(function(){
8374 $('#toolbar_activity_trades_list').addClass("active");
8375 });
8376 */
8377 },
8378 deactivate2: function () {
8379 mut_toolbar.disconnect();
8380 mut_command.disconnect();
8381 mut_trade.disconnect();
8382 /*
8383 $('#toolbar_activity_commands').on("mouseover", save_command_mouseover);
8384 $('#toolbar_activity_trades').on("mouseover", save_trade_mouseover);
8385
8386 $('#toolbar_activity_commands').on("mouseout", save_command_mouseout);
8387 $('#toolbar_activity_commands_list').on("mouseout", save_commandlist_mouseout);
8388 $('#toolbar_activity_trades').on("mouseout", save_trade_mouseout);
8389 $('#toolbar_activity_trades_list').on("mouseout", save_tradelist_mouseout);
8390 */
8391
8392 $('#toolbar_activity_commands').mouseover = save_command_mouseover;
8393 $('#toolbar_activity_trades').mouseover = save_trade_mouseover;
8394
8395 $('#toolbar_activity_commands').mouseout = save_command_mouseout;
8396 $('#toolbar_activity_commands_list').mouseout = save_commandlist_mouseout;
8397 $('#toolbar_activity_trades').mouseout = save_trade_mouseout;
8398 $('#toolbar_activity_trades_list').mouseout = save_tradelist_mouseout;
8399
8400
8401 $('#toolbar_activity_trades_list').removeClass("active");
8402 $('#toolbar_activity_commands_list').removeClass("active");
8403 /*
8404 $('.toolbar_activities .commands').off("mouseover.bla");
8405 */
8406 $('#dio_activity_style').remove();
8407
8408
8409 },
8410 checkToolbarAtStart: function () {
8411 if (parseInt($('.toolbar_activities .commands .count').get(0).innerHTML, 10) > 0) {
8412 ActivityBoxes.showCommandList();
8413 } else {
8414 ActivityBoxes.hideCommandList();
8415 }
8416 if (parseInt($('.toolbar_activities .trades .count').get(0).innerHTML, 10) > 0) {
8417 ActivityBoxes.showTradeList();
8418 } else {
8419 ActivityBoxes.hideTradeList();
8420 }
8421 },
8422 catchToolbarEvents: function () {
8423 var observe_options = {attributes: false, childList: true, characterData: false};
8424
8425 mut_toolbar = new MutationObserver(function (mutations) {
8426 mutations.forEach(function (mutation) {
8427 if (mutation.addedNodes[0]) {
8428 //console.debug(mutation.target.id);
8429 if (mutation.target.id === "toolbar_activity_trades_list") {
8430 ActivityBoxes.draggableTradeBox();
8431 } else {
8432 ActivityBoxes.draggableCommandBox();
8433 }
8434 mutation.addedNodes[0].remove();
8435 }
8436 });
8437 });
8438 //mut_toolbar.observe($('#toolbar_activity_commands_list').get(0), observe_options );
8439 //mut_toolbar.observe($('#toolbar_activity_trades_list').get(0), observe_options );
8440
8441 mut_command = new MutationObserver(function (mutations) {
8442 mutations.forEach(function (mutation) {
8443 if (mutation.addedNodes[0]) {
8444 //console.debug(mutation.addedNodes[0].nodeValue);
8445 if (mutation.addedNodes[0].nodeValue > 0) {
8446 ActivityBoxes.showCommandList();
8447 } else {
8448 //console.debug("hide commands");
8449 ActivityBoxes.hideCommandList();
8450 }
8451 }
8452 });
8453 });
8454 mut_trade = new MutationObserver(function (mutations) {
8455 mutations.forEach(function (mutation) {
8456 if (mutation.addedNodes[0]) {
8457 if (mutation.addedNodes[0].nodeValue > 0) {
8458 ActivityBoxes.showTradeList();
8459 } else {
8460 ActivityBoxes.hideTradeList();
8461 }
8462 }
8463 });
8464 });
8465 mut_command.observe($('.toolbar_activities .commands .count').get(0), observe_options);
8466 mut_trade.observe($('.toolbar_activities .trades .count').get(0), observe_options);
8467 },
8468 // Moveable boxes
8469 draggableTradeBox: function () {
8470 $("#toolbar_activity_trades_list").draggable({
8471 containment: "body",
8472 distance: 20,
8473 snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, .nui_left_box",
8474 opacity: 0.7,
8475 start: function () {
8476 $("#dio_fix_trade").remove();
8477 },
8478 stop: function () {
8479 var pos = $('#toolbar_activity_trades_list').position();
8480
8481 tradebox.left = pos.left;
8482 tradebox.top = pos.top;
8483
8484 saveValue("tradebox", JSON.stringify(tradebox));
8485
8486 $('<style id="dio_fix_trade" type="text/css">' +
8487 '#toolbar_activity_trades_list { left:' + tradebox.left + 'px !important; top:' + tradebox.top + 'px !important; } ' +
8488 '</style>').appendTo('head');
8489 }
8490 });
8491 },
8492 draggableCommandBox: function () {
8493 $("#toolbar_activity_commands_list").draggable({
8494 containment: "body",
8495 distance: 20,
8496 snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, .nui_left_box",
8497 opacity: 0.7,
8498 stop: function () {
8499 var pos = $('#toolbar_activity_commands_list').position();
8500 commandbox.left = pos.left;
8501 commandbox.top = pos.top;
8502
8503 saveValue("commandbox", JSON.stringify(commandbox));
8504 }
8505 });
8506 }
8507 };
8508
8509 /*******************************************************************************************************************************
8510 * Counter
8511 *******************************************************************************************************************************/
8512
8513 function counter(time) {
8514 var type = "", today, counted, year, month, day;
8515 if (uw.Game.market_id !== "zz") {
8516 counted = DATA.count;
8517 today = new Date((time + 7200) * 1000);
8518 year = today.getUTCFullYear();
8519 month = ((today.getUTCMonth() + 1) < 10 ? "0" : "") + (today.getUTCMonth() + 1);
8520 day = (today.getUTCDate() < 10 ? "0" : "") + today.getUTCDate();
8521 today = year + month + day;
8522 //console.log(today);
8523 if (counted[0] !== today) {
8524 type += "d";
8525 }
8526 if (counted[1] == false) {
8527 type += "t";
8528 }
8529 if ((counted[2] == undefined) || (counted[2] == false)) {
8530 type += "b";
8531 }
8532 if (type !== "") {
8533 $.ajax({
8534 type: "GET",
8535 url: "https://diotools.de/game/count.php?type=" + type + "&market=" + uw.Game.market_id + "&date=" + today + "&browser=" + getBrowser(),
8536 dataType: 'text',
8537 success: function (text) {
8538 if (text.indexOf("dly") > -1) {
8539 counted[0] = today;
8540 }
8541 if (text.indexOf("tot") > -1) {
8542 counted[1] = true;
8543 }
8544 if (text.indexOf("bro") > -1) {
8545 counted[2] = true;
8546 }
8547 saveValue("dio_count", JSON.stringify(counted));
8548 }
8549 });
8550 }
8551 }
8552 }
8553
8554
8555 /*******************************************************************************************************************************
8556 * Political Map
8557 *******************************************************************************************************************************/
8558
8559 var PoliticalMap = {
8560 data: null,
8561 activate: function () {
8562 $('<div id="dio_political_map">' +
8563 '<div class="canvas_wrapper"></div>' +
8564 '<select class="zoom_select">' +
8565 '<option value="0.50">1 : 0.50</option>' +
8566 '<option value="0.75">1 : 0.75</option>' +
8567 '<option value="1.00" selected>1 : 1.00</option>' +
8568 '<option value="1.25">1 : 1.25</option>' +
8569 '<option value="1.50">1 : 1.50</option>' +
8570 '<option value="2.00">1 : 2.00</option>' +
8571 '<option value="3.00">1 : 3.00</option>' +
8572 '</select>' +
8573 '<div class="legend sandy-box">' +
8574 '<div class="corner_tl"></div>' +
8575 '<div class="corner_tr"></div>' +
8576 '<div class="corner_bl"></div>' +
8577 '<div class="corner_br"></div>' +
8578 '<div class="border_t"></div>' +
8579 '<div class="border_b"></div>' +
8580 '<div class="border_l"></div>' +
8581 '<div class="border_r"></div>' +
8582 '<div class="middle"></div>' +
8583 '<div class="content"><div class="item"></div></div>' +
8584 '</div></div>').appendTo('#ui_box');
8585
8586 // Style
8587 $('<style id="dio_political_map_style">' +
8588 '#dio_political_map { width:100%; height:100%; z-index:3; background:#123d70; display:none; position:absolute; top:0; } ' +
8589 '#dio_political_map.active { display: block; } ' +
8590 '#dio_political_map .canvas_wrapper { } ' +
8591 '#dio_political_map canvas { position: absolute; cursor:move; top:0; left:0; } ' +
8592 '#dio_political_map .zoom_select { position:absolute; top:70px; left:300px; font-size: 2em; opacity:0.5; } ' +
8593 '#dio_political_map .zoom_select:hover { opacity:1; } ' +
8594 '#dio_political_map .legend { position:absolute; right:200px; top:50px; width:200px; height:auto; text-align:left; } ' +
8595 '#dio_political_map .legend .color_checker { width:15px; height:15px; float:left; border:1px solid rgb(100, 100, 0); margin:5px; position:relative; cursor:pointer; } ' +
8596 '#dio_political_map .legend .wonder_icon { float: left; margin: 4px; } ' +
8597
8598 '.btn_political_map { top:56px; left:-4px; z-index:10; position:absolute; } ' +
8599
8600
8601 '.btn_political_map .ico_political_map.checked { margin-top:8px; } ' +
8602 '</style>').appendTo('head');
8603
8604 PoliticalMap.addButton();
8605
8606 var zoomSelect = $('.zoom_select');
8607
8608 zoomSelect.change(function () {
8609 //PoliticalMap.zoomToCenter();
8610 });
8611 zoomSelect.on("change", function () {
8612 PoliticalMap.zoomToCenter();
8613 });
8614
8615 ColorPicker.init();
8616 },
8617 deactivate: function () {
8618 $('.btn_political_map').remove();
8619 $('#dio_political_map_style').remove();
8620 },
8621 addButton: function () {
8622 var m_ZoomFactor = 1.0;
8623 $('<div class="btn_political_map circle_button" name="political_map"><div class="ico_political_map js-caption"></div></div>').appendTo(".bull_eye_buttons");
8624
8625 var politicalMapButton = $('.btn_political_map');
8626
8627 // Tooltip
8628 politicalMapButton.tooltip("Political Map"); // TODO: Language
8629
8630 // Events
8631 politicalMapButton.on('mousedown', function () {
8632 //$('.btn_political_map, .ico_political_map').addClass("checked");
8633 }).on('mouseup', function () {
8634 //$('.btn_political_map, .ico_political_map').removeClass("checked");
8635 });
8636
8637 $('.rb_map .option').click(function () {
8638 $('.btn_political_map, .ico_political_map').removeClass("checked");
8639 $('#dio_political_map').removeClass("active");
8640 $(this).addClass("checked");
8641 });
8642
8643 politicalMapButton.click(function () {
8644 $('.rb_map .checked').removeClass("checked");
8645 $('.btn_political_map, .ico_political_map').addClass("checked");
8646 $('#dio_political_map').addClass("active");
8647
8648 if ($('#dio_political_map').hasClass("active")) {
8649 if (PoliticalMap.data == null) {
8650 $('#ajax_loader').css({visibility: "visible"});
8651 // Map-Daten aus DB auslesen
8652 PoliticalMap.loadMapData();
8653 } else {
8654 //PoliticalMap.drawMap(PoliticalMap.data);
8655 }
8656 }
8657 });
8658 },
8659 /**
8660 * Läd die Allianzen und Inseln aus der Datenbank
8661 * @since 3.0
8662 */
8663 loadMapData: function () {
8664 $.ajax({
8665 type: "GET",
8666 url: "https://diotools.de/php/map.php?world_id=" + WID + "&callback=jsonCallback",
8667 //dataType: 'jsonp',
8668 //async: false,
8669 //jsonpCallback: 'jsonCallback',
8670 //contentType: "application/json",
8671 success: function (response) {
8672 if (response !== "") {
8673 PoliticalMap.data = response;
8674
8675 var m_ZoomFactor = $('.zoom_select').get(0)[$('.zoom_select').get(0).selectedIndex].selected;
8676
8677 PoliticalMap.drawMap(PoliticalMap.data, m_ZoomFactor);
8678 PoliticalMap.drawWonders(PoliticalMap.data, m_ZoomFactor);
8679
8680 $('#ajax_loader').css({visibility: "hidden"});
8681
8682 // Überprüfen, ob die Weltdaten geupdatet werden müssen
8683 $.ajax({
8684 type: "GET",
8685 url: "https://diotools.de/php/update_db.php?world_id=" + WID
8686 });
8687 } else {
8688 // Welt existiert noch nicht in DB
8689 $.ajax({
8690 type: "GET", url: "https://diotools.de/php/update_db.php?world_id=" + WID,
8691 success: function () {
8692 // Map-Daten aus DB auslesen, wenn die Weltdaten erfolgreich in die DB geladen wurden
8693 $.ajax({
8694 type: "GET",
8695 url: "https://diotools.de/php/map.php?world_id=" + WID,
8696 success: function (response) {
8697 PoliticalMap.data = response;
8698
8699 var m_ZoomFactor = $('.zoom_select').get(0)[$('.zoom_select').get(0).selectedIndex].selected;
8700
8701 PoliticalMap.drawMap(PoliticalMap.data, m_ZoomFactor);
8702 PoliticalMap.drawWonders(PoliticalMap.data, m_ZoomFactor);
8703
8704 $('#ajax_loader').css({visibility: "hidden"});
8705 }
8706 });
8707 }
8708 });
8709 }
8710 }
8711 });
8712 },
8713 /**
8714 * Ändert die Zoomstufe der Karte zum Zentrum hin
8715 *
8716 * @param _zoom
8717 * @since 3.0
8718 */
8719 zoomToCenter: function () {
8720 var _zoom = $('.zoom_select').get(0)[$('.zoom_select').get(0).selectedIndex].value;
8721
8722 var canvas = $('#dio_political_map canvas'),
8723
8724 canvas_size = parseInt($('#dio_political_map canvas').width(), 10); // Breite und Höhe sind immer gleich
8725
8726 var canvas_style = $('#dio_political_map .canvas_wrapper').get(0).style;
8727
8728 // Berechnung: Alter Abstand + (1000 * Zoomänderung / 2)
8729 canvas_style.top = parseInt(canvas_style.top, 10) + (1000 * (canvas_size / 1000 - _zoom)) / 2 + "px";
8730 canvas_style.left = parseInt(canvas_style.left, 10) + (1000 * (canvas_size / 1000 - _zoom)) / 2 + "px";
8731
8732 PoliticalMap.clearMap();
8733 PoliticalMap.drawMap(PoliticalMap.data, _zoom);
8734 PoliticalMap.drawWonders(PoliticalMap.data, _zoom);
8735
8736 },
8737 /**
8738 * Ändert die Zoomstufe der Karte zur Cursorposition hin
8739 *
8740 * @param _zoom
8741 * @param _pos
8742 *
8743 * @since 3.0
8744 */
8745 zoomToCursorPosition: function (_zoom, _pos) {
8746
8747 },
8748 /**
8749 * Zeichnet die Karte in ein Canvas
8750 *
8751 * @param _islandArray {Array}
8752 * @param _zoom {int}
8753 *
8754 * @since 3.0
8755 */
8756 drawMap: function (_islandArray, _zoom) {
8757
8758 $('<canvas class="canv_map" height="' + (1000 * _zoom) + 'px" width="' + (1000 * _zoom) + "px\"></canvas>").prependTo('.canvas_wrapper')
8759
8760 // TODO: Weite und Höhe vom Fenster ermitteln, Update Containment bei onResizeWindow
8761 $('#dio_political_map .canvas_wrapper').draggable({
8762 // left, top, right, bottom
8763 //containment: [-500 * _zoom, -300 * _zoom, 500 * _zoom, 300 * _zoom],
8764 distance: 10,
8765 grid: [100 * _zoom, 100 * _zoom],
8766 //limit: 500,
8767 cursor: 'pointer'
8768 });
8769
8770 var ally_ranking = JSON.parse(_islandArray)['ally_ranking'];
8771 var island_array = JSON.parse(_islandArray)['ally_island_array'];
8772
8773
8774 var c = $('#dio_political_map .canv_map')[0].getContext('2d');
8775
8776 // Grid
8777 c.strokeStyle = 'rgb(0,100,0)';
8778
8779 for (var l = 0; l <= 10; l++) {
8780 // Horizontal Line
8781 c.moveTo(0, l * 100 * _zoom);
8782 c.lineTo(1000 * _zoom, l * 100 * _zoom);
8783 c.stroke();
8784
8785 // Vertical Line
8786 c.moveTo(l * 100 * _zoom, 0);
8787 c.lineTo(l * 100 * _zoom, 1000 * _zoom);
8788 c.stroke();
8789 }
8790
8791 // Center Circle
8792 c.beginPath();
8793 c.arc(500 * _zoom, 500 * _zoom, 100 * _zoom, 0, Math.PI * 2, true);
8794 c.fillStyle = 'rgba(0,100,0,0.2)';
8795 c.fill();
8796 c.stroke();
8797
8798 // Sea numbers
8799 c.fillStyle = 'rgb(0,100,0)';
8800
8801 for (var y = 0; y <= 10; y++) {
8802 for (var x = 0; x <= 10; x++) {
8803 c.fillText(y + "" + x, y * 100 * _zoom + 2, x * 100 * _zoom + 10);
8804 }
8805 }
8806
8807 // Alliance Colors
8808 var colorArray = ["#00A000", "yellow", "red", "rgb(255, 116, 0)", "cyan", "#784D00", "white", "purple", "#0078FF", "deeppink", "darkslategrey"];
8809
8810 // Islands
8811 for (var t in island_array) {
8812 if (island_array.hasOwnProperty(t)) {
8813 var tmp_points = 0, dom_ally = "";
8814 for (var ally in island_array[t]) {
8815 if (island_array[t].hasOwnProperty(ally)) {
8816 if (tmp_points < island_array[t][ally] && (ally !== "X") && (ally !== "")) {
8817 tmp_points = island_array[t][ally];
8818 dom_ally = ally;
8819 }
8820 }
8821 }
8822
8823 c.fillStyle = colorArray[parseInt(ally_ranking[dom_ally], 10) - 1] || "darkslategrey";
8824 //c.fillRect(t.split("x")[0] * _zoom, t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
8825
8826 //c.beginPath();
8827 //console.info(island_array[t]);
8828 //c.arc(t.split("x")[0], t.split("x")[1], 2, 0, Math.PI * 2, true);
8829 //c.fillRect(t.split("x")[0] * _zoom,t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
8830 //c.fill();
8831
8832 // TEST HEATMAP
8833 //console.debug("Blaaa", c.fillStyle);
8834 if (c.fillStyle !== "#2f4f4f") {
8835 var color = c.fillStyle;
8836
8837 var radgrad = c.createRadialGradient(t.split("x")[0] * _zoom + 1, t.split("x")[1] * _zoom + 1, 0, t.split("x")[0] * _zoom + 1, t.split("x")[1] * _zoom + 1, 10);
8838 radgrad.addColorStop(0, PoliticalMap.convertHexToRgba(color, 0.2));
8839 radgrad.addColorStop(0.6, PoliticalMap.convertHexToRgba(color, 0.2));
8840 radgrad.addColorStop(1, PoliticalMap.convertHexToRgba(color, 0.0));
8841
8842 // draw shape
8843 c.fillStyle = radgrad;
8844
8845 c.fillRect(t.split("x")[0] * _zoom - 10, t.split("x")[1] * _zoom - 10, 22, 22);
8846
8847 c.fillStyle = PoliticalMap.convertHexToRgba(color, 0.7);
8848 c.fillRect(t.split("x")[0] * _zoom, t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
8849 }
8850 else {
8851 c.fillRect(t.split("x")[0] * _zoom, t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
8852 }
8853 }
8854 }
8855
8856
8857
8858 // Legende
8859 var legend = $('#dio_political_map .legend .content');
8860
8861 legend.get(0).innerHTML = "";
8862
8863 for (var ally in ally_ranking) {
8864 if (ally_ranking.hasOwnProperty(ally)) {
8865 //legend.append("<div class='item' style='color:"+ colorAllyArray[ally] +"'><div class='color_checker' style='background-color:"+ colorAllyArray[ally] +"'></div>...</div>");
8866
8867 if (ally_ranking[ally] > 10) {
8868 legend.append("<div class='item' style='color:" + colorArray[ally_ranking[ally] - 1] + "'><div class='color_checker' style='background-color:" + colorArray[ally_ranking[ally] - 1] + "'></div>...</div>");
8869
8870 break;
8871 } else {
8872 legend.append("<div class='item' style='color:" + colorArray[ally_ranking[ally] - 1] + "'><div class='color_checker' style='background-color:" + colorArray[ally_ranking[ally] - 1] + "'></div>" + ally + "</div>");
8873
8874 }
8875 }
8876 }
8877
8878 $('#dio_political_map .legend .color_checker').click(function (event) {
8879 // getting user coordinates
8880 var x = event.pageX - this.offsetLeft;
8881 var y = event.pageY - this.offsetTop;
8882
8883 console.debug("Color Checker", event.pageX, this.offsetLeft);
8884
8885 ColorPicker.open(x,y);
8886 });
8887
8888
8889 // TODO: Wenn eine Farbe ausgewählt wurde, soll [...]
8890 $(ColorPicker).on("onColorChanged", function(event, color){
8891 console.debug("Farbe setzen", event, color);
8892
8893 $.ajax({
8894 type: "POST",
8895 url: "https://" + Game.world_id + ".grepolis.com/game/alliance?town_id=" + Game.townId + "&action=assign_map_color&h=" + Game.csrfToken,
8896 data: {
8897 "json": "{\"alliance_id\":\"217\",\"color\":"+ color +",\"player_id\":\"8512878\",\"town_id\":\"71047\",\"nl_init\":true}"
8898 },
8899 success: function (response) {
8900 console.debug("Erfolgreich übertragen", response);
8901 }
8902 });
8903 });
8904
8905 },
8906 convertHexToRgba: function (hex, opacity) {
8907 console.debug("hex", hex);
8908 hex = hex.replace('#', '');
8909 r = parseInt(hex.substring(0, 2), 16);
8910 g = parseInt(hex.substring(2, 4), 16);
8911 b = parseInt(hex.substring(4, 6), 16);
8912
8913 result = 'rgba(' + r + ',' + g + ',' + b + ',' + opacity + ')';
8914 return result;
8915 },
8916 /**
8917 * Zeichnet die Weltwunder auf der Karte
8918 *
8919 * @param _islandArray {Array}
8920 * @param _zoom {int}
8921 *
8922 * @since 3.0
8923 */
8924 drawWonders: function (_islandArray, _zoom) {
8925
8926 $('<canvas class="canv_ww" height="' + (1000 * _zoom) + 'px" width="' + (1000 * _zoom) + 'px"></canvas>').appendTo('.canvas_wrapper')
8927
8928 var c = $('#dio_political_map .canv_ww')[0].getContext('2d');
8929
8930 c.strokeStyle = 'rgb(0,100,0)';
8931
8932 // World Wonders
8933 var wonders = {}, wonderImages = {};
8934 //console.debug(JSON.stringify(wonder.map));
8935
8936 for (var wonderType in wonder.map) {
8937 if (wonder.map.hasOwnProperty(wonderType)) {
8938 var tmp = 0;
8939 for (var wonderCoords in wonder.map[wonderType]) {
8940 if (parseInt(wonder.map[wonderType][wonderCoords], 10) > tmp) {
8941 wonders[wonderType] = wonderCoords;
8942 tmp = parseInt(wonder.map[wonderType][wonderCoords], 10)
8943 }
8944 }
8945 }
8946 }
8947
8948 // Legende
8949 var legend = $('#dio_political_map .legend .content');
8950
8951 legend.append("<div class=\"item no_results\"></div>");
8952
8953 for (var w in wonders) {
8954 if (wonders.hasOwnProperty(w)) {
8955 var _w = w;
8956
8957 wonderImages[_w] = new Image();
8958
8959 wonderImages[_w].onload = function () {
8960 c.drawImage(this, this.pos.split("_")[0] * _zoom - 9, this.pos.split("_")[1] * _zoom - 9);
8961 };
8962
8963 wonderImages[_w].pos = wonders[_w];
8964 wonderImages[_w].src = "https://diotools.de/images/icons/ww/" + _w + ".png";
8965
8966 var wonder_string = _w.split("_of")[0].split("_");
8967 wonder_string = wonder_string[wonder_string.length - 1];
8968 wonder_string = wonder_string.substring(0, 1).toUpperCase() + wonder_string.substring(1);
8969
8970 legend.append("<img class='wonder_icon' src='" + wonderImages[_w].src + "'><div class='item'>" + wonder_string + "</div>");
8971 }
8972 }
8973 },
8974 clearMap: function () {
8975 $('#dio_political_map .canv_map').remove();
8976 $('#dio_political_map .canv_ww').remove();
8977 },
8978 getAllianceColors: function () {
8979 $.ajax({
8980 type: "GET",
8981 url: "https://" + Game.world_id + ".grepolis.com/game/map_data?town_id=" + Game.townId + "&action=get_custom_colors&h=" + Game.csrfToken,
8982 dataType: 'json',
8983 success: function (response) {
8984 // Allianzbox herausfiltern
8985 var html_string = $('#alliance_box', $(response.json.list_html));
8986
8987 var flagArray = $('.flag', html_string);
8988 var linkArray = $('a', html_string);
8989
8990 var allianceColorArray = [];
8991
8992 for (var i = 0; i < flagArray.length; i++) {
8993 allianceColorArray[i] = {
8994 "id": parseInt(linkArray[i].attributes.onclick.value.split(",")[1].split(")")[0], 10),
8995 "color": flagArray[i].style.backgroundColor
8996 };
8997 }
8998
8999 // console.debug("ANTWORT", allianceColorArray);
9000 }
9001 });
9002 }
9003 };
9004
9005 var ColorPicker = {
9006 open: function(pos_left, pos_top){
9007 $('#dio_color_picker').removeClass("hidden");
9008 $('#dio_color_picker').css({
9009 left: pos_left,
9010 top: pos_top
9011 });
9012 },
9013 close: function(){
9014 $('#dio_color_picker').addClass("hidden");
9015 },
9016 init: function () {
9017 // Style
9018 $('<style id="dio_color_picker_style">' +
9019 '#dio_color_picker { left:200px;top:300px;position:absolute;z-index:1000;} ' +
9020 '#dio_color_picker.hidden { display:none;} ' +
9021 '#dio_color_picker span.grepo_input, ' +
9022 '#dio_color_picker a.color_table, ' +
9023 '#dio_color_picker a.confirm, ' +
9024 '#dio_color_picker a.cancel' +
9025 ' { float:left; } ' +
9026 '</style>').appendTo('head');
9027
9028 $(
9029 '<canvas width="600" height="440" style="left:200px !important;top:100px !important;" id="canvas_picker" onclick="console.debug(this.getContext(\'2d\').getImageData(10, 10, 1, 1).data)"></canvas>' +
9030 '<div id="hex">HEX: <input type="text"></input></div>' +
9031 '<div id="rgb">RGB: <input type="text"></input></div>'
9032 ).prependTo('#dio_political_map')
9033
9034 $(
9035 '<div id="dio_color_picker" class="hidden"><table class="bb_popup" cellpadding="0" cellspacing="0"><tbody>' +
9036 '<tr class="bb_popup_top">' +
9037 '<td class="bb_popup_top_left"></td>' +
9038 '<td class="bb_popup_top_middle"></td>' +
9039 '<td class="bb_popup_top_right"></td>' +
9040 '</tr>' +
9041 '<tr>' +
9042 '<td class="bb_popup_middle_left"></td>' +
9043 '<td class="bb_popup_middle_middle">' +
9044 '<div class="bb_color_picker_colors">' +
9045 '<div style="background-color: rgb(255, 0, 0);"></div>' +
9046 '<div style="background-color: rgb(0, 255, 0);"></div>' +
9047 '<div style="background-color: rgb(0, 0, 255);"></div>' +
9048 '</div>' +
9049 '<a href="#" class="cancel"></a>' +
9050 '<span class="grepo_input">' +
9051 '<span class="left">' +
9052 '<span class="right">' +
9053 '<input class="color_string" style="width:50px;" maxlength="6" type="text">' +
9054 '</span>' +
9055 '</span>' +
9056 '</span>' +
9057 '<a href="#" class="color_table"><input type="color" id="c" tabindex=-1 class="hidden"></a>' +
9058 '<a href="#" class="confirm"></a>' +
9059 '</td>' +
9060 '<td class="bb_popup_middle_right"></td>' +
9061 '</tr>' +
9062 '<tr class="bb_popup_bottom">' +
9063 '<td class="bb_popup_bottom_left"></td>' +
9064 '<td class="bb_popup_bottom_middle"></td>' +
9065 '<td class="bb_popup_bottom_right"></td>' +
9066 '</tr>' +
9067 '</tbody></table></div>'
9068 ).prependTo('#dio_political_map');
9069
9070 var canvas = document.getElementById('canvas_picker').getContext('2d');
9071
9072 var count = 5, line = 0, width = 16, height = 12, sep = 1;
9073
9074 var offset = (count - 2) * width;
9075
9076 for (var i = 2, j = 0; i < count; i++, j++) {
9077
9078 line = 0;
9079
9080 // Pinktöne (255,0,255)
9081 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", 0, " + ((i / count * 255) | 0) + ")";
9082 canvas.fillRect(i * width, line, width - sep, height - sep);
9083
9084 canvas.fillStyle = "rgb(255," + ((j / (count - 1) * 255) | 0) + ", 255)";
9085 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9086
9087 line = line + height;
9088
9089 // Rosatöne (255,0,127)
9090 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", 0, " + ((i / count * 127) | 0) + ")";
9091 canvas.fillRect(i * width, line, width - sep, height - sep);
9092
9093 canvas.fillStyle = "rgb(255," + ((j / (count - 1) * 255) | 0) + "," + (127 + ((j / (count - 1) * 127) | 0)) + ")";
9094 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9095
9096 line = line + height;
9097
9098 // Rottöne (255,0,0)
9099 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", 0, 0)";
9100 canvas.fillRect(i * width, line, width - sep, height - sep);
9101
9102 canvas.fillStyle = "rgb(255," + ((j / (count - 1) * 255) | 0) + "," + ((j / (count - 1) * 255) | 0) + ")";
9103 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9104
9105 line = line + height;
9106
9107 // Orangetöne (255, 127, 0)
9108 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", " + ((i / count * 127) | 0) + ", 0)";
9109 canvas.fillRect(i * width, line, width - sep, height - sep);
9110
9111 canvas.fillStyle = "rgb(255, " + (127 + ((j / (count - 1) * 127) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ")";
9112 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9113
9114 line = line + height;
9115
9116 // Dunkelbrauntöne (170, 85, 0)
9117 canvas.fillStyle = "rgb(" + ((i / count * 170) | 0) + ", " + ((i / count * 85) | 0) + ", 0)";
9118 canvas.fillRect(i * width, line, width - sep, height - sep);
9119
9120 canvas.fillStyle = "rgb(" + (170 + (j / (count - 1) * 85) | 0) + ", " + (85 + ((j / (count - 1) * 170) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ")";
9121 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9122
9123 line = line + height;
9124
9125 // Brauntöne (191, 127, 0)
9126 canvas.fillStyle = "rgb(" + ((i / count * 191) | 0) + ", " + ((i / count * 127) | 0) + ", 0)";
9127 canvas.fillRect(i * width, line, width - sep, height - sep);
9128
9129 canvas.fillStyle = "rgb(" + (191 + (j / (count - 1) * 64) | 0) + ", " + (127 + ((j / (count - 1) * 127) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ")";
9130 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9131
9132 line = line + height;
9133
9134 // Gelbtöne (255,255,0)
9135 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ", 0)";
9136 canvas.fillRect(i * width, line, width - sep, height - sep);
9137
9138 canvas.fillStyle = "rgb(255, 255," + ((j / (count - 1) * 255) | 0) + ")";
9139 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9140
9141 line = line + height;
9142
9143 // Gelbgrüntöne (127,255,0)
9144 canvas.fillStyle = "rgb(" + ((i / count * 127) | 0) + "," + ((i / count * 191) | 0) + ", 0)";
9145 canvas.fillRect(i * width, line, width - sep, height - sep);
9146
9147 canvas.fillStyle = "rgb(" + (127 + (j / (count - 1) * 127) | 0) + "," + (191 + (j / (count - 1) * 64) | 0) + "," + ((j / (count - 1) * 255) | 0) + ")";
9148 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9149
9150 line = line + height;
9151
9152 // Dunkelgrasgrüntöne (85, 170, 0)
9153 /*
9154 canvas.fillStyle = "rgb("+ ((i/count*85)|0) +", "+ ((i/count*170)|0) +", 0)";
9155 canvas.fillRect(i * width, line, width-sep, height-sep);
9156
9157 canvas.fillStyle = "rgb("+ (85 + (j/(count-1)*170)|0) +", "+ (170 + ((j/(count-1)*85)|0)) +","+ ((j/(count-1)*255)|0) +")";
9158 canvas.fillRect(i * width + offset, line, width-sep, height-sep);
9159
9160 line = line + height;
9161 */
9162
9163 // Grüntöne (0,255,0)
9164 canvas.fillStyle = "rgb(0," + ((i / count * 255) | 0) + ", 0)";
9165 canvas.fillRect(i * width, line, width - sep, height - sep);
9166
9167 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + ", 255," + ((j / (count - 1) * 255) | 0) + ")";
9168 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9169
9170 line = line + height;
9171
9172 // Türkistöne (0,255,127)
9173 /*
9174 canvas.fillStyle = "rgb(0,"+ ((i/count*255)|0) +","+ ((i/count*127)|0) + ")";
9175 canvas.fillRect(i * width, line, width-sep, height-sep);
9176
9177 canvas.fillStyle = "rgb("+ ((j/(count-1)*255)|0) +", 255,"+ (127 + ((j/(count-1)*127)|0)) +")";
9178 canvas.fillRect(i * width + offset, line, width-sep, height-sep);
9179
9180 line = line + height;
9181 */
9182
9183 // Dunkel-Türkistöne (0,191,127)
9184 canvas.fillStyle = "rgb(0, " + ((i / count * 191) | 0) + "," + ((i / count * 127) | 0) + ")";
9185 canvas.fillRect(i * width, line, width - sep, height - sep);
9186
9187 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + "," + (191 + (j / (count - 1) * 64) | 0) + ", " + (127 + ((j / (count - 1) * 127) | 0)) + ")";
9188 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9189
9190 line = line + height;
9191
9192
9193 // Cyantöne (0,255,255)
9194 canvas.fillStyle = "rgb(0, " + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ")";
9195 canvas.fillRect(i * width, line, width - sep, height - sep);
9196
9197 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + ",255, 255)";
9198 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9199
9200 line = line + height;
9201
9202 // Hellblautöne (0,127,255)
9203 canvas.fillStyle = "rgb(0, " + ((i / count * 127) | 0) + "," + ((i / count * 255) | 0) + ")";
9204 canvas.fillRect(i * width, line, width - sep, height - sep);
9205
9206 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + "," + (127 + ((j / (count - 1) * 127) | 0)) + ", 255)";
9207 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9208
9209 line = line + height;
9210
9211 // Blautöne (0,0,255)
9212 canvas.fillStyle = "rgb(0, 0, " + ((i / count * 255) | 0) + ")";
9213 canvas.fillRect(i * width, line, width - sep, height - sep);
9214
9215 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + "," + ((j / (count - 1) * 255) | 0) + ", 255)";
9216 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9217
9218 line = line + height;
9219
9220 // Lilatöne (127,0,255)
9221 canvas.fillStyle = "rgb(" + ((i / count * 127) | 0) + ", 0, " + ((i / count * 255) | 0) + ")";
9222 canvas.fillRect(i * width, line, width - sep, height - sep);
9223
9224 canvas.fillStyle = "rgb(" + (127 + ((j / (count - 1) * 127) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ", 255)";
9225 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9226
9227 line = line + height;
9228
9229 // Grautöne
9230 /*
9231 canvas.fillStyle = "rgb("+ ((i/count*127)|0) +", "+ ((i/count*127)|0) +", "+ ((i/count*127)|0) +")";
9232 canvas.fillRect(i * width, line, width-sep, height-sep);
9233
9234 canvas.fillStyle = "rgb("+ (127 + ((j/(count-1)*127)|0)) +","+ (127 + ((j/(count-1)*127)|0)) +","+ (127 + ((j/(count-1)*127)|0)) +")";
9235 canvas.fillRect(i * width + offset, line, width-sep, height-sep);
9236
9237 line = line + height;
9238 */
9239
9240 }
9241
9242 line = line + height;
9243
9244 for (var i = 0; i <= count; i++) {
9245 // Grautöne
9246 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ")";
9247 canvas.fillRect(i * width + width * 2, line, width - sep, height - sep);
9248 }
9249
9250
9251 // http://www.javascripter.net/faq/rgbtohex.htm
9252 function rgbToHex(R, G, B) {
9253 return toHex(R) + toHex(G) + toHex(B)
9254 }
9255
9256 function toHex(n) {
9257 n = parseInt(n, 10);
9258 if (isNaN(n)) return "00";
9259 n = Math.max(0, Math.min(n, 255));
9260 return "0123456789ABCDEF".charAt((n - n % 16) / 16) + "0123456789ABCDEF".charAt(n % 16);
9261 }
9262
9263 $('#dio_color_picker a.cancel').click(function () {
9264 ColorPicker.close();
9265 });
9266
9267
9268 $('#dio_color_picker a.confirm').click(function () {
9269 // Custom-Event auslösen
9270 $(ColorPicker).trigger("onColorChanged", [$('#dio_color_picker .color_string')[0].value]);
9271 ColorPicker.close();
9272 });
9273
9274 $('#dio_color_picker a.color_table').click(function () {
9275 document.getElementById("c").click();
9276 });
9277
9278 $('#dio_color_picker a.color_table #c').change(function () {
9279 $('#dio_color_picker input.color_string')[0].value = this.value;
9280 $('#dio_color_picker input.color_string')[0].style.color = this.value;
9281 });
9282 }
9283 };
9284
9285 var UnitImages = {
9286 activate : function(){
9287 $('<style id="dio_unit_images">' +
9288
9289 '.unit_icon25x25 { background-image: url(https://diotools.de/images/game/units/unit_icons_25x25_2.91.png);} ' +
9290 '.unit_icon40x40 { background-image: url(https://diotools.de/images/game/units/unit_icons_40x40_2.91.png);} ' +
9291 '.unit_icon50x50 { background-image: url(https://diotools.de/images/game/units/unit_icons_50x50_2.91.png);} ' +
9292 '.unit_icon90x90 { background-image: url(https://diotools.de/images/game/units/unit_icons_90x90_2.91.png);} ' +
9293
9294 '.unit_icon228x165 { background-image: none; height:0px;} ' +
9295 '.unit_card .deco_statue { background-image: none !important;} ' +
9296 '.grepo_box_silver .border_l, .grepo_box_silver .border_r { background-image: none;} ' +
9297 '.box_corner .box_corner_tl, .grepo_box_silver .box_corner_tr { height:31px; } ' +
9298 '.grepo_box_silver .grepo_box_content { padding: 21px 10px 0px; } ' +
9299
9300 '</style>').appendTo('head');
9301 },
9302 deactivate : function(){
9303 $('#dio_unit_images').remove();
9304
9305 }
9306 };
9307
9308 /*******************************************************************************************************************************
9309 * Holiday Special
9310 *******************************************************************************************************************************/
9311
9312 var HolidaySpecial = {
9313 isHalloween : false, isXmas : false, isNewYear : false, isEaster : false,
9314
9315 activate : function(){
9316 var daystamp = 1000*60*60*24, today = new Date((new Date())%(daystamp*(365+1/4))), // without year
9317
9318 // Halloween -> 15 days
9319 halloween_start = daystamp * 297, // 25. Oktober
9320 halloween_end = daystamp * 321, // 8. November
9321 // Xmas -> 28 days
9322 xmas_start = daystamp * 334, // 1. Dezember
9323 xmas_end = daystamp * 361, // 28. Dezember
9324 // NewYear -> 7 days
9325 newYear_start = daystamp * 0, // 1. Januar
9326 newYear_end = daystamp * 7; // 7. Januar
9327
9328 HolidaySpecial.isHalloween = (today >= halloween_start) ? (today <= halloween_end) : false;
9329
9330 HolidaySpecial.isXmas = (today >= xmas_start) ? (today <= xmas_end) : false;
9331
9332 HolidaySpecial.isNewYear = (today >= newYear_start) ? (today <= newYear_end) : false;
9333
9334 if(HolidaySpecial.isXmas){ HolidaySpecial.XMas.add(); }
9335 if(HolidaySpecial.isNewYear){ HolidaySpecial.NewYear.add(); }
9336
9337 // Calculation Easter
9338
9339 // Jahreszahl
9340 var X = 2016;
9341
9342 // Säkularzahl
9343 var K = parseInt(X / 100, 10);
9344 // Mondparameter
9345 var A = X % 19;
9346
9347 // säkulare Mondschaltung
9348 var M = 15 + parseInt((3 * K + 3)/4, 10) - parseInt((8 * K + 13)/25, 10);
9349
9350 // säkulare Sonnenschaltung
9351 var S = 2 - parseInt((3 * K + 3)/4, 10);
9352
9353 // Erster Vollmond im Frühling
9354 var D = (19 * A + M) % 30;
9355
9356 // Kalendarische Korrekturgröße
9357 var R = parseInt((D + parseInt(A / 11, 10)) / 29, 10);
9358
9359 // Ostergrenze
9360 var OG = 21 + D - R;
9361
9362 // Erster Sonntag im März
9363 var SZ = 7 - ((2016 + parseInt(2016/4, 10) + S) % 7);
9364
9365 // Entfernung des Ostersonntags von der Ostergrenze
9366 var OE = 7 - ((OG - SZ) % 7);
9367
9368 // Ostersonntag als Märzdatum
9369 var OS = OG + OE;
9370
9371 // console.debug("DIO-TOOLS | Ostersonntag: " + OS);
9372
9373 },
9374 XMas : {
9375 add : function(){
9376 $('<a href="http://www.greensmilies.com/smilie-album/weihnachten-smilies/" target="_blank"><div id="dio_xmas"></div></a>').appendTo('#ui_box');
9377
9378 var dioXMAS = $('#dio_xmas');
9379
9380 dioXMAS.css({
9381 background: 'url("http://www.greensmilies.com/smile/smiley_emoticons_weihnachtsmann_nordpol.gif") no-repeat',
9382 height: '51px',
9383 width: '61px',
9384 position:'absolute',
9385 bottom:'10px',
9386 left:'60px',
9387 zIndex:'2000'
9388 });
9389 dioXMAS.tooltip("Ho Ho Ho, Merry Christmas!");
9390 }
9391 },
9392 NewYear : {
9393 add : function(){
9394 // TODO: Jahreszahl dynamisch setzen
9395 $('<a href="http://www.greensmilies.com/smilie-album/" target="_blank"><div id="dio_newYear">'+
9396 '<img src="http://www.greensmilies.com/smile/sign2_2.gif">'+
9397 '<img src="http://www.greensmilies.com/smile/sign2_0.gif">'+
9398 '<img src="http://www.greensmilies.com/smile/sign2_1.gif">'+
9399 '<img src="http://www.greensmilies.com/smile/sign2_7.gif">'+
9400 '</div></a>').appendTo('#ui_box');
9401
9402 var dioNewYear = $('#dio_newYear');
9403
9404 dioNewYear.css({
9405 position:'absolute',
9406 bottom:'10px',
9407 left:'70px',
9408 zIndex:'10'
9409 });
9410 dioNewYear.tooltip("Happy new year!");
9411 }
9412 }
9413 };
9414
9415}