· 6 years ago · Dec 09, 2019, 10:00 PM
1// ==UserScript==
2// @name DIO-TOOLS
3// @namespace DIO
4// @version 3.19
5// @author Diony
6// @updateURL https://diotools.de/downloads/DIO-TOOLS.user.js
7// @downloadURL https://diotools.de/downloads/DIO-TOOLS.user.js
8// @description DIO-Tools is a small extension for the browser game Grepolis. (counter, displays, smilies, trade options, changes to the layout)
9// @include http://de.grepolis.com/game*
10// @include /http[s]{0,1}://[a-z]{2}[0-9]{1,2}\.grepolis\.com/game*/
11// @include https://*.forum.grepolis.com/*
12// @include http://diotools.de/*
13// @require http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
14// @icon http://s7.directupload.net/images/140128/vqchpigi.gif
15// @icon64 http://diotools.de/images/icon_dio_64x64.png
16// @copyright 2013+, DIONY
17// @grant GM_info
18// @grant GM_setValue
19// @grant GM_getValue
20// @grant GM_deleteValue
21// @grant GM_xmlhttpRequest
22// @grant GM_getResourceURL
23// ==/UserScript==
24
25var version = '3.19';
26
27//if(unsafeWindow.DM) console.dir(unsafeWindow.DM.status('l10n'));
28//console.dir(DM.status('templates'));
29
30//http://s7.directupload.net/images/140128/vqchpigi.gif - DIO-Tools-Smiley
31
32//http://de44.grepolis.com/cache/js/libs/jquery-1.10.2.min.js
33
34
35//console.log(JSON.stringify(DM.getl10n()));
36
37
38//// console.log(GM_getResourceText("dio_sprite"));
39
40/*******************************************************************************************************************************
41 * Changes
42 * ----------------------------------------------------------------------------------------------------------------------------
43 * | ● Einstellungen und auch das ganze Script komplett überarbeitet
44 * | ● Features können nun ohne Refresh deaktiviert/aktiviert werden
45 * | ● Einzelne Features sind unabhängiger voneinander und somit auch fehlerresistenter (einzelne Features können sich bei Fehlerauftreten durch Grepolis-Updates nicht mehr gegenseitig blockieren)
46 * | ● Fehlerhafter Biremenzähler als Kompromiss für die Erweiterung der "Verfügbare Einheiten"-Anzeige entfernt: es kann nun jede Einheit im Bullauge angezeigt werden
47 * | ● EO-Zähler hat ATT/UT's doppelt gezählt, wenn nebenher der veröffentlichte Belagerungsbericht im Forum offen war
48 * | ● 3 kleine Layoutfehler beim EO-Zähler behoben
49 * | ● Wenn Zauberfenster und Zauberbox gleichzeitig offen waren, kam es zu einem Layoutfehler
50 * | ● Fehler beim Mausrad-Zoom behoben
51 * | ● Fehler bei der Transporteranzeige behoben: die Kapazität der großen Transporter wurde durch das Rebalancing nichtmehr korrekt berechnet
52 * | ● Smileybox etwas verbessert
53 * | ● Weihnachtssmileys hinzugefügt
54 * | ● Kontextmenü der Stadticons auf der strategischen Karte konnte im Nachtmodus nicht geöffnet werden
55 * | ● Grüner Fortschrittsbalken beim Weltwunderzähler wurde nicht angezeigt
56 * | ● Fenster wurden angepasst (Verfügbare Einheiten und Einheitenvergleich)
57 * ----------------------------------------------------------------------------------------------------------------------------
58 *******************************************************************************************************************************/
59
60/*******************************************************************************************************************************
61 * Bugs / TODOs
62 * ----------------------------------------------------------------------------------------------------------------------------
63 * | ● Aktivitätsbox für Angriffe blendet nicht aus
64 * | ● Smileys verschwinden manchmal? -> bisher nicht reproduzierbar
65 * | ● Performanceeinbruch nach dem Switchen des WW-Fensters
66 * | ● keine Smileys im Grepoforum mit Safari (fehlendes jQuery)
67 * ----------------------------------------------------------------------------------------------------------------------------
68 *******************************************************************************************************************************/
69
70/*******************************************************************************************************************************
71 * Global stuff
72 *******************************************************************************************************************************/
73var uw = unsafeWindow || window, $ = uw.jQuery || jQuery, DATA, GM;
74
75// GM-API?
76GM = (typeof GM_info === 'object');
77
78console.log('%c|= DIO-Tools is active =|', 'color: green; font-size: 1em; font-weight: bolder; ');
79
80function loadValue(name, default_val){
81 var value;
82 if(GM){
83 value = GM_getValue(name, default_val);
84 } else {
85 value = localStorage.getItem(name) || default_val;
86 }
87
88 if(typeof(value) === "string"){
89 value = JSON.parse(value)
90 }
91 return value;
92}
93
94// LOAD DATA
95if(GM && (uw.location.pathname.indexOf("game") >= 0)){
96 var WID = uw.Game.world_id, MID = uw.Game.market_id, AID = uw.Game.alliance_id;
97
98 //GM_deleteValue(WID + "_bullseyeUnit");
99
100 DATA = {
101 // GLOBAL
102 options : loadValue("options", "{}"),
103
104 user : loadValue("dio_user", "{}"),
105 count: loadValue("dio_count", "[]"),
106
107 notification : loadValue('notif', '0'),
108
109 error: loadValue('error', '{}'),
110
111 spellbox : loadValue("spellbox", '{ "top":"23%", "left": "-150%", "show": false }'),
112 commandbox: loadValue("commandbox" , '{ "top":55, "left": 250 }'),
113 tradebox : loadValue("tradebox", '{ "top":55, "left": 450 }'),
114
115 // WORLD
116 townTypes : loadValue(WID + "_townTypes", "{}"),
117 sentUnits : loadValue(WID + "_sentUnits", '{ "attack": {}, "support": {} }'),
118
119 biremes : loadValue(WID + "_biremes", "{}"), //old
120 bullseyeUnit : loadValue(WID + "_bullseyeUnit", '{ "current_group" : -1 }'), // new
121
122 worldWonder : loadValue(WID + "_wonder", '{ "ratio": {}, "storage": {}, "map": {} }'),
123
124 clickCount : loadValue(WID + "_click_count", '{}'), // old
125 statistic : loadValue(WID + "_statistic", '{}'), // new
126
127 // MARKET
128 worldWonderTypes : loadValue(MID + "_wonderTypes", '{}')
129 };
130
131 if(!DATA.worldWonder.map) {
132 DATA.worldWonder.map = {};
133 }
134
135 // Temporary:
136 if(typeof DATA.options.trd == 'boolean') {
137 DATA.options.per = DATA.options.rec = DATA.options.trd; delete DATA.options.trd;
138 }
139 if(typeof DATA.options.mov == 'boolean') {
140 DATA.options.act = DATA.options.mov; delete DATA.options.mov;
141 }
142 if(typeof DATA.options.twn == 'boolean') {
143 DATA.options.tic = DATA.options.til = DATA.options.tim = DATA.options.twn; delete DATA.options.twn;
144 }
145 if(GM) GM_deleteValue("notification");
146}
147
148// GM: EXPORT FUNCTIONS
149uw.saveValueGM = function(name, val){
150 setTimeout(function(){
151 GM_setValue(name, val);
152 }, 0);
153};
154
155uw.deleteValueGM = function(name){
156 setTimeout(function(){
157 GM_deleteValue(name);
158 },0);
159};
160
161uw.getImageDataFromCanvas = function(x, y){
162
163 // console.debug("HEY", document.getElementById('canvas_picker').getContext('2d').getImageData(x, y, 1, 1));
164};
165uw.calculateConcaveHull = function() {
166 var contour = [
167 new poly2tri.Point(100, 100),
168 new poly2tri.Point(100, 300),
169 new poly2tri.Point(300, 300),
170 new poly2tri.Point(300, 100)
171 ];
172
173 var swctx = new poly2tri.SweepContext(contour);
174
175 swctx.triangulate();
176 var triangles = swctx.getTriangles();
177
178 // console.debug(triangles);
179
180 return triangles;
181};
182
183if(typeof exportFunction == 'function'){
184 // Firefox > 30
185 //uw.DATA = cloneInto(DATA, unsafeWindow);
186 exportFunction(uw.saveValueGM, unsafeWindow, {defineAs: "saveValueGM"});
187 exportFunction(uw.deleteValueGM, unsafeWindow, {defineAs: "deleteValueGM"});
188 exportFunction(uw.calculateConcaveHull, unsafeWindow, {defineAs: "calculateConcaveHull"});
189 exportFunction(uw.getImageDataFromCanvas, unsafeWindow, {defineAs: "getImageDataFromCanvas"});
190} else {
191 // Firefox < 30, Chrome, Opera, ...
192 //uw.DATA = DATA;
193}
194
195var time_a, time_b;
196
197// APPEND SCRIPT
198function appendScript(){
199 //console.log("GM-API: " + gm_bool);
200 if(document.getElementsByTagName('body')[0]){
201 var dioscript = document.createElement('script');
202 dioscript.type ='text/javascript';
203 dioscript.id = 'diotools';
204
205 time_a = uw.Timestamp.client();
206 dioscript.textContent = DIO_GAME.toString().replace(/uw\./g, "") + "\n DIO_GAME('"+ version +"', "+ GM +", '" + JSON.stringify(DATA).replace(/'/g, "##") + "', "+ time_a +");";
207 document.body.appendChild(dioscript);
208 } else {
209 setTimeout(function(){
210 appendScript();
211 }, 500);
212 }
213}
214
215if(location.host === "diotools.de"){
216 // PAGE
217 DIO_PAGE();
218}
219else if((uw.location.pathname.indexOf("game") >= 0) && GM){
220 // GAME
221 appendScript();
222}
223else {
224 DIO_FORUM();
225}
226
227function DIO_PAGE(){
228 if(typeof GM_info == 'object') {
229 setTimeout(function() {
230 dio_user = JSON.parse(loadValue("dio_user", ""));
231 console.log(dio_user);
232 uw.dio_version = parseFloat(version);
233 }, 0);
234 } else {
235 dio_user = localStorage.getItem("dio_user") || "";
236
237 dio_version = parseFloat(version);
238 }
239}
240function DIO_FORUM(){
241 var smileyArray = [];
242
243 var _isSmileyButtonClicked = false;
244
245 smileyArray.standard = [
246 "smilenew", "grin", "lol", "neutral_new", "afraid", "freddus_pacman", "auslachen2", "kolobok-sanduhr", "bussi2", "winken4", "flucht2", "panik4", "ins-auge-stechen",
247 "seb_zunge", "fluch4_GREEN", "baby_junge2", "blush-reloaded6", "frown", "verlegen", "blush-pfeif", "stevieh_rolleyes", "daumendreh2", "baby_taptap",
248 "sadnew", "hust", "confusednew", "idea2", "irre", "irre4", "sleep", "candle", "nicken", "no_sad",
249 "thumbs-up_new", "thumbs-down_new", "bravo2", "oh-no2", "kaffee2", "drunk", "saufen", "freu-dance", "hecheln", "headstand", "rollsmiliey", "eazy_cool01", "motz", "cuinlove", "biggrin"
250 ];
251 smileyArray.grepolis = [
252 "mttao_wassermann", "hera", /* Hera */ "medusa", /* Medusa */ "manticore", /* Mantikor */ "cyclops", /* Zyklop */
253 "minotaur", /* Minotaurus */ "pegasus", /* Pegasus */ "hydra", /* Hydra */
254 "silvester_cuinlove", "mttao_schuetze", "kleeblatt2", "wallbash", /* "glaskugel4", */ /* "musketiere_fechtend",*/ /* "krone-hoch",*/ "viking", // Wikinger
255 /* "mttao_waage2", */ "steckenpferd", /* "kinggrin_anbeten2", */ "grepolove", /* Grepo Love */ "skullhaufen", "grepo_pacman" /*, "pferdehaufen" */ // "i/ckajscggscw4s2u60"
256 ];
257
258 var ForumObserver = new MutationObserver(function (mutations) {
259 mutations.forEach(function (mutation) {
260
261 if (mutation.addedNodes[0]) {
262
263 //console.debug("Added Nodes", mutation.addedNodes[0]);
264
265 // Message Box geladen
266 if(mutation.addedNodes[0].className === "redactor_box"){
267
268 //console.debug("Message Box geladen");
269
270 ForumObserver.observe($(".redactor_box").get(0), {
271 attributes: false,
272 childList: true,
273 characterData: false,
274 subtree:true
275 });
276 }
277
278 // Toolbar der Message Box geladen
279 if(_isSmileyButtonClicked === false && mutation.addedNodes[0].className === "redactor_toolbar") {
280 $(".redactor_btn_smilies").click();
281
282 // Soll sich nicht wieder deaktivieren
283 _isSmileyButtonClicked = true;
284 }
285
286 // Smileybar der Toolbar geladen
287 if(mutation.addedNodes[0].className === "redactor_smilies") {
288
289 // Observer soll nicht mehr feuern, wenn die Smileys hinzugefügt werden
290 ForumObserver.disconnect();
291
292 // Hässliche Smileys entfernen
293 $(".smilieCategory ul").empty();
294
295 // Greensmileys hinzufügen
296 for(var smiley in smileyArray.standard){
297 if(smileyArray.standard.hasOwnProperty(smiley)){
298 $(".smilieCategory ul").append(
299 '<li class="Smilie" data-text="">'+
300 '<img src="https://diotools.de/images/smileys/standard/smiley_emoticons_'+ smileyArray.standard[smiley] +'.gif" title="" alt="" data-smilie="yes">'+
301 '</li>'
302 );
303 }
304 }
305
306 $(".smilieCategory ul").append("<br><br>");
307
308 for(var smiley in smileyArray.grepolis){
309 if(smileyArray.grepolis.hasOwnProperty(smiley)){
310 $(".smilieCategory ul").append(
311 '<li class="Smilie" data-text="">'+
312 '<img src="https://diotools.de/images/smileys/grepolis/smiley_emoticons_'+ smileyArray.grepolis[smiley] +'.gif" title="" alt="" data-smilie="yes">'+
313 '</li>'
314 );
315 }
316 }
317
318 _isSmileyBarOpened = true;
319 }
320 }
321 });
322 });
323
324 // Smiley-Button aktivieren, um die Smiley-Toolbar zu öffnen
325 if($(".redactor_btn_smilies").get(0)){
326 $(".redactor_btn_smilies").click();
327
328 _isSmileyButtonClicked = true;
329 }
330
331 // Observer triggern
332 if($("#QuickReply").get(0)) {
333 ForumObserver.observe($("#QuickReply div").get(0), {
334 attributes: false,
335 childList: true,
336 characterData: false,
337 subtree:true
338 });
339 }
340 else if($("#ThreadReply").get(0)) {
341 ForumObserver.observe($("#ThreadReply div").get(0), {
342 attributes: false,
343 childList: true,
344 characterData: false,
345 subtree:true
346 });
347 }
348 /*
349 else if($("#ThreadCreate").get(0)) {
350 ForumObserver.observe($("#ThreadCreate fieldset .ctrlUnit dd div").get(0), {
351 attributes: false,
352 childList: true,
353 characterData: false
354 });
355 }
356 */
357
358 // Threaderstellung, Signatur bearbeiten, Beitrag bearbeiten
359 else if($("form.Preview").get(0)) {
360
361 ForumObserver.observe($("form.Preview .ctrlUnit dd div").get(0), {
362 attributes: false,
363 childList: true,
364 characterData: false
365 });
366 }
367 else if(typeof($("form.AutoValidator").get(0)) !== "undefined") {
368
369 ForumObserver.observe($("form.AutoValidator .messageContainer div").get(0), {
370 attributes: false,
371 childList: true,
372 characterData: false
373 });
374 }
375
376 // TODO: Bearbeiten, Nachrichten
377}
378
379
380
381function DIO_GAME(version, gm, DATA, time_a) {
382 var MutationObserver = uw.MutationObserver || window.MutationObserver,
383
384 WID, MID, AID, PID, LID,
385
386 dio_sprite = "http://666kb.com/i/d9xuhtcctx5fdi8i6.png"; // http://abload.de/img/dio_spritejmqxp.png, http://img1.myimg.de/DIOSPRITEe9708.png -> Forbidden!?
387
388 if (uw.location.pathname.indexOf("game") >= 0) {
389 DATA = JSON.parse(DATA.replace(/##/g, "'"));
390
391 WID = uw.Game.world_id;
392 MID = uw.Game.market_id;
393 AID = uw.Game.alliance_id;
394 PID = uw.Game.player_id;
395 LID = uw.Game.locale_lang.split("_")[0]; // LID ="es";
396
397 // World with Artemis ??
398 Game.hasArtemis = true; //Game.constants.gods.length == 6;
399 }
400
401 $.prototype.reverseList = [].reverse;
402
403 // Implement old jQuery method (version < 1.9)
404 $.fn.toggleClick = function () {
405 var methods = arguments; // Store the passed arguments for future reference
406 var count = methods.length; // Cache the number of methods
407
408 // Use return this to maintain jQuery chainability
409 // For each element you bind to
410 return this.each(function (i, item) {
411 // Create a local counter for that element
412 var index = 0;
413
414 // Bind a click handler to that element
415 $(item).on('click', function () {
416 // That when called will apply the 'index'th method to that element
417 // the index % count means that we constrain our iterator between 0
418 // and (count-1)
419 return methods[index++ % count].apply(this, arguments);
420 });
421 });
422 };
423
424 function saveValue(name, val) {
425 if (gm) {
426 saveValueGM(name, val);
427 } else {
428 localStorage.setItem(name, val);
429 }
430 }
431
432 function deleteValue(name) {
433 if (gm) {
434 deleteValueGM(name);
435 } else {
436 localStorage.removeItem(name);
437 }
438 }
439
440 /*******************************************************************************************************************************
441 * Graphic filters
442 *******************************************************************************************************************************/
443 if (uw.location.pathname.indexOf("game") >= 0) {
444 $('<svg width="0%" height="0%">' +
445 // GREYSCALE
446 '<filter id="GrayScale">' +
447 '<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">' +
448 '</filter>' +
449 // SEPIA
450 '<filter id="Sepia">' +
451 '<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">' +
452 '</filter>' +
453 // SATURATION
454 '<filter id="Saturation"><feColorMatrix type="saturate" values="0.2"></filter>' +
455 '<filter id="Saturation1"><feColorMatrix type="saturate" values="1"></filter>' +
456 '<filter id="Saturation2"><feColorMatrix type="saturate" values="2"></filter>' +
457 // HUE
458 '<filter id="Hue1"><feColorMatrix type="hueRotate" values= "65"></filter>' +
459 '<filter id="Hue2"><feColorMatrix type="hueRotate" values="150"></filter>' +
460 '<filter id="Hue3"><feColorMatrix type="hueRotate" values="-65"></filter>' +
461 // BRIGHTNESS
462 '<filter id="Brightness15">' +
463 '<feComponentTransfer><feFuncR type="linear" slope="1.5"/><feFuncG type="linear" slope="1.5"/><feFuncB type="linear" slope="1.5"/></feComponentTransfer>' +
464 '</filter>' +
465 '<filter id="Brightness12">' +
466 '<feComponentTransfer><feFuncR type="linear" slope="1.2"/><feFuncG type="linear" slope="1.2"/><feFuncB type="linear" slope="1.2"/></feComponentTransfer>' +
467 '</filter>' +
468 '<filter id="Brightness11">' +
469 '<feComponentTransfer><feFuncR type="linear" slope="1.1"/><feFuncG type="linear" slope="1.1"/><feFuncB type="linear" slope="1.1"/></feComponentTransfer>' +
470 '</filter>' +
471 '<filter id="Brightness10">' +
472 '<feComponentTransfer><feFuncR type="linear" slope="1.0"/><feFuncG type="linear" slope="1.0"/><feFuncB type="linear" slope="1.0"/></feComponentTransfer>' +
473 '</filter>' +
474 '<filter id="Brightness07">' +
475 '<feComponentTransfer><feFuncR type="linear" slope="0.7"/><feFuncG type="linear" slope="0.7"/><feFuncB type="linear" slope="0.7"/></feComponentTransfer>' +
476 '</filter>' +
477 '</svg>').appendTo('#ui_box');
478 }
479
480 /*******************************************************************************************************************************
481 * Language versions: german, english, french, russian, polish, spanish
482 *******************************************************************************************************************************/
483 var LANG = {
484 de: {
485 settings: {
486 dsc: "DIO-Tools bietet unter anderem einige Anzeigen, eine Smileyauswahlbox,<br>Handelsoptionen und einige Veränderungen des Layouts.",
487 act: "Funktionen der Toolsammlung aktivieren/deaktivieren:",
488 prv: "Vorschau einzelner Funktionen:",
489
490 version_old: "DIO-Tools-Version ist nicht aktuell",
491 version_new: "DIO-Tools-Version ist aktuell",
492 version_dev: "DIO-Tools-Entwicklerversion",
493
494 version_update: "Aktualisieren",
495
496 link_forum: "http://forum.de.grepolis.com/showthread.php?28838&goto=newpost", //"http://forum.de.grepolis.com/showthread.php?28838"
497 link_contact: "http://forum.de.grepolis.com/private.php?do=newpm&u=10548",
498
499 forum: "Forum",
500 author: "Autor",
501
502 cat_units: "Einheiten",
503 cat_icons: "Stadticons",
504 cat_forum: "Forum",
505 cat_trade: "Handel",
506 cat_wonders: "Weltwunder",
507 cat_layout: "Layout",
508 cat_other: "Sonstiges"
509 },
510 options: {
511 //bir: ["Biremenzähler", "Zählt die jeweiligen Biremen einer Stadt und summiert diese.<br><br>Anzeige im Minimap-Bullauge oben links"],
512 ava: ["Einheitenübersicht", "Zeigt die Einheiten aller Städte an"],
513 sml: ["Smileys", "Erweitert die BBCode-Leiste um eine Smileybox"],
514 str: ["Einheitenstärke", "Fügt mehrere Einheitenstärketabellen in verschiedenen Bereichen hinzu"],
515 tra: ["Transportkapazität", "Zeigt die belegte und verfügbare Transportkapazität im Einheitenmenu an"],
516 per: ["Prozentualer Handel", "Erweitert das Handelsfenster um einen Prozentualer Handel"],
517 rec: ["Rekrutierungshandel", "Erweitert das Handelsfenster um einen Rekrutierungshandel"],
518 cnt: ["EO-Zähler", "Zählt die ATT/UT-Anzahl im EO-Fenster"],
519 way: ["Laufzeit", "Zeigt im ATT/UT-Fenster die Laufzeit bei Verbesserter Truppenbewegung an"],
520 sim: ["Simulator", "Anpassung des Simulatorlayouts & permanente Anzeige der Erweiterten Modifikatorbox"],
521 spl: ["Zauberbox", "Komprimierte verschiebbare & magnetische Zauberbox (Positionsspeicherung)"],
522 act: ["Aktivitätsboxen", "Verbesserte Anzeige der Handels- und Truppenaktivitätsboxen (Positionsspeicherung)"],
523 pop: ["Gunst-Popup", 'Ändert das Aussehen des Gunst-Popups'],
524 tsk: ["Taskleiste", 'Vergrößert die Taskleiste und minimiert das "Tägliche Belohnung"-Fenster beim Start'],
525 cha: ["Chat", "Ersetzt den Allianzchat durch einen Welten-Chat"],
526 bbc: ["DEF-Formular", "Erweitert die BBCode-Leiste um ein automatisches DEF-Formular"],
527 com: ["Einheitenvergleich", "Fügt Einheitenvergleichstabellen hinzu"],
528 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"],
529 til: ["Stadtliste", "Fügt die Stadticons zur Stadtliste hinzu"],
530 tim: ["Karte", "Setzt die Stadticons auf die strategische Karte"],
531 wwc: ["Anteil", "Anteilsrechner & Rohstoffzähler + Vor- & Zurück-Buttons bei fertiggestellten WW's (momentan nicht deaktivierbar!)"],
532 wwr: ["Rangliste", "Überarbeitete Weltwunderrangliste"],
533 wwi: ["Icons", 'Fügt Weltwundericons auf der strategischen Karte hinzu'],
534 con: ["Kontextmenu", 'Vertauscht "Stadt selektieren" und "Stadtübersicht" im Kontextmenu'],
535 sen: ["Abgeschickte Einheiten", 'Zeigt im Angriffs-/Unterstützungsfenster abgeschickte Einheiten an'],
536 tov: ["Stadtübersicht", 'Ersetzt die neue Stadtansicht mit der alten Fensteransicht'],
537 scr: ["Mausrad-Zoom", 'Man kann mit dem Mausrad die 3 Ansichten wechseln'],
538
539 err: ["Automatische Fehlerberichte senden", "Wenn du diese Option aktivierst, kannst du dabei helfen Fehler zu identifizieren."],
540 her: ["Thrakische Eroberung", "Verkleinerung der Karte der Thrakischen Eroberung."]
541 },
542 labels: {
543 uni: "Einheitenübersicht",
544 total: "Gesamt",
545 available: "Verfügbar",
546 outer: "Außerhalb",
547 con: "Selektieren",
548 // Smileys
549 std: "Standard",
550 gre: "Grepolis",
551 nat: "Natur",
552 ppl: "Leute",
553 oth: "Sonstige",
554 // Defense form
555 ttl: "Übersicht: Stadtverteidigung",
556 inf: "Informationen zur Stadt:",
557 dev: "Abweichung",
558 det: "Detailierte Landeinheiten",
559 prm: "Premiumboni",
560 sil: "Silberstand",
561 mov: "Truppenbewegungen:",
562 // WW
563 leg: "WW-Anteil",
564 stg: "Stufe",
565 tot: "Gesamt",
566 // Simulator
567 str: "Einheitenstärke",
568 los: "Verluste",
569 mod: "ohne Modifikatoreinfluss",
570 // Comparison box
571 dsc: "Einheitenvergleich",
572 hck: "Schlag",
573 prc: "Stich",
574 dst: "Distanz",
575 sea: "See",
576 att: "Angriff",
577 def: "Verteidigung",
578 spd: "Geschwindigkeit",
579 bty: "Beute (Rohstoffe)",
580 cap: "Transportkapazität",
581 res: "Baukosten (Rohstoffe)",
582 fav: "Gunst",
583 tim: "Bauzeit (s)",
584 // Trade
585 rat: "Ressourcenverhältnis eines Einheitentyps",
586 shr: "Anteil an der Lagerkapazität der Zielstadt",
587 per: "Prozentualer Handel",
588 // Sent units box
589 lab: "Abgeschickt",
590 improved_movement: "Verbesserte Truppenbewegung"
591 },
592 buttons: {
593 sav: "Speichern", ins: "Einfügen", res: "Zurücksetzen"
594 }
595 },
596
597 en: {
598 settings: {
599 dsc: "DIO-Tools offers, among other things, some displays, a smiley box,<br>trade options and some changes to the layout.",
600 act: "Activate/deactivate features of the toolset:",
601 prv: "Preview of several features:",
602
603 version_old: "Version is not up to date",
604 version_new: "Version is up to date",
605 version_dev: "Developer version",
606
607 version_update: "Update",
608
609 link_forum: "http://forum.en.grepolis.com/showthread.php?52104&goto=newpost",
610 link_contact: "http://forum.en.grepolis.com/private.php?do=newpm&u=46211",
611
612 forum: "Forum",
613 author: "Author",
614
615 cat_units: "Units",
616 cat_icons: "Town icons",
617 cat_forum: "Forum",
618 cat_trade: "Trade",
619 cat_wonders: "World wonder",
620 cat_layout: "Layout",
621 cat_other: "Miscellaneous"
622 },
623 options: {
624 //bir: ["Bireme counter", "Counts the biremes of a city and sums these"],
625 ava: ["Units overview", "Counts the units of all cities"],
626 sml: ["Smilies", "Extends the bbcode bar by a smiley box"],
627 str: ["Unit strength", "Adds unit strength tables in various areas"],
628 tra: ["Transport capacity", "Shows the occupied and available transport capacity in the unit menu"],
629 per: ["Percentual trade", "Extends the trade window by a percentual trade"],
630 rec: ["Recruiting trade", "Extends the trade window by a recruiting trade"],
631 cnt: ["Conquests", "Counts the attacks/supports in the conquest window"],
632 way: ["Troop speed", "Displays improved troop speed in the attack/support window"],
633 sim: ["Simulator", "Adaptation of the simulator layout & permanent display of the extended modifier box"],
634 spl: ["Spell box", "Compressed movable & magnetic spell box (position memory)"],
635 act: ["Activity boxes", "Improved display of trade and troop activity boxes (position memory)"],
636 pop: ["Favor popup", "Changes the favor popup"],
637 tsk: ["Taskbar", "Increases the taskbar and minimizes the daily reward window on startup"],
638 cha: ["Chat", 'Replaced the alliance chat by an world chat. (FlashPlayer required)'],
639 bbc: ["Defense form", "Extends the bbcode bar by an automatic defense form"],
640 com: ["Unit Comparison", "Adds unit comparison tables"],
641 tic: ["Town icons", "Each city receives an icon for the town type (automatic detection)", "Additional icons are available for manual selection"],
642 til: ["Town list", "Adds the town icons to the town list"],
643 tim: ["Map", "Sets the town icons on the strategic map"],
644 wwc: ["Calculator", "Share calculation & resources counter + previous & next buttons on finished world wonders (currently not deactivatable!)"],
645 wwr: ["Ranking", "Redesigned world wonder rankings"],
646 wwi: ["Icons", 'Adds world wonder icons on the strategic map'],
647 con: ["Context menu", 'Swaps "Select town" and "City overview" in the context menu'],
648 sen: ["Sent units", 'Shows sent units in the attack/support window'],
649 tov: ["Town overview", 'Replaces the new town overview with the old window style'],
650 scr: ["Mouse wheel", 'You can change the views with the mouse wheel'],
651
652 err: ["Send bug reports automatically", "If you activate this option, you can help identify bugs."],
653 her: ["Thracian Conquest", "Downsizing of the map of the Thracian conquest."]
654 },
655 labels: {
656 uni: "Units overview",
657 total: "Total",
658 available: "Available",
659 outer: "Outside",
660 con: "Select town",
661 // Smileys
662 std: "Standard",
663 gre: "Grepolis",
664 nat: "Nature",
665 ppl: "People",
666 oth: "Other",
667 hal: "Halloween",
668 xma: "Xmas",
669 // Defense form
670 ttl: "Overview: Town defense",
671 inf: "Town information:",
672 dev: "Deviation",
673 det: "Detailed land units",
674 prm: "Premium bonuses",
675 sil: "Silver volume",
676 mov: "Troop movements:",
677 // WW
678 leg: "WW Share",
679 stg: "Stage",
680 tot: "Total",
681 // Simulator
682 str: "Unit strength",
683 los: "Loss",
684 mod: "without modificator influence",
685 // Comparison box
686 dsc: "Unit comparison",
687 hck: "Blunt",
688 prc: "Sharp",
689 dst: "Distance",
690 sea: "Sea",
691 att: "Offensive",
692 def: "Defensive",
693 spd: "Speed",
694 bty: "Booty (resources)",
695 cap: "Transport capacity",
696 res: "Costs (resources)",
697 fav: "Favor",
698 tim: "Recruiting time (s)",
699 // Trade
700 rat: "Resource ratio of an unit type",
701 shr: "Share of the storage capacity of the target city",
702 per: "Percentage trade",
703 // Sent units box
704 lab: "Sent units",
705 improved_movement: "Improved troop movement"
706 },
707 buttons: {
708 sav: "Save", ins: "Insert", res: "Reset"
709 }
710 },
711 //////////////////////////////////////////////
712 // French Translation by eclat49 //
713 //////////////////////////////////////////////
714 fr: {
715 settings: {
716 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.",
717 act: "Activation/Désactivation des fonctions:",
718 prv: "Aperçu des fonctions séparées:"
719 },
720 options: {
721 //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)"],
722 ava: ["Présentation des unités", "Indique les unités de toutes les villes."],
723 sml: ["Smileys", "Rajoutes une boite de smilies à la boite de bbcode"],
724 str: ["Force unitaire", "Ajoutes des tableaux de force unitaire dans les différentes armes"],
725 //trd: [ "Commerce", "Ajout d'une option par pourcentage, par troupes pour le commerce, ainsi qu'un affichage des limites pour les festivals" ],
726 per: ["Commerce de pourcentage", ""],
727 rec: ["Commerce de recrutement", ""],
728 cnt: ["Compteur conquête", "Comptabilise le nombre d'attaque et de soutien dans la fenêtre de conquête"],
729 way: ["Vitesse des troupes ", "Rajoutes le temps de trajet avec le bonus accélération"],
730 sim: ["Simulateur", "Modification de la présentation du simulateur et affichage permanent des options premium"],
731 spl: ["Boîte de magie", "Boîte de sort cliquable et positionnable"],
732 act: ["Boîte d'activité", "Présentation améliorée du commerce et des mouvement de troupes (mémoire de position)"],
733 pop: ["Popup de faveur", 'Change la popup de faveur'],
734 tsk: ["Barre de tâches ", "La barre de tâches augmente et minimise le fenêtre de bonus journalier"],
735 cha: ["Chat", "Remplace le chat de l'alliance à travers un chat monde."],
736 bbc: ["Formulaire de défense", "Ajout d'un bouton dans la barre BBCode pour un formulaire de défense automatique"],
737 com: ["Comparaison des unités", "Ajoutes des tableaux de comparaison des unités"],
738 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"],
739 til: ["Liste de ville", "Ajoute les icônes de la ville à la liste de la ville"],
740 tim: ["Carte", "Définit les icônes de la ville sur la carte stratégique"],
741 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)"],
742 wwr: ["", ""],
743 //wwi: [ "Icônes",'Adds world wonder icons on the strategic map' ],
744 con: ["Menu contextuel", 'Swaps "Sélectionner ville" et "Aperçu de la ville" dans le menu contextuel'],
745 sen: ["Unités envoyées", 'Affiche unités envoyées dans la fenêtre attaque/support'],
746 tov: ["Aperçu de ville", "Remplace la nouvelle aperçu de la ville avec l'ancien style de fenêtre"],
747 scr: ["Molette de la souris", 'Avec la molette de la souris vous pouvez changer les vues'],
748
749 err: ["Envoyer des rapports de bogues automatiquement", "Si vous activez cette option, vous pouvez aider à identifier les bugs."]
750 },
751 labels: {
752 uni: "Présentation des unités",
753 total: "Global",
754 available: "Disponible",
755 outer: "Extérieur",
756 con: "Sélectionner",
757 // Smileys
758 std: "Standard",
759 gre: "Grepolis",
760 nat: "Nature",
761 ppl: "Gens",
762 oth: "Autres",
763 // Defense form
764 ttl: "Aperçu: Défense de ville",
765 inf: "Renseignements sur la ville:",
766 dev: "Différence",
767 det: "Unités terrestres détaillées",
768 prm: "Bonus premium",
769 sil: "Remplissage de la grotte",
770 mov: "Mouvements de troupes:",
771 // WW
772 leg: "Participation",
773 stg: "Niveau",
774 tot: "Total",
775 // Simulator
776 str: "Force unitaire",
777 los: "Pertes",
778 mod: "sans influence de modificateur",
779 // Comparison box
780 dsc: "Comparaison des unités",
781 hck: "Contond.",
782 prc: "Blanche",
783 dst: "Jet",
784 sea: "Navale",
785 att: "Attaque",
786 def: "Défense",
787 spd: "Vitesse",
788 bty: "Butin",
789 cap: "Capacité de transport",
790 res: "Coût de construction",
791 fav: "Faveur",
792 tim: "Temps de construction (s)",
793 // Trade
794 rat: "Ratio des ressources d'un type d'unité",
795 shr: "Part de la capacité de stockage de la ville cible",
796 per: "Commerce de pourcentage",
797 // Sent units box
798 lab: "Envoyée",
799 improved_movement: "Mouvement des troupes amélioré"
800 },
801 buttons: {
802 sav: "Sauver", ins: "Insertion", res: "Remettre"
803 }
804 },
805 //////////////////////////////////////////////
806 // Russian Translation by MrBobr //
807 //////////////////////////////////////////////
808 ru: {
809 settings: {
810 dsc: "DIO-Tools изменяет некоторые окна, добавляет новые смайлы, отчёты,<br>улучшеные варианты торговли и другие функции.",
811 act: "Включение/выключение функций:",
812 prv: "Примеры внесённых изменений:"
813 },
814 options: {
815 //bir: ["Счётчик бирем", "Показывает число бирем во всех городах"],
816 ava: ["Обзор единиц", "Указывает единицы всех городов"], // ?
817 sml: ["Смайлы", "Добавляет кнопку для вставки смайлов в сообщения"],
818 str: ["Сила отряда", "Добавляет таблицу общей силы отряда в некоторых окнах"],
819 //trd: [ "Торговля", "Добавляет маркеры и отправку недостающих ресурсов, необходимых для фестиваля. Инструменты для долевой торговли" ],
820 per: ["Процент торговля", ""],
821 rec: ["Рекрутинг торговля", ""],
822 cnt: ["Завоевания", "Отображение общего числа атак/подкреплений в окне завоевания города"],
823 way: ["30% ускорение", "Отображает примерное время движения отряда с 30% бонусом"],
824 sim: ["Симулятор", "Изменение интерфейса симулятора, добавление новых функций"],
825 spl: ["Заклинания", "Изменяет положение окна заклинаний"],
826 act: ["Перемещения", "Показывает окна пересылки ресурсов и перемещения войск"],
827 pop: ["Благосклонность", "Отображение окна с уровнем благосклонности богов"],
828 tsk: ["Таскбар", "Увеличение ширины таскбара и сворачивание окна ежедневной награды при входе в игру"],
829 // cha: ["Чат", 'Замена чата игры на irc-чат'],
830 bbc: ["Форма обороны", "Добавляет кнопку для вставки в сообщение отчёта о городе"], // Beschreibung passt nicht ganz
831 com: ["Сравнение юнитов", "Добавляет окно сравнения юнитов"],
832 tic: ["Типы городов", "Каждый город получает значок для городского типа (автоматическое определение)", "Дополнительные иконки доступны для ручного выбора"], // ?
833 til: ["Список город", "Добавляет значки городские в список города"], // ?
834 tim: ["Карта", "Устанавливает городские иконки на стратегической карте"], // ?
835 wwc: ["Чудо света", "Share calculation & resources counter + previous & next buttons on finished world wonders (currently not deactivatable!)"],
836 wwr: ["", ""],
837 //wwi: [ "World wonder icons",'Adds world wonder icons on the strategic map' ],
838 //con: [ "Context menu", 'Swaps "Select town" and "City overview" in the context menu'],
839 //sen: [ "Sent units", 'Shows sent units in the attack/support window'],
840 tov: ["Обзор Город", 'Заменяет новый обзор города с старом стиле окна'], // ?
841 scr: ["Колесо мыши", 'С помощью колеса мыши вы можете изменить взгляды'], // ?
842
843 err: ["Отправить сообщения об ошибках автоматически", "Если вы включите эту опцию, вы можете помочь идентифицировать ошибки"]
844 },
845
846 labels: {
847 uni: "Обзор единиц",
848 total: "Oбщий",
849 available: "доступный",
850 outer: "вне",
851 con: "выбирать",
852 // Smileys
853 std: "",
854 gre: "",
855 nat: "",
856 ppl: "",
857 oth: "",
858 // Defense form
859 ttl: "Обзор: Отчёт о городе",
860 inf: "Информация о войсках и постройках:",
861 dev: "Отклонение",
862 det: "Детальный отчёт",
863 prm: "Премиум-бонусы",
864 sil: "Серебро в пещере",
865 mov: "Перемещения",
866 // WW
867 leg: "",
868 stg: "",
869 tot: "",
870 // Simulator
871 str: "Сила войск",
872 los: "Потери",
873 mod: "без учёта заклинаний, бонусов, исследований",
874 // Comparison box
875 dsc: "Сравнение юнитов",
876 hck: "Ударное",
877 prc: "Колющее",
878 dst: "Дальнего боя",
879 sea: "Морские",
880 att: "Атака",
881 def: "Защита",
882 spd: "Скорость",
883 bty: "Добыча (ресурсы)",
884 cap: "Вместимость транспортов",
885 res: "Стоимость (ресурсы)",
886 fav: "Благосклонность",
887 tim: "Время найма (с)",
888 // Trade
889 rat: "",
890 shr: "",
891 per: "",
892 // Sent units box
893 lab: "Отправлено",
894 improved_movement: "Улучшенная перемещение войск"
895 },
896
897 buttons: {
898 sav: "Сохраниить", ins: "Вставка", res: "Сброс"
899 }
900 },
901 //////////////////////////////////////////////
902 // Polish Translation by anpu //
903 //////////////////////////////////////////////
904 pl: {
905 settings: {
906 dsc: "DIO-Tools oferuje (między innymi) poprawione widoki, nowe uśmieszki,<br>opcje handlu i zmiany w wyglądzie.",
907 act: "Włącz/wyłącz funkcje skryptu:",
908 prv: "podgląd poszczególnych opcji:"
909 },
910 options: {
911 //bir: ["Licznik birem", "Zlicza i sumuje biremy z miast"],
912 ava: ["Przegląd jednostek", "Wskazuje jednostki wszystkich miast"], // ?
913 sml: ["Emotki", "Dodaje dodatkowe (zielone) emotikonki"],
914 str: ["Siła jednostek", "dodaje tabelki z siłą jednostek w różnych miejscach gry"],
915 //trd: [ "Handel", "Rozszerza okno handlu o handel procentowy, proporcje surowców wg jednostek, dodaje znaczniki dla festynów" ],
916 per: ["Handel procentowy", ""],
917 rec: ["Handel rekrutacyjne", ""],
918 cnt: ["Podboje", "Zlicza wsparcia/ataki w oknie podboju (tylko własne podboje)"],
919 way: ["Prędkość wojsk", "Wyświetla dodatkowo czas jednostek dla bonusu przyspieszone ruchy wojsk"],
920 sim: ["Symulator", "Dostosowanie wyglądu symulatora oraz dodanie szybkich pól wyboru"],
921 spl: ["Ramka czarów", "Kompaktowa pływająca ramka z czarami (można umieścić w dowolnym miejscu ekranu. Zapamiętuje położenie.)"],
922 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.)"],
923 pop: ["Łaski", "Zmienia wygląd ramki informacyjnej o ilości produkowanych łask"],
924 tsk: ["Pasek skrótów", "Powiększa pasek skrótów i minimalizuje okienko z bonusem dziennym"],
925 // cha: ["Czat", 'Zastępuje standardowy Chat chatem IRC'],
926 bbc: ["Raportów obronnych", "Rozszerza pasek skrótów BBcode o generator raportów obronnych"],
927 com: ["Porównianie", "Dodaje tabelki z porównaniem jednostek"],
928 tic: ["Ikony miasta", "Każde miasto otrzyma ikonę typu miasta (automatyczne wykrywanie)", "Dodatkowe ikony są dostępne dla ręcznego wyboru"], // ?
929 til: ["Lista miasto", "Dodaje ikony miasta do listy miasta"], // ?
930 tim: ["Mapa", "Zestawy ikon miasta na mapie strategicznej"], // ?
931 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)"],
932 wwr: ["", ""],
933 //wwi: [ "World wonder icons",'Adds world wonder icons on the strategic map' ],
934 con: ["menu kontekstowe", 'Zamiemia miejcami przycisk "wybierz miasto" z przyciskiem "podgląd miasta" po kliknięciu miasta na mapie'],
935 sen: ["Wysłane jednostki", 'Pokaż wysłane jednostki w oknie wysyłania ataków/wsparć'],
936 tov: ["Podgląd miasta", 'Zastępuje nowy podgląd miasta starym'],
937 scr: ["Zoom", 'Możesz zmienić poziom przybliżenia mapy kółkiem myszy'],
938
939 err: ["Automatycznie wysyłać raporty o błędach", "Jeśli włączysz tę opcję, możesz pomóc zidentyfikować błędy"]
940
941 },
942 labels: {
943 uni: "Przegląd jednostek",
944 total: "Ogólny",
945 available: "Dostępny",
946 outer: "Na zewnątrz",
947 con: "Wybierz miasto",
948 // Smileys
949 std: "Standard" /* "Standardowe" */,
950 gre: "Grepolis",
951 nat: "Przyroda",
952 ppl: "Ludzie",
953 oth: "Inne",
954 // Defense form
955 ttl: "Podgląd: Obrona miasta",
956 inf: "Informacje o mieście:",
957 dev: "Ochyłka",
958 det: "jednostki lądowe",
959 prm: "opcje Premium",
960 sil: "Ilość srebra",
961 mov: "Ruchy wojsk",
962 // WW
963 leg: "Udział w Cudzie",
964 stg: "Poziom",
965 tot: "Łącznie",
966 // Simulator
967 str: "Siła jednostek",
968 los: "Straty",
969 mod: "bez modyfikatorów",
970 // Comparison box
971 dsc: "Porównianie jednostek",
972 hck: "Obuchowa",
973 prc: "Tnąca",
974 dst: "Dystansowa",
975 sea: "Morskie",
976 att: "Offensywne",
977 def: "Defensywne",
978 spd: "Prędkość",
979 bty: "Łup (surowce)",
980 cap: "Pojemność transportu",
981 res: "Koszta (surowce)",
982 fav: "Łaski",
983 tim: "Czas rekrutacji (s)",
984 // Trade
985 rat: "Stosunek surowców dla wybranej jednostki",
986 shr: "procent zapełnienia magazynu w docelowym mieście",
987 per: "Handel procentowy",
988 // Sent units box
989 lab: "Wysłane jednostki",
990 improved_movement: "Przyspieszone ruchy wojsk"
991 },
992 buttons: {
993 sav: "Zapisz", ins: "Wstaw", res: "Anuluj"
994 }
995 },
996 //////////////////////////////////////////////
997 // Spanish Translation by Juana de Castilla //
998 //////////////////////////////////////////////
999 es: {
1000 settings: {
1001 dsc: "DIO-Tools ofrece, entre otras cosas, varias pantallas, ventana de <br>emoticones, opciones de comercio y algunos cambios en el diseño.",
1002 act: "Activar/desactivar características de las herramientas:",
1003 prv: "Vista previa de varias características:"
1004 },
1005 options: {
1006 //bir: ["Contador de birremes", "Cuenta los birremes de una ciudad y los suma"],
1007 ava: ["Información general unidades", "Indica las unidades de todas las ciudades"], // ?
1008 sml: ["Emoticones", "Código BB para emoticones"],
1009 str: ["Fortaleza de la Unidad", "Añade tabla de fortalezas de cada unidad en varias zonas"],
1010 //trd: [ "Comercio", "Añade en la pestaña de comercio un porcentaje de comercio y reclutamiento y limitadores de Mercado por cada ciudad" ],
1011 per: ["Comercio de porcentual", ""],
1012 rec: ["Comercio de reclutamiento", ""],
1013 cnt: ["Conquistas", "contador de ataques y refuerzos en la pestaña de conquista"],
1014 way: ["Velocidad de tropas", "Muestra movimiento de tropas mejorado en la ventana de ataque/refuerzo"],
1015 sim: ["Simulador", "Adaptación de la ventana del simulador incluyendo recuadro de modificadores"],
1016 spl: ["Ventana de hechizos", "Ventana deslizante y comprimida de los hechizos (memoria posicional)"],
1017 act: ["Ventana de actividad", "Mejora las ventanas de comercio y movimiento de tropas (memoria posicional)"],
1018 pop: ["Popup", "Cambia el popup de favores"],
1019 tsk: ["Barra de tareas", "aumenta la barra de tareas y minimice la recompensa al aparecer"],
1020 // cha: ["Chat", 'Sustituye el chat de la alianza con un irc chat.'],
1021 bbc: ["Formulario de defensa", "Añade en la barra de códigos bb un formulario de defensa"],
1022 com: ["Comparación", "añade ventana de comparación de unidades"],
1023 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"],
1024 til: ["Lista de la ciudad", "Agrega los iconos de la ciudad a la lista de la ciudad"],
1025 tim: ["Map", "Establece los iconos de la ciudad en el mapa estratégico"],
1026 wwc: ["Maravillas", "Calcula participación & contador de recursos + antes y después teclas de maravillas terminadas (no desactibable ahora!)"],
1027 wwr: ["", ""],
1028 //wwi: [ "World wonder icons",'Adds world wonder icons on the strategic map' ],
1029 con: ["menú contextual", 'Cambia "Elegir ciudad" y "vista de la ciudad" en el menú contextual '],
1030 sen: ["Unidades enviadas", 'Muestra las unidades enviadas en la ventana de ataque/refuerzos'],
1031 tov: ["Información de la ciudad", 'sustituye la vista nueva de ciudad por la ventana antigua'],
1032 scr: ["Rueda raton", 'Puede cambiar las vistas con la rueda del raton'],
1033
1034 err: ["Enviar informes de errores automáticamente", "Si se activa esta opción, puede ayudar a identificar errores."]
1035 },
1036 labels: {
1037 uni: "Información general unidades",
1038 total: "Total",
1039 available: "Disponible",
1040 outer: "Fuera",
1041 con: "Escoger ciudad",
1042 // Smileys
1043 std: "Standard",
1044 gre: "Grepolis",
1045 nat: "Natura",
1046 ppl: "Gente",
1047 oth: "Otros",
1048 // Defense form
1049 ttl: "Vista general: Defensa de la ciudad",
1050 inf: "Información de la ciudad:",
1051 dev: "Desviación",
1052 det: "Unidades de tierra detalladas",
1053 prm: "Bonos Premium",
1054 sil: "Volumen de plata",
1055 mov: "Movimientos de tropas:",
1056 // WW
1057 leg: "WW cuota",
1058 stg: "Nivel",
1059 tot: "Total",
1060 // Simulator
1061 str: "Fortaleza de la Unidad",
1062 los: "Perdida",
1063 mod: "sin influencia del modificador",
1064 // Comparison box
1065 dsc: "Comparación de Unidades",
1066 hck: "Contundente",
1067 prc: "Punzante",
1068 dst: "Distancia",
1069 sea: "Mar",
1070 att: "Ataque",
1071 def: "Defensa",
1072 spd: "Velocidad",
1073 bty: "Botín (recursos)",
1074 cap: "Capacidad de transporte",
1075 res: "Costes (recursos)",
1076 fav: "Favor",
1077 tim: "Tiempo de reclutamiento (s)",
1078 // Trade
1079 rat: "Proporción de recursos de un tipo de unidad",
1080 shr: "Porcentaje de la capacidad de almacenamiento de la ciudad destino",
1081 per: "Porcentaje de comercio",
1082 // Sent units box
1083 lab: "Unidades enviadas",
1084 improved_movement: "Movimiento de tropas mejorados"
1085 },
1086 buttons: {
1087 sav: "Guardar", ins: "Insertar", res: "Reinicio"
1088 }
1089 },
1090 ar: {},
1091 //////////////////////////////////////////////
1092 // Portuguese (BR) Translation by HELL //
1093 //////////////////////////////////////////////
1094 br: {
1095 settings: {
1096 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.",
1097 act: "Ativar/desativar recursos do conjunto de ferramentas:",
1098 prv: "Pré-visualização de vários recursos:",
1099
1100 version_old: "Versão não está atualizada",
1101 version_new: "Versão está atualizada",
1102 version_dev: "Versão do desenvolvedor",
1103
1104 version_update: "Atualização",
1105
1106 link_forum: "http://forum.en.grepolis.com/showthread.php?52104&goto=newpost",
1107 link_contact: "http://forum.en.grepolis.com/private.php?do=newpm&u=46211",
1108
1109 forum: "Forum",
1110 author: "Autor",
1111
1112 cat_units: "Unidades",
1113 cat_icons: "Ícones nas Cidades",
1114 cat_forum: "Forum",
1115 cat_trade: "Comércio",
1116 cat_wonders: "Maravilhas do Mundo",
1117 cat_layout: "Layout",
1118 cat_other: "Outros"
1119 },
1120 options: {
1121 // bir: ["Contador de Birremes", "Conta as biremes da cidade na cidade"],
1122 ava: ["Visão Geral da unidade", "Indica as unidades de todas as cidades"], // ?
1123 sml: ["Smilies", "Estende o bbcode com uma caixa de smiley"],
1124 str: ["Força das Tropas", "Adiciona quadros de força das tropas em diversas áreas"],
1125 tra: ["Capacidade de Transporte", "Mostra a capacidade de transporte ocupado e disponível no menu de unidades"],
1126 per: ["Percentual de comércio", "Estende-se a janela de comércio com um percentual de comércio"],
1127 rec: ["Comércio para recrutamento", "Estende-se a janela de comércio com um comércio de recrutamento"],
1128 cnt: ["Conquistas", "Conta os ataques/apoios na janela de conquista"],
1129 way: ["Velocidade da Tropa", "Displays mostram a possivél velocidade de tropa na janela de ataque/suporte"],
1130 sim: ["Simulador", "Adaptação do layout simulador & exposição permanente da caixa poderes estendida"],
1131 spl: ["Caixa de Poderes Divinos", "Pequena caixa móvel & magnética de poderes divinos (com memória de posição) "],
1132 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)"],
1133 pop: ["Caixa de favores divino", "Altera a caixa de favores divino por um novo layout"],
1134 tsk: ["Barra de tarefas", "Aumenta a barra de tarefas e minimiza a janela recompensa diária no inicio"],
1135 // cha: ["Chat", 'Substituiu o da bate-papo por um bate-papo IRC.'],
1136 bbc: ["Pedido de Apoio", "Estende a barra de bbcode com uma forma de Pedido de Apoio Automática"],
1137 com: ["Comparação de Unidades", "Adiciona tabelas de comparação de unidade"],
1138 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"],
1139 til: ["Lista das Cidades", "Adiciona os ícones da cidade na lista de cidades"],
1140 tim: ["Mapa", "Mostra os ícones das cidades no mapa estratégico"],
1141 wwc: ["Calculadora de WW", "Cálculo compartilhado & contador de recursos + botões anterior e próxima maravilhas do mundo (atualmente não desactivável!)"],
1142 wwr: ["Classificação", "Classificação das maravilha do mundo redesenhadas"],
1143 wwi: ["Icones", 'Adiciona ícones nas maravilha do mundo no mapa estratégico'],
1144 con: ["Menu de Contexto", 'Troca da "Selecione cidade" e "Visão Geral da Cidade" no menu de contexto'],
1145 sen: ["Unidades Enviadas", 'Shows sent units in the attack/support window'],
1146 tov: ["Visão da Cidade", 'Substitui o novo panorama da cidade, com o estilo da janela antiga'],
1147 scr: ["Roda do Mouse", 'Você pode alterar os pontos de vista com a roda do mouse'],
1148
1149 err: ["Enviar automaticamente relatórios de erros", "Se você ativar essa opção, você pode ajudar a identificar erros."],
1150 her: ["Conquista Thracian", "Redução de tamanho do mapa da conquista Thracian."]
1151 },
1152 labels: {
1153 uni: "Visão Geral da unidade",
1154 total: "Global",
1155 available: "Disponível",
1156 outer: "Fora",
1157 con: "Selecionar cidade",
1158 // Smileys
1159 std: "Padrão",
1160 gre: "Grepolis",
1161 nat: "Natural",
1162 ppl: "Popular",
1163 oth: "Outros",
1164 hal: "Halloween",
1165 xma: "Natal",
1166 // Defense form
1167 ttl: "Pedido de Apoio",
1168 inf: "Informação da cidade:",
1169 dev: "Desvio",
1170 det: "Unidades Detalhadas",
1171 prm: "Bônus Premium",
1172 sil: "Prata na Gruta",
1173 mov: "Movimentação de Tropas:",
1174 // WW
1175 leg: "WW Maravilhas",
1176 stg: "Level",
1177 tot: "Total",
1178 // Simulator
1179 str: "Força das Unidades",
1180 los: "Perdas",
1181 mod: "Sem modificador de influência",
1182 // Comparison box
1183 dsc: "Comparação de unidades",
1184 hck: "Impacto",
1185 prc: "Corte",
1186 dst: "Arremço",
1187 sea: "Naval",
1188 att: "Ofensivo",
1189 def: "Defensivo",
1190 spd: "Velocidade",
1191 bty: "Saque (recursos)",
1192 cap: "Capacidade de trasporte",
1193 res: "Custo (recursos)",
1194 fav: "Favor",
1195 tim: "Tempo de recrutamento (s)",
1196 // Trade
1197 rat: "Proporção de recursos de um tipo de unidade",
1198 shr: "A partir do armazenamento sobre a cidade de destino",
1199 per: "Percentual de comércio",
1200 // Sent units box
1201 lab: "Unidades enviadas",
1202 improved_movement: "Movimentação de tropas com ajuste de bônus"
1203 },
1204 buttons: {
1205 sav: "Salvar", ins: "Inserir", res: "Resetar"
1206 }
1207 },
1208 pt : {},
1209 //////////////////////////////////////////////
1210 // Czech Translation by Piwus //
1211 //////////////////////////////////////////////
1212 cz: {
1213 settings: {
1214 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ů.",
1215 act: "Aktivovat/Deaktivovat funkce sady nástrojů:",
1216 prv: "Ukázka několika funkcí:",
1217
1218 version_old: "Verze je zastaralá",
1219 version_new: "Verze je aktuální",
1220 version_dev: "Vývojářská verze",
1221
1222 version_update: "Aktualizovat",
1223
1224 link_forum: "http://forum.en.grepolis.com/showthread.php?52104&goto=newpost",
1225 link_contact: "http://forum.en.grepolis.com/private.php?do=newpm&u=46211",
1226
1227 forum: "Forum",
1228 author: "Autor",
1229
1230 cat_units: "Jednotky",
1231 cat_icons: "Ikony měst",
1232 cat_forum: "Forum",
1233 cat_trade: "Obchod",
1234 cat_wonders: "Div světa",
1235 cat_layout: "Okna",
1236 cat_other: "Ostatní"
1237 },
1238 options: {
1239 // bir: ["Počítadlo birém", "Spočítá každé birémy ve městech a sečte je."],
1240 ava: ["Jednotky Přehled", "Označuje jednotky všemi městy"], // ?
1241 sml: ["Smajlíci", "Rozšiřuje panel BBkodů okénkem smajlíků"],
1242 str: ["Síla jednotek", "Přidává tabulku sil jednotek v různých oblastech"],
1243 tra: ["Transportní kapacita", "Zobrazuje obsazenou a dostupnou transportní kapacitu v nabídce jednotek"],
1244 per: ["Procentuální obchod", "Rozšiřuje obchodní okno možností procentuálního obchodu"],
1245 rec: ["Obchod rekrutace", "Rozšiřuje obchodní okno možností obchodem pro rekrutaci"],
1246 cnt: ["Dobývání", "Počítá Útok/Obrana v okně dobývání (pouze vlastní dobývání zatím)"],
1247 way: ["Rychlost vojsk", "Zobrazuje vylepšenou rychlost vojsk v okně útoku/obrany"],
1248 sim: ["Simulátor", "Přizpůsobení rozložení simulátoru & permanentní zobrazování rozšířeného okna modifikátoru"],
1249 spl: ["Okénko kouzel", "Stlačené klouzání oken & magnetické okénko kouzel (pozice paměti)"],
1250 act: ["Aktivní okénka", "Zlepšený zobrazení obchodů a vojsk aktivními okénky (pozice paměti)"],
1251 pop: ["Vyskakovací okénko přízně", "Změní vyskakovací okno seznamu přízní"],
1252 tsk: ["Hlavní panel", "Zvyšuje hlavní panel a minimalizuje bonus denní odměny po přihlášení"],
1253 // cha: ["Chat", 'Nahrazen alianční chat chatem IRC.'],
1254 bbc: ["Obranné hlášení", "Rozšiřuje panel BBkodů automatickém hlášení obrany města"],
1255 com: ["Porovnání jednotek", "Přidává tabulku porovnání jednotek"],
1256 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ě"],
1257 til: ["Seznam měst", "Přidává ikony měst do seznamu měst"],
1258 tim: ["Mapa", "Přidává ikony měst na stategickou mapu"],
1259 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!)"],
1260 wwr: ["Žebříček", "Předělaný žebříček divů světa"],
1261 wwi: ["Ikony", 'Přídává ikony divů světa na strategickou mapu'],
1262 con: ["Kontextové menu", 'Vyměňuje "Vybrat město" a "Přehled města" v kontextovém menu'],
1263 sen: ["Odeslané jednotky", 'Zobrazuje odeslané jednotky útoku/obrany v okně'],
1264 tov: ["Přehled města", 'Nahrazuje nový přehled měst starším stylem okna'],
1265 scr: ["Kolečko myši", 'Můžeš změnit pohledy s kolečkem myši'],
1266
1267 err: ["Hlásit chyby automaticky", "Pokud aktivuješ tuto možnost,pomůžeš nám identifikovat chyby."],
1268 her: ["Thrácké dobývání", "Redukuje mapy Thráckého dobývání."]
1269 },
1270 labels: {
1271 uni: "Jednotky Přehled",
1272 total: "Celkový",
1273 available: "K dispozici",
1274 outer: "Vně",
1275 con: "Zvolit město",
1276 // Smileys
1277 std: "Standartní",
1278 gre: "Grepolis",
1279 nat: "Příroda",
1280 ppl: "Lidi",
1281 oth: "Ostatní",
1282 hal: "Halloween",
1283 xma: "Vánoce",
1284 // Defense form
1285 ttl: "Přehled: Obrana města",
1286 inf: "Informace o městě:",
1287 dev: "Odchylka",
1288 det: "Podrobné pozemní jednotky",
1289 prm: "Prémiové bonusy",
1290 sil: "Objem stříbra",
1291 mov: "Pohyby vojsk:",
1292 // WW
1293 leg: "Podíl divu světa",
1294 stg: "Stupeň",
1295 tot: "Celkem",
1296 // Simulator
1297 str: "Síla jednotek",
1298 los: "Ztráta",
1299 mod: "bez vlivu modifikátoru",
1300 // Comparison box
1301 dsc: "Porovnání jednotek",
1302 hck: "Sečné",
1303 prc: "Bodné",
1304 dst: "Střelné",
1305 sea: "Moře",
1306 att: "Útočné",
1307 def: "Obranné",
1308 spd: "Rychlost",
1309 bty: "Kořist (suroviny)",
1310 cap: "Transportní kapacita",
1311 res: "Náklady (suroviny)",
1312 fav: "Přízeň",
1313 tim: "Doba rekrutování (s)",
1314 // Trade
1315 rat: "Poměr surovin typu jednotky",
1316 shr: "Podíl na úložné kapacitě cílového města",
1317 per: "Procentuální obchod",
1318 // Sent units box
1319 lab: "Odeslané jednotky",
1320 improved_movement: "Vylepšený pohyb jednotek"
1321 },
1322 buttons: {
1323 sav: "Uložit", ins: "Vložit", res: "Resetovat"
1324 }
1325 }
1326 };
1327
1328 LANG.ar = LANG.es;
1329 LANG.pt = LANG.br;
1330 LANG.cs = LANG.cz;
1331
1332 // Create JSON
1333 // console.log(JSON.stringify(LANG.en));
1334
1335 // Forum: Choose language
1336 if (!(uw.location.pathname.indexOf("game") >= 0)) {
1337 LID = uw.location.host.split(".")[1];
1338 }
1339
1340 console.debug("SPRACHE", LID);
1341 // Translation GET
1342 function getText(category, name) {
1343 var txt = "???";
1344 if (LANG[LID]) {
1345 if (LANG[LID][category]) {
1346 if (LANG[LID][category][name]) {
1347 txt = LANG[LID][category][name];
1348 } else {
1349 if (LANG.en[category]) {
1350 if (LANG.en[category][name]) {
1351 txt = LANG.en[category][name];
1352 }
1353 }
1354 }
1355 } else {
1356 if (LANG.en[category]) {
1357 if (LANG.en[category][name]) {
1358 txt = LANG.en[category][name];
1359 }
1360 }
1361 }
1362 } else {
1363 if (LANG.en[category]) {
1364 if (LANG.en[category][name]) {
1365 txt = LANG.en[category][name];
1366 }
1367 }
1368 }
1369 return txt;
1370 }
1371
1372 /*******************************************************************************************************************************
1373 * Settings
1374 *******************************************************************************************************************************/
1375
1376 // (De)activation of the features
1377 var options_def = {
1378 bir: true, // Biremes counter
1379 ava: true, // Available units
1380 sml: true, // Smileys
1381 str: true, // Unit strength
1382 tra: true, // Transport capacity
1383 per: true, // Percentual Trade
1384 rec: true, // Recruiting Trade
1385 way: true, // Troop speed
1386 cnt: true, // Attack/support counter
1387 sim: true, // Simulator
1388 spl: true, // Spell box
1389 act: false,// Activity boxes
1390 tsk: true, // Task bar
1391 cha: true, // Chat
1392 pop: true, // Favor popup
1393 bbc: true, // BBCode bar
1394 com: true, // Unit comparison
1395 tic: true, // Town icons
1396 til: true, // Town icons: Town list
1397 tim: true, // Town icons: Map
1398 wwc: true, // World wonder counter
1399 wwr: true, // World wonder ranking
1400 wwi: true, // World wonder icons
1401 con: true, // Context menu
1402 sen: true, // Sent units
1403 tov: false,// Town overview
1404 scr: true, // Mausrad,
1405
1406 err: false,// Error Reports
1407 her: true // Thrakische Eroberung
1408 };
1409
1410 if (uw.location.pathname.indexOf("game") >= 0) {
1411 for (var opt in options_def) {
1412 if (options_def.hasOwnProperty(opt)) {
1413 if (DATA.options[opt] === undefined) {
1414 DATA.options[opt] = options_def[opt];
1415 }
1416 }
1417 }
1418 }
1419
1420 var version_text = '', version_color = 'black';
1421
1422 function getLatestVersion() {
1423 $('<style id="dio_version">' +
1424 '#version_info .version_icon { background: url(http://666kb.com/i/ct1etaz0uyohw402i.png) -50px -50px no-repeat; width:25px; height:25px; float:left; } ' +
1425 '#version_info .version_icon.red { filter:hue-rotate(-100deg); -webkit-filter: hue-rotate(-100deg); } ' +
1426 '#version_info .version_icon.green { filter:hue-rotate(0deg); -webkit-filter: hue-rotate(0deg); } ' +
1427 '#version_info .version_icon.blue { filter:hue-rotate(120deg); -webkit-filter: hue-rotate(120deg); } ' +
1428 '#version_info .version_text { line-height: 2; margin: 0px 6px 0px 6px; float: left;} ' +
1429 '</style>').appendTo("head");
1430
1431 var v_info = $('#version_info');
1432 if (version_text === '') {
1433 $.ajax({
1434 type: "GET", url: "https://diotools.de/scripts/version.php",
1435 success: function (response) {
1436 var latest_version = parseFloat(response),
1437 current_version = parseFloat(version);
1438
1439 if (current_version < latest_version) {
1440 version_text = "<div class='version_icon red'></div><div class='version_text'>" + getText('settings', 'version_old') + "</div><div class='version_icon red'></div>" +
1441 '<a class="version_text" href="https://diotools.de/downloads/DIO-TOOLS.user.js" target="_blank">--> Update</a>';
1442 version_color = 'crimson';
1443 } else if (current_version == latest_version) {
1444 version_text = "<div class='version_icon green'></div><div class='version_text'>" + getText('settings', 'version_new') + "</div><div class='version_icon green'></div>";
1445 version_color = 'darkgreen';
1446 } else {
1447 version_text = "<div class='version_icon blue'></div><div class='version_text'>" + getText('settings', 'version_dev') + "</div><div class='version_icon blue'></div>";
1448 version_color = 'darkblue';
1449 }
1450 v_info.html(version_text).css({color: version_color});
1451 }
1452 });
1453 } else {
1454 v_info.html(version_text).css({color: version_color});
1455 }
1456 }
1457
1458 // Add DIO-Tools to grepo settings
1459 function settings() {
1460 var wid = $(".settings-menu").get(0).parentNode.id;
1461
1462 if (!$("#dio_tools").get(0)) {
1463 $(".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>');
1464 }
1465
1466 $(".settings-link").click(function () {
1467 $('.section').each(function () {
1468 this.style.display = "block";
1469 });
1470 $('.settings-container').removeClass("dio_overflow");
1471
1472 $('#dio_bg_medusa').css({display: "none"});
1473
1474 if ($('#dio_settings').get(0)) {
1475 $('#dio_settings').get(0).style.display = "none";
1476 }
1477 });
1478
1479 $("#dio_tools").click(function () {
1480 if ($('.email').get(0)) {
1481 $('.settings-container').removeClass("email");
1482 }
1483
1484 $('.settings-container').addClass("dio_overflow");
1485
1486 $('#dio_bg_medusa').css({display: "block"});
1487
1488 if (!$('#dio_settings').get(0)) {
1489 // Styles
1490 $('<style id="dio_settings_style">' +
1491 // Chrome Scroollbar Style
1492 '#dio_settings ::-webkit-scrollbar { width: 13px; } ' +
1493 '#dio_settings ::-webkit-scrollbar-track { background-color: rgba(130, 186, 135, 0.5); border-top-right-radius: 4px; border-bottom-right-radius: 4px; } ' +
1494 '#dio_settings ::-webkit-scrollbar-thumb { background-color: rgba(87, 121, 45, 0.5); border-radius: 3px; } ' +
1495 '#dio_settings ::-webkit-scrollbar-thumb:hover { background-color: rgba(87, 121, 45, 0.8); } ' +
1496
1497 '#dio_settings table tr :first-child { text-align:center; vertical-align:top; } ' +
1498
1499 '#dio_settings #version_info { font-weight:bold;height: 35px;margin-top:-5px; } ' +
1500 '#dio_settings #version_info img { margin:-1px 2px -8px 0px; } ' +
1501
1502 '#dio_settings .icon_types_table { font-size:0.7em; line-height:2.5; border:1px solid green; border-spacing:10px 2px; border-radius:5px; } ' +
1503 '#dio_settings .icon_types_table td { text-align:left; } ' +
1504
1505 '#dio_settings table p { margin:0.2em 0em; } ' +
1506
1507 '#dio_settings .checkbox_new .cbx_caption { white-space:nowrap; margin-right:10px; font-weight:bold; } ' +
1508
1509 '#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;} ' +
1510
1511 '#dio_settings .dio_settings_tabs li { float:left; } ' +
1512
1513 '#dio_settings .icon_small { margin:0px; } ' +
1514
1515 '#dio_settings img { max-width:90px; max-height:90px; margin-right:10px; } ' +
1516
1517 '#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; } ' +
1518 '#dio_settings .content .content_category { display:none; border-spacing:5px; } ' +
1519
1520 '#dio_settings .dio_options_table legend { font-weight:bold; } ' +
1521 '#dio_settings .dio_options_table p { margin:0px; } ' +
1522 '#dio_settings #donate_btn { filter: hue-rotate(45deg); -webkit-filter: hue-rotate(45deg); } ' +
1523
1524 '#donate_btn { background: url(' + dio_sprite + '); width:100px; height:26px; background-position: 0px -300px; } ' +
1525 '#donate_btn.de { background-position: 0px -250px; } ' +
1526 '#donate_btn.en { background-position: 0px -300px; } ' +
1527
1528 '#dio_hall table { border-spacing: 9px 3px; } ' +
1529 '#dio_hall table th { text-align:left !important;color:green;text-decoration:underline;padding-bottom:10px; } ' +
1530 '#dio_hall table td.value { text-align: right; } ' +
1531
1532 '#dio_hall table td.laurel.green { background: url("/images/game/ally/founder.png") no-repeat; height:18px; width:18px; background-size:100%; } ' +
1533 '#dio_hall table td.laurel.bronze { background: url("https://diotools.de/images/game/laurel_sprite.png") no-repeat 25%; height:18px; width:18px; } ' +
1534 '#dio_hall table td.laurel.silver { background: url("https://diotools.de/images/game/laurel_sprite.png") no-repeat 50%; height:18px; width:18px; } ' +
1535 '#dio_hall table td.laurel.gold { background: url("https://diotools.de/images/game/laurel_sprite.png") no-repeat 75%; height:18px; width:18px; } ' +
1536 '#dio_hall table td.laurel.blue { background: url("https://diotools.de/images/game/laurel_sprite.png") no-repeat 100%; height:18px; width:18px; } ' +
1537 '</style>').appendTo('head');
1538
1539
1540 $('.settings-container').append(
1541 '<div id="dio_settings" class="player_settings section"><div id="dio_bg_medusa"></div>' +
1542 '<div class="game_header bold"><a href="#" target="_blank" style="color:white">DIO-Tools (v' + version + ')</a></div>' +
1543
1544 // Check latest version
1545 '<div id="version_info"><img src="http://666kb.com/i/csmicltyu4zhiwo5b.gif" /></div>' +
1546
1547 // Donate button
1548 '<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">' +
1549 '<div id="donate_btn" class="' + LID + '" alt="Donate"></div></a></div>' +
1550
1551 // Settings navigation
1552 '<ul class="menu_inner dio_settings_tabs">' +
1553 '<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>' +
1554 '<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>' +
1555 '<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>' +
1556 '<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>' +
1557 '<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>' +
1558 '<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>' +
1559 '<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>' +
1560 '</ul>' +
1561
1562 // Settings content
1563 '<DIV class="content">' +
1564
1565 // Units tab
1566 '<table id="dio_units_table" class="content_category visible"><tr>' +
1567 '<td><img src="https://diotools.de/images/game/settings/units/available_units.png" alt="" /></td>' +
1568 '<td><div id="ava" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "ava")[0] + '</div></div>' +
1569 '<p>' + getText("options", "ava")[1] + '</p></td>' +
1570 '</tr><tr>' +
1571 '<td><img src="https://diotools.de/images/game/settings/units/sent_units.png" alt="" /></td>' +
1572 '<td><div id="sen" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "sen")[0] + '</div></div>' +
1573 '<p>' + getText("options", "sen")[1] + '</p></td>' +
1574 '</tr><tr>' +
1575 '<td><img src="https://diotools.de/images/game/settings/units/unit_strength.png" alt="" /></td>' +
1576 '<td><div id="str" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "str")[0] + '</div></div>' +
1577 '<p>' + getText("options", "str")[1] + '</p></td>' +
1578 '</tr><tr>' +
1579 '<td><img src="https://diotools.de/images/game/settings/units/transport_capacity.png" alt="" /></td>' +
1580 '<td><div id="tra" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "tra")[0] + '</div></div>' +
1581 '<p>' + getText("options", "tra")[1] + '</p></td>' +
1582 '</tr><tr>' +
1583 '<td><img src="https://diotools.de/images/game/settings/units/unit_comparison.png" alt="" /></td>' +
1584 '<td><div id="com" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "com")[0] + '</div></div>' +
1585 '<p>' + getText("options", "com")[1] + '</p></td>' +
1586 '</tr></table>' +
1587
1588 // Icons tab
1589 '<table id="dio_icons_table" class="content_category"><tr>' +
1590 '<td><img src="https://diotools.de/images/game/settings/townicons/townicons.png" alt="" /></td>' +
1591 '<td><div id="tic" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "tic")[0] + '</div></div>' +
1592 '<p>' + getText("options", "tic")[1] + '</p>' +
1593 '<table class="icon_types_table">' +
1594 '<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>' +
1595 '<tr><td><div class="icon_small townicon_ld"></div> Land Defensive</td>' + '<td><div class="icon_small townicon_fd"></div> Fly Defensive</td></tr>' +
1596 '<tr><td><div class="icon_small townicon_so"></div> Navy Offensive</td>' + '<td><div class="icon_small townicon_no"></div> Outside</td></tr>' +
1597 '<tr><td><div class="icon_small townicon_sd"></div> Navy Defensive</td>' + '<td><div class="icon_small townicon_po"></div> Empty</td></tr>' +
1598 '</table><br>' +
1599 '<p>' + getText("options", "tic")[2] + ':</p>' +
1600 '<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>' +
1601 '<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>' +
1602 '<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>' +
1603 '<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>' +
1604 '<div class="icon_small townicon_wo"></div>' +
1605 '</td>' +
1606 '</tr><tr>' +
1607 '<td><img src="https://diotools.de/images/game/settings/townicons/townlist.png" alt="" style="border: 1px solid rgb(158, 133, 78);" /></td>' +
1608 '<td><div id="til" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "til")[0] + '</div></div>' +
1609 '<p>' + getText("options", "til")[1] + '</p></td>' +
1610 '</tr><tr>' +
1611 '<td><img src="https://diotools.de/images/game/settings/townicons/map.png" alt="" /></td>' +
1612 '<td><div id="tim" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "tim")[0] + '</div></div>' +
1613 '<p>' + getText("options", "tim")[1] + '</p></td>' +
1614 '</tr></table>' +
1615
1616 // Forum tab
1617 '<table id="dio_forum_table" class="content_category"><tr>' +
1618 '<td><img src="https://diotools.de/images/game/settings/forum/smiley_box.png" alt="" /></td>' +
1619 '<td><div id="sml" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "sml")[0] + '</div></div>' +
1620 '<p>' + getText("options", "sml")[1] + '</p>' +
1621 '<img src="http://www.greensmilies.com/smile/smiley_emoticons_mttao_wassermann.gif" /> <img src="http://666kb.com/i/cigrqlp2odi2kqo24.gif" /> ' +
1622 '<img src="http://666kb.com/i/cifvfsu3e2sdiipn0.gif" alt="" /> <img src="http://666kb.com/i/cigmv8wnffb3v0ifg.gif" /> ' +
1623 '<img src="http://666kb.com/i/cj2byjendffymp88t.gif" alt="" /> <img src="http://666kb.com/i/cj1l9gndtu3nduyvi.gif" /> ' +
1624 '<img src="http://666kb.com/i/cigrmpfofys5xtiks.gif" alt="" />' + //'<img src="http://666kb.com/i/cifohielywpedbyh8.gif" />'+
1625 '<br><br><br></td>' +
1626 '</tr><tr>' +
1627 '<td><img src="https://diotools.de/images/game/settings/forum/def_formular.png" alt="" /></td>' +
1628 '<td><div id="bbc" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "bbc")[0] + '</div></div>' +
1629 '<p>' + getText("options", "bbc")[1] + '</p><br><img src="http://s1.directupload.net/images/140401/9b2ydh82.png" alt="" style="max-width:none !important;" /></td>' +
1630 '</tr></table>' +
1631
1632 // Trade tab
1633 '<table id="dio_trade_table" class="content_category"><tr>' +
1634 '<td><img src="https://diotools.de/images/game/settings/trade/recruiting_trade.png" /></td>' +
1635 '<td><div id="rec" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "rec")[0] + '</div></div>' +
1636 '<p>' + getText("options", "rec")[1] + '</p><br>' +
1637 /*
1638 '<p><u>Beispiel Feuerschiffe:</u><br>'+
1639 '<p>Verhältnisauswahl</p>'+
1640 '<table style="font-size: 0.7em;line-height: 2.5;border: 1px solid green;border-spacing: 10px 2px;border-radius: 5px;">'+
1641 '<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>'+
1642 '<tr><td>Kosten</td><td>1300</td><td></td><td>300</td><td></td><td>800</td></tr>'+
1643 '<tr><td>Verhältnis</td><td>1</td><td>:</td><td>0.23</td><td>:</td><td>0.62</td></tr>'+
1644 '</table>'+
1645 '<p>Lagergröße Zielstadt: 25500 - 1000 Puffer (=100%)</p>'+
1646 '<p>Handelsmenge 25%: </p>'+
1647 '<table style="font-size: 0.7em;line-height: 2.5;">'+
1648 '<tr><td>4 x 25%</td><td>4 x 25%</td><td>...</td></tr>'+
1649 '<tr><td><img src="http://s7.directupload.net/images/140920/uc4dsyp9.png" style="width:60px" /></td>'+
1650 '<td><img src="http://s7.directupload.net/images/140920/uc4dsyp9.png" style="width:60px" /></td><td>...</td></tr>'+
1651 '</table>'+
1652 //'- 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'+
1653 //'- nach Ankommen von jeweils 5 Portionen, Einheiten in Auftrag geben (19-21 Feuerschiffe bei maximaler Lagerkapazität)'+
1654 //'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.'+
1655 //'Das Ganze beschleunigt das Befüllen der Rekrutierungsschleifen enorm und es gehen dabei keine Rohstoffe verloren.</p>'+
1656 '<br><br><br></td>'+
1657 */
1658 '</tr><tr>' +
1659 '<td><img src="https://diotools.de/images/game/settings/trade/percentage_trade.png" /></td>' +
1660 '<td><div id="per" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "per")[0] + '</div></div>' +
1661 '<p>' + getText("options", "per")[1] + '</p><br></td>' +
1662 /*
1663 '</tr><tr>'+
1664 '<td><img src="http://s7.directupload.net/images/140917/tveb5n33.png" /></td>'+
1665 '<td><div id="trd2" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">Trade Limit Marker</div></div>'+
1666 '<p></p></td>'+
1667 */
1668 '</tr></table>' +
1669
1670 // World wonder tab
1671 '<table id="dio_wonder_table" class="content_category"><tr>' +
1672 '<td><img src="https://diotools.de/images/game/settings/wonders/share.png" alt="" /></td>' +
1673 '<td><div id="wwc" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "wwc")[0] + '</div></div>' +
1674 '<p>' + getText("options", "wwc")[1] + '</p><br/>' +
1675 '<img src="https://diotools.de/images/game/settings/wonders/share_calculator.png" alt="" style="max-width:none !important;" /></td>' +
1676 '</tr><tr>' +
1677 '<td><img src="https://diotools.de/images/game/settings/wonders/ranking.png" alt="" /></td>' +
1678 '<td><div id="wwr" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "wwr")[0] + '</div></div>' +
1679 '<p>' + getText("options", "wwr")[1] + '</p></td>' +
1680 '</tr><tr>' +
1681 '<td><img src="https://diotools.de/images/game/settings/wonders/icons.png" alt="" /></td>' +
1682 '<td><div id="wwi" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "wwi")[0] + '</div></div>' +
1683 '<p>' + getText("options", "wwi")[1] + '</p></td>' +
1684 '</tr></table>' +
1685
1686 // Layout tab
1687 '<table id="dio_layout_table" class="content_category"><tr>' +
1688 '<td><img src="https://diotools.de/images/game/settings/layout/simulator.png" alt="" /></td>' +
1689 '<td><div id="sim" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "sim")[0] + '</div></div>' +
1690 '<p>' + getText("options", "sim")[1] + '</p></td>' +
1691 '</tr><tr>' +
1692 '<td><img src="https://diotools.de/images/game/settings/layout/spellbox.png" alt="" /></td>' +
1693 '<td><div id="spl" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "spl")[0] + '</div></div>' +
1694 '<p>' + getText("options", "spl")[1] + '</p></td>' +
1695 '</tr><tr>' +
1696
1697 ((Game.market_id !== "de" && Game.market_id !== "zz") ? (
1698 '<td><img src="https://diotools.de/images/game/settings/layout/taskbar.png" alt="" /></td>' +
1699 '<td><div id="tsk" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "tsk")[0] + '</div></div>' +
1700 '<p>' + getText("options", "tsk")[1] + '</p></td>' +
1701 '</tr><tr>'
1702 ) : "" ) +
1703
1704 '<td><img src="https://diotools.de/images/game/settings/layout/favor_popup.png" alt="" /></td>' +
1705 '<td><div id="pop" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "pop")[0] + '</div></div>' +
1706 '<p>' + getText("options", "pop")[1] + '</p></td>' +
1707 '</tr><tr>' +
1708 '<td><img src="https://diotools.de/images/game/settings/layout/contextmenu.png" alt="" /></td>' +
1709 '<td><div id="con" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "con")[0] + '</div></div>' +
1710 '<p>' + getText("options", "con")[1] + '</p></td>' +
1711 '</tr><tr>' +
1712 '<td><img src="https://diotools.de/images/game/settings/layout/activity_boxes.png" alt="" /></td>' +
1713 '<td><div id="act" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "act")[0] + '</div></div>' +
1714 '<p>' + getText("options", "act")[1] + '</p></td>' +
1715 '</tr></table>' +
1716
1717 // Other Stuff tab
1718 '<table id="dio_other_table" class="content_category"><tr>' +
1719 '<td><img src="https://diotools.de/images/game/settings/misc/troop_speed.png" style="border: 1px solid rgb(158, 133, 78);" alt="" /></td>' +
1720 '<td><div id="way" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "way")[0] + '</div></div>' +
1721 '<p>' + getText("options", "way")[1] + '</p></td>' +
1722 '</tr><tr>' +
1723
1724 // Betaphase in DE
1725 ((Game.market_id === "de" || Game.market_id === "zz") ? (
1726
1727 '<td><img src="https://diotools.de/images/game/settings/misc/chat_new.png" alt="" /></td>' +
1728 '<td><div id="cha" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "cha")[0] + '</div></div>' +
1729 '<p>' + getText("options", "cha")[1] + '</p></td>' +
1730 '</tr><tr>'
1731
1732 ) : "") +
1733
1734 '<td><img src="https://diotools.de/images/game/settings/misc/conquer_counter.png" style="border: 1px solid rgb(158, 133, 78);" alt="" /></td>' +
1735 '<td><div id="cnt" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "cnt")[0] + '</div></div>' +
1736 '<p>' + getText("options", "cnt")[1] + '</p></td>' +
1737 '</tr><tr>' +
1738 '<td><img src="https://diotools.de/images/game/settings/misc/mousewheel_zoom.png" alt="" /></td>' +
1739 '<td><div id="scr" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "scr")[0] + '</div></div>' +
1740 '<p>' + getText("options", "scr")[1] + '</p><br><br></td>' +
1741 '</tr><tr>' +
1742 '<td><img src="" alt="" /></td>' +
1743 '<td><div id="err" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "err")[0] + '</div></div>' +
1744 '<p>' + getText("options", "err")[1] + '</p></td>' +
1745 '</tr></table>' +
1746
1747
1748 // Hall of DIO-Tools tab
1749 '<div id="dio_hall" class="content_category">'+
1750 "<p>I like to thank all of you who helped the development of DIO-Tools by donating or translating!</p>"+
1751 '<table style="float:left;margin-right: 75px;">'+
1752 '<tr><th colspan="3">Donations</th></tr>'+
1753 (function(){
1754 var donations = [
1755 ["Eduard R", 50],
1756 ["Gregoire L", 25],
1757 ["Renee A", 20], ["Dirk R", 20], ["Patti T", 20],
1758 ["Klaus N", 15],
1759 ["Marco S", 10], ["Richard L", 10], ["Carsten K", 10], ["Tatiana H", 10], ["Ursula S", 10], ["Susanne S", 10], ["Falk T", 10],
1760 ["Belinda M", 8], ["Wolfgang R", 8],
1761 ["Miguel B", 7],
1762 ["Antje S", 5], ["Hans-Jörg S", 5], ["Deanna P", 5], ["ForexTraction", 5], ["Rene F", 5], ["Rüdiger D", 5], ["Hans Hermann S", 5],
1763 ["Siegbert M", 5], ["Wilhelm B", 5], ["Peter P", 5], ["Helga W", 5], ["Lydia R", 5],
1764 ["Michael S", 3],
1765 ["Mario P", 2], ["Artur G", 2], ["Heiko K", 2], ["Alexander B", 2], ["Dick N", 2],
1766 ["Marcel G", 1], ["Ramona L", 1], ["Dennis S", 1], ["Konstandinos K", 1], ["Sarl T", 1], ["Jagadics I", 1], ["Andreas R", 1],
1767 ["Peter F", 1], ["Vinicio G", 1], ["Marielle M", 1], ["Christian B", 1], ["Bernd W", 1], ["Maria N", 1], ["Thomas W", 1],
1768 ["Domenik F", 1], ["Oliver H", 1], ["Jens R", 1], ["Nicole S", 1], ["Hartmut S", 1], ["Alex L", 1], ["Andreas S", 1]
1769 ];
1770 var donation_table = "";
1771
1772 for(var d = 0; d < donations.length; d++){
1773
1774 var donation_class = "";
1775
1776 switch(donations[d][1]){
1777 case 50: donation_class = "gold"; break;
1778 case 25: donation_class = "silver"; break;
1779 case 20: donation_class = "bronze"; break;
1780 default: donation_class = "green"; break;
1781 }
1782
1783 donation_table += '<tr class="donation"><td class="laurel '+ donation_class +'"></td><td>' + donations[d][0] + '</td><td class="value">' + donations[d][1] + '€</td></tr>';
1784 }
1785
1786 return donation_table;
1787 })() +
1788 '</table>'+
1789 '<table>'+
1790 '<tr><th colspan="3">Translations</th></tr>'+
1791 (function(){
1792 var translations = [
1793 ["eclat49", "FR"],
1794 ["MrBobr", "RU"],
1795 ["anpu", "PL"],
1796 ["Juana de Castilla", "ES"],
1797 ["HELL", "BR"],
1798 ["Piwus", "CZ"]
1799 ];
1800
1801 var translation_table = "";
1802
1803 for(var d = 0; d < translations.length; d++){
1804 translation_table += '<tr class="translation"><td class="laurel blue"></td><td >' + translations[d][0] + '</td><td class="value">' + translations[d][1] + '</td></tr>';
1805 }
1806
1807 return translation_table;
1808 })() +
1809 '</table>'+
1810 '</div>' +
1811
1812 '</DIV>' +
1813
1814 // Links (Forum, PM, ...)
1815 '<div style="bottom: -50px;font-weight: bold;position: absolute;width: 99%;">' +
1816
1817 '<a id="hall_of_diotools" href="#" style="font-weight:bold; float:left">' +
1818 '<img src="/images/game/ally/founder.png" alt="" style="float:left;height:19px;margin:0px 5px -3px;"><span>Hall of DIO-Tools</span></a>' +
1819
1820 '<span class="bbcodes_player bold" style="font-weight:bold; float:right; margin-left:20px;">' + getText("settings", "author") + ': ' +
1821 '<a id="link_contact" href=' + getText("settings", "link_contact") + ' target="_blank">Diony</a></span>' +
1822
1823 '<a id="link_forum" href=' + getText("settings", "link_forum") + ' target="_blank" style="font-weight:bold; float:right">' +
1824 '<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>' +
1825
1826 '</div>' +
1827
1828 '</div></div>');
1829
1830 getLatestVersion();
1831
1832 // Tab event handler
1833 $('#dio_settings .dio_settings_tabs .submenu_link').click(function () {
1834 if (!$(this).hasClass("active")) {
1835 $('#dio_settings .dio_settings_tabs .submenu_link.active').removeClass("active");
1836 $(this).addClass("active");
1837 $("#dio_settings .visible").removeClass("visible");
1838 $("#" + this.id + "_table").addClass("visible");
1839 }
1840 });
1841
1842 //
1843 $('#hall_of_diotools').click(function () {
1844 $('#dio_settings .dio_settings_tabs .submenu_link.active').removeClass("active");
1845
1846 $("#dio_settings .visible").removeClass("visible");
1847 $("#dio_hall").addClass("visible");
1848 });
1849
1850 $("#dio_settings .checkbox_new").click(function () {
1851 $(this).toggleClass("checked").toggleClass("disabled").toggleClass("green");
1852 toggleActivation(this.id);
1853
1854 DATA.options[this.id] = $(this).hasClass("checked");
1855
1856 saveValue("options", JSON.stringify(DATA.options));
1857 });
1858 for (var e in DATA.options) {
1859 if (DATA.options.hasOwnProperty(e)) {
1860 if (DATA.options[e] === true) {
1861 $("#" + e).addClass("checked").addClass("green");
1862 } else {
1863 $("#" + e).addClass("disabled");
1864 }
1865 }
1866 }
1867
1868 $('#dio_save').click(function () {
1869 $('#dio_settings .checkbox_new').each(function () {
1870 var act = false;
1871 if ($("#" + this.id).hasClass("checked")) {
1872 act = true;
1873 }
1874 DATA.options[this.id] = act;
1875 });
1876 saveValue("options", JSON.stringify(DATA.options));
1877 });
1878 }
1879 $('.section').each(function () {
1880 this.style.display = "none";
1881 });
1882 $('#dio_settings').get(0).style.display = "block";
1883 });
1884 }
1885
1886 function toggleActivation(opt) {
1887 var FEATURE, activation = true;
1888 switch (opt) {
1889 case "sml":
1890 FEATURE = SmileyBox;
1891 break;
1892 case "bir":
1893 FEATURE = BiremeCounter;
1894 break;
1895 case "str":
1896 FEATURE = UnitStrength.Menu;
1897 break;
1898 case "tra":
1899 FEATURE = TransportCapacity;
1900 break;
1901 case "ava":
1902 FEATURE = AvailableUnits;
1903 break;
1904 case "sim":
1905 FEATURE = Simulator;
1906 break;
1907 case "spl":
1908 FEATURE = Spellbox;
1909 break;
1910 case "tsk":
1911 FEATURE = Taskbar;
1912 break;
1913 case "scr":
1914 FEATURE = MouseWheelZoom;
1915 break;
1916 case "cha":
1917 FEATURE = Chat;
1918 break;
1919 case "com":
1920 FEATURE = UnitComparison;
1921 break;
1922 case "pop":
1923 FEATURE = FavorPopup;
1924 break;
1925 case "con":
1926 FEATURE = ContextMenu;
1927 break;
1928 case "tic":
1929 FEATURE = TownIcons;
1930 break;
1931 case "tim":
1932 FEATURE = TownIcons.Map;
1933 break;
1934 case "til":
1935 FEATURE = TownList;
1936 break;
1937 case "sen":
1938 FEATURE = SentUnits;
1939 break;
1940 case "act":
1941 FEATURE = ActivityBoxes;
1942 break;
1943 case "wwc":
1944 FEATURE = WorldWonderCalculator;
1945 break;
1946 case "wwr":
1947 FEATURE = WorldWonderRanking;
1948 break;
1949 case "wwi":
1950 FEATURE = WorldWonderIcons;
1951 break;
1952 case "pom":
1953 FEATURE = PoliticalMap;
1954 break;
1955 case "rec":
1956 FEATURE = RecruitingTrade;
1957 break;
1958 case "way":
1959 FEATURE = ShortDuration;
1960 break;
1961
1962 default:
1963 activation = false;
1964 break;
1965 }
1966 if (activation) {
1967 if (DATA.options[opt]) {
1968 FEATURE.deactivate();
1969 } else {
1970 FEATURE.activate();
1971 }
1972 }
1973 }
1974
1975 function addSettingsButton() {
1976 var tooltip_str = "DIO-Tools: " + (DM.getl10n("layout", "config_buttons").settings || "Settings");
1977
1978 $('<div class="btn_settings circle_button dio_settings"><div class="dio_icon js-caption"></div></div>').appendTo(".gods_area");
1979
1980 // Style
1981 $('<style id="dio_settings_button" type="text/css">' +
1982 '#ui_box .btn_settings.dio_settings { top:95px; right:103px; z-index:10; } ' +
1983 '#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% } ' +
1984 '#ui_box .dio_settings .dio_icon.click { margin-top:8px; }' +
1985 '</style>').appendTo('head');
1986
1987 // Tooltip
1988 $('.dio_settings').tooltip(tooltip_str);
1989
1990 // Mouse Events
1991 $('.dio_settings').on('mousedown', function () {
1992 $('.dio_icon').addClass('click');
1993 });
1994 $('.dio_settings').on('mouseup', function () {
1995 $('.dio_icon').removeClass('click');
1996 });
1997 $('.dio_settings').click(openSettings);
1998 }
1999
2000 var diosettings = false;
2001
2002 function openSettings() {
2003 if (!GPWindowMgr.getOpenFirst(Layout.wnd.TYPE_PLAYER_SETTINGS)) {
2004 diosettings = true;
2005 }
2006 Layout.wnd.Create(GPWindowMgr.TYPE_PLAYER_SETTINGS, 'Settings');
2007 }
2008
2009 var exc = false, sum = 0, ch = ["IGCCJB"], alpha = 'ABCDEFGHIJ';
2010
2011 function a() {
2012 var pA = PID.toString(), pB = "";
2013
2014 for (var c in pA) {
2015 if (pA.hasOwnProperty(c)) {
2016 pB += alpha[pA[parseInt(c, 10)]];
2017 }
2018 }
2019
2020 sum = 0;
2021 for (var b in ch) {
2022 if (ch.hasOwnProperty(b)) {
2023 if (pB !== ch[b]) {
2024 exc = true;
2025 } else {
2026 exc = false;
2027 return;
2028 }
2029 for (var s in ch[b]) {
2030 if (ch[b].hasOwnProperty(s)) {
2031 sum += alpha.indexOf(ch[b][s]);
2032 }
2033 }
2034 }
2035 }
2036 }
2037
2038
2039 var autoTownTypes, manuTownTypes, population, sentUnitsArray, biriArray, spellbox, commandbox, tradebox, wonder, wonderTypes;
2040
2041 function setStyle() {
2042 // Settings
2043 $('<style id="dio_settings_style" type="text/css">' +
2044 '#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;} ' +
2045 '.dio_overflow { overflow: hidden; } ' +
2046 '#dio_icon { width:15px; vertical-align:middle; margin-top:-2px; } ' +
2047 '#quackicon { width:15px !important; vertical-align:middle !important; margin-top:-2px; height:12px !important; } ' +
2048 '#dio_settings .green { color: green; } ' +
2049 '#dio_settings .visible { display:block !important; } ' +
2050 '</style>').appendTo('head');
2051
2052 // Town Icons
2053 $('<style id="dio_icons" type="text/css">.icon_small { position:relative; height:20px; width:25px; margin-left:-25px; }</style>').appendTo('head');
2054
2055 // Tutorial-Quest Container
2056 $('<style id="dio_quest_container" type="text/css"> #tutorial_quest_container { top: 130px } </style>').appendTo('head');
2057
2058 // Velerios
2059 $('<style id="dio_velerios" type="text/css"> #ph_trader_image { background-image: url(http://s14.directupload.net/images/140826/mh8k8nyw.jpg); } </style>').appendTo('head');
2060 // http://s7.directupload.net/images/140826/bgqlsdrf.jpg
2061
2062 // Specific player wishes
2063 if (PID == 1212083) {
2064 $('<style id="dio_wishes" type="text/css"> #world_end_info { display: none; } </style>').appendTo('head');
2065 }
2066 }
2067
2068 function loadFeatures() {
2069 if (typeof(ITowns) !== "undefined") {
2070
2071 autoTownTypes = {};
2072 manuTownTypes = DATA.townTypes;
2073 population = {};
2074
2075 sentUnitsArray = DATA.sentUnits;
2076 biriArray = DATA.biremes;
2077
2078 spellbox = DATA.spellbox;
2079 commandbox = DATA.commandbox;
2080 tradebox = DATA.tradebox;
2081
2082 wonder = DATA.worldWonder;
2083 wonderTypes = DATA.worldWonderTypes;
2084
2085 var DIO_USER = {'name': uw.Game.player_name, 'market': MID};
2086 saveValue("dio_user", JSON.stringify(DIO_USER));
2087
2088
2089 $.Observer(uw.GameEvents.game.load).subscribe('DIO_START', function (e, data) {
2090 a();
2091
2092 // English => default language
2093 if (!LANG[LID]) {
2094 LID = "en";
2095 }
2096
2097 if ((ch.length == 1) && exc && (sum == 28)) {
2098 // AJAX-EVENTS
2099 setTimeout(function () {
2100 ajaxObserver();
2101 }, 0);
2102
2103 addSettingsButton();
2104
2105 addFunctionToITowns();
2106
2107 if (DATA.options.tsk) {
2108 setTimeout(function () {
2109 minimizeDailyReward();
2110
2111 if(Game.market_id !== "de" && Game.market_id !== "zz") {
2112 Taskbar.activate();
2113 }
2114 }, 0);
2115 }
2116
2117 //addStatsButton();
2118
2119 fixUnitValues();
2120
2121 setTimeout(function () {
2122
2123 var waitCount = 0;
2124
2125 // No comment... it's Grepolis... i don't know... *rolleyes*
2126 function waitForGrepoLazyLoading() {
2127 if (typeof(ITowns.townGroups.getGroupsDIO()[-1]) !== "undefined" && typeof(ITowns.getTown(Game.townId).getBuildings) !== "undefined") {
2128
2129 try {
2130 // Funktion wird manchmal nicht ausgeführt:
2131 var units = ITowns.getTown(Game.townId).units();
2132
2133
2134 getAllUnits();
2135
2136 setInterval(function () {
2137 getAllUnits();
2138 }, 900000); // 15min
2139
2140 setInterval(function () {
2141 UnitCounter.count();
2142 }, 600000); // 10min
2143
2144 if (DATA.options.ava) {
2145 setTimeout(function () {
2146 AvailableUnits.activate();
2147 }, 0);
2148 }
2149 if (DATA.options.tic) {
2150 setTimeout(function () {
2151 TownIcons.activate();
2152 TownPopup.activate();
2153 }, 0);
2154 }
2155 if (DATA.options.tim) {
2156 setTimeout(function () {
2157 TownIcons.Map.activate();
2158 }, 0);
2159 }
2160 if (DATA.options.til) {
2161 setTimeout(function () {
2162 TownList.activate();
2163 }, 0);
2164 }
2165
2166 HiddenHighlightWindow.activate();
2167
2168
2169 } catch(e){
2170 if(waitCount < 12) {
2171 waitCount++;
2172
2173 console.warn("DIO-Tools | Fehler | getAllUnits | units() fehlerhaft ausgeführt?", e);
2174
2175 // Ausführung wiederholen
2176 setTimeout(function () {
2177 waitForGrepoLazyLoading();
2178 }, 5000); // 5s
2179 }
2180 else {
2181 errorHandling(e, "waitForGrepoLazyLoading2");
2182 }
2183 }
2184 }
2185 else {
2186 var e = { "stack": "getGroups() = " + typeof(ITowns.townGroups.getGroupsDIO()[-1]) + ", getBuildings() = " + typeof(ITowns.getTown(Game.townId).getBuildings) };
2187
2188 if(waitCount < 12) {
2189 waitCount++;
2190
2191 console.warn("DIO-Tools | Fehler | getAllUnits | " + e.stack);
2192
2193 // Ausführung wiederholen
2194 setTimeout(function () {
2195 waitForGrepoLazyLoading();
2196 }, 5000); // 5s
2197 }
2198 else {
2199
2200
2201 errorHandling(e, "waitForGrepoLazyLoading2");
2202 }
2203 }
2204 }
2205
2206 waitForGrepoLazyLoading();
2207
2208 }, 0);
2209
2210 if (DATA.options.pop) {
2211 setTimeout(function () {
2212 FavorPopup.activate();
2213 }, 0);
2214 }
2215 if (DATA.options.spl) {
2216 setTimeout(function () {
2217 Spellbox.activate();
2218 }, 0);
2219 }
2220
2221 imageSelectionProtection();
2222
2223 if (DATA.options.con) {
2224 setTimeout(function () {
2225 ContextMenu.activate();
2226 }, 0);
2227 }
2228
2229 if (DATA.options.act) {
2230 setTimeout(function () {
2231 ActivityBoxes.activate();
2232 }, 0);
2233 }
2234
2235 if (DATA.options.str) {
2236 setTimeout(function () {
2237 UnitStrength.Menu.activate();
2238 hideNavElements();
2239 }, 0);
2240 }
2241
2242 if (DATA.options.tra) {
2243 setTimeout(function () {
2244 TransportCapacity.activate();
2245 }, 0);
2246 }
2247
2248 if (DATA.options.com) {
2249 setTimeout(function () {
2250 UnitComparison.activate();
2251 }, 0);
2252 }
2253
2254 if (DATA.options.sml) {
2255 setTimeout(function () {
2256 SmileyBox.activate();
2257 }, 0);
2258 }
2259
2260 if (DATA.options.cha && (Game.market_id === "de" || Game.market_id === "zz")) {
2261 setTimeout(function () {
2262 Chat.activate();
2263 }, 0);
2264 }
2265
2266 if (DATA.options.scr) {
2267 setTimeout(function () {
2268 MouseWheelZoom.activate();
2269 }, 0);
2270 }
2271
2272 if (DATA.options.sim) {
2273 setTimeout(function () {
2274 Simulator.activate();
2275 }, 0);
2276 }
2277
2278 if (DATA.options.sen) {
2279 setTimeout(function () {
2280 SentUnits.activate();
2281 }, 0);
2282 }
2283
2284 if (DATA.options.wwc) {
2285 setTimeout(function () {
2286 WorldWonderCalculator.activate();
2287 }, 0);
2288 }
2289
2290 if(DATA.options.rec) {
2291 setTimeout(function () {
2292 RecruitingTrade.activate();
2293 }, 0);
2294 }
2295
2296 if(DATA.options.way) {
2297 setTimeout(function () {
2298 ShortDuration.activate();
2299 }, 0);
2300 }
2301
2302 if (PID === 84367 || PID === 104769 || PID === 1291505) {
2303 setTimeout(function() {
2304 PoliticalMap.activate();
2305
2306 //PoliticalMap.getAllianceColors();
2307
2308 //Statistics.activate();
2309 }, 0);
2310 }
2311
2312 setTimeout(function () {
2313 counter(uw.Timestamp.server());
2314 setInterval(function () {
2315 counter(uw.Timestamp.server());
2316 }, 21600000);
2317 }, 60000);
2318
2319 // Notifications
2320 setTimeout(function () {
2321 Notification.init();
2322 }, 0);
2323
2324 setTimeout(function(){ HolidaySpecial.activate(); }, 0);
2325
2326
2327 // Execute once to get the world wonder types and coordinates
2328 setTimeout(function () {
2329 if (!wonderTypes.great_pyramid_of_giza) {
2330 getWorldWonderTypes();
2331 }
2332 if (wonderTypes.great_pyramid_of_giza) {
2333 setTimeout(function () {
2334 if (!wonder.map.mausoleum_of_halicarnassus) {
2335 getWorldWonders();
2336 } else {
2337 if (DATA.options.wwi) {
2338 WorldWonderIcons.activate();
2339 }
2340 }
2341 }, 2000);
2342 }
2343 }, 3000);
2344
2345 // Execute once to get alliance ratio
2346 if (wonder.ratio[AID] == -1 || !$.isNumeric(wonder.ratio[AID])) {
2347 setTimeout(function () {
2348 getPointRatioFromAllianceProfile();
2349 }, 5000);
2350 }
2351 }
2352 time_b = uw.Timestamp.client();
2353 //console.log("Gebrauchte Zeit:" + (time_b - time_a));
2354 });
2355 } else {
2356 setTimeout(function () {
2357 loadFeatures();
2358 }, 100);
2359 }
2360 }
2361
2362 if (uw.location.pathname.indexOf("game") >= 0) {
2363 setStyle();
2364
2365 loadFeatures();
2366 }
2367
2368 /*******************************************************************************************************************************
2369 * HTTP-Requests
2370 * *****************************************************************************************************************************/
2371 function ajaxObserver() {
2372 $(document).ajaxComplete(function (e, xhr, opt) {
2373
2374 var url = opt.url.split("?"), action = "";
2375
2376 //console.debug("0: ", url[0]);
2377 //console.debug("1: ", url[1]);
2378
2379 if(typeof(url[1]) !== "undefined" && typeof(url[1].split(/&/)[1]) !== "undefined") {
2380
2381 action = url[0].substr(5) + "/" + url[1].split(/&/)[1].substr(7);
2382 }
2383
2384
2385 if (PID == 84367 || PID == 104769 || PID == 1577066) {
2386 console.log(action);
2387 //console.log((JSON.parse(xhr.responseText).json));
2388 }
2389 switch (action) {
2390 case "/frontend_bridge/fetch": // Daily Reward
2391 //$('.daily_login').find(".minimize").click();
2392 break;
2393 case "/player/index":
2394 settings();
2395 if (diosettings) {
2396 $('#dio_tools').click();
2397 diosettings = false;
2398 }
2399 break;
2400 // Ab Grepolis Version 2.114 ist der Ajax-Request: /frontend_bridge/execute
2401 case "/frontend_bridge/execute":
2402 case "/index/switch_town":
2403 if (DATA.options.str) {
2404 setTimeout(function () {
2405 UnitStrength.Menu.update();
2406 }, 0);
2407 }
2408 if (DATA.options.tra) {
2409 setTimeout(function () {
2410 TransportCapacity.update();
2411 }, 0);
2412 }
2413 if (DATA.options.bir) {
2414 //BiremeCounter.get();
2415 }
2416 if (DATA.options.tic) {
2417 setTimeout(function () {
2418 TownIcons.changeTownIcon();
2419 }, 0);
2420
2421 }
2422 break;
2423 case "/building_docks/index":
2424 if (DATA.options.bir) {
2425 //BiremeCounter.getDocks();
2426 }
2427 break;
2428 case "/building_place/units_beyond":
2429 if (DATA.options.bir) {
2430 //BiremeCounter.getAgora();
2431 }
2432 //addTransporterBackButtons();
2433 break;
2434 case "/building_place/simulator":
2435 if (DATA.options.sim) {
2436 Simulator.change();
2437 }
2438 break;
2439 case "/building_place/simulate":
2440 if (DATA.options.sim) {
2441 afterSimulation();
2442 }
2443 break;
2444
2445 case "/alliance_forum/forum":
2446 case "/message/new":
2447 case "/message/forward":
2448 case "/message/view":
2449 case "/player_memo/load_memo_content":
2450 if (DATA.options.sml) {
2451 SmileyBox.add(action);
2452 }
2453 if (DATA.options.bbc) {
2454 addForm(action);
2455 }
2456 break;
2457 case "/wonders/index":
2458 if (DATA.options.per) {
2459 WWTradeHandler();
2460 }
2461 if (DATA.options.wwc) {
2462 getResWW();
2463 }
2464 break;
2465 case "/wonders/send_resources":
2466 if (DATA.options.wwc) {
2467 getResWW();
2468 }
2469 break;
2470 case "/ranking/alliance":
2471 getPointRatioFromAllianceRanking();
2472 break;
2473 case "/ranking/wonder_alliance":
2474 getPointRatioFromAllianceRanking();
2475 if (DATA.options.wwr) {
2476 WorldWonderRanking.change(JSON.parse(xhr.responseText).plain.html);
2477 }
2478 if (DATA.options.wwi) {
2479 WorldWonderIcons.activate();
2480 }
2481 break;
2482 case "/alliance/members_show":
2483 getPointRatioFromAllianceMembers();
2484 break;
2485 case "/town_info/trading":
2486 addTradeMarks(15, 18, 15, "red");
2487 TownTabHandler(action.split("/")[2]);
2488 break;
2489 case "/town_overviews/trade_overview":
2490 addPercentTrade(1234, false); // TODO
2491 case "/farm_town_overviews/get_farm_towns_for_town":
2492 changeResColor();
2493 break;
2494 case "/command_info/conquest_info":
2495 if (DATA.options.str) {
2496 UnitStrength.Conquest.add();
2497 }
2498 break;
2499 case "/command_info/conquest_movements":
2500 case "/conquest_info/getinfo":
2501 if (DATA.options.cnt) {
2502 countMovements();
2503 }
2504 break;
2505 case "/building_barracks/index":
2506 case "/building_barracks/build":
2507 if (DATA.options.str) {
2508 UnitStrength.Barracks.add();
2509 }
2510 break;
2511 case "/town_info/attack":
2512 case "/town_info/support":
2513 //console.debug(JSON.parse(xhr.responseText));
2514 TownTabHandler(action.split("/")[2]);
2515
2516 break;
2517 case "/report/index":
2518 changeDropDownButton();
2519 loadFilter();
2520 saveFilter();
2521 //removeReports();
2522 break;
2523 case "/report/view":
2524 Statistics.LuckCounter.count();
2525 break;
2526 case "/message/default":
2527 case "/message/index":
2528 break;
2529 case "/town_info/go_to_town":
2530 /*
2531 //console.log(uw.Layout.wnd);
2532 var windo = uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).getID();
2533 //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX));
2534 uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).setPosition([100,400]);
2535 //console.log(windo);
2536 //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).getPosition());
2537 */
2538 break;
2539 }
2540 });
2541 }
2542
2543 function test() {
2544 //http://gpde.innogamescdn.com/images/game/temp/island.png
2545
2546 //console.log(uw.WMap);
2547 //console.log(uw.WMap.getSea(uw.WMap.getXCoord(), uw.WMap.getYCoord()));
2548
2549 //console.log(uw.GameControllers.LayoutToolbarActivitiesController().prototype.getActivityTypes());
2550 //console.log(uw.GameViews);
2551 //console.log(uw.GameViews.BarracksUnitDetails());
2552
2553 //console.log(uw.ITowns.getTown(uw.Game.townId).unitsOuter().sword);
2554 //console.log(uw.ITowns.getCurrentTown().unitsOuter().sword);
2555
2556 //console.log(uw.ITowns.getTown(uw.Game.townId).researches().attributes);
2557 //console.log(uw.ITowns.getTown(uw.Game.townId).hasConqueror());
2558 //console.log(uw.ITowns.getTown(uw.Game.townId).allUnits());
2559 //console.log(uw.ITowns.all_units.fragments[uw.Game.townId]._byId);
2560 //console.log("Zeus: " + uw.ITowns.player_gods.zeus_favor_delta_property.lastTriggeredVirtualPropertyValue);
2561 //console.log(uw.ITowns.player_gods.attributes);
2562
2563 //console.log(uw.ITowns.getTown('5813').createTownLink());
2564 //console.log(uw.ITowns.getTown(5813).unitsOuterTown);
2565
2566 //console.log(uw.ITowns.getTown(uw.Game.townId).getLinkFragment());
2567
2568 //console.log(uw.ITowns.getTown(uw.Game.townId).allGodsFavors());
2569
2570 console.debug("STADTGRUPPEN", Game.constants.ui.town_group);
2571 }
2572
2573 /*******************************************************************************************************************************
2574 * Helping functions
2575 * ----------------------------------------------------------------------------------------------------------------------------
2576 * | ● fixUnitValues: Get unit values and overwrite some wrong values
2577 * | ● getMaxZIndex: Get the highest z-index of "ui-dialog"-class elements
2578 * ----------------------------------------------------------------------------------------------------------------------------
2579 *******************************************************************************************************************************/
2580
2581 // Fix buggy grepolis values
2582 function fixUnitValues() {
2583 //uw.GameData.units.small_transporter.attack = uw.GameData.units.big_transporter.attack = uw.GameData.units.demolition_ship.attack = uw.GameData.units.militia.attack = 0;
2584 //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;
2585 uw.GameData.units.militia.resources = {wood: 0, stone: 0, iron: 0};
2586 }
2587
2588 function getMaxZIndex() {
2589 var maxZ = Math.max.apply(null, $.map($("div[class^='ui-dialog']"), function (e, n) {
2590 if ($(e).css('position') == 'absolute') {
2591 return parseInt($(e).css('z-index'), 10) || 1000;
2592 }
2593 }));
2594 return (maxZ !== -Infinity) ? maxZ + 1 : 1000;
2595 }
2596
2597 function getBrowser() {
2598 var ua = navigator.userAgent,
2599 tem,
2600 M = ua.match(/(opera|maxthon|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
2601 if (/trident/i.test(M[1])) {
2602 tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
2603 M[1] = 'IE';
2604 M[2] = tem[1] || '';
2605 }
2606 if (M[1] === 'Chrome') {
2607 tem = ua.match(/\bOPR\/(\d+)/);
2608 if (tem !== null) {
2609 M[1] = 'Opera';
2610 M[2] = tem[1];
2611 }
2612 }
2613 M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
2614 if ((tem = ua.match(/version\/(\d+)/i)) !== null) M.splice(1, 1, tem[1]);
2615
2616 return M.join(' ');
2617 }
2618
2619 // Error Handling / Remote diagnosis / Automatic bug reports
2620 function errorHandling(e, fn) {
2621 if (PID == 84367 || PID == 104769 || PID === 1291505) {
2622 HumanMessage.error("DIO-TOOLS(" + version + ")-ERROR: " + e.message);
2623 console.log("DIO-TOOLS | Error-Stack | ", e.stack);
2624 } else {
2625 if (!DATA.error[version]) {
2626 DATA.error[version] = {};
2627 }
2628
2629 if (DATA.options.err && !DATA.error[version][fn]) {
2630 $.ajax({
2631 type: "POST",
2632 url: "https://diotools.de/game/error.php",
2633 data: {error: e.stack.replace(/'/g, '"'), "function": fn, browser: getBrowser(), version: version},
2634 success: function (text) {
2635 DATA.error[version][fn] = true;
2636 saveValue("error", JSON.stringify(DATA.error));
2637 }
2638 });
2639 }
2640 }
2641 }
2642
2643 function createWindowType(name, title, width, height, minimizable, position) {
2644 $('<style id="dio_window">' +
2645 '.dio_title_img { height:18px; float:left; margin-right:3px; } ' +
2646 '.dio_title { margin:1px 6px 13px 23px; color:rgb(126,223,126); } ' +
2647 '</style>').appendTo('head');
2648
2649 // Create Window Type
2650 function WndHandler(wndhandle) {
2651 this.wnd = wndhandle;
2652 }
2653
2654 Function.prototype.inherits.call(WndHandler, WndHandlerDefault);
2655 WndHandler.prototype.getDefaultWindowOptions = function () {
2656 return {
2657 position: position,
2658 width: width,
2659 height: height,
2660 minimizable: minimizable,
2661 title: "<img class='dio_title_img' src='http://666kb.com/i/cifvfsu3e2sdiipn0.gif' /><div class='dio_title'>" + title + "</div>"
2662 };
2663 };
2664 GPWindowMgr.addWndType(name, "", WndHandler, 1);
2665 }
2666
2667 // Notification
2668 var Notification = {
2669 init: function () {
2670 // NotificationType
2671 NotificationType.DIO_TOOLS = "diotools";
2672
2673 // Style
2674 $('<style id="dio_notification" type="text/css">' +
2675 '#notification_area .diotools .icon { background: url(http://666kb.com/i/cifvfsu3e2sdiipn0.gif) 4px 7px no-repeat !important;} ' +
2676 '#notification_area .diotools { cursor:pointer; } ' +
2677 '</style>').appendTo('head');
2678
2679 var notif = DATA.notification;
2680 if (notif <= 7) {
2681 //Notification.create(1, 'Swap context menu buttons ("Select town" and "City overview")');
2682 //Notification.create(2, 'Town overview (old window mode)');
2683 //Notification.create(3, 'Mouse wheel: You can change the views with the mouse wheel');
2684 //Notification.create(4, 'Town icons on the strategic map');
2685 //Notification.create(5, 'Percentual unit population in the town list');
2686 //Notification.create(6, 'New world wonder ranking');
2687 //Notification.create(7, 'World wonder icons on the strategic map');
2688
2689 // Click Event
2690 $('.diotools .icon').click(function () {
2691 openSettings();
2692 $(this).parent().find(".close").click();
2693 });
2694
2695 saveValue('notif', '8');
2696 }
2697 },
2698 create: function (nid, feature) {
2699 var Notification = new NotificationHandler();
2700 Notification.notify($('#notification_area>.notification').length + 1, uw.NotificationType.DIO_TOOLS,
2701 "<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>");
2702 }
2703 };
2704
2705 /*******************************************************************************************************************************
2706 * Mousewheel Zoom
2707 *******************************************************************************************************************************/
2708
2709 var MouseWheelZoom = {
2710 // Scroll trough the views
2711 activate: function () {
2712 $('#main_area, #dio_political_map, .viewport, .sjs-city-overview-viewport').bind('mousewheel', function (e) {
2713 e.stopPropagation();
2714 var current = $('.bull_eye_buttons .checked').get(0).getAttribute("name"), delta = 0, scroll, sub_scroll = 6;
2715
2716 switch (current) {
2717 case 'political_map':
2718 scroll = 4;
2719 break;
2720 case 'strategic_map':
2721 scroll = 3;
2722 break;
2723 case 'island_view':
2724 scroll = 2;
2725 break;
2726 case 'city_overview':
2727 scroll = 1;
2728 break;
2729 }
2730 delta = -e.originalEvent.detail || e.originalEvent.wheelDelta; // Firefox || Chrome & Opera
2731
2732 //console.debug("cursor_pos", e.pageX, e.pageY);
2733
2734 if (scroll !== 4) {
2735 if (delta < 0) {
2736 scroll += 1;
2737 } else {
2738 scroll -= 1;
2739 }
2740 } else {
2741 // Zoomstufen bei der Politischen Karte
2742 sub_scroll = $('.zoom_select').get(0).selectedIndex;
2743
2744 if (delta < 0) {
2745 sub_scroll -= 1;
2746 } else {
2747 sub_scroll += 1;
2748 }
2749 if (sub_scroll === -1) {
2750 sub_scroll = 0;
2751 }
2752 if (sub_scroll === 7) {
2753 scroll = 3;
2754 }
2755 }
2756 switch (scroll) {
2757 case 4:
2758 if (!$('.bull_eye_buttons .btn_political_map').hasClass("checked")) {
2759 $('.bull_eye_buttons .btn_political_map').click();
2760 }
2761
2762 // onChange wird aufgerufen, wenn sich die Selektierung ändert
2763 //$('.zoom_select option').eq(sub_scroll).prop('selected', true);
2764 $('.zoom_select').get(0)[sub_scroll].selected = true;
2765 //$('.zoom_select').get(0).change();
2766 //$('.zoom_select').get(0).val(sub_scroll);
2767
2768
2769 PoliticalMap.zoomToCenter();
2770 //PoliticalMap.zoomToCenterToCursorPosition($('.zoom_select').get(0)[sub_scroll].value, [e.pageX, e.pageY]);
2771
2772 break;
2773 case 3:
2774 $('.bull_eye_buttons .strategic_map').click();
2775 $('#popup_div').css('display', 'none');
2776 break;
2777 case 2:
2778 $('.bull_eye_buttons .island_view').click();
2779 TownPopup.remove();
2780 break;
2781 case 1:
2782 $('.bull_eye_buttons .city_overview').click();
2783 break;
2784 }
2785
2786 // Prevent page from scrolling
2787 return false;
2788 });
2789 },
2790 deactivate: function () {
2791 $('#main_area, .ui_city_overview').unbind('mousewheel');
2792 }
2793 };
2794
2795
2796 /*******************************************************************************************************************************
2797 * Statistics
2798 * ----------------------------------------------------------------------------------------------------------------------------
2799 * | ● Expansion of towns?
2800 * | ● Occupancy of the farms?
2801 * | ● Mouseclick-Counter?
2802 * | ● Resource distribution (%)?
2803 * | ● Building level counter ?
2804 * ----------------------------------------------------------------------------------------------------------------------------
2805 *******************************************************************************************************************************/
2806 //$('<script src="https://github.com/mbostock/d3/blob/master/d3.js"></script>').appendTo("head");
2807 // http://mbostock.github.com/d3/d3.v2.js
2808 var Statistics = {
2809 activate: function () {
2810 Statistics.addButton();
2811
2812 $('<style id="dio_statistic">' +
2813 'path { stroke: steelblue; stroke-width: 1; fill: none; } ' +
2814 '.axis { shape-rendering: crispEdges; } ' +
2815 '.x.axis line { stroke: lightgrey; } ' +
2816 '.x.axis .minor { stroke-opacity: .5; } ' +
2817 '.x.axis path { display: none; } ' +
2818 '.y.axis line, .y.axis path { fill: none; stroke: #000; } ' +
2819 '</style>').appendTo('head');
2820
2821 Statistics.ClickCounter.activate();
2822
2823 // Create Window Type
2824 createWindowType("DIO_STATISTICS", "Statistics", 300, 250, true, ["center", "center", 100, 100]);
2825 },
2826 deactivate: function () {
2827 $('#dio_statistic_button').remove();
2828 $('#dio_statistic').remove();
2829 Statistics.ClickCounter.deactivate();
2830 },
2831 addButton: function () {
2832 $('<div id="dio_statistic_button" class="circle_button"><div class="ico_statistics js-caption"></div></div>').appendTo(".gods_area");
2833
2834 // Style
2835 $('<style id="dio_statistic_style">' +
2836 '#dio_statistic_button { top:56px; left:-4px; z-index:10; position:absolute; } ' +
2837
2838 '#dio_statistic_button .ico_statistics { margin:7px 0px 0px 8px; width:17px; height:17px; background:url(http://s1.directupload.net/images/140408/pltgqlaw.png) no-repeat 0px 0px; background-size:100%; } ' +
2839 // http://s14.directupload.net/images/140408/k4wikrlq.png // http://s7.directupload.net/images/140408/ahfr8227.png
2840 '#dio_statistic_button .ico_statistics.checked { margin-top:8px; } ' +
2841 '</style>').appendTo('head');
2842
2843 // Tooltip
2844 $('#dio_statistic_button').tooltip(getText("labels", "uni")); // TODO
2845
2846 // Events
2847 $('#dio_statistic_button').on('mousedown', function () {
2848 $('#dio_statistic_button, .ico_statistics').addClass("checked");
2849 }).on('mouseup', function () {
2850 $('#dio_statistic_button, .ico_statistics').removeClass("checked");
2851 });
2852
2853 $('#dio_statistic_button').click(function () {
2854 if (!Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_STATISTICS)) {
2855 Statistics.openWindow();
2856 $('#dio_statistic_button, .ico_statistics').addClass("checked");
2857 } else {
2858 Statistics.closeWindow();
2859 $('#dio_statistic_button, .ico_statistics').removeClass("checked");
2860 }
2861 });
2862 },
2863 openWindow: function () {
2864 var content =
2865 '<div id="dio_mouseclicks" style="margin-bottom:5px; font-style:italic;">' +
2866 '<span style="text-decoration:underline;">Insgesamt:</span> <span></span>' +
2867 '<span style="float:right;"></span><span style="text-decoration:underline;float:right;">Heute:</span> ' +
2868 '</div><canvas id="dio_graph" width="290" height="150" style="margin-top:15px;"></canvas>';
2869
2870 Layout.wnd.Create(GPWindowMgr.TYPE_DIO_STATISTICS).setContent(content);
2871
2872 Statistics.ClickCounter.onOpenWindow();
2873
2874 // Draw diagram
2875 var graph, xPadding = 35, yPadding = 25;
2876
2877 var data = {values: [{X: "Jan", Y: 0}]};
2878
2879 //console.log(DATA.clickCount);
2880 for (var o in DATA.clickCount) {
2881 data.values.push({X: "opp", Y: DATA.clickCount[o]});
2882 }
2883
2884 function getMaxY() {
2885 var max = 0;
2886 for (var i = 0; i < data.values.length; i++) {
2887 if (data.values[i].Y > max) {
2888 max = data.values[i].Y;
2889 }
2890 }
2891 max += 10 - max % 10;
2892 return max + 10;
2893 }
2894
2895 function getXPixel(val) {
2896 return ((graph.width() - xPadding) / data.values.length) * val + (xPadding + 10);
2897 }
2898
2899 function getYPixel(val) {
2900 return graph.height() - (((graph.height() - yPadding) / getMaxY()) * val) - yPadding;
2901 }
2902
2903 graph = $('#dio_graph');
2904 var c = graph[0].getContext('2d');
2905
2906 c.lineWidth = 2;
2907 c.strokeStyle = '#333';
2908 c.font = 'italic 8pt sans-serif';
2909 c.textAlign = "center";
2910
2911 // Axis
2912 c.beginPath();
2913 c.moveTo(xPadding, 0);
2914 c.lineTo(xPadding, graph.height() - yPadding);
2915 c.lineTo(graph.width(), graph.height() - yPadding);
2916 c.stroke();
2917
2918 // X-Axis caption
2919 for (var x = 0; x < data.values.length; x++) {
2920 c.fillText(data.values[x].X, getXPixel(x), graph.height() - yPadding + 20);
2921 }
2922
2923 // Y-Axis caption
2924 c.textAlign = "right";
2925 c.textBaseline = "middle";
2926
2927 var maxY = getMaxY(), maxYscala = Math.ceil(maxY / 1000) * 1000;
2928 //console.log(maxY);
2929 for (var y = 0; y < maxY; y += maxYscala / 10) {
2930 c.fillText(y, xPadding - 10, getYPixel(y));
2931 }
2932
2933 // Graph
2934 c.strokeStyle = 'rgb(0,150,0)';
2935 c.beginPath();
2936 c.moveTo(getXPixel(0), getYPixel(data.values[0].Y));
2937
2938 for (var i = 1; i < data.values.length; i++) {
2939 c.lineTo(getXPixel(i), getYPixel(data.values[i].Y));
2940 }
2941 c.stroke();
2942
2943 // Points
2944 c.fillStyle = '#333';
2945
2946 for (var p = 0; p < data.values.length; p++) {
2947 c.beginPath();
2948 c.arc(getXPixel(p), getYPixel(data.values[p].Y), 2, 0, Math.PI * 2, true);
2949 c.fill();
2950 }
2951 },
2952 closeWindow: function () {
2953 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_STATISTICS).close();
2954 },
2955
2956 ClickCounter: {
2957 today: "00000000",
2958 activate: function () {
2959 Statistics.ClickCounter.updateDate();
2960
2961 $(document).on("mousedown", function () {
2962 DATA.clickCount[Statistics.ClickCounter.today]++;
2963 });
2964
2965 window.onbeforeunload = function () {
2966 Statistics.ClickCounter.save();
2967 };
2968
2969 // TODO: Update date
2970 setTimeout(function () {
2971 Statistics.ClickCounter.updateDate();
2972 }, 0);
2973 },
2974 deactivate: function () {
2975 $(document).off("mousedown");
2976 },
2977 save: function () {
2978 saveValue(WID + "_click_count", JSON.stringify(DATA.clickCount));
2979 },
2980 updateDate: function () {
2981 var today = new Date((window.Timestamp.server() + 7200) * 1000);
2982
2983 Statistics.ClickCounter.today = today.getUTCFullYear() + ((today.getUTCMonth() + 1) < 10 ? "0" : "") + (today.getUTCMonth() + 1) + (today.getUTCDate() < 10 ? "0" : "") + today.getUTCDate();
2984
2985 DATA.clickCount[Statistics.ClickCounter.today] = DATA.clickCount[Statistics.ClickCounter.today] || 0;
2986 },
2987 onOpenWindow: function () {
2988 $('#dio_mouseclicks span:eq(2)').get(0).innerHTML = DATA.clickCount[Statistics.ClickCounter.today];
2989 $(document).off("mousedown");
2990 $(document).on("mousedown", function () {
2991 if ($('#dio_mouseclicks').get(0)) {
2992 $('#dio_mouseclicks span:eq(2)').get(0).innerHTML = ++DATA.clickCount[Statistics.ClickCounter.today];
2993 } else {
2994 DATA.clickCount[Statistics.ClickCounter.today]++;
2995 $(document).off("mousedown");
2996 $(document).on("mousedown", function () {
2997 DATA.clickCount[Statistics.ClickCounter.today]++;
2998 });
2999 }
3000 });
3001 }
3002 },
3003 LuckCounter: {
3004 luckArray: {},
3005 count: function () {
3006 if ($('.fight_bonus.luck').get(0)) {
3007 var report_id = $('#report_report_header .game_arrow_delete').attr("onclick").split(",")[1].split(")")[0].trim(),
3008 luck = parseInt($('.fight_bonus.luck').get(0).innerHTML.split(":")[1].split("%")[0].trim(), 10);
3009
3010 Statistics.LuckCounter.luckArray[report_id] = luck;
3011
3012 //console.log(Statistics.LuckCounter.calcAverage());
3013 }
3014 },
3015 calcAverage: function () {
3016 var sum = 0, count = 0;
3017 for (var report_id in Statistics.LuckCounter.luckArray) {
3018 if (Statistics.LuckCounter.luckArray.hasOwnProperty(report_id)) {
3019 sum += parseInt(Statistics.LuckCounter.luckArray[report_id], 10);
3020 count++;
3021 }
3022 }
3023 return (parseFloat(sum) / parseFloat(count));
3024 }
3025 }
3026 };
3027
3028 /*******************************************************************************************************************************
3029 * Body Handler
3030 * ----------------------------------------------------------------------------------------------------------------------------
3031 * | ● Town icon
3032 * | ● Town list: Adds town type to the town list
3033 * | ● Swap Context Icons
3034 * | ● City overview
3035 * ----------------------------------------------------------------------------------------------------------------------------
3036 *******************************************************************************************************************************/
3037
3038 function imageSelectionProtection() {
3039 $('<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');
3040 }
3041
3042 var worldWonderIcon = {
3043 colossus_of_rhodes: "url(https://gpall.innogamescdn.com/images/game/map/wonder_colossus_of_rhodes.png) 38px -1px;",
3044 great_pyramid_of_giza: "url(https://gpall.innogamescdn.com/images/game/map/wonder_great_pyramid_of_giza.png) 34px -6px;",
3045 hanging_gardens_of_babylon: "url(https://gpall.innogamescdn.com/images/game/map/wonder_hanging_gardens_of_babylon.png) 34px -5px;",
3046 lighthouse_of_alexandria: "url(https://gpall.innogamescdn.com/images/game/map/wonder_lighthouse_of_alexandria.png) 37px -1px;",
3047 mausoleum_of_halicarnassus: "url(https://gpall.innogamescdn.com/images/game/map/wonder_mausoleum_of_halicarnassus.png) 37px -4px;",
3048 statue_of_zeus_at_olympia: "url(https://gpall.innogamescdn.com/images/game/map/wonder_statue_of_zeus_at_olympia.png) 36px -3px;",
3049 temple_of_artemis_at_ephesus: "url(https://gpall.innogamescdn.com/images/game/map/wonder_temple_of_artemis_at_ephesus.png) 34px -5px;"
3050 };
3051
3052 var WorldWonderIcons = {
3053 activate: function () {
3054 try {
3055 if (!$('#dio_wondericons').get(0)) {
3056 var color = "orange";
3057
3058 // style for world wonder icons
3059 var style_str = "<style id='dio_wondericons' type='text/css'>";
3060 for (var ww_type in wonder.map) {
3061 if (wonder.map.hasOwnProperty(ww_type)) {
3062 for (var ww in wonder.map[ww_type]) {
3063 if (wonder.map[ww_type].hasOwnProperty(ww)) {
3064 /*
3065 if(wonder.map[ww_type][ww] !== AID){
3066 color = "rgb(192, 109, 54)";
3067 } else {
3068 color = "orange";
3069 }
3070 */
3071 style_str += "#mini_i" + ww + ":before {" +
3072 "content: '';" +
3073 "background:" + color + " " + worldWonderIcon[ww_type] +
3074 "background-size: auto 97%;" +
3075 "padding: 8px 16px;" +
3076 "top: 50px;" +
3077 "position: relative;" +
3078 "border-radius: 40px;" +
3079 "z-index: 200;" +
3080 "cursor: pointer;" +
3081 "box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5);" +
3082 "border: 2px solid green; } " +
3083 "#mini_i" + ww + ":hover:before { z-index: 201; " +
3084 "filter: url(#Brightness12);" +
3085 "-webkit-filter: brightness(1.2); } ";
3086 }
3087 }
3088 }
3089 }
3090 $(style_str + "</style>").appendTo('head');
3091
3092 // Context menu on mouseclick
3093 $('#minimap_islands_layer').on('click', '.m_island', function (e) {
3094 var ww_coords = this.id.split("i")[3].split("_");
3095 uw.Layout.contextMenu(e, 'wonder', {ix: ww_coords[0], iy: ww_coords[1]});
3096 });
3097
3098
3099 }
3100 } catch (error) {
3101 errorHandling(error, "setWonderIconsOnMap");
3102 }
3103 },
3104 deactivate: function () {
3105 $('#dio_wondericons').remove();
3106 }
3107 };
3108
3109 var TownIcons = {
3110 types: {
3111 // Automatic Icons
3112 lo: 0,
3113 ld: 3,
3114 so: 6,
3115 sd: 7,
3116 fo: 10,
3117 fd: 9,
3118 bu: 14, /* Building */
3119 po: 22,
3120 no: 12,
3121
3122 // Manual Icons
3123 fa: 20, /* Favor */
3124 re: 15, /* Resources */
3125 di: 2, /* Distance */
3126 sh: 1, /* Pierce */
3127 lu: 13, /* ?? */
3128 dp: 11, /* Diplomacy */
3129 ha: 15, /* ? */
3130 si: 18, /* Silber */
3131 ra: 17,
3132 ch: 19, /* Research */
3133 ti: 23, /* Time */
3134 un: 5,
3135 wd: 16, /* Wood */
3136 wo: 24, /* World */
3137 bo: 13, /* Booty */
3138 gr: 21, /* Lorbeer */
3139 st: 17, /* Stone */
3140 is: 26, /* ?? */
3141 he: 4, /* Helmet */
3142 ko: 8 /* Kolo */
3143
3144 },
3145 deactivate: function () {
3146 $('#town_icon').remove();
3147 $('#dio_townicons_field').remove();
3148
3149 TownPopup.deactivate();
3150 },
3151 activate: function () {
3152 try {
3153 $('<div id="town_icon"><div class="town_icon_bg"><div class="icon_big townicon_' +
3154 (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no") + " auto")) + '"></div></div></div>').appendTo('.town_name_area');
3155
3156 // Town Icon Style
3157 $('#town_icon .icon_big').css({
3158 backgroundPosition: TownIcons.types[(manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")))] * -25 + 'px 0px'
3159 });
3160 //console.debug(dio_sprite);
3161 $('<style id="dio_townicons_field" type="text/css">' +
3162 '#town_icon { background:url(' + dio_sprite + ') 0 -125px no-repeat; position:absolute; width:69px; height:61px; left:-47px; top:0px; z-index: 10; } ' +
3163 '#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; } ' +
3164 '#town_icon .town_icon_bg:hover { filter:url(#Brightness11); -webkit-filter:brightness(1.1); box-shadow: 0px 0px 15px rgb(1, 197, 33); } ' +
3165 '#town_icon .icon_big { position:absolute; left:9px; top:9px; height:25px; width:25px; } ' +
3166
3167 '#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;' +
3168 'background:url(https://gpall.innogamescdn.com/images/game/popup/middle_middle.png); } ' +
3169 '#town_icon .item-list { max-height:400px; max-width:200px; align:right; overflow-x:hidden; } ' +
3170
3171 '#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;} ' +
3172 '#town_icon .option_s:hover { border: 2px solid rgb(59, 121, 81) !important;-webkit-filter: brightness(1.3); } ' +
3173 '#town_icon .sel { border: 2px solid rgb(202, 176, 109); } ' +
3174 '#town_icon hr { width:145px; margin:0px 0px 7px 0px; position:relative; top:3px; border:0px; border-top:2px dotted #000; float:left} ' +
3175 '#town_icon .auto_s { width:136px; height:16px; float:left} ' +
3176
3177 // Quickbar modification
3178 '.ui_quickbar .left, .ui_quickbar .right { width:46%; } ' +
3179
3180 // because of Kapsonfires Script and Beta Worlds bug report bar:
3181 '.town_name_area { z-index:11; left:52%; } ' +
3182 '.town_name_area .left { z-index:20; left:-39px; } ' +
3183 '</style>').appendTo('head');
3184
3185
3186 var icoArray = ['ld', 'lo', 'sh', 'di', 'un',
3187 'sd', 'so', 'ko', 'ti', 'gr',
3188 'fd', 'fo', 'dp', 'no', 'po',
3189 're', 'wd', 'st', 'si', 'bu',
3190 'he', 'ch', 'bo', 'fa', 'wo'];
3191
3192 // Fill select box with town icons
3193 $('<div class="select_town_icon dropdown-list default active"><div class="item-list"></div></div>').appendTo("#town_icon");
3194 for (var i in icoArray) {
3195 if (icoArray.hasOwnProperty(i)) {
3196 $('.select_town_icon .item-list').append('<div class="option_s icon_small townicon_' + icoArray[i] + '" name="' + icoArray[i] + '"></div>');
3197 }
3198 }
3199 $('<hr><div class="option_s auto_s" name="auto"><b>Auto</b></div>').appendTo('.select_town_icon .item-list');
3200
3201 $('#town_icon .option_s').click(function () {
3202 $("#town_icon .sel").removeClass("sel");
3203 $(this).addClass("sel");
3204
3205 if ($(this).attr("name") === "auto") {
3206 delete manuTownTypes[uw.Game.townId];
3207 } else {
3208 manuTownTypes[uw.Game.townId] = $(this).attr("name");
3209 }
3210 TownIcons.changeTownIcon();
3211
3212 // Update town icons on the map
3213 TownIcons.Map.activate(); //setOnMap();
3214
3215 saveValue(WID + "_townTypes", JSON.stringify(manuTownTypes));
3216 });
3217
3218 // Show & hide drop menus on click
3219 $('#town_icon .town_icon_bg').click(function () {
3220 var el = $('#town_icon .select_town_icon').get(0);
3221 if (el.style.display === "none") {
3222 el.style.display = "block";
3223 } else {
3224 el.style.display = "none";
3225 }
3226 });
3227
3228 $('#town_icon .select_town_icon [name="' + (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" : "" )) + '"]').addClass("sel");
3229
3230 } catch (error) {
3231 errorHandling(error, "addTownIcon");
3232 }
3233 },
3234 changeTownIcon: function () {
3235 var townType = (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")));
3236 $('#town_icon .icon_big').removeClass().addClass('icon_big townicon_' + townType + " auto");
3237 $('#town_icon .sel').removeClass("sel");
3238 $('#town_icon .select_town_icon [name="' + (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" : "" )) + '"]').addClass("sel");
3239
3240 $('#town_icon .icon_big').css({
3241 backgroundPosition: TownIcons.types[townType] * -25 + 'px 0px'
3242 });
3243
3244 $('#town_icon .select_town_icon').get(0).style.display = "none";
3245 },
3246 Map: {
3247 // TODO: activate aufspliten in activate und add
3248 activate: function () {
3249 try {
3250 // if town icon changed
3251 if ($('#dio_townicons_map').get(0)) {
3252 $('#dio_townicons_map').remove();
3253 }
3254
3255 // Style for own towns (town icons)
3256 var start = (new Date()).getTime(), end, style_str = "<style id='dio_townicons_map' type='text/css'>";
3257 for (var e in autoTownTypes) {
3258 if (autoTownTypes.hasOwnProperty(e)) {
3259 style_str += "#mini_t" + e + ", #town_flag_"+ e + " .flagpole {"+
3260 "background: rgb(255, 187, 0) url(" + dio_sprite + ") " + (TownIcons.types[(manuTownTypes[e] || autoTownTypes[e])] * -25) + "px -27px repeat !important; } ";
3261 }
3262 }
3263
3264 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); } ";
3265
3266 // Mouseover Effect
3267 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; } ";
3268
3269
3270 // Context menu on mouse click
3271 style_str += "#minimap_islands_layer .m_town { z-index: 99; cursor: pointer; } ";
3272
3273 $('#minimap_islands_layer').off('click', '.m_town');
3274 $('#minimap_islands_layer').on('click', '.m_town', function (z) {
3275 var id = parseInt(this.id.substring(6), 10);
3276
3277 // Town names of foreign towns are unknown
3278 if(typeof(uw.ITowns.getTown(id)) !== "undefined") {
3279 Layout.contextMenu(z, 'determine', {"id": id, "name": uw.ITowns.getTown(id).name});
3280 }
3281 else {
3282 // No town name in the title of the window
3283 Layout.contextMenu(z, 'determine', {"id": id });
3284 }
3285
3286 // Prevent parent world wonder event
3287 z.stopPropagation();
3288 });
3289
3290 $('#minimap_islands_layer').off("mousedown");
3291 $('#minimap_islands_layer').on("mousedown", function(){
3292
3293 if(typeof($('#context_menu').get(0)) !== "undefined"){
3294 $('#context_menu').get(0).remove();
3295 }
3296 });
3297
3298
3299 // Town Popup for own towns
3300 style_str += "#dio_town_popup .count { position: absolute; bottom: 1px; right: 1px; font-size: 10px; } ";
3301
3302 // Town Popups on Strategic map
3303 $('#minimap_islands_layer').off('mouseout', '.m_town');
3304 $('#minimap_islands_layer').on('mouseout', '.m_town', function () {
3305 TownPopup.remove();
3306 });
3307 $('#minimap_islands_layer').off('mouseover', '.m_town');
3308 $('#minimap_islands_layer').on('mouseover', '.m_town', function () {
3309 TownPopup.add(this);
3310 });
3311
3312 // Town Popups on island view
3313 $('#map_towns').off('mouseout', '.own_town .flagpole');
3314 $('#map_towns').on('mouseout', '.own_town .flagpole', function () {
3315 TownPopup.remove();
3316 });
3317 $('#map_towns').off('mouseover', '.own_town .flagpole');
3318 $('#map_towns').on('mouseover', '.own_town .flagpole', function () {
3319 TownPopup.add(this);
3320 });
3321
3322
3323 // Style for foreign cities (shadow)
3324 style_str += "#minimap_islands_layer .m_town { text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.7); } ";
3325
3326 // Style for night mode
3327 style_str += "#minimap_canvas.expanded.night, #map.night .flagpole { filter: brightness(0.7); -webkit-filter: brightness(0.7); } ";
3328 style_str += "#minimap_click_layer { display:none; }";
3329
3330 style_str += "</style>";
3331 $(style_str).appendTo('head');
3332
3333
3334 } catch (error) {
3335 errorHandling(error, "TownIcons.Map.activate");
3336 }
3337 },
3338 deactivate: function () {
3339 $('#dio_townicons_map').remove();
3340
3341 // Events entfernen
3342 $('#minimap_islands_layer').off('click', '.m_town');
3343 $('#minimap_islands_layer').off("mousedown");
3344
3345 $('#minimap_islands_layer').off('mouseout', '.m_town');
3346 $('#minimap_islands_layer').off('mouseover', '.m_town');
3347 }
3348 }
3349 };
3350
3351 var TownPopup = {
3352 activate : function(){
3353
3354 $('<style id="dio_town_popup_style" type="text/css">' +
3355 '#dio_town_popup { position:absolute; z-index:99;max-width: 173px;} ' +
3356
3357 '#dio_town_popup .title { margin:5px;font-weight: bold; } ' +
3358
3359 '#dio_town_popup .dio_branding { position:absolute; right:12px; top:8px; height: 20px; filter:sepia(1); -webkit-filter:sepia(1); opacity:0.5; } ' +
3360
3361 '#dio_town_popup .unit_content, ' +
3362 '#dio_town_popup .spy_content, ' +
3363 '#dio_town_popup .god_content, ' +
3364 '#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; } ' +
3365 '#dio_town_popup .resources_content { text-align: right; margin-top:3px; } ' +
3366
3367 '#dio_town_popup .resources_content table { min-width:95% } ' +
3368
3369 '#dio_town_popup .footer_content { margin-top:3px; } ' +
3370 '#dio_town_popup .footer_content table { width:100%; } ' +
3371
3372 '#dio_town_popup .spy_content { height:25px; margin-right:3px; } ' +
3373 '#dio_town_popup .god_content { width:24px; } ' +
3374
3375 '#dio_town_popup .god_mini { height: 25px; width: 32px; background-size: 75%; background-position: 0px -122px; margin-right: -8px; } ' +
3376
3377 // God Icon
3378 '#dio_town_popup .god_mini.zeus { background-position: 0px 0px; } ' +
3379 '#dio_town_popup .god_mini.athena { background-position: 0px -24px; } ' +
3380 '#dio_town_popup .god_mini.poseidon { background-position: 0px -49px; } ' +
3381 '#dio_town_popup .god_mini.hera { background-position: 0px -73px; } ' +
3382 '#dio_town_popup .god_mini.hades { background-position: 0px -98px; } ' +
3383 '#dio_town_popup .god_mini.artemis { background-position: 0px -146px; } ' +
3384
3385 '#dio_town_popup .count { position: absolute; bottom: -2px; right: 2px; font-size: 10px; font-family: Verdana,Arial,Helvetica,sans-serif; } ' +
3386 '#dio_town_popup .four_digit_number .count { font-size:8px !important; } ' +
3387 '#dio_town_popup .unit_icon25x25 { border: 1px solid #6e4b0b; margin: 1px; } ' +
3388 '#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%; } ' +
3389
3390 // Spy Icon
3391 '#dio_town_popup .support_filter { margin: 0px 4px 0px 0px; float:left; } ' +
3392 '#dio_town_popup .spy_text { line-height: 2.3em; float:left; } ' +
3393
3394 // Bei langen Stadtnamen wird sonst der Rand abgeschnitten:
3395 '#dio_town_popup .popup_middle_right { min-width: 11px; } ' +
3396
3397 '</style>').appendTo('head');
3398
3399 },
3400 deactivate : function(){
3401 $("#dio_town_popup_style").remove();
3402 },
3403 add : function(that){
3404 var townID = 0;
3405 //console.debug("TOWN", $(that).offset(), that.id);
3406
3407 if(that.id === ""){
3408 // Island view
3409 townID = parseInt($(that).parent()[0].id.substring(10), 10);
3410 }
3411 else {
3412 // Strategic map
3413 townID = parseInt(that.id.substring(6), 10);
3414 }
3415
3416 // Own town?
3417 if (typeof(uw.ITowns.getTown(townID)) !== "undefined") {
3418
3419 var units = ITowns.getTowns()[townID].units();
3420
3421 TownPopup.remove();
3422
3423 // var popup = "<div id='dio_town_popup' style='left:" + ($(that).offset().left + 20) + "px; top:" + ($(that).offset().top + 20) + "px; '>";
3424 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'>";
3425
3426 popup += "<tr class='popup_top'><td class='popup_top_left'></td><td class='popup_top_middle'></td><td class='popup_top_right'></td></tr>";
3427
3428 popup += "<tr><td class='popup_middle_left'> </td><td style='width: auto;' class='popup_middle_middle'>";
3429
3430 // Title (town name)
3431 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>";
3432
3433 // Unit Container
3434 popup += "<div class='unit_content'>";
3435 if(!$.isEmptyObject(units)) {
3436
3437 for (var unit_id in units) {
3438 if (units.hasOwnProperty(unit_id)) {
3439
3440 var classSize = "";
3441
3442 if(units[unit_id] > 1000){
3443 classSize = "four_digit_number";
3444 }
3445
3446 // Unit
3447 popup += '<div class="unit_icon25x25 ' + unit_id + ' '+ classSize +'"><span class="count text_shadow">' + units[unit_id] + '</span></div>';
3448 }
3449 }
3450 }
3451
3452 // - Wall
3453 var wallLevel = ITowns.getTowns()[townID].getBuildings().attributes.wall;
3454 popup += '<div class="wall image bold"><span class="count text_shadow">'+ wallLevel +'</span></div>';
3455
3456 popup += "</div>";
3457
3458 // Resources Container
3459 popup += "<div class='resources_content'><table cellspacing='2px' cellpadding='0px'><tr>";
3460
3461 var resources = ITowns.getTowns()[townID].resources();
3462 var storage = ITowns.getTowns()[townID].getStorage();
3463
3464 // - Wood
3465 var textColor = (resources.wood === storage) ? textColor = "color:red;" : textColor = "";
3466 popup += '<td class="resources_small wood"></td><td style="'+ textColor +'; width:1%;">' + resources.wood + '</td>';
3467
3468 popup += '<td style="min-width:15px;"></td>';
3469
3470 // - Population
3471 popup += '<td class="resources_small population"></td><td style="width:1%">' + resources.population + '</td>';
3472
3473 popup += '</tr><tr>';
3474
3475 // - Stone
3476 textColor = (resources.stone === storage) ? textColor = "color:red;" : textColor = "";
3477 popup += '<td class="resources_small stone"></td><td style="'+ textColor +'">' + resources.stone + '</td>';
3478
3479 popup += '</tr><tr>';
3480
3481 // - Iron
3482 textColor = (resources.iron === storage) ? textColor = "color:red;" : textColor = "";
3483 popup += '<td class="resources_small iron"></td><td style="'+ textColor +'">' + resources.iron + '</td>';
3484
3485
3486 popup += "</tr></table></div>";
3487
3488 // console.debug("TOWNINFO", ITowns.getTowns()[townID]);
3489
3490 // Spy and God Container
3491 popup += "<div class='footer_content'><table cellspacing='0px'><tr>";
3492
3493 var spy_storage = ITowns.getTowns()[townID].getEspionageStorage();
3494
3495 // - Spy content
3496 popup += "<td class='spy_content'>";
3497 popup += '<div class="support_filter attack_spy"></div><div class="spy_text">'+ pointNumber(spy_storage) +'</div>';
3498 popup += "</td>";
3499
3500 popup += "<td></td>";
3501
3502 // - God Content
3503 var god = ITowns.getTowns()[townID].god();
3504
3505 popup += "<td class='god_content'>";
3506 popup += '<div class="god_mini '+ god +'"></div>';
3507 popup += "</td>";
3508
3509 popup += "</tr></table></div>";
3510
3511
3512
3513 popup += "</td><td class='popup_middle_right'> </td></tr>";
3514
3515 popup += "<tr class='popup_bottom'><td class='popup_bottom_left'></td><td class='popup_bottom_middle'></td><td class='popup_bottom_right'></td></tr>";
3516
3517 popup += "</table>";
3518
3519 $(popup).appendTo("#popup_div_curtain");
3520 }
3521 },
3522 remove : function(){
3523 $('#dio_town_popup').remove();
3524 }
3525 };
3526
3527 // Style for town icons
3528 var style_str = '<style id="dio_townicons" type="text/css">';
3529 for (var s in TownIcons.types) {
3530 if (TownIcons.types.hasOwnProperty(s)) {
3531 style_str += '.townicon_' + s + ' { background:url(' + dio_sprite + ') ' + (TownIcons.types[s] * -25) + 'px -26px repeat;float:left;} ';
3532 }
3533 }
3534 style_str += '</style>';
3535 $(style_str).appendTo('head');
3536
3537
3538 var ContextMenu = {
3539 activate: function () {
3540 // Set context menu event handler
3541 $.Observer(uw.GameEvents.map.context_menu.click).subscribe('DIO_CONTEXT', function (e, data) {
3542 if (DATA.options.con && $('#context_menu').children().length == 4) {
3543 // Clear animation
3544 $('#context_menu div#goToTown').css({
3545 left: '0px',
3546 top: '0px',
3547 WebkitAnimation: 'none', //'A 0s linear',
3548 animation: 'none' //'B 0s linear'
3549 });
3550 }
3551 // Replace german label of 'select town' button
3552 if (LID === "de" && $('#select_town').get(0)) {
3553 $("#select_town .caption").get(0).innerHTML = "Selektieren";
3554 }
3555 });
3556
3557 // Set context menu animation
3558 $('<style id="dio_context_menu" type="text/css">' +
3559 // set fixed position of 'select town' button
3560 '#select_town { left: 0px !important; top: 0px !important; z-index: 6; } ' +
3561 // set animation of 'goToTown' button
3562 '#context_menu div#goToTown { left: 30px; top: -51px; ' +
3563 '-webkit-animation: A 0.115s linear; animation: B 0.2s;} ' +
3564 '@-webkit-keyframes A { from {left: 0px; top: 0px;} to {left: 30px; top: -51px;} }' +
3565 '@keyframes B { from {left: 0px; top: 0px;} to {left: 30px; top: -51px;} }' +
3566 '</style>').appendTo('head');
3567 },
3568 deactivate: function () {
3569 $.Observer(uw.GameEvents.map.context_menu.click).unsubscribe('DIO_CONTEXT');
3570
3571 $('#dio_context_menu').remove();
3572 }
3573 };
3574
3575
3576 var TownList = {
3577 activate: function () {
3578 // Style town list
3579 $('<style id="dio_town_list" type="text/css">' +
3580 '#town_groups_list .item { text-align: left; padding-left:35px; } ' +
3581 '#town_groups_list .inner_column { border: 1px solid rgba(100, 100, 0, 0.3);margin: -2px 0px 0px 2px; } ' +
3582 '#town_groups_list .island_quest_icon { position: absolute; right: 37px; top: 3px; } ' +
3583 '#town_groups_list .island_quest_icon.hidden_icon { display:none; } ' +
3584 // Quacks Zentrier-Button verschieben
3585 '#town_groups_list .jump_town { right: 37px !important; } ' +
3586 // Population percentage
3587 '#town_groups_list .pop_percent { position: absolute; right: 7px; top:0px; font-size: 0.7em; display:block !important;} ' +
3588 '#town_groups_list .full { color: green; } ' +
3589 '#town_groups_list .threequarter { color: darkgoldenrod; } ' +
3590 '#town_groups_list .half { color: darkred; } ' +
3591 '#town_groups_list .quarter { color: red; } ' +
3592 '</style>').appendTo('head');
3593
3594
3595 // Open town list: hook to grepolis function render()
3596 var i = 0;
3597 while (uw.layout_main_controller.sub_controllers[i].name != 'town_name_area') {
3598 i++;
3599 }
3600
3601 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;
3602
3603 uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render = function () {
3604 uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render_old();
3605 TownList.change();
3606 };
3607
3608 // Town List open?
3609 if ($('#town_groups_list').get(0)) {
3610 TownList.change();
3611 }
3612 },
3613 deactivate: function () {
3614 var i = 0;
3615 while (uw.layout_main_controller.sub_controllers[i].name != 'town_name_area') {
3616 i++;
3617 }
3618
3619 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;
3620
3621 $('#dio_town_list').remove();
3622
3623 $('#town_groups_list .small_icon, #town_groups_list .pop_percent').css({display: 'none'});
3624
3625 //$.Observer(uw.GameEvents.town.town_switch).unsubscribe('DIO_SWITCH_TOWN');
3626
3627 $("#town_groups_list .town_group_town").unbind('mouseenter mouseleave');
3628 },
3629 change: function () {
3630 if (!$('#town_groups_list .icon_small').get(0) && !$('#town_groups_list .pop_percent').get(0)) {
3631 $("#town_groups_list .town_group_town").each(function () {
3632 try {
3633 var town_item = $(this), town_id = town_item.attr('name'), townicon_div, percent_div = "", percent = -1, pop_space = "full";
3634
3635 if (population[town_id]) {
3636 percent = population[town_id].percent;
3637 }
3638 if (percent < 75) {
3639 pop_space = "threequarter";
3640 }
3641 if (percent < 50) {
3642 pop_space = "half";
3643 }
3644 if (percent < 25) {
3645 pop_space = "quarter";
3646 }
3647
3648 if (!town_item.find('icon_small').length) {
3649 townicon_div = '<div class="icon_small townicon_' + (manuTownTypes[town_id] || autoTownTypes[town_id] || "no") + '"></div>';
3650 // TODO: Notlösung...
3651 if (percent != -1) {
3652 percent_div = '<div class="pop_percent ' + pop_space + '">' + percent + '%</div>';
3653 }
3654 town_item.prepend(townicon_div + percent_div);
3655 }
3656
3657 // opening context menu
3658 /*
3659 $(this).click(function(e){
3660 console.log(e);
3661 uw.Layout.contextMenu(e, 'determine', {"id": town_id,"name": uw.ITowns[town_id].getName()});
3662 });
3663 */
3664
3665 } catch (error) {
3666 errorHandling(error, "TownList.change");
3667 }
3668 });
3669
3670 }
3671
3672 // Hover Effect for Quacks Tool:
3673 $("#town_groups_list .town_group_town").hover(function () {
3674 $(this).find('.island_quest_icon').addClass("hidden_icon");
3675 }, function () {
3676 $(this).find('.island_quest_icon').removeClass("hidden_icon");
3677 });
3678
3679 // Add change town list event handler
3680 //$.Observer(uw.GameEvents.town.town_switch).subscribe('DIO_SWITCH_TOWN', function () {
3681 //TownList.change();
3682 //});
3683 }
3684 };
3685
3686 var HiddenHighlightWindow = {
3687 activate : function(){
3688 // Style town list
3689 $('<style id="dio_hidden_highlight_window" type="text/css">' +
3690 '.strategic_map_filter { display:none !important; } ' +
3691 '</style>').appendTo('head');
3692 },
3693 deactivate : function (){
3694 $('#dio_hidden_highlight_window').remove();
3695 }
3696 };
3697
3698 /*******************************************************************************************************************************
3699 * Available units
3700 * ----------------------------------------------------------------------------------------------------------------------------
3701 * | ● GetAllUnits
3702 * | ● Shows all available units
3703 * ----------------------------------------------------------------------------------------------------------------------------
3704 *******************************************************************************************************************************/
3705 var groupUnitArray = {};
3706 // TODO: split Function (getUnits, calcUnitsSum, availableUnits, countBiremes, getTownTypes)?
3707
3708 // Alter Einheitenzähler
3709 function getAllUnits() {
3710 try {
3711 var townArray = uw.ITowns.getTowns(), groupArray = uw.ITowns.townGroups.getGroupsDIO(),
3712
3713 unitArray = {
3714 "sword": 0,
3715 "archer": 0,
3716 "hoplite": 0,
3717 "chariot": 0,
3718 "godsent": 0,
3719 "rider": 0,
3720 "slinger": 0,
3721 "catapult": 0,
3722 "small_transporter": 0,
3723 "big_transporter": 0,
3724 "manticore": 0,
3725 "harpy": 0,
3726 "pegasus": 0,
3727 "cerberus": 0,
3728 "minotaur": 0,
3729 "medusa": 0,
3730 "zyklop": 0,
3731 "centaur": 0,
3732 "fury": 0,
3733 "sea_monster": 0
3734 },
3735
3736 unitArraySea = {"bireme": 0, "trireme": 0, "attack_ship": 0, "demolition_ship": 0, "colonize_ship": 0};
3737
3738 //console.debug("DIO-TOOLS | getAllUnits | GROUP ARRAY", groupArray);
3739
3740
3741 if (uw.Game.hasArtemis) {
3742 unitArray = $.extend(unitArray, {"griffin": 0, "calydonian_boar": 0});
3743 }
3744 unitArray = $.extend(unitArray, unitArraySea);
3745
3746 for (var group in groupArray) {
3747 if (groupArray.hasOwnProperty(group)) {
3748 // Clone Object "unitArray"
3749 groupUnitArray[group] = Object.create(unitArray);
3750
3751 for (var town in groupArray[group].towns) {
3752 if (groupArray[group].towns.hasOwnProperty(town)) {
3753 var type = {lo: 0, ld: 0, so: 0, sd: 0, fo: 0, fd: 0}; // Type for TownList
3754
3755 for (var unit in unitArray) {
3756 if (unitArray.hasOwnProperty(unit)) {
3757 // All Groups: Available units
3758 var tmp = parseInt(uw.ITowns.getTown(town).units()[unit], 10);
3759 groupUnitArray[group][unit] += tmp || 0;
3760 // Only for group "All"
3761 if (group == -1) {
3762 // Bireme counter // old
3763 if (unit === "bireme" && ((biriArray[townArray[town].id] || 0) < (tmp || 0))) {
3764 biriArray[townArray[town].id] = tmp;
3765 }
3766 //TownTypes
3767 if (!uw.GameData.units[unit].is_naval) {
3768 if (uw.GameData.units[unit].flying) {
3769 type.fd += ((uw.GameData.units[unit].def_hack + uw.GameData.units[unit].def_pierce + uw.GameData.units[unit].def_distance) / 3 * (tmp || 0));
3770 type.fo += (uw.GameData.units[unit].attack * (tmp || 0));
3771 } else {
3772 type.ld += ((uw.GameData.units[unit].def_hack + uw.GameData.units[unit].def_pierce + uw.GameData.units[unit].def_distance) / 3 * (tmp || 0));
3773 type.lo += (uw.GameData.units[unit].attack * (tmp || 0));
3774 }
3775 } else {
3776 type.sd += (uw.GameData.units[unit].defense * (tmp || 0));
3777 type.so += (uw.GameData.units[unit].attack * (tmp || 0));
3778 }
3779 }
3780 }
3781 }
3782 // Only for group "All"
3783 if (group == -1) {
3784 // Icon: DEF or OFF?
3785 var z = ((type.sd + type.ld + type.fd) <= (type.so + type.lo + type.fo)) ? "o" : "d",
3786 temp = 0;
3787
3788 for (var t in type) {
3789 if (type.hasOwnProperty(t)) {
3790 // Icon: Land/Sea/Fly (t[0]) + OFF/DEF (z)
3791 if (temp < type[t]) {
3792 autoTownTypes[townArray[town].id] = t[0] + z;
3793 temp = type[t];
3794 }
3795 // Icon: Troops Outside (overwrite)
3796 if (temp < 1000) {
3797 autoTownTypes[townArray[town].id] = "no";
3798 }
3799 }
3800 }
3801 // Icon: Empty Town (overwrite)
3802 var popBuilding = 0, buildVal = uw.GameData.buildings, levelArray = townArray[town].buildings().getLevels(),
3803 popMax = Math.floor(buildVal.farm.farm_factor * Math.pow(townArray[town].buildings().getBuildingLevel("farm"), buildVal.farm.farm_pow)), // Population from farm level
3804 popPlow = townArray[town].getResearches().attributes.plow ? 200 : 0,
3805 popFactor = townArray[town].getBuildings().getBuildingLevel("thermal") ? 1.1 : 1.0, // Thermal
3806 popExtra = townArray[town].getPopulationExtra();
3807
3808 for (var b in levelArray) {
3809 if (levelArray.hasOwnProperty(b)) {
3810 popBuilding += Math.round(buildVal[b].pop * Math.pow(levelArray[b], buildVal[b].pop_factor));
3811 }
3812 }
3813 population[town] = {};
3814
3815 population[town].max = popMax * popFactor + popPlow + popExtra;
3816 population[town].buildings = popBuilding;
3817 population[town].units = parseInt((population[town].max - (popBuilding + townArray[town].getAvailablePopulation()) ), 10);
3818
3819 if (population[town].units < 300) {
3820 autoTownTypes[townArray[town].id] = "po";
3821 }
3822
3823 population[town].percent = Math.round(100 / (population[town].max - popBuilding) * population[town].units);
3824 }
3825 }
3826 }
3827 }
3828 }
3829
3830 // Update Available Units
3831 AvailableUnits.updateBullseye();
3832 if (GPWindowMgr.TYPE_DIO_UNITS) {
3833 if (Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS)) {
3834 AvailableUnits.updateWindow();
3835 }
3836 }
3837 } catch (error) {
3838 errorHandling(error, "getAllUnits"); // TODO: Eventueller Fehler in Funktion
3839 }
3840 }
3841
3842 function addFunctionToITowns() {
3843 // Copy function and prevent an error
3844 uw.ITowns.townGroups.getGroupsDIO = function () {
3845 var town_groups_towns, town_groups, groups = {};
3846
3847 // #Grepolis Fix: 2.75 -> 2.76
3848 if (MM.collections) {
3849 town_groups_towns = MM.collections.TownGroupTown[0];
3850 town_groups = MM.collections.TownGroup[0];
3851 } else {
3852 town_groups_towns = MM.getCollections().TownGroupTown[0];
3853 town_groups = MM.getCollections().TownGroup[0];
3854 }
3855
3856 town_groups_towns.each(function (town_group_town) {
3857 var gid = town_group_town.getGroupId(),
3858 group = groups[gid],
3859 town_id = town_group_town.getTownId();
3860
3861 if (!group) {
3862 groups[gid] = group = {
3863 id: gid,
3864 //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
3865 towns: {}
3866 };
3867 }
3868
3869 group.towns[town_id] = {id: town_id};
3870 //groups[gid].towns[town_id]={id:town_id};
3871 });
3872 //console.log(groups);
3873 return groups;
3874 };
3875 }
3876
3877
3878 // Neuer Einheitenzähler
3879 var UnitCounter = {
3880 units : {"total":{}, "available":{}, "outer":{}, "foreign":{}},
3881
3882 count : function(){
3883 var tooltipHelper = require("helpers/units_tooltip_helper");
3884
3885 var groups = uw.ITowns.townGroups.getGroupsDIO();
3886
3887 for (var groupId in groups) {
3888 if (groups.hasOwnProperty(groupId)) {
3889
3890 UnitCounter.units.total[groupId] = {};
3891 UnitCounter.units.available[groupId] = {};
3892 UnitCounter.units.outer[groupId] = {};
3893
3894
3895 for (var townId in groups[groupId].towns) {
3896 if (groups[groupId].towns.hasOwnProperty(townId)) {
3897
3898 // Einheiten gesamt
3899 UnitCounter.units.total[groupId][townId] = ITowns.towns[townId].units();
3900
3901 // Einheiten verfügbar
3902 UnitCounter.units.available[groupId][townId] = ITowns.towns[townId].units();
3903
3904 // Einheiten außerhalb
3905 UnitCounter.units.outer[groupId][townId] = {};
3906
3907 var supports = tooltipHelper.getDataForSupportingUnitsInOtherTownFromCollection(MM.getTownAgnosticCollectionsByName("Units")[1].fragments[townId], MM.getOnlyCollectionByName("Town"));
3908
3909 for (var supportId in supports) {
3910 if (supports.hasOwnProperty(supportId)) {
3911
3912 for (var attributeId in supports[supportId].attributes) {
3913 if (supports[supportId].attributes.hasOwnProperty(attributeId)) {
3914
3915 // Attribut ist eine Einheit?
3916 if (typeof(GameData.units[attributeId]) !== "undefined" && supports[supportId].attributes[attributeId] > 0) {
3917
3918 UnitCounter.units.outer[groupId][townId][attributeId] = (UnitCounter.units.outer[groupId][townId][attributeId] || 0) + supports[supportId].attributes[attributeId];
3919
3920 UnitCounter.units.total[groupId][townId][attributeId] = (UnitCounter.units.total[groupId][townId][attributeId] || 0) + supports[supportId].attributes[attributeId];
3921 }
3922 }
3923 }
3924 }
3925 }
3926 }
3927 }
3928
3929 // Summen aller Städte berechnen
3930 UnitCounter.summarize(groupId);
3931 }
3932 }
3933
3934 return UnitCounter.units;
3935 },
3936
3937 summarize : function(groupId){
3938 var tooltipHelper = require("helpers/units_tooltip_helper");
3939
3940 UnitCounter.units.total[groupId]["all"] = {};
3941 UnitCounter.units.available[groupId]["all"] = {};
3942 UnitCounter.units.outer[groupId]["all"] = {};
3943
3944 for(var townId in UnitCounter.units.total[groupId]){
3945 if(UnitCounter.units.total[groupId].hasOwnProperty(townId) && townId !== "all"){
3946
3947 // Einheiten gesamt
3948 for(var unitId in UnitCounter.units.total[groupId][townId]){
3949 if(UnitCounter.units.total[groupId][townId].hasOwnProperty(unitId)){
3950
3951 UnitCounter.units.total[groupId]["all"][unitId] = (UnitCounter.units.total[groupId]["all"][unitId] || 0) + UnitCounter.units.total[groupId][townId][unitId];
3952 }
3953 }
3954
3955 // Einheiten verfügbar
3956 for(var unitId in UnitCounter.units.available[groupId][townId]){
3957 if(UnitCounter.units.available[groupId][townId].hasOwnProperty(unitId)){
3958
3959 UnitCounter.units.available[groupId]["all"][unitId] = (UnitCounter.units.available[groupId]["all"][unitId] || 0) + UnitCounter.units.available[groupId][townId][unitId];
3960 }
3961 }
3962
3963 // Einheiten außerhalb
3964 for(var unitId in UnitCounter.units.outer[groupId][townId]){
3965 if(UnitCounter.units.outer[groupId][townId].hasOwnProperty(unitId)){
3966
3967 UnitCounter.units.outer[groupId]["all"][unitId] = (UnitCounter.units.outer[groupId]["all"][unitId] || 0) + UnitCounter.units.outer[groupId][townId][unitId];
3968 }
3969 }
3970 }
3971 }
3972 }
3973 };
3974
3975
3976 var AvailableUnits = {
3977 activate: function () {
3978 var default_title = DM.getl10n("place", "support_overview").options.troop_count + " (" + DM.getl10n("hercules2014", "available") + ")";
3979
3980 $(".picomap_container").prepend("<div id='available_units_bullseye' class='unit_icon90x90 " + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme") + "'><div class='amount'></div></div>");
3981
3982 $('.picomap_overlayer').tooltip(getText("options", "ava")[0]);
3983
3984 // Ab version 2.115
3985 if($(".topleft_navigation_area").get(0)) {
3986
3987 $(".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>");
3988
3989 $('<style id="dio_available_units_style_addition">' +
3990 '.coords_box { top: 117px !important; } ' +
3991 '.nui_grepo_score { top: 150px !important; } ' +
3992 '.nui_left_box { top: 102px !important; } ' +
3993 '.nui_main_menu { top: 293px !important; }' +
3994 '#grcrt_mnu_list .nui_main_menu {top: 0px !important; }'+
3995 '.bull_eye_buttons, .rb_map { height:38px !important; }' +
3996
3997 '#ui_box .btn_change_colors { top: 31px !important; }' +
3998
3999 '.picomap_area { position: absolute; overflow: visible; top: 0; left: 0; width: 156px; height: 161px; z-index: 5; }' +
4000 '.picomap_area .picomap_container, .picomap_area .picomap_overlayer { position: absolute; top: 33px; left: -3px; width: 147px; height: 101px; }' +
4001 //'.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;} '+
4002 '.picomap_area .picomap_overlayer { background: url(' + dio_sprite + '); background-position: 473px 250px; width: 147px; height: 101px; z-index: 5;} ' +
4003 '</style>').appendTo('head');
4004 }
4005
4006 // Style
4007 $('<style id="dio_available_units_style">' +
4008
4009 '@-webkit-keyframes Z { 0% { opacity: 0; } 100% { opacity: 1; } } ' +
4010 '@keyframes Z { 0% { opacity: 0; } 100% { opacity: 1; } } ' +
4011
4012 '@-webkit-keyframes blurr { 0% { -webkit-filter: blur(5px); } 100% { -webkit-filter: blur(0px); } } ' +
4013
4014 '.picomap_overlayer { cursor:pointer; } ' +
4015
4016 '.picomap_area .bull_eye_buttons { height: 55px; } ' +
4017
4018 '#sea_id { background: none; font-size:25px; cursor:default; height:50px; width:50px; position:absolute; top:70px; left:157px; z-index: 30; } ' +
4019
4020 // Available bullseye unit
4021 '#available_units_bullseye { margin: 5px 28px 0px 28px; -webkit-animation: blur 2s; animation: Z 1s; } ' +
4022
4023 '#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; } ' +
4024
4025 '#available_units_bullseye.big_number { font-size: 0.90em; line-height: 1.4; } ' +
4026
4027 '#available_units_bullseye.blur { -webkit-animation: blurr 0.6s; } ' +
4028
4029
4030
4031 // Land units
4032 '#available_units_bullseye.sword .amount { color:#E2D9C1; top:57px; width:90px; } ' +
4033 '#available_units_bullseye.hoplite .amount { color:#E2D9C1; top:57px; width:90px; } ' +
4034 '#available_units_bullseye.archer .amount { color:#E2D0C1; top:47px; width:70px; } ' +
4035 '#available_units_bullseye.chariot { margin-top: 15px; } ' +
4036 '#available_units_bullseye.chariot .amount { color:#F5E8B4; top:38px; width:91px; } ' +
4037 '#available_units_bullseye.rider .amount { color:#DFCC6C; top:52px; width:105px; } ' +
4038 '#available_units_bullseye.slinger .amount { color:#F5E8B4; top:53px; width:91px; } ' +
4039 '#available_units_bullseye.catapult .amount { color:#F5F6C5; top:36px; width:87px; } ' +
4040 '#available_units_bullseye.godsent .amount { color:#F5F6C5; top:57px; width:92px; } ' +
4041
4042 // Mythic units
4043 '#available_units_bullseye.medusa .amount { color:#FBFFBB; top:50px; width:65px; } ' +
4044 '#available_units_bullseye.manticore .amount { color:#ECD181; top:50px; width:55px; } ' +
4045 '#available_units_bullseye.pegasus { margin-top: 16px; } ' +
4046 '#available_units_bullseye.pegasus .amount { color:#F7F8E3; top:36px; width:90px; } ' +
4047 '#available_units_bullseye.minotaur { margin-top: 10px; } ' +
4048 '#available_units_bullseye.minotaur .amount { color:#EAD88A; top:48px; width:78px; } ' +
4049 '#available_units_bullseye.zyklop { margin-top: 3px; } '+
4050 '#available_units_bullseye.zyklop .amount { color:#EDE0B0; top:50px; width:95px; } ' +
4051 '#available_units_bullseye.harpy { margin-top: 16px; } ' +
4052 '#available_units_bullseye.harpy .amount { color:#E7DB79; top:30px; width:78px; } ' +
4053 '#available_units_bullseye.sea_monster .amount { color:#D8EA84; top:58px; width:91px; } ' +
4054 '#available_units_bullseye.cerberus .amount { color:#EC7445; top:25px; width:101px; } ' +
4055 '#available_units_bullseye.centaur { margin-top: 15px; } ' +
4056 '#available_units_bullseye.centaur .amount { color:#ECE0A8; top:29px; width:83px; } ' +
4057 '#available_units_bullseye.fury .amount { color:#E0E0BC; top:57px; width:95px; } ' +
4058 '#available_units_bullseye.griffin { margin-top: 15px; } ' +
4059 '#available_units_bullseye.griffin .amount { color:#FFDC9D; top:40px; width:98px; } ' +
4060 '#available_units_bullseye.calydonian_boar .amount { color:#FFDC9D; top:17px; width:85px; } ' +
4061
4062 // Naval units
4063 '#available_units_bullseye.attack_ship .amount { color:#FFCB00; top:26px; width:99px; } ' +
4064 '#available_units_bullseye.bireme .amount { color:#DFC677; color:azure; top:28px; width:79px; } ' +
4065 '#available_units_bullseye.trireme .amount { color:#F4FFD4; top:24px; width:90px; } ' +
4066 '#available_units_bullseye.small_transporter .amount { color:#F5F6C5; top:26px; width:84px; } ' +
4067 '#available_units_bullseye.big_transporter .amount { color:#FFDC9D; top:27px; width:78px; } ' +
4068 '#available_units_bullseye.colonize_ship .amount { color:#F5F6C5; top:29px; width:76px; } ' +
4069 '#available_units_bullseye.colonize_ship .amount { color:#F5F6C5; top:29px; width:76px; } ' +
4070 '#available_units_bullseye.demolition_ship .amount { color:#F5F6C5; top:35px; width:90px; } ' +
4071
4072 // Available units window
4073 '#available_units { overflow: auto; } ' +
4074 '#available_units .unit { margin: 5px; cursor:pointer; overflow:visible; } ' +
4075 '#available_units .unit.active { border: 2px solid #7f653a; border-radius:30px; margin:4px; } ' +
4076 '#available_units .unit span { text-shadow: 1px 1px 1px black, 1px 1px 2px black;} ' +
4077 '#available_units hr { margin: 5px 0px 5px 0px; } ' +
4078 '#available_units .drop_box .option { float: left; margin-right: 30px; width:100%; } ' +
4079 '#available_units .drop_box { position:absolute; top: -38px; right: 83px; width:90px; z-index:10; } ' +
4080 '#available_units .drop_box .drop_group { width: 120px; } ' +
4081 '#available_units .drop_box .select_group.open { display:block; } ' +
4082 '#available_units .drop_box .item-list { overflow: auto; overflow-x: hidden; } ' +
4083 '#available_units .drop_box .arrow { width:18px; height:18px; background:url(' + drop_out.src + ') no-repeat -1px -1px; position:absolute; } ' +
4084
4085 // Available units button
4086 '#btn_available_units { top:86px; left:119px; z-index:10; position:absolute; } ' +
4087 '#btn_available_units .ico_available_units { margin:5px 0px 0px 4px; width:24px; height:24px; ' +
4088 'background:url(http://s1.directupload.net/images/140323/w4ekrw8b.png) no-repeat 0px 0px;background-size:100%; filter:url(#Hue1); -webkit-filter:hue-rotate(100deg); } ' +
4089
4090 '</style>').appendTo('head');
4091
4092 createWindowType("DIO_UNITS", (LANG.hasOwnProperty(LID) ? getText("options", "ava")[0] : default_title), 365, 310, true, [240, 70]);
4093
4094 // Set Sea-ID beside the bull eye
4095 $('#sea_id').prependTo('#ui_box');
4096
4097 AvailableUnits.addButton();
4098
4099 UnitCounter.count();
4100 AvailableUnits.updateBullseye();
4101 },
4102 deactivate: function () {
4103 $('#available_units_bullseye').remove();
4104 $('#available_units_bullseye_addition').remove();
4105
4106 $('#dio_available_units_style').remove();
4107 $('#dio_available_units_style_addition').remove();
4108
4109 $('#btn_available_units').remove();
4110
4111 if (Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS)) {
4112 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS).close();
4113 }
4114
4115 $('.picomap_overlayer').unbind();
4116
4117 $('#sea_id').appendTo('.picomap_container')
4118 },
4119 addButton: function () {
4120 var default_title = DM.getl10n("place", "support_overview").options.troop_count + " (" + DM.getl10n("hercules2014", "available") + ")";
4121
4122 $('<div id="btn_available_units" class="circle_button"><div class="ico_available_units js-caption"></div></div>').appendTo(".bull_eye_buttons");
4123
4124 // Events
4125 $('#btn_available_units').on('mousedown', function () {
4126 $('#btn_available_units, .ico_available_units').addClass("checked");
4127 }).on('mouseup', function () {
4128 $('#btn_available_units, .ico_available_units').removeClass("checked");
4129 });
4130
4131 $('#btn_available_units, .picomap_overlayer').click(function () {
4132 if (!Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS)) {
4133 AvailableUnits.openWindow();
4134 $('#btn_available_units, .ico_available_units').addClass("checked");
4135 } else {
4136 AvailableUnits.closeWindow();
4137 $('#btn_available_units, .ico_available_units').removeClass("checked");
4138 }
4139 });
4140
4141 // Tooltip
4142 $('#btn_available_units').tooltip(LANG.hasOwnProperty(LID) ? getText("labels", "uni") : default_title);
4143 },
4144 openWindow: function () {
4145 var groupArray = uw.ITowns.townGroups.getGroupsDIO(),
4146
4147 unitArray = {
4148 "sword": 0,
4149 "archer": 0,
4150 "hoplite": 0,
4151 "slinger": 0,
4152 "rider": 0,
4153 "chariot": 0,
4154 "catapult": 0,
4155 "godsent": 0,
4156 "manticore": 0,
4157 "harpy": 0,
4158 "pegasus": 0,
4159 "griffin": 0,
4160 "cerberus": 0,
4161 "minotaur": 0,
4162 "medusa": 0,
4163 "zyklop": 0,
4164 "centaur": 0,
4165 "calydonian_boar": 0,
4166 "fury": 0,
4167 "sea_monster": 0,
4168 "small_transporter": 0,
4169 "big_transporter": 0,
4170 "bireme": 0,
4171 "attack_ship": 0,
4172 "trireme": 0,
4173 "demolition_ship": 0,
4174 "colonize_ship": 0
4175 };
4176
4177 if (!uw.Game.hasArtemis) {
4178 delete unitArray.calydonian_boar;
4179 delete unitArray.griffin;
4180 }
4181
4182 var land_units_str = "", content =
4183 '<div id="available_units">' +
4184 // Dropdown menu
4185 '<div class="drop_box">' +
4186 '<div class="drop_group dropdown default">' +
4187 '<div class="border-left"></div><div class="border-right"></div>' +
4188 '<div class="caption" name="' + groupArray[DATA.bullseyeUnit.current_group].id + '">' + ITowns.town_groups._byId[groupArray[DATA.bullseyeUnit.current_group].id].attributes.name + '</div>' +
4189 '<div class="arrow"></div>' +
4190 '</div>' +
4191 '<div class="select_group dropdown-list default active"><div class="item-list"></div></div>' +
4192 '</div>' +
4193 '<table width="100%" class="radiobutton horizontal rbtn_visibility"><tr>'+
4194 '<td width="40%"><div class="option js-option" name="total"><div class="pointer"></div>'+ getText("labels", "total") +'</div></td>'+
4195 '<td width="40%"><div class="option js-option" name="available"><div class="pointer"></div>'+ getText("labels", "available") +'</div></td>'+
4196 '<td width="20%"><div class="option js-option" name="outer"><div class="pointer"></div>'+ getText("labels", "outer") +'</div></td>'+
4197 '</tr></table>'+
4198 '<hr>'+
4199 // Content
4200 '<div class="box_content">';
4201
4202 for (var unit in unitArray) {
4203 if (unitArray.hasOwnProperty(unit)) {
4204 land_units_str += '<div class="unit index_unit bold unit_icon40x40 ' + unit + '"></div>';
4205 if (unit == "sea_monster") {
4206 land_units_str += '<div style="clear:left;"></div>'; // break
4207 }
4208 }
4209 }
4210 content += land_units_str + '</div></div>';
4211
4212 AvailableUnits.wnd = Layout.wnd.Create(GPWindowMgr.TYPE_DIO_UNITS);
4213
4214 AvailableUnits.wnd.setContent(content);
4215
4216 if (Game.premium_features.curator <= Timestamp.now()) {
4217 $('#available_units .drop_box').css({display: 'none'});
4218 DATA.bullseyeUnit.current_group = -1;
4219 }
4220
4221 // Add groups to dropdown menu
4222 for (var group in groupArray) {
4223 if (groupArray.hasOwnProperty(group)) {
4224 var group_name = ITowns.town_groups._byId[group].attributes.name;
4225 $('<div class="option' + (group == -1 ? " sel" : "") + '" name="' + group + '">' + group_name + '</div>').appendTo('#available_units .item-list');
4226 }
4227 }
4228
4229 // Set active mode
4230 if(typeof(DATA.bullseyeUnit.mode) !== "undefined"){
4231 $('.radiobutton .option[name="'+ DATA.bullseyeUnit.mode +'"]').addClass("checked");
4232 }
4233 else{
4234 $('.radiobutton .option[name="available"]').addClass("checked");
4235 }
4236
4237 // Update
4238 AvailableUnits.updateWindow();
4239
4240 // Dropdown menu Handler
4241 $('#available_units .drop_group').click(function () {
4242 $('#available_units .select_group').toggleClass('open');
4243 });
4244 // Change group
4245 $('#available_units .select_group .option').click(function () {
4246 DATA.bullseyeUnit.current_group = $(this).attr("name");
4247 $('#available_units .select_group').removeClass('open');
4248 $('#available_units .select_group .option.sel').removeClass("sel");
4249 $(this).addClass("sel");
4250
4251 $('#available_units .drop_group .caption').attr("name", DATA.bullseyeUnit.current_group);
4252 $('#available_units .drop_group .caption').get(0).innerHTML = this.innerHTML;
4253
4254 $('#available_units .unit.active').removeClass("active");
4255 $('#available_units .unit.' + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme")).addClass("active");
4256
4257 UnitCounter.count();
4258
4259 AvailableUnits.updateWindow();
4260 AvailableUnits.updateBullseye();
4261 AvailableUnits.save();
4262 });
4263
4264 // Change mode (total, available, outer)
4265 $('.radiobutton .option').click(function(){
4266
4267 DATA.bullseyeUnit.mode = $(this).attr("name");
4268
4269 $('.radiobutton .option.checked').removeClass("checked");
4270 $(this).addClass("checked");
4271
4272 UnitCounter.count();
4273
4274 AvailableUnits.updateWindow();
4275 AvailableUnits.updateBullseye();
4276 AvailableUnits.save();
4277 });
4278
4279 // Set active bullseye unit
4280 $('#available_units .unit.' + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme")).addClass("active");
4281
4282 // Change bullseye unit
4283 $('#available_units .unit').click(function () {
4284 DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] = this.className.split(" ")[4].trim();
4285
4286 $('#available_units .unit.active').removeClass("active");
4287 $(this).addClass("active");
4288
4289 AvailableUnits.updateBullseye();
4290 AvailableUnits.save();
4291
4292 });
4293
4294 // Close button event - uncheck available units button
4295 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS).getJQCloseButton().get(0).onclick = function () {
4296 $('#btn_available_units, .ico_available_units').removeClass("checked");
4297 };
4298 },
4299 closeWindow: function () {
4300 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS).close();
4301 },
4302 save: function () {
4303 // console.debug("BULLSEYE SAVE", DATA.bullseyeUnit);
4304
4305 saveValue(WID + "_bullseyeUnit", JSON.stringify(DATA.bullseyeUnit));
4306 },
4307 updateBullseye: function () {
4308
4309 var sum = 0, str = "", fsize = ['1.4em', '1.2em', '1.15em', '1.1em', '1.0em', '0.95em'], i;
4310
4311 if ($('#available_units_bullseye').get(0)) {
4312 $('#available_units_bullseye').get(0).className = "unit_icon90x90 " + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme");
4313
4314 if (UnitCounter.units[DATA.bullseyeUnit.mode || "available"][DATA.bullseyeUnit.current_group]) {
4315 sum = UnitCounter.units[DATA.bullseyeUnit.mode || "available"][DATA.bullseyeUnit.current_group]["all"][(DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme" )] || 0;
4316 }
4317 sum = sum.toString();
4318
4319 for (i = 0; i < sum.length; i++) {
4320 str += "<span style='font-size:" + fsize[i] + "'>" + sum[i] + "</span>";
4321 }
4322 $('#available_units_bullseye .amount').get(0).innerHTML = str;
4323
4324 if (sum >= 100000) {
4325 $('#available_units_bullseye').addClass("big_number");
4326 } else {
4327 $('#available_units_bullseye').removeClass("big_number");
4328 }
4329 }
4330 },
4331 updateWindow: function () {
4332
4333 $('#available_units .box_content .unit').each(function () {
4334 var unit = this.className.split(" ")[4];
4335
4336 // TODO: Alte Variante entfernen
4337 // Alte Variante:
4338 //this.innerHTML = '<span style="font-size:0.9em">' + groupUnitArray[DATA.bullseyeUnit.current_group][unit] + '</span>';
4339
4340 // Neue Variante
4341 this.innerHTML = '<span style="font-size:0.9em">' + (UnitCounter.units[DATA.bullseyeUnit.mode || "available"][DATA.bullseyeUnit.current_group]["all"][unit] || 0) + '</span>';
4342 });
4343 }
4344 };
4345
4346 /*******************************************************************************************************************************
4347 * Comparison box
4348 * ----------------------------------------------------------------------------------------------------------------------------
4349 * | ● Compares the units of each unit type
4350 * ----------------------------------------------------------------------------------------------------------------------------
4351 *******************************************************************************************************************************/
4352 var UnitComparison = {
4353 activate: function () {
4354 //UnitComparison.addBox();
4355 UnitComparison.addButton();
4356
4357 // Create Window Type
4358 createWindowType("DIO_COMPARISON", getText("labels", "dsc"), 480, 315, true, ["center", "center", 100, 100]);
4359
4360 // Style
4361 $('<style id="dio_comparison_style"> ' +
4362
4363 // Button
4364 '#dio_comparison_button { top:51px; left:120px; z-index:10; position:absolute; } ' +
4365 '#dio_comparison_button .ico_comparison { margin:5px 0px 0px 4px; width:24px; height:24px; ' +
4366 'background:url(http://666kb.com/i/cjq6cxia4ms8mn95r.png) no-repeat 0px 0px; background-size:100%; filter:url(#Hue1); -webkit-filter:hue-rotate(60deg); } ' +
4367 '#dio_comparison_button.checked .ico_comparison { margin-top:6px; } ' +
4368
4369 // Window
4370 '#dio_comparison a { float:left; background-repeat:no-repeat; background-size:25px; line-height:2; margin-right:10px; } ' +
4371 '#dio_comparison .box_content { text-align:center; font-style:normal; } ' +
4372
4373 // Menu tabs
4374 '#dio_comparison_menu .tab_icon { left: 23px;} ' +
4375 '#dio_comparison_menu .tab_label { margin-left: 18px; } ' +
4376
4377 // Content
4378 '#dio_comparison .hidden { display:none; } ' +
4379 '#dio_comparison table { width:480px; } ' +
4380 '#dio_comparison .hack .t_hack, #dio_comparison .pierce .t_pierce, #dio_comparison .distance .t_distance, #dio_comparison .sea .t_sea { display:inline-table; } ' +
4381
4382 '#dio_comparison .box_content { background:url(http://s1.directupload.net/images/140206/8jd9d3ec.png) 94% 94% no-repeat; background-size:140px; } ' +
4383
4384 '#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%; } ' +
4385 '#dio_comparison .compare_type_icon.booty { background:url(http://s14.directupload.net/images/140404/ki4gwd7x.png); background-size:100%; } ' +
4386 '#dio_comparison .compare_type_icon.time { background:url(https://gpall.innogamescdn.com/images/game/res/time.png); background-size:100%; } ' +
4387 '#dio_comparison .compare_type_icon.favor { background:url(https://gpall.innogamescdn.com/images/game/res/favor.png); background-size:100%; } ' +
4388 '</style>').appendTo("head");
4389 },
4390 deactivate: function () {
4391 $('#dio_comparison_button').remove();
4392 $('#dio_comparison_style').remove();
4393
4394 if (Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON)) {
4395 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON).close();
4396 }
4397 },
4398 addButton: function () {
4399 $('<div id="dio_comparison_button" class="circle_button"><div class="ico_comparison js-caption"></div></div>').appendTo(".bull_eye_buttons");
4400
4401 // Events
4402 /*
4403 $('#dio_comparison_button').on('mousedown', function(){
4404 $('#dio_comparison_button').addClass("checked");
4405 }, function(){
4406 $('#dio_comparison_button').removeClass("checked");
4407 });
4408 */
4409 $('#dio_comparison_button').on('click', function () {
4410 if (!Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON)) {
4411 UnitComparison.openWindow();
4412 $('#dio_comparison_button').addClass("checked");
4413 } else {
4414 UnitComparison.closeWindow();
4415 $('#dio_comparison_button').removeClass("checked");
4416 }
4417 });
4418
4419 // Tooltip
4420 $('#dio_comparison_button').tooltip(getText("labels", "dsc"));
4421 },
4422 openWindow: function () {
4423 var content =
4424 // Title tabs
4425 '<ul id="dio_comparison_menu" class="menu_inner" style="top: -36px; right: 35px;">' +
4426 '<li><a class="submenu_link sea" href="#"><span class="left"><span class="right"><span class="middle">' +
4427 '<span class="tab_icon icon_small townicon_so"></span><span class="tab_label">' + getText("labels", "sea") + '</span>' +
4428 '</span></span></span></a></li>' +
4429 '<li><a class="submenu_link distance" href="#"><span class="left"><span class="right"><span class="middle">' +
4430 '<span class="tab_icon icon_small townicon_di"></span><span class="tab_label">' + getText("labels", "dst") + '</span>' +
4431 '</span></span></span></a></li>' +
4432 '<li><a class="submenu_link pierce" href="#"><span class="left"><span class="right"><span class="middle">' +
4433 '<span class="tab_icon icon_small townicon_sh"></span><span class="tab_label">' + getText("labels", "prc") + '</span>' +
4434 '</span></span></span></a></li>' +
4435 '<li><a class="submenu_link hack active" href="#"><span class="left"><span class="right"><span class="middle">' +
4436 '<span class="tab_icon icon_small townicon_lo"></span><span class="tab_label">' + getText("labels", "hck") + '</span>' +
4437 '</span></span></span></a></li>' +
4438 '</ul>' +
4439 // Content
4440 '<div id="dio_comparison" style="margin-bottom:5px; font-style:italic;"><div class="box_content hack"></div></div>';
4441
4442 Layout.wnd.Create(GPWindowMgr.TYPE_DIO_COMPARISON).setContent(content);
4443
4444 UnitComparison.addComparisonTable("hack");
4445 UnitComparison.addComparisonTable("pierce");
4446 UnitComparison.addComparisonTable("distance");
4447 UnitComparison.addComparisonTable("sea");
4448
4449 // Tooltips
4450 var labelArray = DM.getl10n("barracks"),
4451 labelAttack = DM.getl10n("context_menu", "titles").attack,
4452 labelDefense = DM.getl10n("place", "tabs")[0];
4453
4454 $('.tr_att').tooltip(labelAttack);
4455 $('.tr_def').tooltip(labelDefense + " (Ø)");
4456 $('.tr_def_sea').tooltip(labelDefense);
4457 $('.tr_spd').tooltip(labelArray.tooltips.speed);
4458 $('.tr_bty').tooltip(labelArray.tooltips.booty.title);
4459 $('.tr_bty_sea').tooltip(labelArray.tooltips.ship_transport.title);
4460 $('.tr_res').tooltip(labelArray.costs + " (" +
4461 labelArray.cost_details.wood + " + " +
4462 labelArray.cost_details.stone + " + " +
4463 labelArray.cost_details.iron + ")"
4464 );
4465 $('.tr_fav').tooltip(labelArray.costs + " (" + labelArray.cost_details.favor + ")");
4466 $('.tr_tim').tooltip(labelArray.cost_details.buildtime_barracks + " (s)");
4467 $('.tr_tim_sea').tooltip(labelArray.cost_details.buildtime_docks + " (s)");
4468
4469 UnitComparison.switchComparisonTables();
4470
4471 // Close button event - uncheck available units button
4472 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON).getJQCloseButton().get(0).onclick = function () {
4473 $('#dio_comparison_button').removeClass("checked");
4474 $('.ico_comparison').get(0).style.marginTop = "5px";
4475 };
4476 },
4477 closeWindow: function () {
4478 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON).close();
4479 },
4480 switchComparisonTables: function () {
4481 $('#dio_comparison_menu .hack, #dio_comparison_menu .pierce, #dio_comparison_menu .distance, #dio_comparison_menu .sea').click(function () {
4482 $('#dio_comparison .box_content').removeClass($('#dio_comparison .box_content').get(0).className.split(" ")[1]);
4483 //console.debug(this.className.split(" ")[1]);
4484 $('#dio_comparison .box_content').addClass(this.className.split(" ")[1]);
4485
4486 $('#dio_comparison_menu .active').removeClass("active");
4487 $(this).addClass("active");
4488 });
4489 },
4490
4491 tooltips: [], t: 0,
4492
4493 addComparisonTable: function (type) {
4494 var pos = {
4495 att: {hack: "36%", pierce: "27%", distance: "45.5%", sea: "72.5%"},
4496 def: {hack: "18%", pierce: "18%", distance: "18%", sea: "81.5%"}
4497 };
4498 var unitIMG = "https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png";
4499 var strArray = [
4500 "<td></td>",
4501 '<td><div class="compare_type_icon" style="background-position: 0% ' + pos.att[type] + ';"></div></td>',
4502 '<td><div class="compare_type_icon" style="background-position: 0% ' + pos.def[type] + ';"></div></td>',
4503 '<td><div class="compare_type_icon" style="background-position: 0% 63%;"></div></td>',
4504 (type !== "sea") ? '<td><div class="compare_type_icon booty"></div></td>' : '<td><div class="compare_type_icon" style="background-position: 0% 91%;"></div></td>',
4505 '<td><div class="compare_type_icon" style="background-position: 0% 54%;"></div></td>',
4506 '<td><div class="compare_type_icon favor"></div></td>',
4507 '<td><div class="compare_type_icon time"></div></td>'
4508 ];
4509
4510 for (var e in uw.GameData.units) {
4511 if (uw.GameData.units.hasOwnProperty(e)) {
4512 var valArray = [];
4513
4514 if (type === (uw.GameData.units[e].attack_type || "sea") && (e !== "militia")) {
4515 valArray.att = Math.round(uw.GameData.units[e].attack * 10 / uw.GameData.units[e].population) / 10;
4516 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;
4517 valArray.def = valArray.def || Math.round(uw.GameData.units[e].defense * 10 / uw.GameData.units[e].population) / 10;
4518 valArray.speed = uw.GameData.units[e].speed;
4519 valArray.booty = Math.round(((uw.GameData.units[e].booty) * 10) / uw.GameData.units[e].population) / 10;
4520 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;
4521 valArray.favor = Math.round((uw.GameData.units[e].favor * 10) / uw.GameData.units[e].population) / 10;
4522 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));
4523 valArray.time = Math.round(uw.GameData.units[e].build_time / uw.GameData.units[e].population);
4524
4525 // World without Artemis? -> grey griffin and boar
4526 valArray.heroStyle = "";
4527 valArray.heroStyleIMG = "";
4528
4529 if (!uw.Game.hasArtemis && ((e === "griffin") || (e === "calydonian_boar"))) {
4530 valArray.heroStyle = "color:black;opacity: 0.4;";
4531 valArray.heroStyleIMG = "filter: url(#GrayScale); -webkit-filter:grayscale(100%);";
4532 }
4533
4534 strArray[0] += '<td class="un' + (UnitComparison.t) + '"><span class="unit index_unit unit_icon40x40 ' + e + '" style="' + valArray.heroStyle + valArray.heroStyleIMG + '"></span></td>';
4535 strArray[1] += '<td class="bold" style="color:' + ((valArray.att > 19) ? 'green;' : ((valArray.att < 10 && valArray.att !== 0 ) ? 'red;' : 'black;')) + valArray.heroStyle + '">' + valArray.att + '</td>';
4536 strArray[2] += '<td class="bold" style="color:' + ((valArray.def > 19) ? 'green;' : ((valArray.def < 10 && valArray.def !== 0 ) ? 'red;' : 'black;')) + valArray.heroStyle + '">' + valArray.def + '</td>';
4537 strArray[3] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.speed + '</td>';
4538 strArray[4] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.booty + '</td>';
4539 strArray[5] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.res + '</td>';
4540 strArray[6] += '<td class="bold" style="color:' + ((valArray.favor > 0) ? 'rgb(0, 0, 214);' : 'black;') + valArray.heroStyle + ';">' + valArray.favor + '</td>';
4541 strArray[7] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.time + '</td>';
4542
4543 UnitComparison.tooltips[UnitComparison.t] = uw.GameData.units[e].name;
4544 UnitComparison.t++;
4545 }
4546 }
4547 }
4548
4549 $('<table class="hidden t_' + type + '" cellpadding="1px">' +
4550 '<tr>' + strArray[0] + '</tr>' +
4551 '<tr class="tr_att">' + strArray[1] + '</tr><tr class="tr_def' + (type == "sea" ? "_sea" : "") + '">' + strArray[2] + '</tr>' +
4552 '<tr class="tr_spd">' + strArray[3] + '</tr><tr class="tr_bty' + (type == "sea" ? "_sea" : "") + '">' + strArray[4] + '</tr>' +
4553 '<tr class="tr_res">' + strArray[5] + '</tr><tr class="tr_fav">' + strArray[6] + '</tr><tr class="tr_tim' + (type == "sea" ? "_sea" : "") + '">' + strArray[7] + '</tr>' +
4554 '</table>').appendTo('#dio_comparison .box_content');
4555
4556 for (var i = 0; i <= UnitComparison.t; i++) {
4557 $('.un' + i).tooltip(UnitComparison.tooltips[i]);
4558 }
4559 }
4560 };
4561
4562 /*******************************************************************************************************************************
4563 * Reports and Messages
4564 * ----------------------------------------------------------------------------------------------------------------------------
4565 * | ● Storage of the selected filter (only in German Grepolis yet)
4566 * ----------------------------------------------------------------------------------------------------------------------------
4567 *******************************************************************************************************************************/
4568
4569 var filter = "all";
4570
4571 function saveFilter() {
4572 $('#dd_filter_type_list .item-list div').each(function () {
4573 $(this).click(function () {
4574 filter = $(this).attr("name");
4575 });
4576 });
4577 /*
4578 var i = 0;
4579 $("#report_list a").each(function () {
4580 //console.log((i++) +" = " + $(this).attr('data-reportid'));
4581 });
4582 */
4583 }
4584
4585 function loadFilter() {
4586 if ($('#dd_filter_type_list .selected').attr("name") !== filter) {
4587 $('#dd_filter_type .caption').click();
4588 $('#dd_filter_type_list .item-list div[name=' + filter + ']').click();
4589 }
4590 }
4591
4592 function removeReports() {
4593 $("#report_list li:contains('spioniert')").each(function () {
4594 //$(this).remove();
4595 });
4596 }
4597
4598 var zut = 0;
4599 var messageArray = {};
4600
4601 function filterPlayer() {
4602 if (!$('#message_filter_list').get(0)) {
4603 $('<div id="message_filter_list" style="height:300px;overflow-y:scroll; width: 790px;"></div>').appendTo('#folder_container');
4604 $("#message_list").get(0).style.display = "none";
4605 }
4606 if (zut < parseInt($('.es_last_page').get(0).value, 10) - 1) {
4607 $('.es_page_input').get(0).value = zut++;
4608 $('.jump_button').click();
4609 $("#message_list li:contains('')").each(function () {
4610 $(this).appendTo('#message_filter_list');
4611 });
4612 } else {
4613 zut = 1;
4614 }
4615 }
4616
4617
4618 /*******************************************************************************************************************************
4619 * World Wonder Ranking - Change
4620 *******************************************************************************************************************************/
4621
4622 function getWorldWonderTypes() {
4623 $.ajax({
4624 type: "GET",
4625 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 +
4626 "%7D&_=" + uw.Game.server_time,
4627 success: function (text) {
4628 try {
4629 //console.log(JSON.parse(text));
4630 temp = JSON.parse(text).json.data.world_wonders;
4631 for (var t in temp) {
4632 if (temp.hasOwnProperty(t)) {
4633 wonderTypes[temp[t].wonder_type] = temp[t].full_name;
4634 }
4635 }
4636 temp = JSON.parse(text).json.data.buildable_wonders;
4637 for (var x in temp) {
4638 if (temp.hasOwnProperty(x)) {
4639 wonderTypes[x] = temp[x].name;
4640 }
4641 }
4642 saveValue(MID + "_wonderTypes", JSON.stringify(wonderTypes));
4643 } catch (error) {
4644 errorHandling(error, "getWorldWonderTypes");
4645 }
4646 }
4647 });
4648 }
4649
4650 function getWorldWonders() {
4651 $.ajax({
4652 type: "GET",
4653 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 +
4654 "%7D&_=" + uw.Game.server_time
4655 });
4656 }
4657
4658 var WorldWonderRanking = {
4659 activate: function () {
4660 if ($('#dio_wonder_ranking').get(0)) {
4661 $('#dio_wonder_ranking').remove();
4662 }
4663 $('<style id="dio_wonder_ranking" type="text/css"> .wonder_ranking { display: none; } </style>').appendTo('head');
4664 },
4665 deactivate: function () {
4666 if ($('#dio_wonder_ranking').get(0)) {
4667 $('#dio_wonder_ranking').remove();
4668 }
4669 $('<style id="dio_wonder_ranking" type="text/css"> .wonder_ranking { display: block; } </style>').appendTo('head');
4670 },
4671 change: function (html) {
4672 if ($('#ranking_inner tr', html)[0].children.length !== 1) { // world wonders exist?
4673 try {
4674 var ranking = {}, temp_ally, temp_ally_id, temp_ally_link;
4675
4676 // Save world wonder ranking into array
4677 $('#ranking_inner tr', html).each(function () {
4678 try {
4679 if (this.children[0].innerHTML) {
4680 temp_ally = this.children[1].children[0].innerHTML; // das hier
4681
4682 temp_ally_id = this.children[1].children[0].onclick.toString();
4683 temp_ally_id = temp_ally_id.substring(temp_ally_id.indexOf(",") + 1);
4684 temp_ally_id = temp_ally_id.substring(0, temp_ally_id.indexOf(")"));
4685
4686 temp_ally_link = this.children[1].innerHTML;
4687
4688 } else {
4689 //World wonder name
4690 var wonder_name = this.children[3].children[0].innerHTML;
4691
4692 for (var w in wonderTypes) {
4693 if (wonderTypes.hasOwnProperty(w)) {
4694 if (wonder_name == wonderTypes[w]) {
4695 var level = this.children[4].innerHTML, // world wonder level
4696 ww_data = JSON.parse(atob(this.children[3].children[0].href.split("#")[1])), wonder_link;
4697 //console.log(ww_data);
4698
4699 if (!ranking.hasOwnProperty(level)) {
4700 // add wonder types
4701 ranking[level] = {
4702 colossus_of_rhodes: {},
4703 great_pyramid_of_giza: {},
4704 hanging_gardens_of_babylon: {},
4705 lighthouse_of_alexandria: {},
4706 mausoleum_of_halicarnassus: {},
4707 statue_of_zeus_at_olympia: {},
4708 temple_of_artemis_at_ephesus: {}
4709 };
4710 }
4711
4712 if (!ranking[level][w].hasOwnProperty(temp_ally_id)) {
4713 ranking[level][w][temp_ally_id] = {}; // add alliance array
4714 }
4715 // island coordinates of the world wonder:
4716 ranking[level][w][temp_ally_id].ix = ww_data.ix;
4717 ranking[level][w][temp_ally_id].iy = ww_data.iy;
4718 ranking[level][w][temp_ally_id].sea = this.children[5].innerHTML; // world wonder sea
4719
4720 wonder_link = this.children[3].innerHTML;
4721 if (temp_ally.length > 15) {
4722 temp_ally = temp_ally.substring(0, 15) + '.';
4723 }
4724 wonder_link = wonder_link.substr(0, wonder_link.indexOf(">") + 1) + temp_ally + '</a>';
4725
4726 ranking[level][w][temp_ally_id].ww_link = wonder_link;
4727
4728 // other data of the world wonder
4729 ranking[level][w][temp_ally_id].ally_link = temp_ally_link;
4730 ranking[level][w][temp_ally_id].ally_name = temp_ally; // alliance name
4731 ranking[level][w][temp_ally_id].name = wonder_name; // world wonder name
4732
4733 // Save wonder coordinates for wonder icons on map
4734 if (!wonder.map[w]) {
4735 wonder.map[w] = {};
4736 }
4737 wonder.map[w][ww_data.ix + "_" + ww_data.iy] = level;
4738 saveValue(WID + "_wonder", JSON.stringify(wonder));
4739
4740 }
4741 }
4742 }
4743 }
4744 } catch (error) {
4745 errorHandling(error, "WorldWonderRanking.change(function)");
4746 }
4747 });
4748
4749 if ($('#ranking_table_wrapper').get(0)) {
4750 $('#ranking_fixed_table_header').get(0).innerHTML = '<tr>' +
4751 '<td style="width:10px">#</td>' +
4752 '<td>Colossus</td>' +
4753 '<td>Pyramid</td>' +
4754 '<td>Garden</td>' +
4755 '<td>Lighthouse</td>' +
4756 '<td>Mausoleum</td>' +
4757 '<td>Statue</td>' +
4758 '<td>Temple</td>' +
4759 '</tr>';
4760
4761 $('#ranking_fixed_table_header').css({
4762 tableLayout: 'fixed',
4763 width: '100%',
4764 //paddingLeft: '0px',
4765 paddingRight: '15px'
4766 });
4767
4768 var ranking_substr = '', z = 0;
4769 for (var level = 10; level >= 1; level--) {
4770 if (ranking.hasOwnProperty(level)) {
4771 var complete = "";
4772 if (level == 10) {
4773 complete = "background: rgba(255, 236, 108, 0.36);";
4774 }
4775
4776 // Alternate table background color
4777 if (z === 0) {
4778 ranking_substr += '<tr class="game_table_odd" style="' + complete + '"><td style="border-right: 1px solid #d0be97;">' + level + '</td>';
4779 z = 1;
4780 } else {
4781 ranking_substr += '<tr class="game_table_even" style="' + complete + '"><td style="border-right: 1px solid #d0be97;">' + level + '</td>';
4782 z = 0;
4783 }
4784 for (var w in ranking[level]) {
4785 if (ranking[level].hasOwnProperty(w)) {
4786 ranking_substr += '<td>';
4787
4788 for (var a in ranking[level][w]) {
4789 if (ranking[level][w].hasOwnProperty(a)) {
4790 ranking_substr += '<nobr>' + ranking[level][w][a].ww_link + '</nobr><br />'; // ww link
4791 }
4792 }
4793 ranking_substr += '</td>';
4794 }
4795 }
4796 ranking_substr += '</tr>';
4797 }
4798 }
4799
4800 var ranking_str = '<table id="ranking_endless_scroll" class="game_table" cellspacing="0"><tr>' +
4801 '<td style="width:10px;border-right: 1px solid #d0be97;"></td>' +
4802 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.colossus_of_rhodes + ';margin-left:26px"></div></td>' + // Colossus
4803 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.great_pyramid_of_giza + ';margin-left:19px"></div></td>' + // Pyramid
4804 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.hanging_gardens_of_babylon + ';margin-left:19px"></div></td>' + // Garden
4805 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.lighthouse_of_alexandria + ';margin-left:24px"></div></td>' + // Lighthouse
4806 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.mausoleum_of_halicarnassus + ';margin-left:25px"></div></td>' + // Mausoleum
4807 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.statue_of_zeus_at_olympia + ';margin-left:25px"></div></td>' + // Statue
4808 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.temple_of_artemis_at_ephesus + ';margin-left:22px"></div></td>' + // Temple
4809 '</tr>' + ranking_substr + '</table>';
4810
4811 $('#ranking_table_wrapper').get(0).innerHTML = ranking_str;
4812
4813 $('#ranking_endless_scroll .dio_wonder').css({
4814 width: "65px", height: "60px",
4815 backgroundSize: "auto 100%",
4816 backgroundPosition: "64px 0px"
4817 });
4818
4819 $('#ranking_endless_scroll').css({
4820 tableLayout: 'fixed',
4821 width: '100%',
4822 overflowY: 'auto',
4823 overflowX: 'hidden',
4824 fontSize: '0.7em',
4825 lineHeight: '2'
4826 });
4827 $('#ranking_endless_scroll tbody').css({
4828 verticalAlign: 'text-top'
4829 });
4830
4831 $('#ranking_table_wrapper img').css({
4832 width: "60px"
4833 });
4834 $('#ranking_table_wrapper').css({
4835 overflowY: 'scroll'
4836 });
4837 }
4838 } catch (error) {
4839 errorHandling(error, "WorldWonderRanking.change");
4840 }
4841 }
4842 if ($('.wonder_ranking').get(0)) {
4843 $('.wonder_ranking').get(0).style.display = "block";
4844 }
4845 }
4846 };
4847
4848 /*******************************************************************************************************************************
4849 * World Wonder
4850 * ----------------------------------------------------------------------------------------------------------------------------
4851 * | ● click adjustment
4852 * | ● Share calculation (= ratio of player points to alliance points)
4853 * | ● Resources calculation & counter (stores amount)
4854 * | ● Adds missing previous & next buttons on finished world wonders (better browsing through world wonders)
4855 * ----------------------------------------------------------------------------------------------------------------------------
4856 *******************************************************************************************************************************/
4857
4858 // getPointRatio: Default
4859 function getPointRatioFromAllianceProfile() {
4860 if (AID) {
4861 $.ajax({
4862 type: "GET",
4863 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 +
4864 '%2C%22nlreq_id%22%3A' + uw.Game.notification_last_requested_id + '%7D&_=' + uw.Game.server_time,
4865 success: function (text) {
4866 try {
4867 text = text.substr(text.indexOf("/li") + 14).substr(0, text.indexOf("\ "));
4868 var AP = parseInt(text, 10);
4869 wonder.ratio[AID] = 100 / AP * uw.Game.player_points;
4870 saveValue(WID + "_wonder", JSON.stringify(wonder));
4871 } catch (error) {
4872 errorHandling(error, "getPointRatioFromAllianceProfile");
4873 }
4874 }
4875 });
4876 } else {
4877 wonder.ratio[AID] = -1;
4878 saveValue(WID + "_wonder", JSON.stringify(wonder));
4879 }
4880 }
4881
4882 function getPointRatioFromAllianceRanking() {
4883 try {
4884 if (AID && $('.current_player .r_points').get(0)) {
4885 wonder.ratio[AID] = 100 / parseInt($('.current_player .r_points').get(0).innerHTML, 10) * uw.Game.player_points;
4886 saveValue(WID + "_wonder", JSON.stringify(wonder));
4887 }
4888 } catch (error) {
4889 errorHandling(error, "getPointRatioFromAllianceRaking");
4890 }
4891 }
4892
4893 function getPointRatioFromAllianceMembers() {
4894 try {
4895 var ally_points = 0;
4896 $('#ally_members_body tr').each(function () {
4897 ally_points += parseInt($(this).children().eq(2).text(), 10) || 0;
4898 });
4899 wonder.ratio[AID] = 100 / ally_points * uw.Game.player_points;
4900 saveValue(WID + "_wonder", JSON.stringify(wonder));
4901 } catch (error) {
4902 errorHandling(error, "getPointRatioFromAllianceMembers");
4903 }
4904 }
4905
4906 var WorldWonderCalculator = {
4907 activate: function () {
4908 // Style
4909 $('<style id="dio_wonder_calculator"> ' +
4910 '.wonder_controls { height:380px; } ' +
4911 '.wonder_controls .wonder_progress { margin: 0px auto 5px; } ' +
4912 '.wonder_controls .wonder_header { text-align:left; margin:10px -8px 12px 3px; }' +
4913 '.wonder_controls .build_wonder_icon { top:25px !important; }' +
4914 '.wonder_controls .wonder_progress_bar { top:54px; }' +
4915 '.wonder_controls .trade fieldset { float:right; } ' +
4916 '.wonder_controls .wonder_res_container { right:29px; } ' +
4917 '.wonder_controls .ww_ratio {position:relative; height:auto; } ' +
4918 '.wonder_controls fieldset.next_level_res { height:auto; } ' +
4919 '.wonder_controls .town-capacity-indicator { margin-top:0px; } ' +
4920
4921 '.wonder_controls .ww_ratio .progress { line-height:1; color:white; font-size:0.8em; } ' +
4922 '.wonder_controls .ww_perc { position:absolute; width:242px; text-align:center; } ' +
4923 '.wonder_controls .indicator3 { z-index:0; } ' +
4924 '.wonder_controls .indicator3.red { background-position:right -203px; height:10px; width:242px; } ' +
4925 '.wonder_controls .indicator3.green { background-position:right -355px; height:10px; width:242px; } ' +
4926 '.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; } ' +
4927 '.wonder_controls .town-capacity-indicator { margin-top:0px; } ' +
4928 '</style>').appendTo('head');
4929 },
4930 deactivate: function () {
4931 $('#dio_wonder_calculator').remove();
4932 }
4933 };
4934
4935 // TODO: Split function...
4936 function getResWW() {
4937 try {
4938 var wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_WONDERS);
4939
4940 for (var e in wndArray) {
4941 if (wndArray.hasOwnProperty(e)) {
4942 var wndID = "#gpwnd_" + wndArray[e].getID() + " ";
4943
4944 if ($(wndID + '.wonder_progress').get(0)) {
4945 var res = 0,
4946 ww_share = {total: {share: 0, sum: 0}, stage: {share: 0, sum: 0}},
4947 ww_type = $(wndID + '.finished_image_small').attr('src').split("/")[6].split("_")[0], // Which world wonder?
4948 res_stages = [2, 4, 6, 10, 16, 28, 48, 82, 140, 238], // Rohstoffmenge pro Rohstofftyp in 100.000 Einheiten
4949 stage = parseInt($(wndID + '.wonder_expansion_stage span').get(0).innerHTML.split("/")[0], 10) + 1, // Derzeitige Füllstufe
4950 speed = uw.Game.game_speed;
4951
4952 wonder.storage[AID] = wonder.storage[AID] || {};
4953
4954 wonder.storage[AID][ww_type] = wonder.storage[AID][ww_type] || {};
4955
4956 wonder.storage[AID][ww_type][stage] = wonder.storage[AID][ww_type][stage] || 0;
4957
4958 if (!$(wndID + '.ww_ratio').get(0)) {
4959 $('<fieldset class="ww_ratio"></fieldset>').appendTo(wndID + '.wonder_res_container .trade');
4960 $(wndID + '.wonder_header').prependTo(wndID + '.wonder_progress');
4961 $(wndID + '.wonder_res_container .send_res').insertBefore(wndID + '.wonder_res_container .next_level_res');
4962 }
4963
4964 for (var d in res_stages) {
4965 if (res_stages.hasOwnProperty(d)) {
4966 ww_share.total.sum += res_stages[d];
4967 }
4968 }
4969
4970 ww_share.total.sum *= speed * 300000;
4971
4972 ww_share.total.share = parseInt(wonder.ratio[AID] * (ww_share.total.sum / 100), 10);
4973
4974 ww_share.stage.sum = speed * res_stages[stage - 1] * 300000;
4975
4976 ww_share.stage.share = parseInt(wonder.ratio[AID] * (ww_share.stage.sum / 100), 10); // ( 3000 = 3 Rohstofftypen * 100000 Rohstoffe / 100 Prozent)
4977 setResWW(stage, ww_type, ww_share, wndID);
4978
4979
4980 $(wndID + '.wonder_res_container .send_resources_btn').click(function (e) {
4981 try {
4982 wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_wood input:text').get(0).value, 10);
4983 wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_stone input:text').get(0).value, 10);
4984 wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_iron input:text').get(0).value, 10);
4985
4986 setResWW(stage, ww_type, ww_share, wndID);
4987 saveValue(WID + "_wonder", JSON.stringify(wonder));
4988 } catch (error) {
4989 errorHandling(error, "getResWW_Click");
4990 }
4991 });
4992
4993 } else {
4994 $('<div class="prev_ww pos_Y"></div><div class="next_ww pos_Y"></div>').appendTo(wndID + '.wonder_controls');
4995
4996 $(wndID + '.wonder_finished').css({width: '100%'});
4997
4998 $(wndID + '.pos_Y').css({
4999 top: '-266px'
5000 });
5001 }
5002 }
5003 }
5004 } catch (error) {
5005 errorHandling(error, "getResWW");
5006 }
5007 }
5008
5009 function setResWW(stage, ww_type, ww_share, wndID) {
5010 try {
5011 var stage_width, total_width, res_total = 0, stage_color = "red", total_color = "red";
5012
5013 for (var z in wonder.storage[AID][ww_type]) {
5014 if (wonder.storage[AID][ww_type].hasOwnProperty(z)) {
5015 res_total += wonder.storage[AID][ww_type][z];
5016 }
5017 }
5018
5019 // Progressbar
5020 if (ww_share.stage.share > wonder.storage[AID][ww_type][stage]) {
5021 stage_width = (242 / ww_share.stage.share) * wonder.storage[AID][ww_type][stage];
5022 stage_color = "red";
5023 } else {
5024 stage_width = 242;
5025 stage_color = "green"
5026 }
5027 if (ww_share.total.share > res_total) {
5028 total_color = "red";
5029 total_width = (242 / ww_share.total.share) * res_total;
5030 } else {
5031 total_width = 242;
5032 total_color = "green"
5033 }
5034
5035 $(wndID + '.ww_ratio').get(0).innerHTML = "";
5036 $(wndID + '.ww_ratio').append(
5037 '<legend>' + getText("labels", "leg") + ' (<span style="color:#090">' + (Math.round(wonder.ratio[AID] * 100) / 100) + '%</span>):</legend>' +
5038 '<div class="town-capacity-indicator">' +
5039 '<div class="icon all_res"></div>' +
5040 '<div id="ww_town_capacity_stadium" class="tripple-progress-progressbar">' +
5041 '<div class="border_l"></div><div class="border_r"></div><div class="body"></div>' +
5042 '<div class="progress overloaded">' +
5043 '<div class="indicator3 ' + stage_color + '" style="width:' + stage_width + 'px"></div>' +
5044 '<span class="ww_perc">' + Math.round(wonder.storage[AID][ww_type][stage] / ww_share.stage.share * 100) + '%</span>' +
5045 '</div>' +
5046 '<div class="amounts">' + getText("labels", "stg") + ': <span class="curr">' + pointNumber(wonder.storage[AID][ww_type][stage]) + '</span> / ' +
5047 '<span class="max">' + pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) + '</span></div>' +
5048 '</div></div>' +
5049 '<div class="town-capacity-indicator">' +
5050 '<div class="icon all_res"></div>' +
5051 '<div id="ww_town_capacity_total" class="tripple-progress-progressbar">' +
5052 '<div class="border_l"></div><div class="border_r"></div><div class="body"></div>' +
5053 '<div class="progress overloaded">' +
5054 '<div class="indicator3 ' + total_color + '" style="width:' + total_width + 'px;"></div>' +
5055 '<span class="ww_perc">' + Math.round(res_total / ww_share.total.share * 100) + '%</span>' +
5056 '</div>' +
5057 '<div class="amounts">' + getText("labels", "tot") + ': <span class="curr">' + pointNumber(res_total) + '</span> / ' +
5058 '<span class="max">' + pointNumber((Math.round(ww_share.total.share / 1000) * 1000)) + '</span></div>' +
5059 '</div></div>');
5060
5061 $(wndID + '.ww_ratio').tooltip(
5062 "<table style='border-spacing:0px; text-align:right' cellpadding='5px'><tr>" +
5063 "<td align='right' style='border-right: 1px solid;border-bottom: 1px solid'></td>" +
5064 "<td style='border-right: 1px solid; border-bottom: 1px solid'><span class='bbcodes_player bold'>(" + (Math.round((wonder.ratio[AID]) * 100) / 100) + "%)</span></td>" +
5065 "<td style='border-bottom: 1px solid'><span class='bbcodes_ally bold'>(100%)</span></td></tr>" +
5066 "<tr><td class='bold' style='border-right:1px solid;text-align:center'>" + getText("labels", "stg") + " " + stage + "</td>" +
5067 "<td style='border-right: 1px solid'>" + pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) + "</td>" +
5068 "<td>" + pointNumber(Math.round(ww_share.stage.sum / 1000) * 1000) + "</td></tr>" +
5069 "<tr><td class='bold' style='border-right:1px solid;text-align:center'>" + getText("labels", "tot") + "</td>" +
5070 "<td style='border-right: 1px solid'>" + pointNumber(Math.round(ww_share.total.share / 1000) * 1000) + "</td>" +
5071 "<td>" + pointNumber(Math.round(ww_share.total.sum / 1000) * 1000) + "</td>" +
5072 "</tr></table>");
5073
5074 } catch (error) {
5075 errorHandling(error, "setResWW");
5076 }
5077 }
5078
5079 // Adds points to numbers
5080 function pointNumber(number) {
5081 var sep;
5082 if (LID === "de") {
5083 sep = ".";
5084 } else {
5085 sep = ",";
5086 }
5087
5088 number = number.toString();
5089 if (number.length > 3) {
5090 var mod = number.length % 3;
5091 var output = (mod > 0 ? (number.substring(0, mod)) : '');
5092
5093 for (var i = 0; i < Math.floor(number.length / 3); i++) {
5094 if ((mod == 0) && (i == 0)) {
5095 output += number.substring(mod + 3 * i, mod + 3 * i + 3);
5096 } else {
5097 output += sep + number.substring(mod + 3 * i, mod + 3 * i + 3);
5098 }
5099 }
5100 number = output;
5101 }
5102 return number;
5103 }
5104
5105 /*******************************************************************************************************************************
5106 * Farming Village Overview
5107 * ----------------------------------------------------------------------------------------------------------------------------
5108 * | ● Color change on possibility of city festivals
5109 * ----------------------------------------------------------------------------------------------------------------------------
5110 * *****************************************************************************************************************************/
5111
5112 function changeResColor() {
5113 var res, res_min, i = 0;
5114 $('#fto_town_list .fto_resource_count :last-child').reverseList().each(function () {
5115 if ($(this).parent().hasClass("stone")) {
5116 res_min = 18000;
5117 } else {
5118 res_min = 15000;
5119 }
5120 res = parseInt(this.innerHTML, 10);
5121 if ((res >= res_min) && !($(this).hasClass("town_storage_full"))) {
5122 this.style.color = '#0A0';
5123 }
5124 if (res < res_min) {
5125 this.style.color = '#000';
5126 }
5127 });
5128 }
5129
5130 /********************************************************************************************************************************
5131 * Conquest Info
5132 * -----------------------------------------------------------------------------------------------------------------------------
5133 * | ● Amount of supports und attacks in the conquest window
5134 * | ● Layout adjustment (for reasons of clarity)
5135 * | - TODO: conquest window of own cities
5136 * -----------------------------------------------------------------------------------------------------------------------------
5137 * ******************************************************************************************************************************/
5138
5139 function countMovements() {
5140 var sup = 0, att = 0;
5141 $('.tab_content #unit_movements .support').each(function () {
5142 sup++;
5143 });
5144 $('.tab_content #unit_movements .attack_land, .tab_content #unit_movements .attack_sea, .tab_content #unit_movements .attack_takeover').each(function () {
5145 att++;
5146 });
5147
5148 var str = "<div id='move_counter' style=''><div style='float:left;margin-right:5px;'></div>" +
5149 "<div class='movement def'></div>" +
5150 "<div class='movement' style='color:green;'> " + sup + "</div>" +
5151 "<div class='movement off'> </div>" +
5152 "<div style='color:red;'> " + att + "</div></div>" +
5153 "<hr class='move_hr'>";
5154
5155 if ($('.gpwindow_content .tab_content .bold').get(0)) {
5156 $('.gpwindow_content .tab_content .bold').append(str);
5157 } else {
5158 $('.gpwindow_content h4:eq(1)').append(str);
5159
5160 // TODO: set player link ?
5161 /*
5162 $('#unit_movements li div').each(function(){
5163
5164 //console.log(this.innerHTML);
5165 });
5166 */
5167 }
5168
5169 $('<style id="dio_conquest"> ' +
5170 '.move_hr { margin:7px 0px 0px 0px; background-color:#5F5242; height:2px; border:0px solid; } ' +
5171 // Smaller movements
5172 '#unit_movements { font-size: 0.80em; } ' +
5173 '#unit_movements .incoming { width:150px; height:45px; float:left; } ' +
5174 // Counter
5175 '#move_counter { position:relative; width:100px; margin-top:-16px; left: 40%; } ' +
5176 '#move_counter .movement { float:left; margin:0px 5px 0px 0px; height:18px; width:18px; position:relative; } ' +
5177 '#move_counter .def { background:url(https://gpall.innogamescdn.com/images/game/place/losts.png); background-position:0 -36px; } ' +
5178 '#move_counter .off { background:url(https://gpall.innogamescdn.com/images/game/place/losts.png); background-position:0 0px; }' +
5179 '</style>').appendTo("head");
5180
5181 /*
5182 $('#unit_movements div').each(function(){
5183 if($(this).attr('class') === "unit_movements_arrow"){
5184 // delete placeholder for arrow of outgoing movements (there are no outgoing movements)
5185 if(!this.style.background) { this.remove(); }
5186 } else {
5187 // realign texts
5188 $(this).css({
5189 margin: '3px',
5190 paddingLeft: '3px'
5191 });
5192 }
5193 });
5194 */
5195 }
5196
5197 /*******************************************************************************************************************************
5198 * Town window
5199 * ----------------------------------------------------------------------------------------------------------------------------
5200 * | ● TownTabHandler (trade, attack, support,...)
5201 * | ● Sent units box
5202 * | ● Short duration: Display of 30% troop speed improvement in attack/support tab
5203 * | ● Trade options:
5204 * | - Ressource marks on possibility of city festivals
5205 * | - Percentual Trade: Trade button
5206 * | - Recruiting Trade: Selection boxes (ressource ratio of unit type + share of the warehouse capacity of the target town)
5207 * ----------------------------------------------------------------------------------------------------------------------------
5208 *******************************************************************************************************************************/
5209 var arrival_interval = {};
5210 // TODO: Change both functions in MultipleWindowHandler()
5211 function TownTabHandler(action) {
5212 var wndArray, wndID, wndA;
5213 wndArray = Layout.wnd.getOpen(uw.Layout.wnd.TYPE_TOWN);
5214 //console.log(wndArray);
5215 for (var e in wndArray) {
5216 if (wndArray.hasOwnProperty(e)) {
5217 //console.log(wndArray[e].getHandler());
5218 wndA = wndArray[e].getAction();
5219 wndID = "#gpwnd_" + wndArray[e].getID() + " ";
5220 if (!$(wndID).get(0)) {
5221 wndID = "#gpwnd_" + (wndArray[e].getID() + 1) + " ";
5222 }
5223 //console.log(wndID);
5224 if (wndA === action) {
5225 switch (action) {
5226 case "trading":
5227 if ($(wndID + '#trade_tab').get(0)) {
5228 if (!$(wndID + '.rec_trade').get(0) && DATA.options.rec) {
5229 RecruitingTrade.add(wndID);
5230 }
5231 //console.log(DATA.options.per);
5232 if (!$(wndID + '.btn_trade').get(0) && DATA.options.per) {
5233 addPercentTrade(wndID, false);
5234 }
5235 }
5236 //addTradeMarks(wndID, 15, 18, 15, "red"); // town festival
5237 break;
5238 case "support":
5239 case "attack":
5240 //if(!arrival_interval[wndID]){
5241 if (DATA.options.way && !($('.js-casted-powers-viewport .unit_movement_boost').get(0) || $(wndID + '.short_duration').get(0))) {
5242 //if(arrival_interval[wndID]) console.log("add " + wndID);
5243 ShortDuration.add(wndID);
5244 }
5245 if (DATA.options.sen) {
5246 SentUnits.add(wndID, action);
5247 }
5248 //}
5249 break;
5250 case "rec_mark":
5251 //addTradeMarks(wndID, 15, 18, 15, "lime");
5252 break;
5253 }
5254 }
5255 }
5256 }
5257 }
5258
5259 function WWTradeHandler() {
5260 var wndArray, wndID, wndA;
5261 wndArray = uw.GPWindowMgr.getOpen(uw.GPWindowMgr.TYPE_WONDERS);
5262 for (var e in wndArray) {
5263 if (wndArray.hasOwnProperty(e)) {
5264 wndID = "#gpwnd_" + wndArray[e].getID() + " ";
5265 if (DATA.options.per && !($(wndID + '.btn_trade').get(0) || $(wndID + '.next_building_phase').get(0) || $(wndID + '#ww_time_progressbar').get(0))) {
5266 addPercentTrade(wndID, true);
5267 }
5268 }
5269 }
5270 }
5271
5272 /*******************************************************************************************************************************
5273 * ● Sent units box
5274 *******************************************************************************************************************************/
5275 var SentUnits = {
5276 activate: function () {
5277 $.Observer(GameEvents.command.send_unit).subscribe('DIO_SEND_UNITS', function (e, data) {
5278 for (var z in data.params) {
5279 if (data.params.hasOwnProperty(z) && (data.sending_type !== "")) {
5280 if (uw.GameData.units[z]) {
5281 sentUnitsArray[data.sending_type][z] = (sentUnitsArray[data.sending_type][z] == undefined ? 0 : sentUnitsArray[data.sending_type][z]);
5282 sentUnitsArray[data.sending_type][z] += data.params[z];
5283 }
5284 }
5285 }
5286 //SentUnits.update(data.sending_type); ????
5287 });
5288 },
5289 deactivate: function () {
5290 $.Observer(GameEvents.command.send_unit).unsubscribe('DIO_SEND_UNITS');
5291 },
5292 add: function (wndID, action) {
5293 if (!$(wndID + '.sent_units_box').get(0)) {
5294 $('<div class="game_inner_box sent_units_box ' + action + '"><div class="game_border ">' +
5295 '<div class="game_border_top"></div><div class="game_border_bottom"></div><div class="game_border_left"></div><div class="game_border_right"></div>' +
5296 '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
5297 '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
5298 '<div class="game_header bold">' +
5299 '<div class="icon_sent townicon_' + (action == "attack" ? "lo" : "ld") + '"></div><span>' + getText("labels", "lab") + ' (' + (action == "attack" ? "OFF" : "DEF") + ')</span>' +
5300 '</div>' +
5301 '<div class="troops"><div class="units_list"></div><hr style="width: 172px;border: 1px solid rgb(185, 142, 93);margin: 3px 0px 2px -1px;">' +
5302 '<div id="btn_sent_units_reset" class="button_new">' +
5303 '<div class="left"></div>' +
5304 '<div class="right"></div>' +
5305 '<div class="caption js-caption">' + getText("buttons", "res") + '<div class="effect js-effect"></div></div>' +
5306 '</div>' +
5307 '</div></div>').appendTo(wndID + '.attack_support_window');
5308
5309 SentUnits.update(action);
5310
5311 $(wndID + '.icon_sent').css({
5312 height: '20px',
5313 marginTop: '-2px',
5314 width: '20px',
5315 backgroundPositionY: '-26px',
5316 paddingLeft: '0px',
5317 marginLeft: '0px'
5318 });
5319
5320 $(wndID + '.sent_units_box').css({
5321 position: 'absolute',
5322 right: '0px',
5323 bottom: '16px',
5324 width: '192px'
5325 });
5326 $(wndID + '.troops').css({padding: '6px 0px 6px 6px'});
5327
5328 $(wndID + '#btn_sent_units_reset').click(function () {
5329 // Overwrite old array
5330 sentUnitsArray[action] = {};
5331
5332 SentUnits.update(action);
5333 });
5334 }
5335 },
5336 update: function (action) {
5337 try {
5338 // Remove old unit list
5339 $('.sent_units_box.' + action + ' .units_list').each(function () {
5340 this.innerHTML = "";
5341 });
5342 // Add new unit list
5343 for (var x in sentUnitsArray[action]) {
5344 if (sentUnitsArray[action].hasOwnProperty(x)) {
5345 if ((sentUnitsArray[action][x] || 0) > 0) {
5346 $('.sent_units_box.' + action + ' .units_list').each(function () {
5347 $(this).append('<div class="unit_icon25x25 ' + x +
5348 (sentUnitsArray[action][x] >= 1000 ? (sentUnitsArray[action][x] >= 10000 ? " five_digit_number" : " four_digit_number") : "") + '">' +
5349 '<span class="count text_shadow">' + sentUnitsArray[action][x] + '</span>' +
5350 '</div>');
5351 });
5352 }
5353 }
5354 }
5355 saveValue(WID + "_sentUnits", JSON.stringify(sentUnitsArray));
5356 } catch (error) {
5357 errorHandling(error, "updateSentUnitsBox");
5358 }
5359 }
5360 };
5361
5362 /*******************************************************************************************************************************
5363 * ● Short duration
5364 *******************************************************************************************************************************/
5365
5366 // TODO: Calculator implementieren
5367 var DurationCalculator = {
5368 activate: function () {
5369 var speedBoosterSprite = "https://diotools.de/images/game/speed_booster.png";
5370
5371 $('<style id="dio_duration_calculator_style">' +
5372 '.dio_speed_booster { border:1px solid #724B08; border-spacing: 0px;} ' +
5373 '.dio_speed_booster td { border:0; padding:2px; } ' +
5374 '.dio_speed_booster .checkbox_new { margin: 4px 0px 1px 3px; } ' +
5375 '.dio_speed_booster .odd { background: url("https://gpall.innogamescdn.com/images/game/border/brown.png") repeat scroll 0% 0% transparent; } ' +
5376 '.dio_speed_booster .even { background: url("https://gpall.innogamescdn.com/images/game/border/odd.png") repeat scroll 0% 0% transparent; } ' +
5377 '.booster_icon { width:20px; height:20px; background-image:url(' + speedBoosterSprite + ');} ' +
5378 '.booster_icon.improved_speed { background-position:0 0; } ' +
5379 '.booster_icon.cartography { background-position:-20px 0; } ' +
5380 '.booster_icon.meteorology { background-position:-40px 0; } ' +
5381 '.booster_icon.lighthouse { background-position:-60px 0; } ' +
5382 '.booster_icon.set_sail { background-position:-80px 0; } ' +
5383 '.booster_icon.atalanta { background-position:-100px 0; } ' +
5384 '</style>').appendTo('head');
5385
5386 $('<table class="dio_speed_booster"><tr>' +
5387 '<td class="odd"><div class="booster_icon improved_speed"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5388 '<td class="even"><div class="booster_icon cartography"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5389 '<td class="odd"><div class="booster_icon meteorology"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5390 '<td class="even"><div class="booster_icon lighthouse"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5391 '<td class="odd"><div class="booster_icon set_sail"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5392 '<td class="even"><div class="booster_icon atalanta"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5393 '</tr></table>').appendTo(wndID + ".duration_container");
5394 },
5395 deactivate: function () {
5396 $('#dio_duration_calculator_style').remove();
5397 },
5398 add: function (wndID, data) {
5399
5400 }
5401 };
5402
5403
5404 var ShortDuration = {
5405 activate: function () {
5406
5407 $('<style id="dio_short_duration_style">' +
5408 '.attack_support_window .tab_type_support .duration_container { top:0px !important; } ' +
5409 //'.attack_support_window .tab_type_attack .duration_container { width:auto; top:10px; } ' +
5410
5411 '.attack_support_window .dio_duration { border-spacing:0px; margin-bottom:2px; text-align:right; } ' +
5412
5413 '.attack_support_window .way_duration, '+
5414 '.attack_support_window .arrival_time { padding:0px 0px 0px 0px; background:none; } ' +
5415
5416 '.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; } ' +
5417 '.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; } ' +
5418 '.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); } ' +
5419
5420 '.attack_support_window .max_booty { padding:0px 0px 0px 30px; margin:3px 4px 4px 4px; width:auto; } ' +
5421 '.attack_support_window .fight_bonus.morale { margin-top:2px; } ' +
5422
5423 '.attack_support_window .fast_boats_needed { background:transparent url(http://s7.directupload.net/images/140724/4pvfuch8.png) no-repeat 0 0; padding:2px 10px 7px 24px; margin:13px 0px -8px 13px; } ' +
5424 '.attack_support_window .slow_boats_needed { background:transparent url(http://s1.directupload.net/images/140724/b5xl8nmj.png) no-repeat 0 0; padding:2px 10px 7px 24px; margin:13px 0px -8px 13px; } ' +
5425
5426 '</style>').appendTo('head');
5427
5428 },
5429 deactivate: function () {
5430 $("#dio_short_duration_style").remove();
5431 },
5432 add: function (wndID) {
5433 //console.log($(wndID + ".duration_container").get(0));
5434 try {
5435 var tooltip = (LANG.hasOwnProperty(LID) ? getText("labels", "improved_movement") : "") + " (+30% " + DM.getl10n("barracks", "tooltips").speed.trim() + ")";
5436
5437 $('<table class="dio_duration">' +
5438 '<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>' +
5439 '<tr class="short_duration_row" style="color:darkgreen">' +
5440 '<td> ╚> </td><td><span class="short_duration">~0:00:00</span></td>' +
5441 '<td> ╚></td><td><span class="short_arrival">~00:00:00</span></td>' +
5442 '<td class="short_icon"></td><td></td></tr>' +
5443 '</table>').prependTo(wndID + ".duration_container");
5444
5445
5446
5447 $(wndID + ".nightbonus").appendTo(wndID + ".dio_night");
5448 $(wndID + '.way_duration').appendTo(wndID + ".dio_way");
5449 $(wndID + ".arrival_time").appendTo(wndID + ".dio_arrival");
5450
5451
5452 // Tooltip
5453 $(wndID + '.short_duration_row').tooltip(tooltip);
5454
5455 // Detection of changes
5456 ShortDuration.change(wndID);
5457 // $(wndID + '.way_duration').bind('DOMSubtreeModified', function(e) { console.log(e); }); // Alternative
5458
5459 } catch (error) {
5460 errorHandling(error, "addShortDuration");
5461 }
5462 },
5463 change: function (wndID) {
5464 var duration = new MutationObserver(function (mutations) {
5465 mutations.forEach(function (mutation) {
5466 if (mutation.addedNodes[0]) {
5467 //console.debug(mutation);
5468 ShortDuration.calculate(wndID);
5469 }
5470 });
5471 });
5472 if ($(wndID + '.way_duration').get(0)) {
5473 duration.observe($(wndID + '.way_duration').get(0), {
5474 attributes: false,
5475 childList: true,
5476 characterData: false
5477 });
5478 }
5479 },
5480 //$('<style> .duration_container { display: block !important } </style>').appendTo("head");
5481 calculate: function (wndID) {
5482 //console.log(wndID);
5483 //console.log($(wndID + '.duration_container .way_duration').get(0));
5484 try {
5485 var setup_time = 900 / Game.game_speed,
5486 duration_time = $(wndID + '.duration_container .way_duration').get(0).innerHTML.replace("~", "").split(":"),
5487 // TODO: hier tritt manchmal Fehler auf TypeError: Cannot read property "innerHTML" of undefined at calcShortDuration (<anonymous>:3073:86)
5488 arrival_time,
5489 h, m, s,
5490 atalanta_factor = 0;
5491
5492 var hasCartography = ITowns.getTown(Game.townId).getResearches().get("cartography");
5493 var hasMeteorology = ITowns.getTown(Game.townId).getResearches().get("meteorology");
5494 var hasSetSail = ITowns.getTown(Game.townId).getResearches().get("set_sail");
5495
5496 var hasLighthouse = ITowns.getTown(Game.townId).buildings().get("lighthouse");
5497
5498 // Atalanta aktiviert?
5499 if ($(wndID + '.unit_container.heroes_pickup .atalanta').get(0)) {
5500 if ($(wndID + '.cbx_include_hero').hasClass("checked")) {
5501 // Beschleunigung hängt vom Level ab, Level 1 = 11%, Level 20 = 30%
5502 var atalanta_level = MM.getCollections().PlayerHero[0].models[1].get("level");
5503
5504 atalanta_factor = (atalanta_level + 10) / 100;
5505 }
5506 }
5507
5508 // Sekunden, Minuten und Stunden zusammenrechnen (-> in Sekunden)
5509 duration_time = ((parseInt(duration_time[0], 10) * 60 + parseInt(duration_time[1], 10)) * 60 + parseInt(duration_time[2], 10));
5510
5511 // Verkürzte Laufzeit berechnen
5512 duration_time = ((duration_time - setup_time) * (1 + atalanta_factor)) / (1 + 0.3 + atalanta_factor) + setup_time;
5513
5514
5515 h = Math.floor(duration_time / 3600);
5516 m = Math.floor((duration_time - h * 3600) / 60);
5517 s = Math.floor(duration_time - h * 3600 - m * 60);
5518
5519 if (m < 10) {
5520 m = "0" + m;
5521 }
5522 if (s < 10) {
5523 s = "0" + s;
5524 }
5525
5526 $(wndID + '.short_duration').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
5527
5528 // Ankunftszeit errechnen
5529 arrival_time = Math.round((Timestamp.server() + Game.server_gmt_offset)) + duration_time;
5530
5531 h = Math.floor(arrival_time / 3600);
5532 m = Math.floor((arrival_time - h * 3600) / 60);
5533 s = Math.floor(arrival_time - h * 3600 - m * 60);
5534
5535 h %= 24;
5536
5537 if (m < 10) {
5538 m = "0" + m;
5539 }
5540 if (s < 10) {
5541 s = "0" + s;
5542 }
5543
5544 $(wndID + '.short_arrival').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
5545
5546 clearInterval(arrival_interval[wndID]);
5547
5548 arrival_interval[wndID] = setInterval(function () {
5549 arrival_time += 1;
5550
5551 h = Math.floor(arrival_time / 3600);
5552 m = Math.floor((arrival_time - h * 3600) / 60);
5553 s = Math.floor(arrival_time - h * 3600 - m * 60);
5554
5555 h %= 24;
5556
5557 if (m < 10) {
5558 m = "0" + m;
5559 }
5560 if (s < 10) {
5561 s = "0" + s;
5562 }
5563
5564 if ($(wndID + '.short_arrival').get(0)) {
5565 $(wndID + '.short_arrival').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
5566 } else {
5567 clearInterval(arrival_interval[wndID]);
5568 }
5569 }, 1000);
5570
5571 } catch (error) {
5572 errorHandling(error, "ShortDuration.calculate");
5573 }
5574 }
5575 };
5576
5577 /*******************************************************************************************************************************
5578 * ● Dropdown menu
5579 *******************************************************************************************************************************/
5580
5581 // TODO: Umstellen!
5582 // Preload images for drop down arrow buttons
5583 var drop_over = new Image();
5584 drop_over.src = "http://s7.directupload.net/images/140107/hna95u8a.png";
5585 var drop_out = new Image();
5586 drop_out.src = "http://s14.directupload.net/images/140107/ppsz5mxk.png";
5587
5588 function changeDropDownButton() {
5589 $('<style id="dio_style_arrow" type="text/css">' +
5590 '#dd_filter_type .arrow, .select_rec_unit .arrow {' +
5591 'width: 18px !important; height: 17px !important; background: url("http://s14.directupload.net/images/140107/ppsz5mxk.png") no-repeat 0px -1px !important;' +
5592 'position: absolute; top: 2px !important; right: 3px; } ' +
5593 '</style>').appendTo('head');
5594
5595 }
5596
5597 /*******************************************************************************************************************************
5598 * ● Recruiting Trade
5599 * *****************************************************************************************************************************/
5600 var trade_count = 0, unit = "FS", percent = "0.0"; // Recruiting Trade
5601
5602 // TODO: Funktion umformen, Style anpassen!
5603 var RecruitingTrade = {
5604 activate: function () {
5605 $('<style id="dio_style_recruiting_trade" type="text/css">' +
5606 '#dio_recruiting_trade .option_s { filter:grayscale(100%); -webkit-filter:grayscale(100%); margin:0px; cursor:pointer; } ' +
5607 '#dio_recruiting_trade .option_s:hover { filter:unset !important; -webkit-filter:unset !important; } ' +
5608 '#dio_recruiting_trade .select_rec_unit .sel { filter:sepia(100%); -webkit-filter:sepia(100%); } ' +
5609
5610 '#dio_recruiting_trade .option {color:#000; background:#FFEEC7; } ' +
5611 '#dio_recruiting_trade .option:hover {color:#fff; background:#328BF1; } ' +
5612
5613 '#dio_recruiting_trade { position:absolute; left:30px; top:70px; } ' +
5614 '#dio_recruiting_trade .select_rec_unit { position:absolute; top:20px; width:84px; display:none; } ' +
5615 '#dio_recruiting_trade .select_rec_perc { position:absolute; top:20px; width:50px; display:none; left:50px; } ' +
5616
5617 '#dio_recruiting_trade .open { display:block !important; } '+
5618
5619 '#dio_recruiting_trade .item-list { max-height:unset; } ' +
5620
5621 '#dio_recruiting_trade .arrow { width:18px; height:18px; background:url(' + drop_out.src + ') no-repeat -1px -1px; position:absolute; } ' +
5622
5623 '#trade_tab .content { height:320px; } ' +
5624
5625 '#dio_recruiting_trade .rec_count { position:absolute; top:25px; } ' +
5626
5627 '#dio_recruiting_trade .drop_rec_unit { position:absolute; display:block; width:50px; overflow:visible; } ' +
5628 '#dio_recruiting_trade .drop_rec_perc { position:absolute; display:block; width:55px; left:49px; color:#000; } ' +
5629
5630 '</style>').appendTo('head');
5631 },
5632 deactivate: function () {
5633 $('#dio_style_recruiting_trade').remove();
5634 },
5635 add: function (wndID) {
5636 var max_amount;
5637
5638 $('<div id="dio_recruiting_trade" class="rec_trade">' +
5639 // DropDown-Button for unit
5640 '<div class="drop_rec_unit dropdown default">' +
5641 '<div class="border-left"></div>' +
5642 '<div class="border-right"></div>' +
5643 '<div class="caption" name="' + unit + '">' + unit + '</div>' +
5644 '<div class="arrow"></div>' +
5645 '</div>' +
5646 '<div class="drop_rec_perc dropdown default">' +
5647 // DropDown-Button for ratio
5648 '<div class="border-left"></div>' +
5649 '<div class="border-right"></div>' +
5650 '<div class="caption" name="' + percent + '">' + Math.round(percent * 100) + '%</div>' +
5651 '<div class="arrow"></div>' +
5652 '</div><span class="rec_count">(' + trade_count + ')</span></div>').appendTo(wndID + ".content");
5653
5654 // Select boxes for unit and ratio
5655 $('<div class="select_rec_unit dropdown-list default active">' +
5656 '<div class="item-list">' +
5657 '<div class="option_s unit index_unit unit_icon40x40 attack_ship" name="FS"></div>' +
5658 '<div class="option_s unit index_unit unit_icon40x40 bireme" name="BI"></div>' +
5659 '<div class="option_s unit index_unit unit_icon40x40 sword" name="SK"></div>' +
5660 '<div class="option_s unit index_unit unit_icon40x40 slinger" name="SL"></div>' +
5661 '<div class="option_s unit index_unit unit_icon40x40 archer" name="BS"></div>' +
5662 '<div class="option_s unit index_unit unit_icon40x40 hoplite" name="HO"></div>' +
5663 '<div class="option_s unit index_unit unit_icon40x40 rider" name="RE"></div>' +
5664 '<div class="option_s unit index_unit unit_icon40x40 chariot" name="SW"></div>' +
5665 '</div></div>').appendTo(wndID + ".rec_trade");
5666 $('<div class="select_rec_perc dropdown-list default inactive">' +
5667 '<div class="item-list">' +
5668 '<div class="option sel" name="0.0"> 0%</div>' +
5669 '<div class="option" name="0.05"> 5%</div>' +
5670 '<div class="option" name="0.1">10%</div>' +
5671 '<div class="option" name="0.16666">17%</div>' +
5672 '<div class="option" name="0.2">20%</div>' +
5673 '<div class="option" name="0.25">25%</div>' +
5674 '<div class="option" name="0.33">33%</div>' +
5675 '<div class="option" name="0.5">50%</div>' +
5676 '</div></div>').appendTo(wndID + ".rec_trade");
5677
5678 $(wndID + ".rec_trade [name='" + unit + "']").toggleClass("sel");
5679
5680 // click events of the drop menu
5681 $(wndID + ' .select_rec_unit .option_s').each(function () {
5682 $(this).click(function (e) {
5683 $(".select_rec_unit .sel").toggleClass("sel");
5684 $("." + this.className.split(" ")[4]).toggleClass("sel");
5685
5686 unit = $(this).attr("name");
5687 $('.drop_rec_unit .caption').attr("name", unit);
5688 $('.drop_rec_unit .caption').each(function () {
5689 this.innerHTML = unit;
5690 });
5691 $($(this).parent().parent().get(0)).removeClass("open");
5692 $('.drop_rec_unit .caption').change();
5693 });
5694 });
5695 $(wndID + ' .select_rec_perc .option').each(function () {
5696 $(this).click(function (e) {
5697 $(this).parent().find(".sel").toggleClass("sel");
5698 $(this).toggleClass("sel");
5699
5700 percent = $(this).attr("name");
5701 $('.drop_rec_perc .caption').attr("name", percent);
5702 $('.drop_rec_perc .caption').each(function () {
5703 this.innerHTML = Math.round(percent * 100) + "%";
5704 });
5705 $($(this).parent().parent().get(0)).removeClass("open")
5706 $('.drop_rec_perc .caption').change();
5707 });
5708 });
5709
5710 // show & hide drop menus on click
5711 $(wndID + '.drop_rec_perc').click(function (e) {
5712
5713 if (!$($(e.target)[0].parentNode.parentNode.childNodes[4]).hasClass("open")) {
5714 $($(e.target)[0].parentNode.parentNode.childNodes[4]).addClass("open");
5715 $($(e.target)[0].parentNode.parentNode.childNodes[3]).removeClass("open");
5716 } else {
5717 $($(e.target)[0].parentNode.parentNode.childNodes[4]).removeClass("open");
5718 }
5719 });
5720 $(wndID + '.drop_rec_unit').click(function (e) {
5721
5722 if (!$($(e.target)[0].parentNode.parentNode.childNodes[3]).hasClass("open")) {
5723 $($(e.target)[0].parentNode.parentNode.childNodes[3]).addClass("open");
5724 $($(e.target)[0].parentNode.parentNode.childNodes[4]).removeClass("open");
5725 } else {
5726 $($(e.target)[0].parentNode.parentNode.childNodes[3]).removeClass("open");
5727 }
5728 });
5729
5730 $(wndID).click(function (e) {
5731 var clicked = $(e.target), element = $('#' + this.id + ' .dropdown-list.open').get(0);
5732 if ((clicked[0].parentNode.className.split(" ")[1] !== "dropdown") && element) {
5733 $(element).removeClass("open");
5734 }
5735 });
5736
5737 // hover arrow change
5738 $(wndID + '.dropdown').hover(function (e) {
5739 $(e.target)[0].parentNode.childNodes[3].style.background = "url('" + drop_over.src + "') no-repeat -1px -1px";
5740 }, function (e) {
5741 $(e.target)[0].parentNode.childNodes[3].style.background = "url('" + drop_out.src + "') no-repeat -1px -1px";
5742 });
5743
5744 $(wndID + ".drop_rec_unit .caption").attr("name", unit);
5745 $(wndID + ".drop_rec_perc .caption").attr("name", percent);
5746
5747 $(wndID + '.drop_rec_unit').tooltip(getText("labels", "rat"));
5748 $(wndID + '.drop_rec_perc').tooltip(getText("labels", "shr"));
5749
5750 var ratio = {
5751 NO: {w: 0, s: 0, i: 0},
5752 FS: {w: 1, s: 0.2308, i: 0.6154},
5753 BI: {w: 1, s: 0.8750, i: 0.2250},
5754 SL: {w: 0.55, s: 1, i: 0.4},
5755 RE: {w: 0.6666, s: 0.3333, i: 1},
5756 SK: {w: 1, s: 0, i: 0.8947},
5757 HO: {w: 0, s: 0.5, i: 1},
5758 BS: {w: 1, s: 0, i: 0.6250},
5759 SW: {w: 0.4545, s: 1, i: 0.7273}
5760 };
5761
5762
5763 if ($('#town_capacity_wood .max').get(0)) {
5764 max_amount = parseInt($('#town_capacity_wood .max').get(0).innerHTML, 10);
5765 } else {
5766 max_amount = 25500;
5767 }
5768
5769 $(wndID + '.caption').change(function (e) {
5770 //console.log($(this).attr('name') + ", " + unit + "; " + percent);
5771 if (!(($(this).attr('name') === unit) || ($(this).attr('name') === percent))) {
5772 //trade_count = 0;
5773 $('.rec_count').get(0).innerHTML = "(" + trade_count + ")";
5774 }
5775
5776 var tmp = $(this).attr('name');
5777
5778 if ($(this).parent().attr('class').split(" ")[0] === "drop_rec_unit") {
5779 unit = tmp;
5780 } else {
5781 percent = tmp;
5782 }
5783 var max = (max_amount - 100) / 1000;
5784 addTradeMarks(max * ratio[unit].w, max * ratio[unit].s, max * ratio[unit].i, "lime");
5785
5786 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)
5787 var rArray = uw.ITowns.getTown(uw.Game.townId).getCurrentResources();
5788 var tradeCapacity = uw.ITowns.getTown(uw.Game.townId).getAvailableTradeCapacity();
5789
5790 var wood = ratio[unit].w * part;
5791 var stone = ratio[unit].s * part;
5792 var iron = ratio[unit].i * part;
5793
5794 if ((wood > rArray.wood) || (stone > rArray.stone) || (iron > rArray.iron) || ( (wood + stone + iron) > tradeCapacity)) {
5795 wood = stone = iron = 0;
5796 $('.drop_rec_perc .caption').css({color: '#f00'});
5797 //$('.' + e.target.parentNode.parentNode.className + ' .select_rec_perc .sel').css({color:'#f00'});
5798 //$('.select_rec_perc .sel').css({color:'#f00'});
5799 } else {
5800 $('.' + e.target.parentNode.parentNode.className + ' .drop_rec_perc .caption').css({color: '#000'});
5801 }
5802 $("#trade_type_wood [type='text']").select().val(wood).blur();
5803 $("#trade_type_stone [type='text']").select().val(stone).blur();
5804 $("#trade_type_iron [type='text']").select().val(iron).blur();
5805 });
5806
5807 $('#trade_button').click(function () {
5808 trade_count++;
5809 $('.rec_count').get(0).innerHTML = "(" + trade_count + ")";
5810
5811 });
5812
5813 $(wndID + '.drop_rec_perc .caption').change();
5814 }
5815 };
5816
5817 /*******************************************************************************************************************************
5818 * ● Ressources marks
5819 *******************************************************************************************************************************/
5820 function addTradeMarks(woodmark, stonemark, ironmark, color) {
5821 var max_amount, limit, wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_TOWN), wndID;
5822 for (var e in wndArray) {
5823 if (wndArray.hasOwnProperty(e)) {
5824 wndID = "#gpwnd_" + wndArray[e].getID() + " ";
5825 if ($(wndID + '.town-capacity-indicator').get(0)) {
5826
5827 max_amount = $(wndID + '.amounts .max').get(0).innerHTML;
5828
5829 $('#trade_tab .c_' + color).each(function () {
5830 this.remove();
5831 });
5832 $('#trade_tab .progress').each(function () {
5833 if ($("p", this).length < 3) {
5834 if ($(this).parent().get(0).id != "big_progressbar") {
5835 limit = 1000 * (242 / parseInt(max_amount, 10));
5836
5837 switch ($(this).parent().get(0).id.split("_")[2]) {
5838 case "wood":
5839 limit = limit * woodmark;
5840 break;
5841 case "stone":
5842 limit = limit * stonemark;
5843 break;
5844 case "iron":
5845 limit = limit * ironmark;
5846 break;
5847 }
5848 $('<p class="c_' + color + '"style="position:absolute;left: ' + limit + 'px; background:' + color + ';width:2px;height:100%;margin:0px"></p>').appendTo(this);
5849 }
5850 }
5851 });
5852 }
5853 }
5854 }
5855 }
5856
5857 /*******************************************************************************************************************************
5858 * ● Percentual Trade
5859 *******************************************************************************************************************************/
5860 var rest_count = 0;
5861
5862 function addPercentTrade(wndID, ww) {
5863
5864 var a = "";
5865 var content = wndID + ".content";
5866 if (ww) {
5867 a = "ww_";
5868 content = wndID + '.trade .send_res';
5869 }
5870 $('<div class="btn btn_trade"><a class="button" href="#">' +
5871 '<span class="left"><span class="right">' +
5872 '<span class="middle mid">' +
5873 '<span class="img_trade"></span></span></span></span>' +
5874 '<span style="clear:both;"></span>' +
5875 '</a></div>').prependTo(content);
5876
5877 $(wndID + '.btn_trade').tooltip(getText("labels", "per"));
5878
5879 setPercentTrade(wndID, ww);
5880
5881 // Style
5882 $(wndID + '.btn').css({width: '20px', overflow: 'visible', position: 'absolute', display: 'block'});
5883
5884 if (!ww) {
5885 $(wndID + '.content').css({height: '320px'});
5886 }
5887
5888 if (ww) {
5889 $(wndID + '.btn_trade').css({left: '678px', top: '154px'});
5890 } else {
5891 $(wndID + '.btn_trade').css({left: '336px', top: '135px'});
5892 }
5893
5894 $(wndID + '.mid').css({minWidth: '26px'});
5895
5896 $(wndID + '.img_trade').css({
5897 width: '27px',
5898 height: '27px',
5899 top: '-3px',
5900 float: 'left',
5901 position: 'relative',
5902 background: 'url("http://666kb.com/i/cjq6d72qk521ig1zz.png") no-repeat'
5903 });
5904
5905 }
5906
5907 var res = {};
5908
5909 function setPercentTrade(wndID, ww) {
5910 var a = ww ? "ww_" : "", own_town = $(wndID + '.town_info').get(0) ? true : false;
5911
5912 $(wndID + '.btn_trade').toggleClick(function () {
5913 res.wood = {};
5914 res.stone = {};
5915 res.iron = {};
5916 res.sum = {};
5917
5918 res.sum.amount = 0;
5919 // Set amount of resources to 0
5920 setAmount(true, a, wndID);
5921 // Total amount of resources // TODO: ITowns.getTown(Game.townId).getCurrentResources(); ?
5922 for (var e in res) {
5923 if (res.hasOwnProperty(e) && e != "sum") {
5924 res[e].rest = false;
5925 res[e].amount = parseInt($('.ui_resources_bar .' + e + ' .amount').get(0).innerHTML, 10);
5926 res.sum.amount += res[e].amount;
5927 }
5928 }
5929 // Percentage of total resources
5930 res.wood.percent = 100 / res.sum.amount * res.wood.amount;
5931 res.stone.percent = 100 / res.sum.amount * res.stone.amount;
5932 res.iron.percent = 100 / res.sum.amount * res.iron.amount;
5933
5934 // Total trading capacity
5935 res.sum.cur = parseInt($(wndID + '#' + a + 'big_progressbar .caption .curr').get(0).innerHTML, 10);
5936
5937 // Amount of resources on the percentage of trading capacity (%)
5938 res.wood.part = parseInt(res.sum.cur / 100 * res.wood.percent, 10);
5939 res.stone.part = parseInt(res.sum.cur / 100 * res.stone.percent, 10);
5940 res.iron.part = parseInt(res.sum.cur / 100 * res.iron.percent, 10);
5941
5942 // Get rest warehouse capacity of each resource type
5943 for (var f in res) {
5944 if (res.hasOwnProperty(f) && f != "sum") {
5945 if (!ww && own_town) { // Own town
5946 var curr = parseInt($(wndID + '#town_capacity_' + f + ' .amounts .curr').get(0).innerHTML.replace('+', '').trim(), 10) || 0,
5947 curr2 = parseInt($(wndID + '#town_capacity_' + f + ' .amounts .curr2').get(0).innerHTML.replace('+', '').trim(), 10) || 0,
5948 max = parseInt($(wndID + '#town_capacity_' + f + ' .amounts .max').get(0).innerHTML.replace('+', '').trim(), 10) || 0;
5949
5950 res[f].cur = curr + curr2;
5951 res[f].max = max - res[f].cur;
5952
5953 if (res[f].max < 0) {
5954 res[f].max = 0;
5955 }
5956
5957 } else { // World wonder or foreign town
5958 res[f].max = 30000;
5959 }
5960 }
5961 }
5962 // Rest of fraction (0-2 units) add to stone amount
5963 res.stone.part += res.sum.cur - (res.wood.part + res.stone.part + res.iron.part);
5964
5965 res.sum.rest = 0;
5966 rest_count = 0;
5967 calcRestAmount();
5968 setAmount(false, a, wndID);
5969 }, function () {
5970 setAmount(true, a, wndID);
5971 });
5972 }
5973
5974 function calcRestAmount() {
5975 // Subdivide rest
5976 if (res.sum.rest > 0) {
5977 for (var e in res) {
5978 if (res.hasOwnProperty(e) && e != "sum" && res[e].rest != true) {
5979 res[e].part += res.sum.rest / (3 - rest_count);
5980 }
5981 }
5982 res.sum.rest = 0;
5983 }
5984 // Calculate new rest
5985 for (var f in res) {
5986 if (res.hasOwnProperty(f) && f != "sum" && res[f].rest != true) {
5987 if (res[f].max <= res[f].part) {
5988 res[f].rest = true;
5989 res.sum.rest += res[f].part - res[f].max;
5990 rest_count += 1;
5991 res[f].part = res[f].max;
5992 }
5993 }
5994 }
5995 // Recursion
5996 if (res.sum.rest > 0 && rest_count < 3) {
5997 calcRestAmount();
5998 }
5999 }
6000
6001 function setAmount(clear, a, wndID) {
6002 for (var e in res) {
6003 if (res.hasOwnProperty(e) && e != "sum") {
6004 if (clear == true) {
6005 res[e].part = 0;
6006 }
6007 $(wndID + "#" + a + "trade_type_" + e + ' [type="text"]').select().val(res[e].part).blur();
6008 }
6009 }
6010 }
6011
6012 /********************************************************************************************************************************
6013 * Unit strength (blunt/sharp/distance) and Transport Capacity
6014 * ----------------------------------------------------------------------------------------------------------------------------
6015 * | ● Unit strength: Menu
6016 * | - Switching of def/off display with buttons
6017 * | - Possible Selection of certain unit types
6018 * | ● Unit strength: Conquest
6019 * | ● Unit strength: Barracks
6020 * | ● Transport capacity: Menu
6021 * | - Switching of transporter speed (+/- big transporter)
6022 * ----------------------------------------------------------------------------------------------------------------------------
6023 * ******************************************************************************************************************************/
6024
6025 var def = true, blunt = 0, sharp = 0, dist = 0, shipsize = false;
6026
6027 var UnitStrength = {
6028 // Calculate defensive strength
6029 calcDef: function (units) {
6030 var e;
6031 blunt = sharp = dist = 0;
6032 for (e in units) {
6033 if (units.hasOwnProperty(e)) {
6034 blunt += units[e] * uw.GameData.units[e].def_hack;
6035 sharp += units[e] * uw.GameData.units[e].def_pierce;
6036 dist += units[e] * uw.GameData.units[e].def_distance;
6037 }
6038 }
6039 },
6040 // Calculate offensive strength
6041 calcOff: function (units, selectedUnits) {
6042 var e;
6043 blunt = sharp = dist = 0;
6044 for (e in selectedUnits) {
6045 if (selectedUnits.hasOwnProperty(e)) {
6046 var attack = (units[e] || 0) * uw.GameData.units[e].attack;
6047 switch (uw.GameData.units[e].attack_type) {
6048 case 'hack':
6049 blunt += attack;
6050 break;
6051 case 'pierce':
6052 sharp += attack;
6053 break;
6054 case 'distance':
6055 dist += attack;
6056 break;
6057 }
6058 }
6059 }
6060 },
6061 /*******************************************************************************************************************************
6062 * ● Unit strength: Unit menu
6063 *******************************************************************************************************************************/
6064 Menu: {
6065 activate: function () {
6066 $('<div id="strength" class="cont def"><hr>' +
6067 '<span class="bold text_shadow cont_left strength_font">' +
6068 '<table style="margin:0px;">' +
6069 '<tr><td><div class="ico units_info_sprite img_hack"></td><td id="blunt">0</td></tr>' +
6070 '<tr><td><div class="ico units_info_sprite img_pierce"></td><td id="sharp">0</td></tr>' +
6071 '<tr><td><div class="ico units_info_sprite img_dist"></td><td id="dist">0</td></tr>' +
6072 '</table>' +
6073 '</span>' +
6074 '<div class="cont_right">' +
6075 '<img id="def_button" class="active img" src="https://gpall.innogamescdn.com/images/game/unit_overview/support.png">' +
6076 '<img id="off_button" class="img" src="https://gpall.innogamescdn.com/images/game/unit_overview/attack.png">' +
6077 '</div></div>').appendTo('.units_land .content');
6078
6079 // Style
6080 $('<style id="dio_strength_style">' +
6081 '#strength.def #off_button, #strength.off #def_button { filter:url(#Sepia); -webkit-filter:sepia(1); }' +
6082 '#strength.off #off_button, #strength.def #def_button { filter:none; -webkit-filter:none; } ' +
6083
6084 '#strength.off .img_hack { background-position:0% 36%;} ' +
6085 '#strength.def .img_hack { background-position:0% 0%;} ' +
6086 '#strength.off .img_pierce { background-position:0% 27%;} ' +
6087 '#strength.def .img_pierce { background-position:0% 9%;} ' +
6088 '#strength.off .img_dist { background-position:0% 45%;} ' +
6089 '#strength.def .img_dist { background-position:0% 18%;} ' +
6090
6091 '#strength .strength_font { font-size: 0.8em; } ' +
6092 '#strength.off .strength_font { color:#edb;} ' +
6093 '#strength.def .strength_font { color:#fc6;} ' +
6094
6095 '#strength .ico { height:20px; width:20px; } ' +
6096 '#strength .units_info_sprite { background:url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png); background-size:100%; } ' +
6097
6098 '#strength .img_pierce { background-position:0px -20px; } ' +
6099 '#strength .img_dist { background-position:0px -40px; } ' +
6100 '#strength hr { margin:0px; background-color:#5F5242; height:2px; border:0px solid; } ' +
6101 '#strength .cont_left { width:65%; display:table-cell; } ' +
6102
6103 '#strength.cont { background:url(https://gpall.innogamescdn.com/images/game/layout/layout_units_nav_border.png); } ' +
6104
6105 '#strength .cont_right { width:30%; display:table-cell; vertical-align:middle; } ' +
6106 '#strength .img { float:right; background:none; margin:2px 8px 2px 0px; } ' +
6107
6108 '</style>').appendTo("head");
6109
6110 // Button events
6111 $('.units_land .units_wrapper, .btn_gods_spells .checked').click(function () {
6112 setTimeout(function () {
6113 UnitStrength.Menu.update();
6114 }, 100);
6115 });
6116
6117 $('#off_button').click(function () {
6118 $('#strength').addClass('off').removeClass('def');
6119
6120 def = false;
6121 UnitStrength.Menu.update();
6122 });
6123 $('#def_button').click(function () {
6124 $('#strength').addClass('def').removeClass('off');
6125
6126 def = true;
6127 UnitStrength.Menu.update();
6128 });
6129 $('#def_button, #off_button').hover(function () {
6130 $(this).css('cursor', 'pointer');
6131 });
6132
6133 UnitStrength.Menu.update();
6134 },
6135 deactivate: function () {
6136 $('#strength').remove();
6137 $('#dio_strength_style').remove();
6138 },
6139 update: function () {
6140 var unitsIn = uw.ITowns.getTown(uw.Game.townId).units(), units = UnitStrength.Menu.getSelected();
6141
6142 // Calculation
6143 if (def === true) {
6144 UnitStrength.calcDef(units);
6145 } else {
6146 UnitStrength.calcOff(unitsIn, units);
6147 }
6148 $('#blunt').get(0).innerHTML = blunt;
6149 $('#sharp').get(0).innerHTML = sharp;
6150 $('#dist').get(0).innerHTML = dist;
6151 },
6152 getSelected: function () {
6153 var units = [];
6154 if ($(".units_land .units_wrapper .selected").length > 0) {
6155 $(".units_land .units_wrapper .selected").each(function () {
6156 units[this.className.split(" ")[1]] = this.children[0].innerHTML;
6157 });
6158 } else {
6159 $(".units_land .units_wrapper .unit").each(function () {
6160 units[this.className.split(" ")[1]] = this.children[0].innerHTML;
6161 });
6162 }
6163 return units;
6164 }
6165 },
6166 /*******************************************************************************************************************************
6167 * ● Unit strength: Conquest
6168 *******************************************************************************************************************************/
6169 Conquest: {
6170 add: function () {
6171 var units = [], str;
6172
6173 // units of the siege
6174 $('#conqueror_units_in_town .unit').each(function () {
6175 str = $(this).attr("class").split(" ")[4];
6176 if (!uw.GameData.units[str].is_naval) {
6177 units[str] = parseInt(this.children[0].innerHTML, 10);
6178 //console.log($(this).attr("class").split(" ")[4]);
6179 }
6180 });
6181 // calculation
6182 UnitStrength.calcDef(units);
6183
6184 $('<div id="strength_eo" class="game_border" style="width:90px; margin: 20px; align:center;">' +
6185 '<div class="game_border_top"></div><div class="game_border_bottom"></div>' +
6186 '<div class="game_border_left"></div><div class="game_border_right"></div>' +
6187 '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
6188 '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
6189 '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">' +
6190 '<tr><td width="1%"><div class="ico units_info_sprite img_hack"></div></td><td id="bl" align="center" width="100%">0</td></tr>' +
6191 '<tr><td><div class="ico units_info_sprite img_pierce"></div></td><td id="sh" align="center">0</td></tr>' +
6192 '<tr><td><div class="ico units_info_sprite img_dist"></div></td><td id="di" align="center">0</td></tr>' +
6193 '</table></span>' +
6194 '</div>').appendTo('#conqueror_units_in_town');
6195
6196 $('#strength_eo').tooltip('Gesamteinheitenstärke der Belagerungstruppen');
6197
6198 // Veröffentlichung-Button-Text
6199 $('#conqueror_units_in_town .publish_conquest_public_id_wrap').css({
6200 marginLeft: '130px'
6201 });
6202
6203 $('#strength_eo .ico').css({
6204 height: '20px',
6205 width: '20px'
6206 });
6207 $('#strength_eo .units_info_sprite').css({
6208 background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
6209 backgroundSize: '100%'
6210 });
6211 $('#strength_eo .img_pierce').css({backgroundPosition: '0% 9%'});
6212 $('#strength_eo .img_dist').css({backgroundPosition: '0% 18%'});
6213
6214
6215 $('#bl').get(0).innerHTML = blunt;
6216 $('#sh').get(0).innerHTML = sharp;
6217 $('#di').get(0).innerHTML = dist;
6218 }
6219 },
6220 /*******************************************************************************************************************************
6221 * ● Unit strength: Barracks
6222 *******************************************************************************************************************************/
6223 Barracks: {
6224 add: function () {
6225 if (!$('#strength_baracks').get(0)) {
6226 var units = [], pop = 0;
6227
6228 // whole units of the town
6229 $('#units .unit_order_total').each(function () {
6230 units[$(this).parent().parent().attr("id")] = this.innerHTML;
6231 });
6232 // calculation
6233 UnitStrength.calcDef(units);
6234
6235 // population space of the units
6236 for (var e in units) {
6237 if (units.hasOwnProperty(e)) {
6238 pop += units[e] * uw.GameData.units[e].population;
6239 }
6240 }
6241 $('<div id="strength_baracks" class="game_border" style="float:right; width:70px; align:center;">' +
6242 '<div class="game_border_top"></div><div class="game_border_bottom"></div>' +
6243 '<div class="game_border_left"></div><div class="game_border_right"></div>' +
6244 '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
6245 '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
6246 '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">' +
6247 '<tr><td width="1%"><div class="ico units_info_sprite img_hack"></div></td><td id="b" align="center" width="100%">0</td></tr>' +
6248 '<tr><td><div class="ico units_info_sprite img_pierce"></div></td><td id="s" align="center">0</td></tr>' +
6249 '<tr><td><div class="ico units_info_sprite img_dist"></div></td><td id="d" align="center">0</td></tr>' +
6250 '</table></span>' +
6251 '</div>').appendTo('.ui-dialog #units');
6252
6253 $('<div id="pop_baracks" class="game_border" style="float:right; width:60px; align:center;">' +
6254 '<div class="game_border_top"></div><div class="game_border_bottom"></div>' +
6255 '<div class="game_border_left"></div><div class="game_border_right"></div>' +
6256 '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
6257 '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
6258 '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">' +
6259 '<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>' +
6260 '</table></span>' +
6261 '</div>').appendTo('.ui-dialog #units');
6262
6263 $('.ui-dialog #units .ico').css({
6264 height: '20px',
6265 width: '20px'
6266 });
6267 $('.ui-dialog #units .units_info_sprite').css({
6268 background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
6269 backgroundSize: '100%'
6270 });
6271 $('.ui-dialog #units .img_pierce').css({backgroundPosition: '0% 9%'});
6272 $('.ui-dialog #units .img_dist').css({backgroundPosition: '0% 18%'});
6273
6274 //$('#pop_baracks').tooltip('Bevölkerungszahl aller Landeinheiten der Stadt');
6275 //$('#strength_baracks').tooltip('Gesamteinheitenstärke stadteigener Truppen');
6276
6277 $('#b').get(0).innerHTML = blunt;
6278 $('#s').get(0).innerHTML = sharp;
6279 $('#d').get(0).innerHTML = dist;
6280 $('#p').get(0).innerHTML = pop;
6281 }
6282 }
6283 }
6284 };
6285
6286 /*******************************************************************************************************************************
6287 * ● Transporter capacity
6288 *******************************************************************************************************************************/
6289 var TransportCapacity = {
6290 activate: function () {
6291 // transporter display
6292 $('<div id="transporter" class="cont" style="height:25px;">' +
6293 '<table style=" margin:0px;"><tr align="center" >' +
6294 '<td><img id="ship_img" class="ico" src="http://s7.directupload.net/images/140724/4pvfuch8.png"></td>' +
6295 '<td><span id="ship" class="bold text_shadow" style="color:#FFCC66;font-size: 10px;line-height: 2.1;"></span></td>' +
6296 '</tr></table>' +
6297 '</div>').appendTo('.units_naval .content');
6298
6299 $('#transporter.cont').css({
6300 background: 'url(https://gpall.innogamescdn.com/images/game/layout/layout_units_nav_border.png)'
6301 });
6302
6303 $('#transporter').hover(function () {
6304 $(this).css('cursor', 'pointer');
6305 });
6306 $('#transporter').toggleClick(
6307 function () {
6308 $('#ship_img').get(0).src = "http://s1.directupload.net/images/140724/b5xl8nmj.png";
6309 shipsize = !shipsize;
6310 TransportCapacity.update();
6311 },
6312 function () {
6313 $('#ship_img').get(0).src = "http://s7.directupload.net/images/140724/4pvfuch8.png";
6314 shipsize = !shipsize;
6315 TransportCapacity.update();
6316 }
6317 );
6318 TransportCapacity.update();
6319 },
6320 deactivate: function () {
6321 $('#transporter').remove();
6322 },
6323 update: function () {
6324 var bigTransp = 0, smallTransp = 0, pop = 0, ship = 0, unit, berth, units = [];
6325 // Ship space (available)
6326 smallTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().small_transporter, 10);
6327 if (isNaN(smallTransp)) smallTransp = 0;
6328 if (shipsize) {
6329 bigTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().big_transporter, 10);
6330 if (isNaN(bigTransp)) bigTransp = 0;
6331 }
6332
6333 // Checking: Research berth
6334 berth = 0;
6335 if (uw.ITowns.getTown(uw.Game.townId).researches().hasBerth()) {
6336 berth = GameData.research_bonus.berth;
6337 }
6338 ship = bigTransp * (GameData.units.big_transporter.capacity + berth) + smallTransp * (GameData.units.small_transporter.capacity + berth);
6339
6340 units = uw.ITowns.getTown(uw.Game.townId).units();
6341
6342 // Ship space (required)
6343 for (var e in units) {
6344 if (units.hasOwnProperty(e)) {
6345 if (uw.GameData.units[e]) { // without Heroes
6346 if (!(uw.GameData.units[e].is_naval || uw.GameData.units[e].flying)) {
6347 pop += units[e] * uw.GameData.units[e].population;
6348 }
6349 }
6350 }
6351 }
6352 $('#ship').get(0).innerHTML = pop + "/" + ship;
6353 }
6354 };
6355
6356
6357 /*******************************************************************************************************************************
6358 * Simulator
6359 * ----------------------------------------------------------------------------------------------------------------------------
6360 * | ● Layout adjustment
6361 * | ● Permanent display of the extended modifier box
6362 * | ● Unit strength for entered units (without modificator influence yet)
6363 * ----------------------------------------------------------------------------------------------------------------------------
6364 *******************************************************************************************************************************/
6365 var Simulator = {
6366 activate: function () {
6367 $('<style id="dio_simulator_style" type="text/css">' +
6368
6369 '#place_simulator { overflow: hidden !important} ' +
6370 '#place_simulator .game_body { height: 417px !important} ' +
6371
6372 '#place_simulator_form h4 { display:none; } '+
6373
6374 '#place_simulator .place_simulator_table { margin: 0px !important } '+
6375
6376 '#place_simulator_form .place_sim_wrap_mods { margin-bottom: 2px; } '+
6377
6378 // Bonus container
6379 '.place_sim_bonuses_heroes { position:absolute; right:3px; top:27px; width: 272px;} ' +
6380 '.place_sim_bonuses_heroes .place_sim_showhide { display:none; } ' + // Hide modifier box button
6381
6382
6383 //'.place_sim_wrap_mods {position: relative; right: -17px !important} '+
6384 '.place_sim_wrap_mods .place_simulator_table :eq(1) { width: 300px;} ' + ////////////// genauer!
6385 '.place_sim_wrap_mods > .place_simulator_table { width: 272px;} ' + ////////////// genauer!
6386
6387 // Wall losses
6388 '.place_sim_wrap_mods tr:last-child { display:none; } ' +
6389
6390 // Extended modifier box
6391 //'@-webkit-keyframes MODBOX { 0% { opacity: 0; } 100% { opacity: 1; } } '+
6392 //'@keyframes MODBOX { 0% { opacity: 0; } 100% { opacity: 1; } } '+
6393
6394 '.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} ' +
6395 '.place_sim_wrap_mods_extended table tr td:eq(0) { width: 18px !important } ' +
6396 '.place_sim_wrap_mods_extended td { border:0px; } ' +
6397 '.place_sim_wrap_mods_extended tr td:first-child { border-left:0px; width:19px; padding-left:0px; } ' +
6398 '.place_sim_wrap_mods_extended .place_simulator_table { margin:0px; border-collapse:separate; border:1px solid #724B08; table-layout:fixed; width:100% } ' +
6399
6400 '.place_simulator_table .place_image { display:block; width: 20px; height:20px; background-size:100%; margin:auto; } ' +
6401
6402 '.place_simulator_table .place_image.pa_commander { background: url(https://diotools.de/images/game/advisors/advisors_22.png); background-position: 0px 44px; } ' +
6403 '.place_simulator_table .place_image.pa_captain { background: url(https://diotools.de/images/game/advisors/advisors_22.png); background-position: 0px 88px; } ' +
6404 '.place_simulator_table .place_image.pa_priest { background: url(https://diotools.de/images/game/advisors/advisors_22.png); background-position: 0px 66px; } ' +
6405
6406 '.place_simulator_table .place_image.is_night { background-position: 0px -40px; } ' +
6407 '.place_simulator_table .place_image.research_ram { background-position: 0px -300px; } ' +
6408 '.place_simulator_table .place_image.research_phalanx { background-position: 0px -280px; }' +
6409 '.place_simulator_table .place_image.research_divine_selection { background-position: 0 -600px; }' +
6410
6411 '.place_sim_wrap_mods_extended .place_cross { height:16px; background:none; } ' +
6412 '.place_sim_wrap_mods_extended .place_checkbox_field { display:table-cell; width:13px; height:13px; } ' +
6413
6414 '.place_sim_wrap_mods_extended tr:last-child { display:none;} ' +
6415
6416 '.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} ' +
6417
6418 '.place_sim_wrap_mods_extended .game_border>div { display:none; } ' +
6419 '.place_sim_wrap_mods_extended .game_border { margin:0px; } ' +
6420
6421 '.place_sim_wrap_mods_extended .game_border { height: 139px; overflow-y: auto; overflow-x: hidden; }' + // Größe der Modfikatorbox begrenzen
6422
6423 '#place_simulator .window_inner_curtain { display: none !important } ' + // Hintergrund entfernen bei offener Modifikatorbox
6424
6425 // Unit container
6426 '#simulator_body .unit_container { height: 50px !important; width: 50px !important; margin: 0px 3px 0px 1px !important} ' +
6427 '.place_simulator_odd, .place_simulator_even { text-align: center !important} ' +
6428 '.place_insert_field { margin: 0px !important} ' +
6429
6430 '#place_sim_ground_units { position:absolute; bottom: 35px;} ' +
6431
6432 // Sea unit box
6433 '#place_sim_naval_units { position: absolute; } ' +
6434 '#place_sim_naval_units tbody tr:last-child { height:auto !important; }' +
6435
6436 // Land unit box
6437 '#place_sim_wrap_units { position: absolute !important; bottom: 35px !important} ' +
6438
6439 '#simulator_body>h4 { position:absolute;bottom:188px;} ' +
6440
6441 // Select boxes
6442 '.place_sim_select_gods_wrap { position:absolute; bottom:182px; } ' +
6443
6444 '.place_sim_select_gods_wrap .place_sim_select_gods { width: 150px; } ' +
6445 '.place_sim_select_gods_wrap select { max-width: 120px; } ' +
6446
6447 '.place_sim_select_gods_wrap .place_symbol, .place_sim_select_strategies .place_symbol { margin: 1px 2px 0px 5px !important} ' +
6448 '.place_sim_insert_units .place_symbol { filter: hue-rotate(330deg); -webkit-filter: hue-rotate(330deg);} ' +
6449 '.place_attack { float: left !important} ' +
6450
6451 // Hero box
6452 '.place_sim_heroes_container { position: absolute; right: 0px; z-index: 1; } ' +
6453 '.place_sim_hero_container { width: 45px !important; height: 25px !important} ' +
6454
6455 '#place_simulator .place_sim_bonuses_heroes h4:nth-of-type(2) { display:none; }' + // Heroes title
6456
6457 // - Hero container
6458 '.place_sim_hero_choose, .place_sim_hero_unit_container { height: 26px !important; width: 30px !important} ' +
6459 '#hero_defense_icon, #hero_attack_icon { height: 25px !important; width: 25px !important; margin: 0px !important} ' +
6460 '#hero_defense_dd, #hero_attack_dd { height: 25px !important; width: 25px !important; margin: 1px !important} ' +
6461 '.place_sim_hero_attack, .place_sim_hero_defense { margin-left: 3px !important} ' +
6462 '#hero_attack_text, #hero_defense_text { font-size: 11px !important; bottom: 0px !important} ' +
6463 '.place_sim_heroes_container .plus { left: 2px; top: 2px !important} ' +
6464
6465 '.place_sim_heroes_container .button_new.square { left: 2px !important; } ' +
6466
6467
6468 // - Hero spinner
6469 '.place_sim_heroes_container .spinner { height: 25px !important; width: 40px !important } ' +
6470 '.place_sim_heroes_container td:nth-child(0) { height: 30px !important} ' +
6471 '.place_sim_heroes_container .spinner { height: 24px !important; position:absolute !important; width:12px !important; left:29px !important; '+
6472 'background:url(https://gpall.innogamescdn.com/images/game/border/odd.png) repeat !important; border: 1px solid rgb(107, 107, 107) !important; } ' +
6473 '.place_sim_heroes_container .spinner .button_down, .place_sim_heroes_container .spinner .button_up { bottom: 2px !important; cursor: pointer !important} ' +
6474 '.place_sim_heroes_container .spinner .border_l, .place_sim_heroes_container .spinner .border_r, .place_sim_heroes_container .spinner .body { display:none; } '+
6475
6476 // Quack
6477 '#q_place_sim_lost_res { display: none; } ' +
6478 '</style>').appendTo('head');
6479
6480 if($('#place_simulator').get(0)) {
6481 Simulator.change();
6482 }
6483
6484 SimulatorStrength.activate();
6485
6486 },
6487 deactivate: function () {
6488 $('#dio_simulator_style').remove();
6489 if($('#simu_table').get(0)) {
6490 $('#simu_table').remove();
6491
6492 // Hero box
6493 if ($('.place_sim_heroes_container').get(0)) {
6494 $('.hero_unit').each(function () {
6495 $(this).addClass('unit_icon40x40').removeClass('unit_icon25x25');
6496 });
6497
6498 // Hero spinner
6499 $('.place_sim_heroes_container .spinner').each(function () {
6500 $(this).addClass('place_sim_hero_spinner');
6501 });
6502 }
6503 }
6504
6505 SimulatorStrength.deactivate();
6506 },
6507 change: function () {
6508 // TODO: Durch CSS ersetzen...
6509
6510 // Wall loss
6511 $('.place_sim_wrap_mods tr:eq(1) td:eq(5)').html('<span id="building_place_def_losses_wall_level" class="place_losses bold"></span>');
6512
6513 // Extended modificator box
6514 $('.place_sim_wrap_mods_extended .power').each(function () {
6515 $(this).removeClass("power_icon45x45").addClass("power_icon16x16");
6516 });
6517 $('.place_sim_wrap_mods_extended td:nth-child(even)').each(function () {
6518 $(this).addClass("left_border place_simulator_odd");
6519 });
6520 $('.place_sim_wrap_mods_extended td:nth-child(odd)').each(function () {
6521 $(this).addClass("left_border place_simulator_even");
6522 });
6523
6524 // Border entfernen
6525 $('.place_sim_wrap_mods_extend td:first-child').each(function () {
6526 $(this).removeClass("left_border");
6527 });
6528
6529 // -> Update percentage each time
6530 $('.place_checkbox_field').click(function () {
6531 FightSimulator.closeModsExtended(); //$('.place_sim_bonuses_more_confirm').get(0).click();
6532 });
6533
6534 // Hero world ?
6535 if (uw.Game.hasArtemis) {
6536 $('.place_sim_wrap_mods_extend tr').each(function () {
6537 this.children[1].style.borderLeft = "none";
6538 this.children[0].remove();
6539 });
6540 }
6541
6542 // Hero box
6543 if ($('.place_sim_heroes_container').get(0)) {
6544 $('.hero_unit').each(function () {
6545 $(this).removeClass('unit_icon40x40').addClass('unit_icon25x25');
6546 });
6547
6548 // Hero spinner
6549 $('.place_sim_heroes_container .spinner').each(function () {
6550 $(this).removeClass('place_sim_hero_spinner');
6551 });
6552 }
6553
6554 setStrengthSimulator();
6555 }
6556 };
6557
6558 function afterSimulation() {
6559 var lossArray = {att: {res: 0, fav: 0, pop: 0}, def: {res: 0, fav: 0, pop: 0}},
6560 wall_level = parseInt($('.place_sim_wrap_mods .place_insert_field[name="sim[mods][def][wall_level]"]').val(), 10),
6561 wall_damage = parseInt($('#building_place_def_losses_wall_level').get(0).innerHTML, 10),
6562 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];
6563
6564 // Calculate unit losses
6565 $('#place_sim_ground_units .place_losses, #place_sim_naval_units .place_losses').each(function () {
6566 var loss = parseInt(this.innerHTML, 10) || 0;
6567 //console.log(this.innerHTML);
6568 if (loss > 0) {
6569 var unit = this.id.substring(26);
6570 var side = this.id.split("_")[2]; // att / def
6571 lossArray[side].res += loss * (uw.GameData.units[unit].resources.wood + uw.GameData.units[unit].resources.stone + uw.GameData.units[unit].resources.iron);
6572 lossArray[side].fav += loss * uw.GameData.units[unit].favor;
6573 lossArray[side].pop += loss * uw.GameData.units[unit].population;
6574 }
6575 });
6576 // Calculate wall resource losses
6577 for (var w = wall_level; w > wall_level - wall_damage; w--) {
6578 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
6579 }
6580
6581 // Insert losses into table
6582 for (var x in lossArray) {
6583 if (lossArray.hasOwnProperty(x)) {
6584 for (var z in lossArray[x]) {
6585 if (lossArray[x].hasOwnProperty(z)) {
6586 //console.log(((z === "res") && (lossArray[x][z] > 10000)) ? (Math.round(lossArray[x][z] / 1000) + "k") : lossArray[x][z]);
6587 $("#" + x + "_" + z).get(0).innerHTML = ((z === "res") && (lossArray[x][z] > 10000)) ? (Math.round(lossArray[x][z] / 1000) + "k") : lossArray[x][z];
6588
6589 }
6590 }
6591 }
6592 }
6593 }
6594
6595 // Stärkeanzeige: Simulator
6596 var unitsGround = {att: {}, def: {}}, unitsNaval = {att: {}, def: {}}, name = "";
6597
6598 var SimulatorStrength = {
6599 unitsGround : {att: {}, def: {}},
6600 unitsNaval : {att: {}, def: {}},
6601
6602 activate : function(){
6603 $('<style id="dio_simulator_strength_style">'+
6604 '#dio_simulator_strength { position:absolute; top:192px; font-size:0.8em; width:63%; } '+
6605 '#dio_simulator_strength .ico { height:20px; width:20px; margin:auto; } '+
6606 '#dio_simulator_strength .units_info_sprite { background:url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png); background-size:100%; } ' +
6607
6608 '#dio_simulator_strength .img_hack { background-position:0% 36%; } '+
6609 '#dio_simulator_strength .img_pierce { background-position:0% 27%; } '+
6610 '#dio_simulator_strength .img_dist { background-position:0% 45% !important; } '+
6611 '#dio_simulator_strength .img_ship { background-position:0% 72%; } '+
6612
6613 '#dio_simulator_strength .img_fav { background: url(https://gpall.innogamescdn.com/images/game/res/favor.png) !important; background-size: 100%; } '+
6614 '#dio_simulator_strength .img_res { background: url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png) 0% 54%; background-size: 100%; } '+
6615 '#dio_simulator_strength .img_pop { background: url(https://gpall.innogamescdn.com/images/game/res/pop.png); background-size:100%; } '+
6616
6617 '#dio_simulator_strength .left_border { width: 54px; } '+
6618 '</style>'
6619 ).appendTo('head');
6620
6621 },
6622 deactivate : function(){
6623 $('#dio_simulator_strength_style').remove();
6624 },
6625 add : function(){
6626 $('<div id="dio_simulator_strength">' +
6627 '<div style="float:left; margin-right:12px;"><h4>' + getText("labels", "str") + '</h4>' +
6628 '<table class="place_simulator_table strength" cellpadding="0px" cellspacing="0px" style="align:center;">' +
6629 '<tr>' +
6630 '<td class="place_simulator_even"></td>' +
6631 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_hack"></div></td>' +
6632 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_pierce"></div></td>' +
6633 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_dist"></div></td>' +
6634 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_ship"></div></td>' +
6635 '</tr><tr>' +
6636 '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>' +
6637 '<td class="left_border place_simulator_odd" id="att_b">0</td>' +
6638 '<td class="left_border place_simulator_even" id="att_s">0</td>' +
6639 '<td class="left_border place_simulator_odd" id="att_d">0</td>' +
6640 '<td class="left_border place_simulator_even" id="att_ship">0</td>' +
6641 '</tr><tr>' +
6642 '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
6643 '<td class="left_border place_simulator_odd" id="def_b">0</td>' +
6644 '<td class="left_border place_simulator_even" id="def_s">0</td>' +
6645 '<td class="left_border place_simulator_odd" id="def_d">0</td>' +
6646 '<td class="left_border place_simulator_even" id="def_ship">0</td>' +
6647 '</tr>' +
6648 '</table>' +
6649 '</div><div><h4>' + getText("labels", "los") + '</h4>' +
6650 '<table class="place_simulator_table loss" cellpadding="0px" cellspacing="0px" style="align:center;">' +
6651 '<tr>' +
6652 '<td class="place_simulator_even"></td>' +
6653 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_res"></div></td>' +
6654 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_fav"></div></td>' +
6655 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_pop"></div></td>' +
6656 '</tr><tr>' +
6657 '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>' +
6658 '<td class="left_border place_simulator_odd" id="att_res">0</td>' +
6659 '<td class="left_border place_simulator_even" id="att_fav">0</td>' +
6660 '<td class="left_border place_simulator_odd" id="att_pop">0</td>' +
6661 '</tr><tr>' +
6662 '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
6663 '<td class="left_border place_simulator_odd" id="def_res">0</td>' +
6664 '<td class="left_border place_simulator_even" id="def_fav">0</td>' +
6665 '<td class="left_border place_simulator_odd" id="def_pop">0</td>' +
6666 '</tr>' +
6667 '</table>' +
6668 '</div></div>').appendTo('#simulator_body');
6669
6670
6671 $('#dio_simulator_strength .left_border').each(function () {
6672 $(this)[0].align = 'center';
6673 });
6674
6675 // Tooltips setzen
6676 $('#dio_simulator_strength .strength').tooltip(getText("labels", "str") + " (" + getText("labels", "mod") + ")");
6677 $('#dio_simulator_strength .loss').tooltip(getText("labels", "los"));
6678
6679 // Klick auf Einheitenbild
6680 $('.index_unit').click(function () {
6681 var type = $(this).attr('class').split(" ")[4];
6682 $('.place_insert_field[name="sim[units][att][' + type + ']"]').change();
6683 });
6684
6685 $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').on('input change', function () {
6686 name = $(this).attr("name").replace(/\]/g, "").split("[");
6687 var str = this;
6688
6689
6690 setTimeout(function () {
6691 var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2],
6692 val, e;
6693
6694 val = parseInt($(str).val(), 10);
6695 val = val || 0;
6696
6697 if (unit_type == "ground") {
6698 unitsGround[name[2]][name[3]] = val;
6699
6700 if (name[2] == "def") {
6701 UnitStrength.calcDef(unitsGround.def);
6702 } else {
6703 UnitStrength.calcOff(unitsGround.att, unitsGround.att);
6704 }
6705 $('#' + name[2] + '_b').get(0).innerHTML = blunt;
6706 $('#' + name[2] + '_s').get(0).innerHTML = sharp;
6707 $('#' + name[2] + '_d').get(0).innerHTML = dist;
6708
6709 } else {
6710 var att = 0, def = 0;
6711 unitsNaval[name[2]][name[3]] = val;
6712
6713 if (name[2] == "def") {
6714 for (e in unitsNaval.def) {
6715 if (unitsNaval.def.hasOwnProperty(e)) {
6716 def += unitsNaval.def[e] * uw.GameData.units[e].defense;
6717 }
6718 }
6719 $('#def_ship').get(0).innerHTML = def;
6720
6721 } else {
6722 for (e in unitsNaval.att) {
6723 if (unitsNaval.att.hasOwnProperty(e)) {
6724 att += unitsNaval.att[e] * uw.GameData.units[e].attack;
6725 }
6726 }
6727 $('#att_ship').get(0).innerHTML = att;
6728 }
6729 }
6730 }, 100);
6731 });
6732
6733 // Abfrage wegen eventueller Spionageweiterleitung
6734 getUnitInputs();
6735 setTimeout(function () {
6736 setChangeUnitInputs("def");
6737 }, 100);
6738
6739 $('#select_insert_units').change(function () {
6740 var side = $(this).find('option:selected').val();
6741
6742 setTimeout(function () {
6743 getUnitInputs();
6744 if (side === "att" || side === "def") {
6745 setChangeUnitInputs(side);
6746 }
6747 }, 200);
6748 });
6749 },
6750
6751 getUnitInputs : function(){
6752 $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').each(function () {
6753 var name = $(this).attr("name").replace(/\]/g, "").split("[");
6754
6755 var str = this;
6756
6757 var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2];
6758
6759 var val = parseInt($(str).val(), 10);
6760
6761 val = val || 0;
6762
6763 if (unit_type === "ground") {
6764 SimulatorStrength.unitsGround[name[2]][name[3]] = val;
6765 } else {
6766 SimulatorStrength.unitsNaval[name[2]][name[3]] = val;
6767 }
6768 });
6769 },
6770
6771 updateStrength : function(){
6772
6773 }
6774 }
6775 function setStrengthSimulator() {
6776 $('<div id="dio_simulator_strength">' +
6777 '<div style="float:left; margin-right:12px;"><h4>' + getText("labels", "str") + '</h4>' +
6778 '<table class="place_simulator_table strength" cellpadding="0px" cellspacing="0px" style="align:center;">' +
6779 '<tr>' +
6780 '<td class="place_simulator_even"></td>' +
6781 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_hack"></div></td>' +
6782 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_pierce"></div></td>' +
6783 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_dist"></div></td>' +
6784 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_ship"></div></td>' +
6785 '</tr><tr>' +
6786 '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>' +
6787 '<td class="left_border place_simulator_odd" id="att_b">0</td>' +
6788 '<td class="left_border place_simulator_even" id="att_s">0</td>' +
6789 '<td class="left_border place_simulator_odd" id="att_d">0</td>' +
6790 '<td class="left_border place_simulator_even" id="att_ship">0</td>' +
6791 '</tr><tr>' +
6792 '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
6793 '<td class="left_border place_simulator_odd" id="def_b">0</td>' +
6794 '<td class="left_border place_simulator_even" id="def_s">0</td>' +
6795 '<td class="left_border place_simulator_odd" id="def_d">0</td>' +
6796 '<td class="left_border place_simulator_even" id="def_ship">0</td>' +
6797 '</tr>' +
6798 '</table>' +
6799 '</div><div><h4>' + getText("labels", "los") + '</h4>' +
6800 '<table class="place_simulator_table loss" cellpadding="0px" cellspacing="0px" style="align:center;">' +
6801 '<tr>' +
6802 '<td class="place_simulator_even"></td>' +
6803 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_res"></div></td>' +
6804 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_fav"></div></td>' +
6805 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_pop"></div></td>' +
6806 '</tr><tr>' +
6807 '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>' +
6808 '<td class="left_border place_simulator_odd" id="att_res">0</td>' +
6809 '<td class="left_border place_simulator_even" id="att_fav">0</td>' +
6810 '<td class="left_border place_simulator_odd" id="att_pop">0</td>' +
6811 '</tr><tr>' +
6812 '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
6813 '<td class="left_border place_simulator_odd" id="def_res">0</td>' +
6814 '<td class="left_border place_simulator_even" id="def_fav">0</td>' +
6815 '<td class="left_border place_simulator_odd" id="def_pop">0</td>' +
6816 '</tr>' +
6817 '</table>' +
6818 '</div></div>').appendTo('#simulator_body');
6819
6820
6821 /*
6822 $('#dio_simulator_strength').css({
6823 position: 'absolute',
6824 top: '192px',
6825 fontSize: '0.8em',
6826 width: '63%'
6827 });
6828 $('#dio_simulator_strength .ico').css({
6829 height: '20px',
6830 width: '20px',
6831 margin: 'auto'
6832 });
6833 $('#dio_simulator_strength .units_info_sprite').css({
6834 background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
6835 backgroundSize: '100%'
6836 });
6837 $('#dio_simulator_strength .img_hack').css({backgroundPosition: '0% 36%'});
6838 $('#dio_simulator_strength .img_pierce').css({backgroundPosition: '0% 27%'});
6839 $('#dio_simulator_strength .img_dist').css({backgroundPosition: '0% 45%'});
6840 $('#dio_simulator_strength .img_ship').css({backgroundPosition: '0% 72%'});
6841
6842 $('#dio_simulator_strength .img_fav').css({
6843 background: 'url(https://gpall.innogamescdn.com/images/game/res/favor.png)',
6844 backgroundSize: '100%'
6845 });
6846 $('#dio_simulator_strength .img_res').css({
6847 background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png) 0% 54%',
6848 backgroundSize: '100%'
6849 });
6850 $('#dio_simulator_strength .img_pop').css({
6851 background: 'url(https://gpall.innogamescdn.com/images/game/res/pop.png)',
6852 backgroundSize: '100%'
6853 });
6854
6855 $('#dio_simulator_strength .left_border').css({
6856 width: '54px'
6857 });
6858 */
6859
6860
6861 $('#dio_simulator_strength .left_border').each(function () {
6862 $(this)[0].align = 'center';
6863 });
6864
6865 $('#dio_simulator_strength .strength').tooltip(getText("labels", "str") + " (" + getText("labels", "mod") + ")");
6866 $('#dio_simulator_strength .loss').tooltip(getText("labels", "los"));
6867
6868 // Klick auf Einheitenbild
6869 $('.index_unit').click(function () {
6870 var type = $(this).attr('class').split(" ")[4];
6871 $('.place_insert_field[name="sim[units][att][' + type + ']"]').change();
6872 });
6873
6874 $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').on('input change', function () {
6875 name = $(this).attr("name").replace(/\]/g, "").split("[");
6876 var str = this;
6877 //console.log(str);
6878 setTimeout(function () {
6879 var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2],
6880 val, e;
6881
6882 val = parseInt($(str).val(), 10);
6883 val = val || 0;
6884
6885 if (unit_type == "ground") {
6886 unitsGround[name[2]][name[3]] = val;
6887
6888 if (name[2] == "def") {
6889 UnitStrength.calcDef(unitsGround.def);
6890 } else {
6891 UnitStrength.calcOff(unitsGround.att, unitsGround.att);
6892 }
6893 $('#' + name[2] + '_b').get(0).innerHTML = blunt;
6894 $('#' + name[2] + '_s').get(0).innerHTML = sharp;
6895 $('#' + name[2] + '_d').get(0).innerHTML = dist;
6896
6897 } else {
6898 var att = 0, def = 0;
6899 unitsNaval[name[2]][name[3]] = val;
6900
6901 if (name[2] == "def") {
6902 for (e in unitsNaval.def) {
6903 if (unitsNaval.def.hasOwnProperty(e)) {
6904 def += unitsNaval.def[e] * uw.GameData.units[e].defense;
6905 }
6906 }
6907 $('#def_ship').get(0).innerHTML = def;
6908
6909 } else {
6910 for (e in unitsNaval.att) {
6911 if (unitsNaval.att.hasOwnProperty(e)) {
6912 att += unitsNaval.att[e] * uw.GameData.units[e].attack;
6913 }
6914 }
6915 $('#att_ship').get(0).innerHTML = att;
6916 }
6917 }
6918 }, 100);
6919 });
6920
6921 // Abfrage wegen eventueller Spionageweiterleitung
6922 getUnitInputs();
6923 setTimeout(function () {
6924 setChangeUnitInputs("def");
6925 }, 100);
6926
6927 $('#select_insert_units').change(function () {
6928 var side = $(this).find('option:selected').val();
6929
6930 setTimeout(function () {
6931 getUnitInputs();
6932 if (side === "att" || side === "def") {
6933 setChangeUnitInputs(side);
6934 }
6935 }, 200);
6936 });
6937 }
6938
6939 function getUnitInputs() {
6940 $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').each(function () {
6941 name = $(this).attr("name").replace(/\]/g, "").split("[");
6942
6943 var str = this;
6944
6945 var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2];
6946
6947 var val = parseInt($(str).val(), 10);
6948
6949 val = val || 0;
6950
6951 if (unit_type === "ground") {
6952 unitsGround[name[2]][name[3]] = val;
6953 } else {
6954 unitsNaval[name[2]][name[3]] = val;
6955 }
6956 });
6957 }
6958
6959 function setChangeUnitInputs(side) {
6960 $('.place_insert_field[name="sim[units][' + side + '][godsent]"]').change();
6961 setTimeout(function () {
6962 $('.place_insert_field[name="sim[units][' + side + '][colonize_ship]"]').change();
6963 }, 100);
6964 }
6965
6966 /*******************************************************************************************************************************
6967 * Defense form
6968 * ----------------------------------------------------------------------------------------------------------------------------
6969 * | ● Adds a defense form to the bbcode bar
6970 * ----------------------------------------------------------------------------------------------------------------------------
6971 *******************************************************************************************************************************/
6972
6973 // Funktion aufteilen...
6974 function addForm(e) {
6975 var textareaId = "", bbcodeBarId = "";
6976
6977 switch (e) {
6978 case "/alliance_forum/forum":
6979 textareaId = "#forum_post_textarea";
6980 bbcodeBarId = "#forum";
6981 break;
6982 case "/message/forward":
6983 textareaId = "#message_message";
6984 bbcodeBarId = "#message_bbcodes";
6985 break;
6986 case "/message/new":
6987 textareaId = "#message_new_message";
6988 bbcodeBarId = "#message_bbcodes";
6989 break;
6990 case "/message/view":
6991 textareaId = "#message_reply_message";
6992 bbcodeBarId = "#message_bbcodes";
6993 break;
6994 case "/player_memo/load_memo_content":
6995 textareaId = "#memo_text_area";
6996 bbcodeBarId = "#memo_edit";
6997 break;
6998 }
6999
7000 $('<a title="Verteidigungsformular" href="#" class="dio_bbcode_option def_form" name="def_form"></a>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
7001
7002 $('.def_form_button').css({
7003 cursor: 'pointer',
7004 marginTop: '3px'
7005 });
7006
7007 $(bbcodeBarId + ' .dio_bbcode_option').css({
7008 background: 'url("http://s14.directupload.net/images/140126/lt3hyb8j.png")',
7009 display: 'block',
7010 float: 'left',
7011 width: '22px',
7012 height: '23px',
7013 margin: '0 3px 0 0',
7014 position: 'relative'
7015 });
7016 $(bbcodeBarId + ' .def_form').css({
7017 backgroundPosition: '-89px 0px'
7018 });
7019 var imgArray = {
7020 wall: 'https://gpall.innogamescdn.com/images/game/main/wall.png',
7021 tower: 'https://gpall.innogamescdn.com/images/game/main/tower.png',
7022 hide: 'https://gpall.innogamescdn.com/images/game/main/hide.png',
7023
7024 spy: 'http://s7.directupload.net/images/140114/yr993xwc.png',
7025 pop: 'http://s7.directupload.net/images/140114/4d6xktxm.png',
7026
7027 rev1: 'http://s7.directupload.net/images/140115/9cv6otiu.png',
7028 rev0: 'http://s7.directupload.net/images/140115/aue4rg6i.png',
7029 eo1: 'http://s1.directupload.net/images/140115/fkzlipyh.png',
7030 eo0: 'http://s1.directupload.net/images/140115/hs2kg59c.png',
7031 att: 'http://s1.directupload.net/images/140115/3t6uy4te.png',
7032 sup: 'http://s7.directupload.net/images/140115/ty6szerx.png',
7033
7034 zeus: 'http://s1.directupload.net/images/140114/cdxecrpu.png',
7035 hera: 'http://s1.directupload.net/images/140114/mve54v2o.png',
7036 athena: 'http://s14.directupload.net/images/140114/kyqyedhe.png',
7037 poseidon: 'http://s7.directupload.net/images/140114/tusr9oyi.png',
7038 hades: 'http://s7.directupload.net/images/140114/huins2gn.png',
7039 artemis: 'http://s7.directupload.net/images/140114/kghjhko8.png',
7040 nogod: 'http://s1.directupload.net/images/140114/e7vmvfap.png',
7041
7042 captain: 'http://s14.directupload.net/images/140114/88gg75rc.png',
7043 commander: 'http://s14.directupload.net/images/140114/slbst52o.png',
7044 priest: 'http://s1.directupload.net/images/140114/glptekkx.png',
7045
7046 phalanx: 'http://s7.directupload.net/images/140114/e97wby6z.png',
7047 ram: 'http://s7.directupload.net/images/140114/s854ds3w.png',
7048
7049 militia: 'http://wiki.en.grepolis.com/images/9/9b/Militia_40x40.png',
7050 sword: 'http://wiki.en.grepolis.com/images/9/9c/Sword_40x40.png',
7051 slinger: 'http://wiki.en.grepolis.com/images/d/dc/Slinger_40x40.png',
7052 archer: 'http://wiki.en.grepolis.com/images/1/1a/Archer_40x40.png',
7053 hoplite: 'http://wiki.en.grepolis.com/images/b/bd/Hoplite_40x40.png',
7054 rider: 'http://wiki.en.grepolis.com/images/e/e9/Rider_40x40.png',
7055 chariot: 'http://wiki.en.grepolis.com/images/b/b8/Chariot_40x40.png',
7056 catapult: 'http://wiki.en.grepolis.com/images/f/f0/Catapult_40x40.png',
7057 godsent: 'http://wiki.de.grepolis.com/images/6/6e/Grepolis_Wiki_225.png',
7058
7059 def_sum: 'http://s14.directupload.net/images/140127/6cxnis9r.png',
7060
7061 minotaur: 'http://wiki.de.grepolis.com/images/7/70/Minotaur_40x40.png',
7062 manticore: 'http://wiki.de.grepolis.com/images/5/5e/Manticore_40x40.png',
7063 zyclop: 'http://wiki.de.grepolis.com/images/6/66/Zyklop_40x40.png',
7064 sea_monster: 'http://wiki.de.grepolis.com/images/7/70/Sea_monster_40x40.png',
7065 harpy: 'http://wiki.de.grepolis.com/images/8/80/Harpy_40x40.png',
7066 medusa: 'http://wiki.de.grepolis.com/images/d/db/Medusa_40x40.png',
7067 centaur: 'http://wiki.de.grepolis.com/images/5/53/Centaur_40x40.png',
7068 pegasus: 'http://wiki.de.grepolis.com/images/5/54/Pegasus_40x40.png',
7069 cerberus: 'http://wiki.de.grepolis.com/images/6/67/Zerberus_40x40.png',
7070 fury: 'http://wiki.de.grepolis.com/images/6/67/Erinys_40x40.png',
7071 griffin: 'http://wiki.de.grepolis.com/images/d/d1/Unit_greif.png',
7072 calydonian_boar: 'http://wiki.de.grepolis.com/images/9/93/Unit_eber.png',
7073
7074 big_transporter: 'http://wiki.en.grepolis.com/images/0/04/Big_transporter_40x40.png',
7075 bireme: 'http://wiki.en.grepolis.com/images/4/44/Bireme_40x40.png',
7076 attack_ship: 'http://wiki.en.grepolis.com/images/e/e6/Attack_ship_40x40.png',
7077 demolition_ship: 'http://wiki.en.grepolis.com/images/e/ec/Demolition_ship_40x40.png',
7078 small_transporter: 'http://wiki.en.grepolis.com/images/8/85/Small_transporter_40x40.png',
7079 trireme: 'http://wiki.en.grepolis.com/images/a/ad/Trireme_40x40.png',
7080 colonize_ship: 'http://wiki.en.grepolis.com/images/d/d1/Colonize_ship_40x40.png',
7081
7082 move_icon: 'https://gpall.innogamescdn.com/images/game/unit_overview/',
7083
7084 bordure: 'http://s1.directupload.net/images/140126/8y6pmetk.png'
7085 };
7086
7087 $('<div class="bb_def_chooser">' +
7088 '<div class="bbcode_box middle_center">' +
7089 '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div>' +
7090 '<div class="bbcode_box top_center"></div><div class="bbcode_box bottom_center"></div>' +
7091 '<div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>' +
7092 '<div class="bbcode_box middle_left"></div><div class="bbcode_box middle_right"></div>' +
7093 '<div class="bbcode_box content clearfix" style="padding:5px">' +
7094 '<div id="f_uni" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "det") + '</div></div><br><br>' +
7095 '<div id="f_prm" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "prm") + '</div></div><br><br>' +
7096 '<div id="f_sil" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "sil") + '</div></div><br><br>' +
7097 '<div id="f_mov" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "mov") + '</div></div><br><br>' +
7098 '<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>' +
7099 '</div></div></div>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
7100
7101 $('.bb_def_chooser').css({
7102 display: 'none',
7103 top: '38px',
7104 left: '510px',
7105 position: 'absolute',
7106 width: '190px',
7107 zIndex: 10000
7108 });
7109
7110 $(bbcodeBarId + " .bb_def_chooser .checkbox_new").click(function () {
7111 $(this).toggleClass("checked");
7112 });
7113
7114 $(bbcodeBarId + ' .def_form').toggleClick(function () {
7115 $(this).parent().find(".bb_def_chooser").get(0).style.display = "block";
7116 }, function () {
7117 $(this).parent().find(".bb_def_chooser").get(0).style.display = "none";
7118 });
7119
7120 $(bbcodeBarId + ' #dio_insert').click(function () {
7121 var textarea = $(textareaId).get(0), text = $(textarea).val(), troop_table = "", troop_img = "", troop_count = "", separator = "", move_table = "", landunit_sum = 0;
7122
7123 $('.def_form').click();
7124
7125 if ($('#f_uni').hasClass("checked")) {
7126 $('.units_land .unit, .units_naval .unit').each(function () {
7127 troop_img += separator + '[img]' + imgArray[this.className.split(" ")[1]] + '[/img]';
7128 troop_count += separator + '[center]' + $(this).find(".value").get(0).innerHTML + '[/center]';
7129 separator = "[||]";
7130 });
7131 } else {
7132 $('.units_land .unit').each(function () {
7133 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);
7134 if (def > 10) {
7135 landunit_sum += parseInt($(this).find(".value").get(0).innerHTML, 10) * uw.GameData.units[a].population * ((def > 20) ? 2 : 1);
7136 }
7137 });
7138 landunit_sum = (landunit_sum > 10000) ? ((Math.round(landunit_sum / 100)) / 10) + "k" : landunit_sum;
7139
7140 troop_img += '[img]' + imgArray.def_sum + '[/img]';
7141 troop_count += '[center]' + landunit_sum + '[/center]';
7142 separator = "[||]";
7143 $('.units_naval .unit').each(function () {
7144 troop_img += separator + '[img]' + imgArray[this.className.split(" ")[1]] + '[/img]';
7145 troop_count += separator + '[center]' + $(this).find(".value").get(0).innerHTML + '[/center]';
7146 });
7147 }
7148 if (troop_img !== "") {
7149 troop_table = "\n[table][**]" + troop_img + "[/**][**]" + troop_count + "[/**][/table]\n";
7150 }
7151
7152 var str = '[img]' + imgArray.bordure + '[/img]' +
7153 '\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' +
7154 //'[table][**][img]'+ imgArray.sup +'[/img][||]'+
7155 '[size=12][town]' + uw.ITowns.getTown(uw.Game.townId).getId() + '[/town] ([player]' + uw.Game.player_name + '[/player])[/size]' +
7156 //'[||][img]'+ imgArray['rev' + (uw.ITowns.getTown(uw.Game.townId).hasConqueror()?1:0)] +'[/img][/**][/table]'+
7157 '\n\n[i][b]' + getText("labels", "inf") + '[/b][/i]' + troop_table +
7158 '[table][*]' +
7159 '[img]' + imgArray.wall + '[/img][|]\n' +
7160 '[img]' + imgArray.tower + '[/img][|]\n' +
7161 '[img]' + imgArray.phalanx + '[/img][|]\n' +
7162 '[img]' + imgArray.ram + '[/img][|]\n' +
7163 ($('#f_prm').hasClass("checked") ? '[img]' + imgArray.commander + '[/img][|]\n' : ' ') +
7164 ($('#f_prm').hasClass("checked") ? '[img]' + imgArray.captain + '[/img][|]\n' : ' ') +
7165 ($('#f_prm').hasClass("checked") ? '[img]' + imgArray.priest + '[/img][|]\n' : ' ') +
7166 ($('#f_sil').hasClass("checked") ? '[center][img]' + imgArray.spy + '[/img][/center][|]\n' : ' ') +
7167 '[img]' + imgArray.pop + '[/img][|]\n' +
7168 '[img]' + imgArray[(uw.ITowns.getTown(uw.Game.townId).god() || "nogod")] + '[/img][/*]\n' +
7169 '[**][center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("wall") + '[/center][||]' +
7170 '[center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("tower") + '[/center][||]' +
7171 '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.phalanx ? '+' : '-') + '[/center][||]' +
7172 '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.ram ? '+' : '-') + '[/center][||]' +
7173 ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.commander >= uw.Timestamp.now()) ? '+' : '-') + '[/center][||]' : ' ') +
7174 ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.captain >= uw.Timestamp.now()) ? '+' : '-') + '[/center][||]' : ' ') +
7175 ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.priest >= uw.Timestamp.now()) ? '+' : '-') + '[/center][||]' : ' ') +
7176 ($('#f_sil').hasClass("checked") ? '[center]' + Math.round(uw.ITowns.getTown(uw.Game.townId).getEspionageStorage() / 1000) + 'k[/center][||]' : ' ') +
7177 '[center]' + uw.ITowns.getTown(uw.Game.townId).getAvailablePopulation() + '[/center][||]' +
7178 '[center]' + $('.gods_favor_amount').get(0).innerHTML + '[/center]' +
7179 '[/**][/table]';
7180
7181 var bb_count_str = parseInt(str.match(/\[/g).length, 10), bb_count_move = 0;
7182
7183 var i = 0;
7184 if ($('#f_mov').hasClass("checked")) {
7185 move_table += '\n[i][b]' + getText("labels", "mov") + '[/b][/i]\n[table]';
7186
7187 $('#toolbar_activity_commands').mouseover();
7188
7189 $('#toolbar_activity_commands_list .content .command').each(function () {
7190 var cl = $(this).children()[0].className.split(" ");
7191 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)) {
7192 move_table += (i % 1) ? "" : "[**]";
7193 i++;
7194 move_table += "[img]" + imgArray.move_icon + cl[2] + ".png[/img][||]";
7195 move_table += getArrivalTime($(this).children()[1].innerHTML) + (uw.Game.market_id === "de" ? " Uhr[||]" : " [||]");
7196 move_table += "[town]" + JSON.parse(atob($(this).children()[2].firstChild.href.split("#")[1])).id + "[/town]";
7197 move_table += (i % 1) ? "[||]" : "[/**]";
7198 }
7199 bb_count_move = parseInt(move_table.match(/\[/g).length, 10);
7200 });
7201 if ((bb_count_str + bb_count_move) > 480) {
7202 move_table += '[**]...[/**]';
7203 }
7204
7205 $('#toolbar_activity_commands').mouseout();
7206
7207 //console.log((bb_count_str + bb_count_move));
7208 move_table += (i % 1) ? "[/**]" : "";
7209 move_table += "[*][|][color=#800000][size=6][i] (" + getText("labels", "dev") + ": ±1s)[/i][/size][/color][/*][/table]\n";
7210 }
7211
7212 str += move_table + '[img]' + imgArray.bordure + '[/img]';
7213
7214
7215 $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + str + text.substring($(textarea).get(0).selectionEnd));
7216 });
7217 }
7218
7219 function getArrivalTime(duration_time) {
7220 /*
7221 var server_time = new Date((uw.Timestamp.server() + 7200) * 1000);
7222
7223 duration_time = duration_time.split(":");
7224
7225 s = server_time.getUTCSeconds() + parseInt(duration_time[2], 10);
7226 m = server_time.getUTCMinutes() + parseInt(duration_time[1], 10) + ((s>=60)? 1 : 0);
7227 h = server_time.getUTCHours() + parseInt(duration_time[0], 10) + ((m>=60)? 1 : 0);
7228 */
7229
7230 var server_time = $('.server_time_area').get(0).innerHTML.split(" ")[0].split(":"), arrival_time, s, m, h;
7231 duration_time = duration_time.split(":");
7232
7233 s = parseInt(server_time[2], 10) + parseInt(duration_time[2], 10);
7234 m = parseInt(server_time[1], 10) + parseInt(duration_time[1], 10) + ((s >= 60) ? 1 : 0);
7235 h = parseInt(server_time[0], 10) + parseInt(duration_time[0], 10) + ((m >= 60) ? 1 : 0);
7236
7237 s = s % 60;
7238 m = m % 60;
7239 h = h % 24;
7240
7241 s = ((s < 10) ? "0" : "") + s;
7242 m = ((m < 10) ? "0" : "") + m;
7243 h = ((h < 10) ? "0" : "") + h;
7244
7245 arrival_time = h + ":" + m + ":" + s;
7246
7247 return arrival_time;
7248 }
7249
7250
7251 /*******************************************************************************************************************************
7252 * Smiley box
7253 * ----------------------------------------------------------------------------------------------------------------------------
7254 * | ● Display of a smiley selection box for text input fields (forum, messages, notes):
7255 * | ● Used smileys: http://www.greensmilies.com/smilie-album/
7256 * | + Own Grepolis smileys
7257 * ----------------------------------------------------------------------------------------------------------------------------
7258 *******************************************************************************************************************************/
7259
7260 var smileyArray = {};
7261
7262 var SmileyBox = {
7263 loading_error: false, isHalloween: false, isXmas: false, isForum: $(".editor_textbox_container").get(0),
7264
7265 activate: function () {
7266 $('<style id="dio_smiley">' +
7267 '.smiley_button { cursor:pointer; margin:3px 2px 2px 2px; } ' +
7268
7269 '.smiley_box.game { z-index:5000; position:absolute; top:27px; left:430px; min-width:300px; display:none; } ' +
7270
7271 // Smiley categories
7272 '.smiley_box .box_header { display: table; width: 100%; text-align:center; } ' +
7273 '.smiley_box .group { display:table-cell; color: #0c450c; cursor: pointer; font-weight:bold; padding: 0px 2px 0px 2px; } ' +
7274 '.smiley_box .group.active { color: #089421; text-decoration:underline;} ' +
7275 '.smiley_box .group:hover { color: #14999E; } ' + // #11AD6C
7276
7277 // Special smiley categories
7278 '.smiley_box .halloween { color: #E25E00; } ' +
7279 '.smiley_box .xmas { color: darkred; } ' +
7280
7281 '.smiley_box hr { margin:3px 0px 0px 0px; color:#086b18; border:1px solid; } ' +
7282
7283 // Smilies
7284 '.smiley_box .box_content { overflow: hidden; } ' +
7285 '.smiley_box .box_content .smiley { border: 1px solid rgba(0,0,0,0); border-radius: 5px;} ' +
7286 '.smiley_box .box_content .smiley:hover { background: rgba(8, 148, 77, 0.2); border: 1px solid rgba(0, 128, 0, 0.5); } ' +
7287
7288 // Smiley page link
7289 '.smiley_box .box_footer { text-align:center; margin-top:4px; } ' +
7290 '.smiley_box a:link, .smiley_box a:visited { color: #086b18; font-size: 0.7em; } ' +
7291 '.smiley_box a:hover { color: #14999E; } ' +
7292
7293 // TODO Forum ...
7294 '.smiley_box.forum .box_header_left { float:left; } ' +
7295 //'.smiley_box.forum .group { padding-right: 10px; } '+
7296 '.smiley_box.forum .box_header_right { text-align:right; margin-top:2px; } ' +
7297
7298 '.smiley_box.forum { max-height:90px; margin-left:5px; width:99%; min-height:10px; } ' +
7299 '.smiley_box.forum .box_content { overflow:overlay; min-height:70px; margin-bottom:10px; } ' +
7300
7301 '.smiley_box.forum a:link, .smiley_box.forum a:visited { font-size: 1em; } ' +
7302
7303 '</style>').appendTo('head');
7304
7305
7306 // Smiley categories
7307 smileyArray.button = ["rollsmiliey", "smile"];
7308
7309 smileyArray.standard = [
7310 "smilenew", "grin", "lol", "neutral_new", "afraid", "freddus_pacman", "auslachen2", "kolobok-sanduhr", "bussi2", "winken4", "flucht2", "panik4", "ins-auge-stechen",
7311 "seb_zunge", "fluch4_GREEN", "baby_junge2", "blush-reloaded6", "frown", "verlegen", "blush-pfeif", "stevieh_rolleyes", "daumendreh2", "baby_taptap",
7312 "sadnew", "hust", "confusednew", "idea2", "irre", "irre4", "sleep", "candle", "nicken", "no_sad",
7313 "thumbs-up_new", "thumbs-down_new", "bravo2", "oh-no2", "kaffee2", "drunk", "saufen", "freu-dance", "hecheln", "headstand", "rollsmiliey", "eazy_cool01", "motz", "cuinlove", "biggrin"
7314 ];
7315 smileyArray.nature = [
7316 "dinosaurier07", "flu-super-gau", "ben_cat", "schwein", "hundeleine01", "blume", "ben_sharky", "ben_cow", "charly_bissig", "gehirnschnecke_confused", "mttao_fische", "mttao_angler",
7317 "insel", "fliegeschnappen", "spider", /* Spinne */ "shipwrecked", /* Schiffbrüchiger */ "plapperhase", "ben_dumbo"
7318 ];
7319 smileyArray.grepolis = [
7320 "mttao_wassermann", "hera", /* Hera */ "medusa", /* Medusa */ "manticore", /* Mantikor */ "cyclops", /* Zyklop */
7321 "minotaur", /* Minotaurus */ "pegasus", /* Pegasus */ "hydra", /* Hydra */
7322 "silvester_cuinlove", "mttao_schuetze", "kleeblatt2", "wallbash", /* "glaskugel4", */ "musketiere_fechtend", /* "krone-hoch",*/ "viking", // Wikinger
7323 "mttao_waage2", "steckenpferd", /* "kinggrin_anbeten2", */ "grepolove", /* Grepo Love */ "skullhaufen", "pferdehaufen" // "i/ckajscggscw4s2u60"
7324 ];
7325 smileyArray.people = [
7326 "seb_hut5", "opa_boese2", "star-wars-yoda1-gruen", "hexefliegend", "snob", "seb_detektiv_ani", "seb_cowboy", "devil", "segen", "pirat5", "borg", "hexe3b",
7327 "pharaoh", "hippie", "eazy_polizei", "stars_elvis", "mttao_chefkoch", "nikolaus", "pirate3_biggrin", "batman_skeptisch", "tubbie1", "tubbie2", "tubbie3", "tubbie4"
7328 ];
7329 smileyArray.other = [
7330 "steinwerfen", "herzen02", "scream-if-you-can", "kolobok", "headbash", "liebeskummer", "bussi", "brautpaar-reis", "grab-schaufler2", "boxen2", "aufsmaul",
7331 "sauf", "mttao_kehren", "sm", "weckruf", "klugscheisser2", "karte2_rot", "dagegen", "party", "dafuer", "outofthebox", "pokal_gold", "koepfler", "transformer"
7332 ];
7333
7334 // TODO: HolidayChecker benutzen!
7335 SmileyBox.checkHolidaySeason();
7336
7337 if (SmileyBox.isHalloween) {
7338 smileyArray.halloween = [
7339 "zombies_alien", "zombies_lol", "zombies_rolleyes", "zombie01", "zombies_smile", "zombie02", "zombies_skeptisch", "zombies_eek", "zombies_frown",
7340 "scream-if-you-can", "geistani", "pfeildurchkopf01", "grab-schaufler", "kuerbisleuchten", "mummy3",
7341 "kuerbishaufen", "halloweenskulljongleur", "fledermausvampir", "frankenstein_lol", "halloween_confused", "zombies_razz",
7342 "halloweenstars_freddykrueger", "zombies_cool", "geist2", "fledermaus2", "halloweenstars_dracula"
7343 // "batman" "halloweenstars_lastsummer"
7344 ];
7345 }
7346 if (SmileyBox.isXmas) {
7347 smileyArray.xmas = [
7348 "schneeballwerfen", "schneeball", "xmas4_advent4", "nikolaus", "weihnachtsmann_junge", "schneewerfen_wald", "weihnachtsmann_nordpol", "xmas_kilroy_kamin",
7349 "xmas4_laola", "xmas4_aufsmaul", "xmas3_smile", "xmas4_paketliebe", "mttao_ruprecht_peitsche", "3hlkoenige", "santa", "xmas4_hurra2", "weihnachtsgeschenk2", "fred_weihnachten-ostern"
7350 //"dafuer", "outofthebox", "pokal_gold", "koepfler", "transformer"
7351 ];
7352 }
7353
7354 //smileyArray.other = smileyArray.halloween.slice();
7355
7356 // Forum: Extra smiley
7357 if (SmileyBox.isForum) {
7358 smileyArray.grepolis.push("i/ckajscggscw4s2u60"); // Pacman
7359 smileyArray.grepolis.push("i/cowqyl57t5o255zli"); // Bugpolis
7360 smileyArray.grepolis.push("i/cowquq2foog1qrbee"); // Inno
7361 }
7362
7363 SmileyBox.loadSmileys();
7364 },
7365 deactivate: function () {
7366 $('#dio_smiley').remove();
7367 },
7368 checkHolidaySeason: function () {
7369 // TODO: HolidaySpecial-Klasse stattdessen benutzen
7370 var daystamp = 1000 * 60 * 60 * 24, today = new Date((new Date()) % (daystamp * (365 + 1 / 4))), // without year
7371
7372 // Halloween-Smileys ->15 days
7373 halloween_start = daystamp * 297, // 25. Oktober
7374 halloween_end = daystamp * 321, // 8. November
7375 // Xmas-Smileys -> 28 Tage
7376 xmas_start = daystamp * 334, // 1. Dezember
7377 xmas_end = daystamp * 361; // 28. Dezember
7378
7379 SmileyBox.isHalloween = (today >= halloween_start) ? (today <= halloween_end) : false;
7380
7381 SmileyBox.isXmas = (today >= xmas_start) ? (today <= xmas_end) : false;
7382 },
7383 // preload images
7384 loadSmileys: function () {
7385 // Replace german sign smilies
7386 if (LID !== "de") {
7387 smileyArray.other[17] = "dagegen2";
7388 smileyArray.other[19] = "dafuer2";
7389 }
7390
7391 for (var e in smileyArray) {
7392 if (smileyArray.hasOwnProperty(e)) {
7393 for (var f in smileyArray[e]) {
7394 if (smileyArray[e].hasOwnProperty(f)) {
7395 var src = smileyArray[e][f];
7396
7397 smileyArray[e][f] = new Image();
7398 smileyArray[e][f].className = "smiley";
7399
7400 if (src.substring(0, 2) == "i/") {
7401 smileyArray[e][f].src = "http://666kb.com/" + src + ".gif";
7402 } else {
7403 if (SmileyBox.loading_error == false) {
7404 smileyArray[e][f].src = "https://diotools.de/images/smileys/"+ e +"/smiley_emoticons_" + src + ".gif";
7405 //console.debug("Smiley", e);
7406 } else {
7407 smileyArray[e][f].src = 'http://s1.directupload.net/images/140128/93x3p4co.gif';
7408 }
7409 }
7410 smileyArray[e][f].onerror = function () {
7411 this.src = 'http://s1.directupload.net/images/140128/93x3p4co.gif';
7412 };
7413 }
7414 }
7415 }
7416 }
7417 },
7418
7419 // Forum smilies
7420 changeForumEditorLayout: function () {
7421 $('.blockrow').css({border: "none"});
7422
7423 // Subject/Title
7424 $($('.section div label[for="title"]').parent()).css({float: "left", width: "36%", marginRight: "20px"});
7425 $($('.section div label[for="subject"]').parent()).css({float: "left", width: "36%", marginRight: "20px"});
7426
7427 $('.section div input').eq(0).css({marginBottom: "-10px", marginTop: "10px"});
7428 $('#display_posticon').remove();
7429
7430 // Posticons
7431 $('.posticons table').css({width: "50%" /* marginTop: "-16px"*/});
7432 $('.posticons').css({marginBottom: "-16px"});
7433 $('.posticons').insertAfter($('.section div label[for="title"]').parent());
7434 $('.posticons').insertAfter($('.section div label[for="subject"]').parent());
7435 // Posticons hint
7436 $('.posticons p').remove();
7437 // Posticons: No Icon - radio button
7438 $(".posticons [colspan='14']").parent().replaceWith($(".posticons [colspan='14']"));
7439 $(".posticons [colspan='14']").children().wrap("<nobr></nobr>");
7440 $(".posticons [colspan='14']").appendTo('.posticons tr:eq(0)');
7441 $(".posticons [colspan='4']").remove();
7442 },
7443
7444 addForum: function () {
7445 $('<div class="smiley_box forum"><div>' +
7446 '<div class="box_header_left">' +
7447 '<span class="group standard active">' + getText("labels", "std") + '</span>' +
7448 '<span class="group grepolis">' + getText("labels", "gre") + '</span>' +
7449 '<span class="group nature">' + getText("labels", "nat") + '</span>' +
7450 '<span class="group people">' + getText("labels", "ppl") + '</span>' +
7451 '<span class="group other">' + getText("labels", "oth") + '</span>' +
7452 (SmileyBox.isHalloween ? '<span class="group halloween">' + getText("labels", "hal") + '</span>' : '') +
7453 (SmileyBox.isXmas ? '<span class="group xmas">' + getText("labels", "xma") + '</span>' : '') +
7454 '</div>' +
7455 '<div class="box_header_right"><a class="smiley_link" href="http://www.greensmilies.com/smilie-album/" target="_blank">WWW.GREENSMILIES.COM</a></div>' +
7456 '<hr>' +
7457 '<div class="box_content" style="overflow: hidden;"><hr></div>' +
7458 '</div></div><br>').insertAfter(".texteditor");
7459
7460 SmileyBox.addSmileys("standard", "");
7461
7462 $('.group').click(function () {
7463 $('.group.active').removeClass("active");
7464 $(this).addClass("active");
7465 // Change smiley group
7466 SmileyBox.addSmileys(this.className.split(" ")[1], "");
7467 });
7468 },
7469
7470 // add smiley box
7471 add: function (e) {
7472 var bbcodeBarId = "";
7473 switch (e) {
7474 case "/alliance_forum/forum":
7475 bbcodeBarId = "#forum";
7476 break;
7477 case "/message/forward":
7478 bbcodeBarId = "#message_bbcodes";
7479 break;
7480 case "/message/new":
7481 bbcodeBarId = "#message_bbcodes";
7482 break;
7483 case "/message/view":
7484 bbcodeBarId = "#message_bbcodes";//setWonderIconsOnMap
7485 break;
7486 case "/player_memo/load_memo_content":
7487 bbcodeBarId = "#memo_edit"; // old notes
7488 break;
7489 case "/frontend_bridge/fetch":
7490 bbcodeBarId = ".notes_container"; // TODO: new notes
7491 break;
7492 }
7493 if (($(bbcodeBarId + ' #emots_popup_7').get(0) || $(bbcodeBarId + ' #emots_popup_15').get(0)) && PID == 84367) {
7494 $(bbcodeBarId + " .bb_button_wrapper").get(0).lastChild.remove();
7495 }
7496 $('<img class="smiley_button" src="http://www.greensmilies.com/smile/smiley_emoticons_smile.gif">').appendTo(bbcodeBarId + ' .bb_button_wrapper');
7497
7498 $('<div class="smiley_box game">' +
7499 '<div class="bbcode_box middle_center"><div class="bbcode_box middle_right"></div><div class="bbcode_box middle_left"></div>' +
7500 '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div><div class="bbcode_box top_center"></div>' +
7501 '<div class="bbcode_box bottom_center"></div><div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>' +
7502 '<div class="box_header">' +
7503 '<span class="group standard active">' + getText("labels", "std") + '</span>' +
7504 '<span class="group grepolis">' + getText("labels", "gre") + '</span>' +
7505 '<span class="group nature">' + getText("labels", "nat") + '</span>' +
7506 '<span class="group people">' + getText("labels", "ppl") + '</span>' +
7507 '<span class="group ' + (SmileyBox.isHalloween ? 'halloween' : (SmileyBox.isXmas ? 'xmas' : 'other')) + '">' + getText("labels", (SmileyBox.isHalloween ? 'hal' : (SmileyBox.isXmas ? 'xma' : 'oth'))) + '</span>' +
7508 '</div>' +
7509 '<hr>' +
7510 '<div class="box_content"></div>' +
7511 '<hr>' +
7512 '<div class="box_footer"><a href="http://www.greensmilies.com/smilie-album/" target="_blank">WWW.GREENSMILIES.COM</a></div>' +
7513 '</div>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
7514
7515
7516 $(bbcodeBarId + ' .group').click(function () {
7517 $('.group.active').removeClass("active");
7518 $(this).addClass("active");
7519 // Change smiley group
7520 SmileyBox.addSmileys(this.className.split(" ")[1], "#" + $(this).closest('.bb_button_wrapper').parent().get(0).id);
7521 });
7522
7523 SmileyBox.addSmileys("standard", bbcodeBarId);
7524
7525 // smiley box toggle
7526 $(bbcodeBarId + " .smiley_button").toggleClick(
7527 function () {
7528 this.src = smileyArray.button[0].src;
7529 $(this).closest('.bb_button_wrapper').find(".smiley_box").get(0).style.display = "block";
7530 },
7531 function () {
7532 this.src = smileyArray.button[1].src;
7533 $(this).closest('.bb_button_wrapper').find(".smiley_box").get(0).style.display = "none";
7534 }
7535 );
7536 },
7537
7538 // insert smileys from arrays into smiley box
7539 addSmileys: function (type, bbcodeBarId) {
7540 // reset smilies
7541 if ($(bbcodeBarId + " .box_content").get(0)) {
7542 $(bbcodeBarId + " .box_content").get(0).innerHTML = '';
7543 }
7544 // add smilies
7545 for (var e in smileyArray[type]) {
7546 if (smileyArray[type].hasOwnProperty(e)) {
7547 $(smileyArray[type][e]).clone().appendTo(bbcodeBarId + " .box_content");
7548 //$('<img class="smiley" src="' + smileyArray[type][e].src + '" alt="" />').appendTo(bbcodeBarId + " .box_content");
7549 }
7550 }
7551 $('.smiley').css({margin: '0px', padding: '2px', maxHeight: '35px', cursor: 'pointer'});
7552
7553 $(bbcodeBarId + " .box_content .smiley").click(function () {
7554 var textarea;
7555 if (uw.location.pathname.indexOf("game") >= 0) {
7556 // hide smiley box
7557 $(this).closest('.bb_button_wrapper').find(".smiley_button").click();
7558 // find textarea
7559 textarea = $(this).closest('.gpwindow_content').find("textarea").get(0);
7560 } else {
7561
7562 if ($('.editor_textbox_container').get(0)) {
7563 textarea = $('.editor_textbox_container .cke_contents textarea').get(0);
7564 } else {
7565 $(this).appendTo('iframe .forum');
7566 }
7567 }
7568 var text = $(textarea).val();
7569 $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + "[img]" + this.src + "[/img]" + text.substring($(textarea).get(0).selectionEnd));
7570 });
7571 }
7572 };
7573
7574
7575 /*******************************************************************************************************************************
7576 * Biremes counter
7577 * ----------------------------------------------------------------------------------------------------------------------------
7578 * | ● Incremental update when calling a city (experimental, especially intended for siege worlds)
7579 * ----------------------------------------------------------------------------------------------------------------------------
7580 * @deprecated
7581 * *****************************************************************************************************************************/
7582
7583 // TODO: Altes Feature entfernen
7584 var BiremeCounter = {
7585 activate: function () {
7586 $(".picomap_container").prepend("<div id='available_units'><div id='bi_count'></div></div>");
7587
7588 $('.picomap_overlayer').tooltip(getText("options", "bir")[0]);
7589 BiremeCounter.update();
7590
7591 // Style
7592 $('<style id="dio_bireme_counter">' +
7593 '#available_units { background: url(https://gpall.innogamescdn.com/images/game/units/units_sprite_90x90_compressed.jpg); height:90px;' +
7594 'width:90px; position: relative; margin: 5px 28px 0px 28px; background-position: -270px 0px; } ' +
7595 '#bi_count { color:#826021; position:relative; top:28px; font-style:italic; width:79px; } ' +
7596 '#sea_id { background: none; font-size:25px; cursor:default; height:50px; width:50px; position:absolute; top:70px; left:157px; z-index: 30; } ' +
7597 '</style>').appendTo('head');
7598
7599 // fs_count: color: #FFC374;position: relative;top: 30px;font-style: italic;width: 101px;text-shadow: 1px 1px 0px rgb(69, 0, 0);
7600 // manti: background-position: -1350px 180px;
7601 // manti-count: color: #ECD181;position: relative;top: 48px;font-style: italic;width: 52px;text-shadow: 2px 2px 0px rgb(0, 0, 0);
7602 // medusa:-1440px 182px;
7603 // med-count: color: #DEECA4;position: relative;top: 50px;font-style: italic;width: 55px;text-shadow: 2px 2px 0px rgb(0, 0, 0);
7604
7605 // Set Sea-ID beside the bull eye
7606 $('#sea_id').prependTo('#ui_box');
7607 },
7608 deactivate: function () {
7609 $('#available_units').remove();
7610 $('#dio_bireme_counter').remove();
7611 $('#sea_id').appendTo('.picomap_container');
7612 },
7613 save: function () {
7614 saveValue(WID + "_biremes", JSON.stringify(biriArray));
7615 },
7616 update: function () {
7617 var sum = 0, e;
7618 if ($('#bi_count').get(0)) {
7619 for (e in biriArray) {
7620 if (biriArray.hasOwnProperty(e)) {
7621 if (!uw.ITowns.getTown(e)) { // town is no longer in possession of user
7622 delete biriArray[e];
7623 BiremeCounter.save();
7624 } else {
7625 sum += parseInt(biriArray[e], 10);
7626 }
7627 }
7628 }
7629
7630 sum = sum.toString();
7631 var str = "", fsize = ['1.4em', '1.2em', '1.15em', '1.1em', '1.0em'], i;
7632
7633 for (i = 0; i < sum.length; i++) {
7634 str += "<span style='font-size:" + fsize[i] + "'>" + sum[i] + "</span>";
7635 }
7636 $('#bi_count').get(0).innerHTML = "<b>" + str + "</b>";
7637 }
7638 },
7639 get: function () {
7640 var biremeIn = parseInt(uw.ITowns.getTown(uw.Game.townId).units().bireme, 10),
7641 biremeOut = parseInt(uw.ITowns.getTown(uw.Game.townId).unitsOuter().bireme, 10);
7642 if (isNaN(biremeIn)) biremeIn = 0;
7643 if (isNaN(biremeOut)) biremeOut = 0;
7644 if (!biriArray[uw.Game.townId] || biriArray[uw.Game.townId] < (biremeIn + biremeOut)) {
7645 biriArray[uw.Game.townId] = biremeIn;
7646 }
7647 BiremeCounter.update();
7648 BiremeCounter.save();
7649 },
7650 getDocks: function () {
7651 var windowID = uw.BuildingWindowFactory.getWnd().getID(),
7652 biremeTotal = parseInt($('#gpwnd_' + windowID + ' #unit_order_tab_bireme .unit_order_total').get(0).innerHTML, 10);
7653
7654 if (!isNaN(biremeTotal)) biriArray[uw.Game.townId] = biremeTotal;
7655 BiremeCounter.update();
7656 BiremeCounter.save();
7657 },
7658 getAgora: function () {
7659 var biremeTotal = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().bireme, 10);
7660 if (isNaN(biremeTotal)) biremeTotal = 0;
7661
7662 $('#units_beyond_list .bireme').each(function () {
7663 biremeTotal += parseInt(this.children[0].innerHTML, 10);
7664 });
7665 biriArray[uw.Game.townId] = biremeTotal;
7666 BiremeCounter.update();
7667 BiremeCounter.save();
7668 }
7669 };
7670
7671 /*******************************************************************************************************************************
7672 * Favor Popup
7673 * ----------------------------------------------------------------------------------------------------------------------------
7674 * | ● Improved favor popup
7675 * ----------------------------------------------------------------------------------------------------------------------------
7676 *******************************************************************************************************************************/
7677 var FavorPopup = {
7678 godArray: {
7679 zeus: '0px',
7680 hera: '-152px',
7681 poseidon: '-101px',
7682 athena: '-50px',
7683 hades: '-203px',
7684 artemis: '-305px'
7685 }, godImg: (new Image()).src = "https://diotools.de/images/game/gods.png",
7686
7687 activate: function () {
7688 $('.gods_favor_button_area, #favor_circular_progress').bind('mouseover mouseout', function () {
7689 return false;
7690 });
7691 $('.gods_area').bind('mouseover', function () {
7692 FavorPopup.setFavorPopup();
7693 });
7694 },
7695
7696 deactivate: function () {
7697 $('.gods_favor_button_area, #favor_circular_progress').unbind('mouseover mouseout');
7698 $('.gods_area').unbind('mouseover');
7699 },
7700
7701 setFavorPopup: function () {
7702 var pic_row = "", fav_row = "", prod_row = "", tooltip_str;
7703
7704 for (var g in FavorPopup.godArray) {
7705 if (FavorPopup.godArray.hasOwnProperty(g)) {
7706 if (uw.ITowns.player_gods.attributes.temples_for_gods[g]) {
7707 pic_row += '<td><div style="width:50px;height:51px;background:url(' + FavorPopup.godImg + ');background-position: 0px ' + FavorPopup.godArray[g] + ';"></td>';
7708 fav_row += '<td class="bold" style="color:blue">' + uw.ITowns.player_gods.attributes[g + "_favor"] + '</td>';
7709 prod_row += '<td class="bold">' + uw.ITowns.player_gods.attributes.production_overview[g].production + '</td>';
7710 }
7711 }
7712 }
7713 tooltip_str = $('<table><tr><td></td>' + pic_row + '</tr>' +
7714 '<tr align="center"><td><img src="https://gpall.innogamescdn.com/images/game/res/favor.png"></td>' + fav_row + '</tr>' +
7715 '<tr align="center"><td>+</td>' + prod_row + '</tr>' +
7716 '</table>');
7717
7718 $('.gods_favor_button_area, #favor_circular_progress').tooltip(tooltip_str);
7719 }
7720 };
7721
7722 /*******************************************************************************************************************************
7723 * GUI Optimization
7724 * ----------------------------------------------------------------------------------------------------------------------------
7725 * | ● Modified spell box (smaller, moveable & position memory)
7726 * | ● Larger taskbar and minimize daily reward-window on startup
7727 * | ● Modify chat
7728 * | ● Improved display of troops and trade activity boxes (movable with position memory on startup)
7729 * ----------------------------------------------------------------------------------------------------------------------------
7730 *******************************************************************************************************************************/
7731
7732 var Spellbox = {
7733 observe: function () {
7734 $.Observer(uw.GameEvents.ui.layout_gods_spells.rendered).subscribe('DIO_SPELLBOX_CHANGE_OPEN', function () {
7735 if (spellbox.show == false) {
7736 spellbox.show = true;
7737 saveValue("spellbox", JSON.stringify(spellbox));
7738 }
7739 Spellbox.change();
7740 });
7741 $.Observer(uw.GameEvents.ui.layout_gods_spells.state_changed).subscribe('DIO_SPELLBOX_CLOSE', function () {
7742 spellbox.show = false;
7743 saveValue("spellbox", JSON.stringify(spellbox));
7744 });
7745
7746 // GRCRT Bug-Fix
7747 if(typeof(RepConv) !== "undefined") {
7748 $.Observer(uw.GameEvents.ui.layout_gods_spells.rendered).unsubscribe('GRCRT_GRC_ui_layout_gods_spells_rendered');
7749
7750 $.Observer(uw.GameEvents.ui.layout_gods_spells.rendered).subscribe('GRCRT_GRC_ui_layout_gods_spells_rendered', function () {
7751 // PlayerGods doesn't exists at game start and the function would call an error
7752 if (typeof(RepConv.models.PlayerGods) !== "undefined") {
7753 RepConvTool.loadPower();
7754 }
7755 });
7756 }
7757 },
7758
7759 activate: function () {
7760 Spellbox.observe();
7761 Spellbox.change();
7762
7763 $('<style id="dio_spellbox_style" type="text/css">' +
7764 // Don't hide hero box, unit time box and hero coin box from GRC
7765 '#ui_box .nui_right_box { overflow: visible; } ' +
7766 // Hide negative spells
7767 '#ui_box .bolt, #ui_box .earthquake, #ui_box .pest { display: none } ' +
7768 // Change spell order
7769 '#ui_box .god_container { float: left } ' +
7770 '#ui_box .god_container[data-god_id="zeus"], #ui_box .god_container[data-god_id="athena"] { float: none } ' +
7771 // Remove background
7772 '#ui_box .powers_container { background: none !important } ' +
7773 // Hide god titles
7774 '#ui_box .content .title { display: none !important } ' +
7775 // Hide border elements
7776 '#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 } ' +
7777 // Layout
7778 '#ui_box .gods_area { height:150px } ' +
7779
7780 '#ui_box .gods_spells_menu { width: 134px; position:absolute; z-index:5000; padding:30px 0px 0px -4px } ' +
7781 '#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 } ' +
7782
7783 '#ui_box .nui_units_box { display:block; margin-top:-8px; position:relative } ' +
7784 '#ui_box .nui_units_box .bottom_ornament { margin-top:-28px; position: relative } ' +
7785 '</style>').appendTo('head');
7786
7787 // Draggable Box
7788 $("#ui_box .gods_spells_menu").draggable({
7789 containment: "body",
7790 distance: 10,
7791 snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, #island_quests_overview",
7792 opacity: 0.7,
7793 stop: function () {
7794 spellbox.top = this.style.top;
7795 spellbox.left = this.style.left;
7796
7797 saveValue("spellbox", JSON.stringify(spellbox));
7798 }
7799 });
7800 $("#ui_box .gods_spells_menu").before($('#ui_box .nui_units_box'));
7801
7802 // Position
7803 $('#ui_box .gods_spells_menu').css({
7804 left: spellbox.left,
7805 top: spellbox.top
7806 });
7807
7808 // Active at game start?
7809 if (spellbox.show && !$('#ui_box .btn_gods_spells').hasClass('active')) {
7810 $('#ui_box .btn_gods_spells').click();
7811 }
7812 },
7813 deactivate: function () {
7814 $('#ui_box .gods_spells_menu').draggable('destroy');
7815
7816 // Position
7817 $('#ui_box .gods_spells_menu').css({
7818 left: "auto",
7819 top: "150px"
7820 });
7821
7822 //$("#ui_box .gods_spells_menu").appendTo('gods_area'); // ?
7823
7824 $('#dio_spellbox_style').remove();
7825
7826 $.Observer(GameEvents.ui.layout_gods_spells.rendered).unsubscribe('DIO_SPELLBOX_CHANGE_OPEN');
7827 $.Observer(GameEvents.ui.layout_gods_spells.state_changed).unsubscribe('DIO_SPELLBOX_CLOSE');
7828 },
7829
7830 change: function () {
7831 //console.log("Unitsbox: "+ $(".nui_units_box").height());
7832 //console.log("Spellbox: "+ $(".gods_spells_menu").height());
7833
7834 // Change spell order
7835 $('#ui_box .god_container[data-god_id="poseidon"]').prependTo('#ui_box .gods_spells_menu .content');
7836 $('#ui_box .god_container[data-god_id="athena"]').appendTo('#ui_box .gods_spells_menu .content');
7837 $('#ui_box .god_container[data-god_id="artemis"]').appendTo('#ui_box .gods_spells_menu .content');
7838 }
7839
7840 };
7841
7842
7843 // Minimize Daily reward window on startup
7844 function minimizeDailyReward() {
7845 /*
7846 $.Observer(uw.GameEvents.window.open).subscribe('DIO_WINDOW', function(u,dato){});
7847 $.Observer(uw.GameEvents.window.reload).subscribe('DIO_WINDOW2', function(f){});
7848 */
7849 if (MutationObserver) {
7850 var startup = new MutationObserver(function (mutations) {
7851 mutations.forEach(function (mutation) {
7852 if (mutation.addedNodes[0]) {
7853 if ($('.daily_login').get(0)) { // && !uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).isMinimized()
7854 $('.daily_login').find(".minimize").click();
7855 //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).minimize();
7856 }
7857 }
7858 });
7859 });
7860 startup.observe($('body').get(0), {attributes: false, childList: true, characterData: false});
7861
7862 setTimeout(function () {
7863 startup.disconnect();
7864 }, 3000);
7865 }
7866 }
7867
7868 // Larger taskbar
7869 var Taskbar = {
7870 activate: function () {
7871 $('.minimized_windows_area').get(0).style.width = "150%";
7872 $('.minimized_windows_area').get(0).style.left = "-25%";
7873 },
7874 deactivate: function () {
7875 $('.minimized_windows_area').get(0).style.width = "100%";
7876 $('.minimized_windows_area').get(0).style.left = "0%";
7877 }
7878 };
7879
7880 // Hide fade out buttons
7881 function hideNavElements() {
7882 if (Game.premium_features.curator <= Timestamp.now()) {
7883 $('.nav').each(function () {
7884 this.style.display = "none";
7885 });
7886 }
7887 }
7888
7889 /*******************************************************************************************************************************
7890 * Chat
7891 *******************************************************************************************************************************/
7892
7893 var Chat = {
7894 user_colors : {},
7895
7896 delay : 10000,
7897
7898 timestamp : 0,
7899
7900 isWindowFocused : true,
7901
7902 isActivated : false,
7903
7904 isOpened : false,
7905
7906 activate : function(){
7907
7908 Chat.isActivated = true;
7909
7910 Chat.isOpened = true;
7911
7912 $('<style id="dio_chat_style">'+
7913 '#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; }'+
7914 '#dio_chat.resize { transition: left 0s; }'+
7915
7916 '#dio_chat .slider { width:100%; height: 6px; top:0; right:1px; position:absolute; margin-left:-8px; cursor: row-resize; }'+
7917
7918 '#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; }'+
7919 '#dio_chat .messagebox .time { float:left; color: #686; }'+
7920 '#dio_chat .messagebox .user { float:left; }'+
7921 '#dio_chat .messagebox .text { word-break: break-word; color: #797; }'+
7922
7923 '#dio_chat .messagebox .welcome .text { color: rgb(200,220,200); }'+
7924
7925 '#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; }'+
7926 '#dio_chat .togglebutton .top { height:4px; width:24px; background: url(https://diotools.de/images/game/button_sprite_vertical.png) 0px -1px; position:absolute;}'+
7927 '#dio_chat .togglebutton:hover .top { background-position: -25px -1px; }'+
7928 '#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; }'+
7929 '#dio_chat .togglebutton:hover .bottom { background-position: -25px 4px; }'+
7930 '#dio_chat .togglebutton .middle { height:100%; width:24px; background: url(https://diotools.de/images/game/button_sprite_vertical.png) -50px 0px; }'+
7931 '#dio_chat .togglebutton:hover .middle { background-position: -75px 0px; }'+
7932 '#dio_chat .togglebutton .arrow { position:absolute; left:6px; top:42.5%; }'+
7933
7934 '#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; }'+
7935
7936 '#dio_chat input { background: rgba(0, 0, 0, 0.5); color: white; border: 0px none; padding: 8px; width: 100%; border-right: 1px solid darkgreen; }'+
7937 '#dio_chat input:hover { background: rgba(0, 0, 10, 0.4); }'+
7938 '#dio_chat input:focus { background: rgba(0, 0, 10, 0.4); }'+
7939 '#dio_chat input::placeholder, '+
7940 '#dio_chat input::-webkit-input-placeholder, '+
7941 '#dio_chat input::-moz-placeholder, ' +
7942 '#dio_chat input:-ms-input-placeholder, '+
7943 '#dio_chat input:-moz-placeholder { color: black; }'+
7944
7945 // Chat im Menü ausblenden
7946 '.nui_main_menu ul { height:auto !important; }'+
7947 '.nui_main_menu li.chat { display:none !important; }'+
7948
7949 '#grcgrc { display:none }'+
7950
7951 '</style>').appendTo('head');
7952
7953 $('<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");
7954
7955 $('<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");
7956
7957 $('<div class="togglebutton"><div class="top"></div><div class="middle"><div class="arrow">◄</div></div><div class="bottom"></div></div>').appendTo("#dio_chat");
7958
7959 // Texteingabe
7960 $('#dio_chat input').keypress(function(e) {
7961
7962 if (e.keyCode === 13) {
7963
7964 var _time = $('.server_time_area').get(0).innerHTML.split(" ")[0];
7965
7966 var _message = $(this).val();
7967
7968 if(_message.length > 0) {
7969
7970 Chat.sendMessage(_message);
7971
7972 $(this).val('');
7973 }
7974
7975 }
7976 });
7977
7978 /*
7979 $('#dio_chat').draggable({
7980 containment: "body",
7981 distance: 10,
7982 snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, #island_quests_overview",
7983 opacity: 0.7,
7984 stop: function () {}
7985 });
7986 */
7987
7988 // Ein-/Ausblenden der Chatbox
7989 $('#dio_chat .togglebutton').toggleClick(
7990 function () {
7991
7992 var x = -($(window).width() * 0.25 + 16);
7993
7994 $('#dio_chat').css("left", x);
7995
7996 setTimeout(function(){
7997 $('#dio_chat .togglebutton .arrow').get(0).innerHTML = "►";
7998 },1300);
7999
8000 // Tooltip
8001 $('#dio_chat .togglebutton').tooltip("Chat öffnen");
8002
8003 },
8004 function (){
8005
8006 $('#dio_chat').css("left", 0);
8007
8008 setTimeout(function(){
8009 $('#dio_chat .togglebutton .arrow').get(0).innerHTML = "◄";
8010 },1300);
8011
8012 // Tooltip
8013 $('#dio_chat .togglebutton').tooltip("Chat schließen");
8014 }
8015 );
8016 // Wenn sich die Fenstergröße ändert
8017
8018 $(window).on("resize.dio", function(){
8019
8020 if($('#dio_chat').css("left") !== "0px"){
8021
8022 var x = -($(window).width() * 0.25 + 16);
8023
8024 $('#dio_chat').addClass("resize");
8025 $('#dio_chat').css("left", x);
8026
8027 setTimeout(function(){
8028 $('#dio_chat').removeClass("resize");
8029 },0);
8030 }
8031 });
8032
8033 // Tooltip
8034 $('#dio_chat .togglebutton').tooltip("Chat schließen");
8035
8036 // Skalierung der Höhe
8037 $('#dio_chat .slider').mousedown(function (e) {
8038 e.preventDefault();
8039
8040 $('#dio_chat .messagebox').css("max-height", "none");
8041
8042 $(document).on("mousemove.dio", function (e) {
8043 e.preventDefault();
8044
8045 var x = $(window).height() - e.pageY - 49;
8046
8047 if (x > 30 && x < $(window).height() - 400) {
8048 $('#dio_chat .messagebox').css("height", x );
8049 }
8050 });
8051 });
8052
8053 $(document).on("mouseup.dio", function (e) {
8054 $(document).off("mousemove.dio");
8055
8056 //$('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollTopMax;
8057 $('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollHeight
8058 });
8059
8060
8061
8062 Chat.timestamp = Timestamp.server();
8063
8064 // Initialer Start
8065 Chat.getMessages();
8066
8067
8068 // Öfter anfragen, wenn man chatten will
8069 $('#dio_chat').hover(function(){
8070
8071 if(Chat.isOpened === true) {
8072 Chat.delay = 3000; // 3s
8073
8074 clearTimeout(Chat.timeout_A);
8075 clearTimeout(Chat.timeout_B);
8076 }
8077
8078 }, function(){
8079
8080 if(Chat.isOpened === true) {
8081
8082 Chat.delay = 10000; // 10s
8083
8084 // Nach 5min nur noch alle 30s
8085 Chat.timeout_A = setTimeout(function () {
8086 Chat.delay = 30000;
8087 }, 300000);
8088
8089 // Nach 15min nur noch alle 60s
8090 Chat.timeout_B = setTimeout(function () {
8091 Chat.delay = 60000;
8092 }, 900000);
8093 }
8094 });
8095
8096 // Nur wenn Grepolis offen ist aktualisieren
8097 $(window).on("focus.dio", function() {
8098 Chat.isWindowFocused = true;
8099
8100 if(Chat.isOpened === true) {
8101
8102 Chat.getMessages();
8103
8104 Chat.delay = 10000; // 10s
8105
8106 clearTimeout(Chat.timeout_A);
8107 clearTimeout(Chat.timeout_B);
8108
8109 // Nach 5min nur noch alle 30s
8110 Chat.timeout_A = setTimeout(function () {
8111 Chat.delay = 30000;
8112 }, 300000);
8113
8114 // Nach 15min nur noch alle 60s
8115 Chat.timeout_B = setTimeout(function () {
8116 Chat.delay = 60000;
8117 }, 900000);
8118 }
8119
8120 }).on("blur.dio", function() {
8121 Chat.isWindowFocused = false;
8122 });
8123 },
8124 deactivate : function(){
8125 Chat.isActivated = false;
8126
8127 $('#dio_chat_style').remove();
8128 $('#dio_chat').remove();
8129
8130 // Events disconnecten
8131 $(document).off('mouseup.dio');
8132 $(window).off('focus.dio');
8133 $(window).off('blur.dio');
8134 $(window).off('resize.dio');
8135 },
8136 sendMessage : function(_message){
8137
8138 _message = encodeURIComponent(_message.replace(/'/g, "'").replace(/ /g, " "));
8139
8140 $.ajax({
8141 type: "GET",
8142 url: "https://diotools.de/php/sendMessage.php?world=" + Game.world_id + "&time=" + Timestamp.server() + "&player="+ Game.player_name +"&message="+ _message,
8143 dataType: 'text',
8144 success: function (response) {
8145 console.debug("Nachricht wurde erfolgreich gesendet");
8146
8147 //$('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollTopMax;
8148 $('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollHeight
8149
8150 Chat.getMessages();
8151 },
8152 error: function (e) {
8153 console.debug("Nachricht konnte nicht gesendet werden", e);
8154 }
8155 });
8156 },
8157 getMessages : function(){
8158
8159 if(Chat.isActivated === true) {
8160
8161 var _currentTimestamp = Timestamp.server();
8162
8163 var _url = "https://diotools.de/php/getMessages.php?world=" + Game.world_id;
8164
8165 if (typeof(Chat.lastID) !== "undefined") {
8166 _url += "&id=" + Chat.lastID;
8167 }
8168 else {
8169 _url += "&time=" + Chat.timestamp;
8170 }
8171
8172 // Eventuell noch nicht gefeuertes Timeout entfernen
8173 clearTimeout(Chat.timeout);
8174
8175 if (Chat.isWindowFocused) {
8176 $.ajax({
8177 type: "GET",
8178 url: _url,
8179 dataType: 'json',
8180 success: function (_messages) {
8181 if(Chat.isActivated === true) {
8182
8183 // Letzte Abfragezeit speichern
8184 Chat.timestamp = _currentTimestamp;
8185
8186 // console.debug("GET MESSAGES", _messages);
8187
8188 /*
8189 var _scrollDown = false;
8190 if ($('#dio_chat .messagebox')[0].scrollTop === $('#dio_chat .messagebox')[0].scrollTopMax) {
8191 _scrollDown = true;
8192 }
8193 */
8194
8195 for (var m in _messages) {
8196 if (_messages.hasOwnProperty(m)) {
8197
8198 if (typeof(_messages[m].last_id) === "undefined") {
8199
8200 // HTML-Tags ersetzen
8201 var _message = _messages[m].message.replace(/</g, '<').replace(/>/g, '>').replace(/'/g, "\'");
8202
8203 $('#dio_chat .messagebox').append(
8204 '<div class="time">' + Chat.formatTime(_messages[m].time) + ': </div>' +
8205 '<div class="user" style="color:' + Chat.getUserColor(_messages[m].player) + '">' + _messages[m].player + ': </div>' +
8206 '<div class="text"> ' + _message + ' </div>'
8207 );
8208 }
8209 else {
8210 Chat.lastID = _messages[m].last_id;
8211 }
8212 }
8213 }
8214
8215 clearTimeout(Chat.timeout);
8216
8217 Chat.timeout = setTimeout(function () {
8218
8219 if (Chat.isWindowFocused) {
8220 Chat.getMessages();
8221 }
8222
8223 }, Chat.delay);
8224
8225 //if(_scrollDown) {
8226 // $('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollTopMax;
8227 $('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollHeight
8228 //}
8229 }
8230 },
8231 error: function (xhr) {
8232 console.debug("Nachrichten konnten nicht geladen werden", xhr);
8233
8234 clearTimeout(Chat.timeout);
8235
8236 Chat.timeout = setTimeout(function () {
8237
8238 Chat.getMessages();
8239
8240 }, Chat.delay);
8241
8242 }
8243 });
8244
8245 }
8246 }
8247 },
8248 getUserColor : function(_user){
8249
8250 if(typeof(Chat.user_colors[_user]) === "undefined") {
8251
8252 var r = Math.floor(Math.random() * 255);
8253 var g = Math.floor(Math.random() * 255);
8254 var b = Math.floor(Math.random() * 255);
8255
8256 // Bei zu dunkler Farbe neue Farbe ermitteln
8257 if (r + g < 200 && r < 130 && g < 130) {
8258
8259 return Chat.getUserColor(_user);
8260 }
8261
8262 Chat.user_colors[_user] = 'rgb(' + r + ',' + g + ',' + b + ')';
8263 }
8264
8265 return Chat.user_colors[_user];
8266 },
8267 formatTime : function(_timestamp){
8268
8269 var date = new Date(_timestamp*1000);
8270
8271 // Hours part from the timestamp
8272 var hours = "0" + date.getHours();
8273 // Minutes part from the timestamp
8274 var minutes = "0" + date.getMinutes();
8275 // Seconds part from the timestamp
8276 var seconds = "0" + date.getSeconds();
8277
8278 // Will display time in 10:30:23 format
8279 return hours.substr(-2) + ':' + minutes.substr(-2) + ':' + seconds.substr(-2);
8280 }
8281 };
8282
8283 /*******************************************************************************************************************************
8284 * Activity boxes
8285 * ----------------------------------------------------------------------------------------------------------------------------
8286 * | ● Show troops and trade activity boxes
8287 * | ● Boxes are magnetic & movable (position memory)
8288 * ----------------------------------------------------------------------------------------------------------------------------
8289 *******************************************************************************************************************************/
8290 var mut_toolbar, mut_command, mut_trade;
8291
8292 var save_command_mouseout,
8293 save_commandlist_mouseout,
8294 save_trade_mouseout,
8295 save_tradelist_mouseout,
8296
8297 save_command_mouseover,
8298 save_trade_mouseover;
8299
8300
8301 var ActivityBoxes = {
8302 activate: function () {
8303 ActivityBoxes.checkToolbarAtStart();
8304
8305 $('#toolbar_activity_commands_list').css({
8306 left: commandbox.left + "px",
8307 top: commandbox.top + "px"
8308 });
8309
8310 $('<style id="fix_lists" type="text/css">' +
8311 '#toolbar_activity_commands_list, #toolbar_activity_trades_list { width: 160px}' +
8312 '.dropdown-list .content { max-height: 329px}' +
8313 '</style>' +
8314 '<style id="dio_fix_trade" type="text/css">' +
8315 '#toolbar_activity_trades_list {' +
8316 'left:' + tradebox.left + 'px !important;' +
8317 'top: ' + tradebox.top + 'px !important}' +
8318 '</style>').appendTo('head');
8319
8320
8321 ActivityBoxes.draggableTradeBox();
8322 ActivityBoxes.draggableCommandBox();
8323
8324 ActivityBoxes.catchToolbarEvents();
8325 },
8326 deactivate: function () {
8327 ActivityBoxes.hideTradeList();
8328 ActivityBoxes.hideCommandList();
8329
8330 mut_toolbar.disconnect();
8331 mut_command.disconnect();
8332 mut_trade.disconnect();
8333 },
8334 showTradeList: function () {
8335 if (!$('#dio_trades_activity_style').get(0)) {
8336 $('#toolbar_activity_trades').mouseover();
8337 $('<style id="dio_trades_activity_style"> #toolbar_activity_trades_list { display: block !important; } </style>').appendTo("head");
8338 }
8339 },
8340 showCommandList: function () {
8341 if (!$('#dio_commands_activity_style').get(0)) {
8342 $('#toolbar_activity_commands').mouseover();
8343 $('<style id="dio_commands_activity_style"> #toolbar_activity_commands_list { ' +
8344 'display:block !important; left:' + commandbox.left + 'px; top:' + commandbox.top + 'px; }' +
8345 '</style>').appendTo("head");
8346 }
8347 },
8348 hideTradeList: function () {
8349 if ($('#dio_trades_activity_style').get(0)) {
8350 $('#dio_trades_activity_style').remove();
8351 $('#toolbar_activity_trades').mouseout();
8352 }
8353 },
8354 hideCommandList: function () {
8355 if ($('#dio_commands_activity_style').get(0)) {
8356 $('#dio_commands_activity_style').remove();
8357 $('#toolbar_activity_commands').mouseout();
8358 }
8359 },
8360 activate2: function () {
8361 var observe_options = {attributes: false, childList: true, characterData: false};
8362
8363 ActivityBoxes.catchToolbarEvents();
8364
8365 mut_command.observe($('.toolbar_activities .commands .count').get(0), observe_options);
8366 mut_trade.observe($('.toolbar_activities .trades .count').get(0), observe_options);
8367
8368 $('<style id="dio_activity_style"> ' +
8369 '#toolbar_activity_commands_list.active { display: block !important; } ' +
8370 '#toolbar_activity_trades_list.active { display: block !important; } ' +
8371 '</style>').appendTo("head");
8372
8373
8374 $('#toolbar_activity_commands').mouseover();
8375 $('#toolbar_activity_trades').mouseover();
8376
8377 $('#toolbar_activity_commands, #toolbar_activity_trades').off("mouseover");
8378
8379 $('#toolbar_activity_commands, #toolbar_activity_commands_list, #toolbar_activity_trades, #toolbar_activity_trades_list').off("mouseout");
8380
8381 $('#toolbar_activity_trades_list').unbind("click");
8382 //console.log($('#toolbar_activity_commands').data('events')["dd:list:show"][0].handler());
8383
8384 ActivityBoxes.checkToolbarAtStart();
8385
8386 $('#toolbar_activity_commands_list').css({
8387 left: commandbox.left + "px",
8388 top: commandbox.top + "px"
8389 });
8390
8391 $('<style id="fix_lists" type="text/css">' +
8392 '#toolbar_activity_commands_list, #toolbar_activity_trades_list { width: 160px}' +
8393 '.dropdown-list .content { max-height: 329px}' +
8394 '</style>' +
8395 '<style id="dio_fix_trade" type="text/css">' +
8396 '#toolbar_activity_trades_list {' +
8397 'left:' + tradebox.left + 'px !important;' +
8398 'top: ' + tradebox.top + 'px !important}' +
8399 '</style>').appendTo('head');
8400
8401 ActivityBoxes.draggableCommandBox();
8402 ActivityBoxes.draggableTradeBox();
8403
8404
8405 /*
8406 $('.toolbar_activities .commands').on("mouseover.bla", function(){
8407 $('#toolbar_activity_commands_list').addClass("active");
8408 });
8409
8410 $('.toolbar_activities .trades').mouseover(function(){
8411 $('#toolbar_activity_trades_list').addClass("active");
8412 });
8413 */
8414 },
8415 deactivate2: function () {
8416 mut_toolbar.disconnect();
8417 mut_command.disconnect();
8418 mut_trade.disconnect();
8419 /*
8420 $('#toolbar_activity_commands').on("mouseover", save_command_mouseover);
8421 $('#toolbar_activity_trades').on("mouseover", save_trade_mouseover);
8422
8423 $('#toolbar_activity_commands').on("mouseout", save_command_mouseout);
8424 $('#toolbar_activity_commands_list').on("mouseout", save_commandlist_mouseout);
8425 $('#toolbar_activity_trades').on("mouseout", save_trade_mouseout);
8426 $('#toolbar_activity_trades_list').on("mouseout", save_tradelist_mouseout);
8427 */
8428
8429 $('#toolbar_activity_commands').mouseover = save_command_mouseover;
8430 $('#toolbar_activity_trades').mouseover = save_trade_mouseover;
8431
8432 $('#toolbar_activity_commands').mouseout = save_command_mouseout;
8433 $('#toolbar_activity_commands_list').mouseout = save_commandlist_mouseout;
8434 $('#toolbar_activity_trades').mouseout = save_trade_mouseout;
8435 $('#toolbar_activity_trades_list').mouseout = save_tradelist_mouseout;
8436
8437
8438 $('#toolbar_activity_trades_list').removeClass("active");
8439 $('#toolbar_activity_commands_list').removeClass("active");
8440 /*
8441 $('.toolbar_activities .commands').off("mouseover.bla");
8442 */
8443 $('#dio_activity_style').remove();
8444
8445
8446 },
8447 checkToolbarAtStart: function () {
8448 if (parseInt($('.toolbar_activities .commands .count').get(0).innerHTML, 10) > 0) {
8449 ActivityBoxes.showCommandList();
8450 } else {
8451 ActivityBoxes.hideCommandList();
8452 }
8453 if (parseInt($('.toolbar_activities .trades .count').get(0).innerHTML, 10) > 0) {
8454 ActivityBoxes.showTradeList();
8455 } else {
8456 ActivityBoxes.hideTradeList();
8457 }
8458 },
8459 catchToolbarEvents: function () {
8460 var observe_options = {attributes: false, childList: true, characterData: false};
8461
8462 mut_toolbar = new MutationObserver(function (mutations) {
8463 mutations.forEach(function (mutation) {
8464 if (mutation.addedNodes[0]) {
8465 //console.debug(mutation.target.id);
8466 if (mutation.target.id === "toolbar_activity_trades_list") {
8467 ActivityBoxes.draggableTradeBox();
8468 } else {
8469 ActivityBoxes.draggableCommandBox();
8470 }
8471 mutation.addedNodes[0].remove();
8472 }
8473 });
8474 });
8475 //mut_toolbar.observe($('#toolbar_activity_commands_list').get(0), observe_options );
8476 //mut_toolbar.observe($('#toolbar_activity_trades_list').get(0), observe_options );
8477
8478 mut_command = new MutationObserver(function (mutations) {
8479 mutations.forEach(function (mutation) {
8480 if (mutation.addedNodes[0]) {
8481 //console.debug(mutation.addedNodes[0].nodeValue);
8482 if (mutation.addedNodes[0].nodeValue > 0) {
8483 ActivityBoxes.showCommandList();
8484 } else {
8485 //console.debug("hide commands");
8486 ActivityBoxes.hideCommandList();
8487 }
8488 }
8489 });
8490 });
8491 mut_trade = new MutationObserver(function (mutations) {
8492 mutations.forEach(function (mutation) {
8493 if (mutation.addedNodes[0]) {
8494 if (mutation.addedNodes[0].nodeValue > 0) {
8495 ActivityBoxes.showTradeList();
8496 } else {
8497 ActivityBoxes.hideTradeList();
8498 }
8499 }
8500 });
8501 });
8502 mut_command.observe($('.toolbar_activities .commands .count').get(0), observe_options);
8503 mut_trade.observe($('.toolbar_activities .trades .count').get(0), observe_options);
8504 },
8505 // Moveable boxes
8506 draggableTradeBox: function () {
8507 $("#toolbar_activity_trades_list").draggable({
8508 containment: "body",
8509 distance: 20,
8510 snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, .nui_left_box",
8511 opacity: 0.7,
8512 start: function () {
8513 $("#dio_fix_trade").remove();
8514 },
8515 stop: function () {
8516 var pos = $('#toolbar_activity_trades_list').position();
8517
8518 tradebox.left = pos.left;
8519 tradebox.top = pos.top;
8520
8521 saveValue("tradebox", JSON.stringify(tradebox));
8522
8523 $('<style id="dio_fix_trade" type="text/css">' +
8524 '#toolbar_activity_trades_list { left:' + tradebox.left + 'px !important; top:' + tradebox.top + 'px !important; } ' +
8525 '</style>').appendTo('head');
8526 }
8527 });
8528 },
8529 draggableCommandBox: function () {
8530 $("#toolbar_activity_commands_list").draggable({
8531 containment: "body",
8532 distance: 20,
8533 snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, .nui_left_box",
8534 opacity: 0.7,
8535 stop: function () {
8536 var pos = $('#toolbar_activity_commands_list').position();
8537 commandbox.left = pos.left;
8538 commandbox.top = pos.top;
8539
8540 saveValue("commandbox", JSON.stringify(commandbox));
8541 }
8542 });
8543 }
8544 };
8545
8546 /*******************************************************************************************************************************
8547 * Counter
8548 *******************************************************************************************************************************/
8549
8550 function counter(time) {
8551 var type = "", today, counted, year, month, day;
8552 if (uw.Game.market_id !== "zz") {
8553 counted = DATA.count;
8554 today = new Date((time + 7200) * 1000);
8555 year = today.getUTCFullYear();
8556 month = ((today.getUTCMonth() + 1) < 10 ? "0" : "") + (today.getUTCMonth() + 1);
8557 day = (today.getUTCDate() < 10 ? "0" : "") + today.getUTCDate();
8558 today = year + month + day;
8559 //console.log(today);
8560 if (counted[0] !== today) {
8561 type += "d";
8562 }
8563 if (counted[1] == false) {
8564 type += "t";
8565 }
8566 if ((counted[2] == undefined) || (counted[2] == false)) {
8567 type += "b";
8568 }
8569 if (type !== "") {
8570 $.ajax({
8571 type: "GET",
8572 url: "https://diotools.de/game/count.php?type=" + type + "&market=" + uw.Game.market_id + "&date=" + today + "&browser=" + getBrowser(),
8573 dataType: 'text',
8574 success: function (text) {
8575 if (text.indexOf("dly") > -1) {
8576 counted[0] = today;
8577 }
8578 if (text.indexOf("tot") > -1) {
8579 counted[1] = true;
8580 }
8581 if (text.indexOf("bro") > -1) {
8582 counted[2] = true;
8583 }
8584 saveValue("dio_count", JSON.stringify(counted));
8585 }
8586 });
8587 }
8588 }
8589 }
8590
8591
8592 /*******************************************************************************************************************************
8593 * Political Map
8594 *******************************************************************************************************************************/
8595
8596 var PoliticalMap = {
8597 data: null,
8598 activate: function () {
8599 $('<div id="dio_political_map">' +
8600 '<div class="canvas_wrapper"></div>' +
8601 '<select class="zoom_select">' +
8602 '<option value="0.50">1 : 0.50</option>' +
8603 '<option value="0.75">1 : 0.75</option>' +
8604 '<option value="1.00" selected>1 : 1.00</option>' +
8605 '<option value="1.25">1 : 1.25</option>' +
8606 '<option value="1.50">1 : 1.50</option>' +
8607 '<option value="2.00">1 : 2.00</option>' +
8608 '<option value="3.00">1 : 3.00</option>' +
8609 '</select>' +
8610 '<div class="legend sandy-box">' +
8611 '<div class="corner_tl"></div>' +
8612 '<div class="corner_tr"></div>' +
8613 '<div class="corner_bl"></div>' +
8614 '<div class="corner_br"></div>' +
8615 '<div class="border_t"></div>' +
8616 '<div class="border_b"></div>' +
8617 '<div class="border_l"></div>' +
8618 '<div class="border_r"></div>' +
8619 '<div class="middle"></div>' +
8620 '<div class="content"><div class="item"></div></div>' +
8621 '</div></div>').appendTo('#ui_box');
8622
8623 // Style
8624 $('<style id="dio_political_map_style">' +
8625 '#dio_political_map { width:100%; height:100%; z-index:3; background:#123d70; display:none; position:absolute; top:0; } ' +
8626 '#dio_political_map.active { display: block; } ' +
8627 '#dio_political_map .canvas_wrapper { } ' +
8628 '#dio_political_map canvas { position: absolute; cursor:move; top:0; left:0; } ' +
8629 '#dio_political_map .zoom_select { position:absolute; top:70px; left:300px; font-size: 2em; opacity:0.5; } ' +
8630 '#dio_political_map .zoom_select:hover { opacity:1; } ' +
8631 '#dio_political_map .legend { position:absolute; right:200px; top:50px; width:200px; height:auto; text-align:left; } ' +
8632 '#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; } ' +
8633 '#dio_political_map .legend .wonder_icon { float: left; margin: 4px; } ' +
8634
8635 '.btn_political_map { top:56px; left:-4px; z-index:10; position:absolute; } ' +
8636
8637 '.btn_political_map .ico_political_map { margin:7px 0px 0px 8px; width:17px; height:17px; background:url(http://s1.directupload.net/images/140408/pltgqlaw.png) no-repeat 0px 0px; background-size:100%; } ' +
8638 // http://s14.directupload.net/images/140408/k4wikrlq.png // http://s7.directupload.net/images/140408/ahfr8227.png
8639 '.btn_political_map .ico_political_map.checked { margin-top:8px; } ' +
8640 '</style>').appendTo('head');
8641
8642 PoliticalMap.addButton();
8643
8644 var zoomSelect = $('.zoom_select');
8645
8646 zoomSelect.change(function () {
8647 //PoliticalMap.zoomToCenter();
8648 });
8649 zoomSelect.on("change", function () {
8650 PoliticalMap.zoomToCenter();
8651 });
8652
8653 ColorPicker.init();
8654 },
8655 deactivate: function () {
8656 $('.btn_political_map').remove();
8657 $('#dio_political_map_style').remove();
8658 },
8659 addButton: function () {
8660 var m_ZoomFactor = 1.0;
8661 $('<div class="btn_political_map circle_button" name="political_map"><div class="ico_political_map js-caption"></div></div>').appendTo(".bull_eye_buttons");
8662
8663 var politicalMapButton = $('.btn_political_map');
8664
8665 // Tooltip
8666 politicalMapButton.tooltip("Political Map"); // TODO: Language
8667
8668 // Events
8669 politicalMapButton.on('mousedown', function () {
8670 //$('.btn_political_map, .ico_political_map').addClass("checked");
8671 }).on('mouseup', function () {
8672 //$('.btn_political_map, .ico_political_map').removeClass("checked");
8673 });
8674
8675 $('.rb_map .option').click(function () {
8676 $('.btn_political_map, .ico_political_map').removeClass("checked");
8677 $('#dio_political_map').removeClass("active");
8678 $(this).addClass("checked");
8679 });
8680
8681 politicalMapButton.click(function () {
8682 $('.rb_map .checked').removeClass("checked");
8683 $('.btn_political_map, .ico_political_map').addClass("checked");
8684 $('#dio_political_map').addClass("active");
8685
8686 if ($('#dio_political_map').hasClass("active")) {
8687 if (PoliticalMap.data == null) {
8688 $('#ajax_loader').css({visibility: "visible"});
8689 // Map-Daten aus DB auslesen
8690 PoliticalMap.loadMapData();
8691 } else {
8692 //PoliticalMap.drawMap(PoliticalMap.data);
8693 }
8694 }
8695 });
8696 },
8697 /**
8698 * Läd die Allianzen und Inseln aus der Datenbank
8699 * @since 3.0
8700 */
8701 loadMapData: function () {
8702 $.ajax({
8703 type: "GET",
8704 url: "https://diotools.de/php/map.php?world_id=" + WID + "&callback=jsonCallback",
8705 //dataType: 'jsonp',
8706 //async: false,
8707 //jsonpCallback: 'jsonCallback',
8708 //contentType: "application/json",
8709 success: function (response) {
8710 if (response !== "") {
8711 PoliticalMap.data = response;
8712
8713 var m_ZoomFactor = $('.zoom_select').get(0)[$('.zoom_select').get(0).selectedIndex].selected;
8714
8715 PoliticalMap.drawMap(PoliticalMap.data, m_ZoomFactor);
8716 PoliticalMap.drawWonders(PoliticalMap.data, m_ZoomFactor);
8717
8718 $('#ajax_loader').css({visibility: "hidden"});
8719
8720 // Überprüfen, ob die Weltdaten geupdatet werden müssen
8721 $.ajax({
8722 type: "GET",
8723 url: "https://diotools.de/php/update_db.php?world_id=" + WID
8724 });
8725 } else {
8726 // Welt existiert noch nicht in DB
8727 $.ajax({
8728 type: "GET", url: "https://diotools.de/php/update_db.php?world_id=" + WID,
8729 success: function () {
8730 // Map-Daten aus DB auslesen, wenn die Weltdaten erfolgreich in die DB geladen wurden
8731 $.ajax({
8732 type: "GET",
8733 url: "https://diotools.de/php/map.php?world_id=" + WID,
8734 success: function (response) {
8735 PoliticalMap.data = response;
8736
8737 var m_ZoomFactor = $('.zoom_select').get(0)[$('.zoom_select').get(0).selectedIndex].selected;
8738
8739 PoliticalMap.drawMap(PoliticalMap.data, m_ZoomFactor);
8740 PoliticalMap.drawWonders(PoliticalMap.data, m_ZoomFactor);
8741
8742 $('#ajax_loader').css({visibility: "hidden"});
8743 }
8744 });
8745 }
8746 });
8747 }
8748 }
8749 });
8750 },
8751 /**
8752 * Ändert die Zoomstufe der Karte zum Zentrum hin
8753 *
8754 * @param _zoom
8755 * @since 3.0
8756 */
8757 zoomToCenter: function () {
8758 var _zoom = $('.zoom_select').get(0)[$('.zoom_select').get(0).selectedIndex].value;
8759
8760 var canvas = $('#dio_political_map canvas'),
8761
8762 canvas_size = parseInt($('#dio_political_map canvas').width(), 10); // Breite und Höhe sind immer gleich
8763
8764 var canvas_style = $('#dio_political_map .canvas_wrapper').get(0).style;
8765
8766 // Berechnung: Alter Abstand + (1000 * Zoomänderung / 2)
8767 canvas_style.top = parseInt(canvas_style.top, 10) + (1000 * (canvas_size / 1000 - _zoom)) / 2 + "px";
8768 canvas_style.left = parseInt(canvas_style.left, 10) + (1000 * (canvas_size / 1000 - _zoom)) / 2 + "px";
8769
8770 PoliticalMap.clearMap();
8771 PoliticalMap.drawMap(PoliticalMap.data, _zoom);
8772 PoliticalMap.drawWonders(PoliticalMap.data, _zoom);
8773
8774 },
8775 /**
8776 * Ändert die Zoomstufe der Karte zur Cursorposition hin
8777 *
8778 * @param _zoom
8779 * @param _pos
8780 *
8781 * @since 3.0
8782 */
8783 zoomToCursorPosition: function (_zoom, _pos) {
8784
8785 },
8786 /**
8787 * Zeichnet die Karte in ein Canvas
8788 *
8789 * @param _islandArray {Array}
8790 * @param _zoom {int}
8791 *
8792 * @since 3.0
8793 */
8794 drawMap: function (_islandArray, _zoom) {
8795
8796 $('<canvas class="canv_map" height="' + (1000 * _zoom) + 'px" width="' + (1000 * _zoom) + "px\"></canvas>").prependTo('.canvas_wrapper')
8797
8798 // TODO: Weite und Höhe vom Fenster ermitteln, Update Containment bei onResizeWindow
8799 $('#dio_political_map .canvas_wrapper').draggable({
8800 // left, top, right, bottom
8801 //containment: [-500 * _zoom, -300 * _zoom, 500 * _zoom, 300 * _zoom],
8802 distance: 10,
8803 grid: [100 * _zoom, 100 * _zoom],
8804 //limit: 500,
8805 cursor: 'pointer'
8806 });
8807
8808 var ally_ranking = JSON.parse(_islandArray)['ally_ranking'];
8809 var island_array = JSON.parse(_islandArray)['ally_island_array'];
8810
8811
8812 var c = $('#dio_political_map .canv_map')[0].getContext('2d');
8813
8814 // Grid
8815 c.strokeStyle = 'rgb(0,100,0)';
8816
8817 for (var l = 0; l <= 10; l++) {
8818 // Horizontal Line
8819 c.moveTo(0, l * 100 * _zoom);
8820 c.lineTo(1000 * _zoom, l * 100 * _zoom);
8821 c.stroke();
8822
8823 // Vertical Line
8824 c.moveTo(l * 100 * _zoom, 0);
8825 c.lineTo(l * 100 * _zoom, 1000 * _zoom);
8826 c.stroke();
8827 }
8828
8829 // Center Circle
8830 c.beginPath();
8831 c.arc(500 * _zoom, 500 * _zoom, 100 * _zoom, 0, Math.PI * 2, true);
8832 c.fillStyle = 'rgba(0,100,0,0.2)';
8833 c.fill();
8834 c.stroke();
8835
8836 // Sea numbers
8837 c.fillStyle = 'rgb(0,100,0)';
8838
8839 for (var y = 0; y <= 10; y++) {
8840 for (var x = 0; x <= 10; x++) {
8841 c.fillText(y + "" + x, y * 100 * _zoom + 2, x * 100 * _zoom + 10);
8842 }
8843 }
8844
8845 // Alliance Colors
8846 var colorArray = ["#00A000", "yellow", "red", "rgb(255, 116, 0)", "cyan", "#784D00", "white", "purple", "#0078FF", "deeppink", "darkslategrey"];
8847
8848 // Islands
8849 for (var t in island_array) {
8850 if (island_array.hasOwnProperty(t)) {
8851 var tmp_points = 0, dom_ally = "";
8852 for (var ally in island_array[t]) {
8853 if (island_array[t].hasOwnProperty(ally)) {
8854 if (tmp_points < island_array[t][ally] && (ally !== "X") && (ally !== "")) {
8855 tmp_points = island_array[t][ally];
8856 dom_ally = ally;
8857 }
8858 }
8859 }
8860
8861 c.fillStyle = colorArray[parseInt(ally_ranking[dom_ally], 10) - 1] || "darkslategrey";
8862 //c.fillRect(t.split("x")[0] * _zoom, t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
8863
8864 //c.beginPath();
8865 //console.info(island_array[t]);
8866 //c.arc(t.split("x")[0], t.split("x")[1], 2, 0, Math.PI * 2, true);
8867 //c.fillRect(t.split("x")[0] * _zoom,t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
8868 //c.fill();
8869
8870 // TEST HEATMAP
8871 //console.debug("Blaaa", c.fillStyle);
8872 if (c.fillStyle !== "#2f4f4f") {
8873 var color = c.fillStyle;
8874
8875 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);
8876 radgrad.addColorStop(0, PoliticalMap.convertHexToRgba(color, 0.2));
8877 radgrad.addColorStop(0.6, PoliticalMap.convertHexToRgba(color, 0.2));
8878 radgrad.addColorStop(1, PoliticalMap.convertHexToRgba(color, 0.0));
8879
8880 // draw shape
8881 c.fillStyle = radgrad;
8882
8883 c.fillRect(t.split("x")[0] * _zoom - 10, t.split("x")[1] * _zoom - 10, 22, 22);
8884
8885 c.fillStyle = PoliticalMap.convertHexToRgba(color, 0.7);
8886 c.fillRect(t.split("x")[0] * _zoom, t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
8887 }
8888 else {
8889 c.fillRect(t.split("x")[0] * _zoom, t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
8890 }
8891 }
8892 }
8893
8894
8895
8896 // Legende
8897 var legend = $('#dio_political_map .legend .content');
8898
8899 legend.get(0).innerHTML = "";
8900
8901 for (var ally in ally_ranking) {
8902 if (ally_ranking.hasOwnProperty(ally)) {
8903 //legend.append("<div class='item' style='color:"+ colorAllyArray[ally] +"'><div class='color_checker' style='background-color:"+ colorAllyArray[ally] +"'></div>...</div>");
8904
8905 if (ally_ranking[ally] > 10) {
8906 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>");
8907
8908 break;
8909 } else {
8910 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>");
8911
8912 }
8913 }
8914 }
8915
8916 $('#dio_political_map .legend .color_checker').click(function (event) {
8917 // getting user coordinates
8918 var x = event.pageX - this.offsetLeft;
8919 var y = event.pageY - this.offsetTop;
8920
8921 console.debug("Color Checker", event.pageX, this.offsetLeft);
8922
8923 ColorPicker.open(x,y);
8924 });
8925
8926
8927 // TODO: Wenn eine Farbe ausgewählt wurde, soll [...]
8928 $(ColorPicker).on("onColorChanged", function(event, color){
8929 console.debug("Farbe setzen", event, color);
8930
8931 $.ajax({
8932 type: "POST",
8933 url: "https://" + Game.world_id + ".grepolis.com/game/alliance?town_id=" + Game.townId + "&action=assign_map_color&h=" + Game.csrfToken,
8934 data: {
8935 "json": "{\"alliance_id\":\"217\",\"color\":"+ color +",\"player_id\":\"8512878\",\"town_id\":\"71047\",\"nl_init\":true}"
8936 },
8937 success: function (response) {
8938 console.debug("Erfolgreich übertragen", response);
8939 }
8940 });
8941 });
8942
8943 },
8944 convertHexToRgba: function (hex, opacity) {
8945 console.debug("hex", hex);
8946 hex = hex.replace('#', '');
8947 r = parseInt(hex.substring(0, 2), 16);
8948 g = parseInt(hex.substring(2, 4), 16);
8949 b = parseInt(hex.substring(4, 6), 16);
8950
8951 result = 'rgba(' + r + ',' + g + ',' + b + ',' + opacity + ')';
8952 return result;
8953 },
8954 /**
8955 * Zeichnet die Weltwunder auf der Karte
8956 *
8957 * @param _islandArray {Array}
8958 * @param _zoom {int}
8959 *
8960 * @since 3.0
8961 */
8962 drawWonders: function (_islandArray, _zoom) {
8963
8964 $('<canvas class="canv_ww" height="' + (1000 * _zoom) + 'px" width="' + (1000 * _zoom) + 'px"></canvas>').appendTo('.canvas_wrapper')
8965
8966 var c = $('#dio_political_map .canv_ww')[0].getContext('2d');
8967
8968 c.strokeStyle = 'rgb(0,100,0)';
8969
8970 // World Wonders
8971 var wonders = {}, wonderImages = {};
8972 //console.debug(JSON.stringify(wonder.map));
8973
8974 for (var wonderType in wonder.map) {
8975 if (wonder.map.hasOwnProperty(wonderType)) {
8976 var tmp = 0;
8977 for (var wonderCoords in wonder.map[wonderType]) {
8978 if (parseInt(wonder.map[wonderType][wonderCoords], 10) > tmp) {
8979 wonders[wonderType] = wonderCoords;
8980 tmp = parseInt(wonder.map[wonderType][wonderCoords], 10)
8981 }
8982 }
8983 }
8984 }
8985
8986 // Legende
8987 var legend = $('#dio_political_map .legend .content');
8988
8989 legend.append("<div class=\"item no_results\"></div>");
8990
8991 for (var w in wonders) {
8992 if (wonders.hasOwnProperty(w)) {
8993 var _w = w;
8994
8995 wonderImages[_w] = new Image();
8996
8997 wonderImages[_w].onload = function () {
8998 c.drawImage(this, this.pos.split("_")[0] * _zoom - 9, this.pos.split("_")[1] * _zoom - 9);
8999 };
9000
9001 wonderImages[_w].pos = wonders[_w];
9002 wonderImages[_w].src = "https://diotools.de/images/icons/ww/" + _w + ".png";
9003
9004 var wonder_string = _w.split("_of")[0].split("_");
9005 wonder_string = wonder_string[wonder_string.length - 1];
9006 wonder_string = wonder_string.substring(0, 1).toUpperCase() + wonder_string.substring(1);
9007
9008 legend.append("<img class='wonder_icon' src='" + wonderImages[_w].src + "'><div class='item'>" + wonder_string + "</div>");
9009 }
9010 }
9011 },
9012 clearMap: function () {
9013 $('#dio_political_map .canv_map').remove();
9014 $('#dio_political_map .canv_ww').remove();
9015 },
9016 getAllianceColors: function () {
9017 $.ajax({
9018 type: "GET",
9019 url: "https://" + Game.world_id + ".grepolis.com/game/map_data?town_id=" + Game.townId + "&action=get_custom_colors&h=" + Game.csrfToken,
9020 dataType: 'json',
9021 success: function (response) {
9022 // Allianzbox herausfiltern
9023 var html_string = $('#alliance_box', $(response.json.list_html));
9024
9025 var flagArray = $('.flag', html_string);
9026 var linkArray = $('a', html_string);
9027
9028 var allianceColorArray = [];
9029
9030 for (var i = 0; i < flagArray.length; i++) {
9031 allianceColorArray[i] = {
9032 "id": parseInt(linkArray[i].attributes.onclick.value.split(",")[1].split(")")[0], 10),
9033 "color": flagArray[i].style.backgroundColor
9034 };
9035 }
9036
9037 // console.debug("ANTWORT", allianceColorArray);
9038 }
9039 });
9040 }
9041 };
9042
9043 var ColorPicker = {
9044 open: function(pos_left, pos_top){
9045 $('#dio_color_picker').removeClass("hidden");
9046 $('#dio_color_picker').css({
9047 left: pos_left,
9048 top: pos_top
9049 });
9050 },
9051 close: function(){
9052 $('#dio_color_picker').addClass("hidden");
9053 },
9054 init: function () {
9055 // Style
9056 $('<style id="dio_color_picker_style">' +
9057 '#dio_color_picker { left:200px;top:300px;position:absolute;z-index:1000;} ' +
9058 '#dio_color_picker.hidden { display:none;} ' +
9059 '#dio_color_picker span.grepo_input, ' +
9060 '#dio_color_picker a.color_table, ' +
9061 '#dio_color_picker a.confirm, ' +
9062 '#dio_color_picker a.cancel' +
9063 ' { float:left; } ' +
9064 '</style>').appendTo('head');
9065
9066 $(
9067 '<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>' +
9068 '<div id="hex">HEX: <input type="text"></input></div>' +
9069 '<div id="rgb">RGB: <input type="text"></input></div>'
9070 ).prependTo('#dio_political_map')
9071
9072 $(
9073 '<div id="dio_color_picker" class="hidden"><table class="bb_popup" cellpadding="0" cellspacing="0"><tbody>' +
9074 '<tr class="bb_popup_top">' +
9075 '<td class="bb_popup_top_left"></td>' +
9076 '<td class="bb_popup_top_middle"></td>' +
9077 '<td class="bb_popup_top_right"></td>' +
9078 '</tr>' +
9079 '<tr>' +
9080 '<td class="bb_popup_middle_left"></td>' +
9081 '<td class="bb_popup_middle_middle">' +
9082 '<div class="bb_color_picker_colors">' +
9083 '<div style="background-color: rgb(255, 0, 0);"></div>' +
9084 '<div style="background-color: rgb(0, 255, 0);"></div>' +
9085 '<div style="background-color: rgb(0, 0, 255);"></div>' +
9086 '</div>' +
9087 '<a href="#" class="cancel"></a>' +
9088 '<span class="grepo_input">' +
9089 '<span class="left">' +
9090 '<span class="right">' +
9091 '<input class="color_string" style="width:50px;" maxlength="6" type="text">' +
9092 '</span>' +
9093 '</span>' +
9094 '</span>' +
9095 '<a href="#" class="color_table"><input type="color" id="c" tabindex=-1 class="hidden"></a>' +
9096 '<a href="#" class="confirm"></a>' +
9097 '</td>' +
9098 '<td class="bb_popup_middle_right"></td>' +
9099 '</tr>' +
9100 '<tr class="bb_popup_bottom">' +
9101 '<td class="bb_popup_bottom_left"></td>' +
9102 '<td class="bb_popup_bottom_middle"></td>' +
9103 '<td class="bb_popup_bottom_right"></td>' +
9104 '</tr>' +
9105 '</tbody></table></div>'
9106 ).prependTo('#dio_political_map');
9107
9108 var canvas = document.getElementById('canvas_picker').getContext('2d');
9109
9110 var count = 5, line = 0, width = 16, height = 12, sep = 1;
9111
9112 var offset = (count - 2) * width;
9113
9114 for (var i = 2, j = 0; i < count; i++, j++) {
9115
9116 line = 0;
9117
9118 // Pinktöne (255,0,255)
9119 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", 0, " + ((i / count * 255) | 0) + ")";
9120 canvas.fillRect(i * width, line, width - sep, height - sep);
9121
9122 canvas.fillStyle = "rgb(255," + ((j / (count - 1) * 255) | 0) + ", 255)";
9123 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9124
9125 line = line + height;
9126
9127 // Rosatöne (255,0,127)
9128 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", 0, " + ((i / count * 127) | 0) + ")";
9129 canvas.fillRect(i * width, line, width - sep, height - sep);
9130
9131 canvas.fillStyle = "rgb(255," + ((j / (count - 1) * 255) | 0) + "," + (127 + ((j / (count - 1) * 127) | 0)) + ")";
9132 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9133
9134 line = line + height;
9135
9136 // Rottöne (255,0,0)
9137 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", 0, 0)";
9138 canvas.fillRect(i * width, line, width - sep, height - sep);
9139
9140 canvas.fillStyle = "rgb(255," + ((j / (count - 1) * 255) | 0) + "," + ((j / (count - 1) * 255) | 0) + ")";
9141 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9142
9143 line = line + height;
9144
9145 // Orangetöne (255, 127, 0)
9146 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", " + ((i / count * 127) | 0) + ", 0)";
9147 canvas.fillRect(i * width, line, width - sep, height - sep);
9148
9149 canvas.fillStyle = "rgb(255, " + (127 + ((j / (count - 1) * 127) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ")";
9150 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9151
9152 line = line + height;
9153
9154 // Dunkelbrauntöne (170, 85, 0)
9155 canvas.fillStyle = "rgb(" + ((i / count * 170) | 0) + ", " + ((i / count * 85) | 0) + ", 0)";
9156 canvas.fillRect(i * width, line, width - sep, height - sep);
9157
9158 canvas.fillStyle = "rgb(" + (170 + (j / (count - 1) * 85) | 0) + ", " + (85 + ((j / (count - 1) * 170) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ")";
9159 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9160
9161 line = line + height;
9162
9163 // Brauntöne (191, 127, 0)
9164 canvas.fillStyle = "rgb(" + ((i / count * 191) | 0) + ", " + ((i / count * 127) | 0) + ", 0)";
9165 canvas.fillRect(i * width, line, width - sep, height - sep);
9166
9167 canvas.fillStyle = "rgb(" + (191 + (j / (count - 1) * 64) | 0) + ", " + (127 + ((j / (count - 1) * 127) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ")";
9168 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9169
9170 line = line + height;
9171
9172 // Gelbtöne (255,255,0)
9173 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ", 0)";
9174 canvas.fillRect(i * width, line, width - sep, height - sep);
9175
9176 canvas.fillStyle = "rgb(255, 255," + ((j / (count - 1) * 255) | 0) + ")";
9177 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9178
9179 line = line + height;
9180
9181 // Gelbgrüntöne (127,255,0)
9182 canvas.fillStyle = "rgb(" + ((i / count * 127) | 0) + "," + ((i / count * 191) | 0) + ", 0)";
9183 canvas.fillRect(i * width, line, width - sep, height - sep);
9184
9185 canvas.fillStyle = "rgb(" + (127 + (j / (count - 1) * 127) | 0) + "," + (191 + (j / (count - 1) * 64) | 0) + "," + ((j / (count - 1) * 255) | 0) + ")";
9186 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9187
9188 line = line + height;
9189
9190 // Dunkelgrasgrüntöne (85, 170, 0)
9191 /*
9192 canvas.fillStyle = "rgb("+ ((i/count*85)|0) +", "+ ((i/count*170)|0) +", 0)";
9193 canvas.fillRect(i * width, line, width-sep, height-sep);
9194
9195 canvas.fillStyle = "rgb("+ (85 + (j/(count-1)*170)|0) +", "+ (170 + ((j/(count-1)*85)|0)) +","+ ((j/(count-1)*255)|0) +")";
9196 canvas.fillRect(i * width + offset, line, width-sep, height-sep);
9197
9198 line = line + height;
9199 */
9200
9201 // Grüntöne (0,255,0)
9202 canvas.fillStyle = "rgb(0," + ((i / count * 255) | 0) + ", 0)";
9203 canvas.fillRect(i * width, line, width - sep, height - sep);
9204
9205 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + ", 255," + ((j / (count - 1) * 255) | 0) + ")";
9206 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9207
9208 line = line + height;
9209
9210 // Türkistöne (0,255,127)
9211 /*
9212 canvas.fillStyle = "rgb(0,"+ ((i/count*255)|0) +","+ ((i/count*127)|0) + ")";
9213 canvas.fillRect(i * width, line, width-sep, height-sep);
9214
9215 canvas.fillStyle = "rgb("+ ((j/(count-1)*255)|0) +", 255,"+ (127 + ((j/(count-1)*127)|0)) +")";
9216 canvas.fillRect(i * width + offset, line, width-sep, height-sep);
9217
9218 line = line + height;
9219 */
9220
9221 // Dunkel-Türkistöne (0,191,127)
9222 canvas.fillStyle = "rgb(0, " + ((i / count * 191) | 0) + "," + ((i / count * 127) | 0) + ")";
9223 canvas.fillRect(i * width, line, width - sep, height - sep);
9224
9225 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + "," + (191 + (j / (count - 1) * 64) | 0) + ", " + (127 + ((j / (count - 1) * 127) | 0)) + ")";
9226 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9227
9228 line = line + height;
9229
9230
9231 // Cyantöne (0,255,255)
9232 canvas.fillStyle = "rgb(0, " + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ")";
9233 canvas.fillRect(i * width, line, width - sep, height - sep);
9234
9235 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + ",255, 255)";
9236 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9237
9238 line = line + height;
9239
9240 // Hellblautöne (0,127,255)
9241 canvas.fillStyle = "rgb(0, " + ((i / count * 127) | 0) + "," + ((i / count * 255) | 0) + ")";
9242 canvas.fillRect(i * width, line, width - sep, height - sep);
9243
9244 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + "," + (127 + ((j / (count - 1) * 127) | 0)) + ", 255)";
9245 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9246
9247 line = line + height;
9248
9249 // Blautöne (0,0,255)
9250 canvas.fillStyle = "rgb(0, 0, " + ((i / count * 255) | 0) + ")";
9251 canvas.fillRect(i * width, line, width - sep, height - sep);
9252
9253 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + "," + ((j / (count - 1) * 255) | 0) + ", 255)";
9254 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9255
9256 line = line + height;
9257
9258 // Lilatöne (127,0,255)
9259 canvas.fillStyle = "rgb(" + ((i / count * 127) | 0) + ", 0, " + ((i / count * 255) | 0) + ")";
9260 canvas.fillRect(i * width, line, width - sep, height - sep);
9261
9262 canvas.fillStyle = "rgb(" + (127 + ((j / (count - 1) * 127) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ", 255)";
9263 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9264
9265 line = line + height;
9266
9267 // Grautöne
9268 /*
9269 canvas.fillStyle = "rgb("+ ((i/count*127)|0) +", "+ ((i/count*127)|0) +", "+ ((i/count*127)|0) +")";
9270 canvas.fillRect(i * width, line, width-sep, height-sep);
9271
9272 canvas.fillStyle = "rgb("+ (127 + ((j/(count-1)*127)|0)) +","+ (127 + ((j/(count-1)*127)|0)) +","+ (127 + ((j/(count-1)*127)|0)) +")";
9273 canvas.fillRect(i * width + offset, line, width-sep, height-sep);
9274
9275 line = line + height;
9276 */
9277
9278 }
9279
9280 line = line + height;
9281
9282 for (var i = 0; i <= count; i++) {
9283 // Grautöne
9284 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ")";
9285 canvas.fillRect(i * width + width * 2, line, width - sep, height - sep);
9286 }
9287
9288
9289 // http://www.javascripter.net/faq/rgbtohex.htm
9290 function rgbToHex(R, G, B) {
9291 return toHex(R) + toHex(G) + toHex(B)
9292 }
9293
9294 function toHex(n) {
9295 n = parseInt(n, 10);
9296 if (isNaN(n)) return "00";
9297 n = Math.max(0, Math.min(n, 255));
9298 return "0123456789ABCDEF".charAt((n - n % 16) / 16) + "0123456789ABCDEF".charAt(n % 16);
9299 }
9300
9301 $('#dio_color_picker a.cancel').click(function () {
9302 ColorPicker.close();
9303 });
9304
9305
9306 $('#dio_color_picker a.confirm').click(function () {
9307 // Custom-Event auslösen
9308 $(ColorPicker).trigger("onColorChanged", [$('#dio_color_picker .color_string')[0].value]);
9309 ColorPicker.close();
9310 });
9311
9312 $('#dio_color_picker a.color_table').click(function () {
9313 document.getElementById("c").click();
9314 });
9315
9316 $('#dio_color_picker a.color_table #c').change(function () {
9317 $('#dio_color_picker input.color_string')[0].value = this.value;
9318 $('#dio_color_picker input.color_string')[0].style.color = this.value;
9319 });
9320 }
9321 };
9322
9323 var UnitImages = {
9324 activate : function(){
9325 $('<style id="dio_unit_images">' +
9326
9327 '.unit_icon25x25 { background-image: url(https://diotools.de/images/game/units/unit_icons_25x25_2.91.png);} ' +
9328 '.unit_icon40x40 { background-image: url(https://diotools.de/images/game/units/unit_icons_40x40_2.91.png);} ' +
9329 '.unit_icon50x50 { background-image: url(https://diotools.de/images/game/units/unit_icons_50x50_2.91.png);} ' +
9330 '.unit_icon90x90 { background-image: url(https://diotools.de/images/game/units/unit_icons_90x90_2.91.png);} ' +
9331
9332 '.unit_icon228x165 { background-image: none; height:0px;} ' +
9333 '.unit_card .deco_statue { background-image: none !important;} ' +
9334 '.grepo_box_silver .border_l, .grepo_box_silver .border_r { background-image: none;} ' +
9335 '.box_corner .box_corner_tl, .grepo_box_silver .box_corner_tr { height:31px; } ' +
9336 '.grepo_box_silver .grepo_box_content { padding: 21px 10px 0px; } ' +
9337
9338 '</style>').appendTo('head');
9339 },
9340 deactivate : function(){
9341 $('#dio_unit_images').remove();
9342
9343 }
9344 };
9345
9346 /*******************************************************************************************************************************
9347 * Holiday Special
9348 *******************************************************************************************************************************/
9349
9350 var HolidaySpecial = {
9351 isHalloween : false, isXmas : false, isNewYear : false, isEaster : false,
9352
9353 activate : function(){
9354 var daystamp = 1000*60*60*24, today = new Date((new Date())%(daystamp*(365+1/4))), // without year
9355
9356 // Halloween -> 15 days
9357 halloween_start = daystamp * 297, // 25. Oktober
9358 halloween_end = daystamp * 321, // 8. November
9359 // Xmas -> 28 days
9360 xmas_start = daystamp * 334, // 1. Dezember
9361 xmas_end = daystamp * 361, // 28. Dezember
9362 // NewYear -> 7 days
9363 newYear_start = daystamp * 0, // 1. Januar
9364 newYear_end = daystamp * 7; // 7. Januar
9365
9366 HolidaySpecial.isHalloween = (today >= halloween_start) ? (today <= halloween_end) : false;
9367
9368 HolidaySpecial.isXmas = (today >= xmas_start) ? (today <= xmas_end) : false;
9369
9370 HolidaySpecial.isNewYear = (today >= newYear_start) ? (today <= newYear_end) : false;
9371
9372 if(HolidaySpecial.isXmas){ HolidaySpecial.XMas.add(); }
9373 if(HolidaySpecial.isNewYear){ HolidaySpecial.NewYear.add(); }
9374
9375 // Calculation Easter
9376
9377 // Jahreszahl
9378 var X = 2016;
9379
9380 // Säkularzahl
9381 var K = parseInt(X / 100, 10);
9382 // Mondparameter
9383 var A = X % 19;
9384
9385 // säkulare Mondschaltung
9386 var M = 15 + parseInt((3 * K + 3)/4, 10) - parseInt((8 * K + 13)/25, 10);
9387
9388 // säkulare Sonnenschaltung
9389 var S = 2 - parseInt((3 * K + 3)/4, 10);
9390
9391 // Erster Vollmond im Frühling
9392 var D = (19 * A + M) % 30;
9393
9394 // Kalendarische Korrekturgröße
9395 var R = parseInt((D + parseInt(A / 11, 10)) / 29, 10);
9396
9397 // Ostergrenze
9398 var OG = 21 + D - R;
9399
9400 // Erster Sonntag im März
9401 var SZ = 7 - ((2016 + parseInt(2016/4, 10) + S) % 7);
9402
9403 // Entfernung des Ostersonntags von der Ostergrenze
9404 var OE = 7 - ((OG - SZ) % 7);
9405
9406 // Ostersonntag als Märzdatum
9407 var OS = OG + OE;
9408
9409 // console.debug("DIO-TOOLS | Ostersonntag: " + OS);
9410
9411 },
9412 XMas : {
9413 add : function(){
9414 $('<a href="http://www.greensmilies.com/smilie-album/weihnachten-smilies/" target="_blank"><div id="dio_xmas"></div></a>').appendTo('#ui_box');
9415
9416 var dioXMAS = $('#dio_xmas');
9417
9418 dioXMAS.css({
9419 background: 'url("http://www.greensmilies.com/smile/smiley_emoticons_weihnachtsmann_nordpol.gif") no-repeat',
9420 height: '51px',
9421 width: '61px',
9422 position:'absolute',
9423 bottom:'10px',
9424 left:'60px',
9425 zIndex:'2000'
9426 });
9427 dioXMAS.tooltip("Ho Ho Ho, Merry Christmas!");
9428 }
9429 },
9430 NewYear : {
9431 add : function(){
9432 // TODO: Jahreszahl dynamisch setzen
9433 $('<a href="http://www.greensmilies.com/smilie-album/" target="_blank"><div id="dio_newYear">'+
9434 '<img src="http://www.greensmilies.com/smile/sign2_2.gif">'+
9435 '<img src="http://www.greensmilies.com/smile/sign2_0.gif">'+
9436 '<img src="http://www.greensmilies.com/smile/sign2_1.gif">'+
9437 '<img src="http://www.greensmilies.com/smile/sign2_7.gif">'+
9438 '</div></a>').appendTo('#ui_box');
9439
9440 var dioNewYear = $('#dio_newYear');
9441
9442 dioNewYear.css({
9443 position:'absolute',
9444 bottom:'10px',
9445 left:'70px',
9446 zIndex:'10'
9447 });
9448 dioNewYear.tooltip("Happy new year!");
9449 }
9450 }
9451 };
9452
9453}