· 6 years ago · Jul 18, 2019, 11: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 '.gods_spells_menu {top: 85px !important;}' +
2051 '</style>').appendTo('head');
2052
2053 // Town Icons
2054 $('<style id="dio_icons" type="text/css">.icon_small { position:relative; height:20px; width:25px; margin-left:-25px; }</style>').appendTo('head');
2055
2056 // Tutorial-Quest Container
2057 $('<style id="dio_quest_container" type="text/css"> #tutorial_quest_container { top: 130px } </style>').appendTo('head');
2058
2059 // Velerios
2060 $('<style id="dio_velerios" type="text/css"> #ph_trader_image { background-image: url(http://s14.directupload.net/images/140826/mh8k8nyw.jpg); } </style>').appendTo('head');
2061 // http://s7.directupload.net/images/140826/bgqlsdrf.jpg
2062
2063 // Specific player wishes
2064 if (PID == 1212083) {
2065 $('<style id="dio_wishes" type="text/css"> #world_end_info { display: none; } </style>').appendTo('head');
2066 }
2067 }
2068
2069 function loadFeatures() {
2070 if (typeof(ITowns) !== "undefined") {
2071
2072 autoTownTypes = {};
2073 manuTownTypes = DATA.townTypes;
2074 population = {};
2075
2076 sentUnitsArray = DATA.sentUnits;
2077 biriArray = DATA.biremes;
2078
2079 spellbox = DATA.spellbox;
2080 commandbox = DATA.commandbox;
2081 tradebox = DATA.tradebox;
2082
2083 wonder = DATA.worldWonder;
2084 wonderTypes = DATA.worldWonderTypes;
2085
2086 var DIO_USER = {'name': uw.Game.player_name, 'market': MID};
2087 saveValue("dio_user", JSON.stringify(DIO_USER));
2088
2089
2090 $.Observer(uw.GameEvents.game.load).subscribe('DIO_START', function (e, data) {
2091 a();
2092
2093 // English => default language
2094 if (!LANG[LID]) {
2095 LID = "en";
2096 }
2097
2098 if ((ch.length == 1) && exc && (sum == 28)) {
2099 // AJAX-EVENTS
2100 setTimeout(function () {
2101 ajaxObserver();
2102 }, 0);
2103
2104 addSettingsButton();
2105
2106 addFunctionToITowns();
2107
2108 if (DATA.options.tsk) {
2109 setTimeout(function () {
2110 minimizeDailyReward();
2111
2112 if(Game.market_id !== "de" && Game.market_id !== "zz") {
2113 Taskbar.activate();
2114 }
2115 }, 0);
2116 }
2117
2118 //addStatsButton();
2119
2120 fixUnitValues();
2121
2122 setTimeout(function () {
2123
2124 var waitCount = 0;
2125
2126 // No comment... it's Grepolis... i don't know... *rolleyes*
2127 function waitForGrepoLazyLoading() {
2128 if (typeof(ITowns.townGroups.getGroupsDIO()[-1]) !== "undefined" && typeof(ITowns.getTown(Game.townId).getBuildings) !== "undefined") {
2129
2130 try {
2131 // Funktion wird manchmal nicht ausgeführt:
2132 var units = ITowns.getTown(Game.townId).units();
2133
2134
2135 getAllUnits();
2136
2137 setInterval(function () {
2138 getAllUnits();
2139 }, 900000); // 15min
2140
2141 setInterval(function () {
2142 UnitCounter.count();
2143 }, 600000); // 10min
2144
2145 if (DATA.options.ava) {
2146 setTimeout(function () {
2147 AvailableUnits.activate();
2148 }, 0);
2149 }
2150 if (DATA.options.tic) {
2151 setTimeout(function () {
2152 TownIcons.activate();
2153 TownPopup.activate();
2154 }, 0);
2155 }
2156 if (DATA.options.tim) {
2157 setTimeout(function () {
2158 TownIcons.Map.activate();
2159 }, 0);
2160 }
2161 if (DATA.options.til) {
2162 setTimeout(function () {
2163 TownList.activate();
2164 }, 0);
2165 }
2166
2167 HiddenHighlightWindow.activate();
2168
2169
2170 } catch(e){
2171 if(waitCount < 12) {
2172 waitCount++;
2173
2174 console.warn("DIO-Tools | Fehler | getAllUnits | units() fehlerhaft ausgeführt?", e);
2175
2176 // Ausführung wiederholen
2177 setTimeout(function () {
2178 waitForGrepoLazyLoading();
2179 }, 5000); // 5s
2180 }
2181 else {
2182 errorHandling(e, "waitForGrepoLazyLoading2");
2183 }
2184 }
2185 }
2186 else {
2187 var e = { "stack": "getGroups() = " + typeof(ITowns.townGroups.getGroupsDIO()[-1]) + ", getBuildings() = " + typeof(ITowns.getTown(Game.townId).getBuildings) };
2188
2189 if(waitCount < 12) {
2190 waitCount++;
2191
2192 console.warn("DIO-Tools | Fehler | getAllUnits | " + e.stack);
2193
2194 // Ausführung wiederholen
2195 setTimeout(function () {
2196 waitForGrepoLazyLoading();
2197 }, 5000); // 5s
2198 }
2199 else {
2200
2201
2202 errorHandling(e, "waitForGrepoLazyLoading2");
2203 }
2204 }
2205 }
2206
2207 waitForGrepoLazyLoading();
2208
2209 }, 0);
2210
2211 if (DATA.options.pop) {
2212 setTimeout(function () {
2213 FavorPopup.activate();
2214 }, 0);
2215 }
2216 if (DATA.options.spl) {
2217 setTimeout(function () {
2218 Spellbox.activate();
2219 }, 0);
2220 }
2221
2222 imageSelectionProtection();
2223
2224 if (DATA.options.con) {
2225 setTimeout(function () {
2226 ContextMenu.activate();
2227 }, 0);
2228 }
2229
2230 if (DATA.options.act) {
2231 setTimeout(function () {
2232 ActivityBoxes.activate();
2233 }, 0);
2234 }
2235
2236 if (DATA.options.str) {
2237 setTimeout(function () {
2238 UnitStrength.Menu.activate();
2239 hideNavElements();
2240 }, 0);
2241 }
2242
2243 if (DATA.options.tra) {
2244 setTimeout(function () {
2245 TransportCapacity.activate();
2246 }, 0);
2247 }
2248
2249 if (DATA.options.com) {
2250 setTimeout(function () {
2251 UnitComparison.activate();
2252 }, 0);
2253 }
2254
2255 if (DATA.options.sml) {
2256 setTimeout(function () {
2257 SmileyBox.activate();
2258 }, 0);
2259 }
2260
2261 if (DATA.options.cha && (Game.market_id === "de" || Game.market_id === "zz")) {
2262 setTimeout(function () {
2263 Chat.activate();
2264 }, 0);
2265 }
2266
2267 if (DATA.options.scr) {
2268 setTimeout(function () {
2269 MouseWheelZoom.activate();
2270 }, 0);
2271 }
2272
2273 if (DATA.options.sim) {
2274 setTimeout(function () {
2275 Simulator.activate();
2276 }, 0);
2277 }
2278
2279 if (DATA.options.sen) {
2280 setTimeout(function () {
2281 SentUnits.activate();
2282 }, 0);
2283 }
2284
2285 if (DATA.options.wwc) {
2286 setTimeout(function () {
2287 WorldWonderCalculator.activate();
2288 }, 0);
2289 }
2290
2291 if(DATA.options.rec) {
2292 setTimeout(function () {
2293 RecruitingTrade.activate();
2294 }, 0);
2295 }
2296
2297 if(DATA.options.way) {
2298 setTimeout(function () {
2299 ShortDuration.activate();
2300 }, 0);
2301 }
2302
2303 if (PID === 84367 || PID === 104769 || PID === 1291505) {
2304 setTimeout(function() {
2305 PoliticalMap.activate();
2306
2307 //PoliticalMap.getAllianceColors();
2308
2309 //Statistics.activate();
2310 }, 0);
2311 }
2312
2313 setTimeout(function () {
2314 counter(uw.Timestamp.server());
2315 setInterval(function () {
2316 counter(uw.Timestamp.server());
2317 }, 21600000);
2318 }, 60000);
2319
2320 // Notifications
2321 setTimeout(function () {
2322 Notification.init();
2323 }, 0);
2324
2325 setTimeout(function(){ HolidaySpecial.activate(); }, 0);
2326
2327
2328 // Execute once to get the world wonder types and coordinates
2329 setTimeout(function () {
2330 if (!wonderTypes.great_pyramid_of_giza) {
2331 getWorldWonderTypes();
2332 }
2333 if (wonderTypes.great_pyramid_of_giza) {
2334 setTimeout(function () {
2335 if (!wonder.map.mausoleum_of_halicarnassus) {
2336 getWorldWonders();
2337 } else {
2338 if (DATA.options.wwi) {
2339 WorldWonderIcons.activate();
2340 }
2341 }
2342 }, 2000);
2343 }
2344 }, 3000);
2345
2346 // Execute once to get alliance ratio
2347 if (wonder.ratio[AID] == -1 || !$.isNumeric(wonder.ratio[AID])) {
2348 setTimeout(function () {
2349 getPointRatioFromAllianceProfile();
2350 }, 5000);
2351 }
2352 }
2353 time_b = uw.Timestamp.client();
2354 //console.log("Gebrauchte Zeit:" + (time_b - time_a));
2355 });
2356 } else {
2357 setTimeout(function () {
2358 loadFeatures();
2359 }, 100);
2360 }
2361 }
2362
2363 if (uw.location.pathname.indexOf("game") >= 0) {
2364 setStyle();
2365
2366 loadFeatures();
2367 }
2368
2369 /*******************************************************************************************************************************
2370 * HTTP-Requests
2371 * *****************************************************************************************************************************/
2372 function ajaxObserver() {
2373 $(document).ajaxComplete(function (e, xhr, opt) {
2374
2375 var url = opt.url.split("?"), action = "";
2376
2377 //console.debug("0: ", url[0]);
2378 //console.debug("1: ", url[1]);
2379
2380 if(typeof(url[1]) !== "undefined" && typeof(url[1].split(/&/)[1]) !== "undefined") {
2381
2382 action = url[0].substr(5) + "/" + url[1].split(/&/)[1].substr(7);
2383 }
2384
2385
2386 if (PID == 84367 || PID == 104769 || PID == 1577066) {
2387 console.log(action);
2388 //console.log((JSON.parse(xhr.responseText).json));
2389 }
2390 switch (action) {
2391 case "/frontend_bridge/fetch": // Daily Reward
2392 //$('.daily_login').find(".minimize").click();
2393 break;
2394 case "/player/index":
2395 settings();
2396 if (diosettings) {
2397 $('#dio_tools').click();
2398 diosettings = false;
2399 }
2400 break;
2401 // Ab Grepolis Version 2.114 ist der Ajax-Request: /frontend_bridge/execute
2402 case "/frontend_bridge/execute":
2403 case "/index/switch_town":
2404 if (DATA.options.str) {
2405 setTimeout(function () {
2406 UnitStrength.Menu.update();
2407 }, 0);
2408 }
2409 if (DATA.options.tra) {
2410 setTimeout(function () {
2411 TransportCapacity.update();
2412 }, 0);
2413 }
2414 if (DATA.options.bir) {
2415 //BiremeCounter.get();
2416 }
2417 if (DATA.options.tic) {
2418 setTimeout(function () {
2419 TownIcons.changeTownIcon();
2420 }, 0);
2421
2422 }
2423 break;
2424 case "/building_docks/index":
2425 if (DATA.options.bir) {
2426 //BiremeCounter.getDocks();
2427 }
2428 break;
2429 case "/building_place/units_beyond":
2430 if (DATA.options.bir) {
2431 //BiremeCounter.getAgora();
2432 }
2433 //addTransporterBackButtons();
2434 break;
2435 case "/building_place/simulator":
2436 if (DATA.options.sim) {
2437 Simulator.change();
2438 }
2439 break;
2440 case "/building_place/simulate":
2441 if (DATA.options.sim) {
2442 afterSimulation();
2443 }
2444 break;
2445
2446 case "/alliance_forum/forum":
2447 case "/message/new":
2448 case "/message/forward":
2449 case "/message/view":
2450 case "/player_memo/load_memo_content":
2451 if (DATA.options.sml) {
2452 SmileyBox.add(action);
2453 }
2454 if (DATA.options.bbc) {
2455 addForm(action);
2456 }
2457 break;
2458 case "/wonders/index":
2459 if (DATA.options.per) {
2460 WWTradeHandler();
2461 }
2462 if (DATA.options.wwc) {
2463 getResWW();
2464 }
2465 break;
2466 case "/wonders/send_resources":
2467 if (DATA.options.wwc) {
2468 getResWW();
2469 }
2470 break;
2471 case "/ranking/alliance":
2472 getPointRatioFromAllianceRanking();
2473 break;
2474 case "/ranking/wonder_alliance":
2475 getPointRatioFromAllianceRanking();
2476 if (DATA.options.wwr) {
2477 WorldWonderRanking.change(JSON.parse(xhr.responseText).plain.html);
2478 }
2479 if (DATA.options.wwi) {
2480 WorldWonderIcons.activate();
2481 }
2482 break;
2483 case "/alliance/members_show":
2484 getPointRatioFromAllianceMembers();
2485 break;
2486 case "/town_info/trading":
2487 addTradeMarks(15, 18, 15, "red");
2488 TownTabHandler(action.split("/")[2]);
2489 break;
2490 case "/town_overviews/trade_overview":
2491 addPercentTrade(1234, false); // TODO
2492 case "/farm_town_overviews/get_farm_towns_for_town":
2493 changeResColor();
2494 break;
2495 case "/command_info/conquest_info":
2496 if (DATA.options.str) {
2497 UnitStrength.Conquest.add();
2498 }
2499 break;
2500 case "/command_info/conquest_movements":
2501 case "/conquest_info/getinfo":
2502 if (DATA.options.cnt) {
2503 countMovements();
2504 }
2505 break;
2506 case "/building_barracks/index":
2507 case "/building_barracks/build":
2508 if (DATA.options.str) {
2509 UnitStrength.Barracks.add();
2510 }
2511 break;
2512 case "/town_info/attack":
2513 case "/town_info/support":
2514 //console.debug(JSON.parse(xhr.responseText));
2515 TownTabHandler(action.split("/")[2]);
2516
2517 break;
2518 case "/report/index":
2519 changeDropDownButton();
2520 loadFilter();
2521 saveFilter();
2522 //removeReports();
2523 break;
2524 case "/report/view":
2525 Statistics.LuckCounter.count();
2526 break;
2527 case "/message/default":
2528 case "/message/index":
2529 break;
2530 case "/town_info/go_to_town":
2531 /*
2532 //console.log(uw.Layout.wnd);
2533 var windo = uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).getID();
2534 //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX));
2535 uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).setPosition([100,400]);
2536 //console.log(windo);
2537 //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).getPosition());
2538 */
2539 break;
2540 }
2541 });
2542 }
2543
2544 function test() {
2545 //http://gpde.innogamescdn.com/images/game/temp/island.png
2546
2547 //console.log(uw.WMap);
2548 //console.log(uw.WMap.getSea(uw.WMap.getXCoord(), uw.WMap.getYCoord()));
2549
2550 //console.log(uw.GameControllers.LayoutToolbarActivitiesController().prototype.getActivityTypes());
2551 //console.log(uw.GameViews);
2552 //console.log(uw.GameViews.BarracksUnitDetails());
2553
2554 //console.log(uw.ITowns.getTown(uw.Game.townId).unitsOuter().sword);
2555 //console.log(uw.ITowns.getCurrentTown().unitsOuter().sword);
2556
2557 //console.log(uw.ITowns.getTown(uw.Game.townId).researches().attributes);
2558 //console.log(uw.ITowns.getTown(uw.Game.townId).hasConqueror());
2559 //console.log(uw.ITowns.getTown(uw.Game.townId).allUnits());
2560 //console.log(uw.ITowns.all_units.fragments[uw.Game.townId]._byId);
2561 //console.log("Zeus: " + uw.ITowns.player_gods.zeus_favor_delta_property.lastTriggeredVirtualPropertyValue);
2562 //console.log(uw.ITowns.player_gods.attributes);
2563
2564 //console.log(uw.ITowns.getTown('5813').createTownLink());
2565 //console.log(uw.ITowns.getTown(5813).unitsOuterTown);
2566
2567 //console.log(uw.ITowns.getTown(uw.Game.townId).getLinkFragment());
2568
2569 //console.log(uw.ITowns.getTown(uw.Game.townId).allGodsFavors());
2570
2571 console.debug("STADTGRUPPEN", Game.constants.ui.town_group);
2572 }
2573
2574 /*******************************************************************************************************************************
2575 * Helping functions
2576 * ----------------------------------------------------------------------------------------------------------------------------
2577 * | ● fixUnitValues: Get unit values and overwrite some wrong values
2578 * | ● getMaxZIndex: Get the highest z-index of "ui-dialog"-class elements
2579 * ----------------------------------------------------------------------------------------------------------------------------
2580 *******************************************************************************************************************************/
2581
2582 // Fix buggy grepolis values
2583 function fixUnitValues() {
2584 //uw.GameData.units.small_transporter.attack = uw.GameData.units.big_transporter.attack = uw.GameData.units.demolition_ship.attack = uw.GameData.units.militia.attack = 0;
2585 //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;
2586 uw.GameData.units.militia.resources = {wood: 0, stone: 0, iron: 0};
2587 }
2588
2589 function getMaxZIndex() {
2590 var maxZ = Math.max.apply(null, $.map($("div[class^='ui-dialog']"), function (e, n) {
2591 if ($(e).css('position') == 'absolute') {
2592 return parseInt($(e).css('z-index'), 10) || 1000;
2593 }
2594 }));
2595 return (maxZ !== -Infinity) ? maxZ + 1 : 1000;
2596 }
2597
2598 function getBrowser() {
2599 var ua = navigator.userAgent,
2600 tem,
2601 M = ua.match(/(opera|maxthon|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
2602 if (/trident/i.test(M[1])) {
2603 tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
2604 M[1] = 'IE';
2605 M[2] = tem[1] || '';
2606 }
2607 if (M[1] === 'Chrome') {
2608 tem = ua.match(/\bOPR\/(\d+)/);
2609 if (tem !== null) {
2610 M[1] = 'Opera';
2611 M[2] = tem[1];
2612 }
2613 }
2614 M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
2615 if ((tem = ua.match(/version\/(\d+)/i)) !== null) M.splice(1, 1, tem[1]);
2616
2617 return M.join(' ');
2618 }
2619
2620 // Error Handling / Remote diagnosis / Automatic bug reports
2621 function errorHandling(e, fn) {
2622 if (PID == 84367 || PID == 104769 || PID === 1291505) {
2623 HumanMessage.error("DIO-TOOLS(" + version + ")-ERROR: " + e.message);
2624 console.log("DIO-TOOLS | Error-Stack | ", e.stack);
2625 } else {
2626 if (!DATA.error[version]) {
2627 DATA.error[version] = {};
2628 }
2629
2630 if (DATA.options.err && !DATA.error[version][fn]) {
2631 $.ajax({
2632 type: "POST",
2633 url: "https://diotools.de/game/error.php",
2634 data: {error: e.stack.replace(/'/g, '"'), "function": fn, browser: getBrowser(), version: version},
2635 success: function (text) {
2636 DATA.error[version][fn] = true;
2637 saveValue("error", JSON.stringify(DATA.error));
2638 }
2639 });
2640 }
2641 }
2642 }
2643
2644 function createWindowType(name, title, width, height, minimizable, position) {
2645 $('<style id="dio_window">' +
2646 '.dio_title_img { height:18px; float:left; margin-right:3px; } ' +
2647 '.dio_title { margin:1px 6px 13px 23px; color:rgb(126,223,126); } ' +
2648 '</style>').appendTo('head');
2649
2650 // Create Window Type
2651 function WndHandler(wndhandle) {
2652 this.wnd = wndhandle;
2653 }
2654
2655 Function.prototype.inherits.call(WndHandler, WndHandlerDefault);
2656 WndHandler.prototype.getDefaultWindowOptions = function () {
2657 return {
2658 position: position,
2659 width: width,
2660 height: height,
2661 minimizable: minimizable,
2662 title: "<img class='dio_title_img' src='http://666kb.com/i/cifvfsu3e2sdiipn0.gif' /><div class='dio_title'>" + title + "</div>"
2663 };
2664 };
2665 GPWindowMgr.addWndType(name, "", WndHandler, 1);
2666 }
2667
2668 // Notification
2669 var Notification = {
2670 init: function () {
2671 // NotificationType
2672 NotificationType.DIO_TOOLS = "diotools";
2673
2674 // Style
2675 $('<style id="dio_notification" type="text/css">' +
2676 '#notification_area .diotools .icon { background: url(http://666kb.com/i/cifvfsu3e2sdiipn0.gif) 4px 7px no-repeat !important;} ' +
2677 '#notification_area .diotools { cursor:pointer; } ' +
2678 '</style>').appendTo('head');
2679
2680 var notif = DATA.notification;
2681 if (notif <= 7) {
2682 //Notification.create(1, 'Swap context menu buttons ("Select town" and "City overview")');
2683 //Notification.create(2, 'Town overview (old window mode)');
2684 //Notification.create(3, 'Mouse wheel: You can change the views with the mouse wheel');
2685 //Notification.create(4, 'Town icons on the strategic map');
2686 //Notification.create(5, 'Percentual unit population in the town list');
2687 //Notification.create(6, 'New world wonder ranking');
2688 //Notification.create(7, 'World wonder icons on the strategic map');
2689
2690 // Click Event
2691 $('.diotools .icon').click(function () {
2692 openSettings();
2693 $(this).parent().find(".close").click();
2694 });
2695
2696 saveValue('notif', '8');
2697 }
2698 },
2699 create: function (nid, feature) {
2700 var Notification = new NotificationHandler();
2701 Notification.notify($('#notification_area>.notification').length + 1, uw.NotificationType.DIO_TOOLS,
2702 "<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>");
2703 }
2704 };
2705
2706 /*******************************************************************************************************************************
2707 * Mousewheel Zoom
2708 *******************************************************************************************************************************/
2709
2710 var MouseWheelZoom = {
2711 // Scroll trough the views
2712 activate: function () {
2713 $('#main_area, #dio_political_map, .viewport, .sjs-city-overview-viewport').bind('mousewheel', function (e) {
2714 e.stopPropagation();
2715 var current = $('.bull_eye_buttons .checked').get(0).getAttribute("name"), delta = 0, scroll, sub_scroll = 6;
2716
2717 switch (current) {
2718 case 'political_map':
2719 scroll = 4;
2720 break;
2721 case 'strategic_map':
2722 scroll = 3;
2723 break;
2724 case 'island_view':
2725 scroll = 2;
2726 break;
2727 case 'city_overview':
2728 scroll = 1;
2729 break;
2730 }
2731 delta = -e.originalEvent.detail || e.originalEvent.wheelDelta; // Firefox || Chrome & Opera
2732
2733 //console.debug("cursor_pos", e.pageX, e.pageY);
2734
2735 if (scroll !== 4) {
2736 if (delta < 0) {
2737 scroll += 1;
2738 } else {
2739 scroll -= 1;
2740 }
2741 } else {
2742 // Zoomstufen bei der Politischen Karte
2743 sub_scroll = $('.zoom_select').get(0).selectedIndex;
2744
2745 if (delta < 0) {
2746 sub_scroll -= 1;
2747 } else {
2748 sub_scroll += 1;
2749 }
2750 if (sub_scroll === -1) {
2751 sub_scroll = 0;
2752 }
2753 if (sub_scroll === 7) {
2754 scroll = 3;
2755 }
2756 }
2757 switch (scroll) {
2758 case 4:
2759 if (!$('.bull_eye_buttons .btn_political_map').hasClass("checked")) {
2760 $('.bull_eye_buttons .btn_political_map').click();
2761 }
2762
2763 // onChange wird aufgerufen, wenn sich die Selektierung ändert
2764 //$('.zoom_select option').eq(sub_scroll).prop('selected', true);
2765 $('.zoom_select').get(0)[sub_scroll].selected = true;
2766 //$('.zoom_select').get(0).change();
2767 //$('.zoom_select').get(0).val(sub_scroll);
2768
2769
2770 PoliticalMap.zoomToCenter();
2771 //PoliticalMap.zoomToCenterToCursorPosition($('.zoom_select').get(0)[sub_scroll].value, [e.pageX, e.pageY]);
2772
2773 break;
2774 case 3:
2775 $('.bull_eye_buttons .strategic_map').click();
2776 $('#popup_div').css('display', 'none');
2777 break;
2778 case 2:
2779 $('.bull_eye_buttons .island_view').click();
2780 TownPopup.remove();
2781 break;
2782 case 1:
2783 $('.bull_eye_buttons .city_overview').click();
2784 break;
2785 }
2786
2787 // Prevent page from scrolling
2788 return false;
2789 });
2790 },
2791 deactivate: function () {
2792 $('#main_area, .ui_city_overview').unbind('mousewheel');
2793 }
2794 };
2795
2796
2797 /*******************************************************************************************************************************
2798 * Statistics
2799 * ----------------------------------------------------------------------------------------------------------------------------
2800 * | ● Expansion of towns?
2801 * | ● Occupancy of the farms?
2802 * | ● Mouseclick-Counter?
2803 * | ● Resource distribution (%)?
2804 * | ● Building level counter ?
2805 * ----------------------------------------------------------------------------------------------------------------------------
2806 *******************************************************************************************************************************/
2807 //$('<script src="https://github.com/mbostock/d3/blob/master/d3.js"></script>').appendTo("head");
2808 // http://mbostock.github.com/d3/d3.v2.js
2809 var Statistics = {
2810 activate: function () {
2811 Statistics.addButton();
2812
2813 $('<style id="dio_statistic">' +
2814 'path { stroke: steelblue; stroke-width: 1; fill: none; } ' +
2815 '.axis { shape-rendering: crispEdges; } ' +
2816 '.x.axis line { stroke: lightgrey; } ' +
2817 '.x.axis .minor { stroke-opacity: .5; } ' +
2818 '.x.axis path { display: none; } ' +
2819 '.y.axis line, .y.axis path { fill: none; stroke: #000; } ' +
2820 '</style>').appendTo('head');
2821
2822 Statistics.ClickCounter.activate();
2823
2824 // Create Window Type
2825 createWindowType("DIO_STATISTICS", "Statistics", 300, 250, true, ["center", "center", 100, 100]);
2826 },
2827 deactivate: function () {
2828 $('#dio_statistic_button').remove();
2829 $('#dio_statistic').remove();
2830 Statistics.ClickCounter.deactivate();
2831 },
2832 addButton: function () {
2833 $('<div id="dio_statistic_button" class="circle_button"><div class="ico_statistics js-caption"></div></div>').appendTo(".gods_area");
2834
2835 // Style
2836 $('<style id="dio_statistic_style">' +
2837 '#dio_statistic_button { top:56px; left:-4px; z-index:10; position:absolute; } ' +
2838
2839 '#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%; } ' +
2840 // http://s14.directupload.net/images/140408/k4wikrlq.png // http://s7.directupload.net/images/140408/ahfr8227.png
2841 '#dio_statistic_button .ico_statistics.checked { margin-top:8px; } ' +
2842 '</style>').appendTo('head');
2843
2844 // Tooltip
2845 $('#dio_statistic_button').tooltip(getText("labels", "uni")); // TODO
2846
2847 // Events
2848 $('#dio_statistic_button').on('mousedown', function () {
2849 $('#dio_statistic_button, .ico_statistics').addClass("checked");
2850 }).on('mouseup', function () {
2851 $('#dio_statistic_button, .ico_statistics').removeClass("checked");
2852 });
2853
2854 $('#dio_statistic_button').click(function () {
2855 if (!Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_STATISTICS)) {
2856 Statistics.openWindow();
2857 $('#dio_statistic_button, .ico_statistics').addClass("checked");
2858 } else {
2859 Statistics.closeWindow();
2860 $('#dio_statistic_button, .ico_statistics').removeClass("checked");
2861 }
2862 });
2863 },
2864 openWindow: function () {
2865 var content =
2866 '<div id="dio_mouseclicks" style="margin-bottom:5px; font-style:italic;">' +
2867 '<span style="text-decoration:underline;">Insgesamt:</span> <span></span>' +
2868 '<span style="float:right;"></span><span style="text-decoration:underline;float:right;">Heute:</span> ' +
2869 '</div><canvas id="dio_graph" width="290" height="150" style="margin-top:15px;"></canvas>';
2870
2871 Layout.wnd.Create(GPWindowMgr.TYPE_DIO_STATISTICS).setContent(content);
2872
2873 Statistics.ClickCounter.onOpenWindow();
2874
2875 // Draw diagram
2876 var graph, xPadding = 35, yPadding = 25;
2877
2878 var data = {values: [{X: "Jan", Y: 0}]};
2879
2880 //console.log(DATA.clickCount);
2881 for (var o in DATA.clickCount) {
2882 data.values.push({X: "opp", Y: DATA.clickCount[o]});
2883 }
2884
2885 function getMaxY() {
2886 var max = 0;
2887 for (var i = 0; i < data.values.length; i++) {
2888 if (data.values[i].Y > max) {
2889 max = data.values[i].Y;
2890 }
2891 }
2892 max += 10 - max % 10;
2893 return max + 10;
2894 }
2895
2896 function getXPixel(val) {
2897 return ((graph.width() - xPadding) / data.values.length) * val + (xPadding + 10);
2898 }
2899
2900 function getYPixel(val) {
2901 return graph.height() - (((graph.height() - yPadding) / getMaxY()) * val) - yPadding;
2902 }
2903
2904 graph = $('#dio_graph');
2905 var c = graph[0].getContext('2d');
2906
2907 c.lineWidth = 2;
2908 c.strokeStyle = '#333';
2909 c.font = 'italic 8pt sans-serif';
2910 c.textAlign = "center";
2911
2912 // Axis
2913 c.beginPath();
2914 c.moveTo(xPadding, 0);
2915 c.lineTo(xPadding, graph.height() - yPadding);
2916 c.lineTo(graph.width(), graph.height() - yPadding);
2917 c.stroke();
2918
2919 // X-Axis caption
2920 for (var x = 0; x < data.values.length; x++) {
2921 c.fillText(data.values[x].X, getXPixel(x), graph.height() - yPadding + 20);
2922 }
2923
2924 // Y-Axis caption
2925 c.textAlign = "right";
2926 c.textBaseline = "middle";
2927
2928 var maxY = getMaxY(), maxYscala = Math.ceil(maxY / 1000) * 1000;
2929 //console.log(maxY);
2930 for (var y = 0; y < maxY; y += maxYscala / 10) {
2931 c.fillText(y, xPadding - 10, getYPixel(y));
2932 }
2933
2934 // Graph
2935 c.strokeStyle = 'rgb(0,150,0)';
2936 c.beginPath();
2937 c.moveTo(getXPixel(0), getYPixel(data.values[0].Y));
2938
2939 for (var i = 1; i < data.values.length; i++) {
2940 c.lineTo(getXPixel(i), getYPixel(data.values[i].Y));
2941 }
2942 c.stroke();
2943
2944 // Points
2945 c.fillStyle = '#333';
2946
2947 for (var p = 0; p < data.values.length; p++) {
2948 c.beginPath();
2949 c.arc(getXPixel(p), getYPixel(data.values[p].Y), 2, 0, Math.PI * 2, true);
2950 c.fill();
2951 }
2952 },
2953 closeWindow: function () {
2954 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_STATISTICS).close();
2955 },
2956
2957 ClickCounter: {
2958 today: "00000000",
2959 activate: function () {
2960 Statistics.ClickCounter.updateDate();
2961
2962 $(document).on("mousedown", function () {
2963 DATA.clickCount[Statistics.ClickCounter.today]++;
2964 });
2965
2966 window.onbeforeunload = function () {
2967 Statistics.ClickCounter.save();
2968 };
2969
2970 // TODO: Update date
2971 setTimeout(function () {
2972 Statistics.ClickCounter.updateDate();
2973 }, 0);
2974 },
2975 deactivate: function () {
2976 $(document).off("mousedown");
2977 },
2978 save: function () {
2979 saveValue(WID + "_click_count", JSON.stringify(DATA.clickCount));
2980 },
2981 updateDate: function () {
2982 var today = new Date((window.Timestamp.server() + 7200) * 1000);
2983
2984 Statistics.ClickCounter.today = today.getUTCFullYear() + ((today.getUTCMonth() + 1) < 10 ? "0" : "") + (today.getUTCMonth() + 1) + (today.getUTCDate() < 10 ? "0" : "") + today.getUTCDate();
2985
2986 DATA.clickCount[Statistics.ClickCounter.today] = DATA.clickCount[Statistics.ClickCounter.today] || 0;
2987 },
2988 onOpenWindow: function () {
2989 $('#dio_mouseclicks span:eq(2)').get(0).innerHTML = DATA.clickCount[Statistics.ClickCounter.today];
2990 $(document).off("mousedown");
2991 $(document).on("mousedown", function () {
2992 if ($('#dio_mouseclicks').get(0)) {
2993 $('#dio_mouseclicks span:eq(2)').get(0).innerHTML = ++DATA.clickCount[Statistics.ClickCounter.today];
2994 } else {
2995 DATA.clickCount[Statistics.ClickCounter.today]++;
2996 $(document).off("mousedown");
2997 $(document).on("mousedown", function () {
2998 DATA.clickCount[Statistics.ClickCounter.today]++;
2999 });
3000 }
3001 });
3002 }
3003 },
3004 LuckCounter: {
3005 luckArray: {},
3006 count: function () {
3007 if ($('.fight_bonus.luck').get(0)) {
3008 var report_id = $('#report_report_header .game_arrow_delete').attr("onclick").split(",")[1].split(")")[0].trim(),
3009 luck = parseInt($('.fight_bonus.luck').get(0).innerHTML.split(":")[1].split("%")[0].trim(), 10);
3010
3011 Statistics.LuckCounter.luckArray[report_id] = luck;
3012
3013 //console.log(Statistics.LuckCounter.calcAverage());
3014 }
3015 },
3016 calcAverage: function () {
3017 var sum = 0, count = 0;
3018 for (var report_id in Statistics.LuckCounter.luckArray) {
3019 if (Statistics.LuckCounter.luckArray.hasOwnProperty(report_id)) {
3020 sum += parseInt(Statistics.LuckCounter.luckArray[report_id], 10);
3021 count++;
3022 }
3023 }
3024 return (parseFloat(sum) / parseFloat(count));
3025 }
3026 }
3027 };
3028
3029 /*******************************************************************************************************************************
3030 * Body Handler
3031 * ----------------------------------------------------------------------------------------------------------------------------
3032 * | ● Town icon
3033 * | ● Town list: Adds town type to the town list
3034 * | ● Swap Context Icons
3035 * | ● City overview
3036 * ----------------------------------------------------------------------------------------------------------------------------
3037 *******************************************************************************************************************************/
3038
3039 function imageSelectionProtection() {
3040 $('<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');
3041 }
3042
3043 var worldWonderIcon = {
3044 colossus_of_rhodes: "url(https://gpall.innogamescdn.com/images/game/map/wonder_colossus_of_rhodes.png) 38px -1px;",
3045 great_pyramid_of_giza: "url(https://gpall.innogamescdn.com/images/game/map/wonder_great_pyramid_of_giza.png) 34px -6px;",
3046 hanging_gardens_of_babylon: "url(https://gpall.innogamescdn.com/images/game/map/wonder_hanging_gardens_of_babylon.png) 34px -5px;",
3047 lighthouse_of_alexandria: "url(https://gpall.innogamescdn.com/images/game/map/wonder_lighthouse_of_alexandria.png) 37px -1px;",
3048 mausoleum_of_halicarnassus: "url(https://gpall.innogamescdn.com/images/game/map/wonder_mausoleum_of_halicarnassus.png) 37px -4px;",
3049 statue_of_zeus_at_olympia: "url(https://gpall.innogamescdn.com/images/game/map/wonder_statue_of_zeus_at_olympia.png) 36px -3px;",
3050 temple_of_artemis_at_ephesus: "url(https://gpall.innogamescdn.com/images/game/map/wonder_temple_of_artemis_at_ephesus.png) 34px -5px;"
3051 };
3052
3053 var WorldWonderIcons = {
3054 activate: function () {
3055 try {
3056 if (!$('#dio_wondericons').get(0)) {
3057 var color = "orange";
3058
3059 // style for world wonder icons
3060 var style_str = "<style id='dio_wondericons' type='text/css'>";
3061 for (var ww_type in wonder.map) {
3062 if (wonder.map.hasOwnProperty(ww_type)) {
3063 for (var ww in wonder.map[ww_type]) {
3064 if (wonder.map[ww_type].hasOwnProperty(ww)) {
3065 /*
3066 if(wonder.map[ww_type][ww] !== AID){
3067 color = "rgb(192, 109, 54)";
3068 } else {
3069 color = "orange";
3070 }
3071 */
3072 style_str += "#mini_i" + ww + ":before {" +
3073 "content: '';" +
3074 "background:" + color + " " + worldWonderIcon[ww_type] +
3075 "background-size: auto 97%;" +
3076 "padding: 8px 16px;" +
3077 "top: 50px;" +
3078 "position: relative;" +
3079 "border-radius: 40px;" +
3080 "z-index: 200;" +
3081 "cursor: pointer;" +
3082 "box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5);" +
3083 "border: 2px solid green; } " +
3084 "#mini_i" + ww + ":hover:before { z-index: 201; " +
3085 "filter: url(#Brightness12);" +
3086 "-webkit-filter: brightness(1.2); } ";
3087 }
3088 }
3089 }
3090 }
3091 $(style_str + "</style>").appendTo('head');
3092
3093 // Context menu on mouseclick
3094 $('#minimap_islands_layer').on('click', '.m_island', function (e) {
3095 var ww_coords = this.id.split("i")[3].split("_");
3096 uw.Layout.contextMenu(e, 'wonder', {ix: ww_coords[0], iy: ww_coords[1]});
3097 });
3098
3099
3100 }
3101 } catch (error) {
3102 errorHandling(error, "setWonderIconsOnMap");
3103 }
3104 },
3105 deactivate: function () {
3106 $('#dio_wondericons').remove();
3107 }
3108 };
3109
3110 var TownIcons = {
3111 types: {
3112 // Automatic Icons
3113 lo: 0,
3114 ld: 3,
3115 so: 6,
3116 sd: 7,
3117 fo: 10,
3118 fd: 9,
3119 bu: 14, /* Building */
3120 po: 22,
3121 no: 12,
3122
3123 // Manual Icons
3124 fa: 20, /* Favor */
3125 re: 15, /* Resources */
3126 di: 2, /* Distance */
3127 sh: 1, /* Pierce */
3128 lu: 13, /* ?? */
3129 dp: 11, /* Diplomacy */
3130 ha: 15, /* ? */
3131 si: 18, /* Silber */
3132 ra: 17,
3133 ch: 19, /* Research */
3134 ti: 23, /* Time */
3135 un: 5,
3136 wd: 16, /* Wood */
3137 wo: 24, /* World */
3138 bo: 13, /* Booty */
3139 gr: 21, /* Lorbeer */
3140 st: 17, /* Stone */
3141 is: 26, /* ?? */
3142 he: 4, /* Helmet */
3143 ko: 8 /* Kolo */
3144
3145 },
3146 deactivate: function () {
3147 $('#town_icon').remove();
3148 $('#dio_townicons_field').remove();
3149
3150 TownPopup.deactivate();
3151 },
3152 activate: function () {
3153 try {
3154 $('<div id="town_icon"><div class="town_icon_bg"><div class="icon_big townicon_' +
3155 (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no") + " auto")) + '"></div></div></div>').appendTo('.town_name_area');
3156
3157 // Town Icon Style
3158 $('#town_icon .icon_big').css({
3159 backgroundPosition: TownIcons.types[(manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")))] * -25 + 'px 0px'
3160 });
3161 //console.debug(dio_sprite);
3162 $('<style id="dio_townicons_field" type="text/css">' +
3163 '#town_icon { background:url(' + dio_sprite + ') 0 -125px no-repeat; position:absolute; width:69px; height:61px; left:-47px; top:0px; z-index: 10; } ' +
3164 '#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; } ' +
3165 '#town_icon .town_icon_bg:hover { filter:url(#Brightness11); -webkit-filter:brightness(1.1); box-shadow: 0px 0px 15px rgb(1, 197, 33); } ' +
3166 '#town_icon .icon_big { position:absolute; left:9px; top:9px; height:25px; width:25px; } ' +
3167
3168 '#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;' +
3169 'background:url(https://gpall.innogamescdn.com/images/game/popup/middle_middle.png); } ' +
3170 '#town_icon .item-list { max-height:400px; max-width:200px; align:right; overflow-x:hidden; } ' +
3171
3172 '#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;} ' +
3173 '#town_icon .option_s:hover { border: 2px solid rgb(59, 121, 81) !important;-webkit-filter: brightness(1.3); } ' +
3174 '#town_icon .sel { border: 2px solid rgb(202, 176, 109); } ' +
3175 '#town_icon hr { width:145px; margin:0px 0px 7px 0px; position:relative; top:3px; border:0px; border-top:2px dotted #000; float:left} ' +
3176 '#town_icon .auto_s { width:136px; height:16px; float:left} ' +
3177
3178 // Quickbar modification
3179 '.ui_quickbar .left, .ui_quickbar .right { width:46%; } ' +
3180
3181 // because of Kapsonfires Script and Beta Worlds bug report bar:
3182 '.town_name_area { z-index:11; left:52%; } ' +
3183 '.town_name_area .left { z-index:20; left:-39px; } ' +
3184 '</style>').appendTo('head');
3185
3186
3187 var icoArray = ['ld', 'lo', 'sh', 'di', 'un',
3188 'sd', 'so', 'ko', 'ti', 'gr',
3189 'fd', 'fo', 'dp', 'no', 'po',
3190 're', 'wd', 'st', 'si', 'bu',
3191 'he', 'ch', 'bo', 'fa', 'wo'];
3192
3193 // Fill select box with town icons
3194 $('<div class="select_town_icon dropdown-list default active"><div class="item-list"></div></div>').appendTo("#town_icon");
3195 for (var i in icoArray) {
3196 if (icoArray.hasOwnProperty(i)) {
3197 $('.select_town_icon .item-list').append('<div class="option_s icon_small townicon_' + icoArray[i] + '" name="' + icoArray[i] + '"></div>');
3198 }
3199 }
3200 $('<hr><div class="option_s auto_s" name="auto"><b>Auto</b></div>').appendTo('.select_town_icon .item-list');
3201
3202 $('#town_icon .option_s').click(function () {
3203 $("#town_icon .sel").removeClass("sel");
3204 $(this).addClass("sel");
3205
3206 if ($(this).attr("name") === "auto") {
3207 delete manuTownTypes[uw.Game.townId];
3208 } else {
3209 manuTownTypes[uw.Game.townId] = $(this).attr("name");
3210 }
3211 TownIcons.changeTownIcon();
3212
3213 // Update town icons on the map
3214 TownIcons.Map.activate(); //setOnMap();
3215
3216 saveValue(WID + "_townTypes", JSON.stringify(manuTownTypes));
3217 });
3218
3219 // Show & hide drop menus on click
3220 $('#town_icon .town_icon_bg').click(function () {
3221 var el = $('#town_icon .select_town_icon').get(0);
3222 if (el.style.display === "none") {
3223 el.style.display = "block";
3224 } else {
3225 el.style.display = "none";
3226 }
3227 });
3228
3229 $('#town_icon .select_town_icon [name="' + (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" : "" )) + '"]').addClass("sel");
3230
3231 } catch (error) {
3232 errorHandling(error, "addTownIcon");
3233 }
3234 },
3235 changeTownIcon: function () {
3236 var townType = (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")));
3237 $('#town_icon .icon_big').removeClass().addClass('icon_big townicon_' + townType + " auto");
3238 $('#town_icon .sel').removeClass("sel");
3239 $('#town_icon .select_town_icon [name="' + (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" : "" )) + '"]').addClass("sel");
3240
3241 $('#town_icon .icon_big').css({
3242 backgroundPosition: TownIcons.types[townType] * -25 + 'px 0px'
3243 });
3244
3245 $('#town_icon .select_town_icon').get(0).style.display = "none";
3246 },
3247 Map: {
3248 // TODO: activate aufspliten in activate und add
3249 activate: function () {
3250 try {
3251 // if town icon changed
3252 if ($('#dio_townicons_map').get(0)) {
3253 $('#dio_townicons_map').remove();
3254 }
3255
3256 // Style for own towns (town icons)
3257 var start = (new Date()).getTime(), end, style_str = "<style id='dio_townicons_map' type='text/css'>";
3258 for (var e in autoTownTypes) {
3259 if (autoTownTypes.hasOwnProperty(e)) {
3260 style_str += "#mini_t" + e + ", #town_flag_"+ e + " .flagpole {"+
3261 "background: rgb(255, 187, 0) url(" + dio_sprite + ") " + (TownIcons.types[(manuTownTypes[e] || autoTownTypes[e])] * -25) + "px -27px repeat !important; } ";
3262 }
3263 }
3264
3265 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); } ";
3266
3267 // Mouseover Effect
3268 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; } ";
3269
3270
3271 // Context menu on mouse click
3272 style_str += "#minimap_islands_layer .m_town { z-index: 99; cursor: pointer; } ";
3273
3274 $('#minimap_islands_layer').off('click', '.m_town');
3275 $('#minimap_islands_layer').on('click', '.m_town', function (z) {
3276 var id = parseInt(this.id.substring(6), 10);
3277
3278 // Town names of foreign towns are unknown
3279 if(typeof(uw.ITowns.getTown(id)) !== "undefined") {
3280 Layout.contextMenu(z, 'determine', {"id": id, "name": uw.ITowns.getTown(id).name});
3281 }
3282 else {
3283 // No town name in the title of the window
3284 Layout.contextMenu(z, 'determine', {"id": id });
3285 }
3286
3287 // Prevent parent world wonder event
3288 z.stopPropagation();
3289 });
3290
3291 $('#minimap_islands_layer').off("mousedown");
3292 $('#minimap_islands_layer').on("mousedown", function(){
3293
3294 if(typeof($('#context_menu').get(0)) !== "undefined"){
3295 $('#context_menu').get(0).remove();
3296 }
3297 });
3298
3299
3300 // Town Popup for own towns
3301 style_str += "#dio_town_popup .count { position: absolute; bottom: 1px; right: 1px; font-size: 10px; } ";
3302
3303 // Town Popups on Strategic map
3304 $('#minimap_islands_layer').off('mouseout', '.m_town');
3305 $('#minimap_islands_layer').on('mouseout', '.m_town', function () {
3306 TownPopup.remove();
3307 });
3308 $('#minimap_islands_layer').off('mouseover', '.m_town');
3309 $('#minimap_islands_layer').on('mouseover', '.m_town', function () {
3310 TownPopup.add(this);
3311 });
3312
3313 // Town Popups on island view
3314 $('#map_towns').off('mouseout', '.own_town .flagpole');
3315 $('#map_towns').on('mouseout', '.own_town .flagpole', function () {
3316 TownPopup.remove();
3317 });
3318 $('#map_towns').off('mouseover', '.own_town .flagpole');
3319 $('#map_towns').on('mouseover', '.own_town .flagpole', function () {
3320 TownPopup.add(this);
3321 });
3322
3323
3324 // Style for foreign cities (shadow)
3325 style_str += "#minimap_islands_layer .m_town { text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.7); } ";
3326
3327 // Style for night mode
3328 style_str += "#minimap_canvas.expanded.night, #map.night .flagpole { filter: brightness(0.7); -webkit-filter: brightness(0.7); } ";
3329 style_str += "#minimap_click_layer { display:none; }";
3330
3331 style_str += "</style>";
3332 $(style_str).appendTo('head');
3333
3334
3335 } catch (error) {
3336 errorHandling(error, "TownIcons.Map.activate");
3337 }
3338 },
3339 deactivate: function () {
3340 $('#dio_townicons_map').remove();
3341
3342 // Events entfernen
3343 $('#minimap_islands_layer').off('click', '.m_town');
3344 $('#minimap_islands_layer').off("mousedown");
3345
3346 $('#minimap_islands_layer').off('mouseout', '.m_town');
3347 $('#minimap_islands_layer').off('mouseover', '.m_town');
3348 }
3349 }
3350 };
3351
3352 var TownPopup = {
3353 activate : function(){
3354
3355 $('<style id="dio_town_popup_style" type="text/css">' +
3356 '#dio_town_popup { position:absolute; z-index:99;max-width: 173px;} ' +
3357
3358 '#dio_town_popup .title { margin:5px;font-weight: bold; } ' +
3359
3360 '#dio_town_popup .dio_branding { position:absolute; right:12px; top:8px; height: 20px; filter:sepia(1); -webkit-filter:sepia(1); opacity:0.5; } ' +
3361
3362 '#dio_town_popup .unit_content, ' +
3363 '#dio_town_popup .spy_content, ' +
3364 '#dio_town_popup .god_content, ' +
3365 '#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; } ' +
3366 '#dio_town_popup .resources_content { text-align: right; margin-top:3px; } ' +
3367
3368 '#dio_town_popup .resources_content table { min-width:95% } ' +
3369
3370 '#dio_town_popup .footer_content { margin-top:3px; } ' +
3371 '#dio_town_popup .footer_content table { width:100%; } ' +
3372
3373 '#dio_town_popup .spy_content { height:25px; margin-right:3px; } ' +
3374 '#dio_town_popup .god_content { width:24px; } ' +
3375
3376 '#dio_town_popup .god_mini { height: 25px; width: 32px; background-size: 75%; background-position: 0px -122px; margin-right: -8px; } ' +
3377
3378 // God Icon
3379 '#dio_town_popup .god_mini.zeus { background-position: 0px 0px; } ' +
3380 '#dio_town_popup .god_mini.athena { background-position: 0px -24px; } ' +
3381 '#dio_town_popup .god_mini.poseidon { background-position: 0px -49px; } ' +
3382 '#dio_town_popup .god_mini.hera { background-position: 0px -73px; } ' +
3383 '#dio_town_popup .god_mini.hades { background-position: 0px -98px; } ' +
3384 '#dio_town_popup .god_mini.artemis { background-position: 0px -146px; } ' +
3385
3386 '#dio_town_popup .count { position: absolute; bottom: -2px; right: 2px; font-size: 10px; font-family: Verdana,Arial,Helvetica,sans-serif; } ' +
3387 '#dio_town_popup .four_digit_number .count { font-size:8px !important; } ' +
3388 '#dio_town_popup .unit_icon25x25 { border: 1px solid #6e4b0b; margin: 1px; } ' +
3389 '#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%; } ' +
3390
3391 // Spy Icon
3392 '#dio_town_popup .support_filter { margin: 0px 4px 0px 0px; float:left; } ' +
3393 '#dio_town_popup .spy_text { line-height: 2.3em; float:left; } ' +
3394
3395 // Bei langen Stadtnamen wird sonst der Rand abgeschnitten:
3396 '#dio_town_popup .popup_middle_right { min-width: 11px; } ' +
3397
3398 '</style>').appendTo('head');
3399
3400 },
3401 deactivate : function(){
3402 $("#dio_town_popup_style").remove();
3403 },
3404 add : function(that){
3405 var townID = 0;
3406 //console.debug("TOWN", $(that).offset(), that.id);
3407
3408 if(that.id === ""){
3409 // Island view
3410 townID = parseInt($(that).parent()[0].id.substring(10), 10);
3411 }
3412 else {
3413 // Strategic map
3414 townID = parseInt(that.id.substring(6), 10);
3415 }
3416
3417 // Own town?
3418 if (typeof(uw.ITowns.getTown(townID)) !== "undefined") {
3419
3420 var units = ITowns.getTowns()[townID].units();
3421
3422 TownPopup.remove();
3423
3424 // var popup = "<div id='dio_town_popup' style='left:" + ($(that).offset().left + 20) + "px; top:" + ($(that).offset().top + 20) + "px; '>";
3425 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'>";
3426
3427 popup += "<tr class='popup_top'><td class='popup_top_left'></td><td class='popup_top_middle'></td><td class='popup_top_right'></td></tr>";
3428
3429 popup += "<tr><td class='popup_middle_left'> </td><td style='width: auto;' class='popup_middle_middle'>";
3430
3431 // Title (town name)
3432 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>";
3433
3434 // Unit Container
3435 popup += "<div class='unit_content'>";
3436 if(!$.isEmptyObject(units)) {
3437
3438 for (var unit_id in units) {
3439 if (units.hasOwnProperty(unit_id)) {
3440
3441 var classSize = "";
3442
3443 if(units[unit_id] > 1000){
3444 classSize = "four_digit_number";
3445 }
3446
3447 // Unit
3448 popup += '<div class="unit_icon25x25 ' + unit_id + ' '+ classSize +'"><span class="count text_shadow">' + units[unit_id] + '</span></div>';
3449 }
3450 }
3451 }
3452
3453 // - Wall
3454 var wallLevel = ITowns.getTowns()[townID].getBuildings().attributes.wall;
3455 popup += '<div class="wall image bold"><span class="count text_shadow">'+ wallLevel +'</span></div>';
3456
3457 popup += "</div>";
3458
3459 // Resources Container
3460 popup += "<div class='resources_content'><table cellspacing='2px' cellpadding='0px'><tr>";
3461
3462 var resources = ITowns.getTowns()[townID].resources();
3463 var storage = ITowns.getTowns()[townID].getStorage();
3464
3465 // - Wood
3466 var textColor = (resources.wood === storage) ? textColor = "color:red;" : textColor = "";
3467 popup += '<td class="resources_small wood"></td><td style="'+ textColor +'; width:1%;">' + resources.wood + '</td>';
3468
3469 popup += '<td style="min-width:15px;"></td>';
3470
3471 // - Population
3472 popup += '<td class="resources_small population"></td><td style="width:1%">' + resources.population + '</td>';
3473
3474 popup += '</tr><tr>';
3475
3476 // - Stone
3477 textColor = (resources.stone === storage) ? textColor = "color:red;" : textColor = "";
3478 popup += '<td class="resources_small stone"></td><td style="'+ textColor +'">' + resources.stone + '</td>';
3479
3480 popup += '</tr><tr>';
3481
3482 // - Iron
3483 textColor = (resources.iron === storage) ? textColor = "color:red;" : textColor = "";
3484 popup += '<td class="resources_small iron"></td><td style="'+ textColor +'">' + resources.iron + '</td>';
3485
3486
3487 popup += "</tr></table></div>";
3488
3489 // console.debug("TOWNINFO", ITowns.getTowns()[townID]);
3490
3491 // Spy and God Container
3492 popup += "<div class='footer_content'><table cellspacing='0px'><tr>";
3493
3494 var spy_storage = ITowns.getTowns()[townID].getEspionageStorage();
3495
3496 // - Spy content
3497 popup += "<td class='spy_content'>";
3498 popup += '<div class="support_filter attack_spy"></div><div class="spy_text">'+ pointNumber(spy_storage) +'</div>';
3499 popup += "</td>";
3500
3501 popup += "<td></td>";
3502
3503 // - God Content
3504 var god = ITowns.getTowns()[townID].god();
3505
3506 popup += "<td class='god_content'>";
3507 popup += '<div class="god_mini '+ god +'"></div>';
3508 popup += "</td>";
3509
3510 popup += "</tr></table></div>";
3511
3512
3513
3514 popup += "</td><td class='popup_middle_right'> </td></tr>";
3515
3516 popup += "<tr class='popup_bottom'><td class='popup_bottom_left'></td><td class='popup_bottom_middle'></td><td class='popup_bottom_right'></td></tr>";
3517
3518 popup += "</table>";
3519
3520 $(popup).appendTo("#popup_div_curtain");
3521 }
3522 },
3523 remove : function(){
3524 $('#dio_town_popup').remove();
3525 }
3526 };
3527
3528 // Style for town icons
3529 var style_str = '<style id="dio_townicons" type="text/css">';
3530 for (var s in TownIcons.types) {
3531 if (TownIcons.types.hasOwnProperty(s)) {
3532 style_str += '.townicon_' + s + ' { background:url(' + dio_sprite + ') ' + (TownIcons.types[s] * -25) + 'px -26px repeat;float:left;} ';
3533 }
3534 }
3535 style_str += '</style>';
3536 $(style_str).appendTo('head');
3537
3538
3539 var ContextMenu = {
3540 activate: function () {
3541 // Set context menu event handler
3542 $.Observer(uw.GameEvents.map.context_menu.click).subscribe('DIO_CONTEXT', function (e, data) {
3543 if (DATA.options.con && $('#context_menu').children().length == 4) {
3544 // Clear animation
3545 $('#context_menu div#goToTown').css({
3546 left: '0px',
3547 top: '0px',
3548 WebkitAnimation: 'none', //'A 0s linear',
3549 animation: 'none' //'B 0s linear'
3550 });
3551 }
3552 // Replace german label of 'select town' button
3553 if (LID === "de" && $('#select_town').get(0)) {
3554 $("#select_town .caption").get(0).innerHTML = "Selektieren";
3555 }
3556 });
3557
3558 // Set context menu animation
3559 $('<style id="dio_context_menu" type="text/css">' +
3560 // set fixed position of 'select town' button
3561 '#select_town { left: 0px !important; top: 0px !important; z-index: 6; } ' +
3562 // set animation of 'goToTown' button
3563 '#context_menu div#goToTown { left: 30px; top: -51px; ' +
3564 '-webkit-animation: A 0.115s linear; animation: B 0.2s;} ' +
3565 '@-webkit-keyframes A { from {left: 0px; top: 0px;} to {left: 30px; top: -51px;} }' +
3566 '@keyframes B { from {left: 0px; top: 0px;} to {left: 30px; top: -51px;} }' +
3567 '</style>').appendTo('head');
3568 },
3569 deactivate: function () {
3570 $.Observer(uw.GameEvents.map.context_menu.click).unsubscribe('DIO_CONTEXT');
3571
3572 $('#dio_context_menu').remove();
3573 }
3574 };
3575
3576
3577 var TownList = {
3578 activate: function () {
3579 // Style town list
3580 $('<style id="dio_town_list" type="text/css">' +
3581 '#town_groups_list .item { text-align: left; padding-left:35px; } ' +
3582 '#town_groups_list .inner_column { border: 1px solid rgba(100, 100, 0, 0.3);margin: -2px 0px 0px 2px; } ' +
3583 '#town_groups_list .island_quest_icon { position: absolute; right: 37px; top: 3px; } ' +
3584 '#town_groups_list .island_quest_icon.hidden_icon { display:none; } ' +
3585 // Quacks Zentrier-Button verschieben
3586 '#town_groups_list .jump_town { right: 37px !important; } ' +
3587 // Population percentage
3588 '#town_groups_list .pop_percent { position: absolute; right: 7px; top:0px; font-size: 0.7em; display:block !important;} ' +
3589 '#town_groups_list .full { color: green; } ' +
3590 '#town_groups_list .threequarter { color: darkgoldenrod; } ' +
3591 '#town_groups_list .half { color: darkred; } ' +
3592 '#town_groups_list .quarter { color: red; } ' +
3593 '</style>').appendTo('head');
3594
3595
3596 // Open town list: hook to grepolis function render()
3597 var i = 0;
3598 while (uw.layout_main_controller.sub_controllers[i].name != 'town_name_area') {
3599 i++;
3600 }
3601
3602 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;
3603
3604 uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render = function () {
3605 uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render_old();
3606 TownList.change();
3607 };
3608
3609 // Town List open?
3610 if ($('#town_groups_list').get(0)) {
3611 TownList.change();
3612 }
3613 },
3614 deactivate: function () {
3615 var i = 0;
3616 while (uw.layout_main_controller.sub_controllers[i].name != 'town_name_area') {
3617 i++;
3618 }
3619
3620 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;
3621
3622 $('#dio_town_list').remove();
3623
3624 $('#town_groups_list .small_icon, #town_groups_list .pop_percent').css({display: 'none'});
3625
3626 //$.Observer(uw.GameEvents.town.town_switch).unsubscribe('DIO_SWITCH_TOWN');
3627
3628 $("#town_groups_list .town_group_town").unbind('mouseenter mouseleave');
3629 },
3630 change: function () {
3631 if (!$('#town_groups_list .icon_small').get(0) && !$('#town_groups_list .pop_percent').get(0)) {
3632 $("#town_groups_list .town_group_town").each(function () {
3633 try {
3634 var town_item = $(this), town_id = town_item.attr('name'), townicon_div, percent_div = "", percent = -1, pop_space = "full";
3635
3636 if (population[town_id]) {
3637 percent = population[town_id].percent;
3638 }
3639 if (percent < 75) {
3640 pop_space = "threequarter";
3641 }
3642 if (percent < 50) {
3643 pop_space = "half";
3644 }
3645 if (percent < 25) {
3646 pop_space = "quarter";
3647 }
3648
3649 if (!town_item.find('icon_small').length) {
3650 townicon_div = '<div class="icon_small townicon_' + (manuTownTypes[town_id] || autoTownTypes[town_id] || "no") + '"></div>';
3651 // TODO: Notlösung...
3652 if (percent != -1) {
3653 percent_div = '<div class="pop_percent ' + pop_space + '">' + percent + '%</div>';
3654 }
3655 town_item.prepend(townicon_div + percent_div);
3656 }
3657
3658 // opening context menu
3659 /*
3660 $(this).click(function(e){
3661 console.log(e);
3662 uw.Layout.contextMenu(e, 'determine', {"id": town_id,"name": uw.ITowns[town_id].getName()});
3663 });
3664 */
3665
3666 } catch (error) {
3667 errorHandling(error, "TownList.change");
3668 }
3669 });
3670
3671 }
3672
3673 // Hover Effect for Quacks Tool:
3674 $("#town_groups_list .town_group_town").hover(function () {
3675 $(this).find('.island_quest_icon').addClass("hidden_icon");
3676 }, function () {
3677 $(this).find('.island_quest_icon').removeClass("hidden_icon");
3678 });
3679
3680 // Add change town list event handler
3681 //$.Observer(uw.GameEvents.town.town_switch).subscribe('DIO_SWITCH_TOWN', function () {
3682 //TownList.change();
3683 //});
3684 }
3685 };
3686
3687 var HiddenHighlightWindow = {
3688 activate : function(){
3689 // Style town list
3690 $('<style id="dio_hidden_highlight_window" type="text/css">' +
3691 '.strategic_map_filter { display:none !important; } ' +
3692 '</style>').appendTo('head');
3693 },
3694 deactivate : function (){
3695 $('#dio_hidden_highlight_window').remove();
3696 }
3697 };
3698
3699 /*******************************************************************************************************************************
3700 * Available units
3701 * ----------------------------------------------------------------------------------------------------------------------------
3702 * | ● GetAllUnits
3703 * | ● Shows all available units
3704 * ----------------------------------------------------------------------------------------------------------------------------
3705 *******************************************************************************************************************************/
3706 var groupUnitArray = {};
3707 // TODO: split Function (getUnits, calcUnitsSum, availableUnits, countBiremes, getTownTypes)?
3708
3709 // Alter Einheitenzähler
3710 function getAllUnits() {
3711 try {
3712 var townArray = uw.ITowns.getTowns(), groupArray = uw.ITowns.townGroups.getGroupsDIO(),
3713
3714 unitArray = {
3715 "sword": 0,
3716 "archer": 0,
3717 "hoplite": 0,
3718 "chariot": 0,
3719 "godsent": 0,
3720 "rider": 0,
3721 "slinger": 0,
3722 "catapult": 0,
3723 "small_transporter": 0,
3724 "big_transporter": 0,
3725 "manticore": 0,
3726 "harpy": 0,
3727 "pegasus": 0,
3728 "cerberus": 0,
3729 "minotaur": 0,
3730 "medusa": 0,
3731 "zyklop": 0,
3732 "centaur": 0,
3733 "fury": 0,
3734 "sea_monster": 0
3735 },
3736
3737 unitArraySea = {"bireme": 0, "trireme": 0, "attack_ship": 0, "demolition_ship": 0, "colonize_ship": 0};
3738
3739 //console.debug("DIO-TOOLS | getAllUnits | GROUP ARRAY", groupArray);
3740
3741
3742 if (uw.Game.hasArtemis) {
3743 unitArray = $.extend(unitArray, {"griffin": 0, "calydonian_boar": 0});
3744 }
3745 unitArray = $.extend(unitArray, unitArraySea);
3746
3747 for (var group in groupArray) {
3748 if (groupArray.hasOwnProperty(group)) {
3749 // Clone Object "unitArray"
3750 groupUnitArray[group] = Object.create(unitArray);
3751
3752 for (var town in groupArray[group].towns) {
3753 if (groupArray[group].towns.hasOwnProperty(town)) {
3754 var type = {lo: 0, ld: 0, so: 0, sd: 0, fo: 0, fd: 0}; // Type for TownList
3755
3756 for (var unit in unitArray) {
3757 if (unitArray.hasOwnProperty(unit)) {
3758 // All Groups: Available units
3759 var tmp = parseInt(uw.ITowns.getTown(town).units()[unit], 10);
3760 groupUnitArray[group][unit] += tmp || 0;
3761 // Only for group "All"
3762 if (group == -1) {
3763 // Bireme counter // old
3764 if (unit === "bireme" && ((biriArray[townArray[town].id] || 0) < (tmp || 0))) {
3765 biriArray[townArray[town].id] = tmp;
3766 }
3767 //TownTypes
3768 if (!uw.GameData.units[unit].is_naval) {
3769 if (uw.GameData.units[unit].flying) {
3770 type.fd += ((uw.GameData.units[unit].def_hack + uw.GameData.units[unit].def_pierce + uw.GameData.units[unit].def_distance) / 3 * (tmp || 0));
3771 type.fo += (uw.GameData.units[unit].attack * (tmp || 0));
3772 } else {
3773 type.ld += ((uw.GameData.units[unit].def_hack + uw.GameData.units[unit].def_pierce + uw.GameData.units[unit].def_distance) / 3 * (tmp || 0));
3774 type.lo += (uw.GameData.units[unit].attack * (tmp || 0));
3775 }
3776 } else {
3777 type.sd += (uw.GameData.units[unit].defense * (tmp || 0));
3778 type.so += (uw.GameData.units[unit].attack * (tmp || 0));
3779 }
3780 }
3781 }
3782 }
3783 // Only for group "All"
3784 if (group == -1) {
3785 // Icon: DEF or OFF?
3786 var z = ((type.sd + type.ld + type.fd) <= (type.so + type.lo + type.fo)) ? "o" : "d",
3787 temp = 0;
3788
3789 for (var t in type) {
3790 if (type.hasOwnProperty(t)) {
3791 // Icon: Land/Sea/Fly (t[0]) + OFF/DEF (z)
3792 if (temp < type[t]) {
3793 autoTownTypes[townArray[town].id] = t[0] + z;
3794 temp = type[t];
3795 }
3796 // Icon: Troops Outside (overwrite)
3797 if (temp < 1000) {
3798 autoTownTypes[townArray[town].id] = "no";
3799 }
3800 }
3801 }
3802 // Icon: Empty Town (overwrite)
3803 var popBuilding = 0, buildVal = uw.GameData.buildings, levelArray = townArray[town].buildings().getLevels(),
3804 popMax = Math.floor(buildVal.farm.farm_factor * Math.pow(townArray[town].buildings().getBuildingLevel("farm"), buildVal.farm.farm_pow)), // Population from farm level
3805 popPlow = townArray[town].getResearches().attributes.plow ? 200 : 0,
3806 popFactor = townArray[town].getBuildings().getBuildingLevel("thermal") ? 1.1 : 1.0, // Thermal
3807 popExtra = townArray[town].getPopulationExtra();
3808
3809 for (var b in levelArray) {
3810 if (levelArray.hasOwnProperty(b)) {
3811 popBuilding += Math.round(buildVal[b].pop * Math.pow(levelArray[b], buildVal[b].pop_factor));
3812 }
3813 }
3814 population[town] = {};
3815
3816 population[town].max = popMax * popFactor + popPlow + popExtra;
3817 population[town].buildings = popBuilding;
3818 population[town].units = parseInt((population[town].max - (popBuilding + townArray[town].getAvailablePopulation()) ), 10);
3819
3820 if (population[town].units < 300) {
3821 autoTownTypes[townArray[town].id] = "po";
3822 }
3823
3824 population[town].percent = Math.round(100 / (population[town].max - popBuilding) * population[town].units);
3825 }
3826 }
3827 }
3828 }
3829 }
3830
3831 // Update Available Units
3832 AvailableUnits.updateBullseye();
3833 if (GPWindowMgr.TYPE_DIO_UNITS) {
3834 if (Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS)) {
3835 AvailableUnits.updateWindow();
3836 }
3837 }
3838 } catch (error) {
3839 errorHandling(error, "getAllUnits"); // TODO: Eventueller Fehler in Funktion
3840 }
3841 }
3842
3843 function addFunctionToITowns() {
3844 // Copy function and prevent an error
3845 uw.ITowns.townGroups.getGroupsDIO = function () {
3846 var town_groups_towns, town_groups, groups = {};
3847
3848 // #Grepolis Fix: 2.75 -> 2.76
3849 if (MM.collections) {
3850 town_groups_towns = MM.collections.TownGroupTown[0];
3851 town_groups = MM.collections.TownGroup[0];
3852 } else {
3853 town_groups_towns = MM.getCollections().TownGroupTown[0];
3854 town_groups = MM.getCollections().TownGroup[0];
3855 }
3856
3857 town_groups_towns.each(function (town_group_town) {
3858 var gid = town_group_town.getGroupId(),
3859 group = groups[gid],
3860 town_id = town_group_town.getTownId();
3861
3862 if (!group) {
3863 groups[gid] = group = {
3864 id: gid,
3865 //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
3866 towns: {}
3867 };
3868 }
3869
3870 group.towns[town_id] = {id: town_id};
3871 //groups[gid].towns[town_id]={id:town_id};
3872 });
3873 //console.log(groups);
3874 return groups;
3875 };
3876 }
3877
3878
3879 // Neuer Einheitenzähler
3880 var UnitCounter = {
3881 units : {"total":{}, "available":{}, "outer":{}, "foreign":{}},
3882
3883 count : function(){
3884 var tooltipHelper = require("helpers/units_tooltip_helper");
3885
3886 var groups = uw.ITowns.townGroups.getGroupsDIO();
3887
3888 for (var groupId in groups) {
3889 if (groups.hasOwnProperty(groupId)) {
3890
3891 UnitCounter.units.total[groupId] = {};
3892 UnitCounter.units.available[groupId] = {};
3893 UnitCounter.units.outer[groupId] = {};
3894
3895
3896 for (var townId in groups[groupId].towns) {
3897 if (groups[groupId].towns.hasOwnProperty(townId)) {
3898
3899 // Einheiten gesamt
3900 UnitCounter.units.total[groupId][townId] = ITowns.towns[townId].units();
3901
3902 // Einheiten verfügbar
3903 UnitCounter.units.available[groupId][townId] = ITowns.towns[townId].units();
3904
3905 // Einheiten außerhalb
3906 UnitCounter.units.outer[groupId][townId] = {};
3907
3908 var supports = tooltipHelper.getDataForSupportingUnitsInOtherTownFromCollection(MM.getTownAgnosticCollectionsByName("Units")[1].fragments[townId], MM.getOnlyCollectionByName("Town"));
3909
3910 for (var supportId in supports) {
3911 if (supports.hasOwnProperty(supportId)) {
3912
3913 for (var attributeId in supports[supportId].attributes) {
3914 if (supports[supportId].attributes.hasOwnProperty(attributeId)) {
3915
3916 // Attribut ist eine Einheit?
3917 if (typeof(GameData.units[attributeId]) !== "undefined" && supports[supportId].attributes[attributeId] > 0) {
3918
3919 UnitCounter.units.outer[groupId][townId][attributeId] = (UnitCounter.units.outer[groupId][townId][attributeId] || 0) + supports[supportId].attributes[attributeId];
3920
3921 UnitCounter.units.total[groupId][townId][attributeId] = (UnitCounter.units.total[groupId][townId][attributeId] || 0) + supports[supportId].attributes[attributeId];
3922 }
3923 }
3924 }
3925 }
3926 }
3927 }
3928 }
3929
3930 // Summen aller Städte berechnen
3931 UnitCounter.summarize(groupId);
3932 }
3933 }
3934
3935 return UnitCounter.units;
3936 },
3937
3938 summarize : function(groupId){
3939 var tooltipHelper = require("helpers/units_tooltip_helper");
3940
3941 UnitCounter.units.total[groupId]["all"] = {};
3942 UnitCounter.units.available[groupId]["all"] = {};
3943 UnitCounter.units.outer[groupId]["all"] = {};
3944
3945 for(var townId in UnitCounter.units.total[groupId]){
3946 if(UnitCounter.units.total[groupId].hasOwnProperty(townId) && townId !== "all"){
3947
3948 // Einheiten gesamt
3949 for(var unitId in UnitCounter.units.total[groupId][townId]){
3950 if(UnitCounter.units.total[groupId][townId].hasOwnProperty(unitId)){
3951
3952 UnitCounter.units.total[groupId]["all"][unitId] = (UnitCounter.units.total[groupId]["all"][unitId] || 0) + UnitCounter.units.total[groupId][townId][unitId];
3953 }
3954 }
3955
3956 // Einheiten verfügbar
3957 for(var unitId in UnitCounter.units.available[groupId][townId]){
3958 if(UnitCounter.units.available[groupId][townId].hasOwnProperty(unitId)){
3959
3960 UnitCounter.units.available[groupId]["all"][unitId] = (UnitCounter.units.available[groupId]["all"][unitId] || 0) + UnitCounter.units.available[groupId][townId][unitId];
3961 }
3962 }
3963
3964 // Einheiten außerhalb
3965 for(var unitId in UnitCounter.units.outer[groupId][townId]){
3966 if(UnitCounter.units.outer[groupId][townId].hasOwnProperty(unitId)){
3967
3968 UnitCounter.units.outer[groupId]["all"][unitId] = (UnitCounter.units.outer[groupId]["all"][unitId] || 0) + UnitCounter.units.outer[groupId][townId][unitId];
3969 }
3970 }
3971 }
3972 }
3973 }
3974 };
3975
3976
3977 var AvailableUnits = {
3978 activate: function () {
3979 var default_title = DM.getl10n("place", "support_overview").options.troop_count + " (" + DM.getl10n("hercules2014", "available") + ")";
3980
3981 $(".picomap_container").prepend("<div id='available_units_bullseye' class='unit_icon90x90 " + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme") + "'><div class='amount'></div></div>");
3982
3983 $('.picomap_overlayer').tooltip(getText("options", "ava")[0]);
3984
3985 // Ab version 2.115
3986 if($(".topleft_navigation_area").get(0)) {
3987
3988 $(".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>");
3989
3990 $('<style id="dio_available_units_style_addition">' +
3991 '.coords_box { top: 117px !important; } ' +
3992 '.nui_grepo_score { top: 150px !important; } ' +
3993 '.nui_left_box { top: 102px !important; } ' +
3994 '.nui_main_menu { top: 257px !important; }' +
3995 '#grcrt_mnu_list .nui_main_menu {top: 0px !important; }'+
3996 '.bull_eye_buttons, .rb_map { height:38px !important; }' +
3997
3998 '#ui_box .btn_change_colors { top: 31px !important; }' +
3999
4000 '.picomap_area { position: absolute; overflow: visible; top: 0; left: 0; width: 156px; height: 161px; z-index: 5; }' +
4001 '.picomap_area .picomap_container, .picomap_area .picomap_overlayer { position: absolute; top: 33px; left: -3px; width: 147px; height: 101px; }' +
4002 //'.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;} '+
4003 '.picomap_area .picomap_overlayer { background: url(' + dio_sprite + '); background-position: 473px 250px; width: 147px; height: 101px; z-index: 5;} ' +
4004 '</style>').appendTo('head');
4005 }
4006
4007 // Style
4008 $('<style id="dio_available_units_style">' +
4009
4010 '@-webkit-keyframes Z { 0% { opacity: 0; } 100% { opacity: 1; } } ' +
4011 '@keyframes Z { 0% { opacity: 0; } 100% { opacity: 1; } } ' +
4012
4013 '@-webkit-keyframes blurr { 0% { -webkit-filter: blur(5px); } 100% { -webkit-filter: blur(0px); } } ' +
4014
4015 '.picomap_overlayer { cursor:pointer; } ' +
4016
4017 '.picomap_area .bull_eye_buttons { height: 55px; } ' +
4018
4019 '#sea_id { background: none; font-size:25px; cursor:default; height:50px; width:50px; position:absolute; top:70px; left:157px; z-index: 30; } ' +
4020
4021 // Available bullseye unit
4022 '#available_units_bullseye { margin: 5px 28px 0px 28px; -webkit-animation: blur 2s; animation: Z 1s; } ' +
4023
4024 '#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; } ' +
4025
4026 '#available_units_bullseye.big_number { font-size: 0.90em; line-height: 1.4; } ' +
4027
4028 '#available_units_bullseye.blur { -webkit-animation: blurr 0.6s; } ' +
4029
4030
4031
4032 // Land units
4033 '#available_units_bullseye.sword .amount { color:#E2D9C1; top:57px; width:90px; } ' +
4034 '#available_units_bullseye.hoplite .amount { color:#E2D9C1; top:57px; width:90px; } ' +
4035 '#available_units_bullseye.archer .amount { color:#E2D0C1; top:47px; width:70px; } ' +
4036 '#available_units_bullseye.chariot { margin-top: 15px; } ' +
4037 '#available_units_bullseye.chariot .amount { color:#F5E8B4; top:38px; width:91px; } ' +
4038 '#available_units_bullseye.rider .amount { color:#DFCC6C; top:52px; width:105px; } ' +
4039 '#available_units_bullseye.slinger .amount { color:#F5E8B4; top:53px; width:91px; } ' +
4040 '#available_units_bullseye.catapult .amount { color:#F5F6C5; top:36px; width:87px; } ' +
4041 '#available_units_bullseye.godsent .amount { color:#F5F6C5; top:57px; width:92px; } ' +
4042
4043 // Mythic units
4044 '#available_units_bullseye.medusa .amount { color:#FBFFBB; top:50px; width:65px; } ' +
4045 '#available_units_bullseye.manticore .amount { color:#ECD181; top:50px; width:55px; } ' +
4046 '#available_units_bullseye.pegasus { margin-top: 16px; } ' +
4047 '#available_units_bullseye.pegasus .amount { color:#F7F8E3; top:36px; width:90px; } ' +
4048 '#available_units_bullseye.minotaur { margin-top: 10px; } ' +
4049 '#available_units_bullseye.minotaur .amount { color:#EAD88A; top:48px; width:78px; } ' +
4050 '#available_units_bullseye.zyklop { margin-top: 3px; } '+
4051 '#available_units_bullseye.zyklop .amount { color:#EDE0B0; top:50px; width:95px; } ' +
4052 '#available_units_bullseye.harpy { margin-top: 16px; } ' +
4053 '#available_units_bullseye.harpy .amount { color:#E7DB79; top:30px; width:78px; } ' +
4054 '#available_units_bullseye.sea_monster .amount { color:#D8EA84; top:58px; width:91px; } ' +
4055 '#available_units_bullseye.cerberus .amount { color:#EC7445; top:25px; width:101px; } ' +
4056 '#available_units_bullseye.centaur { margin-top: 15px; } ' +
4057 '#available_units_bullseye.centaur .amount { color:#ECE0A8; top:29px; width:83px; } ' +
4058 '#available_units_bullseye.fury .amount { color:#E0E0BC; top:57px; width:95px; } ' +
4059 '#available_units_bullseye.griffin { margin-top: 15px; } ' +
4060 '#available_units_bullseye.griffin .amount { color:#FFDC9D; top:40px; width:98px; } ' +
4061 '#available_units_bullseye.calydonian_boar .amount { color:#FFDC9D; top:17px; width:85px; } ' +
4062
4063 // Naval units
4064 '#available_units_bullseye.attack_ship .amount { color:#FFCB00; top:26px; width:99px; } ' +
4065 '#available_units_bullseye.bireme .amount { color:#DFC677; color:azure; top:28px; width:79px; } ' +
4066 '#available_units_bullseye.trireme .amount { color:#F4FFD4; top:24px; width:90px; } ' +
4067 '#available_units_bullseye.small_transporter .amount { color:#F5F6C5; top:26px; width:84px; } ' +
4068 '#available_units_bullseye.big_transporter .amount { color:#FFDC9D; top:27px; width:78px; } ' +
4069 '#available_units_bullseye.colonize_ship .amount { color:#F5F6C5; top:29px; width:76px; } ' +
4070 '#available_units_bullseye.colonize_ship .amount { color:#F5F6C5; top:29px; width:76px; } ' +
4071 '#available_units_bullseye.demolition_ship .amount { color:#F5F6C5; top:35px; width:90px; } ' +
4072
4073 // Available units window
4074 '#available_units { overflow: auto; } ' +
4075 '#available_units .unit { margin: 5px; cursor:pointer; overflow:visible; } ' +
4076 '#available_units .unit.active { border: 2px solid #7f653a; border-radius:30px; margin:4px; } ' +
4077 '#available_units .unit span { text-shadow: 1px 1px 1px black, 1px 1px 2px black;} ' +
4078 '#available_units hr { margin: 5px 0px 5px 0px; } ' +
4079 '#available_units .drop_box .option { float: left; margin-right: 30px; width:100%; } ' +
4080 '#available_units .drop_box { position:absolute; top: -38px; right: 83px; width:90px; z-index:10; } ' +
4081 '#available_units .drop_box .drop_group { width: 120px; } ' +
4082 '#available_units .drop_box .select_group.open { display:block; } ' +
4083 '#available_units .drop_box .item-list { overflow: auto; overflow-x: hidden; } ' +
4084 '#available_units .drop_box .arrow { width:18px; height:18px; background:url(' + drop_out.src + ') no-repeat -1px -1px; position:absolute; } ' +
4085
4086 // Available units button
4087 '#btn_available_units { top:86px; left:119px; z-index:10; position:absolute; } ' +
4088 '#btn_available_units .ico_available_units { margin:5px 0px 0px 4px; width:24px; height:24px; ' +
4089 '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); } ' +
4090
4091 '</style>').appendTo('head');
4092
4093 createWindowType("DIO_UNITS", (LANG.hasOwnProperty(LID) ? getText("options", "ava")[0] : default_title), 365, 310, true, [240, 70]);
4094
4095 // Set Sea-ID beside the bull eye
4096 $('#sea_id').prependTo('#ui_box');
4097
4098 AvailableUnits.addButton();
4099
4100 UnitCounter.count();
4101 AvailableUnits.updateBullseye();
4102 },
4103 deactivate: function () {
4104 $('#available_units_bullseye').remove();
4105 $('#available_units_bullseye_addition').remove();
4106
4107 $('#dio_available_units_style').remove();
4108 $('#dio_available_units_style_addition').remove();
4109
4110 $('#btn_available_units').remove();
4111
4112 if (Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS)) {
4113 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS).close();
4114 }
4115
4116 $('.picomap_overlayer').unbind();
4117
4118 $('#sea_id').appendTo('.picomap_container')
4119 },
4120 addButton: function () {
4121 var default_title = DM.getl10n("place", "support_overview").options.troop_count + " (" + DM.getl10n("hercules2014", "available") + ")";
4122
4123 $('<div id="btn_available_units" class="circle_button"><div class="ico_available_units js-caption"></div></div>').appendTo(".bull_eye_buttons");
4124
4125 // Events
4126 $('#btn_available_units').on('mousedown', function () {
4127 $('#btn_available_units, .ico_available_units').addClass("checked");
4128 }).on('mouseup', function () {
4129 $('#btn_available_units, .ico_available_units').removeClass("checked");
4130 });
4131
4132 $('#btn_available_units, .picomap_overlayer').click(function () {
4133 if (!Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS)) {
4134 AvailableUnits.openWindow();
4135 $('#btn_available_units, .ico_available_units').addClass("checked");
4136 } else {
4137 AvailableUnits.closeWindow();
4138 $('#btn_available_units, .ico_available_units').removeClass("checked");
4139 }
4140 });
4141
4142 // Tooltip
4143 $('#btn_available_units').tooltip(LANG.hasOwnProperty(LID) ? getText("labels", "uni") : default_title);
4144 },
4145 openWindow: function () {
4146 var groupArray = uw.ITowns.townGroups.getGroupsDIO(),
4147
4148 unitArray = {
4149 "sword": 0,
4150 "archer": 0,
4151 "hoplite": 0,
4152 "slinger": 0,
4153 "rider": 0,
4154 "chariot": 0,
4155 "catapult": 0,
4156 "godsent": 0,
4157 "manticore": 0,
4158 "harpy": 0,
4159 "pegasus": 0,
4160 "griffin": 0,
4161 "cerberus": 0,
4162 "minotaur": 0,
4163 "medusa": 0,
4164 "zyklop": 0,
4165 "centaur": 0,
4166 "calydonian_boar": 0,
4167 "fury": 0,
4168 "sea_monster": 0,
4169 "small_transporter": 0,
4170 "big_transporter": 0,
4171 "bireme": 0,
4172 "attack_ship": 0,
4173 "trireme": 0,
4174 "demolition_ship": 0,
4175 "colonize_ship": 0
4176 };
4177
4178 if (!uw.Game.hasArtemis) {
4179 delete unitArray.calydonian_boar;
4180 delete unitArray.griffin;
4181 }
4182
4183 var land_units_str = "", content =
4184 '<div id="available_units">' +
4185 // Dropdown menu
4186 '<div class="drop_box">' +
4187 '<div class="drop_group dropdown default">' +
4188 '<div class="border-left"></div><div class="border-right"></div>' +
4189 '<div class="caption" name="' + groupArray[DATA.bullseyeUnit.current_group].id + '">' + ITowns.town_groups._byId[groupArray[DATA.bullseyeUnit.current_group].id].attributes.name + '</div>' +
4190 '<div class="arrow"></div>' +
4191 '</div>' +
4192 '<div class="select_group dropdown-list default active"><div class="item-list"></div></div>' +
4193 '</div>' +
4194 '<table width="100%" class="radiobutton horizontal rbtn_visibility"><tr>'+
4195 '<td width="40%"><div class="option js-option" name="total"><div class="pointer"></div>'+ getText("labels", "total") +'</div></td>'+
4196 '<td width="40%"><div class="option js-option" name="available"><div class="pointer"></div>'+ getText("labels", "available") +'</div></td>'+
4197 '<td width="20%"><div class="option js-option" name="outer"><div class="pointer"></div>'+ getText("labels", "outer") +'</div></td>'+
4198 '</tr></table>'+
4199 '<hr>'+
4200 // Content
4201 '<div class="box_content">';
4202
4203 for (var unit in unitArray) {
4204 if (unitArray.hasOwnProperty(unit)) {
4205 land_units_str += '<div class="unit index_unit bold unit_icon40x40 ' + unit + '"></div>';
4206 if (unit == "sea_monster") {
4207 land_units_str += '<div style="clear:left;"></div>'; // break
4208 }
4209 }
4210 }
4211 content += land_units_str + '</div></div>';
4212
4213 AvailableUnits.wnd = Layout.wnd.Create(GPWindowMgr.TYPE_DIO_UNITS);
4214
4215 AvailableUnits.wnd.setContent(content);
4216
4217 if (Game.premium_features.curator <= Timestamp.now()) {
4218 $('#available_units .drop_box').css({display: 'none'});
4219 DATA.bullseyeUnit.current_group = -1;
4220 }
4221
4222 // Add groups to dropdown menu
4223 for (var group in groupArray) {
4224 if (groupArray.hasOwnProperty(group)) {
4225 var group_name = ITowns.town_groups._byId[group].attributes.name;
4226 $('<div class="option' + (group == -1 ? " sel" : "") + '" name="' + group + '">' + group_name + '</div>').appendTo('#available_units .item-list');
4227 }
4228 }
4229
4230 // Set active mode
4231 if(typeof(DATA.bullseyeUnit.mode) !== "undefined"){
4232 $('.radiobutton .option[name="'+ DATA.bullseyeUnit.mode +'"]').addClass("checked");
4233 }
4234 else{
4235 $('.radiobutton .option[name="available"]').addClass("checked");
4236 }
4237
4238 // Update
4239 AvailableUnits.updateWindow();
4240
4241 // Dropdown menu Handler
4242 $('#available_units .drop_group').click(function () {
4243 $('#available_units .select_group').toggleClass('open');
4244 });
4245 // Change group
4246 $('#available_units .select_group .option').click(function () {
4247 DATA.bullseyeUnit.current_group = $(this).attr("name");
4248 $('#available_units .select_group').removeClass('open');
4249 $('#available_units .select_group .option.sel').removeClass("sel");
4250 $(this).addClass("sel");
4251
4252 $('#available_units .drop_group .caption').attr("name", DATA.bullseyeUnit.current_group);
4253 $('#available_units .drop_group .caption').get(0).innerHTML = this.innerHTML;
4254
4255 $('#available_units .unit.active').removeClass("active");
4256 $('#available_units .unit.' + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme")).addClass("active");
4257
4258 UnitCounter.count();
4259
4260 AvailableUnits.updateWindow();
4261 AvailableUnits.updateBullseye();
4262 AvailableUnits.save();
4263 });
4264
4265 // Change mode (total, available, outer)
4266 $('.radiobutton .option').click(function(){
4267
4268 DATA.bullseyeUnit.mode = $(this).attr("name");
4269
4270 $('.radiobutton .option.checked').removeClass("checked");
4271 $(this).addClass("checked");
4272
4273 UnitCounter.count();
4274
4275 AvailableUnits.updateWindow();
4276 AvailableUnits.updateBullseye();
4277 AvailableUnits.save();
4278 });
4279
4280 // Set active bullseye unit
4281 $('#available_units .unit.' + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme")).addClass("active");
4282
4283 // Change bullseye unit
4284 $('#available_units .unit').click(function () {
4285 DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] = this.className.split(" ")[4].trim();
4286
4287 $('#available_units .unit.active').removeClass("active");
4288 $(this).addClass("active");
4289
4290 AvailableUnits.updateBullseye();
4291 AvailableUnits.save();
4292
4293 });
4294
4295 // Close button event - uncheck available units button
4296 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS).getJQCloseButton().get(0).onclick = function () {
4297 $('#btn_available_units, .ico_available_units').removeClass("checked");
4298 };
4299 },
4300 closeWindow: function () {
4301 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS).close();
4302 },
4303 save: function () {
4304 // console.debug("BULLSEYE SAVE", DATA.bullseyeUnit);
4305
4306 saveValue(WID + "_bullseyeUnit", JSON.stringify(DATA.bullseyeUnit));
4307 },
4308 updateBullseye: function () {
4309
4310 var sum = 0, str = "", fsize = ['1.4em', '1.2em', '1.15em', '1.1em', '1.0em', '0.95em'], i;
4311
4312 if ($('#available_units_bullseye').get(0)) {
4313 $('#available_units_bullseye').get(0).className = "unit_icon90x90 " + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme");
4314
4315 if (UnitCounter.units[DATA.bullseyeUnit.mode || "available"][DATA.bullseyeUnit.current_group]) {
4316 sum = UnitCounter.units[DATA.bullseyeUnit.mode || "available"][DATA.bullseyeUnit.current_group]["all"][(DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme" )] || 0;
4317 }
4318 sum = sum.toString();
4319
4320 for (i = 0; i < sum.length; i++) {
4321 str += "<span style='font-size:" + fsize[i] + "'>" + sum[i] + "</span>";
4322 }
4323 $('#available_units_bullseye .amount').get(0).innerHTML = str;
4324
4325 if (sum >= 100000) {
4326 $('#available_units_bullseye').addClass("big_number");
4327 } else {
4328 $('#available_units_bullseye').removeClass("big_number");
4329 }
4330 }
4331 },
4332 updateWindow: function () {
4333
4334 $('#available_units .box_content .unit').each(function () {
4335 var unit = this.className.split(" ")[4];
4336
4337 // TODO: Alte Variante entfernen
4338 // Alte Variante:
4339 //this.innerHTML = '<span style="font-size:0.9em">' + groupUnitArray[DATA.bullseyeUnit.current_group][unit] + '</span>';
4340
4341 // Neue Variante
4342 this.innerHTML = '<span style="font-size:0.9em">' + (UnitCounter.units[DATA.bullseyeUnit.mode || "available"][DATA.bullseyeUnit.current_group]["all"][unit] || 0) + '</span>';
4343 });
4344 }
4345 };
4346
4347 /*******************************************************************************************************************************
4348 * Comparison box
4349 * ----------------------------------------------------------------------------------------------------------------------------
4350 * | ● Compares the units of each unit type
4351 * ----------------------------------------------------------------------------------------------------------------------------
4352 *******************************************************************************************************************************/
4353 var UnitComparison = {
4354 activate: function () {
4355 //UnitComparison.addBox();
4356 UnitComparison.addButton();
4357
4358 // Create Window Type
4359 createWindowType("DIO_COMPARISON", getText("labels", "dsc"), 480, 315, true, ["center", "center", 100, 100]);
4360
4361 // Style
4362 $('<style id="dio_comparison_style"> ' +
4363
4364 // Button
4365 '#dio_comparison_button { top:51px; left:120px; z-index:10; position:absolute; } ' +
4366 '#dio_comparison_button .ico_comparison { margin:5px 0px 0px 4px; width:24px; height:24px; ' +
4367 'background:url(http://666kb.com/i/cjq6cxia4ms8mn95r.png) no-repeat 0px 0px; background-size:100%; filter:url(#Hue1); -webkit-filter:hue-rotate(60deg); } ' +
4368 '#dio_comparison_button.checked .ico_comparison { margin-top:6px; } ' +
4369
4370 // Window
4371 '#dio_comparison a { float:left; background-repeat:no-repeat; background-size:25px; line-height:2; margin-right:10px; } ' +
4372 '#dio_comparison .box_content { text-align:center; font-style:normal; } ' +
4373
4374 // Menu tabs
4375 '#dio_comparison_menu .tab_icon { left: 23px;} ' +
4376 '#dio_comparison_menu .tab_label { margin-left: 18px; } ' +
4377
4378 // Content
4379 '#dio_comparison .hidden { display:none; } ' +
4380 '#dio_comparison table { width:480px; } ' +
4381 '#dio_comparison .hack .t_hack, #dio_comparison .pierce .t_pierce, #dio_comparison .distance .t_distance, #dio_comparison .sea .t_sea { display:inline-table; } ' +
4382
4383 '#dio_comparison .box_content { background:url(http://s1.directupload.net/images/140206/8jd9d3ec.png) 94% 94% no-repeat; background-size:140px; } ' +
4384
4385 '#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%; } ' +
4386 '#dio_comparison .compare_type_icon.booty { background:url(http://s14.directupload.net/images/140404/ki4gwd7x.png); background-size:100%; } ' +
4387 '#dio_comparison .compare_type_icon.time { background:url(https://gpall.innogamescdn.com/images/game/res/time.png); background-size:100%; } ' +
4388 '#dio_comparison .compare_type_icon.favor { background:url(https://gpall.innogamescdn.com/images/game/res/favor.png); background-size:100%; } ' +
4389 '</style>').appendTo("head");
4390 },
4391 deactivate: function () {
4392 $('#dio_comparison_button').remove();
4393 $('#dio_comparison_style').remove();
4394
4395 if (Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON)) {
4396 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON).close();
4397 }
4398 },
4399 addButton: function () {
4400 $('<div id="dio_comparison_button" class="circle_button"><div class="ico_comparison js-caption"></div></div>').appendTo(".bull_eye_buttons");
4401
4402 // Events
4403 /*
4404 $('#dio_comparison_button').on('mousedown', function(){
4405 $('#dio_comparison_button').addClass("checked");
4406 }, function(){
4407 $('#dio_comparison_button').removeClass("checked");
4408 });
4409 */
4410 $('#dio_comparison_button').on('click', function () {
4411 if (!Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON)) {
4412 UnitComparison.openWindow();
4413 $('#dio_comparison_button').addClass("checked");
4414 } else {
4415 UnitComparison.closeWindow();
4416 $('#dio_comparison_button').removeClass("checked");
4417 }
4418 });
4419
4420 // Tooltip
4421 $('#dio_comparison_button').tooltip(getText("labels", "dsc"));
4422 },
4423 openWindow: function () {
4424 var content =
4425 // Title tabs
4426 '<ul id="dio_comparison_menu" class="menu_inner" style="top: -36px; right: 35px;">' +
4427 '<li><a class="submenu_link sea" href="#"><span class="left"><span class="right"><span class="middle">' +
4428 '<span class="tab_icon icon_small townicon_so"></span><span class="tab_label">' + getText("labels", "sea") + '</span>' +
4429 '</span></span></span></a></li>' +
4430 '<li><a class="submenu_link distance" href="#"><span class="left"><span class="right"><span class="middle">' +
4431 '<span class="tab_icon icon_small townicon_di"></span><span class="tab_label">' + getText("labels", "dst") + '</span>' +
4432 '</span></span></span></a></li>' +
4433 '<li><a class="submenu_link pierce" href="#"><span class="left"><span class="right"><span class="middle">' +
4434 '<span class="tab_icon icon_small townicon_sh"></span><span class="tab_label">' + getText("labels", "prc") + '</span>' +
4435 '</span></span></span></a></li>' +
4436 '<li><a class="submenu_link hack active" href="#"><span class="left"><span class="right"><span class="middle">' +
4437 '<span class="tab_icon icon_small townicon_lo"></span><span class="tab_label">' + getText("labels", "hck") + '</span>' +
4438 '</span></span></span></a></li>' +
4439 '</ul>' +
4440 // Content
4441 '<div id="dio_comparison" style="margin-bottom:5px; font-style:italic;"><div class="box_content hack"></div></div>';
4442
4443 Layout.wnd.Create(GPWindowMgr.TYPE_DIO_COMPARISON).setContent(content);
4444
4445 UnitComparison.addComparisonTable("hack");
4446 UnitComparison.addComparisonTable("pierce");
4447 UnitComparison.addComparisonTable("distance");
4448 UnitComparison.addComparisonTable("sea");
4449
4450 // Tooltips
4451 var labelArray = DM.getl10n("barracks"),
4452 labelAttack = DM.getl10n("context_menu", "titles").attack,
4453 labelDefense = DM.getl10n("place", "tabs")[0];
4454
4455 $('.tr_att').tooltip(labelAttack);
4456 $('.tr_def').tooltip(labelDefense + " (Ø)");
4457 $('.tr_def_sea').tooltip(labelDefense);
4458 $('.tr_spd').tooltip(labelArray.tooltips.speed);
4459 $('.tr_bty').tooltip(labelArray.tooltips.booty.title);
4460 $('.tr_bty_sea').tooltip(labelArray.tooltips.ship_transport.title);
4461 $('.tr_res').tooltip(labelArray.costs + " (" +
4462 labelArray.cost_details.wood + " + " +
4463 labelArray.cost_details.stone + " + " +
4464 labelArray.cost_details.iron + ")"
4465 );
4466 $('.tr_fav').tooltip(labelArray.costs + " (" + labelArray.cost_details.favor + ")");
4467 $('.tr_tim').tooltip(labelArray.cost_details.buildtime_barracks + " (s)");
4468 $('.tr_tim_sea').tooltip(labelArray.cost_details.buildtime_docks + " (s)");
4469
4470 UnitComparison.switchComparisonTables();
4471
4472 // Close button event - uncheck available units button
4473 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON).getJQCloseButton().get(0).onclick = function () {
4474 $('#dio_comparison_button').removeClass("checked");
4475 $('.ico_comparison').get(0).style.marginTop = "5px";
4476 };
4477 },
4478 closeWindow: function () {
4479 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON).close();
4480 },
4481 switchComparisonTables: function () {
4482 $('#dio_comparison_menu .hack, #dio_comparison_menu .pierce, #dio_comparison_menu .distance, #dio_comparison_menu .sea').click(function () {
4483 $('#dio_comparison .box_content').removeClass($('#dio_comparison .box_content').get(0).className.split(" ")[1]);
4484 //console.debug(this.className.split(" ")[1]);
4485 $('#dio_comparison .box_content').addClass(this.className.split(" ")[1]);
4486
4487 $('#dio_comparison_menu .active').removeClass("active");
4488 $(this).addClass("active");
4489 });
4490 },
4491
4492 tooltips: [], t: 0,
4493
4494 addComparisonTable: function (type) {
4495 var pos = {
4496 att: {hack: "36%", pierce: "27%", distance: "45.5%", sea: "72.5%"},
4497 def: {hack: "18%", pierce: "18%", distance: "18%", sea: "81.5%"}
4498 };
4499 var unitIMG = "https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png";
4500 var strArray = [
4501 "<td></td>",
4502 '<td><div class="compare_type_icon" style="background-position: 0% ' + pos.att[type] + ';"></div></td>',
4503 '<td><div class="compare_type_icon" style="background-position: 0% ' + pos.def[type] + ';"></div></td>',
4504 '<td><div class="compare_type_icon" style="background-position: 0% 63%;"></div></td>',
4505 (type !== "sea") ? '<td><div class="compare_type_icon booty"></div></td>' : '<td><div class="compare_type_icon" style="background-position: 0% 91%;"></div></td>',
4506 '<td><div class="compare_type_icon" style="background-position: 0% 54%;"></div></td>',
4507 '<td><div class="compare_type_icon favor"></div></td>',
4508 '<td><div class="compare_type_icon time"></div></td>'
4509 ];
4510
4511 for (var e in uw.GameData.units) {
4512 if (uw.GameData.units.hasOwnProperty(e)) {
4513 var valArray = [];
4514
4515 if (type === (uw.GameData.units[e].attack_type || "sea") && (e !== "militia")) {
4516 valArray.att = Math.round(uw.GameData.units[e].attack * 10 / uw.GameData.units[e].population) / 10;
4517 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;
4518 valArray.def = valArray.def || Math.round(uw.GameData.units[e].defense * 10 / uw.GameData.units[e].population) / 10;
4519 valArray.speed = uw.GameData.units[e].speed;
4520 valArray.booty = Math.round(((uw.GameData.units[e].booty) * 10) / uw.GameData.units[e].population) / 10;
4521 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;
4522 valArray.favor = Math.round((uw.GameData.units[e].favor * 10) / uw.GameData.units[e].population) / 10;
4523 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));
4524 valArray.time = Math.round(uw.GameData.units[e].build_time / uw.GameData.units[e].population);
4525
4526 // World without Artemis? -> grey griffin and boar
4527 valArray.heroStyle = "";
4528 valArray.heroStyleIMG = "";
4529
4530 if (!uw.Game.hasArtemis && ((e === "griffin") || (e === "calydonian_boar"))) {
4531 valArray.heroStyle = "color:black;opacity: 0.4;";
4532 valArray.heroStyleIMG = "filter: url(#GrayScale); -webkit-filter:grayscale(100%);";
4533 }
4534
4535 strArray[0] += '<td class="un' + (UnitComparison.t) + '"><span class="unit index_unit unit_icon40x40 ' + e + '" style="' + valArray.heroStyle + valArray.heroStyleIMG + '"></span></td>';
4536 strArray[1] += '<td class="bold" style="color:' + ((valArray.att > 19) ? 'green;' : ((valArray.att < 10 && valArray.att !== 0 ) ? 'red;' : 'black;')) + valArray.heroStyle + '">' + valArray.att + '</td>';
4537 strArray[2] += '<td class="bold" style="color:' + ((valArray.def > 19) ? 'green;' : ((valArray.def < 10 && valArray.def !== 0 ) ? 'red;' : 'black;')) + valArray.heroStyle + '">' + valArray.def + '</td>';
4538 strArray[3] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.speed + '</td>';
4539 strArray[4] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.booty + '</td>';
4540 strArray[5] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.res + '</td>';
4541 strArray[6] += '<td class="bold" style="color:' + ((valArray.favor > 0) ? 'rgb(0, 0, 214);' : 'black;') + valArray.heroStyle + ';">' + valArray.favor + '</td>';
4542 strArray[7] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.time + '</td>';
4543
4544 UnitComparison.tooltips[UnitComparison.t] = uw.GameData.units[e].name;
4545 UnitComparison.t++;
4546 }
4547 }
4548 }
4549
4550 $('<table class="hidden t_' + type + '" cellpadding="1px">' +
4551 '<tr>' + strArray[0] + '</tr>' +
4552 '<tr class="tr_att">' + strArray[1] + '</tr><tr class="tr_def' + (type == "sea" ? "_sea" : "") + '">' + strArray[2] + '</tr>' +
4553 '<tr class="tr_spd">' + strArray[3] + '</tr><tr class="tr_bty' + (type == "sea" ? "_sea" : "") + '">' + strArray[4] + '</tr>' +
4554 '<tr class="tr_res">' + strArray[5] + '</tr><tr class="tr_fav">' + strArray[6] + '</tr><tr class="tr_tim' + (type == "sea" ? "_sea" : "") + '">' + strArray[7] + '</tr>' +
4555 '</table>').appendTo('#dio_comparison .box_content');
4556
4557 for (var i = 0; i <= UnitComparison.t; i++) {
4558 $('.un' + i).tooltip(UnitComparison.tooltips[i]);
4559 }
4560 }
4561 };
4562
4563 /*******************************************************************************************************************************
4564 * Reports and Messages
4565 * ----------------------------------------------------------------------------------------------------------------------------
4566 * | ● Storage of the selected filter (only in German Grepolis yet)
4567 * ----------------------------------------------------------------------------------------------------------------------------
4568 *******************************************************************************************************************************/
4569
4570 var filter = "all";
4571
4572 function saveFilter() {
4573 $('#dd_filter_type_list .item-list div').each(function () {
4574 $(this).click(function () {
4575 filter = $(this).attr("name");
4576 });
4577 });
4578 /*
4579 var i = 0;
4580 $("#report_list a").each(function () {
4581 //console.log((i++) +" = " + $(this).attr('data-reportid'));
4582 });
4583 */
4584 }
4585
4586 function loadFilter() {
4587 if ($('#dd_filter_type_list .selected').attr("name") !== filter) {
4588 $('#dd_filter_type .caption').click();
4589 $('#dd_filter_type_list .item-list div[name=' + filter + ']').click();
4590 }
4591 }
4592
4593 function removeReports() {
4594 $("#report_list li:contains('spioniert')").each(function () {
4595 //$(this).remove();
4596 });
4597 }
4598
4599 var zut = 0;
4600 var messageArray = {};
4601
4602 function filterPlayer() {
4603 if (!$('#message_filter_list').get(0)) {
4604 $('<div id="message_filter_list" style="height:300px;overflow-y:scroll; width: 790px;"></div>').appendTo('#folder_container');
4605 $("#message_list").get(0).style.display = "none";
4606 }
4607 if (zut < parseInt($('.es_last_page').get(0).value, 10) - 1) {
4608 $('.es_page_input').get(0).value = zut++;
4609 $('.jump_button').click();
4610 $("#message_list li:contains('')").each(function () {
4611 $(this).appendTo('#message_filter_list');
4612 });
4613 } else {
4614 zut = 1;
4615 }
4616 }
4617
4618
4619 /*******************************************************************************************************************************
4620 * World Wonder Ranking - Change
4621 *******************************************************************************************************************************/
4622
4623 function getWorldWonderTypes() {
4624 $.ajax({
4625 type: "GET",
4626 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 +
4627 "%7D&_=" + uw.Game.server_time,
4628 success: function (text) {
4629 try {
4630 //console.log(JSON.parse(text));
4631 temp = JSON.parse(text).json.data.world_wonders;
4632 for (var t in temp) {
4633 if (temp.hasOwnProperty(t)) {
4634 wonderTypes[temp[t].wonder_type] = temp[t].full_name;
4635 }
4636 }
4637 temp = JSON.parse(text).json.data.buildable_wonders;
4638 for (var x in temp) {
4639 if (temp.hasOwnProperty(x)) {
4640 wonderTypes[x] = temp[x].name;
4641 }
4642 }
4643 saveValue(MID + "_wonderTypes", JSON.stringify(wonderTypes));
4644 } catch (error) {
4645 errorHandling(error, "getWorldWonderTypes");
4646 }
4647 }
4648 });
4649 }
4650
4651 function getWorldWonders() {
4652 $.ajax({
4653 type: "GET",
4654 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 +
4655 "%7D&_=" + uw.Game.server_time
4656 });
4657 }
4658
4659 var WorldWonderRanking = {
4660 activate: function () {
4661 if ($('#dio_wonder_ranking').get(0)) {
4662 $('#dio_wonder_ranking').remove();
4663 }
4664 $('<style id="dio_wonder_ranking" type="text/css"> .wonder_ranking { display: none; } </style>').appendTo('head');
4665 },
4666 deactivate: function () {
4667 if ($('#dio_wonder_ranking').get(0)) {
4668 $('#dio_wonder_ranking').remove();
4669 }
4670 $('<style id="dio_wonder_ranking" type="text/css"> .wonder_ranking { display: block; } </style>').appendTo('head');
4671 },
4672 change: function (html) {
4673 if ($('#ranking_inner tr', html)[0].children.length !== 1) { // world wonders exist?
4674 try {
4675 var ranking = {}, temp_ally, temp_ally_id, temp_ally_link;
4676
4677 // Save world wonder ranking into array
4678 $('#ranking_inner tr', html).each(function () {
4679 try {
4680 if (this.children[0].innerHTML) {
4681 temp_ally = this.children[1].children[0].innerHTML; // das hier
4682
4683 temp_ally_id = this.children[1].children[0].onclick.toString();
4684 temp_ally_id = temp_ally_id.substring(temp_ally_id.indexOf(",") + 1);
4685 temp_ally_id = temp_ally_id.substring(0, temp_ally_id.indexOf(")"));
4686
4687 temp_ally_link = this.children[1].innerHTML;
4688
4689 } else {
4690 //World wonder name
4691 var wonder_name = this.children[3].children[0].innerHTML;
4692
4693 for (var w in wonderTypes) {
4694 if (wonderTypes.hasOwnProperty(w)) {
4695 if (wonder_name == wonderTypes[w]) {
4696 var level = this.children[4].innerHTML, // world wonder level
4697 ww_data = JSON.parse(atob(this.children[3].children[0].href.split("#")[1])), wonder_link;
4698 //console.log(ww_data);
4699
4700 if (!ranking.hasOwnProperty(level)) {
4701 // add wonder types
4702 ranking[level] = {
4703 colossus_of_rhodes: {},
4704 great_pyramid_of_giza: {},
4705 hanging_gardens_of_babylon: {},
4706 lighthouse_of_alexandria: {},
4707 mausoleum_of_halicarnassus: {},
4708 statue_of_zeus_at_olympia: {},
4709 temple_of_artemis_at_ephesus: {}
4710 };
4711 }
4712
4713 if (!ranking[level][w].hasOwnProperty(temp_ally_id)) {
4714 ranking[level][w][temp_ally_id] = {}; // add alliance array
4715 }
4716 // island coordinates of the world wonder:
4717 ranking[level][w][temp_ally_id].ix = ww_data.ix;
4718 ranking[level][w][temp_ally_id].iy = ww_data.iy;
4719 ranking[level][w][temp_ally_id].sea = this.children[5].innerHTML; // world wonder sea
4720
4721 wonder_link = this.children[3].innerHTML;
4722 if (temp_ally.length > 15) {
4723 temp_ally = temp_ally.substring(0, 15) + '.';
4724 }
4725 wonder_link = wonder_link.substr(0, wonder_link.indexOf(">") + 1) + temp_ally + '</a>';
4726
4727 ranking[level][w][temp_ally_id].ww_link = wonder_link;
4728
4729 // other data of the world wonder
4730 ranking[level][w][temp_ally_id].ally_link = temp_ally_link;
4731 ranking[level][w][temp_ally_id].ally_name = temp_ally; // alliance name
4732 ranking[level][w][temp_ally_id].name = wonder_name; // world wonder name
4733
4734 // Save wonder coordinates for wonder icons on map
4735 if (!wonder.map[w]) {
4736 wonder.map[w] = {};
4737 }
4738 wonder.map[w][ww_data.ix + "_" + ww_data.iy] = level;
4739 saveValue(WID + "_wonder", JSON.stringify(wonder));
4740
4741 }
4742 }
4743 }
4744 }
4745 } catch (error) {
4746 errorHandling(error, "WorldWonderRanking.change(function)");
4747 }
4748 });
4749
4750 if ($('#ranking_table_wrapper').get(0)) {
4751 $('#ranking_fixed_table_header').get(0).innerHTML = '<tr>' +
4752 '<td style="width:10px">#</td>' +
4753 '<td>Colossus</td>' +
4754 '<td>Pyramid</td>' +
4755 '<td>Garden</td>' +
4756 '<td>Lighthouse</td>' +
4757 '<td>Mausoleum</td>' +
4758 '<td>Statue</td>' +
4759 '<td>Temple</td>' +
4760 '</tr>';
4761
4762 $('#ranking_fixed_table_header').css({
4763 tableLayout: 'fixed',
4764 width: '100%',
4765 //paddingLeft: '0px',
4766 paddingRight: '15px'
4767 });
4768
4769 var ranking_substr = '', z = 0;
4770 for (var level = 10; level >= 1; level--) {
4771 if (ranking.hasOwnProperty(level)) {
4772 var complete = "";
4773 if (level == 10) {
4774 complete = "background: rgba(255, 236, 108, 0.36);";
4775 }
4776
4777 // Alternate table background color
4778 if (z === 0) {
4779 ranking_substr += '<tr class="game_table_odd" style="' + complete + '"><td style="border-right: 1px solid #d0be97;">' + level + '</td>';
4780 z = 1;
4781 } else {
4782 ranking_substr += '<tr class="game_table_even" style="' + complete + '"><td style="border-right: 1px solid #d0be97;">' + level + '</td>';
4783 z = 0;
4784 }
4785 for (var w in ranking[level]) {
4786 if (ranking[level].hasOwnProperty(w)) {
4787 ranking_substr += '<td>';
4788
4789 for (var a in ranking[level][w]) {
4790 if (ranking[level][w].hasOwnProperty(a)) {
4791 ranking_substr += '<nobr>' + ranking[level][w][a].ww_link + '</nobr><br />'; // ww link
4792 }
4793 }
4794 ranking_substr += '</td>';
4795 }
4796 }
4797 ranking_substr += '</tr>';
4798 }
4799 }
4800
4801 var ranking_str = '<table id="ranking_endless_scroll" class="game_table" cellspacing="0"><tr>' +
4802 '<td style="width:10px;border-right: 1px solid #d0be97;"></td>' +
4803 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.colossus_of_rhodes + ';margin-left:26px"></div></td>' + // Colossus
4804 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.great_pyramid_of_giza + ';margin-left:19px"></div></td>' + // Pyramid
4805 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.hanging_gardens_of_babylon + ';margin-left:19px"></div></td>' + // Garden
4806 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.lighthouse_of_alexandria + ';margin-left:24px"></div></td>' + // Lighthouse
4807 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.mausoleum_of_halicarnassus + ';margin-left:25px"></div></td>' + // Mausoleum
4808 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.statue_of_zeus_at_olympia + ';margin-left:25px"></div></td>' + // Statue
4809 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.temple_of_artemis_at_ephesus + ';margin-left:22px"></div></td>' + // Temple
4810 '</tr>' + ranking_substr + '</table>';
4811
4812 $('#ranking_table_wrapper').get(0).innerHTML = ranking_str;
4813
4814 $('#ranking_endless_scroll .dio_wonder').css({
4815 width: "65px", height: "60px",
4816 backgroundSize: "auto 100%",
4817 backgroundPosition: "64px 0px"
4818 });
4819
4820 $('#ranking_endless_scroll').css({
4821 tableLayout: 'fixed',
4822 width: '100%',
4823 overflowY: 'auto',
4824 overflowX: 'hidden',
4825 fontSize: '0.7em',
4826 lineHeight: '2'
4827 });
4828 $('#ranking_endless_scroll tbody').css({
4829 verticalAlign: 'text-top'
4830 });
4831
4832 $('#ranking_table_wrapper img').css({
4833 width: "60px"
4834 });
4835 $('#ranking_table_wrapper').css({
4836 overflowY: 'scroll'
4837 });
4838 }
4839 } catch (error) {
4840 errorHandling(error, "WorldWonderRanking.change");
4841 }
4842 }
4843 if ($('.wonder_ranking').get(0)) {
4844 $('.wonder_ranking').get(0).style.display = "block";
4845 }
4846 }
4847 };
4848
4849 /*******************************************************************************************************************************
4850 * World Wonder
4851 * ----------------------------------------------------------------------------------------------------------------------------
4852 * | ● click adjustment
4853 * | ● Share calculation (= ratio of player points to alliance points)
4854 * | ● Resources calculation & counter (stores amount)
4855 * | ● Adds missing previous & next buttons on finished world wonders (better browsing through world wonders)
4856 * ----------------------------------------------------------------------------------------------------------------------------
4857 *******************************************************************************************************************************/
4858
4859 // getPointRatio: Default
4860 function getPointRatioFromAllianceProfile() {
4861 if (AID) {
4862 $.ajax({
4863 type: "GET",
4864 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 +
4865 '%2C%22nlreq_id%22%3A' + uw.Game.notification_last_requested_id + '%7D&_=' + uw.Game.server_time,
4866 success: function (text) {
4867 try {
4868 text = text.substr(text.indexOf("/li") + 14).substr(0, text.indexOf("\ "));
4869 var AP = parseInt(text, 10);
4870 wonder.ratio[AID] = 100 / AP * uw.Game.player_points;
4871 saveValue(WID + "_wonder", JSON.stringify(wonder));
4872 } catch (error) {
4873 errorHandling(error, "getPointRatioFromAllianceProfile");
4874 }
4875 }
4876 });
4877 } else {
4878 wonder.ratio[AID] = -1;
4879 saveValue(WID + "_wonder", JSON.stringify(wonder));
4880 }
4881 }
4882
4883 function getPointRatioFromAllianceRanking() {
4884 try {
4885 if (AID && $('.current_player .r_points').get(0)) {
4886 wonder.ratio[AID] = 100 / parseInt($('.current_player .r_points').get(0).innerHTML, 10) * uw.Game.player_points;
4887 saveValue(WID + "_wonder", JSON.stringify(wonder));
4888 }
4889 } catch (error) {
4890 errorHandling(error, "getPointRatioFromAllianceRaking");
4891 }
4892 }
4893
4894 function getPointRatioFromAllianceMembers() {
4895 try {
4896 var ally_points = 0;
4897 $('#ally_members_body tr').each(function () {
4898 ally_points += parseInt($(this).children().eq(2).text(), 10) || 0;
4899 });
4900 wonder.ratio[AID] = 100 / ally_points * uw.Game.player_points;
4901 saveValue(WID + "_wonder", JSON.stringify(wonder));
4902 } catch (error) {
4903 errorHandling(error, "getPointRatioFromAllianceMembers");
4904 }
4905 }
4906
4907 var WorldWonderCalculator = {
4908 activate: function () {
4909 // Style
4910 $('<style id="dio_wonder_calculator"> ' +
4911 '.wonder_controls { height:380px; } ' +
4912 '.wonder_controls .wonder_progress { margin: 0px auto 5px; } ' +
4913 '.wonder_controls .wonder_header { text-align:left; margin:10px -8px 12px 3px; }' +
4914 '.wonder_controls .build_wonder_icon { top:25px !important; }' +
4915 '.wonder_controls .wonder_progress_bar { top:54px; }' +
4916 '.wonder_controls .trade fieldset { float:right; } ' +
4917 '.wonder_controls .wonder_res_container { right:29px; } ' +
4918 '.wonder_controls .ww_ratio {position:relative; height:auto; } ' +
4919 '.wonder_controls fieldset.next_level_res { height:auto; } ' +
4920 '.wonder_controls .town-capacity-indicator { margin-top:0px; } ' +
4921
4922 '.wonder_controls .ww_ratio .progress { line-height:1; color:white; font-size:0.8em; } ' +
4923 '.wonder_controls .ww_perc { position:absolute; width:242px; text-align:center; } ' +
4924 '.wonder_controls .indicator3 { z-index:0; } ' +
4925 '.wonder_controls .indicator3.red { background-position:right -203px; height:10px; width:242px; } ' +
4926 '.wonder_controls .indicator3.green { background-position:right -355px; height:10px; width:242px; } ' +
4927 '.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; } ' +
4928 '.wonder_controls .town-capacity-indicator { margin-top:0px; } ' +
4929 '</style>').appendTo('head');
4930 },
4931 deactivate: function () {
4932 $('#dio_wonder_calculator').remove();
4933 }
4934 };
4935
4936 // TODO: Split function...
4937 function getResWW() {
4938 try {
4939 var wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_WONDERS);
4940
4941 for (var e in wndArray) {
4942 if (wndArray.hasOwnProperty(e)) {
4943 var wndID = "#gpwnd_" + wndArray[e].getID() + " ";
4944
4945 if ($(wndID + '.wonder_progress').get(0)) {
4946 var res = 0,
4947 ww_share = {total: {share: 0, sum: 0}, stage: {share: 0, sum: 0}},
4948 ww_type = $(wndID + '.finished_image_small').attr('src').split("/")[6].split("_")[0], // Which world wonder?
4949 res_stages = [2, 4, 6, 10, 16, 28, 48, 82, 140, 238], // Rohstoffmenge pro Rohstofftyp in 100.000 Einheiten
4950 stage = parseInt($(wndID + '.wonder_expansion_stage span').get(0).innerHTML.split("/")[0], 10) + 1, // Derzeitige Füllstufe
4951 speed = uw.Game.game_speed;
4952
4953 wonder.storage[AID] = wonder.storage[AID] || {};
4954
4955 wonder.storage[AID][ww_type] = wonder.storage[AID][ww_type] || {};
4956
4957 wonder.storage[AID][ww_type][stage] = wonder.storage[AID][ww_type][stage] || 0;
4958
4959 if (!$(wndID + '.ww_ratio').get(0)) {
4960 $('<fieldset class="ww_ratio"></fieldset>').appendTo(wndID + '.wonder_res_container .trade');
4961 $(wndID + '.wonder_header').prependTo(wndID + '.wonder_progress');
4962 $(wndID + '.wonder_res_container .send_res').insertBefore(wndID + '.wonder_res_container .next_level_res');
4963 }
4964
4965 for (var d in res_stages) {
4966 if (res_stages.hasOwnProperty(d)) {
4967 ww_share.total.sum += res_stages[d];
4968 }
4969 }
4970
4971 ww_share.total.sum *= speed * 300000;
4972
4973 ww_share.total.share = parseInt(wonder.ratio[AID] * (ww_share.total.sum / 100), 10);
4974
4975 ww_share.stage.sum = speed * res_stages[stage - 1] * 300000;
4976
4977 ww_share.stage.share = parseInt(wonder.ratio[AID] * (ww_share.stage.sum / 100), 10); // ( 3000 = 3 Rohstofftypen * 100000 Rohstoffe / 100 Prozent)
4978 setResWW(stage, ww_type, ww_share, wndID);
4979
4980
4981 $(wndID + '.wonder_res_container .send_resources_btn').click(function (e) {
4982 try {
4983 wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_wood input:text').get(0).value, 10);
4984 wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_stone input:text').get(0).value, 10);
4985 wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_iron input:text').get(0).value, 10);
4986
4987 setResWW(stage, ww_type, ww_share, wndID);
4988 saveValue(WID + "_wonder", JSON.stringify(wonder));
4989 } catch (error) {
4990 errorHandling(error, "getResWW_Click");
4991 }
4992 });
4993
4994 } else {
4995 $('<div class="prev_ww pos_Y"></div><div class="next_ww pos_Y"></div>').appendTo(wndID + '.wonder_controls');
4996
4997 $(wndID + '.wonder_finished').css({width: '100%'});
4998
4999 $(wndID + '.pos_Y').css({
5000 top: '-266px'
5001 });
5002 }
5003 }
5004 }
5005 } catch (error) {
5006 errorHandling(error, "getResWW");
5007 }
5008 }
5009
5010 function setResWW(stage, ww_type, ww_share, wndID) {
5011 try {
5012 var stage_width, total_width, res_total = 0, stage_color = "red", total_color = "red";
5013
5014 for (var z in wonder.storage[AID][ww_type]) {
5015 if (wonder.storage[AID][ww_type].hasOwnProperty(z)) {
5016 res_total += wonder.storage[AID][ww_type][z];
5017 }
5018 }
5019
5020 // Progressbar
5021 if (ww_share.stage.share > wonder.storage[AID][ww_type][stage]) {
5022 stage_width = (242 / ww_share.stage.share) * wonder.storage[AID][ww_type][stage];
5023 stage_color = "red";
5024 } else {
5025 stage_width = 242;
5026 stage_color = "green"
5027 }
5028 if (ww_share.total.share > res_total) {
5029 total_color = "red";
5030 total_width = (242 / ww_share.total.share) * res_total;
5031 } else {
5032 total_width = 242;
5033 total_color = "green"
5034 }
5035
5036 $(wndID + '.ww_ratio').get(0).innerHTML = "";
5037 $(wndID + '.ww_ratio').append(
5038 '<legend>' + getText("labels", "leg") + ' (<span style="color:#090">' + (Math.round(wonder.ratio[AID] * 100) / 100) + '%</span>):</legend>' +
5039 '<div class="town-capacity-indicator">' +
5040 '<div class="icon all_res"></div>' +
5041 '<div id="ww_town_capacity_stadium" class="tripple-progress-progressbar">' +
5042 '<div class="border_l"></div><div class="border_r"></div><div class="body"></div>' +
5043 '<div class="progress overloaded">' +
5044 '<div class="indicator3 ' + stage_color + '" style="width:' + stage_width + 'px"></div>' +
5045 '<span class="ww_perc">' + Math.round(wonder.storage[AID][ww_type][stage] / ww_share.stage.share * 100) + '%</span>' +
5046 '</div>' +
5047 '<div class="amounts">' + getText("labels", "stg") + ': <span class="curr">' + pointNumber(wonder.storage[AID][ww_type][stage]) + '</span> / ' +
5048 '<span class="max">' + pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) + '</span></div>' +
5049 '</div></div>' +
5050 '<div class="town-capacity-indicator">' +
5051 '<div class="icon all_res"></div>' +
5052 '<div id="ww_town_capacity_total" class="tripple-progress-progressbar">' +
5053 '<div class="border_l"></div><div class="border_r"></div><div class="body"></div>' +
5054 '<div class="progress overloaded">' +
5055 '<div class="indicator3 ' + total_color + '" style="width:' + total_width + 'px;"></div>' +
5056 '<span class="ww_perc">' + Math.round(res_total / ww_share.total.share * 100) + '%</span>' +
5057 '</div>' +
5058 '<div class="amounts">' + getText("labels", "tot") + ': <span class="curr">' + pointNumber(res_total) + '</span> / ' +
5059 '<span class="max">' + pointNumber((Math.round(ww_share.total.share / 1000) * 1000)) + '</span></div>' +
5060 '</div></div>');
5061
5062 $(wndID + '.ww_ratio').tooltip(
5063 "<table style='border-spacing:0px; text-align:right' cellpadding='5px'><tr>" +
5064 "<td align='right' style='border-right: 1px solid;border-bottom: 1px solid'></td>" +
5065 "<td style='border-right: 1px solid; border-bottom: 1px solid'><span class='bbcodes_player bold'>(" + (Math.round((wonder.ratio[AID]) * 100) / 100) + "%)</span></td>" +
5066 "<td style='border-bottom: 1px solid'><span class='bbcodes_ally bold'>(100%)</span></td></tr>" +
5067 "<tr><td class='bold' style='border-right:1px solid;text-align:center'>" + getText("labels", "stg") + " " + stage + "</td>" +
5068 "<td style='border-right: 1px solid'>" + pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) + "</td>" +
5069 "<td>" + pointNumber(Math.round(ww_share.stage.sum / 1000) * 1000) + "</td></tr>" +
5070 "<tr><td class='bold' style='border-right:1px solid;text-align:center'>" + getText("labels", "tot") + "</td>" +
5071 "<td style='border-right: 1px solid'>" + pointNumber(Math.round(ww_share.total.share / 1000) * 1000) + "</td>" +
5072 "<td>" + pointNumber(Math.round(ww_share.total.sum / 1000) * 1000) + "</td>" +
5073 "</tr></table>");
5074
5075 } catch (error) {
5076 errorHandling(error, "setResWW");
5077 }
5078 }
5079
5080 // Adds points to numbers
5081 function pointNumber(number) {
5082 var sep;
5083 if (LID === "de") {
5084 sep = ".";
5085 } else {
5086 sep = ",";
5087 }
5088
5089 number = number.toString();
5090 if (number.length > 3) {
5091 var mod = number.length % 3;
5092 var output = (mod > 0 ? (number.substring(0, mod)) : '');
5093
5094 for (var i = 0; i < Math.floor(number.length / 3); i++) {
5095 if ((mod == 0) && (i == 0)) {
5096 output += number.substring(mod + 3 * i, mod + 3 * i + 3);
5097 } else {
5098 output += sep + number.substring(mod + 3 * i, mod + 3 * i + 3);
5099 }
5100 }
5101 number = output;
5102 }
5103 return number;
5104 }
5105
5106 /*******************************************************************************************************************************
5107 * Farming Village Overview
5108 * ----------------------------------------------------------------------------------------------------------------------------
5109 * | ● Color change on possibility of city festivals
5110 * ----------------------------------------------------------------------------------------------------------------------------
5111 * *****************************************************************************************************************************/
5112
5113 function changeResColor() {
5114 var res, res_min, i = 0;
5115 $('#fto_town_list .fto_resource_count :last-child').reverseList().each(function () {
5116 if ($(this).parent().hasClass("stone")) {
5117 res_min = 18000;
5118 } else {
5119 res_min = 15000;
5120 }
5121 res = parseInt(this.innerHTML, 10);
5122 if ((res >= res_min) && !($(this).hasClass("town_storage_full"))) {
5123 this.style.color = '#0A0';
5124 }
5125 if (res < res_min) {
5126 this.style.color = '#000';
5127 }
5128 });
5129 }
5130
5131 /********************************************************************************************************************************
5132 * Conquest Info
5133 * -----------------------------------------------------------------------------------------------------------------------------
5134 * | ● Amount of supports und attacks in the conquest window
5135 * | ● Layout adjustment (for reasons of clarity)
5136 * | - TODO: conquest window of own cities
5137 * -----------------------------------------------------------------------------------------------------------------------------
5138 * ******************************************************************************************************************************/
5139
5140 function countMovements() {
5141 var sup = 0, att = 0;
5142 $('.tab_content #unit_movements .support').each(function () {
5143 sup++;
5144 });
5145 $('.tab_content #unit_movements .attack_land, .tab_content #unit_movements .attack_sea, .tab_content #unit_movements .attack_takeover').each(function () {
5146 att++;
5147 });
5148
5149 var str = "<div id='move_counter' style=''><div style='float:left;margin-right:5px;'></div>" +
5150 "<div class='movement def'></div>" +
5151 "<div class='movement' style='color:green;'> " + sup + "</div>" +
5152 "<div class='movement off'> </div>" +
5153 "<div style='color:red;'> " + att + "</div></div>" +
5154 "<hr class='move_hr'>";
5155
5156 if ($('.gpwindow_content .tab_content .bold').get(0)) {
5157 $('.gpwindow_content .tab_content .bold').append(str);
5158 } else {
5159 $('.gpwindow_content h4:eq(1)').append(str);
5160
5161 // TODO: set player link ?
5162 /*
5163 $('#unit_movements li div').each(function(){
5164
5165 //console.log(this.innerHTML);
5166 });
5167 */
5168 }
5169
5170 $('<style id="dio_conquest"> ' +
5171 '.move_hr { margin:7px 0px 0px 0px; background-color:#5F5242; height:2px; border:0px solid; } ' +
5172 // Smaller movements
5173 '#unit_movements { font-size: 0.80em; } ' +
5174 '#unit_movements .incoming { width:150px; height:45px; float:left; } ' +
5175 // Counter
5176 '#move_counter { position:relative; width:100px; margin-top:-16px; left: 40%; } ' +
5177 '#move_counter .movement { float:left; margin:0px 5px 0px 0px; height:18px; width:18px; position:relative; } ' +
5178 '#move_counter .def { background:url(https://gpall.innogamescdn.com/images/game/place/losts.png); background-position:0 -36px; } ' +
5179 '#move_counter .off { background:url(https://gpall.innogamescdn.com/images/game/place/losts.png); background-position:0 0px; }' +
5180 '</style>').appendTo("head");
5181
5182 /*
5183 $('#unit_movements div').each(function(){
5184 if($(this).attr('class') === "unit_movements_arrow"){
5185 // delete placeholder for arrow of outgoing movements (there are no outgoing movements)
5186 if(!this.style.background) { this.remove(); }
5187 } else {
5188 // realign texts
5189 $(this).css({
5190 margin: '3px',
5191 paddingLeft: '3px'
5192 });
5193 }
5194 });
5195 */
5196 }
5197
5198 /*******************************************************************************************************************************
5199 * Town window
5200 * ----------------------------------------------------------------------------------------------------------------------------
5201 * | ● TownTabHandler (trade, attack, support,...)
5202 * | ● Sent units box
5203 * | ● Short duration: Display of 30% troop speed improvement in attack/support tab
5204 * | ● Trade options:
5205 * | - Ressource marks on possibility of city festivals
5206 * | - Percentual Trade: Trade button
5207 * | - Recruiting Trade: Selection boxes (ressource ratio of unit type + share of the warehouse capacity of the target town)
5208 * ----------------------------------------------------------------------------------------------------------------------------
5209 *******************************************************************************************************************************/
5210 var arrival_interval = {};
5211 // TODO: Change both functions in MultipleWindowHandler()
5212 function TownTabHandler(action) {
5213 var wndArray, wndID, wndA;
5214 wndArray = Layout.wnd.getOpen(uw.Layout.wnd.TYPE_TOWN);
5215 //console.log(wndArray);
5216 for (var e in wndArray) {
5217 if (wndArray.hasOwnProperty(e)) {
5218 //console.log(wndArray[e].getHandler());
5219 wndA = wndArray[e].getAction();
5220 wndID = "#gpwnd_" + wndArray[e].getID() + " ";
5221 if (!$(wndID).get(0)) {
5222 wndID = "#gpwnd_" + (wndArray[e].getID() + 1) + " ";
5223 }
5224 //console.log(wndID);
5225 if (wndA === action) {
5226 switch (action) {
5227 case "trading":
5228 if ($(wndID + '#trade_tab').get(0)) {
5229 if (!$(wndID + '.rec_trade').get(0) && DATA.options.rec) {
5230 RecruitingTrade.add(wndID);
5231 }
5232 //console.log(DATA.options.per);
5233 if (!$(wndID + '.btn_trade').get(0) && DATA.options.per) {
5234 addPercentTrade(wndID, false);
5235 }
5236 }
5237 //addTradeMarks(wndID, 15, 18, 15, "red"); // town festival
5238 break;
5239 case "support":
5240 case "attack":
5241 //if(!arrival_interval[wndID]){
5242 if (DATA.options.way && !($('.js-casted-powers-viewport .unit_movement_boost').get(0) || $(wndID + '.short_duration').get(0))) {
5243 //if(arrival_interval[wndID]) console.log("add " + wndID);
5244 ShortDuration.add(wndID);
5245 }
5246 if (DATA.options.sen) {
5247 SentUnits.add(wndID, action);
5248 }
5249 //}
5250 break;
5251 case "rec_mark":
5252 //addTradeMarks(wndID, 15, 18, 15, "lime");
5253 break;
5254 }
5255 }
5256 }
5257 }
5258 }
5259
5260 function WWTradeHandler() {
5261 var wndArray, wndID, wndA;
5262 wndArray = uw.GPWindowMgr.getOpen(uw.GPWindowMgr.TYPE_WONDERS);
5263 for (var e in wndArray) {
5264 if (wndArray.hasOwnProperty(e)) {
5265 wndID = "#gpwnd_" + wndArray[e].getID() + " ";
5266 if (DATA.options.per && !($(wndID + '.btn_trade').get(0) || $(wndID + '.next_building_phase').get(0) || $(wndID + '#ww_time_progressbar').get(0))) {
5267 addPercentTrade(wndID, true);
5268 }
5269 }
5270 }
5271 }
5272
5273 /*******************************************************************************************************************************
5274 * ● Sent units box
5275 *******************************************************************************************************************************/
5276 var SentUnits = {
5277 activate: function () {
5278 $.Observer(GameEvents.command.send_unit).subscribe('DIO_SEND_UNITS', function (e, data) {
5279 for (var z in data.params) {
5280 if (data.params.hasOwnProperty(z) && (data.sending_type !== "")) {
5281 if (uw.GameData.units[z]) {
5282 sentUnitsArray[data.sending_type][z] = (sentUnitsArray[data.sending_type][z] == undefined ? 0 : sentUnitsArray[data.sending_type][z]);
5283 sentUnitsArray[data.sending_type][z] += data.params[z];
5284 }
5285 }
5286 }
5287 //SentUnits.update(data.sending_type); ????
5288 });
5289 },
5290 deactivate: function () {
5291 $.Observer(GameEvents.command.send_unit).unsubscribe('DIO_SEND_UNITS');
5292 },
5293 add: function (wndID, action) {
5294 if (!$(wndID + '.sent_units_box').get(0)) {
5295 $('<div class="game_inner_box sent_units_box ' + action + '"><div class="game_border ">' +
5296 '<div class="game_border_top"></div><div class="game_border_bottom"></div><div class="game_border_left"></div><div class="game_border_right"></div>' +
5297 '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
5298 '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
5299 '<div class="game_header bold">' +
5300 '<div class="icon_sent townicon_' + (action == "attack" ? "lo" : "ld") + '"></div><span>' + getText("labels", "lab") + ' (' + (action == "attack" ? "OFF" : "DEF") + ')</span>' +
5301 '</div>' +
5302 '<div class="troops"><div class="units_list"></div><hr style="width: 172px;border: 1px solid rgb(185, 142, 93);margin: 3px 0px 2px -1px;">' +
5303 '<div id="btn_sent_units_reset" class="button_new">' +
5304 '<div class="left"></div>' +
5305 '<div class="right"></div>' +
5306 '<div class="caption js-caption">' + getText("buttons", "res") + '<div class="effect js-effect"></div></div>' +
5307 '</div>' +
5308 '</div></div>').appendTo(wndID + '.attack_support_window');
5309
5310 SentUnits.update(action);
5311
5312 $(wndID + '.icon_sent').css({
5313 height: '20px',
5314 marginTop: '-2px',
5315 width: '20px',
5316 backgroundPositionY: '-26px',
5317 paddingLeft: '0px',
5318 marginLeft: '0px'
5319 });
5320
5321 $(wndID + '.sent_units_box').css({
5322 position: 'absolute',
5323 right: '0px',
5324 bottom: '16px',
5325 width: '192px'
5326 });
5327 $(wndID + '.troops').css({padding: '6px 0px 6px 6px'});
5328
5329 $(wndID + '#btn_sent_units_reset').click(function () {
5330 // Overwrite old array
5331 sentUnitsArray[action] = {};
5332
5333 SentUnits.update(action);
5334 });
5335 }
5336 },
5337 update: function (action) {
5338 try {
5339 // Remove old unit list
5340 $('.sent_units_box.' + action + ' .units_list').each(function () {
5341 this.innerHTML = "";
5342 });
5343 // Add new unit list
5344 for (var x in sentUnitsArray[action]) {
5345 if (sentUnitsArray[action].hasOwnProperty(x)) {
5346 if ((sentUnitsArray[action][x] || 0) > 0) {
5347 $('.sent_units_box.' + action + ' .units_list').each(function () {
5348 $(this).append('<div class="unit_icon25x25 ' + x +
5349 (sentUnitsArray[action][x] >= 1000 ? (sentUnitsArray[action][x] >= 10000 ? " five_digit_number" : " four_digit_number") : "") + '">' +
5350 '<span class="count text_shadow">' + sentUnitsArray[action][x] + '</span>' +
5351 '</div>');
5352 });
5353 }
5354 }
5355 }
5356 saveValue(WID + "_sentUnits", JSON.stringify(sentUnitsArray));
5357 } catch (error) {
5358 errorHandling(error, "updateSentUnitsBox");
5359 }
5360 }
5361 };
5362
5363 /*******************************************************************************************************************************
5364 * ● Short duration
5365 *******************************************************************************************************************************/
5366
5367 // TODO: Calculator implementieren
5368 var DurationCalculator = {
5369 activate: function () {
5370 var speedBoosterSprite = "https://diotools.de/images/game/speed_booster.png";
5371
5372 $('<style id="dio_duration_calculator_style">' +
5373 '.dio_speed_booster { border:1px solid #724B08; border-spacing: 0px;} ' +
5374 '.dio_speed_booster td { border:0; padding:2px; } ' +
5375 '.dio_speed_booster .checkbox_new { margin: 4px 0px 1px 3px; } ' +
5376 '.dio_speed_booster .odd { background: url("https://gpall.innogamescdn.com/images/game/border/brown.png") repeat scroll 0% 0% transparent; } ' +
5377 '.dio_speed_booster .even { background: url("https://gpall.innogamescdn.com/images/game/border/odd.png") repeat scroll 0% 0% transparent; } ' +
5378 '.booster_icon { width:20px; height:20px; background-image:url(' + speedBoosterSprite + ');} ' +
5379 '.booster_icon.improved_speed { background-position:0 0; } ' +
5380 '.booster_icon.cartography { background-position:-20px 0; } ' +
5381 '.booster_icon.meteorology { background-position:-40px 0; } ' +
5382 '.booster_icon.lighthouse { background-position:-60px 0; } ' +
5383 '.booster_icon.set_sail { background-position:-80px 0; } ' +
5384 '.booster_icon.atalanta { background-position:-100px 0; } ' +
5385 '</style>').appendTo('head');
5386
5387 $('<table class="dio_speed_booster"><tr>' +
5388 '<td class="odd"><div class="booster_icon improved_speed"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5389 '<td class="even"><div class="booster_icon cartography"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5390 '<td class="odd"><div class="booster_icon meteorology"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5391 '<td class="even"><div class="booster_icon lighthouse"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5392 '<td class="odd"><div class="booster_icon set_sail"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5393 '<td class="even"><div class="booster_icon atalanta"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5394 '</tr></table>').appendTo(wndID + ".duration_container");
5395 },
5396 deactivate: function () {
5397 $('#dio_duration_calculator_style').remove();
5398 },
5399 add: function (wndID, data) {
5400
5401 }
5402 };
5403
5404
5405 var ShortDuration = {
5406 activate: function () {
5407
5408 $('<style id="dio_short_duration_style">' +
5409 '.attack_support_window .tab_type_support .duration_container { top:0px !important; } ' +
5410 //'.attack_support_window .tab_type_attack .duration_container { width:auto; top:10px; } ' +
5411
5412 '.attack_support_window .dio_duration { border-spacing:0px; margin-bottom:2px; text-align:right; } ' +
5413
5414 '.attack_support_window .way_duration, '+
5415 '.attack_support_window .arrival_time { padding:0px 0px 0px 0px; background:none; } ' +
5416
5417 '.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; } ' +
5418 '.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; } ' +
5419 '.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); } ' +
5420
5421 '.attack_support_window .max_booty { padding:0px 0px 0px 30px; margin:3px 4px 4px 4px; width:auto; } ' +
5422 '.attack_support_window .fight_bonus.morale { margin-top:2px; } ' +
5423
5424 '.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; } ' +
5425 '.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; } ' +
5426
5427 '</style>').appendTo('head');
5428
5429 },
5430 deactivate: function () {
5431 $("#dio_short_duration_style").remove();
5432 },
5433 add: function (wndID) {
5434 //console.log($(wndID + ".duration_container").get(0));
5435 try {
5436 var tooltip = (LANG.hasOwnProperty(LID) ? getText("labels", "improved_movement") : "") + " (+30% " + DM.getl10n("barracks", "tooltips").speed.trim() + ")";
5437
5438 $('<table class="dio_duration">' +
5439 '<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>' +
5440 '<tr class="short_duration_row" style="color:darkgreen">' +
5441 '<td> ╚> </td><td><span class="short_duration">~0:00:00</span></td>' +
5442 '<td> ╚></td><td><span class="short_arrival">~00:00:00</span></td>' +
5443 '<td class="short_icon"></td><td></td></tr>' +
5444 '</table>').prependTo(wndID + ".duration_container");
5445
5446
5447
5448 $(wndID + ".nightbonus").appendTo(wndID + ".dio_night");
5449 $(wndID + '.way_duration').appendTo(wndID + ".dio_way");
5450 $(wndID + ".arrival_time").appendTo(wndID + ".dio_arrival");
5451
5452
5453 // Tooltip
5454 $(wndID + '.short_duration_row').tooltip(tooltip);
5455
5456 // Detection of changes
5457 ShortDuration.change(wndID);
5458 // $(wndID + '.way_duration').bind('DOMSubtreeModified', function(e) { console.log(e); }); // Alternative
5459
5460 } catch (error) {
5461 errorHandling(error, "addShortDuration");
5462 }
5463 },
5464 change: function (wndID) {
5465 var duration = new MutationObserver(function (mutations) {
5466 mutations.forEach(function (mutation) {
5467 if (mutation.addedNodes[0]) {
5468 //console.debug(mutation);
5469 ShortDuration.calculate(wndID);
5470 }
5471 });
5472 });
5473 if ($(wndID + '.way_duration').get(0)) {
5474 duration.observe($(wndID + '.way_duration').get(0), {
5475 attributes: false,
5476 childList: true,
5477 characterData: false
5478 });
5479 }
5480 },
5481 //$('<style> .duration_container { display: block !important } </style>').appendTo("head");
5482 calculate: function (wndID) {
5483 //console.log(wndID);
5484 //console.log($(wndID + '.duration_container .way_duration').get(0));
5485 try {
5486 var setup_time = 900 / Game.game_speed,
5487 duration_time = $(wndID + '.duration_container .way_duration').get(0).innerHTML.replace("~", "").split(":"),
5488 // TODO: hier tritt manchmal Fehler auf TypeError: Cannot read property "innerHTML" of undefined at calcShortDuration (<anonymous>:3073:86)
5489 arrival_time,
5490 h, m, s,
5491 atalanta_factor = 0;
5492
5493 var hasCartography = ITowns.getTown(Game.townId).getResearches().get("cartography");
5494 var hasMeteorology = ITowns.getTown(Game.townId).getResearches().get("meteorology");
5495 var hasSetSail = ITowns.getTown(Game.townId).getResearches().get("set_sail");
5496
5497 var hasLighthouse = ITowns.getTown(Game.townId).buildings().get("lighthouse");
5498
5499 // Atalanta aktiviert?
5500 if ($(wndID + '.unit_container.heroes_pickup .atalanta').get(0)) {
5501 if ($(wndID + '.cbx_include_hero').hasClass("checked")) {
5502 // Beschleunigung hängt vom Level ab, Level 1 = 11%, Level 20 = 30%
5503 var atalanta_level = MM.getCollections().PlayerHero[0].models[1].get("level");
5504
5505 atalanta_factor = (atalanta_level + 10) / 100;
5506 }
5507 }
5508
5509 // Sekunden, Minuten und Stunden zusammenrechnen (-> in Sekunden)
5510 duration_time = ((parseInt(duration_time[0], 10) * 60 + parseInt(duration_time[1], 10)) * 60 + parseInt(duration_time[2], 10));
5511
5512 // Verkürzte Laufzeit berechnen
5513 duration_time = ((duration_time - setup_time) * (1 + atalanta_factor)) / (1 + 0.3 + atalanta_factor) + setup_time;
5514
5515
5516 h = Math.floor(duration_time / 3600);
5517 m = Math.floor((duration_time - h * 3600) / 60);
5518 s = Math.floor(duration_time - h * 3600 - m * 60);
5519
5520 if (m < 10) {
5521 m = "0" + m;
5522 }
5523 if (s < 10) {
5524 s = "0" + s;
5525 }
5526
5527 $(wndID + '.short_duration').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
5528
5529 // Ankunftszeit errechnen
5530 arrival_time = Math.round((Timestamp.server() + Game.server_gmt_offset)) + duration_time;
5531
5532 h = Math.floor(arrival_time / 3600);
5533 m = Math.floor((arrival_time - h * 3600) / 60);
5534 s = Math.floor(arrival_time - h * 3600 - m * 60);
5535
5536 h %= 24;
5537
5538 if (m < 10) {
5539 m = "0" + m;
5540 }
5541 if (s < 10) {
5542 s = "0" + s;
5543 }
5544
5545 $(wndID + '.short_arrival').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
5546
5547 clearInterval(arrival_interval[wndID]);
5548
5549 arrival_interval[wndID] = setInterval(function () {
5550 arrival_time += 1;
5551
5552 h = Math.floor(arrival_time / 3600);
5553 m = Math.floor((arrival_time - h * 3600) / 60);
5554 s = Math.floor(arrival_time - h * 3600 - m * 60);
5555
5556 h %= 24;
5557
5558 if (m < 10) {
5559 m = "0" + m;
5560 }
5561 if (s < 10) {
5562 s = "0" + s;
5563 }
5564
5565 if ($(wndID + '.short_arrival').get(0)) {
5566 $(wndID + '.short_arrival').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
5567 } else {
5568 clearInterval(arrival_interval[wndID]);
5569 }
5570 }, 1000);
5571
5572 } catch (error) {
5573 errorHandling(error, "ShortDuration.calculate");
5574 }
5575 }
5576 };
5577
5578 /*******************************************************************************************************************************
5579 * ● Dropdown menu
5580 *******************************************************************************************************************************/
5581
5582 // TODO: Umstellen!
5583 // Preload images for drop down arrow buttons
5584 var drop_over = new Image();
5585 drop_over.src = "http://s7.directupload.net/images/140107/hna95u8a.png";
5586 var drop_out = new Image();
5587 drop_out.src = "http://s14.directupload.net/images/140107/ppsz5mxk.png";
5588
5589 function changeDropDownButton() {
5590 $('<style id="dio_style_arrow" type="text/css">' +
5591 '#dd_filter_type .arrow, .select_rec_unit .arrow {' +
5592 'width: 18px !important; height: 17px !important; background: url("http://s14.directupload.net/images/140107/ppsz5mxk.png") no-repeat 0px -1px !important;' +
5593 'position: absolute; top: 2px !important; right: 3px; } ' +
5594 '</style>').appendTo('head');
5595
5596 }
5597
5598 /*******************************************************************************************************************************
5599 * ● Recruiting Trade
5600 * *****************************************************************************************************************************/
5601 var trade_count = 0, unit = "FS", percent = "0.0"; // Recruiting Trade
5602
5603 // TODO: Funktion umformen, Style anpassen!
5604 var RecruitingTrade = {
5605 activate: function () {
5606 $('<style id="dio_style_recruiting_trade" type="text/css">' +
5607 '#dio_recruiting_trade .option_s { filter:grayscale(100%); -webkit-filter:grayscale(100%); margin:0px; cursor:pointer; } ' +
5608 '#dio_recruiting_trade .option_s:hover { filter:unset !important; -webkit-filter:unset !important; } ' +
5609 '#dio_recruiting_trade .select_rec_unit .sel { filter:sepia(100%); -webkit-filter:sepia(100%); } ' +
5610
5611 '#dio_recruiting_trade .option {color:#000; background:#FFEEC7; } ' +
5612 '#dio_recruiting_trade .option:hover {color:#fff; background:#328BF1; } ' +
5613
5614 '#dio_recruiting_trade { position:absolute; left:30px; top:70px; } ' +
5615 '#dio_recruiting_trade .select_rec_unit { position:absolute; top:20px; width:84px; display:none; } ' +
5616 '#dio_recruiting_trade .select_rec_perc { position:absolute; top:20px; width:50px; display:none; left:50px; } ' +
5617
5618 '#dio_recruiting_trade .open { display:block !important; } '+
5619
5620 '#dio_recruiting_trade .item-list { max-height:unset; } ' +
5621
5622 '#dio_recruiting_trade .arrow { width:18px; height:18px; background:url(' + drop_out.src + ') no-repeat -1px -1px; position:absolute; } ' +
5623
5624 '#trade_tab .content { height:320px; } ' +
5625
5626 '#dio_recruiting_trade .rec_count { position:absolute; top:25px; } ' +
5627
5628 '#dio_recruiting_trade .drop_rec_unit { position:absolute; display:block; width:50px; overflow:visible; } ' +
5629 '#dio_recruiting_trade .drop_rec_perc { position:absolute; display:block; width:55px; left:49px; color:#000; } ' +
5630
5631 '</style>').appendTo('head');
5632 },
5633 deactivate: function () {
5634 $('#dio_style_recruiting_trade').remove();
5635 },
5636 add: function (wndID) {
5637 var max_amount;
5638
5639 $('<div id="dio_recruiting_trade" class="rec_trade">' +
5640 // DropDown-Button for unit
5641 '<div class="drop_rec_unit dropdown default">' +
5642 '<div class="border-left"></div>' +
5643 '<div class="border-right"></div>' +
5644 '<div class="caption" name="' + unit + '">' + unit + '</div>' +
5645 '<div class="arrow"></div>' +
5646 '</div>' +
5647 '<div class="drop_rec_perc dropdown default">' +
5648 // DropDown-Button for ratio
5649 '<div class="border-left"></div>' +
5650 '<div class="border-right"></div>' +
5651 '<div class="caption" name="' + percent + '">' + Math.round(percent * 100) + '%</div>' +
5652 '<div class="arrow"></div>' +
5653 '</div><span class="rec_count">(' + trade_count + ')</span></div>').appendTo(wndID + ".content");
5654
5655 // Select boxes for unit and ratio
5656 $('<div class="select_rec_unit dropdown-list default active">' +
5657 '<div class="item-list">' +
5658 '<div class="option_s unit index_unit unit_icon40x40 attack_ship" name="FS"></div>' +
5659 '<div class="option_s unit index_unit unit_icon40x40 bireme" name="BI"></div>' +
5660 '<div class="option_s unit index_unit unit_icon40x40 sword" name="SK"></div>' +
5661 '<div class="option_s unit index_unit unit_icon40x40 slinger" name="SL"></div>' +
5662 '<div class="option_s unit index_unit unit_icon40x40 archer" name="BS"></div>' +
5663 '<div class="option_s unit index_unit unit_icon40x40 hoplite" name="HO"></div>' +
5664 '<div class="option_s unit index_unit unit_icon40x40 rider" name="RE"></div>' +
5665 '<div class="option_s unit index_unit unit_icon40x40 chariot" name="SW"></div>' +
5666 '</div></div>').appendTo(wndID + ".rec_trade");
5667 $('<div class="select_rec_perc dropdown-list default inactive">' +
5668 '<div class="item-list">' +
5669 '<div class="option sel" name="0.0"> 0%</div>' +
5670 '<div class="option" name="0.05"> 5%</div>' +
5671 '<div class="option" name="0.1">10%</div>' +
5672 '<div class="option" name="0.16666">17%</div>' +
5673 '<div class="option" name="0.2">20%</div>' +
5674 '<div class="option" name="0.25">25%</div>' +
5675 '<div class="option" name="0.33">33%</div>' +
5676 '<div class="option" name="0.5">50%</div>' +
5677 '</div></div>').appendTo(wndID + ".rec_trade");
5678
5679 $(wndID + ".rec_trade [name='" + unit + "']").toggleClass("sel");
5680
5681 // click events of the drop menu
5682 $(wndID + ' .select_rec_unit .option_s').each(function () {
5683 $(this).click(function (e) {
5684 $(".select_rec_unit .sel").toggleClass("sel");
5685 $("." + this.className.split(" ")[4]).toggleClass("sel");
5686
5687 unit = $(this).attr("name");
5688 $('.drop_rec_unit .caption').attr("name", unit);
5689 $('.drop_rec_unit .caption').each(function () {
5690 this.innerHTML = unit;
5691 });
5692 $($(this).parent().parent().get(0)).removeClass("open");
5693 $('.drop_rec_unit .caption').change();
5694 });
5695 });
5696 $(wndID + ' .select_rec_perc .option').each(function () {
5697 $(this).click(function (e) {
5698 $(this).parent().find(".sel").toggleClass("sel");
5699 $(this).toggleClass("sel");
5700
5701 percent = $(this).attr("name");
5702 $('.drop_rec_perc .caption').attr("name", percent);
5703 $('.drop_rec_perc .caption').each(function () {
5704 this.innerHTML = Math.round(percent * 100) + "%";
5705 });
5706 $($(this).parent().parent().get(0)).removeClass("open")
5707 $('.drop_rec_perc .caption').change();
5708 });
5709 });
5710
5711 // show & hide drop menus on click
5712 $(wndID + '.drop_rec_perc').click(function (e) {
5713
5714 if (!$($(e.target)[0].parentNode.parentNode.childNodes[4]).hasClass("open")) {
5715 $($(e.target)[0].parentNode.parentNode.childNodes[4]).addClass("open");
5716 $($(e.target)[0].parentNode.parentNode.childNodes[3]).removeClass("open");
5717 } else {
5718 $($(e.target)[0].parentNode.parentNode.childNodes[4]).removeClass("open");
5719 }
5720 });
5721 $(wndID + '.drop_rec_unit').click(function (e) {
5722
5723 if (!$($(e.target)[0].parentNode.parentNode.childNodes[3]).hasClass("open")) {
5724 $($(e.target)[0].parentNode.parentNode.childNodes[3]).addClass("open");
5725 $($(e.target)[0].parentNode.parentNode.childNodes[4]).removeClass("open");
5726 } else {
5727 $($(e.target)[0].parentNode.parentNode.childNodes[3]).removeClass("open");
5728 }
5729 });
5730
5731 $(wndID).click(function (e) {
5732 var clicked = $(e.target), element = $('#' + this.id + ' .dropdown-list.open').get(0);
5733 if ((clicked[0].parentNode.className.split(" ")[1] !== "dropdown") && element) {
5734 $(element).removeClass("open");
5735 }
5736 });
5737
5738 // hover arrow change
5739 $(wndID + '.dropdown').hover(function (e) {
5740 $(e.target)[0].parentNode.childNodes[3].style.background = "url('" + drop_over.src + "') no-repeat -1px -1px";
5741 }, function (e) {
5742 $(e.target)[0].parentNode.childNodes[3].style.background = "url('" + drop_out.src + "') no-repeat -1px -1px";
5743 });
5744
5745 $(wndID + ".drop_rec_unit .caption").attr("name", unit);
5746 $(wndID + ".drop_rec_perc .caption").attr("name", percent);
5747
5748 $(wndID + '.drop_rec_unit').tooltip(getText("labels", "rat"));
5749 $(wndID + '.drop_rec_perc').tooltip(getText("labels", "shr"));
5750
5751 var ratio = {
5752 NO: {w: 0, s: 0, i: 0},
5753 FS: {w: 1, s: 0.2308, i: 0.6154},
5754 BI: {w: 1, s: 0.8750, i: 0.2250},
5755 SL: {w: 0.55, s: 1, i: 0.4},
5756 RE: {w: 0.6666, s: 0.3333, i: 1},
5757 SK: {w: 1, s: 0, i: 0.8947},
5758 HO: {w: 0, s: 0.5, i: 1},
5759 BS: {w: 1, s: 0, i: 0.6250},
5760 SW: {w: 0.4545, s: 1, i: 0.7273}
5761 };
5762
5763
5764 if ($('#town_capacity_wood .max').get(0)) {
5765 max_amount = parseInt($('#town_capacity_wood .max').get(0).innerHTML, 10);
5766 } else {
5767 max_amount = 25500;
5768 }
5769
5770 $(wndID + '.caption').change(function (e) {
5771 //console.log($(this).attr('name') + ", " + unit + "; " + percent);
5772 if (!(($(this).attr('name') === unit) || ($(this).attr('name') === percent))) {
5773 //trade_count = 0;
5774 $('.rec_count').get(0).innerHTML = "(" + trade_count + ")";
5775 }
5776
5777 var tmp = $(this).attr('name');
5778
5779 if ($(this).parent().attr('class').split(" ")[0] === "drop_rec_unit") {
5780 unit = tmp;
5781 } else {
5782 percent = tmp;
5783 }
5784 var max = (max_amount - 100) / 1000;
5785 addTradeMarks(max * ratio[unit].w, max * ratio[unit].s, max * ratio[unit].i, "lime");
5786
5787 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)
5788 var rArray = uw.ITowns.getTown(uw.Game.townId).getCurrentResources();
5789 var tradeCapacity = uw.ITowns.getTown(uw.Game.townId).getAvailableTradeCapacity();
5790
5791 var wood = ratio[unit].w * part;
5792 var stone = ratio[unit].s * part;
5793 var iron = ratio[unit].i * part;
5794
5795 if ((wood > rArray.wood) || (stone > rArray.stone) || (iron > rArray.iron) || ( (wood + stone + iron) > tradeCapacity)) {
5796 wood = stone = iron = 0;
5797 $('.drop_rec_perc .caption').css({color: '#f00'});
5798 //$('.' + e.target.parentNode.parentNode.className + ' .select_rec_perc .sel').css({color:'#f00'});
5799 //$('.select_rec_perc .sel').css({color:'#f00'});
5800 } else {
5801 $('.' + e.target.parentNode.parentNode.className + ' .drop_rec_perc .caption').css({color: '#000'});
5802 }
5803 $("#trade_type_wood [type='text']").select().val(wood).blur();
5804 $("#trade_type_stone [type='text']").select().val(stone).blur();
5805 $("#trade_type_iron [type='text']").select().val(iron).blur();
5806 });
5807
5808 $('#trade_button').click(function () {
5809 trade_count++;
5810 $('.rec_count').get(0).innerHTML = "(" + trade_count + ")";
5811
5812 });
5813
5814 $(wndID + '.drop_rec_perc .caption').change();
5815 }
5816 };
5817
5818 /*******************************************************************************************************************************
5819 * ● Ressources marks
5820 *******************************************************************************************************************************/
5821 function addTradeMarks(woodmark, stonemark, ironmark, color) {
5822 var max_amount, limit, wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_TOWN), wndID;
5823 for (var e in wndArray) {
5824 if (wndArray.hasOwnProperty(e)) {
5825 wndID = "#gpwnd_" + wndArray[e].getID() + " ";
5826 if ($(wndID + '.town-capacity-indicator').get(0)) {
5827
5828 max_amount = $(wndID + '.amounts .max').get(0).innerHTML;
5829
5830 $('#trade_tab .c_' + color).each(function () {
5831 this.remove();
5832 });
5833 $('#trade_tab .progress').each(function () {
5834 if ($("p", this).length < 3) {
5835 if ($(this).parent().get(0).id != "big_progressbar") {
5836 limit = 1000 * (242 / parseInt(max_amount, 10));
5837
5838 switch ($(this).parent().get(0).id.split("_")[2]) {
5839 case "wood":
5840 limit = limit * woodmark;
5841 break;
5842 case "stone":
5843 limit = limit * stonemark;
5844 break;
5845 case "iron":
5846 limit = limit * ironmark;
5847 break;
5848 }
5849 $('<p class="c_' + color + '"style="position:absolute;left: ' + limit + 'px; background:' + color + ';width:2px;height:100%;margin:0px"></p>').appendTo(this);
5850 }
5851 }
5852 });
5853 }
5854 }
5855 }
5856 }
5857
5858 /*******************************************************************************************************************************
5859 * ● Percentual Trade
5860 *******************************************************************************************************************************/
5861 var rest_count = 0;
5862
5863 function addPercentTrade(wndID, ww) {
5864
5865 var a = "";
5866 var content = wndID + ".content";
5867 if (ww) {
5868 a = "ww_";
5869 content = wndID + '.trade .send_res';
5870 }
5871 $('<div class="btn btn_trade"><a class="button" href="#">' +
5872 '<span class="left"><span class="right">' +
5873 '<span class="middle mid">' +
5874 '<span class="img_trade"></span></span></span></span>' +
5875 '<span style="clear:both;"></span>' +
5876 '</a></div>').prependTo(content);
5877
5878 $(wndID + '.btn_trade').tooltip(getText("labels", "per"));
5879
5880 setPercentTrade(wndID, ww);
5881
5882 // Style
5883 $(wndID + '.btn').css({width: '20px', overflow: 'visible', position: 'absolute', display: 'block'});
5884
5885 if (!ww) {
5886 $(wndID + '.content').css({height: '320px'});
5887 }
5888
5889 if (ww) {
5890 $(wndID + '.btn_trade').css({left: '678px', top: '154px'});
5891 } else {
5892 $(wndID + '.btn_trade').css({left: '336px', top: '135px'});
5893 }
5894
5895 $(wndID + '.mid').css({minWidth: '26px'});
5896
5897 $(wndID + '.img_trade').css({
5898 width: '27px',
5899 height: '27px',
5900 top: '-3px',
5901 float: 'left',
5902 position: 'relative',
5903 background: 'url("http://666kb.com/i/cjq6d72qk521ig1zz.png") no-repeat'
5904 });
5905
5906 }
5907
5908 var res = {};
5909
5910 function setPercentTrade(wndID, ww) {
5911 var a = ww ? "ww_" : "", own_town = $(wndID + '.town_info').get(0) ? true : false;
5912
5913 $(wndID + '.btn_trade').toggleClick(function () {
5914 res.wood = {};
5915 res.stone = {};
5916 res.iron = {};
5917 res.sum = {};
5918
5919 res.sum.amount = 0;
5920 // Set amount of resources to 0
5921 setAmount(true, a, wndID);
5922 // Total amount of resources // TODO: ITowns.getTown(Game.townId).getCurrentResources(); ?
5923 for (var e in res) {
5924 if (res.hasOwnProperty(e) && e != "sum") {
5925 res[e].rest = false;
5926 res[e].amount = parseInt($('.ui_resources_bar .' + e + ' .amount').get(0).innerHTML, 10);
5927 res.sum.amount += res[e].amount;
5928 }
5929 }
5930 // Percentage of total resources
5931 res.wood.percent = 100 / res.sum.amount * res.wood.amount;
5932 res.stone.percent = 100 / res.sum.amount * res.stone.amount;
5933 res.iron.percent = 100 / res.sum.amount * res.iron.amount;
5934
5935 // Total trading capacity
5936 res.sum.cur = parseInt($(wndID + '#' + a + 'big_progressbar .caption .curr').get(0).innerHTML, 10);
5937
5938 // Amount of resources on the percentage of trading capacity (%)
5939 res.wood.part = parseInt(res.sum.cur / 100 * res.wood.percent, 10);
5940 res.stone.part = parseInt(res.sum.cur / 100 * res.stone.percent, 10);
5941 res.iron.part = parseInt(res.sum.cur / 100 * res.iron.percent, 10);
5942
5943 // Get rest warehouse capacity of each resource type
5944 for (var f in res) {
5945 if (res.hasOwnProperty(f) && f != "sum") {
5946 if (!ww && own_town) { // Own town
5947 var curr = parseInt($(wndID + '#town_capacity_' + f + ' .amounts .curr').get(0).innerHTML.replace('+', '').trim(), 10) || 0,
5948 curr2 = parseInt($(wndID + '#town_capacity_' + f + ' .amounts .curr2').get(0).innerHTML.replace('+', '').trim(), 10) || 0,
5949 max = parseInt($(wndID + '#town_capacity_' + f + ' .amounts .max').get(0).innerHTML.replace('+', '').trim(), 10) || 0;
5950
5951 res[f].cur = curr + curr2;
5952 res[f].max = max - res[f].cur;
5953
5954 if (res[f].max < 0) {
5955 res[f].max = 0;
5956 }
5957
5958 } else { // World wonder or foreign town
5959 res[f].max = 30000;
5960 }
5961 }
5962 }
5963 // Rest of fraction (0-2 units) add to stone amount
5964 res.stone.part += res.sum.cur - (res.wood.part + res.stone.part + res.iron.part);
5965
5966 res.sum.rest = 0;
5967 rest_count = 0;
5968 calcRestAmount();
5969 setAmount(false, a, wndID);
5970 }, function () {
5971 setAmount(true, a, wndID);
5972 });
5973 }
5974
5975 function calcRestAmount() {
5976 // Subdivide rest
5977 if (res.sum.rest > 0) {
5978 for (var e in res) {
5979 if (res.hasOwnProperty(e) && e != "sum" && res[e].rest != true) {
5980 res[e].part += res.sum.rest / (3 - rest_count);
5981 }
5982 }
5983 res.sum.rest = 0;
5984 }
5985 // Calculate new rest
5986 for (var f in res) {
5987 if (res.hasOwnProperty(f) && f != "sum" && res[f].rest != true) {
5988 if (res[f].max <= res[f].part) {
5989 res[f].rest = true;
5990 res.sum.rest += res[f].part - res[f].max;
5991 rest_count += 1;
5992 res[f].part = res[f].max;
5993 }
5994 }
5995 }
5996 // Recursion
5997 if (res.sum.rest > 0 && rest_count < 3) {
5998 calcRestAmount();
5999 }
6000 }
6001
6002 function setAmount(clear, a, wndID) {
6003 for (var e in res) {
6004 if (res.hasOwnProperty(e) && e != "sum") {
6005 if (clear == true) {
6006 res[e].part = 0;
6007 }
6008 $(wndID + "#" + a + "trade_type_" + e + ' [type="text"]').select().val(res[e].part).blur();
6009 }
6010 }
6011 }
6012
6013 /********************************************************************************************************************************
6014 * Unit strength (blunt/sharp/distance) and Transport Capacity
6015 * ----------------------------------------------------------------------------------------------------------------------------
6016 * | ● Unit strength: Menu
6017 * | - Switching of def/off display with buttons
6018 * | - Possible Selection of certain unit types
6019 * | ● Unit strength: Conquest
6020 * | ● Unit strength: Barracks
6021 * | ● Transport capacity: Menu
6022 * | - Switching of transporter speed (+/- big transporter)
6023 * ----------------------------------------------------------------------------------------------------------------------------
6024 * ******************************************************************************************************************************/
6025
6026 var def = true, blunt = 0, sharp = 0, dist = 0, shipsize = false;
6027
6028 var UnitStrength = {
6029 // Calculate defensive strength
6030 calcDef: function (units) {
6031 var e;
6032 blunt = sharp = dist = 0;
6033 for (e in units) {
6034 if (units.hasOwnProperty(e)) {
6035 blunt += units[e] * uw.GameData.units[e].def_hack;
6036 sharp += units[e] * uw.GameData.units[e].def_pierce;
6037 dist += units[e] * uw.GameData.units[e].def_distance;
6038 }
6039 }
6040 },
6041 // Calculate offensive strength
6042 calcOff: function (units, selectedUnits) {
6043 var e;
6044 blunt = sharp = dist = 0;
6045 for (e in selectedUnits) {
6046 if (selectedUnits.hasOwnProperty(e)) {
6047 var attack = (units[e] || 0) * uw.GameData.units[e].attack;
6048 switch (uw.GameData.units[e].attack_type) {
6049 case 'hack':
6050 blunt += attack;
6051 break;
6052 case 'pierce':
6053 sharp += attack;
6054 break;
6055 case 'distance':
6056 dist += attack;
6057 break;
6058 }
6059 }
6060 }
6061 },
6062 /*******************************************************************************************************************************
6063 * ● Unit strength: Unit menu
6064 *******************************************************************************************************************************/
6065 Menu: {
6066 activate: function () {
6067 $('<div id="strength" class="cont def"><hr>' +
6068 '<span class="bold text_shadow cont_left strength_font">' +
6069 '<table style="margin:0px;">' +
6070 '<tr><td><div class="ico units_info_sprite img_hack"></td><td id="blunt">0</td></tr>' +
6071 '<tr><td><div class="ico units_info_sprite img_pierce"></td><td id="sharp">0</td></tr>' +
6072 '<tr><td><div class="ico units_info_sprite img_dist"></td><td id="dist">0</td></tr>' +
6073 '</table>' +
6074 '</span>' +
6075 '<div class="cont_right">' +
6076 '<img id="def_button" class="active img" src="https://gpall.innogamescdn.com/images/game/unit_overview/support.png">' +
6077 '<img id="off_button" class="img" src="https://gpall.innogamescdn.com/images/game/unit_overview/attack.png">' +
6078 '</div></div>').appendTo('.units_land .content');
6079
6080 // Style
6081 $('<style id="dio_strength_style">' +
6082 '#strength.def #off_button, #strength.off #def_button { filter:url(#Sepia); -webkit-filter:sepia(1); }' +
6083 '#strength.off #off_button, #strength.def #def_button { filter:none; -webkit-filter:none; } ' +
6084
6085 '#strength.off .img_hack { background-position:0% 36%;} ' +
6086 '#strength.def .img_hack { background-position:0% 0%;} ' +
6087 '#strength.off .img_pierce { background-position:0% 27%;} ' +
6088 '#strength.def .img_pierce { background-position:0% 9%;} ' +
6089 '#strength.off .img_dist { background-position:0% 45%;} ' +
6090 '#strength.def .img_dist { background-position:0% 18%;} ' +
6091
6092 '#strength .strength_font { font-size: 0.8em; } ' +
6093 '#strength.off .strength_font { color:#edb;} ' +
6094 '#strength.def .strength_font { color:#fc6;} ' +
6095
6096 '#strength .ico { height:20px; width:20px; } ' +
6097 '#strength .units_info_sprite { background:url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png); background-size:100%; } ' +
6098
6099 '#strength .img_pierce { background-position:0px -20px; } ' +
6100 '#strength .img_dist { background-position:0px -40px; } ' +
6101 '#strength hr { margin:0px; background-color:#5F5242; height:2px; border:0px solid; } ' +
6102 '#strength .cont_left { width:65%; display:table-cell; } ' +
6103
6104 '#strength.cont { background:url(https://gpall.innogamescdn.com/images/game/layout/layout_units_nav_border.png); } ' +
6105
6106 '#strength .cont_right { width:30%; display:table-cell; vertical-align:middle; } ' +
6107 '#strength .img { float:right; background:none; margin:2px 8px 2px 0px; } ' +
6108
6109 '</style>').appendTo("head");
6110
6111 // Button events
6112 $('.units_land .units_wrapper, .btn_gods_spells .checked').click(function () {
6113 setTimeout(function () {
6114 UnitStrength.Menu.update();
6115 }, 100);
6116 });
6117
6118 $('#off_button').click(function () {
6119 $('#strength').addClass('off').removeClass('def');
6120
6121 def = false;
6122 UnitStrength.Menu.update();
6123 });
6124 $('#def_button').click(function () {
6125 $('#strength').addClass('def').removeClass('off');
6126
6127 def = true;
6128 UnitStrength.Menu.update();
6129 });
6130 $('#def_button, #off_button').hover(function () {
6131 $(this).css('cursor', 'pointer');
6132 });
6133
6134 UnitStrength.Menu.update();
6135 },
6136 deactivate: function () {
6137 $('#strength').remove();
6138 $('#dio_strength_style').remove();
6139 },
6140 update: function () {
6141 var unitsIn = uw.ITowns.getTown(uw.Game.townId).units(), units = UnitStrength.Menu.getSelected();
6142
6143 // Calculation
6144 if (def === true) {
6145 UnitStrength.calcDef(units);
6146 } else {
6147 UnitStrength.calcOff(unitsIn, units);
6148 }
6149 $('#blunt').get(0).innerHTML = blunt;
6150 $('#sharp').get(0).innerHTML = sharp;
6151 $('#dist').get(0).innerHTML = dist;
6152 },
6153 getSelected: function () {
6154 var units = [];
6155 if ($(".units_land .units_wrapper .selected").length > 0) {
6156 $(".units_land .units_wrapper .selected").each(function () {
6157 units[this.className.split(" ")[1]] = this.children[0].innerHTML;
6158 });
6159 } else {
6160 $(".units_land .units_wrapper .unit").each(function () {
6161 units[this.className.split(" ")[1]] = this.children[0].innerHTML;
6162 });
6163 }
6164 return units;
6165 }
6166 },
6167 /*******************************************************************************************************************************
6168 * ● Unit strength: Conquest
6169 *******************************************************************************************************************************/
6170 Conquest: {
6171 add: function () {
6172 var units = [], str;
6173
6174 // units of the siege
6175 $('#conqueror_units_in_town .unit').each(function () {
6176 str = $(this).attr("class").split(" ")[4];
6177 if (!uw.GameData.units[str].is_naval) {
6178 units[str] = parseInt(this.children[0].innerHTML, 10);
6179 //console.log($(this).attr("class").split(" ")[4]);
6180 }
6181 });
6182 // calculation
6183 UnitStrength.calcDef(units);
6184
6185 $('<div id="strength_eo" class="game_border" style="width:90px; margin: 20px; align:center;">' +
6186 '<div class="game_border_top"></div><div class="game_border_bottom"></div>' +
6187 '<div class="game_border_left"></div><div class="game_border_right"></div>' +
6188 '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
6189 '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
6190 '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">' +
6191 '<tr><td width="1%"><div class="ico units_info_sprite img_hack"></div></td><td id="bl" align="center" width="100%">0</td></tr>' +
6192 '<tr><td><div class="ico units_info_sprite img_pierce"></div></td><td id="sh" align="center">0</td></tr>' +
6193 '<tr><td><div class="ico units_info_sprite img_dist"></div></td><td id="di" align="center">0</td></tr>' +
6194 '</table></span>' +
6195 '</div>').appendTo('#conqueror_units_in_town');
6196
6197 $('#strength_eo').tooltip('Gesamteinheitenstärke der Belagerungstruppen');
6198
6199 // Veröffentlichung-Button-Text
6200 $('#conqueror_units_in_town .publish_conquest_public_id_wrap').css({
6201 marginLeft: '130px'
6202 });
6203
6204 $('#strength_eo .ico').css({
6205 height: '20px',
6206 width: '20px'
6207 });
6208 $('#strength_eo .units_info_sprite').css({
6209 background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
6210 backgroundSize: '100%'
6211 });
6212 $('#strength_eo .img_pierce').css({backgroundPosition: '0% 9%'});
6213 $('#strength_eo .img_dist').css({backgroundPosition: '0% 18%'});
6214
6215
6216 $('#bl').get(0).innerHTML = blunt;
6217 $('#sh').get(0).innerHTML = sharp;
6218 $('#di').get(0).innerHTML = dist;
6219 }
6220 },
6221 /*******************************************************************************************************************************
6222 * ● Unit strength: Barracks
6223 *******************************************************************************************************************************/
6224 Barracks: {
6225 add: function () {
6226 if (!$('#strength_baracks').get(0)) {
6227 var units = [], pop = 0;
6228
6229 // whole units of the town
6230 $('#units .unit_order_total').each(function () {
6231 units[$(this).parent().parent().attr("id")] = this.innerHTML;
6232 });
6233 // calculation
6234 UnitStrength.calcDef(units);
6235
6236 // population space of the units
6237 for (var e in units) {
6238 if (units.hasOwnProperty(e)) {
6239 pop += units[e] * uw.GameData.units[e].population;
6240 }
6241 }
6242 $('<div id="strength_baracks" class="game_border" style="float:right; width:70px; align:center;">' +
6243 '<div class="game_border_top"></div><div class="game_border_bottom"></div>' +
6244 '<div class="game_border_left"></div><div class="game_border_right"></div>' +
6245 '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
6246 '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
6247 '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">' +
6248 '<tr><td width="1%"><div class="ico units_info_sprite img_hack"></div></td><td id="b" align="center" width="100%">0</td></tr>' +
6249 '<tr><td><div class="ico units_info_sprite img_pierce"></div></td><td id="s" align="center">0</td></tr>' +
6250 '<tr><td><div class="ico units_info_sprite img_dist"></div></td><td id="d" align="center">0</td></tr>' +
6251 '</table></span>' +
6252 '</div>').appendTo('.ui-dialog #units');
6253
6254 $('<div id="pop_baracks" class="game_border" style="float:right; width:60px; align:center;">' +
6255 '<div class="game_border_top"></div><div class="game_border_bottom"></div>' +
6256 '<div class="game_border_left"></div><div class="game_border_right"></div>' +
6257 '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
6258 '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
6259 '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">' +
6260 '<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>' +
6261 '</table></span>' +
6262 '</div>').appendTo('.ui-dialog #units');
6263
6264 $('.ui-dialog #units .ico').css({
6265 height: '20px',
6266 width: '20px'
6267 });
6268 $('.ui-dialog #units .units_info_sprite').css({
6269 background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
6270 backgroundSize: '100%'
6271 });
6272 $('.ui-dialog #units .img_pierce').css({backgroundPosition: '0% 9%'});
6273 $('.ui-dialog #units .img_dist').css({backgroundPosition: '0% 18%'});
6274
6275 //$('#pop_baracks').tooltip('Bevölkerungszahl aller Landeinheiten der Stadt');
6276 //$('#strength_baracks').tooltip('Gesamteinheitenstärke stadteigener Truppen');
6277
6278 $('#b').get(0).innerHTML = blunt;
6279 $('#s').get(0).innerHTML = sharp;
6280 $('#d').get(0).innerHTML = dist;
6281 $('#p').get(0).innerHTML = pop;
6282 }
6283 }
6284 }
6285 };
6286
6287 /*******************************************************************************************************************************
6288 * ● Transporter capacity
6289 *******************************************************************************************************************************/
6290 var TransportCapacity = {
6291 activate: function () {
6292 // transporter display
6293 $('<div id="transporter" class="cont" style="height:25px;">' +
6294 '<table style=" margin:0px;"><tr align="center" >' +
6295 '<td><img id="ship_img" class="ico" src="http://s7.directupload.net/images/140724/4pvfuch8.png"></td>' +
6296 '<td><span id="ship" class="bold text_shadow" style="color:#FFCC66;font-size: 10px;line-height: 2.1;"></span></td>' +
6297 '</tr></table>' +
6298 '</div>').appendTo('.units_naval .content');
6299
6300 $('#transporter.cont').css({
6301 background: 'url(https://gpall.innogamescdn.com/images/game/layout/layout_units_nav_border.png)'
6302 });
6303
6304 $('#transporter').hover(function () {
6305 $(this).css('cursor', 'pointer');
6306 });
6307 $('#transporter').toggleClick(
6308 function () {
6309 $('#ship_img').get(0).src = "http://s1.directupload.net/images/140724/b5xl8nmj.png";
6310 shipsize = !shipsize;
6311 TransportCapacity.update();
6312 },
6313 function () {
6314 $('#ship_img').get(0).src = "http://s7.directupload.net/images/140724/4pvfuch8.png";
6315 shipsize = !shipsize;
6316 TransportCapacity.update();
6317 }
6318 );
6319 TransportCapacity.update();
6320 },
6321 deactivate: function () {
6322 $('#transporter').remove();
6323 },
6324 update: function () {
6325 var bigTransp = 0, smallTransp = 0, pop = 0, ship = 0, unit, berth, units = [];
6326 // Ship space (available)
6327 smallTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().small_transporter, 10);
6328 if (isNaN(smallTransp)) smallTransp = 0;
6329 if (shipsize) {
6330 bigTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().big_transporter, 10);
6331 if (isNaN(bigTransp)) bigTransp = 0;
6332 }
6333
6334 // Checking: Research berth
6335 berth = 0;
6336 if (uw.ITowns.getTown(uw.Game.townId).researches().hasBerth()) {
6337 berth = GameData.research_bonus.berth;
6338 }
6339 ship = bigTransp * (GameData.units.big_transporter.capacity + berth) + smallTransp * (GameData.units.small_transporter.capacity + berth);
6340
6341 units = uw.ITowns.getTown(uw.Game.townId).units();
6342
6343 // Ship space (required)
6344 for (var e in units) {
6345 if (units.hasOwnProperty(e)) {
6346 if (uw.GameData.units[e]) { // without Heroes
6347 if (!(uw.GameData.units[e].is_naval || uw.GameData.units[e].flying)) {
6348 pop += units[e] * uw.GameData.units[e].population;
6349 }
6350 }
6351 }
6352 }
6353 $('#ship').get(0).innerHTML = pop + "/" + ship;
6354 }
6355 };
6356
6357
6358 /*******************************************************************************************************************************
6359 * Simulator
6360 * ----------------------------------------------------------------------------------------------------------------------------
6361 * | ● Layout adjustment
6362 * | ● Permanent display of the extended modifier box
6363 * | ● Unit strength for entered units (without modificator influence yet)
6364 * ----------------------------------------------------------------------------------------------------------------------------
6365 *******************************************************************************************************************************/
6366 var Simulator = {
6367 activate: function () {
6368 $('<style id="dio_simulator_style" type="text/css">' +
6369
6370 '#place_simulator { overflow: hidden !important} ' +
6371 '#place_simulator .game_body { height: 417px !important} ' +
6372
6373 '#place_simulator_form h4 { display:none; } '+
6374
6375 '#place_simulator .place_simulator_table { margin: 0px !important } '+
6376
6377 '#place_simulator_form .place_sim_wrap_mods { margin-bottom: 2px; } '+
6378
6379 // Bonus container
6380 '.place_sim_bonuses_heroes { position:absolute; right:3px; top:27px; width: 272px;} ' +
6381 '.place_sim_bonuses_heroes .place_sim_showhide { display:none; } ' + // Hide modifier box button
6382
6383
6384 //'.place_sim_wrap_mods {position: relative; right: -17px !important} '+
6385 '.place_sim_wrap_mods .place_simulator_table :eq(1) { width: 300px;} ' + ////////////// genauer!
6386 '.place_sim_wrap_mods > .place_simulator_table { width: 272px;} ' + ////////////// genauer!
6387
6388 // Wall losses
6389 '.place_sim_wrap_mods tr:last-child { display:none; } ' +
6390
6391 // Extended modifier box
6392 //'@-webkit-keyframes MODBOX { 0% { opacity: 0; } 100% { opacity: 1; } } '+
6393 //'@keyframes MODBOX { 0% { opacity: 0; } 100% { opacity: 1; } } '+
6394
6395 '.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} ' +
6396 '.place_sim_wrap_mods_extended table tr td:eq(0) { width: 18px !important } ' +
6397 '.place_sim_wrap_mods_extended td { border:0px; } ' +
6398 '.place_sim_wrap_mods_extended tr td:first-child { border-left:0px; width:19px; padding-left:0px; } ' +
6399 '.place_sim_wrap_mods_extended .place_simulator_table { margin:0px; border-collapse:separate; border:1px solid #724B08; table-layout:fixed; width:100% } ' +
6400
6401 '.place_simulator_table .place_image { display:block; width: 20px; height:20px; background-size:100%; margin:auto; } ' +
6402
6403 '.place_simulator_table .place_image.pa_commander { background: url(https://diotools.de/images/game/advisors/advisors_22.png); background-position: 0px 44px; } ' +
6404 '.place_simulator_table .place_image.pa_captain { background: url(https://diotools.de/images/game/advisors/advisors_22.png); background-position: 0px 88px; } ' +
6405 '.place_simulator_table .place_image.pa_priest { background: url(https://diotools.de/images/game/advisors/advisors_22.png); background-position: 0px 66px; } ' +
6406
6407 '.place_simulator_table .place_image.is_night { background-position: 0px -40px; } ' +
6408 '.place_simulator_table .place_image.research_ram { background-position: 0px -300px; } ' +
6409 '.place_simulator_table .place_image.research_phalanx { background-position: 0px -280px; }' +
6410 '.place_simulator_table .place_image.research_divine_selection { background-position: 0 -600px; }' +
6411
6412 '.place_sim_wrap_mods_extended .place_cross { height:16px; background:none; } ' +
6413 '.place_sim_wrap_mods_extended .place_checkbox_field { display:table-cell; width:13px; height:13px; } ' +
6414
6415 '.place_sim_wrap_mods_extended tr:last-child { display:none;} ' +
6416
6417 '.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} ' +
6418
6419 '.place_sim_wrap_mods_extended .game_border>div { display:none; } ' +
6420 '.place_sim_wrap_mods_extended .game_border { margin:0px; } ' +
6421
6422 '.place_sim_wrap_mods_extended .game_border { height: 139px; overflow-y: auto; overflow-x: hidden; }' + // Größe der Modfikatorbox begrenzen
6423
6424 '#place_simulator .window_inner_curtain { display: none !important } ' + // Hintergrund entfernen bei offener Modifikatorbox
6425
6426 // Unit container
6427 '#simulator_body .unit_container { height: 50px !important; width: 50px !important; margin: 0px 3px 0px 1px !important} ' +
6428 '.place_simulator_odd, .place_simulator_even { text-align: center !important} ' +
6429 '.place_insert_field { margin: 0px !important} ' +
6430
6431 '#place_sim_ground_units { position:absolute; bottom: 35px;} ' +
6432
6433 // Sea unit box
6434 '#place_sim_naval_units { position: absolute; } ' +
6435 '#place_sim_naval_units tbody tr:last-child { height:auto !important; }' +
6436
6437 // Land unit box
6438 '#place_sim_wrap_units { position: absolute !important; bottom: 35px !important} ' +
6439
6440 '#simulator_body>h4 { position:absolute;bottom:188px;} ' +
6441
6442 // Select boxes
6443 '.place_sim_select_gods_wrap { position:absolute; bottom:182px; } ' +
6444
6445 '.place_sim_select_gods_wrap .place_sim_select_gods { width: 150px; } ' +
6446 '.place_sim_select_gods_wrap select { max-width: 120px; } ' +
6447
6448 '.place_sim_select_gods_wrap .place_symbol, .place_sim_select_strategies .place_symbol { margin: 1px 2px 0px 5px !important} ' +
6449 '.place_sim_insert_units .place_symbol { filter: hue-rotate(330deg); -webkit-filter: hue-rotate(330deg);} ' +
6450 '.place_attack { float: left !important} ' +
6451
6452 // Hero box
6453 '.place_sim_heroes_container { position: absolute; right: 0px; z-index: 1; } ' +
6454 '.place_sim_hero_container { width: 45px !important; height: 25px !important} ' +
6455
6456 '#place_simulator .place_sim_bonuses_heroes h4:nth-of-type(2) { display:none; }' + // Heroes title
6457
6458 // - Hero container
6459 '.place_sim_hero_choose, .place_sim_hero_unit_container { height: 26px !important; width: 30px !important} ' +
6460 '#hero_defense_icon, #hero_attack_icon { height: 25px !important; width: 25px !important; margin: 0px !important} ' +
6461 '#hero_defense_dd, #hero_attack_dd { height: 25px !important; width: 25px !important; margin: 1px !important} ' +
6462 '.place_sim_hero_attack, .place_sim_hero_defense { margin-left: 3px !important} ' +
6463 '#hero_attack_text, #hero_defense_text { font-size: 11px !important; bottom: 0px !important} ' +
6464 '.place_sim_heroes_container .plus { left: 2px; top: 2px !important} ' +
6465
6466 '.place_sim_heroes_container .button_new.square { left: 2px !important; } ' +
6467
6468
6469 // - Hero spinner
6470 '.place_sim_heroes_container .spinner { height: 25px !important; width: 40px !important } ' +
6471 '.place_sim_heroes_container td:nth-child(0) { height: 30px !important} ' +
6472 '.place_sim_heroes_container .spinner { height: 24px !important; position:absolute !important; width:12px !important; left:29px !important; '+
6473 'background:url(https://gpall.innogamescdn.com/images/game/border/odd.png) repeat !important; border: 1px solid rgb(107, 107, 107) !important; } ' +
6474 '.place_sim_heroes_container .spinner .button_down, .place_sim_heroes_container .spinner .button_up { bottom: 2px !important; cursor: pointer !important} ' +
6475 '.place_sim_heroes_container .spinner .border_l, .place_sim_heroes_container .spinner .border_r, .place_sim_heroes_container .spinner .body { display:none; } '+
6476
6477 // Quack
6478 '#q_place_sim_lost_res { display: none; } ' +
6479 '</style>').appendTo('head');
6480
6481 if($('#place_simulator').get(0)) {
6482 Simulator.change();
6483 }
6484
6485 SimulatorStrength.activate();
6486
6487 },
6488 deactivate: function () {
6489 $('#dio_simulator_style').remove();
6490 if($('#simu_table').get(0)) {
6491 $('#simu_table').remove();
6492
6493 // Hero box
6494 if ($('.place_sim_heroes_container').get(0)) {
6495 $('.hero_unit').each(function () {
6496 $(this).addClass('unit_icon40x40').removeClass('unit_icon25x25');
6497 });
6498
6499 // Hero spinner
6500 $('.place_sim_heroes_container .spinner').each(function () {
6501 $(this).addClass('place_sim_hero_spinner');
6502 });
6503 }
6504 }
6505
6506 SimulatorStrength.deactivate();
6507 },
6508 change: function () {
6509 // TODO: Durch CSS ersetzen...
6510
6511 // Wall loss
6512 $('.place_sim_wrap_mods tr:eq(1) td:eq(5)').html('<span id="building_place_def_losses_wall_level" class="place_losses bold"></span>');
6513
6514 // Extended modificator box
6515 $('.place_sim_wrap_mods_extended .power').each(function () {
6516 $(this).removeClass("power_icon45x45").addClass("power_icon16x16");
6517 });
6518 $('.place_sim_wrap_mods_extended td:nth-child(even)').each(function () {
6519 $(this).addClass("left_border place_simulator_odd");
6520 });
6521 $('.place_sim_wrap_mods_extended td:nth-child(odd)').each(function () {
6522 $(this).addClass("left_border place_simulator_even");
6523 });
6524
6525 // Border entfernen
6526 $('.place_sim_wrap_mods_extend td:first-child').each(function () {
6527 $(this).removeClass("left_border");
6528 });
6529
6530 // -> Update percentage each time
6531 $('.place_checkbox_field').click(function () {
6532 FightSimulator.closeModsExtended(); //$('.place_sim_bonuses_more_confirm').get(0).click();
6533 });
6534
6535 // Hero world ?
6536 if (uw.Game.hasArtemis) {
6537 $('.place_sim_wrap_mods_extend tr').each(function () {
6538 this.children[1].style.borderLeft = "none";
6539 this.children[0].remove();
6540 });
6541 }
6542
6543 // Hero box
6544 if ($('.place_sim_heroes_container').get(0)) {
6545 $('.hero_unit').each(function () {
6546 $(this).removeClass('unit_icon40x40').addClass('unit_icon25x25');
6547 });
6548
6549 // Hero spinner
6550 $('.place_sim_heroes_container .spinner').each(function () {
6551 $(this).removeClass('place_sim_hero_spinner');
6552 });
6553 }
6554
6555 setStrengthSimulator();
6556 }
6557 };
6558
6559 function afterSimulation() {
6560 var lossArray = {att: {res: 0, fav: 0, pop: 0}, def: {res: 0, fav: 0, pop: 0}},
6561 wall_level = parseInt($('.place_sim_wrap_mods .place_insert_field[name="sim[mods][def][wall_level]"]').val(), 10),
6562 wall_damage = parseInt($('#building_place_def_losses_wall_level').get(0).innerHTML, 10),
6563 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];
6564
6565 // Calculate unit losses
6566 $('#place_sim_ground_units .place_losses, #place_sim_naval_units .place_losses').each(function () {
6567 var loss = parseInt(this.innerHTML, 10) || 0;
6568 //console.log(this.innerHTML);
6569 if (loss > 0) {
6570 var unit = this.id.substring(26);
6571 var side = this.id.split("_")[2]; // att / def
6572 lossArray[side].res += loss * (uw.GameData.units[unit].resources.wood + uw.GameData.units[unit].resources.stone + uw.GameData.units[unit].resources.iron);
6573 lossArray[side].fav += loss * uw.GameData.units[unit].favor;
6574 lossArray[side].pop += loss * uw.GameData.units[unit].population;
6575 }
6576 });
6577 // Calculate wall resource losses
6578 for (var w = wall_level; w > wall_level - wall_damage; w--) {
6579 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
6580 }
6581
6582 // Insert losses into table
6583 for (var x in lossArray) {
6584 if (lossArray.hasOwnProperty(x)) {
6585 for (var z in lossArray[x]) {
6586 if (lossArray[x].hasOwnProperty(z)) {
6587 //console.log(((z === "res") && (lossArray[x][z] > 10000)) ? (Math.round(lossArray[x][z] / 1000) + "k") : lossArray[x][z]);
6588 $("#" + x + "_" + z).get(0).innerHTML = ((z === "res") && (lossArray[x][z] > 10000)) ? (Math.round(lossArray[x][z] / 1000) + "k") : lossArray[x][z];
6589
6590 }
6591 }
6592 }
6593 }
6594 }
6595
6596 // Stärkeanzeige: Simulator
6597 var unitsGround = {att: {}, def: {}}, unitsNaval = {att: {}, def: {}}, name = "";
6598
6599 var SimulatorStrength = {
6600 unitsGround : {att: {}, def: {}},
6601 unitsNaval : {att: {}, def: {}},
6602
6603 activate : function(){
6604 $('<style id="dio_simulator_strength_style">'+
6605 '#dio_simulator_strength { position:absolute; top:192px; font-size:0.8em; width:63%; } '+
6606 '#dio_simulator_strength .ico { height:20px; width:20px; margin:auto; } '+
6607 '#dio_simulator_strength .units_info_sprite { background:url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png); background-size:100%; } ' +
6608
6609 '#dio_simulator_strength .img_hack { background-position:0% 36%; } '+
6610 '#dio_simulator_strength .img_pierce { background-position:0% 27%; } '+
6611 '#dio_simulator_strength .img_dist { background-position:0% 45% !important; } '+
6612 '#dio_simulator_strength .img_ship { background-position:0% 72%; } '+
6613
6614 '#dio_simulator_strength .img_fav { background: url(https://gpall.innogamescdn.com/images/game/res/favor.png) !important; background-size: 100%; } '+
6615 '#dio_simulator_strength .img_res { background: url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png) 0% 54%; background-size: 100%; } '+
6616 '#dio_simulator_strength .img_pop { background: url(https://gpall.innogamescdn.com/images/game/res/pop.png); background-size:100%; } '+
6617
6618 '#dio_simulator_strength .left_border { width: 54px; } '+
6619 '</style>'
6620 ).appendTo('head');
6621
6622 },
6623 deactivate : function(){
6624 $('#dio_simulator_strength_style').remove();
6625 },
6626 add : function(){
6627 $('<div id="dio_simulator_strength">' +
6628 '<div style="float:left; margin-right:12px;"><h4>' + getText("labels", "str") + '</h4>' +
6629 '<table class="place_simulator_table strength" cellpadding="0px" cellspacing="0px" style="align:center;">' +
6630 '<tr>' +
6631 '<td class="place_simulator_even"></td>' +
6632 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_hack"></div></td>' +
6633 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_pierce"></div></td>' +
6634 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_dist"></div></td>' +
6635 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_ship"></div></td>' +
6636 '</tr><tr>' +
6637 '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>' +
6638 '<td class="left_border place_simulator_odd" id="att_b">0</td>' +
6639 '<td class="left_border place_simulator_even" id="att_s">0</td>' +
6640 '<td class="left_border place_simulator_odd" id="att_d">0</td>' +
6641 '<td class="left_border place_simulator_even" id="att_ship">0</td>' +
6642 '</tr><tr>' +
6643 '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
6644 '<td class="left_border place_simulator_odd" id="def_b">0</td>' +
6645 '<td class="left_border place_simulator_even" id="def_s">0</td>' +
6646 '<td class="left_border place_simulator_odd" id="def_d">0</td>' +
6647 '<td class="left_border place_simulator_even" id="def_ship">0</td>' +
6648 '</tr>' +
6649 '</table>' +
6650 '</div><div><h4>' + getText("labels", "los") + '</h4>' +
6651 '<table class="place_simulator_table loss" cellpadding="0px" cellspacing="0px" style="align:center;">' +
6652 '<tr>' +
6653 '<td class="place_simulator_even"></td>' +
6654 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_res"></div></td>' +
6655 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_fav"></div></td>' +
6656 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_pop"></div></td>' +
6657 '</tr><tr>' +
6658 '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>' +
6659 '<td class="left_border place_simulator_odd" id="att_res">0</td>' +
6660 '<td class="left_border place_simulator_even" id="att_fav">0</td>' +
6661 '<td class="left_border place_simulator_odd" id="att_pop">0</td>' +
6662 '</tr><tr>' +
6663 '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
6664 '<td class="left_border place_simulator_odd" id="def_res">0</td>' +
6665 '<td class="left_border place_simulator_even" id="def_fav">0</td>' +
6666 '<td class="left_border place_simulator_odd" id="def_pop">0</td>' +
6667 '</tr>' +
6668 '</table>' +
6669 '</div></div>').appendTo('#simulator_body');
6670
6671
6672 $('#dio_simulator_strength .left_border').each(function () {
6673 $(this)[0].align = 'center';
6674 });
6675
6676 // Tooltips setzen
6677 $('#dio_simulator_strength .strength').tooltip(getText("labels", "str") + " (" + getText("labels", "mod") + ")");
6678 $('#dio_simulator_strength .loss').tooltip(getText("labels", "los"));
6679
6680 // Klick auf Einheitenbild
6681 $('.index_unit').click(function () {
6682 var type = $(this).attr('class').split(" ")[4];
6683 $('.place_insert_field[name="sim[units][att][' + type + ']"]').change();
6684 });
6685
6686 $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').on('input change', function () {
6687 name = $(this).attr("name").replace(/\]/g, "").split("[");
6688 var str = this;
6689
6690
6691 setTimeout(function () {
6692 var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2],
6693 val, e;
6694
6695 val = parseInt($(str).val(), 10);
6696 val = val || 0;
6697
6698 if (unit_type == "ground") {
6699 unitsGround[name[2]][name[3]] = val;
6700
6701 if (name[2] == "def") {
6702 UnitStrength.calcDef(unitsGround.def);
6703 } else {
6704 UnitStrength.calcOff(unitsGround.att, unitsGround.att);
6705 }
6706 $('#' + name[2] + '_b').get(0).innerHTML = blunt;
6707 $('#' + name[2] + '_s').get(0).innerHTML = sharp;
6708 $('#' + name[2] + '_d').get(0).innerHTML = dist;
6709
6710 } else {
6711 var att = 0, def = 0;
6712 unitsNaval[name[2]][name[3]] = val;
6713
6714 if (name[2] == "def") {
6715 for (e in unitsNaval.def) {
6716 if (unitsNaval.def.hasOwnProperty(e)) {
6717 def += unitsNaval.def[e] * uw.GameData.units[e].defense;
6718 }
6719 }
6720 $('#def_ship').get(0).innerHTML = def;
6721
6722 } else {
6723 for (e in unitsNaval.att) {
6724 if (unitsNaval.att.hasOwnProperty(e)) {
6725 att += unitsNaval.att[e] * uw.GameData.units[e].attack;
6726 }
6727 }
6728 $('#att_ship').get(0).innerHTML = att;
6729 }
6730 }
6731 }, 100);
6732 });
6733
6734 // Abfrage wegen eventueller Spionageweiterleitung
6735 getUnitInputs();
6736 setTimeout(function () {
6737 setChangeUnitInputs("def");
6738 }, 100);
6739
6740 $('#select_insert_units').change(function () {
6741 var side = $(this).find('option:selected').val();
6742
6743 setTimeout(function () {
6744 getUnitInputs();
6745 if (side === "att" || side === "def") {
6746 setChangeUnitInputs(side);
6747 }
6748 }, 200);
6749 });
6750 },
6751
6752 getUnitInputs : function(){
6753 $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').each(function () {
6754 var name = $(this).attr("name").replace(/\]/g, "").split("[");
6755
6756 var str = this;
6757
6758 var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2];
6759
6760 var val = parseInt($(str).val(), 10);
6761
6762 val = val || 0;
6763
6764 if (unit_type === "ground") {
6765 SimulatorStrength.unitsGround[name[2]][name[3]] = val;
6766 } else {
6767 SimulatorStrength.unitsNaval[name[2]][name[3]] = val;
6768 }
6769 });
6770 },
6771
6772 updateStrength : function(){
6773
6774 }
6775 }
6776 function setStrengthSimulator() {
6777 $('<div id="dio_simulator_strength">' +
6778 '<div style="float:left; margin-right:12px;"><h4>' + getText("labels", "str") + '</h4>' +
6779 '<table class="place_simulator_table strength" cellpadding="0px" cellspacing="0px" style="align:center;">' +
6780 '<tr>' +
6781 '<td class="place_simulator_even"></td>' +
6782 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_hack"></div></td>' +
6783 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_pierce"></div></td>' +
6784 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_dist"></div></td>' +
6785 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_ship"></div></td>' +
6786 '</tr><tr>' +
6787 '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>' +
6788 '<td class="left_border place_simulator_odd" id="att_b">0</td>' +
6789 '<td class="left_border place_simulator_even" id="att_s">0</td>' +
6790 '<td class="left_border place_simulator_odd" id="att_d">0</td>' +
6791 '<td class="left_border place_simulator_even" id="att_ship">0</td>' +
6792 '</tr><tr>' +
6793 '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
6794 '<td class="left_border place_simulator_odd" id="def_b">0</td>' +
6795 '<td class="left_border place_simulator_even" id="def_s">0</td>' +
6796 '<td class="left_border place_simulator_odd" id="def_d">0</td>' +
6797 '<td class="left_border place_simulator_even" id="def_ship">0</td>' +
6798 '</tr>' +
6799 '</table>' +
6800 '</div><div><h4>' + getText("labels", "los") + '</h4>' +
6801 '<table class="place_simulator_table loss" cellpadding="0px" cellspacing="0px" style="align:center;">' +
6802 '<tr>' +
6803 '<td class="place_simulator_even"></td>' +
6804 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_res"></div></td>' +
6805 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_fav"></div></td>' +
6806 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_pop"></div></td>' +
6807 '</tr><tr>' +
6808 '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>' +
6809 '<td class="left_border place_simulator_odd" id="att_res">0</td>' +
6810 '<td class="left_border place_simulator_even" id="att_fav">0</td>' +
6811 '<td class="left_border place_simulator_odd" id="att_pop">0</td>' +
6812 '</tr><tr>' +
6813 '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
6814 '<td class="left_border place_simulator_odd" id="def_res">0</td>' +
6815 '<td class="left_border place_simulator_even" id="def_fav">0</td>' +
6816 '<td class="left_border place_simulator_odd" id="def_pop">0</td>' +
6817 '</tr>' +
6818 '</table>' +
6819 '</div></div>').appendTo('#simulator_body');
6820
6821
6822 /*
6823 $('#dio_simulator_strength').css({
6824 position: 'absolute',
6825 top: '192px',
6826 fontSize: '0.8em',
6827 width: '63%'
6828 });
6829 $('#dio_simulator_strength .ico').css({
6830 height: '20px',
6831 width: '20px',
6832 margin: 'auto'
6833 });
6834 $('#dio_simulator_strength .units_info_sprite').css({
6835 background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
6836 backgroundSize: '100%'
6837 });
6838 $('#dio_simulator_strength .img_hack').css({backgroundPosition: '0% 36%'});
6839 $('#dio_simulator_strength .img_pierce').css({backgroundPosition: '0% 27%'});
6840 $('#dio_simulator_strength .img_dist').css({backgroundPosition: '0% 45%'});
6841 $('#dio_simulator_strength .img_ship').css({backgroundPosition: '0% 72%'});
6842
6843 $('#dio_simulator_strength .img_fav').css({
6844 background: 'url(https://gpall.innogamescdn.com/images/game/res/favor.png)',
6845 backgroundSize: '100%'
6846 });
6847 $('#dio_simulator_strength .img_res').css({
6848 background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png) 0% 54%',
6849 backgroundSize: '100%'
6850 });
6851 $('#dio_simulator_strength .img_pop').css({
6852 background: 'url(https://gpall.innogamescdn.com/images/game/res/pop.png)',
6853 backgroundSize: '100%'
6854 });
6855
6856 $('#dio_simulator_strength .left_border').css({
6857 width: '54px'
6858 });
6859 */
6860
6861
6862 $('#dio_simulator_strength .left_border').each(function () {
6863 $(this)[0].align = 'center';
6864 });
6865
6866 $('#dio_simulator_strength .strength').tooltip(getText("labels", "str") + " (" + getText("labels", "mod") + ")");
6867 $('#dio_simulator_strength .loss').tooltip(getText("labels", "los"));
6868
6869 // Klick auf Einheitenbild
6870 $('.index_unit').click(function () {
6871 var type = $(this).attr('class').split(" ")[4];
6872 $('.place_insert_field[name="sim[units][att][' + type + ']"]').change();
6873 });
6874
6875 $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').on('input change', function () {
6876 name = $(this).attr("name").replace(/\]/g, "").split("[");
6877 var str = this;
6878 //console.log(str);
6879 setTimeout(function () {
6880 var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2],
6881 val, e;
6882
6883 val = parseInt($(str).val(), 10);
6884 val = val || 0;
6885
6886 if (unit_type == "ground") {
6887 unitsGround[name[2]][name[3]] = val;
6888
6889 if (name[2] == "def") {
6890 UnitStrength.calcDef(unitsGround.def);
6891 } else {
6892 UnitStrength.calcOff(unitsGround.att, unitsGround.att);
6893 }
6894 $('#' + name[2] + '_b').get(0).innerHTML = blunt;
6895 $('#' + name[2] + '_s').get(0).innerHTML = sharp;
6896 $('#' + name[2] + '_d').get(0).innerHTML = dist;
6897
6898 } else {
6899 var att = 0, def = 0;
6900 unitsNaval[name[2]][name[3]] = val;
6901
6902 if (name[2] == "def") {
6903 for (e in unitsNaval.def) {
6904 if (unitsNaval.def.hasOwnProperty(e)) {
6905 def += unitsNaval.def[e] * uw.GameData.units[e].defense;
6906 }
6907 }
6908 $('#def_ship').get(0).innerHTML = def;
6909
6910 } else {
6911 for (e in unitsNaval.att) {
6912 if (unitsNaval.att.hasOwnProperty(e)) {
6913 att += unitsNaval.att[e] * uw.GameData.units[e].attack;
6914 }
6915 }
6916 $('#att_ship').get(0).innerHTML = att;
6917 }
6918 }
6919 }, 100);
6920 });
6921
6922 // Abfrage wegen eventueller Spionageweiterleitung
6923 getUnitInputs();
6924 setTimeout(function () {
6925 setChangeUnitInputs("def");
6926 }, 100);
6927
6928 $('#select_insert_units').change(function () {
6929 var side = $(this).find('option:selected').val();
6930
6931 setTimeout(function () {
6932 getUnitInputs();
6933 if (side === "att" || side === "def") {
6934 setChangeUnitInputs(side);
6935 }
6936 }, 200);
6937 });
6938 }
6939
6940 function getUnitInputs() {
6941 $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').each(function () {
6942 name = $(this).attr("name").replace(/\]/g, "").split("[");
6943
6944 var str = this;
6945
6946 var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2];
6947
6948 var val = parseInt($(str).val(), 10);
6949
6950 val = val || 0;
6951
6952 if (unit_type === "ground") {
6953 unitsGround[name[2]][name[3]] = val;
6954 } else {
6955 unitsNaval[name[2]][name[3]] = val;
6956 }
6957 });
6958 }
6959
6960 function setChangeUnitInputs(side) {
6961 $('.place_insert_field[name="sim[units][' + side + '][godsent]"]').change();
6962 setTimeout(function () {
6963 $('.place_insert_field[name="sim[units][' + side + '][colonize_ship]"]').change();
6964 }, 100);
6965 }
6966
6967 /*******************************************************************************************************************************
6968 * Defense form
6969 * ----------------------------------------------------------------------------------------------------------------------------
6970 * | ● Adds a defense form to the bbcode bar
6971 * ----------------------------------------------------------------------------------------------------------------------------
6972 *******************************************************************************************************************************/
6973
6974 // Funktion aufteilen...
6975 function addForm(e) {
6976 var textareaId = "", bbcodeBarId = "";
6977
6978 switch (e) {
6979 case "/alliance_forum/forum":
6980 textareaId = "#forum_post_textarea";
6981 bbcodeBarId = "#forum";
6982 break;
6983 case "/message/forward":
6984 textareaId = "#message_message";
6985 bbcodeBarId = "#message_bbcodes";
6986 break;
6987 case "/message/new":
6988 textareaId = "#message_new_message";
6989 bbcodeBarId = "#message_bbcodes";
6990 break;
6991 case "/message/view":
6992 textareaId = "#message_reply_message";
6993 bbcodeBarId = "#message_bbcodes";
6994 break;
6995 case "/player_memo/load_memo_content":
6996 textareaId = "#memo_text_area";
6997 bbcodeBarId = "#memo_edit";
6998 break;
6999 }
7000
7001 $('<a title="Verteidigungsformular" href="#" class="dio_bbcode_option def_form" name="def_form"></a>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
7002
7003 $('.def_form_button').css({
7004 cursor: 'pointer',
7005 marginTop: '3px'
7006 });
7007
7008 $(bbcodeBarId + ' .dio_bbcode_option').css({
7009 background: 'url("http://s14.directupload.net/images/140126/lt3hyb8j.png")',
7010 display: 'block',
7011 float: 'left',
7012 width: '22px',
7013 height: '23px',
7014 margin: '0 3px 0 0',
7015 position: 'relative'
7016 });
7017 $(bbcodeBarId + ' .def_form').css({
7018 backgroundPosition: '-89px 0px'
7019 });
7020 var imgArray = {
7021 wall: 'https://gpall.innogamescdn.com/images/game/main/wall.png',
7022 tower: 'https://gpall.innogamescdn.com/images/game/main/tower.png',
7023 hide: 'https://gpall.innogamescdn.com/images/game/main/hide.png',
7024
7025 spy: 'http://s7.directupload.net/images/140114/yr993xwc.png',
7026 pop: 'http://s7.directupload.net/images/140114/4d6xktxm.png',
7027
7028 rev1: 'http://s7.directupload.net/images/140115/9cv6otiu.png',
7029 rev0: 'http://s7.directupload.net/images/140115/aue4rg6i.png',
7030 eo1: 'http://s1.directupload.net/images/140115/fkzlipyh.png',
7031 eo0: 'http://s1.directupload.net/images/140115/hs2kg59c.png',
7032 att: 'http://s1.directupload.net/images/140115/3t6uy4te.png',
7033 sup: 'http://s7.directupload.net/images/140115/ty6szerx.png',
7034
7035 zeus: 'http://s1.directupload.net/images/140114/cdxecrpu.png',
7036 hera: 'http://s1.directupload.net/images/140114/mve54v2o.png',
7037 athena: 'http://s14.directupload.net/images/140114/kyqyedhe.png',
7038 poseidon: 'http://s7.directupload.net/images/140114/tusr9oyi.png',
7039 hades: 'http://s7.directupload.net/images/140114/huins2gn.png',
7040 artemis: 'http://s7.directupload.net/images/140114/kghjhko8.png',
7041 nogod: 'http://s1.directupload.net/images/140114/e7vmvfap.png',
7042
7043 captain: 'http://s14.directupload.net/images/140114/88gg75rc.png',
7044 commander: 'http://s14.directupload.net/images/140114/slbst52o.png',
7045 priest: 'http://s1.directupload.net/images/140114/glptekkx.png',
7046
7047 phalanx: 'http://s7.directupload.net/images/140114/e97wby6z.png',
7048 ram: 'http://s7.directupload.net/images/140114/s854ds3w.png',
7049
7050 militia: 'http://wiki.en.grepolis.com/images/9/9b/Militia_40x40.png',
7051 sword: 'http://wiki.en.grepolis.com/images/9/9c/Sword_40x40.png',
7052 slinger: 'http://wiki.en.grepolis.com/images/d/dc/Slinger_40x40.png',
7053 archer: 'http://wiki.en.grepolis.com/images/1/1a/Archer_40x40.png',
7054 hoplite: 'http://wiki.en.grepolis.com/images/b/bd/Hoplite_40x40.png',
7055 rider: 'http://wiki.en.grepolis.com/images/e/e9/Rider_40x40.png',
7056 chariot: 'http://wiki.en.grepolis.com/images/b/b8/Chariot_40x40.png',
7057 catapult: 'http://wiki.en.grepolis.com/images/f/f0/Catapult_40x40.png',
7058 godsent: 'http://wiki.de.grepolis.com/images/6/6e/Grepolis_Wiki_225.png',
7059
7060 def_sum: 'http://s14.directupload.net/images/140127/6cxnis9r.png',
7061
7062 minotaur: 'http://wiki.de.grepolis.com/images/7/70/Minotaur_40x40.png',
7063 manticore: 'http://wiki.de.grepolis.com/images/5/5e/Manticore_40x40.png',
7064 zyclop: 'http://wiki.de.grepolis.com/images/6/66/Zyklop_40x40.png',
7065 sea_monster: 'http://wiki.de.grepolis.com/images/7/70/Sea_monster_40x40.png',
7066 harpy: 'http://wiki.de.grepolis.com/images/8/80/Harpy_40x40.png',
7067 medusa: 'http://wiki.de.grepolis.com/images/d/db/Medusa_40x40.png',
7068 centaur: 'http://wiki.de.grepolis.com/images/5/53/Centaur_40x40.png',
7069 pegasus: 'http://wiki.de.grepolis.com/images/5/54/Pegasus_40x40.png',
7070 cerberus: 'http://wiki.de.grepolis.com/images/6/67/Zerberus_40x40.png',
7071 fury: 'http://wiki.de.grepolis.com/images/6/67/Erinys_40x40.png',
7072 griffin: 'http://wiki.de.grepolis.com/images/d/d1/Unit_greif.png',
7073 calydonian_boar: 'http://wiki.de.grepolis.com/images/9/93/Unit_eber.png',
7074
7075 big_transporter: 'http://wiki.en.grepolis.com/images/0/04/Big_transporter_40x40.png',
7076 bireme: 'http://wiki.en.grepolis.com/images/4/44/Bireme_40x40.png',
7077 attack_ship: 'http://wiki.en.grepolis.com/images/e/e6/Attack_ship_40x40.png',
7078 demolition_ship: 'http://wiki.en.grepolis.com/images/e/ec/Demolition_ship_40x40.png',
7079 small_transporter: 'http://wiki.en.grepolis.com/images/8/85/Small_transporter_40x40.png',
7080 trireme: 'http://wiki.en.grepolis.com/images/a/ad/Trireme_40x40.png',
7081 colonize_ship: 'http://wiki.en.grepolis.com/images/d/d1/Colonize_ship_40x40.png',
7082
7083 move_icon: 'https://gpall.innogamescdn.com/images/game/unit_overview/',
7084
7085 bordure: 'http://s1.directupload.net/images/140126/8y6pmetk.png'
7086 };
7087
7088 $('<div class="bb_def_chooser">' +
7089 '<div class="bbcode_box middle_center">' +
7090 '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div>' +
7091 '<div class="bbcode_box top_center"></div><div class="bbcode_box bottom_center"></div>' +
7092 '<div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>' +
7093 '<div class="bbcode_box middle_left"></div><div class="bbcode_box middle_right"></div>' +
7094 '<div class="bbcode_box content clearfix" style="padding:5px">' +
7095 '<div id="f_uni" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "det") + '</div></div><br><br>' +
7096 '<div id="f_prm" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "prm") + '</div></div><br><br>' +
7097 '<div id="f_sil" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "sil") + '</div></div><br><br>' +
7098 '<div id="f_mov" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "mov") + '</div></div><br><br>' +
7099 '<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>' +
7100 '</div></div></div>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
7101
7102 $('.bb_def_chooser').css({
7103 display: 'none',
7104 top: '38px',
7105 left: '510px',
7106 position: 'absolute',
7107 width: '190px',
7108 zIndex: 10000
7109 });
7110
7111 $(bbcodeBarId + " .bb_def_chooser .checkbox_new").click(function () {
7112 $(this).toggleClass("checked");
7113 });
7114
7115 $(bbcodeBarId + ' .def_form').toggleClick(function () {
7116 $(this).parent().find(".bb_def_chooser").get(0).style.display = "block";
7117 }, function () {
7118 $(this).parent().find(".bb_def_chooser").get(0).style.display = "none";
7119 });
7120
7121 $(bbcodeBarId + ' #dio_insert').click(function () {
7122 var textarea = $(textareaId).get(0), text = $(textarea).val(), troop_table = "", troop_img = "", troop_count = "", separator = "", move_table = "", landunit_sum = 0;
7123
7124 $('.def_form').click();
7125
7126 if ($('#f_uni').hasClass("checked")) {
7127 $('.units_land .unit, .units_naval .unit').each(function () {
7128 troop_img += separator + '[img]' + imgArray[this.className.split(" ")[1]] + '[/img]';
7129 troop_count += separator + '[center]' + $(this).find(".value").get(0).innerHTML + '[/center]';
7130 separator = "[||]";
7131 });
7132 } else {
7133 $('.units_land .unit').each(function () {
7134 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);
7135 if (def > 10) {
7136 landunit_sum += parseInt($(this).find(".value").get(0).innerHTML, 10) * uw.GameData.units[a].population * ((def > 20) ? 2 : 1);
7137 }
7138 });
7139 landunit_sum = (landunit_sum > 10000) ? ((Math.round(landunit_sum / 100)) / 10) + "k" : landunit_sum;
7140
7141 troop_img += '[img]' + imgArray.def_sum + '[/img]';
7142 troop_count += '[center]' + landunit_sum + '[/center]';
7143 separator = "[||]";
7144 $('.units_naval .unit').each(function () {
7145 troop_img += separator + '[img]' + imgArray[this.className.split(" ")[1]] + '[/img]';
7146 troop_count += separator + '[center]' + $(this).find(".value").get(0).innerHTML + '[/center]';
7147 });
7148 }
7149 if (troop_img !== "") {
7150 troop_table = "\n[table][**]" + troop_img + "[/**][**]" + troop_count + "[/**][/table]\n";
7151 }
7152
7153 var str = '[img]' + imgArray.bordure + '[/img]' +
7154 '\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' +
7155 //'[table][**][img]'+ imgArray.sup +'[/img][||]'+
7156 '[size=12][town]' + uw.ITowns.getTown(uw.Game.townId).getId() + '[/town] ([player]' + uw.Game.player_name + '[/player])[/size]' +
7157 //'[||][img]'+ imgArray['rev' + (uw.ITowns.getTown(uw.Game.townId).hasConqueror()?1:0)] +'[/img][/**][/table]'+
7158 '\n\n[i][b]' + getText("labels", "inf") + '[/b][/i]' + troop_table +
7159 '[table][*]' +
7160 '[img]' + imgArray.wall + '[/img][|]\n' +
7161 '[img]' + imgArray.tower + '[/img][|]\n' +
7162 '[img]' + imgArray.phalanx + '[/img][|]\n' +
7163 '[img]' + imgArray.ram + '[/img][|]\n' +
7164 ($('#f_prm').hasClass("checked") ? '[img]' + imgArray.commander + '[/img][|]\n' : ' ') +
7165 ($('#f_prm').hasClass("checked") ? '[img]' + imgArray.captain + '[/img][|]\n' : ' ') +
7166 ($('#f_prm').hasClass("checked") ? '[img]' + imgArray.priest + '[/img][|]\n' : ' ') +
7167 ($('#f_sil').hasClass("checked") ? '[center][img]' + imgArray.spy + '[/img][/center][|]\n' : ' ') +
7168 '[img]' + imgArray.pop + '[/img][|]\n' +
7169 '[img]' + imgArray[(uw.ITowns.getTown(uw.Game.townId).god() || "nogod")] + '[/img][/*]\n' +
7170 '[**][center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("wall") + '[/center][||]' +
7171 '[center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("tower") + '[/center][||]' +
7172 '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.phalanx ? '+' : '-') + '[/center][||]' +
7173 '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.ram ? '+' : '-') + '[/center][||]' +
7174 ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.commander >= uw.Timestamp.now()) ? '+' : '-') + '[/center][||]' : ' ') +
7175 ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.captain >= uw.Timestamp.now()) ? '+' : '-') + '[/center][||]' : ' ') +
7176 ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.priest >= uw.Timestamp.now()) ? '+' : '-') + '[/center][||]' : ' ') +
7177 ($('#f_sil').hasClass("checked") ? '[center]' + Math.round(uw.ITowns.getTown(uw.Game.townId).getEspionageStorage() / 1000) + 'k[/center][||]' : ' ') +
7178 '[center]' + uw.ITowns.getTown(uw.Game.townId).getAvailablePopulation() + '[/center][||]' +
7179 '[center]' + $('.gods_favor_amount').get(0).innerHTML + '[/center]' +
7180 '[/**][/table]';
7181
7182 var bb_count_str = parseInt(str.match(/\[/g).length, 10), bb_count_move = 0;
7183
7184 var i = 0;
7185 if ($('#f_mov').hasClass("checked")) {
7186 move_table += '\n[i][b]' + getText("labels", "mov") + '[/b][/i]\n[table]';
7187
7188 $('#toolbar_activity_commands').mouseover();
7189
7190 $('#toolbar_activity_commands_list .content .command').each(function () {
7191 var cl = $(this).children()[0].className.split(" ");
7192 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)) {
7193 move_table += (i % 1) ? "" : "[**]";
7194 i++;
7195 move_table += "[img]" + imgArray.move_icon + cl[2] + ".png[/img][||]";
7196 move_table += getArrivalTime($(this).children()[1].innerHTML) + (uw.Game.market_id === "de" ? " Uhr[||]" : " [||]");
7197 move_table += "[town]" + JSON.parse(atob($(this).children()[2].firstChild.href.split("#")[1])).id + "[/town]";
7198 move_table += (i % 1) ? "[||]" : "[/**]";
7199 }
7200 bb_count_move = parseInt(move_table.match(/\[/g).length, 10);
7201 });
7202 if ((bb_count_str + bb_count_move) > 480) {
7203 move_table += '[**]...[/**]';
7204 }
7205
7206 $('#toolbar_activity_commands').mouseout();
7207
7208 //console.log((bb_count_str + bb_count_move));
7209 move_table += (i % 1) ? "[/**]" : "";
7210 move_table += "[*][|][color=#800000][size=6][i] (" + getText("labels", "dev") + ": ±1s)[/i][/size][/color][/*][/table]\n";
7211 }
7212
7213 str += move_table + '[img]' + imgArray.bordure + '[/img]';
7214
7215
7216 $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + str + text.substring($(textarea).get(0).selectionEnd));
7217 });
7218 }
7219
7220 function getArrivalTime(duration_time) {
7221 /*
7222 var server_time = new Date((uw.Timestamp.server() + 7200) * 1000);
7223
7224 duration_time = duration_time.split(":");
7225
7226 s = server_time.getUTCSeconds() + parseInt(duration_time[2], 10);
7227 m = server_time.getUTCMinutes() + parseInt(duration_time[1], 10) + ((s>=60)? 1 : 0);
7228 h = server_time.getUTCHours() + parseInt(duration_time[0], 10) + ((m>=60)? 1 : 0);
7229 */
7230
7231 var server_time = $('.server_time_area').get(0).innerHTML.split(" ")[0].split(":"), arrival_time, s, m, h;
7232 duration_time = duration_time.split(":");
7233
7234 s = parseInt(server_time[2], 10) + parseInt(duration_time[2], 10);
7235 m = parseInt(server_time[1], 10) + parseInt(duration_time[1], 10) + ((s >= 60) ? 1 : 0);
7236 h = parseInt(server_time[0], 10) + parseInt(duration_time[0], 10) + ((m >= 60) ? 1 : 0);
7237
7238 s = s % 60;
7239 m = m % 60;
7240 h = h % 24;
7241
7242 s = ((s < 10) ? "0" : "") + s;
7243 m = ((m < 10) ? "0" : "") + m;
7244 h = ((h < 10) ? "0" : "") + h;
7245
7246 arrival_time = h + ":" + m + ":" + s;
7247
7248 return arrival_time;
7249 }
7250
7251
7252 /*******************************************************************************************************************************
7253 * Smiley box
7254 * ----------------------------------------------------------------------------------------------------------------------------
7255 * | ● Display of a smiley selection box for text input fields (forum, messages, notes):
7256 * | ● Used smileys: http://www.greensmilies.com/smilie-album/
7257 * | + Own Grepolis smileys
7258 * ----------------------------------------------------------------------------------------------------------------------------
7259 *******************************************************************************************************************************/
7260
7261 var smileyArray = {};
7262
7263 var SmileyBox = {
7264 loading_error: false, isHalloween: false, isXmas: false, isForum: $(".editor_textbox_container").get(0),
7265
7266 activate: function () {
7267 $('<style id="dio_smiley">' +
7268 '.smiley_button { cursor:pointer; margin:3px 2px 2px 2px; } ' +
7269
7270 '.smiley_box.game { z-index:5000; position:absolute; top:27px; left:430px; min-width:300px; display:none; } ' +
7271
7272 // Smiley categories
7273 '.smiley_box .box_header { display: table; width: 100%; text-align:center; } ' +
7274 '.smiley_box .group { display:table-cell; color: #0c450c; cursor: pointer; font-weight:bold; padding: 0px 2px 0px 2px; } ' +
7275 '.smiley_box .group.active { color: #089421; text-decoration:underline;} ' +
7276 '.smiley_box .group:hover { color: #14999E; } ' + // #11AD6C
7277
7278 // Special smiley categories
7279 '.smiley_box .halloween { color: #E25E00; } ' +
7280 '.smiley_box .xmas { color: darkred; } ' +
7281
7282 '.smiley_box hr { margin:3px 0px 0px 0px; color:#086b18; border:1px solid; } ' +
7283
7284 // Smilies
7285 '.smiley_box .box_content { overflow: hidden; } ' +
7286 '.smiley_box .box_content .smiley { border: 1px solid rgba(0,0,0,0); border-radius: 5px;} ' +
7287 '.smiley_box .box_content .smiley:hover { background: rgba(8, 148, 77, 0.2); border: 1px solid rgba(0, 128, 0, 0.5); } ' +
7288
7289 // Smiley page link
7290 '.smiley_box .box_footer { text-align:center; margin-top:4px; } ' +
7291 '.smiley_box a:link, .smiley_box a:visited { color: #086b18; font-size: 0.7em; } ' +
7292 '.smiley_box a:hover { color: #14999E; } ' +
7293
7294 // TODO Forum ...
7295 '.smiley_box.forum .box_header_left { float:left; } ' +
7296 //'.smiley_box.forum .group { padding-right: 10px; } '+
7297 '.smiley_box.forum .box_header_right { text-align:right; margin-top:2px; } ' +
7298
7299 '.smiley_box.forum { max-height:90px; margin-left:5px; width:99%; min-height:10px; } ' +
7300 '.smiley_box.forum .box_content { overflow:overlay; min-height:70px; margin-bottom:10px; } ' +
7301
7302 '.smiley_box.forum a:link, .smiley_box.forum a:visited { font-size: 1em; } ' +
7303
7304 '</style>').appendTo('head');
7305
7306
7307 // Smiley categories
7308 smileyArray.button = ["rollsmiliey", "smile"];
7309
7310 smileyArray.standard = [
7311 "smilenew", "grin", "lol", "neutral_new", "afraid", "freddus_pacman", "auslachen2", "kolobok-sanduhr", "bussi2", "winken4", "flucht2", "panik4", "ins-auge-stechen",
7312 "seb_zunge", "fluch4_GREEN", "baby_junge2", "blush-reloaded6", "frown", "verlegen", "blush-pfeif", "stevieh_rolleyes", "daumendreh2", "baby_taptap",
7313 "sadnew", "hust", "confusednew", "idea2", "irre", "irre4", "sleep", "candle", "nicken", "no_sad",
7314 "thumbs-up_new", "thumbs-down_new", "bravo2", "oh-no2", "kaffee2", "drunk", "saufen", "freu-dance", "hecheln", "headstand", "rollsmiliey", "eazy_cool01", "motz", "cuinlove", "biggrin"
7315 ];
7316 smileyArray.nature = [
7317 "dinosaurier07", "flu-super-gau", "ben_cat", "schwein", "hundeleine01", "blume", "ben_sharky", "ben_cow", "charly_bissig", "gehirnschnecke_confused", "mttao_fische", "mttao_angler",
7318 "insel", "fliegeschnappen", "spider", /* Spinne */ "shipwrecked", /* Schiffbrüchiger */ "plapperhase", "ben_dumbo"
7319 ];
7320 smileyArray.grepolis = [
7321 "mttao_wassermann", "hera", /* Hera */ "medusa", /* Medusa */ "manticore", /* Mantikor */ "cyclops", /* Zyklop */
7322 "minotaur", /* Minotaurus */ "pegasus", /* Pegasus */ "hydra", /* Hydra */
7323 "silvester_cuinlove", "mttao_schuetze", "kleeblatt2", "wallbash", /* "glaskugel4", */ "musketiere_fechtend", /* "krone-hoch",*/ "viking", // Wikinger
7324 "mttao_waage2", "steckenpferd", /* "kinggrin_anbeten2", */ "grepolove", /* Grepo Love */ "skullhaufen", "pferdehaufen" // "i/ckajscggscw4s2u60"
7325 ];
7326 smileyArray.people = [
7327 "seb_hut5", "opa_boese2", "star-wars-yoda1-gruen", "hexefliegend", "snob", "seb_detektiv_ani", "seb_cowboy", "devil", "segen", "pirat5", "borg", "hexe3b",
7328 "pharaoh", "hippie", "eazy_polizei", "stars_elvis", "mttao_chefkoch", "nikolaus", "pirate3_biggrin", "batman_skeptisch", "tubbie1", "tubbie2", "tubbie3", "tubbie4"
7329 ];
7330 smileyArray.other = [
7331 "steinwerfen", "herzen02", "scream-if-you-can", "kolobok", "headbash", "liebeskummer", "bussi", "brautpaar-reis", "grab-schaufler2", "boxen2", "aufsmaul",
7332 "sauf", "mttao_kehren", "sm", "weckruf", "klugscheisser2", "karte2_rot", "dagegen", "party", "dafuer", "outofthebox", "pokal_gold", "koepfler", "transformer"
7333 ];
7334
7335 // TODO: HolidayChecker benutzen!
7336 SmileyBox.checkHolidaySeason();
7337
7338 if (SmileyBox.isHalloween) {
7339 smileyArray.halloween = [
7340 "zombies_alien", "zombies_lol", "zombies_rolleyes", "zombie01", "zombies_smile", "zombie02", "zombies_skeptisch", "zombies_eek", "zombies_frown",
7341 "scream-if-you-can", "geistani", "pfeildurchkopf01", "grab-schaufler", "kuerbisleuchten", "mummy3",
7342 "kuerbishaufen", "halloweenskulljongleur", "fledermausvampir", "frankenstein_lol", "halloween_confused", "zombies_razz",
7343 "halloweenstars_freddykrueger", "zombies_cool", "geist2", "fledermaus2", "halloweenstars_dracula"
7344 // "batman" "halloweenstars_lastsummer"
7345 ];
7346 }
7347 if (SmileyBox.isXmas) {
7348 smileyArray.xmas = [
7349 "schneeballwerfen", "schneeball", "xmas4_advent4", "nikolaus", "weihnachtsmann_junge", "schneewerfen_wald", "weihnachtsmann_nordpol", "xmas_kilroy_kamin",
7350 "xmas4_laola", "xmas4_aufsmaul", "xmas3_smile", "xmas4_paketliebe", "mttao_ruprecht_peitsche", "3hlkoenige", "santa", "xmas4_hurra2", "weihnachtsgeschenk2", "fred_weihnachten-ostern"
7351 //"dafuer", "outofthebox", "pokal_gold", "koepfler", "transformer"
7352 ];
7353 }
7354
7355 //smileyArray.other = smileyArray.halloween.slice();
7356
7357 // Forum: Extra smiley
7358 if (SmileyBox.isForum) {
7359 smileyArray.grepolis.push("i/ckajscggscw4s2u60"); // Pacman
7360 smileyArray.grepolis.push("i/cowqyl57t5o255zli"); // Bugpolis
7361 smileyArray.grepolis.push("i/cowquq2foog1qrbee"); // Inno
7362 }
7363
7364 SmileyBox.loadSmileys();
7365 },
7366 deactivate: function () {
7367 $('#dio_smiley').remove();
7368 },
7369 checkHolidaySeason: function () {
7370 // TODO: HolidaySpecial-Klasse stattdessen benutzen
7371 var daystamp = 1000 * 60 * 60 * 24, today = new Date((new Date()) % (daystamp * (365 + 1 / 4))), // without year
7372
7373 // Halloween-Smileys ->15 days
7374 halloween_start = daystamp * 297, // 25. Oktober
7375 halloween_end = daystamp * 321, // 8. November
7376 // Xmas-Smileys -> 28 Tage
7377 xmas_start = daystamp * 334, // 1. Dezember
7378 xmas_end = daystamp * 361; // 28. Dezember
7379
7380 SmileyBox.isHalloween = (today >= halloween_start) ? (today <= halloween_end) : false;
7381
7382 SmileyBox.isXmas = (today >= xmas_start) ? (today <= xmas_end) : false;
7383 },
7384 // preload images
7385 loadSmileys: function () {
7386 // Replace german sign smilies
7387 if (LID !== "de") {
7388 smileyArray.other[17] = "dagegen2";
7389 smileyArray.other[19] = "dafuer2";
7390 }
7391
7392 for (var e in smileyArray) {
7393 if (smileyArray.hasOwnProperty(e)) {
7394 for (var f in smileyArray[e]) {
7395 if (smileyArray[e].hasOwnProperty(f)) {
7396 var src = smileyArray[e][f];
7397
7398 smileyArray[e][f] = new Image();
7399 smileyArray[e][f].className = "smiley";
7400
7401 if (src.substring(0, 2) == "i/") {
7402 smileyArray[e][f].src = "http://666kb.com/" + src + ".gif";
7403 } else {
7404 if (SmileyBox.loading_error == false) {
7405 smileyArray[e][f].src = "https://diotools.de/images/smileys/"+ e +"/smiley_emoticons_" + src + ".gif";
7406 //console.debug("Smiley", e);
7407 } else {
7408 smileyArray[e][f].src = 'http://s1.directupload.net/images/140128/93x3p4co.gif';
7409 }
7410 }
7411 smileyArray[e][f].onerror = function () {
7412 this.src = 'http://s1.directupload.net/images/140128/93x3p4co.gif';
7413 };
7414 }
7415 }
7416 }
7417 }
7418 },
7419
7420 // Forum smilies
7421 changeForumEditorLayout: function () {
7422 $('.blockrow').css({border: "none"});
7423
7424 // Subject/Title
7425 $($('.section div label[for="title"]').parent()).css({float: "left", width: "36%", marginRight: "20px"});
7426 $($('.section div label[for="subject"]').parent()).css({float: "left", width: "36%", marginRight: "20px"});
7427
7428 $('.section div input').eq(0).css({marginBottom: "-10px", marginTop: "10px"});
7429 $('#display_posticon').remove();
7430
7431 // Posticons
7432 $('.posticons table').css({width: "50%" /* marginTop: "-16px"*/});
7433 $('.posticons').css({marginBottom: "-16px"});
7434 $('.posticons').insertAfter($('.section div label[for="title"]').parent());
7435 $('.posticons').insertAfter($('.section div label[for="subject"]').parent());
7436 // Posticons hint
7437 $('.posticons p').remove();
7438 // Posticons: No Icon - radio button
7439 $(".posticons [colspan='14']").parent().replaceWith($(".posticons [colspan='14']"));
7440 $(".posticons [colspan='14']").children().wrap("<nobr></nobr>");
7441 $(".posticons [colspan='14']").appendTo('.posticons tr:eq(0)');
7442 $(".posticons [colspan='4']").remove();
7443 },
7444
7445 addForum: function () {
7446 $('<div class="smiley_box forum"><div>' +
7447 '<div class="box_header_left">' +
7448 '<span class="group standard active">' + getText("labels", "std") + '</span>' +
7449 '<span class="group grepolis">' + getText("labels", "gre") + '</span>' +
7450 '<span class="group nature">' + getText("labels", "nat") + '</span>' +
7451 '<span class="group people">' + getText("labels", "ppl") + '</span>' +
7452 '<span class="group other">' + getText("labels", "oth") + '</span>' +
7453 (SmileyBox.isHalloween ? '<span class="group halloween">' + getText("labels", "hal") + '</span>' : '') +
7454 (SmileyBox.isXmas ? '<span class="group xmas">' + getText("labels", "xma") + '</span>' : '') +
7455 '</div>' +
7456 '<div class="box_header_right"><a class="smiley_link" href="http://www.greensmilies.com/smilie-album/" target="_blank">WWW.GREENSMILIES.COM</a></div>' +
7457 '<hr>' +
7458 '<div class="box_content" style="overflow: hidden;"><hr></div>' +
7459 '</div></div><br>').insertAfter(".texteditor");
7460
7461 SmileyBox.addSmileys("standard", "");
7462
7463 $('.group').click(function () {
7464 $('.group.active').removeClass("active");
7465 $(this).addClass("active");
7466 // Change smiley group
7467 SmileyBox.addSmileys(this.className.split(" ")[1], "");
7468 });
7469 },
7470
7471 // add smiley box
7472 add: function (e) {
7473 var bbcodeBarId = "";
7474 switch (e) {
7475 case "/alliance_forum/forum":
7476 bbcodeBarId = "#forum";
7477 break;
7478 case "/message/forward":
7479 bbcodeBarId = "#message_bbcodes";
7480 break;
7481 case "/message/new":
7482 bbcodeBarId = "#message_bbcodes";
7483 break;
7484 case "/message/view":
7485 bbcodeBarId = "#message_bbcodes";//setWonderIconsOnMap
7486 break;
7487 case "/player_memo/load_memo_content":
7488 bbcodeBarId = "#memo_edit"; // old notes
7489 break;
7490 case "/frontend_bridge/fetch":
7491 bbcodeBarId = ".notes_container"; // TODO: new notes
7492 break;
7493 }
7494 if (($(bbcodeBarId + ' #emots_popup_7').get(0) || $(bbcodeBarId + ' #emots_popup_15').get(0)) && PID == 84367) {
7495 $(bbcodeBarId + " .bb_button_wrapper").get(0).lastChild.remove();
7496 }
7497 $('<img class="smiley_button" src="http://www.greensmilies.com/smile/smiley_emoticons_smile.gif">').appendTo(bbcodeBarId + ' .bb_button_wrapper');
7498
7499 $('<div class="smiley_box game">' +
7500 '<div class="bbcode_box middle_center"><div class="bbcode_box middle_right"></div><div class="bbcode_box middle_left"></div>' +
7501 '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div><div class="bbcode_box top_center"></div>' +
7502 '<div class="bbcode_box bottom_center"></div><div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>' +
7503 '<div class="box_header">' +
7504 '<span class="group standard active">' + getText("labels", "std") + '</span>' +
7505 '<span class="group grepolis">' + getText("labels", "gre") + '</span>' +
7506 '<span class="group nature">' + getText("labels", "nat") + '</span>' +
7507 '<span class="group people">' + getText("labels", "ppl") + '</span>' +
7508 '<span class="group ' + (SmileyBox.isHalloween ? 'halloween' : (SmileyBox.isXmas ? 'xmas' : 'other')) + '">' + getText("labels", (SmileyBox.isHalloween ? 'hal' : (SmileyBox.isXmas ? 'xma' : 'oth'))) + '</span>' +
7509 '</div>' +
7510 '<hr>' +
7511 '<div class="box_content"></div>' +
7512 '<hr>' +
7513 '<div class="box_footer"><a href="http://www.greensmilies.com/smilie-album/" target="_blank">WWW.GREENSMILIES.COM</a></div>' +
7514 '</div>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
7515
7516
7517 $(bbcodeBarId + ' .group').click(function () {
7518 $('.group.active').removeClass("active");
7519 $(this).addClass("active");
7520 // Change smiley group
7521 SmileyBox.addSmileys(this.className.split(" ")[1], "#" + $(this).closest('.bb_button_wrapper').parent().get(0).id);
7522 });
7523
7524 SmileyBox.addSmileys("standard", bbcodeBarId);
7525
7526 // smiley box toggle
7527 $(bbcodeBarId + " .smiley_button").toggleClick(
7528 function () {
7529 this.src = smileyArray.button[0].src;
7530 $(this).closest('.bb_button_wrapper').find(".smiley_box").get(0).style.display = "block";
7531 },
7532 function () {
7533 this.src = smileyArray.button[1].src;
7534 $(this).closest('.bb_button_wrapper').find(".smiley_box").get(0).style.display = "none";
7535 }
7536 );
7537 },
7538
7539 // insert smileys from arrays into smiley box
7540 addSmileys: function (type, bbcodeBarId) {
7541 // reset smilies
7542 if ($(bbcodeBarId + " .box_content").get(0)) {
7543 $(bbcodeBarId + " .box_content").get(0).innerHTML = '';
7544 }
7545 // add smilies
7546 for (var e in smileyArray[type]) {
7547 if (smileyArray[type].hasOwnProperty(e)) {
7548 $(smileyArray[type][e]).clone().appendTo(bbcodeBarId + " .box_content");
7549 //$('<img class="smiley" src="' + smileyArray[type][e].src + '" alt="" />').appendTo(bbcodeBarId + " .box_content");
7550 }
7551 }
7552 $('.smiley').css({margin: '0px', padding: '2px', maxHeight: '35px', cursor: 'pointer'});
7553
7554 $(bbcodeBarId + " .box_content .smiley").click(function () {
7555 var textarea;
7556 if (uw.location.pathname.indexOf("game") >= 0) {
7557 // hide smiley box
7558 $(this).closest('.bb_button_wrapper').find(".smiley_button").click();
7559 // find textarea
7560 textarea = $(this).closest('.gpwindow_content').find("textarea").get(0);
7561 } else {
7562
7563 if ($('.editor_textbox_container').get(0)) {
7564 textarea = $('.editor_textbox_container .cke_contents textarea').get(0);
7565 } else {
7566 $(this).appendTo('iframe .forum');
7567 }
7568 }
7569 var text = $(textarea).val();
7570 $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + "[img]" + this.src + "[/img]" + text.substring($(textarea).get(0).selectionEnd));
7571 });
7572 }
7573 };
7574
7575
7576 /*******************************************************************************************************************************
7577 * Biremes counter
7578 * ----------------------------------------------------------------------------------------------------------------------------
7579 * | ● Incremental update when calling a city (experimental, especially intended for siege worlds)
7580 * ----------------------------------------------------------------------------------------------------------------------------
7581 * @deprecated
7582 * *****************************************************************************************************************************/
7583
7584 // TODO: Altes Feature entfernen
7585 var BiremeCounter = {
7586 activate: function () {
7587 $(".picomap_container").prepend("<div id='available_units'><div id='bi_count'></div></div>");
7588
7589 $('.picomap_overlayer').tooltip(getText("options", "bir")[0]);
7590 BiremeCounter.update();
7591
7592 // Style
7593 $('<style id="dio_bireme_counter">' +
7594 '#available_units { background: url(https://gpall.innogamescdn.com/images/game/units/units_sprite_90x90_compressed.jpg); height:90px;' +
7595 'width:90px; position: relative; margin: 5px 28px 0px 28px; background-position: -270px 0px; } ' +
7596 '#bi_count { color:#826021; position:relative; top:28px; font-style:italic; width:79px; } ' +
7597 '#sea_id { background: none; font-size:25px; cursor:default; height:50px; width:50px; position:absolute; top:70px; left:157px; z-index: 30; } ' +
7598 '</style>').appendTo('head');
7599
7600 // fs_count: color: #FFC374;position: relative;top: 30px;font-style: italic;width: 101px;text-shadow: 1px 1px 0px rgb(69, 0, 0);
7601 // manti: background-position: -1350px 180px;
7602 // manti-count: color: #ECD181;position: relative;top: 48px;font-style: italic;width: 52px;text-shadow: 2px 2px 0px rgb(0, 0, 0);
7603 // medusa:-1440px 182px;
7604 // med-count: color: #DEECA4;position: relative;top: 50px;font-style: italic;width: 55px;text-shadow: 2px 2px 0px rgb(0, 0, 0);
7605
7606 // Set Sea-ID beside the bull eye
7607 $('#sea_id').prependTo('#ui_box');
7608 },
7609 deactivate: function () {
7610 $('#available_units').remove();
7611 $('#dio_bireme_counter').remove();
7612 $('#sea_id').appendTo('.picomap_container');
7613 },
7614 save: function () {
7615 saveValue(WID + "_biremes", JSON.stringify(biriArray));
7616 },
7617 update: function () {
7618 var sum = 0, e;
7619 if ($('#bi_count').get(0)) {
7620 for (e in biriArray) {
7621 if (biriArray.hasOwnProperty(e)) {
7622 if (!uw.ITowns.getTown(e)) { // town is no longer in possession of user
7623 delete biriArray[e];
7624 BiremeCounter.save();
7625 } else {
7626 sum += parseInt(biriArray[e], 10);
7627 }
7628 }
7629 }
7630
7631 sum = sum.toString();
7632 var str = "", fsize = ['1.4em', '1.2em', '1.15em', '1.1em', '1.0em'], i;
7633
7634 for (i = 0; i < sum.length; i++) {
7635 str += "<span style='font-size:" + fsize[i] + "'>" + sum[i] + "</span>";
7636 }
7637 $('#bi_count').get(0).innerHTML = "<b>" + str + "</b>";
7638 }
7639 },
7640 get: function () {
7641 var biremeIn = parseInt(uw.ITowns.getTown(uw.Game.townId).units().bireme, 10),
7642 biremeOut = parseInt(uw.ITowns.getTown(uw.Game.townId).unitsOuter().bireme, 10);
7643 if (isNaN(biremeIn)) biremeIn = 0;
7644 if (isNaN(biremeOut)) biremeOut = 0;
7645 if (!biriArray[uw.Game.townId] || biriArray[uw.Game.townId] < (biremeIn + biremeOut)) {
7646 biriArray[uw.Game.townId] = biremeIn;
7647 }
7648 BiremeCounter.update();
7649 BiremeCounter.save();
7650 },
7651 getDocks: function () {
7652 var windowID = uw.BuildingWindowFactory.getWnd().getID(),
7653 biremeTotal = parseInt($('#gpwnd_' + windowID + ' #unit_order_tab_bireme .unit_order_total').get(0).innerHTML, 10);
7654
7655 if (!isNaN(biremeTotal)) biriArray[uw.Game.townId] = biremeTotal;
7656 BiremeCounter.update();
7657 BiremeCounter.save();
7658 },
7659 getAgora: function () {
7660 var biremeTotal = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().bireme, 10);
7661 if (isNaN(biremeTotal)) biremeTotal = 0;
7662
7663 $('#units_beyond_list .bireme').each(function () {
7664 biremeTotal += parseInt(this.children[0].innerHTML, 10);
7665 });
7666 biriArray[uw.Game.townId] = biremeTotal;
7667 BiremeCounter.update();
7668 BiremeCounter.save();
7669 }
7670 };
7671
7672 /*******************************************************************************************************************************
7673 * Favor Popup
7674 * ----------------------------------------------------------------------------------------------------------------------------
7675 * | ● Improved favor popup
7676 * ----------------------------------------------------------------------------------------------------------------------------
7677 *******************************************************************************************************************************/
7678 var FavorPopup = {
7679 godArray: {
7680 zeus: '0px',
7681 hera: '-152px',
7682 poseidon: '-101px',
7683 athena: '-50px',
7684 hades: '-203px',
7685 artemis: '-305px'
7686 }, godImg: (new Image()).src = "https://diotools.de/images/game/gods.png",
7687
7688 activate: function () {
7689 $('.gods_favor_button_area, #favor_circular_progress').bind('mouseover mouseout', function () {
7690 return false;
7691 });
7692 $('.gods_area').bind('mouseover', function () {
7693 FavorPopup.setFavorPopup();
7694 });
7695 },
7696
7697 deactivate: function () {
7698 $('.gods_favor_button_area, #favor_circular_progress').unbind('mouseover mouseout');
7699 $('.gods_area').unbind('mouseover');
7700 },
7701
7702 setFavorPopup: function () {
7703 var pic_row = "", fav_row = "", prod_row = "", tooltip_str;
7704
7705 for (var g in FavorPopup.godArray) {
7706 if (FavorPopup.godArray.hasOwnProperty(g)) {
7707 if (uw.ITowns.player_gods.attributes.temples_for_gods[g]) {
7708 pic_row += '<td><div style="width:50px;height:51px;background:url(' + FavorPopup.godImg + ');background-position: 0px ' + FavorPopup.godArray[g] + ';"></td>';
7709 fav_row += '<td class="bold" style="color:blue">' + uw.ITowns.player_gods.attributes[g + "_favor"] + '</td>';
7710 prod_row += '<td class="bold">' + uw.ITowns.player_gods.attributes.production_overview[g].production + '</td>';
7711 }
7712 }
7713 }
7714 tooltip_str = $('<table><tr><td></td>' + pic_row + '</tr>' +
7715 '<tr align="center"><td><img src="https://gpall.innogamescdn.com/images/game/res/favor.png"></td>' + fav_row + '</tr>' +
7716 '<tr align="center"><td>+</td>' + prod_row + '</tr>' +
7717 '</table>');
7718
7719 $('.gods_favor_button_area, #favor_circular_progress').tooltip(tooltip_str);
7720 }
7721 };
7722
7723 /*******************************************************************************************************************************
7724 * GUI Optimization
7725 * ----------------------------------------------------------------------------------------------------------------------------
7726 * | ● Modified spell box (smaller, moveable & position memory)
7727 * | ● Larger taskbar and minimize daily reward-window on startup
7728 * | ● Modify chat
7729 * | ● Improved display of troops and trade activity boxes (movable with position memory on startup)
7730 * ----------------------------------------------------------------------------------------------------------------------------
7731 *******************************************************************************************************************************/
7732
7733 var Spellbox = {
7734 observe: function () {
7735 $.Observer(uw.GameEvents.ui.layout_gods_spells.rendered).subscribe('DIO_SPELLBOX_CHANGE_OPEN', function () {
7736 if (spellbox.show == false) {
7737 spellbox.show = true;
7738 saveValue("spellbox", JSON.stringify(spellbox));
7739 }
7740 Spellbox.change();
7741 });
7742 $.Observer(uw.GameEvents.ui.layout_gods_spells.state_changed).subscribe('DIO_SPELLBOX_CLOSE', function () {
7743 spellbox.show = false;
7744 saveValue("spellbox", JSON.stringify(spellbox));
7745 });
7746
7747 // GRCRT Bug-Fix
7748 if(typeof(RepConv) !== "undefined") {
7749 $.Observer(uw.GameEvents.ui.layout_gods_spells.rendered).unsubscribe('GRCRT_GRC_ui_layout_gods_spells_rendered');
7750
7751 $.Observer(uw.GameEvents.ui.layout_gods_spells.rendered).subscribe('GRCRT_GRC_ui_layout_gods_spells_rendered', function () {
7752 // PlayerGods doesn't exists at game start and the function would call an error
7753 if (typeof(RepConv.models.PlayerGods) !== "undefined") {
7754 RepConvTool.loadPower();
7755 }
7756 });
7757 }
7758 },
7759
7760 activate: function () {
7761 Spellbox.observe();
7762 Spellbox.change();
7763
7764 $('<style id="dio_spellbox_style" type="text/css">' +
7765 // Don't hide hero box, unit time box and hero coin box from GRC
7766 '#ui_box .nui_right_box { overflow: visible; } ' +
7767 // Hide negative spells
7768 '#ui_box .bolt, #ui_box .earthquake, #ui_box .pest { display: none } ' +
7769 // Change spell order
7770 '#ui_box .god_container { float: left } ' +
7771 '#ui_box .god_container[data-god_id="zeus"], #ui_box .god_container[data-god_id="athena"] { float: none } ' +
7772 // Remove background
7773 '#ui_box .powers_container { background: none !important } ' +
7774 // Hide god titles
7775 '#ui_box .content .title { display: none !important } ' +
7776 // Hide border elements
7777 '#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 } ' +
7778 // Layout
7779 '#ui_box .gods_area { height:150px } ' +
7780
7781 '#ui_box .gods_spells_menu { width: 134px; position:absolute; z-index:5000; padding:30px 0px 0px -4px } ' +
7782 '#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 } ' +
7783
7784 '#ui_box .nui_units_box { display:block; margin-top:-8px; position:relative } ' +
7785 '#ui_box .nui_units_box .bottom_ornament { margin-top:-28px; position: relative } ' +
7786 '</style>').appendTo('head');
7787
7788 // Draggable Box
7789 $("#ui_box .gods_spells_menu").draggable({
7790 containment: "body",
7791 distance: 10,
7792 snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, #island_quests_overview",
7793 opacity: 0.7,
7794 stop: function () {
7795 spellbox.top = this.style.top;
7796 spellbox.left = this.style.left;
7797
7798 saveValue("spellbox", JSON.stringify(spellbox));
7799 }
7800 });
7801 $("#ui_box .gods_spells_menu").before($('#ui_box .nui_units_box'));
7802
7803 // Position
7804 $('#ui_box .gods_spells_menu').css({
7805 left: spellbox.left,
7806 top: spellbox.top
7807 });
7808
7809 // Active at game start?
7810 if (spellbox.show && !$('#ui_box .btn_gods_spells').hasClass('active')) {
7811 $('#ui_box .btn_gods_spells').click();
7812 }
7813 },
7814 deactivate: function () {
7815 $('#ui_box .gods_spells_menu').draggable('destroy');
7816
7817 // Position
7818 $('#ui_box .gods_spells_menu').css({
7819 left: "auto",
7820 top: "150px"
7821 });
7822
7823 //$("#ui_box .gods_spells_menu").appendTo('gods_area'); // ?
7824
7825 $('#dio_spellbox_style').remove();
7826
7827 $.Observer(GameEvents.ui.layout_gods_spells.rendered).unsubscribe('DIO_SPELLBOX_CHANGE_OPEN');
7828 $.Observer(GameEvents.ui.layout_gods_spells.state_changed).unsubscribe('DIO_SPELLBOX_CLOSE');
7829 },
7830
7831 change: function () {
7832 //console.log("Unitsbox: "+ $(".nui_units_box").height());
7833 //console.log("Spellbox: "+ $(".gods_spells_menu").height());
7834
7835 // Change spell order
7836 $('#ui_box .god_container[data-god_id="poseidon"]').prependTo('#ui_box .gods_spells_menu .content');
7837 $('#ui_box .god_container[data-god_id="athena"]').appendTo('#ui_box .gods_spells_menu .content');
7838 $('#ui_box .god_container[data-god_id="artemis"]').appendTo('#ui_box .gods_spells_menu .content');
7839 }
7840
7841 };
7842
7843
7844 // Minimize Daily reward window on startup
7845 function minimizeDailyReward() {
7846 /*
7847 $.Observer(uw.GameEvents.window.open).subscribe('DIO_WINDOW', function(u,dato){});
7848 $.Observer(uw.GameEvents.window.reload).subscribe('DIO_WINDOW2', function(f){});
7849 */
7850 if (MutationObserver) {
7851 var startup = new MutationObserver(function (mutations) {
7852 mutations.forEach(function (mutation) {
7853 if (mutation.addedNodes[0]) {
7854 if ($('.daily_login').get(0)) { // && !uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).isMinimized()
7855 $('.daily_login').find(".minimize").click();
7856 //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).minimize();
7857 }
7858 }
7859 });
7860 });
7861 startup.observe($('body').get(0), {attributes: false, childList: true, characterData: false});
7862
7863 setTimeout(function () {
7864 startup.disconnect();
7865 }, 3000);
7866 }
7867 }
7868
7869 // Larger taskbar
7870 var Taskbar = {
7871 activate: function () {
7872 $('.minimized_windows_area').get(0).style.width = "150%";
7873 $('.minimized_windows_area').get(0).style.left = "-25%";
7874 },
7875 deactivate: function () {
7876 $('.minimized_windows_area').get(0).style.width = "100%";
7877 $('.minimized_windows_area').get(0).style.left = "0%";
7878 }
7879 };
7880
7881 // Hide fade out buttons
7882 function hideNavElements() {
7883 if (Game.premium_features.curator <= Timestamp.now()) {
7884 $('.nav').each(function () {
7885 this.style.display = "none";
7886 });
7887 }
7888 }
7889
7890 /*******************************************************************************************************************************
7891 * Chat
7892 *******************************************************************************************************************************/
7893
7894 var Chat = {
7895 user_colors : {},
7896
7897 delay : 10000,
7898
7899 timestamp : 0,
7900
7901 isWindowFocused : true,
7902
7903 isActivated : false,
7904
7905 isOpened : false,
7906
7907 activate : function(){
7908
7909 Chat.isActivated = true;
7910
7911 Chat.isOpened = true;
7912
7913 $('<style id="dio_chat_style">'+
7914 '#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; }'+
7915 '#dio_chat.resize { transition: left 0s; }'+
7916
7917 '#dio_chat .slider { width:100%; height: 6px; top:0; right:1px; position:absolute; margin-left:-8px; cursor: row-resize; }'+
7918
7919 '#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; }'+
7920 '#dio_chat .messagebox .time { float:left; color: #686; }'+
7921 '#dio_chat .messagebox .user { float:left; }'+
7922 '#dio_chat .messagebox .text { word-break: break-word; color: #797; }'+
7923
7924 '#dio_chat .messagebox .welcome .text { color: rgb(200,220,200); }'+
7925
7926 '#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; }'+
7927 '#dio_chat .togglebutton .top { height:4px; width:24px; background: url(https://diotools.de/images/game/button_sprite_vertical.png) 0px -1px; position:absolute;}'+
7928 '#dio_chat .togglebutton:hover .top { background-position: -25px -1px; }'+
7929 '#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; }'+
7930 '#dio_chat .togglebutton:hover .bottom { background-position: -25px 4px; }'+
7931 '#dio_chat .togglebutton .middle { height:100%; width:24px; background: url(https://diotools.de/images/game/button_sprite_vertical.png) -50px 0px; }'+
7932 '#dio_chat .togglebutton:hover .middle { background-position: -75px 0px; }'+
7933 '#dio_chat .togglebutton .arrow { position:absolute; left:6px; top:42.5%; }'+
7934
7935 '#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; }'+
7936
7937 '#dio_chat input { background: rgba(0, 0, 0, 0.5); color: white; border: 0px none; padding: 8px; width: 100%; border-right: 1px solid darkgreen; }'+
7938 '#dio_chat input:hover { background: rgba(0, 0, 10, 0.4); }'+
7939 '#dio_chat input:focus { background: rgba(0, 0, 10, 0.4); }'+
7940 '#dio_chat input::placeholder, '+
7941 '#dio_chat input::-webkit-input-placeholder, '+
7942 '#dio_chat input::-moz-placeholder, ' +
7943 '#dio_chat input:-ms-input-placeholder, '+
7944 '#dio_chat input:-moz-placeholder { color: black; }'+
7945
7946 // Chat im Menü ausblenden
7947 '.nui_main_menu ul { height:auto !important; }'+
7948 '.nui_main_menu li.chat { display:none !important; }'+
7949
7950 '#grcgrc { display:none }'+
7951
7952 '</style>').appendTo('head');
7953
7954 $('<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");
7955
7956 $('<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");
7957
7958 $('<div class="togglebutton"><div class="top"></div><div class="middle"><div class="arrow">◄</div></div><div class="bottom"></div></div>').appendTo("#dio_chat");
7959
7960 // Texteingabe
7961 $('#dio_chat input').keypress(function(e) {
7962
7963 if (e.keyCode === 13) {
7964
7965 var _time = $('.server_time_area').get(0).innerHTML.split(" ")[0];
7966
7967 var _message = $(this).val();
7968
7969 if(_message.length > 0) {
7970
7971 Chat.sendMessage(_message);
7972
7973 $(this).val('');
7974 }
7975
7976 }
7977 });
7978
7979 /*
7980 $('#dio_chat').draggable({
7981 containment: "body",
7982 distance: 10,
7983 snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, #island_quests_overview",
7984 opacity: 0.7,
7985 stop: function () {}
7986 });
7987 */
7988
7989 // Ein-/Ausblenden der Chatbox
7990 $('#dio_chat .togglebutton').toggleClick(
7991 function () {
7992
7993 var x = -($(window).width() * 0.25 + 16);
7994
7995 $('#dio_chat').css("left", x);
7996
7997 setTimeout(function(){
7998 $('#dio_chat .togglebutton .arrow').get(0).innerHTML = "►";
7999 },1300);
8000
8001 // Tooltip
8002 $('#dio_chat .togglebutton').tooltip("Chat öffnen");
8003
8004 },
8005 function (){
8006
8007 $('#dio_chat').css("left", 0);
8008
8009 setTimeout(function(){
8010 $('#dio_chat .togglebutton .arrow').get(0).innerHTML = "◄";
8011 },1300);
8012
8013 // Tooltip
8014 $('#dio_chat .togglebutton').tooltip("Chat schließen");
8015 }
8016 );
8017 // Wenn sich die Fenstergröße ändert
8018
8019 $(window).on("resize.dio", function(){
8020
8021 if($('#dio_chat').css("left") !== "0px"){
8022
8023 var x = -($(window).width() * 0.25 + 16);
8024
8025 $('#dio_chat').addClass("resize");
8026 $('#dio_chat').css("left", x);
8027
8028 setTimeout(function(){
8029 $('#dio_chat').removeClass("resize");
8030 },0);
8031 }
8032 });
8033
8034 // Tooltip
8035 $('#dio_chat .togglebutton').tooltip("Chat schließen");
8036
8037 // Skalierung der Höhe
8038 $('#dio_chat .slider').mousedown(function (e) {
8039 e.preventDefault();
8040
8041 $('#dio_chat .messagebox').css("max-height", "none");
8042
8043 $(document).on("mousemove.dio", function (e) {
8044 e.preventDefault();
8045
8046 var x = $(window).height() - e.pageY - 49;
8047
8048 if (x > 30 && x < $(window).height() - 400) {
8049 $('#dio_chat .messagebox').css("height", x );
8050 }
8051 });
8052 });
8053
8054 $(document).on("mouseup.dio", function (e) {
8055 $(document).off("mousemove.dio");
8056
8057 //$('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollTopMax;
8058 $('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollHeight
8059 });
8060
8061
8062
8063 Chat.timestamp = Timestamp.server();
8064
8065 // Initialer Start
8066 Chat.getMessages();
8067
8068
8069 // Öfter anfragen, wenn man chatten will
8070 $('#dio_chat').hover(function(){
8071
8072 if(Chat.isOpened === true) {
8073 Chat.delay = 3000; // 3s
8074
8075 clearTimeout(Chat.timeout_A);
8076 clearTimeout(Chat.timeout_B);
8077 }
8078
8079 }, function(){
8080
8081 if(Chat.isOpened === true) {
8082
8083 Chat.delay = 10000; // 10s
8084
8085 // Nach 5min nur noch alle 30s
8086 Chat.timeout_A = setTimeout(function () {
8087 Chat.delay = 30000;
8088 }, 300000);
8089
8090 // Nach 15min nur noch alle 60s
8091 Chat.timeout_B = setTimeout(function () {
8092 Chat.delay = 60000;
8093 }, 900000);
8094 }
8095 });
8096
8097 // Nur wenn Grepolis offen ist aktualisieren
8098 $(window).on("focus.dio", function() {
8099 Chat.isWindowFocused = true;
8100
8101 if(Chat.isOpened === true) {
8102
8103 Chat.getMessages();
8104
8105 Chat.delay = 10000; // 10s
8106
8107 clearTimeout(Chat.timeout_A);
8108 clearTimeout(Chat.timeout_B);
8109
8110 // Nach 5min nur noch alle 30s
8111 Chat.timeout_A = setTimeout(function () {
8112 Chat.delay = 30000;
8113 }, 300000);
8114
8115 // Nach 15min nur noch alle 60s
8116 Chat.timeout_B = setTimeout(function () {
8117 Chat.delay = 60000;
8118 }, 900000);
8119 }
8120
8121 }).on("blur.dio", function() {
8122 Chat.isWindowFocused = false;
8123 });
8124 },
8125 deactivate : function(){
8126 Chat.isActivated = false;
8127
8128 $('#dio_chat_style').remove();
8129 $('#dio_chat').remove();
8130
8131 // Events disconnecten
8132 $(document).off('mouseup.dio');
8133 $(window).off('focus.dio');
8134 $(window).off('blur.dio');
8135 $(window).off('resize.dio');
8136 },
8137 sendMessage : function(_message){
8138
8139 _message = encodeURIComponent(_message.replace(/'/g, "'").replace(/ /g, " "));
8140
8141 $.ajax({
8142 type: "GET",
8143 url: "https://diotools.de/php/sendMessage.php?world=" + Game.world_id + "&time=" + Timestamp.server() + "&player="+ Game.player_name +"&message="+ _message,
8144 dataType: 'text',
8145 success: function (response) {
8146 console.debug("Nachricht wurde erfolgreich gesendet");
8147
8148 //$('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollTopMax;
8149 $('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollHeight
8150
8151 Chat.getMessages();
8152 },
8153 error: function (e) {
8154 console.debug("Nachricht konnte nicht gesendet werden", e);
8155 }
8156 });
8157 },
8158 getMessages : function(){
8159
8160 if(Chat.isActivated === true) {
8161
8162 var _currentTimestamp = Timestamp.server();
8163
8164 var _url = "https://diotools.de/php/getMessages.php?world=" + Game.world_id;
8165
8166 if (typeof(Chat.lastID) !== "undefined") {
8167 _url += "&id=" + Chat.lastID;
8168 }
8169 else {
8170 _url += "&time=" + Chat.timestamp;
8171 }
8172
8173 // Eventuell noch nicht gefeuertes Timeout entfernen
8174 clearTimeout(Chat.timeout);
8175
8176 if (Chat.isWindowFocused) {
8177 $.ajax({
8178 type: "GET",
8179 url: _url,
8180 dataType: 'json',
8181 success: function (_messages) {
8182 if(Chat.isActivated === true) {
8183
8184 // Letzte Abfragezeit speichern
8185 Chat.timestamp = _currentTimestamp;
8186
8187 // console.debug("GET MESSAGES", _messages);
8188
8189 /*
8190 var _scrollDown = false;
8191 if ($('#dio_chat .messagebox')[0].scrollTop === $('#dio_chat .messagebox')[0].scrollTopMax) {
8192 _scrollDown = true;
8193 }
8194 */
8195
8196 for (var m in _messages) {
8197 if (_messages.hasOwnProperty(m)) {
8198
8199 if (typeof(_messages[m].last_id) === "undefined") {
8200
8201 // HTML-Tags ersetzen
8202 var _message = _messages[m].message.replace(/</g, '<').replace(/>/g, '>').replace(/'/g, "\'");
8203
8204 $('#dio_chat .messagebox').append(
8205 '<div class="time">' + Chat.formatTime(_messages[m].time) + ': </div>' +
8206 '<div class="user" style="color:' + Chat.getUserColor(_messages[m].player) + '">' + _messages[m].player + ': </div>' +
8207 '<div class="text"> ' + _message + ' </div>'
8208 );
8209 }
8210 else {
8211 Chat.lastID = _messages[m].last_id;
8212 }
8213 }
8214 }
8215
8216 clearTimeout(Chat.timeout);
8217
8218 Chat.timeout = setTimeout(function () {
8219
8220 if (Chat.isWindowFocused) {
8221 Chat.getMessages();
8222 }
8223
8224 }, Chat.delay);
8225
8226 //if(_scrollDown) {
8227 // $('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollTopMax;
8228 $('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollHeight
8229 //}
8230 }
8231 },
8232 error: function (xhr) {
8233 console.debug("Nachrichten konnten nicht geladen werden", xhr);
8234
8235 clearTimeout(Chat.timeout);
8236
8237 Chat.timeout = setTimeout(function () {
8238
8239 Chat.getMessages();
8240
8241 }, Chat.delay);
8242
8243 }
8244 });
8245
8246 }
8247 }
8248 },
8249 getUserColor : function(_user){
8250
8251 if(typeof(Chat.user_colors[_user]) === "undefined") {
8252
8253 var r = Math.floor(Math.random() * 255);
8254 var g = Math.floor(Math.random() * 255);
8255 var b = Math.floor(Math.random() * 255);
8256
8257 // Bei zu dunkler Farbe neue Farbe ermitteln
8258 if (r + g < 200 && r < 130 && g < 130) {
8259
8260 return Chat.getUserColor(_user);
8261 }
8262
8263 Chat.user_colors[_user] = 'rgb(' + r + ',' + g + ',' + b + ')';
8264 }
8265
8266 return Chat.user_colors[_user];
8267 },
8268 formatTime : function(_timestamp){
8269
8270 var date = new Date(_timestamp*1000);
8271
8272 // Hours part from the timestamp
8273 var hours = "0" + date.getHours();
8274 // Minutes part from the timestamp
8275 var minutes = "0" + date.getMinutes();
8276 // Seconds part from the timestamp
8277 var seconds = "0" + date.getSeconds();
8278
8279 // Will display time in 10:30:23 format
8280 return hours.substr(-2) + ':' + minutes.substr(-2) + ':' + seconds.substr(-2);
8281 }
8282 };
8283
8284 /*******************************************************************************************************************************
8285 * Activity boxes
8286 * ----------------------------------------------------------------------------------------------------------------------------
8287 * | ● Show troops and trade activity boxes
8288 * | ● Boxes are magnetic & movable (position memory)
8289 * ----------------------------------------------------------------------------------------------------------------------------
8290 *******************************************************************************************************************************/
8291 var mut_toolbar, mut_command, mut_trade;
8292
8293 var save_command_mouseout,
8294 save_commandlist_mouseout,
8295 save_trade_mouseout,
8296 save_tradelist_mouseout,
8297
8298 save_command_mouseover,
8299 save_trade_mouseover;
8300
8301
8302 var ActivityBoxes = {
8303 activate: function () {
8304 ActivityBoxes.checkToolbarAtStart();
8305
8306 $('#toolbar_activity_commands_list').css({
8307 left: commandbox.left + "px",
8308 top: commandbox.top + "px"
8309 });
8310
8311 $('<style id="fix_lists" type="text/css">' +
8312 '#toolbar_activity_commands_list, #toolbar_activity_trades_list { width: 160px}' +
8313 '.dropdown-list .content { max-height: 329px}' +
8314 '</style>' +
8315 '<style id="dio_fix_trade" type="text/css">' +
8316 '#toolbar_activity_trades_list {' +
8317 'left:' + tradebox.left + 'px !important;' +
8318 'top: ' + tradebox.top + 'px !important}' +
8319 '</style>').appendTo('head');
8320
8321
8322 ActivityBoxes.draggableTradeBox();
8323 ActivityBoxes.draggableCommandBox();
8324
8325 ActivityBoxes.catchToolbarEvents();
8326 },
8327 deactivate: function () {
8328 ActivityBoxes.hideTradeList();
8329 ActivityBoxes.hideCommandList();
8330
8331 mut_toolbar.disconnect();
8332 mut_command.disconnect();
8333 mut_trade.disconnect();
8334 },
8335 showTradeList: function () {
8336 if (!$('#dio_trades_activity_style').get(0)) {
8337 $('#toolbar_activity_trades').mouseover();
8338 $('<style id="dio_trades_activity_style"> #toolbar_activity_trades_list { display: block !important; } </style>').appendTo("head");
8339 }
8340 },
8341 showCommandList: function () {
8342 if (!$('#dio_commands_activity_style').get(0)) {
8343 $('#toolbar_activity_commands').mouseover();
8344 $('<style id="dio_commands_activity_style"> #toolbar_activity_commands_list { ' +
8345 'display:block !important; left:' + commandbox.left + 'px; top:' + commandbox.top + 'px; }' +
8346 '</style>').appendTo("head");
8347 }
8348 },
8349 hideTradeList: function () {
8350 if ($('#dio_trades_activity_style').get(0)) {
8351 $('#dio_trades_activity_style').remove();
8352 $('#toolbar_activity_trades').mouseout();
8353 }
8354 },
8355 hideCommandList: function () {
8356 if ($('#dio_commands_activity_style').get(0)) {
8357 $('#dio_commands_activity_style').remove();
8358 $('#toolbar_activity_commands').mouseout();
8359 }
8360 },
8361 activate2: function () {
8362 var observe_options = {attributes: false, childList: true, characterData: false};
8363
8364 ActivityBoxes.catchToolbarEvents();
8365
8366 mut_command.observe($('.toolbar_activities .commands .count').get(0), observe_options);
8367 mut_trade.observe($('.toolbar_activities .trades .count').get(0), observe_options);
8368
8369 $('<style id="dio_activity_style"> ' +
8370 '#toolbar_activity_commands_list.active { display: block !important; } ' +
8371 '#toolbar_activity_trades_list.active { display: block !important; } ' +
8372 '</style>').appendTo("head");
8373
8374
8375 $('#toolbar_activity_commands').mouseover();
8376 $('#toolbar_activity_trades').mouseover();
8377
8378 $('#toolbar_activity_commands, #toolbar_activity_trades').off("mouseover");
8379
8380 $('#toolbar_activity_commands, #toolbar_activity_commands_list, #toolbar_activity_trades, #toolbar_activity_trades_list').off("mouseout");
8381
8382 $('#toolbar_activity_trades_list').unbind("click");
8383 //console.log($('#toolbar_activity_commands').data('events')["dd:list:show"][0].handler());
8384
8385 ActivityBoxes.checkToolbarAtStart();
8386
8387 $('#toolbar_activity_commands_list').css({
8388 left: commandbox.left + "px",
8389 top: commandbox.top + "px"
8390 });
8391
8392 $('<style id="fix_lists" type="text/css">' +
8393 '#toolbar_activity_commands_list, #toolbar_activity_trades_list { width: 160px}' +
8394 '.dropdown-list .content { max-height: 329px}' +
8395 '</style>' +
8396 '<style id="dio_fix_trade" type="text/css">' +
8397 '#toolbar_activity_trades_list {' +
8398 'left:' + tradebox.left + 'px !important;' +
8399 'top: ' + tradebox.top + 'px !important}' +
8400 '</style>').appendTo('head');
8401
8402 ActivityBoxes.draggableCommandBox();
8403 ActivityBoxes.draggableTradeBox();
8404
8405
8406 /*
8407 $('.toolbar_activities .commands').on("mouseover.bla", function(){
8408 $('#toolbar_activity_commands_list').addClass("active");
8409 });
8410
8411 $('.toolbar_activities .trades').mouseover(function(){
8412 $('#toolbar_activity_trades_list').addClass("active");
8413 });
8414 */
8415 },
8416 deactivate2: function () {
8417 mut_toolbar.disconnect();
8418 mut_command.disconnect();
8419 mut_trade.disconnect();
8420 /*
8421 $('#toolbar_activity_commands').on("mouseover", save_command_mouseover);
8422 $('#toolbar_activity_trades').on("mouseover", save_trade_mouseover);
8423
8424 $('#toolbar_activity_commands').on("mouseout", save_command_mouseout);
8425 $('#toolbar_activity_commands_list').on("mouseout", save_commandlist_mouseout);
8426 $('#toolbar_activity_trades').on("mouseout", save_trade_mouseout);
8427 $('#toolbar_activity_trades_list').on("mouseout", save_tradelist_mouseout);
8428 */
8429
8430 $('#toolbar_activity_commands').mouseover = save_command_mouseover;
8431 $('#toolbar_activity_trades').mouseover = save_trade_mouseover;
8432
8433 $('#toolbar_activity_commands').mouseout = save_command_mouseout;
8434 $('#toolbar_activity_commands_list').mouseout = save_commandlist_mouseout;
8435 $('#toolbar_activity_trades').mouseout = save_trade_mouseout;
8436 $('#toolbar_activity_trades_list').mouseout = save_tradelist_mouseout;
8437
8438
8439 $('#toolbar_activity_trades_list').removeClass("active");
8440 $('#toolbar_activity_commands_list').removeClass("active");
8441 /*
8442 $('.toolbar_activities .commands').off("mouseover.bla");
8443 */
8444 $('#dio_activity_style').remove();
8445
8446
8447 },
8448 checkToolbarAtStart: function () {
8449 if (parseInt($('.toolbar_activities .commands .count').get(0).innerHTML, 10) > 0) {
8450 ActivityBoxes.showCommandList();
8451 } else {
8452 ActivityBoxes.hideCommandList();
8453 }
8454 if (parseInt($('.toolbar_activities .trades .count').get(0).innerHTML, 10) > 0) {
8455 ActivityBoxes.showTradeList();
8456 } else {
8457 ActivityBoxes.hideTradeList();
8458 }
8459 },
8460 catchToolbarEvents: function () {
8461 var observe_options = {attributes: false, childList: true, characterData: false};
8462
8463 mut_toolbar = new MutationObserver(function (mutations) {
8464 mutations.forEach(function (mutation) {
8465 if (mutation.addedNodes[0]) {
8466 //console.debug(mutation.target.id);
8467 if (mutation.target.id === "toolbar_activity_trades_list") {
8468 ActivityBoxes.draggableTradeBox();
8469 } else {
8470 ActivityBoxes.draggableCommandBox();
8471 }
8472 mutation.addedNodes[0].remove();
8473 }
8474 });
8475 });
8476 //mut_toolbar.observe($('#toolbar_activity_commands_list').get(0), observe_options );
8477 //mut_toolbar.observe($('#toolbar_activity_trades_list').get(0), observe_options );
8478
8479 mut_command = new MutationObserver(function (mutations) {
8480 mutations.forEach(function (mutation) {
8481 if (mutation.addedNodes[0]) {
8482 //console.debug(mutation.addedNodes[0].nodeValue);
8483 if (mutation.addedNodes[0].nodeValue > 0) {
8484 ActivityBoxes.showCommandList();
8485 } else {
8486 //console.debug("hide commands");
8487 ActivityBoxes.hideCommandList();
8488 }
8489 }
8490 });
8491 });
8492 mut_trade = new MutationObserver(function (mutations) {
8493 mutations.forEach(function (mutation) {
8494 if (mutation.addedNodes[0]) {
8495 if (mutation.addedNodes[0].nodeValue > 0) {
8496 ActivityBoxes.showTradeList();
8497 } else {
8498 ActivityBoxes.hideTradeList();
8499 }
8500 }
8501 });
8502 });
8503 mut_command.observe($('.toolbar_activities .commands .count').get(0), observe_options);
8504 mut_trade.observe($('.toolbar_activities .trades .count').get(0), observe_options);
8505 },
8506 // Moveable boxes
8507 draggableTradeBox: function () {
8508 $("#toolbar_activity_trades_list").draggable({
8509 containment: "body",
8510 distance: 20,
8511 snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, .nui_left_box",
8512 opacity: 0.7,
8513 start: function () {
8514 $("#dio_fix_trade").remove();
8515 },
8516 stop: function () {
8517 var pos = $('#toolbar_activity_trades_list').position();
8518
8519 tradebox.left = pos.left;
8520 tradebox.top = pos.top;
8521
8522 saveValue("tradebox", JSON.stringify(tradebox));
8523
8524 $('<style id="dio_fix_trade" type="text/css">' +
8525 '#toolbar_activity_trades_list { left:' + tradebox.left + 'px !important; top:' + tradebox.top + 'px !important; } ' +
8526 '</style>').appendTo('head');
8527 }
8528 });
8529 },
8530 draggableCommandBox: function () {
8531 $("#toolbar_activity_commands_list").draggable({
8532 containment: "body",
8533 distance: 20,
8534 snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, .nui_left_box",
8535 opacity: 0.7,
8536 stop: function () {
8537 var pos = $('#toolbar_activity_commands_list').position();
8538 commandbox.left = pos.left;
8539 commandbox.top = pos.top;
8540
8541 saveValue("commandbox", JSON.stringify(commandbox));
8542 }
8543 });
8544 }
8545 };
8546
8547 /*******************************************************************************************************************************
8548 * Counter
8549 *******************************************************************************************************************************/
8550
8551 function counter(time) {
8552 var type = "", today, counted, year, month, day;
8553 if (uw.Game.market_id !== "zz") {
8554 counted = DATA.count;
8555 today = new Date((time + 7200) * 1000);
8556 year = today.getUTCFullYear();
8557 month = ((today.getUTCMonth() + 1) < 10 ? "0" : "") + (today.getUTCMonth() + 1);
8558 day = (today.getUTCDate() < 10 ? "0" : "") + today.getUTCDate();
8559 today = year + month + day;
8560 //console.log(today);
8561 if (counted[0] !== today) {
8562 type += "d";
8563 }
8564 if (counted[1] == false) {
8565 type += "t";
8566 }
8567 if ((counted[2] == undefined) || (counted[2] == false)) {
8568 type += "b";
8569 }
8570 if (type !== "") {
8571 $.ajax({
8572 type: "GET",
8573 url: "https://diotools.de/game/count.php?type=" + type + "&market=" + uw.Game.market_id + "&date=" + today + "&browser=" + getBrowser(),
8574 dataType: 'text',
8575 success: function (text) {
8576 if (text.indexOf("dly") > -1) {
8577 counted[0] = today;
8578 }
8579 if (text.indexOf("tot") > -1) {
8580 counted[1] = true;
8581 }
8582 if (text.indexOf("bro") > -1) {
8583 counted[2] = true;
8584 }
8585 saveValue("dio_count", JSON.stringify(counted));
8586 }
8587 });
8588 }
8589 }
8590 }
8591
8592
8593 /*******************************************************************************************************************************
8594 * Political Map
8595 *******************************************************************************************************************************/
8596
8597 var PoliticalMap = {
8598 data: null,
8599 activate: function () {
8600 $('<div id="dio_political_map">' +
8601 '<div class="canvas_wrapper"></div>' +
8602 '<select class="zoom_select">' +
8603 '<option value="0.50">1 : 0.50</option>' +
8604 '<option value="0.75">1 : 0.75</option>' +
8605 '<option value="1.00" selected>1 : 1.00</option>' +
8606 '<option value="1.25">1 : 1.25</option>' +
8607 '<option value="1.50">1 : 1.50</option>' +
8608 '<option value="2.00">1 : 2.00</option>' +
8609 '<option value="3.00">1 : 3.00</option>' +
8610 '</select>' +
8611 '<div class="legend sandy-box">' +
8612 '<div class="corner_tl"></div>' +
8613 '<div class="corner_tr"></div>' +
8614 '<div class="corner_bl"></div>' +
8615 '<div class="corner_br"></div>' +
8616 '<div class="border_t"></div>' +
8617 '<div class="border_b"></div>' +
8618 '<div class="border_l"></div>' +
8619 '<div class="border_r"></div>' +
8620 '<div class="middle"></div>' +
8621 '<div class="content"><div class="item"></div></div>' +
8622 '</div></div>').appendTo('#ui_box');
8623
8624 // Style
8625 $('<style id="dio_political_map_style">' +
8626 '#dio_political_map { width:100%; height:100%; z-index:3; background:#123d70; display:none; position:absolute; top:0; } ' +
8627 '#dio_political_map.active { display: block; } ' +
8628 '#dio_political_map .canvas_wrapper { } ' +
8629 '#dio_political_map canvas { position: absolute; cursor:move; top:0; left:0; } ' +
8630 '#dio_political_map .zoom_select { position:absolute; top:70px; left:300px; font-size: 2em; opacity:0.5; } ' +
8631 '#dio_political_map .zoom_select:hover { opacity:1; } ' +
8632 '#dio_political_map .legend { position:absolute; right:200px; top:50px; width:200px; height:auto; text-align:left; } ' +
8633 '#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; } ' +
8634 '#dio_political_map .legend .wonder_icon { float: left; margin: 4px; } ' +
8635
8636 '.btn_political_map { top:56px; left:-4px; z-index:10; position:absolute; } ' +
8637
8638 '.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%; } ' +
8639 // http://s14.directupload.net/images/140408/k4wikrlq.png // http://s7.directupload.net/images/140408/ahfr8227.png
8640 '.btn_political_map .ico_political_map.checked { margin-top:8px; } ' +
8641 '</style>').appendTo('head');
8642
8643 PoliticalMap.addButton();
8644
8645 var zoomSelect = $('.zoom_select');
8646
8647 zoomSelect.change(function () {
8648 //PoliticalMap.zoomToCenter();
8649 });
8650 zoomSelect.on("change", function () {
8651 PoliticalMap.zoomToCenter();
8652 });
8653
8654 ColorPicker.init();
8655 },
8656 deactivate: function () {
8657 $('.btn_political_map').remove();
8658 $('#dio_political_map_style').remove();
8659 },
8660 addButton: function () {
8661 var m_ZoomFactor = 1.0;
8662 $('<div class="btn_political_map circle_button" name="political_map"><div class="ico_political_map js-caption"></div></div>').appendTo(".bull_eye_buttons");
8663
8664 var politicalMapButton = $('.btn_political_map');
8665
8666 // Tooltip
8667 politicalMapButton.tooltip("Political Map"); // TODO: Language
8668
8669 // Events
8670 politicalMapButton.on('mousedown', function () {
8671 //$('.btn_political_map, .ico_political_map').addClass("checked");
8672 }).on('mouseup', function () {
8673 //$('.btn_political_map, .ico_political_map').removeClass("checked");
8674 });
8675
8676 $('.rb_map .option').click(function () {
8677 $('.btn_political_map, .ico_political_map').removeClass("checked");
8678 $('#dio_political_map').removeClass("active");
8679 $(this).addClass("checked");
8680 });
8681
8682 politicalMapButton.click(function () {
8683 $('.rb_map .checked').removeClass("checked");
8684 $('.btn_political_map, .ico_political_map').addClass("checked");
8685 $('#dio_political_map').addClass("active");
8686
8687 if ($('#dio_political_map').hasClass("active")) {
8688 if (PoliticalMap.data == null) {
8689 $('#ajax_loader').css({visibility: "visible"});
8690 // Map-Daten aus DB auslesen
8691 PoliticalMap.loadMapData();
8692 } else {
8693 //PoliticalMap.drawMap(PoliticalMap.data);
8694 }
8695 }
8696 });
8697 },
8698 /**
8699 * Läd die Allianzen und Inseln aus der Datenbank
8700 * @since 3.0
8701 */
8702 loadMapData: function () {
8703 $.ajax({
8704 type: "GET",
8705 url: "https://diotools.de/php/map.php?world_id=" + WID + "&callback=jsonCallback",
8706 //dataType: 'jsonp',
8707 //async: false,
8708 //jsonpCallback: 'jsonCallback',
8709 //contentType: "application/json",
8710 success: function (response) {
8711 if (response !== "") {
8712 PoliticalMap.data = response;
8713
8714 var m_ZoomFactor = $('.zoom_select').get(0)[$('.zoom_select').get(0).selectedIndex].selected;
8715
8716 PoliticalMap.drawMap(PoliticalMap.data, m_ZoomFactor);
8717 PoliticalMap.drawWonders(PoliticalMap.data, m_ZoomFactor);
8718
8719 $('#ajax_loader').css({visibility: "hidden"});
8720
8721 // Überprüfen, ob die Weltdaten geupdatet werden müssen
8722 $.ajax({
8723 type: "GET",
8724 url: "https://diotools.de/php/update_db.php?world_id=" + WID
8725 });
8726 } else {
8727 // Welt existiert noch nicht in DB
8728 $.ajax({
8729 type: "GET", url: "https://diotools.de/php/update_db.php?world_id=" + WID,
8730 success: function () {
8731 // Map-Daten aus DB auslesen, wenn die Weltdaten erfolgreich in die DB geladen wurden
8732 $.ajax({
8733 type: "GET",
8734 url: "https://diotools.de/php/map.php?world_id=" + WID,
8735 success: function (response) {
8736 PoliticalMap.data = response;
8737
8738 var m_ZoomFactor = $('.zoom_select').get(0)[$('.zoom_select').get(0).selectedIndex].selected;
8739
8740 PoliticalMap.drawMap(PoliticalMap.data, m_ZoomFactor);
8741 PoliticalMap.drawWonders(PoliticalMap.data, m_ZoomFactor);
8742
8743 $('#ajax_loader').css({visibility: "hidden"});
8744 }
8745 });
8746 }
8747 });
8748 }
8749 }
8750 });
8751 },
8752 /**
8753 * Ändert die Zoomstufe der Karte zum Zentrum hin
8754 *
8755 * @param _zoom
8756 * @since 3.0
8757 */
8758 zoomToCenter: function () {
8759 var _zoom = $('.zoom_select').get(0)[$('.zoom_select').get(0).selectedIndex].value;
8760
8761 var canvas = $('#dio_political_map canvas'),
8762
8763 canvas_size = parseInt($('#dio_political_map canvas').width(), 10); // Breite und Höhe sind immer gleich
8764
8765 var canvas_style = $('#dio_political_map .canvas_wrapper').get(0).style;
8766
8767 // Berechnung: Alter Abstand + (1000 * Zoomänderung / 2)
8768 canvas_style.top = parseInt(canvas_style.top, 10) + (1000 * (canvas_size / 1000 - _zoom)) / 2 + "px";
8769 canvas_style.left = parseInt(canvas_style.left, 10) + (1000 * (canvas_size / 1000 - _zoom)) / 2 + "px";
8770
8771 PoliticalMap.clearMap();
8772 PoliticalMap.drawMap(PoliticalMap.data, _zoom);
8773 PoliticalMap.drawWonders(PoliticalMap.data, _zoom);
8774
8775 },
8776 /**
8777 * Ändert die Zoomstufe der Karte zur Cursorposition hin
8778 *
8779 * @param _zoom
8780 * @param _pos
8781 *
8782 * @since 3.0
8783 */
8784 zoomToCursorPosition: function (_zoom, _pos) {
8785
8786 },
8787 /**
8788 * Zeichnet die Karte in ein Canvas
8789 *
8790 * @param _islandArray {Array}
8791 * @param _zoom {int}
8792 *
8793 * @since 3.0
8794 */
8795 drawMap: function (_islandArray, _zoom) {
8796
8797 $('<canvas class="canv_map" height="' + (1000 * _zoom) + 'px" width="' + (1000 * _zoom) + "px\"></canvas>").prependTo('.canvas_wrapper')
8798
8799 // TODO: Weite und Höhe vom Fenster ermitteln, Update Containment bei onResizeWindow
8800 $('#dio_political_map .canvas_wrapper').draggable({
8801 // left, top, right, bottom
8802 //containment: [-500 * _zoom, -300 * _zoom, 500 * _zoom, 300 * _zoom],
8803 distance: 10,
8804 grid: [100 * _zoom, 100 * _zoom],
8805 //limit: 500,
8806 cursor: 'pointer'
8807 });
8808
8809 var ally_ranking = JSON.parse(_islandArray)['ally_ranking'];
8810 var island_array = JSON.parse(_islandArray)['ally_island_array'];
8811
8812
8813 var c = $('#dio_political_map .canv_map')[0].getContext('2d');
8814
8815 // Grid
8816 c.strokeStyle = 'rgb(0,100,0)';
8817
8818 for (var l = 0; l <= 10; l++) {
8819 // Horizontal Line
8820 c.moveTo(0, l * 100 * _zoom);
8821 c.lineTo(1000 * _zoom, l * 100 * _zoom);
8822 c.stroke();
8823
8824 // Vertical Line
8825 c.moveTo(l * 100 * _zoom, 0);
8826 c.lineTo(l * 100 * _zoom, 1000 * _zoom);
8827 c.stroke();
8828 }
8829
8830 // Center Circle
8831 c.beginPath();
8832 c.arc(500 * _zoom, 500 * _zoom, 100 * _zoom, 0, Math.PI * 2, true);
8833 c.fillStyle = 'rgba(0,100,0,0.2)';
8834 c.fill();
8835 c.stroke();
8836
8837 // Sea numbers
8838 c.fillStyle = 'rgb(0,100,0)';
8839
8840 for (var y = 0; y <= 10; y++) {
8841 for (var x = 0; x <= 10; x++) {
8842 c.fillText(y + "" + x, y * 100 * _zoom + 2, x * 100 * _zoom + 10);
8843 }
8844 }
8845
8846 // Alliance Colors
8847 var colorArray = ["#00A000", "yellow", "red", "rgb(255, 116, 0)", "cyan", "#784D00", "white", "purple", "#0078FF", "deeppink", "darkslategrey"];
8848
8849 // Islands
8850 for (var t in island_array) {
8851 if (island_array.hasOwnProperty(t)) {
8852 var tmp_points = 0, dom_ally = "";
8853 for (var ally in island_array[t]) {
8854 if (island_array[t].hasOwnProperty(ally)) {
8855 if (tmp_points < island_array[t][ally] && (ally !== "X") && (ally !== "")) {
8856 tmp_points = island_array[t][ally];
8857 dom_ally = ally;
8858 }
8859 }
8860 }
8861
8862 c.fillStyle = colorArray[parseInt(ally_ranking[dom_ally], 10) - 1] || "darkslategrey";
8863 //c.fillRect(t.split("x")[0] * _zoom, t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
8864
8865 //c.beginPath();
8866 //console.info(island_array[t]);
8867 //c.arc(t.split("x")[0], t.split("x")[1], 2, 0, Math.PI * 2, true);
8868 //c.fillRect(t.split("x")[0] * _zoom,t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
8869 //c.fill();
8870
8871 // TEST HEATMAP
8872 //console.debug("Blaaa", c.fillStyle);
8873 if (c.fillStyle !== "#2f4f4f") {
8874 var color = c.fillStyle;
8875
8876 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);
8877 radgrad.addColorStop(0, PoliticalMap.convertHexToRgba(color, 0.2));
8878 radgrad.addColorStop(0.6, PoliticalMap.convertHexToRgba(color, 0.2));
8879 radgrad.addColorStop(1, PoliticalMap.convertHexToRgba(color, 0.0));
8880
8881 // draw shape
8882 c.fillStyle = radgrad;
8883
8884 c.fillRect(t.split("x")[0] * _zoom - 10, t.split("x")[1] * _zoom - 10, 22, 22);
8885
8886 c.fillStyle = PoliticalMap.convertHexToRgba(color, 0.7);
8887 c.fillRect(t.split("x")[0] * _zoom, t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
8888 }
8889 else {
8890 c.fillRect(t.split("x")[0] * _zoom, t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
8891 }
8892 }
8893 }
8894
8895
8896
8897 // Legende
8898 var legend = $('#dio_political_map .legend .content');
8899
8900 legend.get(0).innerHTML = "";
8901
8902 for (var ally in ally_ranking) {
8903 if (ally_ranking.hasOwnProperty(ally)) {
8904 //legend.append("<div class='item' style='color:"+ colorAllyArray[ally] +"'><div class='color_checker' style='background-color:"+ colorAllyArray[ally] +"'></div>...</div>");
8905
8906 if (ally_ranking[ally] > 10) {
8907 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>");
8908
8909 break;
8910 } else {
8911 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>");
8912
8913 }
8914 }
8915 }
8916
8917 $('#dio_political_map .legend .color_checker').click(function (event) {
8918 // getting user coordinates
8919 var x = event.pageX - this.offsetLeft;
8920 var y = event.pageY - this.offsetTop;
8921
8922 console.debug("Color Checker", event.pageX, this.offsetLeft);
8923
8924 ColorPicker.open(x,y);
8925 });
8926
8927
8928 // TODO: Wenn eine Farbe ausgewählt wurde, soll [...]
8929 $(ColorPicker).on("onColorChanged", function(event, color){
8930 console.debug("Farbe setzen", event, color);
8931
8932 $.ajax({
8933 type: "POST",
8934 url: "https://" + Game.world_id + ".grepolis.com/game/alliance?town_id=" + Game.townId + "&action=assign_map_color&h=" + Game.csrfToken,
8935 data: {
8936 "json": "{\"alliance_id\":\"217\",\"color\":"+ color +",\"player_id\":\"8512878\",\"town_id\":\"71047\",\"nl_init\":true}"
8937 },
8938 success: function (response) {
8939 console.debug("Erfolgreich übertragen", response);
8940 }
8941 });
8942 });
8943
8944 },
8945 convertHexToRgba: function (hex, opacity) {
8946 console.debug("hex", hex);
8947 hex = hex.replace('#', '');
8948 r = parseInt(hex.substring(0, 2), 16);
8949 g = parseInt(hex.substring(2, 4), 16);
8950 b = parseInt(hex.substring(4, 6), 16);
8951
8952 result = 'rgba(' + r + ',' + g + ',' + b + ',' + opacity + ')';
8953 return result;
8954 },
8955 /**
8956 * Zeichnet die Weltwunder auf der Karte
8957 *
8958 * @param _islandArray {Array}
8959 * @param _zoom {int}
8960 *
8961 * @since 3.0
8962 */
8963 drawWonders: function (_islandArray, _zoom) {
8964
8965 $('<canvas class="canv_ww" height="' + (1000 * _zoom) + 'px" width="' + (1000 * _zoom) + 'px"></canvas>').appendTo('.canvas_wrapper')
8966
8967 var c = $('#dio_political_map .canv_ww')[0].getContext('2d');
8968
8969 c.strokeStyle = 'rgb(0,100,0)';
8970
8971 // World Wonders
8972 var wonders = {}, wonderImages = {};
8973 //console.debug(JSON.stringify(wonder.map));
8974
8975 for (var wonderType in wonder.map) {
8976 if (wonder.map.hasOwnProperty(wonderType)) {
8977 var tmp = 0;
8978 for (var wonderCoords in wonder.map[wonderType]) {
8979 if (parseInt(wonder.map[wonderType][wonderCoords], 10) > tmp) {
8980 wonders[wonderType] = wonderCoords;
8981 tmp = parseInt(wonder.map[wonderType][wonderCoords], 10)
8982 }
8983 }
8984 }
8985 }
8986
8987 // Legende
8988 var legend = $('#dio_political_map .legend .content');
8989
8990 legend.append("<div class=\"item no_results\"></div>");
8991
8992 for (var w in wonders) {
8993 if (wonders.hasOwnProperty(w)) {
8994 var _w = w;
8995
8996 wonderImages[_w] = new Image();
8997
8998 wonderImages[_w].onload = function () {
8999 c.drawImage(this, this.pos.split("_")[0] * _zoom - 9, this.pos.split("_")[1] * _zoom - 9);
9000 };
9001
9002 wonderImages[_w].pos = wonders[_w];
9003 wonderImages[_w].src = "https://diotools.de/images/icons/ww/" + _w + ".png";
9004
9005 var wonder_string = _w.split("_of")[0].split("_");
9006 wonder_string = wonder_string[wonder_string.length - 1];
9007 wonder_string = wonder_string.substring(0, 1).toUpperCase() + wonder_string.substring(1);
9008
9009 legend.append("<img class='wonder_icon' src='" + wonderImages[_w].src + "'><div class='item'>" + wonder_string + "</div>");
9010 }
9011 }
9012 },
9013 clearMap: function () {
9014 $('#dio_political_map .canv_map').remove();
9015 $('#dio_political_map .canv_ww').remove();
9016 },
9017 getAllianceColors: function () {
9018 $.ajax({
9019 type: "GET",
9020 url: "https://" + Game.world_id + ".grepolis.com/game/map_data?town_id=" + Game.townId + "&action=get_custom_colors&h=" + Game.csrfToken,
9021 dataType: 'json',
9022 success: function (response) {
9023 // Allianzbox herausfiltern
9024 var html_string = $('#alliance_box', $(response.json.list_html));
9025
9026 var flagArray = $('.flag', html_string);
9027 var linkArray = $('a', html_string);
9028
9029 var allianceColorArray = [];
9030
9031 for (var i = 0; i < flagArray.length; i++) {
9032 allianceColorArray[i] = {
9033 "id": parseInt(linkArray[i].attributes.onclick.value.split(",")[1].split(")")[0], 10),
9034 "color": flagArray[i].style.backgroundColor
9035 };
9036 }
9037
9038 // console.debug("ANTWORT", allianceColorArray);
9039 }
9040 });
9041 }
9042 };
9043
9044 var ColorPicker = {
9045 open: function(pos_left, pos_top){
9046 $('#dio_color_picker').removeClass("hidden");
9047 $('#dio_color_picker').css({
9048 left: pos_left,
9049 top: pos_top
9050 });
9051 },
9052 close: function(){
9053 $('#dio_color_picker').addClass("hidden");
9054 },
9055 init: function () {
9056 // Style
9057 $('<style id="dio_color_picker_style">' +
9058 '#dio_color_picker { left:200px;top:300px;position:absolute;z-index:1000;} ' +
9059 '#dio_color_picker.hidden { display:none;} ' +
9060 '#dio_color_picker span.grepo_input, ' +
9061 '#dio_color_picker a.color_table, ' +
9062 '#dio_color_picker a.confirm, ' +
9063 '#dio_color_picker a.cancel' +
9064 ' { float:left; } ' +
9065 '</style>').appendTo('head');
9066
9067 $(
9068 '<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>' +
9069 '<div id="hex">HEX: <input type="text"></input></div>' +
9070 '<div id="rgb">RGB: <input type="text"></input></div>'
9071 ).prependTo('#dio_political_map')
9072
9073 $(
9074 '<div id="dio_color_picker" class="hidden"><table class="bb_popup" cellpadding="0" cellspacing="0"><tbody>' +
9075 '<tr class="bb_popup_top">' +
9076 '<td class="bb_popup_top_left"></td>' +
9077 '<td class="bb_popup_top_middle"></td>' +
9078 '<td class="bb_popup_top_right"></td>' +
9079 '</tr>' +
9080 '<tr>' +
9081 '<td class="bb_popup_middle_left"></td>' +
9082 '<td class="bb_popup_middle_middle">' +
9083 '<div class="bb_color_picker_colors">' +
9084 '<div style="background-color: rgb(255, 0, 0);"></div>' +
9085 '<div style="background-color: rgb(0, 255, 0);"></div>' +
9086 '<div style="background-color: rgb(0, 0, 255);"></div>' +
9087 '</div>' +
9088 '<a href="#" class="cancel"></a>' +
9089 '<span class="grepo_input">' +
9090 '<span class="left">' +
9091 '<span class="right">' +
9092 '<input class="color_string" style="width:50px;" maxlength="6" type="text">' +
9093 '</span>' +
9094 '</span>' +
9095 '</span>' +
9096 '<a href="#" class="color_table"><input type="color" id="c" tabindex=-1 class="hidden"></a>' +
9097 '<a href="#" class="confirm"></a>' +
9098 '</td>' +
9099 '<td class="bb_popup_middle_right"></td>' +
9100 '</tr>' +
9101 '<tr class="bb_popup_bottom">' +
9102 '<td class="bb_popup_bottom_left"></td>' +
9103 '<td class="bb_popup_bottom_middle"></td>' +
9104 '<td class="bb_popup_bottom_right"></td>' +
9105 '</tr>' +
9106 '</tbody></table></div>'
9107 ).prependTo('#dio_political_map');
9108
9109 var canvas = document.getElementById('canvas_picker').getContext('2d');
9110
9111 var count = 5, line = 0, width = 16, height = 12, sep = 1;
9112
9113 var offset = (count - 2) * width;
9114
9115 for (var i = 2, j = 0; i < count; i++, j++) {
9116
9117 line = 0;
9118
9119 // Pinktöne (255,0,255)
9120 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", 0, " + ((i / count * 255) | 0) + ")";
9121 canvas.fillRect(i * width, line, width - sep, height - sep);
9122
9123 canvas.fillStyle = "rgb(255," + ((j / (count - 1) * 255) | 0) + ", 255)";
9124 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9125
9126 line = line + height;
9127
9128 // Rosatöne (255,0,127)
9129 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", 0, " + ((i / count * 127) | 0) + ")";
9130 canvas.fillRect(i * width, line, width - sep, height - sep);
9131
9132 canvas.fillStyle = "rgb(255," + ((j / (count - 1) * 255) | 0) + "," + (127 + ((j / (count - 1) * 127) | 0)) + ")";
9133 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9134
9135 line = line + height;
9136
9137 // Rottöne (255,0,0)
9138 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", 0, 0)";
9139 canvas.fillRect(i * width, line, width - sep, height - sep);
9140
9141 canvas.fillStyle = "rgb(255," + ((j / (count - 1) * 255) | 0) + "," + ((j / (count - 1) * 255) | 0) + ")";
9142 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9143
9144 line = line + height;
9145
9146 // Orangetöne (255, 127, 0)
9147 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", " + ((i / count * 127) | 0) + ", 0)";
9148 canvas.fillRect(i * width, line, width - sep, height - sep);
9149
9150 canvas.fillStyle = "rgb(255, " + (127 + ((j / (count - 1) * 127) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ")";
9151 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9152
9153 line = line + height;
9154
9155 // Dunkelbrauntöne (170, 85, 0)
9156 canvas.fillStyle = "rgb(" + ((i / count * 170) | 0) + ", " + ((i / count * 85) | 0) + ", 0)";
9157 canvas.fillRect(i * width, line, width - sep, height - sep);
9158
9159 canvas.fillStyle = "rgb(" + (170 + (j / (count - 1) * 85) | 0) + ", " + (85 + ((j / (count - 1) * 170) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ")";
9160 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9161
9162 line = line + height;
9163
9164 // Brauntöne (191, 127, 0)
9165 canvas.fillStyle = "rgb(" + ((i / count * 191) | 0) + ", " + ((i / count * 127) | 0) + ", 0)";
9166 canvas.fillRect(i * width, line, width - sep, height - sep);
9167
9168 canvas.fillStyle = "rgb(" + (191 + (j / (count - 1) * 64) | 0) + ", " + (127 + ((j / (count - 1) * 127) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ")";
9169 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9170
9171 line = line + height;
9172
9173 // Gelbtöne (255,255,0)
9174 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ", 0)";
9175 canvas.fillRect(i * width, line, width - sep, height - sep);
9176
9177 canvas.fillStyle = "rgb(255, 255," + ((j / (count - 1) * 255) | 0) + ")";
9178 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9179
9180 line = line + height;
9181
9182 // Gelbgrüntöne (127,255,0)
9183 canvas.fillStyle = "rgb(" + ((i / count * 127) | 0) + "," + ((i / count * 191) | 0) + ", 0)";
9184 canvas.fillRect(i * width, line, width - sep, height - sep);
9185
9186 canvas.fillStyle = "rgb(" + (127 + (j / (count - 1) * 127) | 0) + "," + (191 + (j / (count - 1) * 64) | 0) + "," + ((j / (count - 1) * 255) | 0) + ")";
9187 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9188
9189 line = line + height;
9190
9191 // Dunkelgrasgrüntöne (85, 170, 0)
9192 /*
9193 canvas.fillStyle = "rgb("+ ((i/count*85)|0) +", "+ ((i/count*170)|0) +", 0)";
9194 canvas.fillRect(i * width, line, width-sep, height-sep);
9195
9196 canvas.fillStyle = "rgb("+ (85 + (j/(count-1)*170)|0) +", "+ (170 + ((j/(count-1)*85)|0)) +","+ ((j/(count-1)*255)|0) +")";
9197 canvas.fillRect(i * width + offset, line, width-sep, height-sep);
9198
9199 line = line + height;
9200 */
9201
9202 // Grüntöne (0,255,0)
9203 canvas.fillStyle = "rgb(0," + ((i / count * 255) | 0) + ", 0)";
9204 canvas.fillRect(i * width, line, width - sep, height - sep);
9205
9206 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + ", 255," + ((j / (count - 1) * 255) | 0) + ")";
9207 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9208
9209 line = line + height;
9210
9211 // Türkistöne (0,255,127)
9212 /*
9213 canvas.fillStyle = "rgb(0,"+ ((i/count*255)|0) +","+ ((i/count*127)|0) + ")";
9214 canvas.fillRect(i * width, line, width-sep, height-sep);
9215
9216 canvas.fillStyle = "rgb("+ ((j/(count-1)*255)|0) +", 255,"+ (127 + ((j/(count-1)*127)|0)) +")";
9217 canvas.fillRect(i * width + offset, line, width-sep, height-sep);
9218
9219 line = line + height;
9220 */
9221
9222 // Dunkel-Türkistöne (0,191,127)
9223 canvas.fillStyle = "rgb(0, " + ((i / count * 191) | 0) + "," + ((i / count * 127) | 0) + ")";
9224 canvas.fillRect(i * width, line, width - sep, height - sep);
9225
9226 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + "," + (191 + (j / (count - 1) * 64) | 0) + ", " + (127 + ((j / (count - 1) * 127) | 0)) + ")";
9227 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9228
9229 line = line + height;
9230
9231
9232 // Cyantöne (0,255,255)
9233 canvas.fillStyle = "rgb(0, " + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ")";
9234 canvas.fillRect(i * width, line, width - sep, height - sep);
9235
9236 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + ",255, 255)";
9237 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9238
9239 line = line + height;
9240
9241 // Hellblautöne (0,127,255)
9242 canvas.fillStyle = "rgb(0, " + ((i / count * 127) | 0) + "," + ((i / count * 255) | 0) + ")";
9243 canvas.fillRect(i * width, line, width - sep, height - sep);
9244
9245 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + "," + (127 + ((j / (count - 1) * 127) | 0)) + ", 255)";
9246 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9247
9248 line = line + height;
9249
9250 // Blautöne (0,0,255)
9251 canvas.fillStyle = "rgb(0, 0, " + ((i / count * 255) | 0) + ")";
9252 canvas.fillRect(i * width, line, width - sep, height - sep);
9253
9254 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + "," + ((j / (count - 1) * 255) | 0) + ", 255)";
9255 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9256
9257 line = line + height;
9258
9259 // Lilatöne (127,0,255)
9260 canvas.fillStyle = "rgb(" + ((i / count * 127) | 0) + ", 0, " + ((i / count * 255) | 0) + ")";
9261 canvas.fillRect(i * width, line, width - sep, height - sep);
9262
9263 canvas.fillStyle = "rgb(" + (127 + ((j / (count - 1) * 127) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ", 255)";
9264 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9265
9266 line = line + height;
9267
9268 // Grautöne
9269 /*
9270 canvas.fillStyle = "rgb("+ ((i/count*127)|0) +", "+ ((i/count*127)|0) +", "+ ((i/count*127)|0) +")";
9271 canvas.fillRect(i * width, line, width-sep, height-sep);
9272
9273 canvas.fillStyle = "rgb("+ (127 + ((j/(count-1)*127)|0)) +","+ (127 + ((j/(count-1)*127)|0)) +","+ (127 + ((j/(count-1)*127)|0)) +")";
9274 canvas.fillRect(i * width + offset, line, width-sep, height-sep);
9275
9276 line = line + height;
9277 */
9278
9279 }
9280
9281 line = line + height;
9282
9283 for (var i = 0; i <= count; i++) {
9284 // Grautöne
9285 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ")";
9286 canvas.fillRect(i * width + width * 2, line, width - sep, height - sep);
9287 }
9288
9289
9290 // http://www.javascripter.net/faq/rgbtohex.htm
9291 function rgbToHex(R, G, B) {
9292 return toHex(R) + toHex(G) + toHex(B)
9293 }
9294
9295 function toHex(n) {
9296 n = parseInt(n, 10);
9297 if (isNaN(n)) return "00";
9298 n = Math.max(0, Math.min(n, 255));
9299 return "0123456789ABCDEF".charAt((n - n % 16) / 16) + "0123456789ABCDEF".charAt(n % 16);
9300 }
9301
9302 $('#dio_color_picker a.cancel').click(function () {
9303 ColorPicker.close();
9304 });
9305
9306
9307 $('#dio_color_picker a.confirm').click(function () {
9308 // Custom-Event auslösen
9309 $(ColorPicker).trigger("onColorChanged", [$('#dio_color_picker .color_string')[0].value]);
9310 ColorPicker.close();
9311 });
9312
9313 $('#dio_color_picker a.color_table').click(function () {
9314 document.getElementById("c").click();
9315 });
9316
9317 $('#dio_color_picker a.color_table #c').change(function () {
9318 $('#dio_color_picker input.color_string')[0].value = this.value;
9319 $('#dio_color_picker input.color_string')[0].style.color = this.value;
9320 });
9321 }
9322 };
9323
9324 var UnitImages = {
9325 activate : function(){
9326 $('<style id="dio_unit_images">' +
9327
9328 '.unit_icon25x25 { background-image: url(https://diotools.de/images/game/units/unit_icons_25x25_2.91.png);} ' +
9329 '.unit_icon40x40 { background-image: url(https://diotools.de/images/game/units/unit_icons_40x40_2.91.png);} ' +
9330 '.unit_icon50x50 { background-image: url(https://diotools.de/images/game/units/unit_icons_50x50_2.91.png);} ' +
9331 '.unit_icon90x90 { background-image: url(https://diotools.de/images/game/units/unit_icons_90x90_2.91.png);} ' +
9332
9333 '.unit_icon228x165 { background-image: none; height:0px;} ' +
9334 '.unit_card .deco_statue { background-image: none !important;} ' +
9335 '.grepo_box_silver .border_l, .grepo_box_silver .border_r { background-image: none;} ' +
9336 '.box_corner .box_corner_tl, .grepo_box_silver .box_corner_tr { height:31px; } ' +
9337 '.grepo_box_silver .grepo_box_content { padding: 21px 10px 0px; } ' +
9338
9339 '</style>').appendTo('head');
9340 },
9341 deactivate : function(){
9342 $('#dio_unit_images').remove();
9343
9344 }
9345 };
9346
9347 /*******************************************************************************************************************************
9348 * Holiday Special
9349 *******************************************************************************************************************************/
9350
9351 var HolidaySpecial = {
9352 isHalloween : false, isXmas : false, isNewYear : false, isEaster : false,
9353
9354 activate : function(){
9355 var daystamp = 1000*60*60*24, today = new Date((new Date())%(daystamp*(365+1/4))), // without year
9356
9357 // Halloween -> 15 days
9358 halloween_start = daystamp * 297, // 25. Oktober
9359 halloween_end = daystamp * 321, // 8. November
9360 // Xmas -> 28 days
9361 xmas_start = daystamp * 334, // 1. Dezember
9362 xmas_end = daystamp * 361, // 28. Dezember
9363 // NewYear -> 7 days
9364 newYear_start = daystamp * 0, // 1. Januar
9365 newYear_end = daystamp * 7; // 7. Januar
9366
9367 HolidaySpecial.isHalloween = (today >= halloween_start) ? (today <= halloween_end) : false;
9368
9369 HolidaySpecial.isXmas = (today >= xmas_start) ? (today <= xmas_end) : false;
9370
9371 HolidaySpecial.isNewYear = (today >= newYear_start) ? (today <= newYear_end) : false;
9372
9373 if(HolidaySpecial.isXmas){ HolidaySpecial.XMas.add(); }
9374 if(HolidaySpecial.isNewYear){ HolidaySpecial.NewYear.add(); }
9375
9376 // Calculation Easter
9377
9378 // Jahreszahl
9379 var X = 2016;
9380
9381 // Säkularzahl
9382 var K = parseInt(X / 100, 10);
9383 // Mondparameter
9384 var A = X % 19;
9385
9386 // säkulare Mondschaltung
9387 var M = 15 + parseInt((3 * K + 3)/4, 10) - parseInt((8 * K + 13)/25, 10);
9388
9389 // säkulare Sonnenschaltung
9390 var S = 2 - parseInt((3 * K + 3)/4, 10);
9391
9392 // Erster Vollmond im Frühling
9393 var D = (19 * A + M) % 30;
9394
9395 // Kalendarische Korrekturgröße
9396 var R = parseInt((D + parseInt(A / 11, 10)) / 29, 10);
9397
9398 // Ostergrenze
9399 var OG = 21 + D - R;
9400
9401 // Erster Sonntag im März
9402 var SZ = 7 - ((2016 + parseInt(2016/4, 10) + S) % 7);
9403
9404 // Entfernung des Ostersonntags von der Ostergrenze
9405 var OE = 7 - ((OG - SZ) % 7);
9406
9407 // Ostersonntag als Märzdatum
9408 var OS = OG + OE;
9409
9410 // console.debug("DIO-TOOLS | Ostersonntag: " + OS);
9411
9412 },
9413 XMas : {
9414 add : function(){
9415 $('<a href="http://www.greensmilies.com/smilie-album/weihnachten-smilies/" target="_blank"><div id="dio_xmas"></div></a>').appendTo('#ui_box');
9416
9417 var dioXMAS = $('#dio_xmas');
9418
9419 dioXMAS.css({
9420 background: 'url("http://www.greensmilies.com/smile/smiley_emoticons_weihnachtsmann_nordpol.gif") no-repeat',
9421 height: '51px',
9422 width: '61px',
9423 position:'absolute',
9424 bottom:'10px',
9425 left:'60px',
9426 zIndex:'2000'
9427 });
9428 dioXMAS.tooltip("Ho Ho Ho, Merry Christmas!");
9429 }
9430 },
9431 NewYear : {
9432 add : function(){
9433 // TODO: Jahreszahl dynamisch setzen
9434 $('<a href="http://www.greensmilies.com/smilie-album/" target="_blank"><div id="dio_newYear">'+
9435 '<img src="http://www.greensmilies.com/smile/sign2_2.gif">'+
9436 '<img src="http://www.greensmilies.com/smile/sign2_0.gif">'+
9437 '<img src="http://www.greensmilies.com/smile/sign2_1.gif">'+
9438 '<img src="http://www.greensmilies.com/smile/sign2_7.gif">'+
9439 '</div></a>').appendTo('#ui_box');
9440
9441 var dioNewYear = $('#dio_newYear');
9442
9443 dioNewYear.css({
9444 position:'absolute',
9445 bottom:'10px',
9446 left:'70px',
9447 zIndex:'10'
9448 });
9449 dioNewYear.tooltip("Happy new year!");
9450 }
9451 }
9452 };
9453
9454}