· 7 years ago · Feb 08, 2019, 02:36 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,3}\.grepolis\.com/game*/
11// @include https://*.forum.grepolis.com/*
12// @include http://diotools.de/*
13// @require http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
14// @icon http://s7.directupload.net/images/140128/vqchpigi.gif
15// @icon64 http://diotools.de/images/icon_dio_64x64.png
16// @copyright 2013+, DIONY
17// @grant GM_info
18// @grant GM_setValue
19// @grant GM_getValue
20// @grant GM_deleteValue
21// @grant GM_xmlhttpRequest
22// @grant GM_getResourceURL
23// ==/UserScript==
24
25var version = '3.19';
26
27//if(unsafeWindow.DM) console.dir(unsafeWindow.DM.status('l10n'));
28//console.dir(DM.status('templates'));
29
30//http://s7.directupload.net/images/140128/vqchpigi.gif - DIO-Tools-Smiley
31
32//http://de44.grepolis.com/cache/js/libs/jquery-1.10.2.min.js
33
34
35//console.log(JSON.stringify(DM.getl10n()));
36
37
38//// console.log(GM_getResourceText("dio_sprite"));
39
40/*******************************************************************************************************************************
41 * Changes
42 * ----------------------------------------------------------------------------------------------------------------------------
43 * | ◠Einstellungen und auch das ganze Script komplett überarbeitet
44 * | ◠Features können nun ohne Refresh deaktiviert/aktiviert werden
45 * | ◠Einzelne Features sind unabhängiger voneinander und somit auch fehlerresistenter (einzelne Features können sich bei Fehlerauftreten durch Grepolis-Updates nicht mehr gegenseitig blockieren)
46 * | ◠Fehlerhafter Biremenzähler als Kompromiss für die Erweiterung der "Verfügbare Einheiten"-Anzeige entfernt: es kann nun jede Einheit im Bullauge angezeigt werden
47 * | ◠EO-Zähler hat ATT/UT's doppelt gezählt, wenn nebenher der veröffentlichte Belagerungsbericht im Forum offen war
48 * | ◠3 kleine Layoutfehler beim EO-Zähler behoben
49 * | â— Wenn Zauberfenster und Zauberbox gleichzeitig offen waren, kam es zu einem Layoutfehler
50 * | â— Fehler beim Mausrad-Zoom behoben
51 * | ◠Fehler bei der Transporteranzeige behoben: die Kapazität der großen Transporter wurde durch das Rebalancing nichtmehr korrekt berechnet
52 * | â— Smileybox etwas verbessert
53 * | ◠Weihnachtssmileys hinzugefügt
54 * | ◠Kontextmenü der Stadticons auf der strategischen Karte konnte im Nachtmodus nicht geöffnet werden
55 * | ◠Grüner Fortschrittsbalken beim Weltwunderzähler wurde nicht angezeigt
56 * | ◠Fenster wurden angepasst (Verfügbare Einheiten und Einheitenvergleich)
57 * ----------------------------------------------------------------------------------------------------------------------------
58 *******************************************************************************************************************************/
59
60/*******************************************************************************************************************************
61 * Bugs / TODOs
62 * ----------------------------------------------------------------------------------------------------------------------------
63 * | ◠Aktivitätsbox für Angriffe blendet nicht aus
64 * | â— Smileys verschwinden manchmal? -> bisher nicht reproduzierbar
65 * | â— Performanceeinbruch nach dem Switchen des WW-Fensters
66 * | â— keine Smileys im Grepoforum mit Safari (fehlendes jQuery)
67 * ----------------------------------------------------------------------------------------------------------------------------
68 *******************************************************************************************************************************/
69
70/*******************************************************************************************************************************
71 * Global stuff
72 *******************************************************************************************************************************/
73var uw = unsafeWindow || window, $ = uw.jQuery || jQuery, DATA, GM;
74
75// GM-API?
76GM = (typeof GM_info === 'object');
77
78console.log('%c|= DIO-Tools is active =|', 'color: green; font-size: 1em; font-weight: bolder; ');
79
80function loadValue(name, default_val){
81 var value;
82 if(GM){
83 value = GM_getValue(name, default_val);
84 } else {
85 value = localStorage.getItem(name) || default_val;
86 }
87
88 if(typeof(value) === "string"){
89 value = JSON.parse(value)
90 }
91 return value;
92}
93
94// LOAD DATA
95if(GM && (uw.location.pathname.indexOf("game") >= 0)){
96 var WID = uw.Game.world_id, MID = uw.Game.market_id, AID = uw.Game.alliance_id;
97
98 //GM_deleteValue(WID + "_bullseyeUnit");
99
100 DATA = {
101 // GLOBAL
102 options : loadValue("options", "{}"),
103
104 user : loadValue("dio_user", "{}"),
105 count: loadValue("dio_count", "[]"),
106
107 notification : loadValue('notif', '0'),
108
109 error: loadValue('error', '{}'),
110
111 spellbox : loadValue("spellbox", '{ "top":"23%", "left": "-150%", "show": false }'),
112 commandbox: loadValue("commandbox" , '{ "top":55, "left": 250 }'),
113 tradebox : loadValue("tradebox", '{ "top":55, "left": 450 }'),
114
115 // WORLD
116 townTypes : loadValue(WID + "_townTypes", "{}"),
117 sentUnits : loadValue(WID + "_sentUnits", '{ "attack": {}, "support": {} }'),
118
119 biremes : loadValue(WID + "_biremes", "{}"), //old
120 bullseyeUnit : loadValue(WID + "_bullseyeUnit", '{ "current_group" : -1 }'), // new
121
122 worldWonder : loadValue(WID + "_wonder", '{ "ratio": {}, "storage": {}, "map": {} }'),
123
124 clickCount : loadValue(WID + "_click_count", '{}'), // old
125 statistic : loadValue(WID + "_statistic", '{}'), // new
126
127 // MARKET
128 worldWonderTypes : loadValue(MID + "_wonderTypes", '{}')
129 };
130
131 if(!DATA.worldWonder.map) {
132 DATA.worldWonder.map = {};
133 }
134
135 // Temporary:
136 if(typeof DATA.options.trd == 'boolean') {
137 DATA.options.per = DATA.options.rec = DATA.options.trd; delete DATA.options.trd;
138 }
139 if(typeof DATA.options.mov == 'boolean') {
140 DATA.options.act = DATA.options.mov; delete DATA.options.mov;
141 }
142 if(typeof DATA.options.twn == 'boolean') {
143 DATA.options.tic = DATA.options.til = DATA.options.tim = DATA.options.twn; delete DATA.options.twn;
144 }
145 if(GM) GM_deleteValue("notification");
146}
147
148// GM: EXPORT FUNCTIONS
149uw.saveValueGM = function(name, val){
150 setTimeout(function(){
151 GM_setValue(name, val);
152 }, 0);
153};
154
155uw.deleteValueGM = function(name){
156 setTimeout(function(){
157 GM_deleteValue(name);
158 },0);
159};
160
161uw.getImageDataFromCanvas = function(x, y){
162
163 // console.debug("HEY", document.getElementById('canvas_picker').getContext('2d').getImageData(x, y, 1, 1));
164};
165uw.calculateConcaveHull = function() {
166 var contour = [
167 new poly2tri.Point(100, 100),
168 new poly2tri.Point(100, 300),
169 new poly2tri.Point(300, 300),
170 new poly2tri.Point(300, 100)
171 ];
172
173 var swctx = new poly2tri.SweepContext(contour);
174
175 swctx.triangulate();
176 var triangles = swctx.getTriangles();
177
178 // console.debug(triangles);
179
180 return triangles;
181};
182
183if(typeof exportFunction == 'function'){
184 // Firefox > 30
185 //uw.DATA = cloneInto(DATA, unsafeWindow);
186 exportFunction(uw.saveValueGM, unsafeWindow, {defineAs: "saveValueGM"});
187 exportFunction(uw.deleteValueGM, unsafeWindow, {defineAs: "deleteValueGM"});
188 exportFunction(uw.calculateConcaveHull, unsafeWindow, {defineAs: "calculateConcaveHull"});
189 exportFunction(uw.getImageDataFromCanvas, unsafeWindow, {defineAs: "getImageDataFromCanvas"});
190} else {
191 // Firefox < 30, Chrome, Opera, ...
192 //uw.DATA = DATA;
193}
194
195var time_a, time_b;
196
197// APPEND SCRIPT
198function appendScript(){
199 //console.log("GM-API: " + gm_bool);
200 if(document.getElementsByTagName('body')[0]){
201 var dioscript = document.createElement('script');
202 dioscript.type ='text/javascript';
203 dioscript.id = 'diotools';
204
205 time_a = uw.Timestamp.client();
206 dioscript.textContent = DIO_GAME.toString().replace(/uw\./g, "") + "\n DIO_GAME('"+ version +"', "+ GM +", '" + JSON.stringify(DATA).replace(/'/g, "##") + "', "+ time_a +");";
207 document.body.appendChild(dioscript);
208 } else {
209 setTimeout(function(){
210 appendScript();
211 }, 500);
212 }
213}
214
215if(location.host === "diotools.de"){
216 // PAGE
217 DIO_PAGE();
218}
219else if((uw.location.pathname.indexOf("game") >= 0) && GM){
220 // GAME
221 appendScript();
222}
223else {
224 DIO_FORUM();
225}
226
227function DIO_PAGE(){
228 if(typeof GM_info == 'object') {
229 setTimeout(function() {
230 dio_user = JSON.parse(loadValue("dio_user", ""));
231 console.log(dio_user);
232 uw.dio_version = parseFloat(version);
233 }, 0);
234 } else {
235 dio_user = localStorage.getItem("dio_user") || "";
236
237 dio_version = parseFloat(version);
238 }
239}
240function DIO_FORUM(){
241 var smileyArray = [];
242
243 var _isSmileyButtonClicked = false;
244
245 smileyArray.standard = [
246 "smilenew", "grin", "lol", "neutral_new", "afraid", "freddus_pacman", "auslachen2", "kolobok-sanduhr", "bussi2", "winken4", "flucht2", "panik4", "ins-auge-stechen",
247 "seb_zunge", "fluch4_GREEN", "baby_junge2", "blush-reloaded6", "frown", "verlegen", "blush-pfeif", "stevieh_rolleyes", "daumendreh2", "baby_taptap",
248 "sadnew", "hust", "confusednew", "idea2", "irre", "irre4", "sleep", "candle", "nicken", "no_sad",
249 "thumbs-up_new", "thumbs-down_new", "bravo2", "oh-no2", "kaffee2", "drunk", "saufen", "freu-dance", "hecheln", "headstand", "rollsmiliey", "eazy_cool01", "motz", "cuinlove", "biggrin"
250 ];
251 smileyArray.grepolis = [
252 "mttao_wassermann", "hera", /* Hera */ "medusa", /* Medusa */ "manticore", /* Mantikor */ "cyclops", /* Zyklop */
253 "minotaur", /* Minotaurus */ "pegasus", /* Pegasus */ "hydra", /* Hydra */
254 "silvester_cuinlove", "mttao_schuetze", "kleeblatt2", "wallbash", /* "glaskugel4", */ /* "musketiere_fechtend",*/ /* "krone-hoch",*/ "viking", // Wikinger
255 /* "mttao_waage2", */ "steckenpferd", /* "kinggrin_anbeten2", */ "grepolove", /* Grepo Love */ "skullhaufen", "grepo_pacman" /*, "pferdehaufen" */ // "i/ckajscggscw4s2u60"
256 ];
257
258 var ForumObserver = new MutationObserver(function (mutations) {
259 mutations.forEach(function (mutation) {
260
261 if (mutation.addedNodes[0]) {
262
263 //console.debug("Added Nodes", mutation.addedNodes[0]);
264
265 // Message Box geladen
266 if(mutation.addedNodes[0].className === "redactor_box"){
267
268 //console.debug("Message Box geladen");
269
270 ForumObserver.observe($(".redactor_box").get(0), {
271 attributes: false,
272 childList: true,
273 characterData: false,
274 subtree:true
275 });
276 }
277
278 // Toolbar der Message Box geladen
279 if(_isSmileyButtonClicked === false && mutation.addedNodes[0].className === "redactor_toolbar") {
280 $(".redactor_btn_smilies").click();
281
282 // Soll sich nicht wieder deaktivieren
283 _isSmileyButtonClicked = true;
284 }
285
286 // Smileybar der Toolbar geladen
287 if(mutation.addedNodes[0].className === "redactor_smilies") {
288
289 // Observer soll nicht mehr feuern, wenn die Smileys hinzugefügt werden
290 ForumObserver.disconnect();
291
292 // Hässliche Smileys entfernen
293 $(".smilieCategory ul").empty();
294
295 // Greensmileys hinzufügen
296 for(var smiley in smileyArray.standard){
297 if(smileyArray.standard.hasOwnProperty(smiley)){
298 $(".smilieCategory ul").append(
299 '<li class="Smilie" data-text="">'+
300 '<img src="https://diotools.de/images/smileys/standard/smiley_emoticons_'+ smileyArray.standard[smiley] +'.gif" title="" alt="" data-smilie="yes">'+
301 '</li>'
302 );
303 }
304 }
305
306 $(".smilieCategory ul").append("<br><br>");
307
308 for(var smiley in smileyArray.grepolis){
309 if(smileyArray.grepolis.hasOwnProperty(smiley)){
310 $(".smilieCategory ul").append(
311 '<li class="Smilie" data-text="">'+
312 '<img src="https://diotools.de/images/smileys/grepolis/smiley_emoticons_'+ smileyArray.grepolis[smiley] +'.gif" title="" alt="" data-smilie="yes">'+
313 '</li>'
314 );
315 }
316 }
317
318 _isSmileyBarOpened = true;
319 }
320 }
321 });
322 });
323
324 // Smiley-Button aktivieren, um die Smiley-Toolbar zu öffnen
325 if($(".redactor_btn_smilies").get(0)){
326 $(".redactor_btn_smilies").click();
327
328 _isSmileyButtonClicked = true;
329 }
330
331 // Observer triggern
332 if($("#QuickReply").get(0)) {
333 ForumObserver.observe($("#QuickReply div").get(0), {
334 attributes: false,
335 childList: true,
336 characterData: false,
337 subtree:true
338 });
339 }
340 else if($("#ThreadReply").get(0)) {
341 ForumObserver.observe($("#ThreadReply div").get(0), {
342 attributes: false,
343 childList: true,
344 characterData: false,
345 subtree:true
346 });
347 }
348 /*
349 else if($("#ThreadCreate").get(0)) {
350 ForumObserver.observe($("#ThreadCreate fieldset .ctrlUnit dd div").get(0), {
351 attributes: false,
352 childList: true,
353 characterData: false
354 });
355 }
356 */
357
358 // Threaderstellung, Signatur bearbeiten, Beitrag bearbeiten
359 else if($("form.Preview").get(0)) {
360
361 ForumObserver.observe($("form.Preview .ctrlUnit dd div").get(0), {
362 attributes: false,
363 childList: true,
364 characterData: false
365 });
366 }
367 else if(typeof($("form.AutoValidator").get(0)) !== "undefined") {
368
369 ForumObserver.observe($("form.AutoValidator .messageContainer div").get(0), {
370 attributes: false,
371 childList: true,
372 characterData: false
373 });
374 }
375
376 // TODO: Bearbeiten, Nachrichten
377}
378
379
380
381function DIO_GAME(version, gm, DATA, time_a) {
382 var MutationObserver = uw.MutationObserver || window.MutationObserver,
383
384 WID, MID, AID, PID, LID,
385
386 dio_sprite = "http://666kb.com/i/d9xuhtcctx5fdi8i6.png"; // http://abload.de/img/dio_spritejmqxp.png, http://img1.myimg.de/DIOSPRITEe9708.png -> Forbidden!?
387
388 if (uw.location.pathname.indexOf("game") >= 0) {
389 DATA = JSON.parse(DATA.replace(/##/g, "'"));
390
391 WID = uw.Game.world_id;
392 MID = uw.Game.market_id;
393 AID = uw.Game.alliance_id;
394 PID = uw.Game.player_id;
395 LID = uw.Game.locale_lang.split("_")[0]; // LID ="es";
396
397 // World with Artemis ??
398 Game.hasArtemis = true; //Game.constants.gods.length == 6;
399 }
400
401 $.prototype.reverseList = [].reverse;
402
403 // Implement old jQuery method (version < 1.9)
404 $.fn.toggleClick = function () {
405 var methods = arguments; // Store the passed arguments for future reference
406 var count = methods.length; // Cache the number of methods
407
408 // Use return this to maintain jQuery chainability
409 // For each element you bind to
410 return this.each(function (i, item) {
411 // Create a local counter for that element
412 var index = 0;
413
414 // Bind a click handler to that element
415 $(item).on('click', function () {
416 // That when called will apply the 'index'th method to that element
417 // the index % count means that we constrain our iterator between 0
418 // and (count-1)
419 return methods[index++ % count].apply(this, arguments);
420 });
421 });
422 };
423
424 function saveValue(name, val) {
425 if (gm) {
426 saveValueGM(name, val);
427 } else {
428 localStorage.setItem(name, val);
429 }
430 }
431
432 function deleteValue(name) {
433 if (gm) {
434 deleteValueGM(name);
435 } else {
436 localStorage.removeItem(name);
437 }
438 }
439
440 /*******************************************************************************************************************************
441 * Graphic filters
442 *******************************************************************************************************************************/
443 if (uw.location.pathname.indexOf("game") >= 0) {
444 $('<svg width="0%" height="0%">' +
445 // GREYSCALE
446 '<filter id="GrayScale">' +
447 '<feColorMatrix type="matrix" values="0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0">' +
448 '</filter>' +
449 // SEPIA
450 '<filter id="Sepia">' +
451 '<feColorMatrix type="matrix" values="0.343 0.669 0.119 0 0 0.249 0.626 0.130 0 0 0.172 0.334 0.111 0 0 0.000 0.000 0.000 1 0">' +
452 '</filter>' +
453 // SATURATION
454 '<filter id="Saturation"><feColorMatrix type="saturate" values="0.2"></filter>' +
455 '<filter id="Saturation1"><feColorMatrix type="saturate" values="1"></filter>' +
456 '<filter id="Saturation2"><feColorMatrix type="saturate" values="2"></filter>' +
457 // HUE
458 '<filter id="Hue1"><feColorMatrix type="hueRotate" values= "65"></filter>' +
459 '<filter id="Hue2"><feColorMatrix type="hueRotate" values="150"></filter>' +
460 '<filter id="Hue3"><feColorMatrix type="hueRotate" values="-65"></filter>' +
461 // BRIGHTNESS
462 '<filter id="Brightness15">' +
463 '<feComponentTransfer><feFuncR type="linear" slope="1.5"/><feFuncG type="linear" slope="1.5"/><feFuncB type="linear" slope="1.5"/></feComponentTransfer>' +
464 '</filter>' +
465 '<filter id="Brightness12">' +
466 '<feComponentTransfer><feFuncR type="linear" slope="1.2"/><feFuncG type="linear" slope="1.2"/><feFuncB type="linear" slope="1.2"/></feComponentTransfer>' +
467 '</filter>' +
468 '<filter id="Brightness11">' +
469 '<feComponentTransfer><feFuncR type="linear" slope="1.1"/><feFuncG type="linear" slope="1.1"/><feFuncB type="linear" slope="1.1"/></feComponentTransfer>' +
470 '</filter>' +
471 '<filter id="Brightness10">' +
472 '<feComponentTransfer><feFuncR type="linear" slope="1.0"/><feFuncG type="linear" slope="1.0"/><feFuncB type="linear" slope="1.0"/></feComponentTransfer>' +
473 '</filter>' +
474 '<filter id="Brightness07">' +
475 '<feComponentTransfer><feFuncR type="linear" slope="0.7"/><feFuncG type="linear" slope="0.7"/><feFuncB type="linear" slope="0.7"/></feComponentTransfer>' +
476 '</filter>' +
477 '</svg>').appendTo('#ui_box');
478 }
479
480 /*******************************************************************************************************************************
481 * Language versions: german, english, french, russian, polish, spanish
482 *******************************************************************************************************************************/
483 var LANG = {
484 de: {
485 settings: {
486 dsc: "DIO-Tools bietet unter anderem einige Anzeigen, eine Smileyauswahlbox,<br>Handelsoptionen und einige Veränderungen des Layouts.",
487 act: "Funktionen der Toolsammlung aktivieren/deaktivieren:",
488 prv: "Vorschau einzelner Funktionen:",
489
490 version_old: "DIO-Tools-Version ist nicht aktuell",
491 version_new: "DIO-Tools-Version ist aktuell",
492 version_dev: "DIO-Tools-Entwicklerversion",
493
494 version_update: "Aktualisieren",
495
496 link_forum: "http://forum.de.grepolis.com/showthread.php?28838&goto=newpost", //"http://forum.de.grepolis.com/showthread.php?28838"
497 link_contact: "http://forum.de.grepolis.com/private.php?do=newpm&u=10548",
498
499 forum: "Forum",
500 author: "Autor",
501
502 cat_units: "Einheiten",
503 cat_icons: "Stadticons",
504 cat_forum: "Forum",
505 cat_trade: "Handel",
506 cat_wonders: "Weltwunder",
507 cat_layout: "Layout",
508 cat_other: "Sonstiges"
509 },
510 options: {
511 //bir: ["Biremenzähler", "Zählt die jeweiligen Biremen einer Stadt und summiert diese.<br><br>Anzeige im Minimap-Bullauge oben links"],
512 ava: ["Einheitenübersicht", "Zeigt die Einheiten aller Städte an"],
513 sml: ["Smileys", "Erweitert die BBCode-Leiste um eine Smileybox"],
514 str: ["Einheitenstärke", "Fügt mehrere Einheitenstärketabellen in verschiedenen Bereichen hinzu"],
515 tra: ["Transportkapazität", "Zeigt die belegte und verfügbare Transportkapazität im Einheitenmenu an"],
516 per: ["Prozentualer Handel", "Erweitert das Handelsfenster um einen Prozentualer Handel"],
517 rec: ["Rekrutierungshandel", "Erweitert das Handelsfenster um einen Rekrutierungshandel"],
518 cnt: ["EO-Zähler", "Zählt die ATT/UT-Anzahl im EO-Fenster"],
519 way: ["Laufzeit", "Zeigt im ATT/UT-Fenster die Laufzeit bei Verbesserter Truppenbewegung an"],
520 sim: ["Simulator", "Anpassung des Simulatorlayouts & permanente Anzeige der Erweiterten Modifikatorbox"],
521 spl: ["Zauberbox", "Komprimierte verschiebbare & magnetische Zauberbox (Positionsspeicherung)"],
522 act: ["Aktivitätsboxen", "Verbesserte Anzeige der Handels- und Truppenaktivitätsboxen (Positionsspeicherung)"],
523 pop: ["Gunst-Popup", 'Ändert das Aussehen des Gunst-Popups'],
524 tsk: ["Taskleiste", 'Vergrößert die Taskleiste und minimiert das "Tägliche Belohnung"-Fenster beim Start'],
525 cha: ["Chat", "Ersetzt den Allianzchat durch einen Welten-Chat"],
526 bbc: ["DEF-Formular", "Erweitert die BBCode-Leiste um ein automatisches DEF-Formular"],
527 com: ["Einheitenvergleich", "Fügt Einheitenvergleichstabellen hinzu"],
528 tic: ["Stadticons", "Jede Stadt erhält ein Icon für den Stadttyp (Automatische Erkennung)", "Zusätzliche Icons stehen bei der manuellen Auswahl zur Verfügung"],
529 til: ["Stadtliste", "Fügt die Stadticons zur Stadtliste hinzu"],
530 tim: ["Karte", "Setzt die Stadticons auf die strategische Karte"],
531 wwc: ["Anteil", "Anteilsrechner & Rohstoffzähler + Vor- & Zurück-Buttons bei fertiggestellten WW's (momentan nicht deaktivierbar!)"],
532 wwr: ["Rangliste", "Überarbeitete Weltwunderrangliste"],
533 wwi: ["Icons", 'Fügt Weltwundericons auf der strategischen Karte hinzu'],
534 con: ["Kontextmenu", 'Vertauscht "Stadt selektieren" und "Stadtübersicht" im Kontextmenu'],
535 sen: ["Abgeschickte Einheiten", 'Zeigt im Angriffs-/Unterstützungsfenster abgeschickte Einheiten an'],
536 tov: ["Stadtübersicht", 'Ersetzt die neue Stadtansicht mit der alten Fensteransicht'],
537 scr: ["Mausrad-Zoom", 'Man kann mit dem Mausrad die 3 Ansichten wechseln'],
538
539 err: ["Automatische Fehlerberichte senden", "Wenn du diese Option aktivierst, kannst du dabei helfen Fehler zu identifizieren."],
540 her: ["Thrakische Eroberung", "Verkleinerung der Karte der Thrakischen Eroberung."]
541 },
542 labels: {
543 uni: "Einheitenübersicht",
544 total: "Gesamt",
545 available: "Verfügbar",
546 outer: "Außerhalb",
547 con: "Selektieren",
548 // Smileys
549 std: "Standard",
550 gre: "Grepolis",
551 nat: "Natur",
552 ppl: "Leute",
553 oth: "Sonstige",
554 // Defense form
555 ttl: "Übersicht: Stadtverteidigung",
556 inf: "Informationen zur Stadt:",
557 dev: "Abweichung",
558 det: "Detailierte Landeinheiten",
559 prm: "Premiumboni",
560 sil: "Silberstand",
561 mov: "Truppenbewegungen:",
562 // WW
563 leg: "WW-Anteil",
564 stg: "Stufe",
565 tot: "Gesamt",
566 // Simulator
567 str: "Einheitenstärke",
568 los: "Verluste",
569 mod: "ohne Modifikatoreinfluss",
570 // Comparison box
571 dsc: "Einheitenvergleich",
572 hck: "Schlag",
573 prc: "Stich",
574 dst: "Distanz",
575 sea: "See",
576 att: "Angriff",
577 def: "Verteidigung",
578 spd: "Geschwindigkeit",
579 bty: "Beute (Rohstoffe)",
580 cap: "Transportkapazität",
581 res: "Baukosten (Rohstoffe)",
582 fav: "Gunst",
583 tim: "Bauzeit (s)",
584 // Trade
585 rat: "Ressourcenverhältnis eines Einheitentyps",
586 shr: "Anteil an der Lagerkapazität der Zielstadt",
587 per: "Prozentualer Handel",
588 // Sent units box
589 lab: "Abgeschickt",
590 improved_movement: "Verbesserte Truppenbewegung"
591 },
592 buttons: {
593 sav: "Speichern", ins: "Einfügen", res: "Zurücksetzen"
594 }
595 },
596
597 en: {
598 settings: {
599 dsc: "DIO-Tools offers, among other things, some displays, a smiley box,<br>trade options and some changes to the layout.",
600 act: "Activate/deactivate features of the toolset:",
601 prv: "Preview of several features:",
602
603 version_old: "Version is not up to date",
604 version_new: "Version is up to date",
605 version_dev: "Developer version",
606
607 version_update: "Update",
608
609 link_forum: "http://forum.en.grepolis.com/showthread.php?52104&goto=newpost",
610 link_contact: "http://forum.en.grepolis.com/private.php?do=newpm&u=46211",
611
612 forum: "Forum",
613 author: "Author",
614
615 cat_units: "Units",
616 cat_icons: "Town icons",
617 cat_forum: "Forum",
618 cat_trade: "Trade",
619 cat_wonders: "World wonder",
620 cat_layout: "Layout",
621 cat_other: "Miscellaneous"
622 },
623 options: {
624 //bir: ["Bireme counter", "Counts the biremes of a city and sums these"],
625 ava: ["Units overview", "Counts the units of all cities"],
626 sml: ["Smilies", "Extends the bbcode bar by a smiley box"],
627 str: ["Unit strength", "Adds unit strength tables in various areas"],
628 tra: ["Transport capacity", "Shows the occupied and available transport capacity in the unit menu"],
629 per: ["Percentual trade", "Extends the trade window by a percentual trade"],
630 rec: ["Recruiting trade", "Extends the trade window by a recruiting trade"],
631 cnt: ["Conquests", "Counts the attacks/supports in the conquest window"],
632 way: ["Troop speed", "Displays improved troop speed in the attack/support window"],
633 sim: ["Simulator", "Adaptation of the simulator layout & permanent display of the extended modifier box"],
634 spl: ["Spell box", "Compressed movable & magnetic spell box (position memory)"],
635 act: ["Activity boxes", "Improved display of trade and troop activity boxes (position memory)"],
636 pop: ["Favor popup", "Changes the favor popup"],
637 tsk: ["Taskbar", "Increases the taskbar and minimizes the daily reward window on startup"],
638 cha: ["Chat", 'Replaced the alliance chat by an world chat. (FlashPlayer required)'],
639 bbc: ["Defense form", "Extends the bbcode bar by an automatic defense form"],
640 com: ["Unit Comparison", "Adds unit comparison tables"],
641 tic: ["Town icons", "Each city receives an icon for the town type (automatic detection)", "Additional icons are available for manual selection"],
642 til: ["Town list", "Adds the town icons to the town list"],
643 tim: ["Map", "Sets the town icons on the strategic map"],
644 wwc: ["Calculator", "Share calculation & resources counter + previous & next buttons on finished world wonders (currently not deactivatable!)"],
645 wwr: ["Ranking", "Redesigned world wonder rankings"],
646 wwi: ["Icons", 'Adds world wonder icons on the strategic map'],
647 con: ["Context menu", 'Swaps "Select town" and "City overview" in the context menu'],
648 sen: ["Sent units", 'Shows sent units in the attack/support window'],
649 tov: ["Town overview", 'Replaces the new town overview with the old window style'],
650 scr: ["Mouse wheel", 'You can change the views with the mouse wheel'],
651
652 err: ["Send bug reports automatically", "If you activate this option, you can help identify bugs."],
653 her: ["Thracian Conquest", "Downsizing of the map of the Thracian conquest."]
654 },
655 labels: {
656 uni: "Units overview",
657 total: "Total",
658 available: "Available",
659 outer: "Outside",
660 con: "Select town",
661 // Smileys
662 std: "Standard",
663 gre: "Grepolis",
664 nat: "Nature",
665 ppl: "People",
666 oth: "Other",
667 hal: "Halloween",
668 xma: "Xmas",
669 // Defense form
670 ttl: "Overview: Town defense",
671 inf: "Town information:",
672 dev: "Deviation",
673 det: "Detailed land units",
674 prm: "Premium bonuses",
675 sil: "Silver volume",
676 mov: "Troop movements:",
677 // WW
678 leg: "WW Share",
679 stg: "Stage",
680 tot: "Total",
681 // Simulator
682 str: "Unit strength",
683 los: "Loss",
684 mod: "without modificator influence",
685 // Comparison box
686 dsc: "Unit comparison",
687 hck: "Blunt",
688 prc: "Sharp",
689 dst: "Distance",
690 sea: "Sea",
691 att: "Offensive",
692 def: "Defensive",
693 spd: "Speed",
694 bty: "Booty (resources)",
695 cap: "Transport capacity",
696 res: "Costs (resources)",
697 fav: "Favor",
698 tim: "Recruiting time (s)",
699 // Trade
700 rat: "Resource ratio of an unit type",
701 shr: "Share of the storage capacity of the target city",
702 per: "Percentage trade",
703 // Sent units box
704 lab: "Sent units",
705 improved_movement: "Improved troop movement"
706 },
707 buttons: {
708 sav: "Save", ins: "Insert", res: "Reset"
709 }
710 },
711 //////////////////////////////////////////////
712 // French Translation by eclat49 //
713 //////////////////////////////////////////////
714 fr: {
715 settings: {
716 dsc: "DIO-Tools offres certains écrans, une boîte de smiley, les options <br>commerciales, des changements à la mise en page et d'autres choses.",
717 act: "Activation/Désactivation des fonctions:",
718 prv: "Aperçu des fonctions séparées:"
719 },
720 options: {
721 //bir: ["Compteur de birèmes ", "Totalise l'ensemble des birèmes présentent en villes et les résume. (Remplace la mini carte dans le cadran)"],
722 ava: ["Présentation des unités", "Indique les unités de toutes les villes."],
723 sml: ["Smileys", "Rajoutes une boite de smilies à la boite de bbcode"],
724 str: ["Force unitaire", "Ajoutes des tableaux de force unitaire dans les différentes armes"],
725 //trd: [ "Commerce", "Ajout d'une option par pourcentage, par troupes pour le commerce, ainsi qu'un affichage des limites pour les festivals" ],
726 per: ["Commerce de pourcentage", ""],
727 rec: ["Commerce de recrutement", ""],
728 cnt: ["Compteur conquête", "Comptabilise le nombre d'attaque et de soutien dans la fenêtre de conquête"],
729 way: ["Vitesse des troupes ", "Rajoutes le temps de trajet avec le bonus accélération"],
730 sim: ["Simulateur", "Modification de la présentation du simulateur et affichage permanent des options premium"],
731 spl: ["Boîte de magie", "Boîte de sort cliquable et positionnable"],
732 act: ["Boîte d'activité", "Présentation améliorée du commerce et des mouvement de troupes (mémoire de position)"],
733 pop: ["Popup de faveur", 'Change la popup de faveur'],
734 tsk: ["Barre de tâches ", "La barre de tâches augmente et minimise le fenêtre de bonus journalier"],
735 cha: ["Chat", "Remplace le chat de l'alliance à travers un chat monde."],
736 bbc: ["Formulaire de défense", "Ajout d'un bouton dans la barre BBCode pour un formulaire de défense automatique"],
737 com: ["Comparaison des unités", "Ajoutes des tableaux de comparaison des unités"],
738 tic: ["Icônes des villes", "Chaque ville reçoit une icône pour le type de ville (détection automatique)", "Des icônes supplémentaires sont disponibles pour la sélection manuelle"],
739 til: ["Liste de ville", "Ajoute les icônes de la ville à la liste de la ville"],
740 tim: ["Carte", "Définit les icônes de la ville sur la carte stratégique"],
741 wwc: ["Merveille du monde", "Compteur de ressource et calcul d'envoi + bouton précédent et suivant sur les merveilles finies(ne peut être désactivé pour le moment)"],
742 wwr: ["", ""],
743 //wwi: [ "Icônes",'Adds world wonder icons on the strategic map' ],
744 con: ["Menu contextuel", 'Swaps "Sélectionner ville" et "Aperçu de la ville" dans le menu contextuel'],
745 sen: ["Unités envoyées", 'Affiche unités envoyées dans la fenêtre attaque/support'],
746 tov: ["Aperçu de ville", "Remplace la nouvelle aperçu de la ville avec l'ancien style de fenêtre"],
747 scr: ["Molette de la souris", 'Avec la molette de la souris vous pouvez changer les vues'],
748
749 err: ["Envoyer des rapports de bogues automatiquement", "Si vous activez cette option, vous pouvez aider à identifier les bugs."]
750 },
751 labels: {
752 uni: "Présentation des unités",
753 total: "Global",
754 available: "Disponible",
755 outer: "Extérieur",
756 con: "Sélectionner",
757 // Smileys
758 std: "Standard",
759 gre: "Grepolis",
760 nat: "Nature",
761 ppl: "Gens",
762 oth: "Autres",
763 // Defense form
764 ttl: "Aperçu: Défense de ville",
765 inf: "Renseignements sur la ville:",
766 dev: "Différence",
767 det: "Unités terrestres détaillées",
768 prm: "Bonus premium",
769 sil: "Remplissage de la grotte",
770 mov: "Mouvements de troupes:",
771 // WW
772 leg: "Participation",
773 stg: "Niveau",
774 tot: "Total",
775 // Simulator
776 str: "Force unitaire",
777 los: "Pertes",
778 mod: "sans influence de modificateur",
779 // Comparison box
780 dsc: "Comparaison des unités",
781 hck: "Contond.",
782 prc: "Blanche",
783 dst: "Jet",
784 sea: "Navale",
785 att: "Attaque",
786 def: "Défense",
787 spd: "Vitesse",
788 bty: "Butin",
789 cap: "Capacité de transport",
790 res: "Coût de construction",
791 fav: "Faveur",
792 tim: "Temps de construction (s)",
793 // Trade
794 rat: "Ratio des ressources d'un type d'unité",
795 shr: "Part de la capacité de stockage de la ville cible",
796 per: "Commerce de pourcentage",
797 // Sent units box
798 lab: "Envoyée",
799 improved_movement: "Mouvement des troupes amélioré"
800 },
801 buttons: {
802 sav: "Sauver", ins: "Insertion", res: "Remettre"
803 }
804 },
805 //////////////////////////////////////////////
806 // Russian Translation by MrBobr //
807 //////////////////////////////////////////////
808 ru: {
809 settings: {
810 dsc: "DIO-Tools изменÑет некоторые окна, добавлÑет новые Ñмайлы, отчёты,<br>улучшеные варианты торговли и другие функции.",
811 act: "Включение/выключение функций:",
812 prv: "Примеры внеÑённых изменений:"
813 },
814 options: {
815 //bir: ["Счётчик бирем", "Показывает чиÑло бирем во вÑех городах"],
816 ava: ["Обзор единиц", "Указывает единицы вÑех городов"], // ?
817 sml: ["Смайлы", "ДобавлÑет кнопку Ð´Ð»Ñ Ð²Ñтавки Ñмайлов в ÑообщениÑ"],
818 str: ["Сила отрÑда", "ДобавлÑет таблицу общей Ñилы отрÑда в некоторых окнах"],
819 //trd: [ "ТорговлÑ", "ДобавлÑет маркеры и отправку недоÑтающих реÑурÑов, необходимых Ð´Ð»Ñ Ñ„ÐµÑтивалÑ. ИнÑтрументы Ð´Ð»Ñ Ð´Ð¾Ð»ÐµÐ²Ð¾Ð¹ торговли" ],
820 per: ["Процент торговлÑ", ""],
821 rec: ["Рекрутинг торговлÑ", ""],
822 cnt: ["ЗавоеваниÑ", "Отображение общего чиÑла атак/подкреплений в окне Ð·Ð°Ð²Ð¾ÐµÐ²Ð°Ð½Ð¸Ñ Ð³Ð¾Ñ€Ð¾Ð´Ð°"],
823 way: ["30% уÑкорение", "Отображает примерное Ð²Ñ€ÐµÐ¼Ñ Ð´Ð²Ð¸Ð¶ÐµÐ½Ð¸Ñ Ð¾Ñ‚Ñ€Ñда Ñ 30% бонуÑом"],
824 sim: ["СимулÑтор", "Изменение интерфейÑа ÑимулÑтора, добавление новых функций"],
825 spl: ["ЗаклинаниÑ", "ИзменÑет положение окна заклинаний"],
826 act: ["ПеремещениÑ", "Показывает окна переÑылки реÑурÑов и Ð¿ÐµÑ€ÐµÐ¼ÐµÑ‰ÐµÐ½Ð¸Ñ Ð²Ð¾Ð¹Ñк"],
827 pop: ["БлагоÑклонноÑть", "Отображение окна Ñ ÑƒÑ€Ð¾Ð²Ð½ÐµÐ¼ благоÑклонноÑти богов"],
828 tsk: ["ТаÑкбар", "Увеличение ширины таÑкбара и Ñворачивание окна ежедневной награды при входе в игру"],
829 // cha: ["Чат", 'Замена чата игры на irc-чат'],
830 bbc: ["Форма обороны", "ДобавлÑет кнопку Ð´Ð»Ñ Ð²Ñтавки в Ñообщение отчёта о городе"], // Beschreibung passt nicht ganz
831 com: ["Сравнение юнитов", "ДобавлÑет окно ÑÑ€Ð°Ð²Ð½ÐµÐ½Ð¸Ñ ÑŽÐ½Ð¸Ñ‚Ð¾Ð²"],
832 tic: ["Типы городов", "Каждый город получает значок Ð´Ð»Ñ Ð³Ð¾Ñ€Ð¾Ð´Ñкого типа (автоматичеÑкое определение)", "Дополнительные иконки доÑтупны Ð´Ð»Ñ Ñ€ÑƒÑ‡Ð½Ð¾Ð³Ð¾ выбора"], // ?
833 til: ["СпиÑок город", "ДобавлÑет значки городÑкие в ÑпиÑок города"], // ?
834 tim: ["Карта", "УÑтанавливает городÑкие иконки на ÑтратегичеÑкой карте"], // ?
835 wwc: ["Чудо Ñвета", "Share calculation & resources counter + previous & next buttons on finished world wonders (currently not deactivatable!)"],
836 wwr: ["", ""],
837 //wwi: [ "World wonder icons",'Adds world wonder icons on the strategic map' ],
838 //con: [ "Context menu", 'Swaps "Select town" and "City overview" in the context menu'],
839 //sen: [ "Sent units", 'Shows sent units in the attack/support window'],
840 tov: ["Обзор Город", 'ЗаменÑет новый обзор города Ñ Ñтаром Ñтиле окна'], // ?
841 scr: ["КолеÑо мыши", 'С помощью колеÑа мыши вы можете изменить взглÑды'], // ?
842
843 err: ["Отправить ÑÐ¾Ð¾Ð±Ñ‰ÐµÐ½Ð¸Ñ Ð¾Ð± ошибках автоматичеÑки", "ЕÑли вы включите Ñту опцию, вы можете помочь идентифицировать ошибки"]
844 },
845
846 labels: {
847 uni: "Обзор единиц",
848 total: "Oбщий",
849 available: "доÑтупный",
850 outer: "вне",
851 con: "выбирать",
852 // Smileys
853 std: "",
854 gre: "",
855 nat: "",
856 ppl: "",
857 oth: "",
858 // Defense form
859 ttl: "Обзор: Отчёт о городе",
860 inf: "Ð˜Ð½Ñ„Ð¾Ñ€Ð¼Ð°Ñ†Ð¸Ñ Ð¾ войÑках и поÑтройках:",
861 dev: "Отклонение",
862 det: "Детальный отчёт",
863 prm: "Премиум-бонуÑÑ‹",
864 sil: "Серебро в пещере",
865 mov: "ПеремещениÑ",
866 // WW
867 leg: "",
868 stg: "",
869 tot: "",
870 // Simulator
871 str: "Сила войÑк",
872 los: "Потери",
873 mod: "без учёта заклинаний, бонуÑов, иÑÑледований",
874 // Comparison box
875 dsc: "Сравнение юнитов",
876 hck: "Ударное",
877 prc: "Колющее",
878 dst: "Дальнего боÑ",
879 sea: "МорÑкие",
880 att: "Ðтака",
881 def: "Защита",
882 spd: "СкороÑть",
883 bty: "Добыча (реÑурÑÑ‹)",
884 cap: "ВмеÑтимоÑть транÑпортов",
885 res: "СтоимоÑть (реÑурÑÑ‹)",
886 fav: "БлагоÑклонноÑть",
887 tim: "Ð’Ñ€ÐµÐ¼Ñ Ð½Ð°Ð¹Ð¼Ð° (Ñ)",
888 // Trade
889 rat: "",
890 shr: "",
891 per: "",
892 // Sent units box
893 lab: "Отправлено",
894 improved_movement: "Ð£Ð»ÑƒÑ‡ÑˆÐµÐ½Ð½Ð°Ñ Ð¿ÐµÑ€ÐµÐ¼ÐµÑ‰ÐµÐ½Ð¸Ðµ войÑк"
895 },
896
897 buttons: {
898 sav: "Сохраниить", ins: "Ð’Ñтавка", res: "СброÑ"
899 }
900 },
901 //////////////////////////////////////////////
902 // Polish Translation by anpu //
903 //////////////////////////////////////////////
904 pl: {
905 settings: {
906 dsc: "DIO-Tools oferuje (między innymi) poprawione widoki, nowe uśmieszki,<br>opcje handlu i zmiany w wyglądzie.",
907 act: "Włącz/wyłącz funkcje skryptu:",
908 prv: "podgląd poszczególnych opcji:"
909 },
910 options: {
911 //bir: ["Licznik birem", "Zlicza i sumuje biremy z miast"],
912 ava: ["PrzeglÄ…d jednostek", "Wskazuje jednostki wszystkich miast"], // ?
913 sml: ["Emotki", "Dodaje dodatkowe (zielone) emotikonki"],
914 str: ["Siła jednostek", "dodaje tabelki z siłą jednostek w różnych miejscach gry"],
915 //trd: [ "Handel", "Rozszerza okno handlu o handel procentowy, proporcje surowców wg jednostek, dodaje znaczniki dla festynów" ],
916 per: ["Handel procentowy", ""],
917 rec: ["Handel rekrutacyjne", ""],
918 cnt: ["Podboje", "Zlicza wsparcia/ataki w oknie podboju (tylko własne podboje)"],
919 way: ["Prędkość wojsk", "Wyświetla dodatkowo czas jednostek dla bonusu przyspieszone ruchy wojsk"],
920 sim: ["Symulator", "Dostosowanie wyglądu symulatora oraz dodanie szybkich pól wyboru"],
921 spl: ["Ramka czarów", "Kompaktowa pływająca ramka z czarami (można umieścić w dowolnym miejscu ekranu. Zapamiętuje położenie.)"],
922 act: ["Ramki aktywności", "Ulepszony podgląd ruchów wojsk i handlu (można umieścić w dowolnym miejscu ekranu. Zapamiętuje położenie.)"],
923 pop: ["Åaski", "Zmienia wyglÄ…d ramki informacyjnej o iloÅ›ci produkowanych Å‚ask"],
924 tsk: ["Pasek skrótów", "Powiększa pasek skrótów i minimalizuje okienko z bonusem dziennym"],
925 // cha: ["Czat", 'Zastępuje standardowy Chat chatem IRC'],
926 bbc: ["Raportów obronnych", "Rozszerza pasek skrótów BBcode o generator raportów obronnych"],
927 com: ["Porównianie", "Dodaje tabelki z porównaniem jednostek"],
928 tic: ["Ikony miasta", "Każde miasto otrzyma ikonę typu miasta (automatyczne wykrywanie)", "Dodatkowe ikony są dostępne dla ręcznego wyboru"], // ?
929 til: ["Lista miasto", "Dodaje ikony miasta do listy miasta"], // ?
930 tim: ["Mapa", "Zestawy ikon miasta na mapie strategicznej"], // ?
931 wwc: ["Cuda Świata", "Liczy udział w budowie oraz ilość wysłanych surowców na budowę Cudu Świata oraz dodaje przyciski do szybkiego przełączania między cudami (obecnie nie możliwe do wyłączenia)"],
932 wwr: ["", ""],
933 //wwi: [ "World wonder icons",'Adds world wonder icons on the strategic map' ],
934 con: ["menu kontekstowe", 'Zamiemia miejcami przycisk "wybierz miasto" z przyciskiem "podgląd miasta" po kliknięciu miasta na mapie'],
935 sen: ["Wysłane jednostki", 'Pokaż wysłane jednostki w oknie wysyłania ataków/wsparć'],
936 tov: ["Podgląd miasta", 'Zastępuje nowy podgląd miasta starym'],
937 scr: ["Zoom", 'Możesz zmienić poziom przybliżenia mapy kółkiem myszy'],
938
939 err: ["Automatycznie wysyłać raporty o błędach", "Jeśli włączysz tę opcję, możesz pomóc zidentyfikować błędy"]
940
941 },
942 labels: {
943 uni: "PrzeglÄ…d jednostek",
944 total: "Ogólny",
945 available: "Dostępny",
946 outer: "Na zewnÄ…trz",
947 con: "Wybierz miasto",
948 // Smileys
949 std: "Standard" /* "Standardowe" */,
950 gre: "Grepolis",
951 nat: "Przyroda",
952 ppl: "Ludzie",
953 oth: "Inne",
954 // Defense form
955 ttl: "PodglÄ…d: Obrona miasta",
956 inf: "Informacje o mieście:",
957 dev: "Ochyłka",
958 det: "jednostki lÄ…dowe",
959 prm: "opcje Premium",
960 sil: "Ilość srebra",
961 mov: "Ruchy wojsk",
962 // WW
963 leg: "Udział w Cudzie",
964 stg: "Poziom",
965 tot: "ÅÄ…cznie",
966 // Simulator
967 str: "Siła jednostek",
968 los: "Straty",
969 mod: "bez modyfikatorów",
970 // Comparison box
971 dsc: "Porównianie jednostek",
972 hck: "Obuchowa",
973 prc: "TnÄ…ca",
974 dst: "Dystansowa",
975 sea: "Morskie",
976 att: "Offensywne",
977 def: "Defensywne",
978 spd: "Prędkość",
979 bty: "Åup (surowce)",
980 cap: "Pojemność transportu",
981 res: "Koszta (surowce)",
982 fav: "Åaski",
983 tim: "Czas rekrutacji (s)",
984 // Trade
985 rat: "Stosunek surowców dla wybranej jednostki",
986 shr: "procent zapełnienia magazynu w docelowym mieście",
987 per: "Handel procentowy",
988 // Sent units box
989 lab: "Wysłane jednostki",
990 improved_movement: "Przyspieszone ruchy wojsk"
991 },
992 buttons: {
993 sav: "Zapisz", ins: "Wstaw", res: "Anuluj"
994 }
995 },
996 //////////////////////////////////////////////
997 // Spanish Translation by Juana de Castilla //
998 //////////////////////////////////////////////
999 es: {
1000 settings: {
1001 dsc: "DIO-Tools ofrece, entre otras cosas, varias pantallas, ventana de <br>emoticones, opciones de comercio y algunos cambios en el diseño.",
1002 act: "Activar/desactivar caracterÃsticas de las herramientas:",
1003 prv: "Vista previa de varias caracterÃsticas:"
1004 },
1005 options: {
1006 //bir: ["Contador de birremes", "Cuenta los birremes de una ciudad y los suma"],
1007 ava: ["Información general unidades", "Indica las unidades de todas las ciudades"], // ?
1008 sml: ["Emoticones", "Código BB para emoticones"],
1009 str: ["Fortaleza de la Unidad", "Añade tabla de fortalezas de cada unidad en varias zonas"],
1010 //trd: [ "Comercio", "Añade en la pestaña de comercio un porcentaje de comercio y reclutamiento y limitadores de Mercado por cada ciudad" ],
1011 per: ["Comercio de porcentual", ""],
1012 rec: ["Comercio de reclutamiento", ""],
1013 cnt: ["Conquistas", "contador de ataques y refuerzos en la pestaña de conquista"],
1014 way: ["Velocidad de tropas", "Muestra movimiento de tropas mejorado en la ventana de ataque/refuerzo"],
1015 sim: ["Simulador", "Adaptación de la ventana del simulador incluyendo recuadro de modificadores"],
1016 spl: ["Ventana de hechizos", "Ventana deslizante y comprimida de los hechizos (memoria posicional)"],
1017 act: ["Ventana de actividad", "Mejora las ventanas de comercio y movimiento de tropas (memoria posicional)"],
1018 pop: ["Popup", "Cambia el popup de favores"],
1019 tsk: ["Barra de tareas", "aumenta la barra de tareas y minimice la recompensa al aparecer"],
1020 // cha: ["Chat", 'Sustituye el chat de la alianza con un irc chat.'],
1021 bbc: ["Formulario de defensa", "Añade en la barra de códigos bb un formulario de defensa"],
1022 com: ["Comparación", "añade ventana de comparación de unidades"],
1023 tic: ["Iconos de la ciudad", "Cada ciudad recibe un icono para el tipo de la ciudad (detección automática)", "Iconos adicionales están disponibles para la selección manual"],
1024 til: ["Lista de la ciudad", "Agrega los iconos de la ciudad a la lista de la ciudad"],
1025 tim: ["Map", "Establece los iconos de la ciudad en el mapa estratégico"],
1026 wwc: ["Maravillas", "Calcula participación & contador de recursos + antes y después teclas de maravillas terminadas (no desactibable ahora!)"],
1027 wwr: ["", ""],
1028 //wwi: [ "World wonder icons",'Adds world wonder icons on the strategic map' ],
1029 con: ["menú contextual", 'Cambia "Elegir ciudad" y "vista de la ciudad" en el menú contextual '],
1030 sen: ["Unidades enviadas", 'Muestra las unidades enviadas en la ventana de ataque/refuerzos'],
1031 tov: ["Información de la ciudad", 'sustituye la vista nueva de ciudad por la ventana antigua'],
1032 scr: ["Rueda raton", 'Puede cambiar las vistas con la rueda del raton'],
1033
1034 err: ["Enviar informes de errores automáticamente", "Si se activa esta opción, puede ayudar a identificar errores."]
1035 },
1036 labels: {
1037 uni: "Información general unidades",
1038 total: "Total",
1039 available: "Disponible",
1040 outer: "Fuera",
1041 con: "Escoger ciudad",
1042 // Smileys
1043 std: "Standard",
1044 gre: "Grepolis",
1045 nat: "Natura",
1046 ppl: "Gente",
1047 oth: "Otros",
1048 // Defense form
1049 ttl: "Vista general: Defensa de la ciudad",
1050 inf: "Información de la ciudad:",
1051 dev: "Desviación",
1052 det: "Unidades de tierra detalladas",
1053 prm: "Bonos Premium",
1054 sil: "Volumen de plata",
1055 mov: "Movimientos de tropas:",
1056 // WW
1057 leg: "WW cuota",
1058 stg: "Nivel",
1059 tot: "Total",
1060 // Simulator
1061 str: "Fortaleza de la Unidad",
1062 los: "Perdida",
1063 mod: "sin influencia del modificador",
1064 // Comparison box
1065 dsc: "Comparación de Unidades",
1066 hck: "Contundente",
1067 prc: "Punzante",
1068 dst: "Distancia",
1069 sea: "Mar",
1070 att: "Ataque",
1071 def: "Defensa",
1072 spd: "Velocidad",
1073 bty: "BotÃn (recursos)",
1074 cap: "Capacidad de transporte",
1075 res: "Costes (recursos)",
1076 fav: "Favor",
1077 tim: "Tiempo de reclutamiento (s)",
1078 // Trade
1079 rat: "Proporción de recursos de un tipo de unidad",
1080 shr: "Porcentaje de la capacidad de almacenamiento de la ciudad destino",
1081 per: "Porcentaje de comercio",
1082 // Sent units box
1083 lab: "Unidades enviadas",
1084 improved_movement: "Movimiento de tropas mejorados"
1085 },
1086 buttons: {
1087 sav: "Guardar", ins: "Insertar", res: "Reinicio"
1088 }
1089 },
1090 ar: {},
1091 //////////////////////////////////////////////
1092 // Portuguese (BR) Translation by HELL //
1093 //////////////////////////////////////////////
1094 br: {
1095 settings: {
1096 dsc: "DIO-Tools oferece, entre outras coisas, algumas telas, uma caixa de smiley, opções de comércio <br> e algumas alterações no layout.",
1097 act: "Ativar/desativar recursos do conjunto de ferramentas:",
1098 prv: "Pré-visualização de vários recursos:",
1099
1100 version_old: "Versão não está atualizada",
1101 version_new: "Versão está atualizada",
1102 version_dev: "Versão do desenvolvedor",
1103
1104 version_update: "Atualização",
1105
1106 link_forum: "http://forum.en.grepolis.com/showthread.php?52104&goto=newpost",
1107 link_contact: "http://forum.en.grepolis.com/private.php?do=newpm&u=46211",
1108
1109 forum: "Forum",
1110 author: "Autor",
1111
1112 cat_units: "Unidades",
1113 cat_icons: "Ãcones nas Cidades",
1114 cat_forum: "Forum",
1115 cat_trade: "Comércio",
1116 cat_wonders: "Maravilhas do Mundo",
1117 cat_layout: "Layout",
1118 cat_other: "Outros"
1119 },
1120 options: {
1121 // bir: ["Contador de Birremes", "Conta as biremes da cidade na cidade"],
1122 ava: ["Visão Geral da unidade", "Indica as unidades de todas as cidades"], // ?
1123 sml: ["Smilies", "Estende o bbcode com uma caixa de smiley"],
1124 str: ["Força das Tropas", "Adiciona quadros de força das tropas em diversas áreas"],
1125 tra: ["Capacidade de Transporte", "Mostra a capacidade de transporte ocupado e disponÃvel no menu de unidades"],
1126 per: ["Percentual de comércio", "Estende-se a janela de comércio com um percentual de comércio"],
1127 rec: ["Comércio para recrutamento", "Estende-se a janela de comércio com um comércio de recrutamento"],
1128 cnt: ["Conquistas", "Conta os ataques/apoios na janela de conquista"],
1129 way: ["Velocidade da Tropa", "Displays mostram a possivél velocidade de tropa na janela de ataque/suporte"],
1130 sim: ["Simulador", "Adaptação do layout simulador & exposição permanente da caixa poderes estendida"],
1131 spl: ["Caixa de Poderes Divinos", "Pequena caixa móvel & magnética de poderes divinos (com memória de posição) "],
1132 act: ["Ativar caixas suspensas de comércio e ataque", "Melhorias da exibição de caixas de comércio e atividade tropa (com memória de posição)"],
1133 pop: ["Caixa de favores divino", "Altera a caixa de favores divino por um novo layout"],
1134 tsk: ["Barra de tarefas", "Aumenta a barra de tarefas e minimiza a janela recompensa diária no inicio"],
1135 // cha: ["Chat", 'Substituiu o da bate-papo por um bate-papo IRC.'],
1136 bbc: ["Pedido de Apoio", "Estende a barra de bbcode com uma forma de Pedido de Apoio Automática"],
1137 com: ["Comparação de Unidades", "Adiciona tabelas de comparação de unidade"],
1138 tic: ["Ãcones nas Cidades", "Cada cidade recebe um Ãcone para o tipo de tropas na cidade (detecção automática) "," Ãcones adicionais estão disponÃveis para seleção manual"],
1139 til: ["Lista das Cidades", "Adiciona os Ãcones da cidade na lista de cidades"],
1140 tim: ["Mapa", "Mostra os Ãcones das cidades no mapa estratégico"],
1141 wwc: ["Calculadora de WW", "Cálculo compartilhado & contador de recursos + botões anterior e próxima maravilhas do mundo (atualmente não desactivável!)"],
1142 wwr: ["Classificação", "Classificação das maravilha do mundo redesenhadas"],
1143 wwi: ["Icones", 'Adiciona Ãcones nas maravilha do mundo no mapa estratégico'],
1144 con: ["Menu de Contexto", 'Troca da "Selecione cidade" e "Visão Geral da Cidade" no menu de contexto'],
1145 sen: ["Unidades Enviadas", 'Shows sent units in the attack/support window'],
1146 tov: ["Visão da Cidade", 'Substitui o novo panorama da cidade, com o estilo da janela antiga'],
1147 scr: ["Roda do Mouse", 'Você pode alterar os pontos de vista com a roda do mouse'],
1148
1149 err: ["Enviar automaticamente relatórios de erros", "Se você ativar essa opção, você pode ajudar a identificar erros."],
1150 her: ["Conquista Thracian", "Redução de tamanho do mapa da conquista Thracian."]
1151 },
1152 labels: {
1153 uni: "Visão Geral da unidade",
1154 total: "Global",
1155 available: "DisponÃvel",
1156 outer: "Fora",
1157 con: "Selecionar cidade",
1158 // Smileys
1159 std: "Padrão",
1160 gre: "Grepolis",
1161 nat: "Natural",
1162 ppl: "Popular",
1163 oth: "Outros",
1164 hal: "Halloween",
1165 xma: "Natal",
1166 // Defense form
1167 ttl: "Pedido de Apoio",
1168 inf: "Informação da cidade:",
1169 dev: "Desvio",
1170 det: "Unidades Detalhadas",
1171 prm: "Bônus Premium",
1172 sil: "Prata na Gruta",
1173 mov: "Movimentação de Tropas:",
1174 // WW
1175 leg: "WW Maravilhas",
1176 stg: "Level",
1177 tot: "Total",
1178 // Simulator
1179 str: "Força das Unidades",
1180 los: "Perdas",
1181 mod: "Sem modificador de influência",
1182 // Comparison box
1183 dsc: "Comparação de unidades",
1184 hck: "Impacto",
1185 prc: "Corte",
1186 dst: "Arremço",
1187 sea: "Naval",
1188 att: "Ofensivo",
1189 def: "Defensivo",
1190 spd: "Velocidade",
1191 bty: "Saque (recursos)",
1192 cap: "Capacidade de trasporte",
1193 res: "Custo (recursos)",
1194 fav: "Favor",
1195 tim: "Tempo de recrutamento (s)",
1196 // Trade
1197 rat: "Proporção de recursos de um tipo de unidade",
1198 shr: "A partir do armazenamento sobre a cidade de destino",
1199 per: "Percentual de comércio",
1200 // Sent units box
1201 lab: "Unidades enviadas",
1202 improved_movement: "Movimentação de tropas com ajuste de bônus"
1203 },
1204 buttons: {
1205 sav: "Salvar", ins: "Inserir", res: "Resetar"
1206 }
1207 },
1208 pt : {},
1209 //////////////////////////////////////////////
1210 // Czech Translation by Piwus //
1211 //////////////////////////////////////////////
1212 cz: {
1213 settings: {
1214 dsc: "DIO-Tools nabÃzÃ,mimo jiné,nÄ›která nová zobrazenÃ,okénko smajlÃků,<br>obchodnà možnosti a nÄ›které zmÄ›ny v rozloženà panelů.",
1215 act: "Aktivovat/Deaktivovat funkce sady nástrojů:",
1216 prv: "Ukázka nÄ›kolika funkcÃ:",
1217
1218 version_old: "Verze je zastaralá",
1219 version_new: "Verze je aktuálnÃ",
1220 version_dev: "Vývojářská verze",
1221
1222 version_update: "Aktualizovat",
1223
1224 link_forum: "http://forum.en.grepolis.com/showthread.php?52104&goto=newpost",
1225 link_contact: "http://forum.en.grepolis.com/private.php?do=newpm&u=46211",
1226
1227 forum: "Forum",
1228 author: "Autor",
1229
1230 cat_units: "Jednotky",
1231 cat_icons: "Ikony měst",
1232 cat_forum: "Forum",
1233 cat_trade: "Obchod",
1234 cat_wonders: "Div světa",
1235 cat_layout: "Okna",
1236 cat_other: "OstatnÃ"
1237 },
1238 options: {
1239 // bir: ["PoÄÃtadlo birém", "SpoÄÃtá každé birémy ve mÄ›stech a seÄte je."],
1240 ava: ["Jednotky PÅ™ehled", "OznaÄuje jednotky vÅ¡emi mÄ›sty"], // ?
1241 sml: ["SmajlÃci", "RozÅ¡iÅ™uje panel BBkodů okénkem smajlÃků"],
1242 str: ["SÃla jednotek", "PÅ™idává tabulku sil jednotek v různých oblastech"],
1243 tra: ["Transportnà kapacita", "Zobrazuje obsazenou a dostupnou transportnà kapacitu v nabÃdce jednotek"],
1244 per: ["Procentuálnà obchod", "RozÅ¡iÅ™uje obchodnà okno možnostà procentuálnÃho obchodu"],
1245 rec: ["Obchod rekrutace", "Rozšiřuje obchodnà okno možnostà obchodem pro rekrutaci"],
1246 cnt: ["DobývánÃ", "PoÄÃtá Útok/Obrana v oknÄ› dobývánà (pouze vlastnà dobývánà zatÃm)"],
1247 way: ["Rychlost vojsk", "Zobrazuje vylepšenou rychlost vojsk v okně útoku/obrany"],
1248 sim: ["Simulátor", "PÅ™izpůsobenà rozloženà simulátoru & permanentnà zobrazovánà rozÅ¡ÃÅ™eného okna modifikátoru"],
1249 spl: ["Okénko kouzel", "StlaÄené klouzánà oken & magnetické okénko kouzel (pozice pamÄ›ti)"],
1250 act: ["Aktivnà okénka", "ZlepÅ¡ený zobrazenà obchodů a vojsk aktivnÃmi okénky (pozice pamÄ›ti)"],
1251 pop: ["Vyskakovacà okénko pÅ™ÃznÄ›", "ZmÄ›nà vyskakovacà okno seznamu pÅ™ÃznÃ"],
1252 tsk: ["Hlavnà panel", "ZvyÅ¡uje hlavnà panel a minimalizuje bonus dennà odmÄ›ny po pÅ™ihlášenÃ"],
1253 // cha: ["Chat", 'Nahrazen alianÄnà chat chatem IRC.'],
1254 bbc: ["Obranné hlášenÃ", "RozÅ¡iÅ™uje panel BBkodů automatickém hlášenà obrany mÄ›sta"],
1255 com: ["Porovnánà jednotek", "Přidává tabulku porovnánà jednotek"],
1256 tic: ["Ikony měst", "Každé město dostává svojà ikonku dle typu města (automatická detekce)", "Dalšà ikonky jsou k dispozici manuálně"],
1257 til: ["Seznam měst", "Přidává ikony měst do seznamu měst"],
1258 tim: ["Mapa", "Přidává ikony měst na stategickou mapu"],
1259 wwc: ["KalkulaÄka", "VýpoÄet podÃlu & poÄÃtadlo surovin + pÅ™edchozà & dalšà tlaÄÃtka na dokonÄených divech svÄ›ta (aktuálnÄ› nelze deaktivovat!)"],
1260 wwr: ["ŽebÅ™ÃÄek", "PÅ™edÄ›laný žebÅ™ÃÄek divů svÄ›ta"],
1261 wwi: ["Ikony", 'PÅ™Ãdává ikony divů svÄ›ta na strategickou mapu'],
1262 con: ["Kontextové menu", 'Vyměňuje "Vybrat město" a "Přehled města" v kontextovém menu'],
1263 sen: ["Odeslané jednotky", 'Zobrazuje odeslané jednotky útoku/obrany v okně'],
1264 tov: ["PÅ™ehled mÄ›sta", 'Nahrazuje nový pÅ™ehled mÄ›st starÅ¡Ãm stylem okna'],
1265 scr: ["KoleÄko myÅ¡i", 'MůžeÅ¡ zmÄ›nit pohledy s koleÄkem myÅ¡i'],
1266
1267 err: ["Hlásit chyby automaticky", "Pokud aktivuješ tuto možnost,pomůžeš nám identifikovat chyby."],
1268 her: ["Thrácké dobývánÃ", "Redukuje mapy Thráckého dobývánÃ."]
1269 },
1270 labels: {
1271 uni: "Jednotky Přehled",
1272 total: "Celkový",
1273 available: "K dispozici",
1274 outer: "VnÄ›",
1275 con: "Zvolit město",
1276 // Smileys
1277 std: "StandartnÃ",
1278 gre: "Grepolis",
1279 nat: "PÅ™Ãroda",
1280 ppl: "Lidi",
1281 oth: "OstatnÃ",
1282 hal: "Halloween",
1283 xma: "Vánoce",
1284 // Defense form
1285 ttl: "Přehled: Obrana města",
1286 inf: "Informace o městě:",
1287 dev: "Odchylka",
1288 det: "Podrobné pozemnà jednotky",
1289 prm: "Prémiové bonusy",
1290 sil: "Objem stÅ™Ãbra",
1291 mov: "Pohyby vojsk:",
1292 // WW
1293 leg: "PodÃl divu svÄ›ta",
1294 stg: "Stupeň",
1295 tot: "Celkem",
1296 // Simulator
1297 str: "SÃla jednotek",
1298 los: "Ztráta",
1299 mod: "bez vlivu modifikátoru",
1300 // Comparison box
1301 dsc: "Porovnánà jednotek",
1302 hck: "SeÄné",
1303 prc: "Bodné",
1304 dst: "Střelné",
1305 sea: "Moře",
1306 att: "ÚtoÄné",
1307 def: "Obranné",
1308 spd: "Rychlost",
1309 bty: "Kořist (suroviny)",
1310 cap: "Transportnà kapacita",
1311 res: "Náklady (suroviny)",
1312 fav: "PÅ™Ãzeň",
1313 tim: "Doba rekrutovánà (s)",
1314 // Trade
1315 rat: "Poměr surovin typu jednotky",
1316 shr: "PodÃl na úložné kapacitÄ› cÃlového mÄ›sta",
1317 per: "Procentuálnà obchod",
1318 // Sent units box
1319 lab: "Odeslané jednotky",
1320 improved_movement: "Vylepšený pohyb jednotek"
1321 },
1322 buttons: {
1323 sav: "Uložit", ins: "Vložit", res: "Resetovat"
1324 }
1325 }
1326 };
1327
1328 LANG.ar = LANG.es;
1329 LANG.pt = LANG.br;
1330 LANG.cs = LANG.cz;
1331
1332 // Create JSON
1333 // console.log(JSON.stringify(LANG.en));
1334
1335 // Forum: Choose language
1336 if (!(uw.location.pathname.indexOf("game") >= 0)) {
1337 LID = uw.location.host.split(".")[1];
1338 }
1339
1340 console.debug("SPRACHE", LID);
1341 // Translation GET
1342 function getText(category, name) {
1343 var txt = "???";
1344 if (LANG[LID]) {
1345 if (LANG[LID][category]) {
1346 if (LANG[LID][category][name]) {
1347 txt = LANG[LID][category][name];
1348 } else {
1349 if (LANG.en[category]) {
1350 if (LANG.en[category][name]) {
1351 txt = LANG.en[category][name];
1352 }
1353 }
1354 }
1355 } else {
1356 if (LANG.en[category]) {
1357 if (LANG.en[category][name]) {
1358 txt = LANG.en[category][name];
1359 }
1360 }
1361 }
1362 } else {
1363 if (LANG.en[category]) {
1364 if (LANG.en[category][name]) {
1365 txt = LANG.en[category][name];
1366 }
1367 }
1368 }
1369 return txt;
1370 }
1371
1372 /*******************************************************************************************************************************
1373 * Settings
1374 *******************************************************************************************************************************/
1375
1376 // (De)activation of the features
1377 var options_def = {
1378 bir: true, // Biremes counter
1379 ava: true, // Available units
1380 sml: true, // Smileys
1381 str: true, // Unit strength
1382 tra: true, // Transport capacity
1383 per: true, // Percentual Trade
1384 rec: true, // Recruiting Trade
1385 way: true, // Troop speed
1386 cnt: true, // Attack/support counter
1387 sim: true, // Simulator
1388 spl: true, // Spell box
1389 act: false,// Activity boxes
1390 tsk: true, // Task bar
1391 cha: true, // Chat
1392 pop: true, // Favor popup
1393 bbc: true, // BBCode bar
1394 com: true, // Unit comparison
1395 tic: true, // Town icons
1396 til: true, // Town icons: Town list
1397 tim: true, // Town icons: Map
1398 wwc: true, // World wonder counter
1399 wwr: true, // World wonder ranking
1400 wwi: true, // World wonder icons
1401 con: true, // Context menu
1402 sen: true, // Sent units
1403 tov: false,// Town overview
1404 scr: true, // Mausrad,
1405
1406 err: false,// Error Reports
1407 her: true // Thrakische Eroberung
1408 };
1409
1410 if (uw.location.pathname.indexOf("game") >= 0) {
1411 for (var opt in options_def) {
1412 if (options_def.hasOwnProperty(opt)) {
1413 if (DATA.options[opt] === undefined) {
1414 DATA.options[opt] = options_def[opt];
1415 }
1416 }
1417 }
1418 }
1419
1420 var version_text = '', version_color = 'black';
1421
1422 function getLatestVersion() {
1423 $('<style id="dio_version">' +
1424 '#version_info .version_icon { background: url(http://666kb.com/i/ct1etaz0uyohw402i.png) -50px -50px no-repeat; width:25px; height:25px; float:left; } ' +
1425 '#version_info .version_icon.red { filter:hue-rotate(-100deg); -webkit-filter: hue-rotate(-100deg); } ' +
1426 '#version_info .version_icon.green { filter:hue-rotate(0deg); -webkit-filter: hue-rotate(0deg); } ' +
1427 '#version_info .version_icon.blue { filter:hue-rotate(120deg); -webkit-filter: hue-rotate(120deg); } ' +
1428 '#version_info .version_text { line-height: 2; margin: 0px 6px 0px 6px; float: left;} ' +
1429 '</style>').appendTo("head");
1430
1431 var v_info = $('#version_info');
1432 if (version_text === '') {
1433 $.ajax({
1434 type: "GET", url: "https://diotools.de/scripts/version.php",
1435 success: function (response) {
1436 var latest_version = parseFloat(response),
1437 current_version = parseFloat(version);
1438
1439 if (current_version < latest_version) {
1440 version_text = "<div class='version_icon red'></div><div class='version_text'>" + getText('settings', 'version_old') + "</div><div class='version_icon red'></div>" +
1441 '<a class="version_text" href="https://diotools.de/downloads/DIO-TOOLS.user.js" target="_blank">--> Update</a>';
1442 version_color = 'crimson';
1443 } else if (current_version == latest_version) {
1444 version_text = "<div class='version_icon green'></div><div class='version_text'>" + getText('settings', 'version_new') + "</div><div class='version_icon green'></div>";
1445 version_color = 'darkgreen';
1446 } else {
1447 version_text = "<div class='version_icon blue'></div><div class='version_text'>" + getText('settings', 'version_dev') + "</div><div class='version_icon blue'></div>";
1448 version_color = 'darkblue';
1449 }
1450 v_info.html(version_text).css({color: version_color});
1451 }
1452 });
1453 } else {
1454 v_info.html(version_text).css({color: version_color});
1455 }
1456 }
1457
1458 // Add DIO-Tools to grepo settings
1459 function settings() {
1460 var wid = $(".settings-menu").get(0).parentNode.id;
1461
1462 if (!$("#dio_tools").get(0)) {
1463 $(".settings-menu ul:last").append('<li id="dio_li"><img id="dio_icon" src="http://www.greensmilies.com/smile/smiley_emoticons_smile.gif"></div> <a id="dio_tools" href="#"> DIO-Tools</a></li>');
1464 }
1465
1466 $(".settings-link").click(function () {
1467 $('.section').each(function () {
1468 this.style.display = "block";
1469 });
1470 $('.settings-container').removeClass("dio_overflow");
1471
1472 $('#dio_bg_medusa').css({display: "none"});
1473
1474 if ($('#dio_settings').get(0)) {
1475 $('#dio_settings').get(0).style.display = "none";
1476 }
1477 });
1478
1479 $("#dio_tools").click(function () {
1480 if ($('.email').get(0)) {
1481 $('.settings-container').removeClass("email");
1482 }
1483
1484 $('.settings-container').addClass("dio_overflow");
1485
1486 $('#dio_bg_medusa').css({display: "block"});
1487
1488 if (!$('#dio_settings').get(0)) {
1489 // Styles
1490 $('<style id="dio_settings_style">' +
1491 // Chrome Scroollbar Style
1492 '#dio_settings ::-webkit-scrollbar { width: 13px; } ' +
1493 '#dio_settings ::-webkit-scrollbar-track { background-color: rgba(130, 186, 135, 0.5); border-top-right-radius: 4px; border-bottom-right-radius: 4px; } ' +
1494 '#dio_settings ::-webkit-scrollbar-thumb { background-color: rgba(87, 121, 45, 0.5); border-radius: 3px; } ' +
1495 '#dio_settings ::-webkit-scrollbar-thumb:hover { background-color: rgba(87, 121, 45, 0.8); } ' +
1496
1497 '#dio_settings table tr :first-child { text-align:center; vertical-align:top; } ' +
1498
1499 '#dio_settings #version_info { font-weight:bold;height: 35px;margin-top:-5px; } ' +
1500 '#dio_settings #version_info img { margin:-1px 2px -8px 0px; } ' +
1501
1502 '#dio_settings .icon_types_table { font-size:0.7em; line-height:2.5; border:1px solid green; border-spacing:10px 2px; border-radius:5px; } ' +
1503 '#dio_settings .icon_types_table td { text-align:left; } ' +
1504
1505 '#dio_settings table p { margin:0.2em 0em; } ' +
1506
1507 '#dio_settings .checkbox_new .cbx_caption { white-space:nowrap; margin-right:10px; font-weight:bold; } ' +
1508
1509 '#dio_settings .dio_settings_tabs {width:auto; border:2px solid darkgreen; background:#2B241A; padding:1px 1px 0px 1px; right:auto; border-top-left-radius:5px; border-top-right-radius:5px; border-bottom:0px;} ' +
1510
1511 '#dio_settings .dio_settings_tabs li { float:left; } ' +
1512
1513 '#dio_settings .icon_small { margin:0px; } ' +
1514
1515 '#dio_settings img { max-width:90px; max-height:90px; margin-right:10px; } ' +
1516
1517 '#dio_settings .content { border:2px solid darkgreen; border-radius:5px; border-top-left-radius:0px; background:rgba(31, 25, 12, 0.1); top:23px; position:relative; padding:10px; height:350px; overflow-y:auto; } ' +
1518 '#dio_settings .content .content_category { display:none; border-spacing:5px; } ' +
1519
1520 '#dio_settings .dio_options_table legend { font-weight:bold; } ' +
1521 '#dio_settings .dio_options_table p { margin:0px; } ' +
1522 '#dio_settings #donate_btn { filter: hue-rotate(45deg); -webkit-filter: hue-rotate(45deg); } ' +
1523
1524 '#donate_btn { background: url(' + dio_sprite + '); width:100px; height:26px; background-position: 0px -300px; } ' +
1525 '#donate_btn.de { background-position: 0px -250px; } ' +
1526 '#donate_btn.en { background-position: 0px -300px; } ' +
1527
1528 '#dio_hall table { border-spacing: 9px 3px; } ' +
1529 '#dio_hall table th { text-align:left !important;color:green;text-decoration:underline;padding-bottom:10px; } ' +
1530 '#dio_hall table td.value { text-align: right; } ' +
1531
1532 '#dio_hall table td.laurel.green { background: url("/images/game/ally/founder.png") no-repeat; height:18px; width:18px; background-size:100%; } ' +
1533 '#dio_hall table td.laurel.bronze { background: url("https://diotools.de/images/game/laurel_sprite.png") no-repeat 25%; height:18px; width:18px; } ' +
1534 '#dio_hall table td.laurel.silver { background: url("https://diotools.de/images/game/laurel_sprite.png") no-repeat 50%; height:18px; width:18px; } ' +
1535 '#dio_hall table td.laurel.gold { background: url("https://diotools.de/images/game/laurel_sprite.png") no-repeat 75%; height:18px; width:18px; } ' +
1536 '#dio_hall table td.laurel.blue { background: url("https://diotools.de/images/game/laurel_sprite.png") no-repeat 100%; height:18px; width:18px; } ' +
1537 '</style>').appendTo('head');
1538
1539
1540 $('.settings-container').append(
1541 '<div id="dio_settings" class="player_settings section"><div id="dio_bg_medusa"></div>' +
1542 '<div class="game_header bold"><a href="#" target="_blank" style="color:white">DIO-Tools (v' + version + ')</a></div>' +
1543
1544 // Check latest version
1545 '<div id="version_info"><img src="http://666kb.com/i/csmicltyu4zhiwo5b.gif" /></div>' +
1546
1547 // Donate button
1548 '<div style="position:absolute; left: 495px;top: 40px;"><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3EWUQUTMC5VKS" target="_blank">' +
1549 '<div id="donate_btn" class="' + LID + '" alt="Donate"></div></a></div>' +
1550
1551 // Settings navigation
1552 '<ul class="menu_inner dio_settings_tabs">' +
1553 '<li><a class="submenu_link active" href="#" id="dio_units"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_units") + '</span></span></span></a></li>' +
1554 '<li><a class="submenu_link" href="#" id="dio_icons"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_icons") + '</span></span></span></a></li>' +
1555 '<li><a class="submenu_link" href="#" id="dio_forum"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_forum") + '</span></span></span></a></li>' +
1556 '<li><a class="submenu_link" href="#" id="dio_trade"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_trade") + '</span></span></span></a></li>' +
1557 '<li><a class="submenu_link" href="#" id="dio_wonder"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_wonders") + '</span></span></span></a></li>' +
1558 '<li><a class="submenu_link" href="#" id="dio_layout"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_layout") + '</span></span></span></a></li>' +
1559 '<li><a class="submenu_link" href="#" id="dio_other"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_other") + '</span></span></span></a></li>' +
1560 '</ul>' +
1561
1562 // Settings content
1563 '<DIV class="content">' +
1564
1565 // Units tab
1566 '<table id="dio_units_table" class="content_category visible"><tr>' +
1567 '<td><img src="https://diotools.de/images/game/settings/units/available_units.png" alt="" /></td>' +
1568 '<td><div id="ava" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "ava")[0] + '</div></div>' +
1569 '<p>' + getText("options", "ava")[1] + '</p></td>' +
1570 '</tr><tr>' +
1571 '<td><img src="https://diotools.de/images/game/settings/units/sent_units.png" alt="" /></td>' +
1572 '<td><div id="sen" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "sen")[0] + '</div></div>' +
1573 '<p>' + getText("options", "sen")[1] + '</p></td>' +
1574 '</tr><tr>' +
1575 '<td><img src="https://diotools.de/images/game/settings/units/unit_strength.png" alt="" /></td>' +
1576 '<td><div id="str" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "str")[0] + '</div></div>' +
1577 '<p>' + getText("options", "str")[1] + '</p></td>' +
1578 '</tr><tr>' +
1579 '<td><img src="https://diotools.de/images/game/settings/units/transport_capacity.png" alt="" /></td>' +
1580 '<td><div id="tra" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "tra")[0] + '</div></div>' +
1581 '<p>' + getText("options", "tra")[1] + '</p></td>' +
1582 '</tr><tr>' +
1583 '<td><img src="https://diotools.de/images/game/settings/units/unit_comparison.png" alt="" /></td>' +
1584 '<td><div id="com" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "com")[0] + '</div></div>' +
1585 '<p>' + getText("options", "com")[1] + '</p></td>' +
1586 '</tr></table>' +
1587
1588 // Icons tab
1589 '<table id="dio_icons_table" class="content_category"><tr>' +
1590 '<td><img src="https://diotools.de/images/game/settings/townicons/townicons.png" alt="" /></td>' +
1591 '<td><div id="tic" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "tic")[0] + '</div></div>' +
1592 '<p>' + getText("options", "tic")[1] + '</p>' +
1593 '<table class="icon_types_table">' +
1594 '<tr><td style="width:115px"><div class="icon_small townicon_lo"></div> Land Offensive</td>' + '<td><div class="icon_small townicon_fo"></div> Fly Offensive</td></tr>' +
1595 '<tr><td><div class="icon_small townicon_ld"></div> Land Defensive</td>' + '<td><div class="icon_small townicon_fd"></div> Fly Defensive</td></tr>' +
1596 '<tr><td><div class="icon_small townicon_so"></div> Navy Offensive</td>' + '<td><div class="icon_small townicon_no"></div> Outside</td></tr>' +
1597 '<tr><td><div class="icon_small townicon_sd"></div> Navy Defensive</td>' + '<td><div class="icon_small townicon_po"></div> Empty</td></tr>' +
1598 '</table><br>' +
1599 '<p>' + getText("options", "tic")[2] + ':</p>' +
1600 '<div class="icon_small townicon_sh"></div><div class="icon_small townicon_di"></div><div class="icon_small townicon_un"></div><div class="icon_small townicon_ko"></div>' +
1601 '<div class="icon_small townicon_ti"></div><div class="icon_small townicon_gr"></div><div class="icon_small townicon_dp"></div><div class="icon_small townicon_re"></div>' +
1602 '<div class="icon_small townicon_wd"></div><div class="icon_small townicon_st"></div><div class="icon_small townicon_si"></div><div class="icon_small townicon_bu"></div>' +
1603 '<div class="icon_small townicon_he"></div><div class="icon_small townicon_ch"></div><div class="icon_small townicon_bo"></div><div class="icon_small townicon_fa"></div>' +
1604 '<div class="icon_small townicon_wo"></div>' +
1605 '</td>' +
1606 '</tr><tr>' +
1607 '<td><img src="https://diotools.de/images/game/settings/townicons/townlist.png" alt="" style="border: 1px solid rgb(158, 133, 78);" /></td>' +
1608 '<td><div id="til" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "til")[0] + '</div></div>' +
1609 '<p>' + getText("options", "til")[1] + '</p></td>' +
1610 '</tr><tr>' +
1611 '<td><img src="https://diotools.de/images/game/settings/townicons/map.png" alt="" /></td>' +
1612 '<td><div id="tim" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "tim")[0] + '</div></div>' +
1613 '<p>' + getText("options", "tim")[1] + '</p></td>' +
1614 '</tr></table>' +
1615
1616 // Forum tab
1617 '<table id="dio_forum_table" class="content_category"><tr>' +
1618 '<td><img src="https://diotools.de/images/game/settings/forum/smiley_box.png" alt="" /></td>' +
1619 '<td><div id="sml" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "sml")[0] + '</div></div>' +
1620 '<p>' + getText("options", "sml")[1] + '</p>' +
1621 '<img src="http://www.greensmilies.com/smile/smiley_emoticons_mttao_wassermann.gif" /> <img src="http://666kb.com/i/cigrqlp2odi2kqo24.gif" /> ' +
1622 '<img src="http://666kb.com/i/cifvfsu3e2sdiipn0.gif" alt="" /> <img src="http://666kb.com/i/cigmv8wnffb3v0ifg.gif" /> ' +
1623 '<img src="http://666kb.com/i/cj2byjendffymp88t.gif" alt="" /> <img src="http://666kb.com/i/cj1l9gndtu3nduyvi.gif" /> ' +
1624 '<img src="http://666kb.com/i/cigrmpfofys5xtiks.gif" alt="" />' + //'<img src="http://666kb.com/i/cifohielywpedbyh8.gif" />'+
1625 '<br><br><br></td>' +
1626 '</tr><tr>' +
1627 '<td><img src="https://diotools.de/images/game/settings/forum/def_formular.png" alt="" /></td>' +
1628 '<td><div id="bbc" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "bbc")[0] + '</div></div>' +
1629 '<p>' + getText("options", "bbc")[1] + '</p><br><img src="http://s1.directupload.net/images/140401/9b2ydh82.png" alt="" style="max-width:none !important;" /></td>' +
1630 '</tr></table>' +
1631
1632 // Trade tab
1633 '<table id="dio_trade_table" class="content_category"><tr>' +
1634 '<td><img src="https://diotools.de/images/game/settings/trade/recruiting_trade.png" /></td>' +
1635 '<td><div id="rec" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "rec")[0] + '</div></div>' +
1636 '<p>' + getText("options", "rec")[1] + '</p><br>' +
1637 /*
1638 '<p><u>Beispiel Feuerschiffe:</u><br>'+
1639 '<p>Verhältnisauswahl</p>'+
1640 '<table style="font-size: 0.7em;line-height: 2.5;border: 1px solid green;border-spacing: 10px 2px;border-radius: 5px;">'+
1641 '<tr><th></th><th><div class="icon_small townicon_wd"></div></th><td></td><th><div class="icon_small townicon_st"></div></th><td></td><th><div class="icon_small townicon_si"></div></th></tr>'+
1642 '<tr><td>Kosten</td><td>1300</td><td></td><td>300</td><td></td><td>800</td></tr>'+
1643 '<tr><td>Verhältnis</td><td>1</td><td>:</td><td>0.23</td><td>:</td><td>0.62</td></tr>'+
1644 '</table>'+
1645 '<p>Lagergröße Zielstadt: 25500 - 1000 Puffer (=100%)</p>'+
1646 '<p>Handelsmenge 25%: </p>'+
1647 '<table style="font-size: 0.7em;line-height: 2.5;">'+
1648 '<tr><td>4 x 25%</td><td>4 x 25%</td><td>...</td></tr>'+
1649 '<tr><td><img src="http://s7.directupload.net/images/140920/uc4dsyp9.png" style="width:60px" /></td>'+
1650 '<td><img src="http://s7.directupload.net/images/140920/uc4dsyp9.png" style="width:60px" /></td><td>...</td></tr>'+
1651 '</table>'+
1652 //'- Versenden von 35 einzelnen Rohstoffportionen im Anteil 20% (z.B. 4900 Holz, 1130 Stein, 3015 Silber bei Lagerkapazität von 25.500), das heißt 5 Portionen für einen Rekrutierungsslot'+
1653 //'- nach Ankommen von jeweils 5 Portionen, Einheiten in Auftrag geben (19-21 Feuerschiffe bei maximaler Lagerkapazität)'+
1654 //'Ein Puffer von 1000 Rohstoffeinheiten wird dabei von der Lagerkapazität der Zielstadt abgezogen, damit Rekrutierungsreste und neu produzierte Rohstoffe nicht gleich zum Überlaufen des Lagers führen.'+
1655 //'Das Ganze beschleunigt das Befüllen der Rekrutierungsschleifen enorm und es gehen dabei keine Rohstoffe verloren.</p>'+
1656 '<br><br><br></td>'+
1657 */
1658 '</tr><tr>' +
1659 '<td><img src="https://diotools.de/images/game/settings/trade/percentage_trade.png" /></td>' +
1660 '<td><div id="per" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "per")[0] + '</div></div>' +
1661 '<p>' + getText("options", "per")[1] + '</p><br></td>' +
1662 /*
1663 '</tr><tr>'+
1664 '<td><img src="http://s7.directupload.net/images/140917/tveb5n33.png" /></td>'+
1665 '<td><div id="trd2" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">Trade Limit Marker</div></div>'+
1666 '<p></p></td>'+
1667 */
1668 '</tr></table>' +
1669
1670 // World wonder tab
1671 '<table id="dio_wonder_table" class="content_category"><tr>' +
1672 '<td><img src="https://diotools.de/images/game/settings/wonders/share.png" alt="" /></td>' +
1673 '<td><div id="wwc" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "wwc")[0] + '</div></div>' +
1674 '<p>' + getText("options", "wwc")[1] + '</p><br/>' +
1675 '<img src="https://diotools.de/images/game/settings/wonders/share_calculator.png" alt="" style="max-width:none !important;" /></td>' +
1676 '</tr><tr>' +
1677 '<td><img src="https://diotools.de/images/game/settings/wonders/ranking.png" alt="" /></td>' +
1678 '<td><div id="wwr" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "wwr")[0] + '</div></div>' +
1679 '<p>' + getText("options", "wwr")[1] + '</p></td>' +
1680 '</tr><tr>' +
1681 '<td><img src="https://diotools.de/images/game/settings/wonders/icons.png" alt="" /></td>' +
1682 '<td><div id="wwi" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "wwi")[0] + '</div></div>' +
1683 '<p>' + getText("options", "wwi")[1] + '</p></td>' +
1684 '</tr></table>' +
1685
1686 // Layout tab
1687 '<table id="dio_layout_table" class="content_category"><tr>' +
1688 '<td><img src="https://diotools.de/images/game/settings/layout/simulator.png" alt="" /></td>' +
1689 '<td><div id="sim" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "sim")[0] + '</div></div>' +
1690 '<p>' + getText("options", "sim")[1] + '</p></td>' +
1691 '</tr><tr>' +
1692 '<td><img src="https://diotools.de/images/game/settings/layout/spellbox.png" alt="" /></td>' +
1693 '<td><div id="spl" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "spl")[0] + '</div></div>' +
1694 '<p>' + getText("options", "spl")[1] + '</p></td>' +
1695 '</tr><tr>' +
1696
1697 ((Game.market_id !== "de" && Game.market_id !== "zz") ? (
1698 '<td><img src="https://diotools.de/images/game/settings/layout/taskbar.png" alt="" /></td>' +
1699 '<td><div id="tsk" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "tsk")[0] + '</div></div>' +
1700 '<p>' + getText("options", "tsk")[1] + '</p></td>' +
1701 '</tr><tr>'
1702 ) : "" ) +
1703
1704 '<td><img src="https://diotools.de/images/game/settings/layout/favor_popup.png" alt="" /></td>' +
1705 '<td><div id="pop" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "pop")[0] + '</div></div>' +
1706 '<p>' + getText("options", "pop")[1] + '</p></td>' +
1707 '</tr><tr>' +
1708 '<td><img src="https://diotools.de/images/game/settings/layout/contextmenu.png" alt="" /></td>' +
1709 '<td><div id="con" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "con")[0] + '</div></div>' +
1710 '<p>' + getText("options", "con")[1] + '</p></td>' +
1711 '</tr><tr>' +
1712 '<td><img src="https://diotools.de/images/game/settings/layout/activity_boxes.png" alt="" /></td>' +
1713 '<td><div id="act" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "act")[0] + '</div></div>' +
1714 '<p>' + getText("options", "act")[1] + '</p></td>' +
1715 '</tr></table>' +
1716
1717 // Other Stuff tab
1718 '<table id="dio_other_table" class="content_category"><tr>' +
1719 '<td><img src="https://diotools.de/images/game/settings/misc/troop_speed.png" style="border: 1px solid rgb(158, 133, 78);" alt="" /></td>' +
1720 '<td><div id="way" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "way")[0] + '</div></div>' +
1721 '<p>' + getText("options", "way")[1] + '</p></td>' +
1722 '</tr><tr>' +
1723
1724 // Betaphase in DE
1725 ((Game.market_id === "de" || Game.market_id === "zz") ? (
1726
1727 '<td><img src="https://diotools.de/images/game/settings/misc/chat_new.png" alt="" /></td>' +
1728 '<td><div id="cha" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "cha")[0] + '</div></div>' +
1729 '<p>' + getText("options", "cha")[1] + '</p></td>' +
1730 '</tr><tr>'
1731
1732 ) : "") +
1733
1734 '<td><img src="https://diotools.de/images/game/settings/misc/conquer_counter.png" style="border: 1px solid rgb(158, 133, 78);" alt="" /></td>' +
1735 '<td><div id="cnt" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "cnt")[0] + '</div></div>' +
1736 '<p>' + getText("options", "cnt")[1] + '</p></td>' +
1737 '</tr><tr>' +
1738 '<td><img src="https://diotools.de/images/game/settings/misc/mousewheel_zoom.png" alt="" /></td>' +
1739 '<td><div id="scr" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "scr")[0] + '</div></div>' +
1740 '<p>' + getText("options", "scr")[1] + '</p><br><br></td>' +
1741 '</tr><tr>' +
1742 '<td><img src="" alt="" /></td>' +
1743 '<td><div id="err" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "err")[0] + '</div></div>' +
1744 '<p>' + getText("options", "err")[1] + '</p></td>' +
1745 '</tr></table>' +
1746
1747
1748 // Hall of DIO-Tools tab
1749 '<div id="dio_hall" class="content_category">'+
1750 "<p>I like to thank all of you who helped the development of DIO-Tools by donating or translating!</p>"+
1751 '<table style="float:left;margin-right: 75px;">'+
1752 '<tr><th colspan="3">Donations</th></tr>'+
1753 (function(){
1754 var donations = [
1755 ["Eduard R", 50],
1756 ["Gregoire L", 25],
1757 ["Renee A", 20], ["Dirk R", 20], ["Patti T", 20],
1758 ["Klaus N", 15],
1759 ["Marco S", 10], ["Richard L", 10], ["Carsten K", 10], ["Tatiana H", 10], ["Ursula S", 10], ["Susanne S", 10], ["Falk T", 10],
1760 ["Belinda M", 8], ["Wolfgang R", 8],
1761 ["Miguel B", 7],
1762 ["Antje S", 5], ["Hans-Jörg S", 5], ["Deanna P", 5], ["ForexTraction", 5], ["Rene F", 5], ["Rüdiger D", 5], ["Hans Hermann S", 5],
1763 ["Siegbert M", 5], ["Wilhelm B", 5], ["Peter P", 5], ["Helga W", 5], ["Lydia R", 5],
1764 ["Michael S", 3],
1765 ["Mario P", 2], ["Artur G", 2], ["Heiko K", 2], ["Alexander B", 2], ["Dick N", 2],
1766 ["Marcel G", 1], ["Ramona L", 1], ["Dennis S", 1], ["Konstandinos K", 1], ["Sarl T", 1], ["Jagadics I", 1], ["Andreas R", 1],
1767 ["Peter F", 1], ["Vinicio G", 1], ["Marielle M", 1], ["Christian B", 1], ["Bernd W", 1], ["Maria N", 1], ["Thomas W", 1],
1768 ["Domenik F", 1], ["Oliver H", 1], ["Jens R", 1], ["Nicole S", 1], ["Hartmut S", 1], ["Alex L", 1], ["Andreas S", 1]
1769 ];
1770 var donation_table = "";
1771
1772 for(var d = 0; d < donations.length; d++){
1773
1774 var donation_class = "";
1775
1776 switch(donations[d][1]){
1777 case 50: donation_class = "gold"; break;
1778 case 25: donation_class = "silver"; break;
1779 case 20: donation_class = "bronze"; break;
1780 default: donation_class = "green"; break;
1781 }
1782
1783 donation_table += '<tr class="donation"><td class="laurel '+ donation_class +'"></td><td>' + donations[d][0] + '</td><td class="value">' + donations[d][1] + '€</td></tr>';
1784 }
1785
1786 return donation_table;
1787 })() +
1788 '</table>'+
1789 '<table>'+
1790 '<tr><th colspan="3">Translations</th></tr>'+
1791 (function(){
1792 var translations = [
1793 ["eclat49", "FR"],
1794 ["MrBobr", "RU"],
1795 ["anpu", "PL"],
1796 ["Juana de Castilla", "ES"],
1797 ["HELL", "BR"],
1798 ["Piwus", "CZ"]
1799 ];
1800
1801 var translation_table = "";
1802
1803 for(var d = 0; d < translations.length; d++){
1804 translation_table += '<tr class="translation"><td class="laurel blue"></td><td >' + translations[d][0] + '</td><td class="value">' + translations[d][1] + '</td></tr>';
1805 }
1806
1807 return translation_table;
1808 })() +
1809 '</table>'+
1810 '</div>' +
1811
1812 '</DIV>' +
1813
1814 // Links (Forum, PM, ...)
1815 '<div style="bottom: -50px;font-weight: bold;position: absolute;width: 99%;">' +
1816
1817 '<a id="hall_of_diotools" href="#" style="font-weight:bold; float:left">' +
1818 '<img src="/images/game/ally/founder.png" alt="" style="float:left;height:19px;margin:0px 5px -3px;"><span>Hall of DIO-Tools</span></a>' +
1819
1820 '<span class="bbcodes_player bold" style="font-weight:bold; float:right; margin-left:20px;">' + getText("settings", "author") + ': ' +
1821 '<a id="link_contact" href=' + getText("settings", "link_contact") + ' target="_blank">Diony</a></span>' +
1822
1823 '<a id="link_forum" href=' + getText("settings", "link_forum") + ' target="_blank" style="font-weight:bold; float:right">' +
1824 '<img src="http://forum.de.grepolis.com/grepolis/statusicon/forum_new-16.png" alt="" style="margin: 0px 5px -3px 5px;" /><span>' + getText("settings", "forum") + '</span></a>' +
1825
1826 '</div>' +
1827
1828 '</div></div>');
1829
1830 getLatestVersion();
1831
1832 // Tab event handler
1833 $('#dio_settings .dio_settings_tabs .submenu_link').click(function () {
1834 if (!$(this).hasClass("active")) {
1835 $('#dio_settings .dio_settings_tabs .submenu_link.active').removeClass("active");
1836 $(this).addClass("active");
1837 $("#dio_settings .visible").removeClass("visible");
1838 $("#" + this.id + "_table").addClass("visible");
1839 }
1840 });
1841
1842 //
1843 $('#hall_of_diotools').click(function () {
1844 $('#dio_settings .dio_settings_tabs .submenu_link.active').removeClass("active");
1845
1846 $("#dio_settings .visible").removeClass("visible");
1847 $("#dio_hall").addClass("visible");
1848 });
1849
1850 $("#dio_settings .checkbox_new").click(function () {
1851 $(this).toggleClass("checked").toggleClass("disabled").toggleClass("green");
1852 toggleActivation(this.id);
1853
1854 DATA.options[this.id] = $(this).hasClass("checked");
1855
1856 saveValue("options", JSON.stringify(DATA.options));
1857 });
1858 for (var e in DATA.options) {
1859 if (DATA.options.hasOwnProperty(e)) {
1860 if (DATA.options[e] === true) {
1861 $("#" + e).addClass("checked").addClass("green");
1862 } else {
1863 $("#" + e).addClass("disabled");
1864 }
1865 }
1866 }
1867
1868 $('#dio_save').click(function () {
1869 $('#dio_settings .checkbox_new').each(function () {
1870 var act = false;
1871 if ($("#" + this.id).hasClass("checked")) {
1872 act = true;
1873 }
1874 DATA.options[this.id] = act;
1875 });
1876 saveValue("options", JSON.stringify(DATA.options));
1877 });
1878 }
1879 $('.section').each(function () {
1880 this.style.display = "none";
1881 });
1882 $('#dio_settings').get(0).style.display = "block";
1883 });
1884 }
1885
1886 function toggleActivation(opt) {
1887 var FEATURE, activation = true;
1888 switch (opt) {
1889 case "sml":
1890 FEATURE = SmileyBox;
1891 break;
1892 case "bir":
1893 FEATURE = BiremeCounter;
1894 break;
1895 case "str":
1896 FEATURE = UnitStrength.Menu;
1897 break;
1898 case "tra":
1899 FEATURE = TransportCapacity;
1900 break;
1901 case "ava":
1902 FEATURE = AvailableUnits;
1903 break;
1904 case "sim":
1905 FEATURE = Simulator;
1906 break;
1907 case "spl":
1908 FEATURE = Spellbox;
1909 break;
1910 case "tsk":
1911 FEATURE = Taskbar;
1912 break;
1913 case "scr":
1914 FEATURE = MouseWheelZoom;
1915 break;
1916 case "cha":
1917 FEATURE = Chat;
1918 break;
1919 case "com":
1920 FEATURE = UnitComparison;
1921 break;
1922 case "pop":
1923 FEATURE = FavorPopup;
1924 break;
1925 case "con":
1926 FEATURE = ContextMenu;
1927 break;
1928 case "tic":
1929 FEATURE = TownIcons;
1930 break;
1931 case "tim":
1932 FEATURE = TownIcons.Map;
1933 break;
1934 case "til":
1935 FEATURE = TownList;
1936 break;
1937 case "sen":
1938 FEATURE = SentUnits;
1939 break;
1940 case "act":
1941 FEATURE = ActivityBoxes;
1942 break;
1943 case "wwc":
1944 FEATURE = WorldWonderCalculator;
1945 break;
1946 case "wwr":
1947 FEATURE = WorldWonderRanking;
1948 break;
1949 case "wwi":
1950 FEATURE = WorldWonderIcons;
1951 break;
1952 case "pom":
1953 FEATURE = PoliticalMap;
1954 break;
1955 case "rec":
1956 FEATURE = RecruitingTrade;
1957 break;
1958 case "way":
1959 FEATURE = ShortDuration;
1960 break;
1961
1962 default:
1963 activation = false;
1964 break;
1965 }
1966 if (activation) {
1967 if (DATA.options[opt]) {
1968 FEATURE.deactivate();
1969 } else {
1970 FEATURE.activate();
1971 }
1972 }
1973 }
1974
1975 function addSettingsButton() {
1976 var tooltip_str = "DIO-Tools: " + (DM.getl10n("layout", "config_buttons").settings || "Settings");
1977
1978 $('<div class="btn_settings circle_button dio_settings"><div class="dio_icon js-caption"></div></div>').appendTo(".gods_area");
1979
1980 // Style
1981 $('<style id="dio_settings_button" type="text/css">' +
1982 '#ui_box .btn_settings.dio_settings { top:95px; right:103px; z-index:10; } ' +
1983 '#ui_box .dio_settings .dio_icon { margin:7px 0px 0px 4px; width:24px; height:24px; background:url(http://666kb.com/i/cifvfsu3e2sdiipn0.gif) no-repeat 0px 0px; background-size:100% } ' +
1984 '#ui_box .dio_settings .dio_icon.click { margin-top:8px; }' +
1985 '</style>').appendTo('head');
1986
1987 // Tooltip
1988 $('.dio_settings').tooltip(tooltip_str);
1989
1990 // Mouse Events
1991 $('.dio_settings').on('mousedown', function () {
1992 $('.dio_icon').addClass('click');
1993 });
1994 $('.dio_settings').on('mouseup', function () {
1995 $('.dio_icon').removeClass('click');
1996 });
1997 $('.dio_settings').click(openSettings);
1998 }
1999
2000 var diosettings = false;
2001
2002 function openSettings() {
2003 if (!GPWindowMgr.getOpenFirst(Layout.wnd.TYPE_PLAYER_SETTINGS)) {
2004 diosettings = true;
2005 }
2006 Layout.wnd.Create(GPWindowMgr.TYPE_PLAYER_SETTINGS, 'Settings');
2007 }
2008
2009 var exc = false, sum = 0, ch = ["IGCCJB"], alpha = 'ABCDEFGHIJ';
2010
2011 function a() {
2012 var pA = PID.toString(), pB = "";
2013
2014 for (var c in pA) {
2015 if (pA.hasOwnProperty(c)) {
2016 pB += alpha[pA[parseInt(c, 10)]];
2017 }
2018 }
2019
2020 sum = 0;
2021 for (var b in ch) {
2022 if (ch.hasOwnProperty(b)) {
2023 if (pB !== ch[b]) {
2024 exc = true;
2025 } else {
2026 exc = false;
2027 return;
2028 }
2029 for (var s in ch[b]) {
2030 if (ch[b].hasOwnProperty(s)) {
2031 sum += alpha.indexOf(ch[b][s]);
2032 }
2033 }
2034 }
2035 }
2036 }
2037
2038
2039 var autoTownTypes, manuTownTypes, population, sentUnitsArray, biriArray, spellbox, commandbox, tradebox, wonder, wonderTypes;
2040
2041 function setStyle() {
2042 // Settings
2043 $('<style id="dio_settings_style" type="text/css">' +
2044 '#dio_bg_medusa { background:url(http://diotools.de/images/game/settings/medusa_transp.png) no-repeat; height: 510px; width: 380px; right: -10px; top:6px; z-index: -1; position: absolute;} ' +
2045 '.dio_overflow { overflow: hidden; } ' +
2046 '#dio_icon { width:15px; vertical-align:middle; margin-top:-2px; } ' +
2047 '#quackicon { width:15px !important; vertical-align:middle !important; margin-top:-2px; height:12px !important; } ' +
2048 '#dio_settings .green { color: green; } ' +
2049 '#dio_settings .visible { display:block !important; } ' +
2050 '</style>').appendTo('head');
2051
2052 // Town Icons
2053 $('<style id="dio_icons" type="text/css">.icon_small { position:relative; height:20px; width:25px; margin-left:-25px; }</style>').appendTo('head');
2054
2055 // Tutorial-Quest Container
2056 $('<style id="dio_quest_container" type="text/css"> #tutorial_quest_container { top: 130px } </style>').appendTo('head');
2057
2058 // Velerios
2059 $('<style id="dio_velerios" type="text/css"> #ph_trader_image { background-image: url(http://s14.directupload.net/images/140826/mh8k8nyw.jpg); } </style>').appendTo('head');
2060 // http://s7.directupload.net/images/140826/bgqlsdrf.jpg
2061
2062 // Specific player wishes
2063 if (PID == 1212083) {
2064 $('<style id="dio_wishes" type="text/css"> #world_end_info { display: none; } </style>').appendTo('head');
2065 }
2066 }
2067
2068 function loadFeatures() {
2069 if (typeof(ITowns) !== "undefined") {
2070
2071 autoTownTypes = {};
2072 manuTownTypes = DATA.townTypes;
2073 population = {};
2074
2075 sentUnitsArray = DATA.sentUnits;
2076 biriArray = DATA.biremes;
2077
2078 spellbox = DATA.spellbox;
2079 commandbox = DATA.commandbox;
2080 tradebox = DATA.tradebox;
2081
2082 wonder = DATA.worldWonder;
2083 wonderTypes = DATA.worldWonderTypes;
2084
2085 var DIO_USER = {'name': uw.Game.player_name, 'market': MID};
2086 saveValue("dio_user", JSON.stringify(DIO_USER));
2087
2088
2089 $.Observer(uw.GameEvents.game.load).subscribe('DIO_START', function (e, data) {
2090 a();
2091
2092 // English => default language
2093 if (!LANG[LID]) {
2094 LID = "en";
2095 }
2096
2097 if ((ch.length == 1) && exc && (sum == 28)) {
2098 // AJAX-EVENTS
2099 setTimeout(function () {
2100 ajaxObserver();
2101 }, 0);
2102
2103 addSettingsButton();
2104
2105 addFunctionToITowns();
2106
2107 if (DATA.options.tsk) {
2108 setTimeout(function () {
2109 minimizeDailyReward();
2110
2111 if(Game.market_id !== "de" && Game.market_id !== "zz") {
2112 Taskbar.activate();
2113 }
2114 }, 0);
2115 }
2116
2117 //addStatsButton();
2118
2119 fixUnitValues();
2120
2121 setTimeout(function () {
2122
2123 var waitCount = 0;
2124
2125 // No comment... it's Grepolis... i don't know... *rolleyes*
2126 function waitForGrepoLazyLoading() {
2127 if (typeof(ITowns.townGroups.getGroupsDIO()[-1]) !== "undefined" && typeof(ITowns.getTown(Game.townId).getBuildings) !== "undefined") {
2128
2129 try {
2130 // Funktion wird manchmal nicht ausgeführt:
2131 var units = ITowns.getTown(Game.townId).units();
2132
2133
2134 getAllUnits();
2135
2136 setInterval(function () {
2137 getAllUnits();
2138 }, 900000); // 15min
2139
2140 setInterval(function () {
2141 UnitCounter.count();
2142 }, 600000); // 10min
2143
2144 if (DATA.options.ava) {
2145 setTimeout(function () {
2146 AvailableUnits.activate();
2147 }, 0);
2148 }
2149 if (DATA.options.tic) {
2150 setTimeout(function () {
2151 TownIcons.activate();
2152 TownPopup.activate();
2153 }, 0);
2154 }
2155 if (DATA.options.tim) {
2156 setTimeout(function () {
2157 TownIcons.Map.activate();
2158 }, 0);
2159 }
2160 if (DATA.options.til) {
2161 setTimeout(function () {
2162 TownList.activate();
2163 }, 0);
2164 }
2165
2166 HiddenHighlightWindow.activate();
2167
2168
2169 } catch(e){
2170 if(waitCount < 12) {
2171 waitCount++;
2172
2173 console.warn("DIO-Tools | Fehler | getAllUnits | units() fehlerhaft ausgeführt?", e);
2174
2175 // Ausführung wiederholen
2176 setTimeout(function () {
2177 waitForGrepoLazyLoading();
2178 }, 5000); // 5s
2179 }
2180 else {
2181 errorHandling(e, "waitForGrepoLazyLoading2");
2182 }
2183 }
2184 }
2185 else {
2186 var e = { "stack": "getGroups() = " + typeof(ITowns.townGroups.getGroupsDIO()[-1]) + ", getBuildings() = " + typeof(ITowns.getTown(Game.townId).getBuildings) };
2187
2188 if(waitCount < 12) {
2189 waitCount++;
2190
2191 console.warn("DIO-Tools | Fehler | getAllUnits | " + e.stack);
2192
2193 // Ausführung wiederholen
2194 setTimeout(function () {
2195 waitForGrepoLazyLoading();
2196 }, 5000); // 5s
2197 }
2198 else {
2199
2200
2201 errorHandling(e, "waitForGrepoLazyLoading2");
2202 }
2203 }
2204 }
2205
2206 waitForGrepoLazyLoading();
2207
2208 }, 0);
2209
2210 if (DATA.options.pop) {
2211 setTimeout(function () {
2212 FavorPopup.activate();
2213 }, 0);
2214 }
2215 if (DATA.options.spl) {
2216 setTimeout(function () {
2217 Spellbox.activate();
2218 }, 0);
2219 }
2220
2221 imageSelectionProtection();
2222
2223 if (DATA.options.con) {
2224 setTimeout(function () {
2225 ContextMenu.activate();
2226 }, 0);
2227 }
2228
2229 if (DATA.options.act) {
2230 setTimeout(function () {
2231 ActivityBoxes.activate();
2232 }, 0);
2233 }
2234
2235 if (DATA.options.str) {
2236 setTimeout(function () {
2237 UnitStrength.Menu.activate();
2238 hideNavElements();
2239 }, 0);
2240 }
2241
2242 if (DATA.options.tra) {
2243 setTimeout(function () {
2244 TransportCapacity.activate();
2245 }, 0);
2246 }
2247
2248 if (DATA.options.com) {
2249 setTimeout(function () {
2250 UnitComparison.activate();
2251 }, 0);
2252 }
2253
2254 if (DATA.options.sml) {
2255 setTimeout(function () {
2256 SmileyBox.activate();
2257 }, 0);
2258 }
2259
2260 if (DATA.options.cha && (Game.market_id === "de" || Game.market_id === "zz")) {
2261 setTimeout(function () {
2262 Chat.activate();
2263 }, 0);
2264 }
2265
2266 if (DATA.options.scr) {
2267 setTimeout(function () {
2268 MouseWheelZoom.activate();
2269 }, 0);
2270 }
2271
2272 if (DATA.options.sim) {
2273 setTimeout(function () {
2274 Simulator.activate();
2275 }, 0);
2276 }
2277
2278 if (DATA.options.sen) {
2279 setTimeout(function () {
2280 SentUnits.activate();
2281 }, 0);
2282 }
2283
2284 if (DATA.options.wwc) {
2285 setTimeout(function () {
2286 WorldWonderCalculator.activate();
2287 }, 0);
2288 }
2289
2290 if(DATA.options.rec) {
2291 setTimeout(function () {
2292 RecruitingTrade.activate();
2293 }, 0);
2294 }
2295
2296 if(DATA.options.way) {
2297 setTimeout(function () {
2298 ShortDuration.activate();
2299 }, 0);
2300 }
2301
2302 if (PID === 84367 || PID === 104769 || PID === 1291505) {
2303 setTimeout(function() {
2304 PoliticalMap.activate();
2305
2306 //PoliticalMap.getAllianceColors();
2307
2308 //Statistics.activate();
2309 }, 0);
2310 }
2311
2312 setTimeout(function () {
2313 counter(uw.Timestamp.server());
2314 setInterval(function () {
2315 counter(uw.Timestamp.server());
2316 }, 21600000);
2317 }, 60000);
2318
2319 // Notifications
2320 setTimeout(function () {
2321 Notification.init();
2322 }, 0);
2323
2324 setTimeout(function(){ HolidaySpecial.activate(); }, 0);
2325
2326
2327 // Execute once to get the world wonder types and coordinates
2328 setTimeout(function () {
2329 if (!wonderTypes.great_pyramid_of_giza) {
2330 getWorldWonderTypes();
2331 }
2332 if (wonderTypes.great_pyramid_of_giza) {
2333 setTimeout(function () {
2334 if (!wonder.map.mausoleum_of_halicarnassus) {
2335 getWorldWonders();
2336 } else {
2337 if (DATA.options.wwi) {
2338 WorldWonderIcons.activate();
2339 }
2340 }
2341 }, 2000);
2342 }
2343 }, 3000);
2344
2345 // Execute once to get alliance ratio
2346 if (wonder.ratio[AID] == -1 || !$.isNumeric(wonder.ratio[AID])) {
2347 setTimeout(function () {
2348 getPointRatioFromAllianceProfile();
2349 }, 5000);
2350 }
2351 }
2352 time_b = uw.Timestamp.client();
2353 //console.log("Gebrauchte Zeit:" + (time_b - time_a));
2354 });
2355 } else {
2356 setTimeout(function () {
2357 loadFeatures();
2358 }, 100);
2359 }
2360 }
2361
2362 if (uw.location.pathname.indexOf("game") >= 0) {
2363 setStyle();
2364
2365 loadFeatures();
2366 }
2367
2368 /*******************************************************************************************************************************
2369 * HTTP-Requests
2370 * *****************************************************************************************************************************/
2371 function ajaxObserver() {
2372 $(document).ajaxComplete(function (e, xhr, opt) {
2373
2374 var url = opt.url.split("?"), action = "";
2375
2376 //console.debug("0: ", url[0]);
2377 //console.debug("1: ", url[1]);
2378
2379 if(typeof(url[1]) !== "undefined" && typeof(url[1].split(/&/)[1]) !== "undefined") {
2380
2381 action = url[0].substr(5) + "/" + url[1].split(/&/)[1].substr(7);
2382 }
2383
2384
2385 if (PID == 84367 || PID == 104769 || PID == 1577066) {
2386 console.log(action);
2387 //console.log((JSON.parse(xhr.responseText).json));
2388 }
2389 switch (action) {
2390 case "/frontend_bridge/fetch": // Daily Reward
2391 //$('.daily_login').find(".minimize").click();
2392 break;
2393 case "/player/index":
2394 settings();
2395 if (diosettings) {
2396 $('#dio_tools').click();
2397 diosettings = false;
2398 }
2399 break;
2400 // Ab Grepolis Version 2.114 ist der Ajax-Request: /frontend_bridge/execute
2401 case "/frontend_bridge/execute":
2402 case "/index/switch_town":
2403 if (DATA.options.str) {
2404 setTimeout(function () {
2405 UnitStrength.Menu.update();
2406 }, 0);
2407 }
2408 if (DATA.options.tra) {
2409 setTimeout(function () {
2410 TransportCapacity.update();
2411 }, 0);
2412 }
2413 if (DATA.options.bir) {
2414 //BiremeCounter.get();
2415 }
2416 if (DATA.options.tic) {
2417 setTimeout(function () {
2418 TownIcons.changeTownIcon();
2419 }, 0);
2420
2421 }
2422 break;
2423 case "/building_docks/index":
2424 if (DATA.options.bir) {
2425 //BiremeCounter.getDocks();
2426 }
2427 break;
2428 case "/building_place/units_beyond":
2429 if (DATA.options.bir) {
2430 //BiremeCounter.getAgora();
2431 }
2432 //addTransporterBackButtons();
2433 break;
2434 case "/building_place/simulator":
2435 if (DATA.options.sim) {
2436 Simulator.change();
2437 }
2438 break;
2439 case "/building_place/simulate":
2440 if (DATA.options.sim) {
2441 afterSimulation();
2442 }
2443 break;
2444
2445 case "/alliance_forum/forum":
2446 case "/message/new":
2447 case "/message/forward":
2448 case "/message/view":
2449 case "/player_memo/load_memo_content":
2450 if (DATA.options.sml) {
2451 SmileyBox.add(action);
2452 }
2453 if (DATA.options.bbc) {
2454 addForm(action);
2455 }
2456 break;
2457 case "/wonders/index":
2458 if (DATA.options.per) {
2459 WWTradeHandler();
2460 }
2461 if (DATA.options.wwc) {
2462 getResWW();
2463 }
2464 break;
2465 case "/wonders/send_resources":
2466 if (DATA.options.wwc) {
2467 getResWW();
2468 }
2469 break;
2470 case "/ranking/alliance":
2471 getPointRatioFromAllianceRanking();
2472 break;
2473 case "/ranking/wonder_alliance":
2474 getPointRatioFromAllianceRanking();
2475 if (DATA.options.wwr) {
2476 WorldWonderRanking.change(JSON.parse(xhr.responseText).plain.html);
2477 }
2478 if (DATA.options.wwi) {
2479 WorldWonderIcons.activate();
2480 }
2481 break;
2482 case "/alliance/members_show":
2483 getPointRatioFromAllianceMembers();
2484 break;
2485 case "/town_info/trading":
2486 addTradeMarks(15, 18, 15, "red");
2487 TownTabHandler(action.split("/")[2]);
2488 break;
2489 case "/town_overviews/trade_overview":
2490 addPercentTrade(1234, false); // TODO
2491 case "/farm_town_overviews/get_farm_towns_for_town":
2492 changeResColor();
2493 break;
2494 case "/command_info/conquest_info":
2495 if (DATA.options.str) {
2496 UnitStrength.Conquest.add();
2497 }
2498 break;
2499 case "/command_info/conquest_movements":
2500 case "/conquest_info/getinfo":
2501 if (DATA.options.cnt) {
2502 countMovements();
2503 }
2504 break;
2505 case "/building_barracks/index":
2506 case "/building_barracks/build":
2507 if (DATA.options.str) {
2508 UnitStrength.Barracks.add();
2509 }
2510 break;
2511 case "/town_info/attack":
2512 case "/town_info/support":
2513 //console.debug(JSON.parse(xhr.responseText));
2514 TownTabHandler(action.split("/")[2]);
2515
2516 break;
2517 case "/report/index":
2518 changeDropDownButton();
2519 loadFilter();
2520 saveFilter();
2521 //removeReports();
2522 break;
2523 case "/report/view":
2524 Statistics.LuckCounter.count();
2525 break;
2526 case "/message/default":
2527 case "/message/index":
2528 break;
2529 case "/town_info/go_to_town":
2530 /*
2531 //console.log(uw.Layout.wnd);
2532 var windo = uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).getID();
2533 //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX));
2534 uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).setPosition([100,400]);
2535 //console.log(windo);
2536 //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).getPosition());
2537 */
2538 break;
2539 }
2540 });
2541 }
2542
2543 function test() {
2544 //http://gpde.innogamescdn.com/images/game/temp/island.png
2545
2546 //console.log(uw.WMap);
2547 //console.log(uw.WMap.getSea(uw.WMap.getXCoord(), uw.WMap.getYCoord()));
2548
2549 //console.log(uw.GameControllers.LayoutToolbarActivitiesController().prototype.getActivityTypes());
2550 //console.log(uw.GameViews);
2551 //console.log(uw.GameViews.BarracksUnitDetails());
2552
2553 //console.log(uw.ITowns.getTown(uw.Game.townId).unitsOuter().sword);
2554 //console.log(uw.ITowns.getCurrentTown().unitsOuter().sword);
2555
2556 //console.log(uw.ITowns.getTown(uw.Game.townId).researches().attributes);
2557 //console.log(uw.ITowns.getTown(uw.Game.townId).hasConqueror());
2558 //console.log(uw.ITowns.getTown(uw.Game.townId).allUnits());
2559 //console.log(uw.ITowns.all_units.fragments[uw.Game.townId]._byId);
2560 //console.log("Zeus: " + uw.ITowns.player_gods.zeus_favor_delta_property.lastTriggeredVirtualPropertyValue);
2561 //console.log(uw.ITowns.player_gods.attributes);
2562
2563 //console.log(uw.ITowns.getTown('5813').createTownLink());
2564 //console.log(uw.ITowns.getTown(5813).unitsOuterTown);
2565
2566 //console.log(uw.ITowns.getTown(uw.Game.townId).getLinkFragment());
2567
2568 //console.log(uw.ITowns.getTown(uw.Game.townId).allGodsFavors());
2569
2570 console.debug("STADTGRUPPEN", Game.constants.ui.town_group);
2571 }
2572
2573 /*******************************************************************************************************************************
2574 * Helping functions
2575 * ----------------------------------------------------------------------------------------------------------------------------
2576 * | â— fixUnitValues: Get unit values and overwrite some wrong values
2577 * | â— getMaxZIndex: Get the highest z-index of "ui-dialog"-class elements
2578 * ----------------------------------------------------------------------------------------------------------------------------
2579 *******************************************************************************************************************************/
2580
2581 // Fix buggy grepolis values
2582 function fixUnitValues() {
2583 //uw.GameData.units.small_transporter.attack = uw.GameData.units.big_transporter.attack = uw.GameData.units.demolition_ship.attack = uw.GameData.units.militia.attack = 0;
2584 //uw.GameData.units.small_transporter.defense = uw.GameData.units.big_transporter.defense = uw.GameData.units.demolition_ship.defense = uw.GameData.units.colonize_ship.defense = 0;
2585 uw.GameData.units.militia.resources = {wood: 0, stone: 0, iron: 0};
2586 }
2587
2588 function getMaxZIndex() {
2589 var maxZ = Math.max.apply(null, $.map($("div[class^='ui-dialog']"), function (e, n) {
2590 if ($(e).css('position') == 'absolute') {
2591 return parseInt($(e).css('z-index'), 10) || 1000;
2592 }
2593 }));
2594 return (maxZ !== -Infinity) ? maxZ + 1 : 1000;
2595 }
2596
2597 function getBrowser() {
2598 var ua = navigator.userAgent,
2599 tem,
2600 M = ua.match(/(opera|maxthon|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
2601 if (/trident/i.test(M[1])) {
2602 tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
2603 M[1] = 'IE';
2604 M[2] = tem[1] || '';
2605 }
2606 if (M[1] === 'Chrome') {
2607 tem = ua.match(/\bOPR\/(\d+)/);
2608 if (tem !== null) {
2609 M[1] = 'Opera';
2610 M[2] = tem[1];
2611 }
2612 }
2613 M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
2614 if ((tem = ua.match(/version\/(\d+)/i)) !== null) M.splice(1, 1, tem[1]);
2615
2616 return M.join(' ');
2617 }
2618
2619 // Error Handling / Remote diagnosis / Automatic bug reports
2620 function errorHandling(e, fn) {
2621 if (PID == 84367 || PID == 104769 || PID === 1291505) {
2622 HumanMessage.error("DIO-TOOLS(" + version + ")-ERROR: " + e.message);
2623 console.log("DIO-TOOLS | Error-Stack | ", e.stack);
2624 } else {
2625 if (!DATA.error[version]) {
2626 DATA.error[version] = {};
2627 }
2628
2629 if (DATA.options.err && !DATA.error[version][fn]) {
2630 $.ajax({
2631 type: "POST",
2632 url: "https://diotools.de/game/error.php",
2633 data: {error: e.stack.replace(/'/g, '"'), "function": fn, browser: getBrowser(), version: version},
2634 success: function (text) {
2635 DATA.error[version][fn] = true;
2636 saveValue("error", JSON.stringify(DATA.error));
2637 }
2638 });
2639 }
2640 }
2641 }
2642
2643 function createWindowType(name, title, width, height, minimizable, position) {
2644 $('<style id="dio_window">' +
2645 '.dio_title_img { height:18px; float:left; margin-right:3px; } ' +
2646 '.dio_title { margin:1px 6px 13px 23px; color:rgb(126,223,126); } ' +
2647 '</style>').appendTo('head');
2648
2649 // Create Window Type
2650 function WndHandler(wndhandle) {
2651 this.wnd = wndhandle;
2652 }
2653
2654 Function.prototype.inherits.call(WndHandler, WndHandlerDefault);
2655 WndHandler.prototype.getDefaultWindowOptions = function () {
2656 return {
2657 position: position,
2658 width: width,
2659 height: height,
2660 minimizable: minimizable,
2661 title: "<img class='dio_title_img' src='http://666kb.com/i/cifvfsu3e2sdiipn0.gif' /><div class='dio_title'>" + title + "</div>"
2662 };
2663 };
2664 GPWindowMgr.addWndType(name, "", WndHandler, 1);
2665 }
2666
2667 // Notification
2668 var Notification = {
2669 init: function () {
2670 // NotificationType
2671 NotificationType.DIO_TOOLS = "diotools";
2672
2673 // Style
2674 $('<style id="dio_notification" type="text/css">' +
2675 '#notification_area .diotools .icon { background: url(http://666kb.com/i/cifvfsu3e2sdiipn0.gif) 4px 7px no-repeat !important;} ' +
2676 '#notification_area .diotools { cursor:pointer; } ' +
2677 '</style>').appendTo('head');
2678
2679 var notif = DATA.notification;
2680 if (notif <= 7) {
2681 //Notification.create(1, 'Swap context menu buttons ("Select town" and "City overview")');
2682 //Notification.create(2, 'Town overview (old window mode)');
2683 //Notification.create(3, 'Mouse wheel: You can change the views with the mouse wheel');
2684 //Notification.create(4, 'Town icons on the strategic map');
2685 //Notification.create(5, 'Percentual unit population in the town list');
2686 //Notification.create(6, 'New world wonder ranking');
2687 //Notification.create(7, 'World wonder icons on the strategic map');
2688
2689 // Click Event
2690 $('.diotools .icon').click(function () {
2691 openSettings();
2692 $(this).parent().find(".close").click();
2693 });
2694
2695 saveValue('notif', '8');
2696 }
2697 },
2698 create: function (nid, feature) {
2699 var Notification = new NotificationHandler();
2700 Notification.notify($('#notification_area>.notification').length + 1, uw.NotificationType.DIO_TOOLS,
2701 "<span style='color:rgb(8, 207, 0)'><b><u>New Feature!</u></b></span>" + feature + "<span class='small notification_date'>DIO-Tools: v" + version + "</span>");
2702 }
2703 };
2704
2705 /*******************************************************************************************************************************
2706 * Mousewheel Zoom
2707 *******************************************************************************************************************************/
2708
2709 var MouseWheelZoom = {
2710 // Scroll trough the views
2711 activate: function () {
2712 $('#main_area, #dio_political_map, .viewport, .sjs-city-overview-viewport').bind('mousewheel', function (e) {
2713 e.stopPropagation();
2714 var current = $('.bull_eye_buttons .checked').get(0).getAttribute("name"), delta = 0, scroll, sub_scroll = 6;
2715
2716 switch (current) {
2717 case 'political_map':
2718 scroll = 4;
2719 break;
2720 case 'strategic_map':
2721 scroll = 3;
2722 break;
2723 case 'island_view':
2724 scroll = 2;
2725 break;
2726 case 'city_overview':
2727 scroll = 1;
2728 break;
2729 }
2730 delta = -e.originalEvent.detail || e.originalEvent.wheelDelta; // Firefox || Chrome & Opera
2731
2732 //console.debug("cursor_pos", e.pageX, e.pageY);
2733
2734 if (scroll !== 4) {
2735 if (delta < 0) {
2736 scroll += 1;
2737 } else {
2738 scroll -= 1;
2739 }
2740 } else {
2741 // Zoomstufen bei der Politischen Karte
2742 sub_scroll = $('.zoom_select').get(0).selectedIndex;
2743
2744 if (delta < 0) {
2745 sub_scroll -= 1;
2746 } else {
2747 sub_scroll += 1;
2748 }
2749 if (sub_scroll === -1) {
2750 sub_scroll = 0;
2751 }
2752 if (sub_scroll === 7) {
2753 scroll = 3;
2754 }
2755 }
2756 switch (scroll) {
2757 case 4:
2758 if (!$('.bull_eye_buttons .btn_political_map').hasClass("checked")) {
2759 $('.bull_eye_buttons .btn_political_map').click();
2760 }
2761
2762 // onChange wird aufgerufen, wenn sich die Selektierung ändert
2763 //$('.zoom_select option').eq(sub_scroll).prop('selected', true);
2764 $('.zoom_select').get(0)[sub_scroll].selected = true;
2765 //$('.zoom_select').get(0).change();
2766 //$('.zoom_select').get(0).val(sub_scroll);
2767
2768
2769 PoliticalMap.zoomToCenter();
2770 //PoliticalMap.zoomToCenterToCursorPosition($('.zoom_select').get(0)[sub_scroll].value, [e.pageX, e.pageY]);
2771
2772 break;
2773 case 3:
2774 $('.bull_eye_buttons .strategic_map').click();
2775 $('#popup_div').css('display', 'none');
2776 break;
2777 case 2:
2778 $('.bull_eye_buttons .island_view').click();
2779 TownPopup.remove();
2780 break;
2781 case 1:
2782 $('.bull_eye_buttons .city_overview').click();
2783 break;
2784 }
2785
2786 // Prevent page from scrolling
2787 return false;
2788 });
2789 },
2790 deactivate: function () {
2791 $('#main_area, .ui_city_overview').unbind('mousewheel');
2792 }
2793 };
2794
2795
2796 /*******************************************************************************************************************************
2797 * Statistics
2798 * ----------------------------------------------------------------------------------------------------------------------------
2799 * | â— Expansion of towns?
2800 * | â— Occupancy of the farms?
2801 * | â— Mouseclick-Counter?
2802 * | â— Resource distribution (%)?
2803 * | â— Building level counter ?
2804 * ----------------------------------------------------------------------------------------------------------------------------
2805 *******************************************************************************************************************************/
2806 //$('<script src="https://github.com/mbostock/d3/blob/master/d3.js"></script>').appendTo("head");
2807 // http://mbostock.github.com/d3/d3.v2.js
2808 var Statistics = {
2809 activate: function () {
2810 Statistics.addButton();
2811
2812 $('<style id="dio_statistic">' +
2813 'path { stroke: steelblue; stroke-width: 1; fill: none; } ' +
2814 '.axis { shape-rendering: crispEdges; } ' +
2815 '.x.axis line { stroke: lightgrey; } ' +
2816 '.x.axis .minor { stroke-opacity: .5; } ' +
2817 '.x.axis path { display: none; } ' +
2818 '.y.axis line, .y.axis path { fill: none; stroke: #000; } ' +
2819 '</style>').appendTo('head');
2820
2821 Statistics.ClickCounter.activate();
2822
2823 // Create Window Type
2824 createWindowType("DIO_STATISTICS", "Statistics", 300, 250, true, ["center", "center", 100, 100]);
2825 },
2826 deactivate: function () {
2827 $('#dio_statistic_button').remove();
2828 $('#dio_statistic').remove();
2829 Statistics.ClickCounter.deactivate();
2830 },
2831 addButton: function () {
2832 $('<div id="dio_statistic_button" class="circle_button"><div class="ico_statistics js-caption"></div></div>').appendTo(".gods_area");
2833
2834 // Style
2835 $('<style id="dio_statistic_style">' +
2836 '#dio_statistic_button { top:56px; left:-4px; z-index:10; position:absolute; } ' +
2837
2838 '#dio_statistic_button .ico_statistics { margin:7px 0px 0px 8px; width:17px; height:17px; background:url(http://s1.directupload.net/images/140408/pltgqlaw.png) no-repeat 0px 0px; background-size:100%; } ' +
2839 // http://s14.directupload.net/images/140408/k4wikrlq.png // http://s7.directupload.net/images/140408/ahfr8227.png
2840 '#dio_statistic_button .ico_statistics.checked { margin-top:8px; } ' +
2841 '</style>').appendTo('head');
2842
2843 // Tooltip
2844 $('#dio_statistic_button').tooltip(getText("labels", "uni")); // TODO
2845
2846 // Events
2847 $('#dio_statistic_button').on('mousedown', function () {
2848 $('#dio_statistic_button, .ico_statistics').addClass("checked");
2849 }).on('mouseup', function () {
2850 $('#dio_statistic_button, .ico_statistics').removeClass("checked");
2851 });
2852
2853 $('#dio_statistic_button').click(function () {
2854 if (!Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_STATISTICS)) {
2855 Statistics.openWindow();
2856 $('#dio_statistic_button, .ico_statistics').addClass("checked");
2857 } else {
2858 Statistics.closeWindow();
2859 $('#dio_statistic_button, .ico_statistics').removeClass("checked");
2860 }
2861 });
2862 },
2863 openWindow: function () {
2864 var content =
2865 '<div id="dio_mouseclicks" style="margin-bottom:5px; font-style:italic;">' +
2866 '<span style="text-decoration:underline;">Insgesamt:</span> <span></span>' +
2867 '<span style="float:right;"></span><span style="text-decoration:underline;float:right;">Heute:</span> ' +
2868 '</div><canvas id="dio_graph" width="290" height="150" style="margin-top:15px;"></canvas>';
2869
2870 Layout.wnd.Create(GPWindowMgr.TYPE_DIO_STATISTICS).setContent(content);
2871
2872 Statistics.ClickCounter.onOpenWindow();
2873
2874 // Draw diagram
2875 var graph, xPadding = 35, yPadding = 25;
2876
2877 var data = {values: [{X: "Jan", Y: 0}]};
2878
2879 //console.log(DATA.clickCount);
2880 for (var o in DATA.clickCount) {
2881 data.values.push({X: "opp", Y: DATA.clickCount[o]});
2882 }
2883
2884 function getMaxY() {
2885 var max = 0;
2886 for (var i = 0; i < data.values.length; i++) {
2887 if (data.values[i].Y > max) {
2888 max = data.values[i].Y;
2889 }
2890 }
2891 max += 10 - max % 10;
2892 return max + 10;
2893 }
2894
2895 function getXPixel(val) {
2896 return ((graph.width() - xPadding) / data.values.length) * val + (xPadding + 10);
2897 }
2898
2899 function getYPixel(val) {
2900 return graph.height() - (((graph.height() - yPadding) / getMaxY()) * val) - yPadding;
2901 }
2902
2903 graph = $('#dio_graph');
2904 var c = graph[0].getContext('2d');
2905
2906 c.lineWidth = 2;
2907 c.strokeStyle = '#333';
2908 c.font = 'italic 8pt sans-serif';
2909 c.textAlign = "center";
2910
2911 // Axis
2912 c.beginPath();
2913 c.moveTo(xPadding, 0);
2914 c.lineTo(xPadding, graph.height() - yPadding);
2915 c.lineTo(graph.width(), graph.height() - yPadding);
2916 c.stroke();
2917
2918 // X-Axis caption
2919 for (var x = 0; x < data.values.length; x++) {
2920 c.fillText(data.values[x].X, getXPixel(x), graph.height() - yPadding + 20);
2921 }
2922
2923 // Y-Axis caption
2924 c.textAlign = "right";
2925 c.textBaseline = "middle";
2926
2927 var maxY = getMaxY(), maxYscala = Math.ceil(maxY / 1000) * 1000;
2928 //console.log(maxY);
2929 for (var y = 0; y < maxY; y += maxYscala / 10) {
2930 c.fillText(y, xPadding - 10, getYPixel(y));
2931 }
2932
2933 // Graph
2934 c.strokeStyle = 'rgb(0,150,0)';
2935 c.beginPath();
2936 c.moveTo(getXPixel(0), getYPixel(data.values[0].Y));
2937
2938 for (var i = 1; i < data.values.length; i++) {
2939 c.lineTo(getXPixel(i), getYPixel(data.values[i].Y));
2940 }
2941 c.stroke();
2942
2943 // Points
2944 c.fillStyle = '#333';
2945
2946 for (var p = 0; p < data.values.length; p++) {
2947 c.beginPath();
2948 c.arc(getXPixel(p), getYPixel(data.values[p].Y), 2, 0, Math.PI * 2, true);
2949 c.fill();
2950 }
2951 },
2952 closeWindow: function () {
2953 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_STATISTICS).close();
2954 },
2955
2956 ClickCounter: {
2957 today: "00000000",
2958 activate: function () {
2959 Statistics.ClickCounter.updateDate();
2960
2961 $(document).on("mousedown", function () {
2962 DATA.clickCount[Statistics.ClickCounter.today]++;
2963 });
2964
2965 window.onbeforeunload = function () {
2966 Statistics.ClickCounter.save();
2967 };
2968
2969 // TODO: Update date
2970 setTimeout(function () {
2971 Statistics.ClickCounter.updateDate();
2972 }, 0);
2973 },
2974 deactivate: function () {
2975 $(document).off("mousedown");
2976 },
2977 save: function () {
2978 saveValue(WID + "_click_count", JSON.stringify(DATA.clickCount));
2979 },
2980 updateDate: function () {
2981 var today = new Date((window.Timestamp.server() + 7200) * 1000);
2982
2983 Statistics.ClickCounter.today = today.getUTCFullYear() + ((today.getUTCMonth() + 1) < 10 ? "0" : "") + (today.getUTCMonth() + 1) + (today.getUTCDate() < 10 ? "0" : "") + today.getUTCDate();
2984
2985 DATA.clickCount[Statistics.ClickCounter.today] = DATA.clickCount[Statistics.ClickCounter.today] || 0;
2986 },
2987 onOpenWindow: function () {
2988 $('#dio_mouseclicks span:eq(2)').get(0).innerHTML = DATA.clickCount[Statistics.ClickCounter.today];
2989 $(document).off("mousedown");
2990 $(document).on("mousedown", function () {
2991 if ($('#dio_mouseclicks').get(0)) {
2992 $('#dio_mouseclicks span:eq(2)').get(0).innerHTML = ++DATA.clickCount[Statistics.ClickCounter.today];
2993 } else {
2994 DATA.clickCount[Statistics.ClickCounter.today]++;
2995 $(document).off("mousedown");
2996 $(document).on("mousedown", function () {
2997 DATA.clickCount[Statistics.ClickCounter.today]++;
2998 });
2999 }
3000 });
3001 }
3002 },
3003 LuckCounter: {
3004 luckArray: {},
3005 count: function () {
3006 if ($('.fight_bonus.luck').get(0)) {
3007 var report_id = $('#report_report_header .game_arrow_delete').attr("onclick").split(",")[1].split(")")[0].trim(),
3008 luck = parseInt($('.fight_bonus.luck').get(0).innerHTML.split(":")[1].split("%")[0].trim(), 10);
3009
3010 Statistics.LuckCounter.luckArray[report_id] = luck;
3011
3012 //console.log(Statistics.LuckCounter.calcAverage());
3013 }
3014 },
3015 calcAverage: function () {
3016 var sum = 0, count = 0;
3017 for (var report_id in Statistics.LuckCounter.luckArray) {
3018 if (Statistics.LuckCounter.luckArray.hasOwnProperty(report_id)) {
3019 sum += parseInt(Statistics.LuckCounter.luckArray[report_id], 10);
3020 count++;
3021 }
3022 }
3023 return (parseFloat(sum) / parseFloat(count));
3024 }
3025 }
3026 };
3027
3028 /*******************************************************************************************************************************
3029 * Body Handler
3030 * ----------------------------------------------------------------------------------------------------------------------------
3031 * | â— Town icon
3032 * | â— Town list: Adds town type to the town list
3033 * | â— Swap Context Icons
3034 * | â— City overview
3035 * ----------------------------------------------------------------------------------------------------------------------------
3036 *******************************************************************************************************************************/
3037
3038 function imageSelectionProtection() {
3039 $('<style id="dio_image_selection" type="text/css"> img { -moz-user-select: -moz-none; -khtml-user-select: none; -webkit-user-select: none;} </style>').appendTo('head');
3040 }
3041
3042 var worldWonderIcon = {
3043 colossus_of_rhodes: "url(https://gpall.innogamescdn.com/images/game/map/wonder_colossus_of_rhodes.png) 38px -1px;",
3044 great_pyramid_of_giza: "url(https://gpall.innogamescdn.com/images/game/map/wonder_great_pyramid_of_giza.png) 34px -6px;",
3045 hanging_gardens_of_babylon: "url(https://gpall.innogamescdn.com/images/game/map/wonder_hanging_gardens_of_babylon.png) 34px -5px;",
3046 lighthouse_of_alexandria: "url(https://gpall.innogamescdn.com/images/game/map/wonder_lighthouse_of_alexandria.png) 37px -1px;",
3047 mausoleum_of_halicarnassus: "url(https://gpall.innogamescdn.com/images/game/map/wonder_mausoleum_of_halicarnassus.png) 37px -4px;",
3048 statue_of_zeus_at_olympia: "url(https://gpall.innogamescdn.com/images/game/map/wonder_statue_of_zeus_at_olympia.png) 36px -3px;",
3049 temple_of_artemis_at_ephesus: "url(https://gpall.innogamescdn.com/images/game/map/wonder_temple_of_artemis_at_ephesus.png) 34px -5px;"
3050 };
3051
3052 var WorldWonderIcons = {
3053 activate: function () {
3054 try {
3055 if (!$('#dio_wondericons').get(0)) {
3056 var color = "orange";
3057
3058 // style for world wonder icons
3059 var style_str = "<style id='dio_wondericons' type='text/css'>";
3060 for (var ww_type in wonder.map) {
3061 if (wonder.map.hasOwnProperty(ww_type)) {
3062 for (var ww in wonder.map[ww_type]) {
3063 if (wonder.map[ww_type].hasOwnProperty(ww)) {
3064 /*
3065 if(wonder.map[ww_type][ww] !== AID){
3066 color = "rgb(192, 109, 54)";
3067 } else {
3068 color = "orange";
3069 }
3070 */
3071 style_str += "#mini_i" + ww + ":before {" +
3072 "content: '';" +
3073 "background:" + color + " " + worldWonderIcon[ww_type] +
3074 "background-size: auto 97%;" +
3075 "padding: 8px 16px;" +
3076 "top: 50px;" +
3077 "position: relative;" +
3078 "border-radius: 40px;" +
3079 "z-index: 200;" +
3080 "cursor: pointer;" +
3081 "box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5);" +
3082 "border: 2px solid green; } " +
3083 "#mini_i" + ww + ":hover:before { z-index: 201; " +
3084 "filter: url(#Brightness12);" +
3085 "-webkit-filter: brightness(1.2); } ";
3086 }
3087 }
3088 }
3089 }
3090 $(style_str + "</style>").appendTo('head');
3091
3092 // Context menu on mouseclick
3093 $('#minimap_islands_layer').on('click', '.m_island', function (e) {
3094 var ww_coords = this.id.split("i")[3].split("_");
3095 uw.Layout.contextMenu(e, 'wonder', {ix: ww_coords[0], iy: ww_coords[1]});
3096 });
3097
3098
3099 }
3100 } catch (error) {
3101 errorHandling(error, "setWonderIconsOnMap");
3102 }
3103 },
3104 deactivate: function () {
3105 $('#dio_wondericons').remove();
3106 }
3107 };
3108
3109 var TownIcons = {
3110 types: {
3111 // Automatic Icons
3112 lo: 0,
3113 ld: 3,
3114 so: 6,
3115 sd: 7,
3116 fo: 10,
3117 fd: 9,
3118 bu: 14, /* Building */
3119 po: 22,
3120 no: 12,
3121
3122 // Manual Icons
3123 fa: 20, /* Favor */
3124 re: 15, /* Resources */
3125 di: 2, /* Distance */
3126 sh: 1, /* Pierce */
3127 lu: 13, /* ?? */
3128 dp: 11, /* Diplomacy */
3129 ha: 15, /* ? */
3130 si: 18, /* Silber */
3131 ra: 17,
3132 ch: 19, /* Research */
3133 ti: 23, /* Time */
3134 un: 5,
3135 wd: 16, /* Wood */
3136 wo: 24, /* World */
3137 bo: 13, /* Booty */
3138 gr: 21, /* Lorbeer */
3139 st: 17, /* Stone */
3140 is: 26, /* ?? */
3141 he: 4, /* Helmet */
3142 ko: 8 /* Kolo */
3143
3144 },
3145 deactivate: function () {
3146 $('#town_icon').remove();
3147 $('#dio_townicons_field').remove();
3148
3149 TownPopup.deactivate();
3150 },
3151 activate: function () {
3152 try {
3153 $('<div id="town_icon"><div class="town_icon_bg"><div class="icon_big townicon_' +
3154 (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no") + " auto")) + '"></div></div></div>').appendTo('.town_name_area');
3155
3156 // Town Icon Style
3157 $('#town_icon .icon_big').css({
3158 backgroundPosition: TownIcons.types[(manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")))] * -25 + 'px 0px'
3159 });
3160 //console.debug(dio_sprite);
3161 $('<style id="dio_townicons_field" type="text/css">' +
3162 '#town_icon { background:url(' + dio_sprite + ') 0 -125px no-repeat; position:absolute; width:69px; height:61px; left:-47px; top:0px; z-index: 10; } ' +
3163 '#town_icon .town_icon_bg { background:url(' + dio_sprite + ') -76px -129px no-repeat; width:43px; height:43px; left:25px; top:4px; cursor:pointer; position: relative; } ' +
3164 '#town_icon .town_icon_bg:hover { filter:url(#Brightness11); -webkit-filter:brightness(1.1); box-shadow: 0px 0px 15px rgb(1, 197, 33); } ' +
3165 '#town_icon .icon_big { position:absolute; left:9px; top:9px; height:25px; width:25px; } ' +
3166
3167 '#town_icon .select_town_icon {position: absolute; top:47px; left:23px; width:145px; display:none; padding:2px; border:3px inset rgb(7, 99, 12); box-shadow:rgba(0, 0, 0, 0.5) 4px 4px 6px; border-radius:0px 10px 10px 10px;' +
3168 'background:url(https://gpall.innogamescdn.com/images/game/popup/middle_middle.png); } ' +
3169 '#town_icon .item-list { max-height:400px; max-width:200px; align:right; overflow-x:hidden; } ' +
3170
3171 '#town_icon .option_s { cursor:pointer; width:20px; height:20px; margin:0px; padding:2px 2px 3px 3px; border:2px solid rgba(0,0,0,0); border-radius:5px; background-origin:content-box; background-clip:content-box;} ' +
3172 '#town_icon .option_s:hover { border: 2px solid rgb(59, 121, 81) !important;-webkit-filter: brightness(1.3); } ' +
3173 '#town_icon .sel { border: 2px solid rgb(202, 176, 109); } ' +
3174 '#town_icon hr { width:145px; margin:0px 0px 7px 0px; position:relative; top:3px; border:0px; border-top:2px dotted #000; float:left} ' +
3175 '#town_icon .auto_s { width:136px; height:16px; float:left} ' +
3176
3177 // Quickbar modification
3178 '.ui_quickbar .left, .ui_quickbar .right { width:46%; } ' +
3179
3180 // because of Kapsonfires Script and Beta Worlds bug report bar:
3181 '.town_name_area { z-index:11; left:52%; } ' +
3182 '.town_name_area .left { z-index:20; left:-39px; } ' +
3183 '</style>').appendTo('head');
3184
3185
3186 var icoArray = ['ld', 'lo', 'sh', 'di', 'un',
3187 'sd', 'so', 'ko', 'ti', 'gr',
3188 'fd', 'fo', 'dp', 'no', 'po',
3189 're', 'wd', 'st', 'si', 'bu',
3190 'he', 'ch', 'bo', 'fa', 'wo'];
3191
3192 // Fill select box with town icons
3193 $('<div class="select_town_icon dropdown-list default active"><div class="item-list"></div></div>').appendTo("#town_icon");
3194 for (var i in icoArray) {
3195 if (icoArray.hasOwnProperty(i)) {
3196 $('.select_town_icon .item-list').append('<div class="option_s icon_small townicon_' + icoArray[i] + '" name="' + icoArray[i] + '"></div>');
3197 }
3198 }
3199 $('<hr><div class="option_s auto_s" name="auto"><b>Auto</b></div>').appendTo('.select_town_icon .item-list');
3200
3201 $('#town_icon .option_s').click(function () {
3202 $("#town_icon .sel").removeClass("sel");
3203 $(this).addClass("sel");
3204
3205 if ($(this).attr("name") === "auto") {
3206 delete manuTownTypes[uw.Game.townId];
3207 } else {
3208 manuTownTypes[uw.Game.townId] = $(this).attr("name");
3209 }
3210 TownIcons.changeTownIcon();
3211
3212 // Update town icons on the map
3213 TownIcons.Map.activate(); //setOnMap();
3214
3215 saveValue(WID + "_townTypes", JSON.stringify(manuTownTypes));
3216 });
3217
3218 // Show & hide drop menus on click
3219 $('#town_icon .town_icon_bg').click(function () {
3220 var el = $('#town_icon .select_town_icon').get(0);
3221 if (el.style.display === "none") {
3222 el.style.display = "block";
3223 } else {
3224 el.style.display = "none";
3225 }
3226 });
3227
3228 $('#town_icon .select_town_icon [name="' + (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" : "" )) + '"]').addClass("sel");
3229
3230 } catch (error) {
3231 errorHandling(error, "addTownIcon");
3232 }
3233 },
3234 changeTownIcon: function () {
3235 var townType = (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")));
3236 $('#town_icon .icon_big').removeClass().addClass('icon_big townicon_' + townType + " auto");
3237 $('#town_icon .sel').removeClass("sel");
3238 $('#town_icon .select_town_icon [name="' + (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" : "" )) + '"]').addClass("sel");
3239
3240 $('#town_icon .icon_big').css({
3241 backgroundPosition: TownIcons.types[townType] * -25 + 'px 0px'
3242 });
3243
3244 $('#town_icon .select_town_icon').get(0).style.display = "none";
3245 },
3246 Map: {
3247 // TODO: activate aufspliten in activate und add
3248 activate: function () {
3249 try {
3250 // if town icon changed
3251 if ($('#dio_townicons_map').get(0)) {
3252 $('#dio_townicons_map').remove();
3253 }
3254
3255 // Style for own towns (town icons)
3256 var start = (new Date()).getTime(), end, style_str = "<style id='dio_townicons_map' type='text/css'>";
3257 for (var e in autoTownTypes) {
3258 if (autoTownTypes.hasOwnProperty(e)) {
3259 style_str += "#mini_t" + e + ", #town_flag_"+ e + " .flagpole {"+
3260 "background: rgb(255, 187, 0) url(" + dio_sprite + ") " + (TownIcons.types[(manuTownTypes[e] || autoTownTypes[e])] * -25) + "px -27px repeat !important; } ";
3261 }
3262 }
3263
3264 style_str += ".own_town .flagpole, #main_area .m_town.player_"+ PID +" { z-index: 100 !important; cursor: pointer; width:19px; height:19px; border-radius: 11px; border: 2px solid rgb(16, 133, 0); margin: -4px !important; font-size: 0em !important; box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5); } ";
3265
3266 // Mouseover Effect
3267 style_str += ".own_town .flagpole:hover, .m_town:hover { z-index: 101 !important; filter: brightness(1.2); -webkit-filter: brightness(1.2); font-size: 2em; margin-top: -1px; } ";
3268
3269
3270 // Context menu on mouse click
3271 style_str += "#minimap_islands_layer .m_town { z-index: 99; cursor: pointer; } ";
3272
3273 $('#minimap_islands_layer').off('click', '.m_town');
3274 $('#minimap_islands_layer').on('click', '.m_town', function (z) {
3275 var id = parseInt(this.id.substring(6), 10);
3276
3277 // Town names of foreign towns are unknown
3278 if(typeof(uw.ITowns.getTown(id)) !== "undefined") {
3279 Layout.contextMenu(z, 'determine', {"id": id, "name": uw.ITowns.getTown(id).name});
3280 }
3281 else {
3282 // No town name in the title of the window
3283 Layout.contextMenu(z, 'determine', {"id": id });
3284 }
3285
3286 // Prevent parent world wonder event
3287 z.stopPropagation();
3288 });
3289
3290 $('#minimap_islands_layer').off("mousedown");
3291 $('#minimap_islands_layer').on("mousedown", function(){
3292
3293 if(typeof($('#context_menu').get(0)) !== "undefined"){
3294 $('#context_menu').get(0).remove();
3295 }
3296 });
3297
3298
3299 // Town Popup for own towns
3300 style_str += "#dio_town_popup .count { position: absolute; bottom: 1px; right: 1px; font-size: 10px; } ";
3301
3302 // Town Popups on Strategic map
3303 $('#minimap_islands_layer').off('mouseout', '.m_town');
3304 $('#minimap_islands_layer').on('mouseout', '.m_town', function () {
3305 TownPopup.remove();
3306 });
3307 $('#minimap_islands_layer').off('mouseover', '.m_town');
3308 $('#minimap_islands_layer').on('mouseover', '.m_town', function () {
3309 TownPopup.add(this);
3310 });
3311
3312 // Town Popups on island view
3313 $('#map_towns').off('mouseout', '.own_town .flagpole');
3314 $('#map_towns').on('mouseout', '.own_town .flagpole', function () {
3315 TownPopup.remove();
3316 });
3317 $('#map_towns').off('mouseover', '.own_town .flagpole');
3318 $('#map_towns').on('mouseover', '.own_town .flagpole', function () {
3319 TownPopup.add(this);
3320 });
3321
3322
3323 // Style for foreign cities (shadow)
3324 style_str += "#minimap_islands_layer .m_town { text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.7); } ";
3325
3326 // Style for night mode
3327 style_str += "#minimap_canvas.expanded.night, #map.night .flagpole { filter: brightness(0.7); -webkit-filter: brightness(0.7); } ";
3328 style_str += "#minimap_click_layer { display:none; }";
3329
3330 style_str += "</style>";
3331 $(style_str).appendTo('head');
3332
3333
3334 } catch (error) {
3335 errorHandling(error, "TownIcons.Map.activate");
3336 }
3337 },
3338 deactivate: function () {
3339 $('#dio_townicons_map').remove();
3340
3341 // Events entfernen
3342 $('#minimap_islands_layer').off('click', '.m_town');
3343 $('#minimap_islands_layer').off("mousedown");
3344
3345 $('#minimap_islands_layer').off('mouseout', '.m_town');
3346 $('#minimap_islands_layer').off('mouseover', '.m_town');
3347 }
3348 }
3349 };
3350
3351 function updateIcon() {
3352 setTimeout(function() {
3353 var townType = (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")));
3354 $('#town_icon .icon_big').removeClass().addClass('icon_big townicon_' + townType + " auto");
3355 $('#town_icon .icon_big').css({
3356 backgroundPosition: TownIcons.types[townType] * -25 + 'px 0px'
3357 });
3358 },200);
3359 }
3360
3361 $(".btn_next_town").click(function () {
3362 updateIcon();
3363 });
3364 $(".btn_prev_town").click(function () {
3365 updateIcon();
3366 });
3367 document.onkeydown = function(e) {
3368 e = e || window.event;
3369 if (e.keyCode == '37' || e.keyCode == '39') {
3370 updateIcon();
3371 }
3372 };
3373
3374
3375 var TownPopup = {
3376 activate : function(){
3377
3378 $('<style id="dio_town_popup_style" type="text/css">' +
3379 '#dio_town_popup { position:absolute; z-index:99;max-width: 173px;} ' +
3380
3381 '#dio_town_popup .title { margin:5px;font-weight: bold; } ' +
3382
3383 '#dio_town_popup .dio_branding { position:absolute; right:12px; top:8px; height: 20px; filter:sepia(1); -webkit-filter:sepia(1); opacity:0.5; } ' +
3384
3385 '#dio_town_popup .unit_content, ' +
3386 '#dio_town_popup .spy_content, ' +
3387 '#dio_town_popup .god_content, ' +
3388 '#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; } ' +
3389 '#dio_town_popup .resources_content { text-align: right; margin-top:3px; } ' +
3390
3391 '#dio_town_popup .resources_content table { min-width:95% } ' +
3392
3393 '#dio_town_popup .footer_content { margin-top:3px; } ' +
3394 '#dio_town_popup .footer_content table { width:100%; } ' +
3395
3396 '#dio_town_popup .spy_content { height:25px; margin-right:3px; } ' +
3397 '#dio_town_popup .god_content { width:24px; } ' +
3398
3399 '#dio_town_popup .god_mini { height: 25px; width: 32px; background-size: 75%; background-position: 0px -122px; margin-right: -8px; } ' +
3400
3401 // God Icon
3402 '#dio_town_popup .god_mini.zeus { background-position: 0px 0px; } ' +
3403 '#dio_town_popup .god_mini.athena { background-position: 0px -24px; } ' +
3404 '#dio_town_popup .god_mini.poseidon { background-position: 0px -49px; } ' +
3405 '#dio_town_popup .god_mini.hera { background-position: 0px -73px; } ' +
3406 '#dio_town_popup .god_mini.hades { background-position: 0px -98px; } ' +
3407 '#dio_town_popup .god_mini.artemis { background-position: 0px -146px; } ' +
3408
3409 '#dio_town_popup .count { position: absolute; bottom: -2px; right: 2px; font-size: 10px; font-family: Verdana,Arial,Helvetica,sans-serif; } ' +
3410 '#dio_town_popup .four_digit_number .count { font-size:8px !important; } ' +
3411 '#dio_town_popup .unit_icon25x25 { border: 1px solid #6e4b0b; margin: 1px; } ' +
3412 '#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%; } ' +
3413
3414 // Spy Icon
3415 '#dio_town_popup .support_filter { margin: 0px 4px 0px 0px; float:left; } ' +
3416 '#dio_town_popup .spy_text { line-height: 2.3em; float:left; } ' +
3417
3418 // Bei langen Stadtnamen wird sonst der Rand abgeschnitten:
3419 '#dio_town_popup .popup_middle_right { min-width: 11px; } ' +
3420
3421 '</style>').appendTo('head');
3422
3423 },
3424 deactivate : function(){
3425 $("#dio_town_popup_style").remove();
3426 },
3427 add : function(that){
3428 var townID = 0;
3429 //console.debug("TOWN", $(that).offset(), that.id);
3430
3431 if(that.id === ""){
3432 // Island view
3433 townID = parseInt($(that).parent()[0].id.substring(10), 10);
3434 }
3435 else {
3436 // Strategic map
3437 townID = parseInt(that.id.substring(6), 10);
3438 }
3439
3440 // Own town?
3441 if (typeof(uw.ITowns.getTown(townID)) !== "undefined") {
3442
3443 var units = ITowns.getTowns()[townID].units();
3444
3445 TownPopup.remove();
3446
3447 // var popup = "<div id='dio_town_popup' style='left:" + ($(that).offset().left + 20) + "px; top:" + ($(that).offset().top + 20) + "px; '>";
3448 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'>";
3449
3450 popup += "<tr class='popup_top'><td class='popup_top_left'></td><td class='popup_top_middle'></td><td class='popup_top_right'></td></tr>";
3451
3452 popup += "<tr><td class='popup_middle_left'> </td><td style='width: auto;' class='popup_middle_middle'>";
3453
3454 // Title (town name)
3455 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>";
3456
3457 // Unit Container
3458 popup += "<div class='unit_content'>";
3459 if(!$.isEmptyObject(units)) {
3460
3461 for (var unit_id in units) {
3462 if (units.hasOwnProperty(unit_id)) {
3463
3464 var classSize = "";
3465
3466 if(units[unit_id] > 1000){
3467 classSize = "four_digit_number";
3468 }
3469
3470 // Unit
3471 popup += '<div class="unit_icon25x25 ' + unit_id + ' '+ classSize +'"><span class="count text_shadow">' + units[unit_id] + '</span></div>';
3472 }
3473 }
3474 }
3475
3476 // - Wall
3477 var wallLevel = ITowns.getTowns()[townID].getBuildings().attributes.wall;
3478 popup += '<div class="wall image bold"><span class="count text_shadow">'+ wallLevel +'</span></div>';
3479
3480 popup += "</div>";
3481
3482 // Resources Container
3483 popup += "<div class='resources_content'><table cellspacing='2px' cellpadding='0px'><tr>";
3484
3485 var resources = ITowns.getTowns()[townID].resources();
3486 var storage = ITowns.getTowns()[townID].getStorage();
3487
3488 // - Wood
3489 var textColor = (resources.wood === storage) ? textColor = "color:red;" : textColor = "";
3490 popup += '<td class="resources_small wood"></td><td style="'+ textColor +'; width:1%;">' + resources.wood + '</td>';
3491
3492 popup += '<td style="min-width:15px;"></td>';
3493
3494 // - Population
3495 popup += '<td class="resources_small population"></td><td style="width:1%">' + resources.population + '</td>';
3496
3497 popup += '</tr><tr>';
3498
3499 // - Stone
3500 textColor = (resources.stone === storage) ? textColor = "color:red;" : textColor = "";
3501 popup += '<td class="resources_small stone"></td><td style="'+ textColor +'">' + resources.stone + '</td>';
3502
3503 popup += '</tr><tr>';
3504
3505 // - Iron
3506 textColor = (resources.iron === storage) ? textColor = "color:red;" : textColor = "";
3507 popup += '<td class="resources_small iron"></td><td style="'+ textColor +'">' + resources.iron + '</td>';
3508
3509
3510 popup += "</tr></table></div>";
3511
3512 // console.debug("TOWNINFO", ITowns.getTowns()[townID]);
3513
3514 // Spy and God Container
3515 popup += "<div class='footer_content'><table cellspacing='0px'><tr>";
3516
3517 var spy_storage = ITowns.getTowns()[townID].getEspionageStorage();
3518
3519 // - Spy content
3520 popup += "<td class='spy_content'>";
3521 popup += '<div class="support_filter attack_spy"></div><div class="spy_text">'+ pointNumber(spy_storage) +'</div>';
3522 popup += "</td>";
3523
3524 popup += "<td></td>";
3525
3526 // - God Content
3527 var god = ITowns.getTowns()[townID].god();
3528
3529 popup += "<td class='god_content'>";
3530 popup += '<div class="god_mini '+ god +'"></div>';
3531 popup += "</td>";
3532
3533 popup += "</tr></table></div>";
3534
3535
3536
3537 popup += "</td><td class='popup_middle_right'> </td></tr>";
3538
3539 popup += "<tr class='popup_bottom'><td class='popup_bottom_left'></td><td class='popup_bottom_middle'></td><td class='popup_bottom_right'></td></tr>";
3540
3541 popup += "</table>";
3542
3543 $(popup).appendTo("#popup_div_curtain");
3544 }
3545 },
3546 remove : function(){
3547 $('#dio_town_popup').remove();
3548 }
3549 };
3550
3551 // Style for town icons
3552 var style_str = '<style id="dio_townicons" type="text/css">';
3553 for (var s in TownIcons.types) {
3554 if (TownIcons.types.hasOwnProperty(s)) {
3555 style_str += '.townicon_' + s + ' { background:url(' + dio_sprite + ') ' + (TownIcons.types[s] * -25) + 'px -26px repeat;float:left;} ';
3556 }
3557 }
3558 style_str += '</style>';
3559 $(style_str).appendTo('head');
3560
3561
3562 var ContextMenu = {
3563 activate: function () {
3564 // Set context menu event handler
3565 $.Observer(uw.GameEvents.map.context_menu.click).subscribe('DIO_CONTEXT', function (e, data) {
3566 if (DATA.options.con && $('#context_menu').children().length == 4) {
3567 // Clear animation
3568 $('#context_menu div#goToTown').css({
3569 left: '0px',
3570 top: '0px',
3571 WebkitAnimation: 'none', //'A 0s linear',
3572 animation: 'none' //'B 0s linear'
3573 });
3574 }
3575 // Replace german label of 'select town' button
3576 if (LID === "de" && $('#select_town').get(0)) {
3577 $("#select_town .caption").get(0).innerHTML = "Selektieren";
3578 }
3579 });
3580
3581 // Set context menu animation
3582 $('<style id="dio_context_menu" type="text/css">' +
3583 // set fixed position of 'select town' button
3584 '#select_town { left: 0px !important; top: 0px !important; z-index: 6; } ' +
3585 // set animation of 'goToTown' button
3586 '#context_menu div#goToTown { left: 30px; top: -51px; ' +
3587 '-webkit-animation: A 0.115s linear; animation: B 0.2s;} ' +
3588 '@-webkit-keyframes A { from {left: 0px; top: 0px;} to {left: 30px; top: -51px;} }' +
3589 '@keyframes B { from {left: 0px; top: 0px;} to {left: 30px; top: -51px;} }' +
3590 '</style>').appendTo('head');
3591 updateIcon();
3592 },
3593 deactivate: function () {
3594 $.Observer(uw.GameEvents.map.context_menu.click).unsubscribe('DIO_CONTEXT');
3595
3596 $('#dio_context_menu').remove();
3597 }
3598 };
3599
3600
3601 var TownList = {
3602 activate: function () {
3603 // Style town list
3604 $('<style id="dio_town_list" type="text/css">' +
3605 '#town_groups_list .item { text-align: left; padding-left:35px; } ' +
3606 '#town_groups_list .inner_column { border: 1px solid rgba(100, 100, 0, 0.3);margin: -2px 0px 0px 2px; } ' +
3607 '#town_groups_list .island_quest_icon { position: absolute; right: 37px; top: 3px; } ' +
3608 '#town_groups_list .island_quest_icon.hidden_icon { display:none; } ' +
3609 // Quacks Zentrier-Button verschieben
3610 '#town_groups_list .jump_town { right: 37px !important; } ' +
3611 // Population percentage
3612 '#town_groups_list .pop_percent { position: absolute; right: 7px; top:0px; font-size: 0.7em; display:block !important;} ' +
3613 '#town_groups_list .full { color: green; } ' +
3614 '#town_groups_list .threequarter { color: darkgoldenrod; } ' +
3615 '#town_groups_list .half { color: darkred; } ' +
3616 '#town_groups_list .quarter { color: red; } ' +
3617 '</style>').appendTo('head');
3618
3619
3620 // Open town list: hook to grepolis function render()
3621 var i = 0;
3622 while (uw.layout_main_controller.sub_controllers[i].name != 'town_name_area') {
3623 i++;
3624 }
3625
3626 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;
3627
3628 uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render = function () {
3629 uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render_old();
3630 TownList.change();
3631 };
3632
3633 // Town List open?
3634 if ($('#town_groups_list').get(0)) {
3635 TownList.change();
3636 }
3637 },
3638 deactivate: function () {
3639 var i = 0;
3640 while (uw.layout_main_controller.sub_controllers[i].name != 'town_name_area') {
3641 i++;
3642 }
3643
3644 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;
3645
3646 $('#dio_town_list').remove();
3647
3648 $('#town_groups_list .small_icon, #town_groups_list .pop_percent').css({display: 'none'});
3649
3650 //$.Observer(uw.GameEvents.town.town_switch).unsubscribe('DIO_SWITCH_TOWN');
3651
3652 $("#town_groups_list .town_group_town").unbind('mouseenter mouseleave');
3653 },
3654 change: function () {
3655 if (!$('#town_groups_list .icon_small').get(0) && !$('#town_groups_list .pop_percent').get(0)) {
3656 $("#town_groups_list .town_group_town").each(function () {
3657 try {
3658 var town_item = $(this), town_id = town_item.attr('name'), townicon_div, percent_div = "", percent = -1, pop_space = "full";
3659
3660 if (population[town_id]) {
3661 percent = population[town_id].percent;
3662 }
3663 if (percent < 75) {
3664 pop_space = "threequarter";
3665 }
3666 if (percent < 50) {
3667 pop_space = "half";
3668 }
3669 if (percent < 25) {
3670 pop_space = "quarter";
3671 }
3672
3673 if (!town_item.find('icon_small').length) {
3674 townicon_div = '<div class="icon_small townicon_' + (manuTownTypes[town_id] || autoTownTypes[town_id] || "no") + '"></div>';
3675 // TODO: Notlösung...
3676 if (percent != -1) {
3677 percent_div = '<div class="pop_percent ' + pop_space + '">' + percent + '%</div>';
3678 }
3679 town_item.prepend(townicon_div + percent_div);
3680 }
3681
3682 // opening context menu
3683 /*
3684 $(this).click(function(e){
3685 console.log(e);
3686 uw.Layout.contextMenu(e, 'determine', {"id": town_id,"name": uw.ITowns[town_id].getName()});
3687 });
3688 */
3689
3690 updateIcon();
3691
3692 } catch (error) {
3693 errorHandling(error, "TownList.change");
3694 }
3695 });
3696
3697 }
3698
3699 // Hover Effect for Quacks Tool:
3700 $("#town_groups_list .town_group_town").hover(function () {
3701 $(this).find('.island_quest_icon').addClass("hidden_icon");
3702 }, function () {
3703 $(this).find('.island_quest_icon').removeClass("hidden_icon");
3704 });
3705
3706 // Add change town list event handler
3707 //$.Observer(uw.GameEvents.town.town_switch).subscribe('DIO_SWITCH_TOWN', function () {
3708 //TownList.change();
3709 //});
3710 }
3711 };
3712
3713 var HiddenHighlightWindow = {
3714 activate : function(){
3715 // Style town list
3716 $('<style id="dio_hidden_highlight_window" type="text/css">' +
3717 '.strategic_map_filter { display:none !important; } ' +
3718 '</style>').appendTo('head');
3719 },
3720 deactivate : function (){
3721 $('#dio_hidden_highlight_window').remove();
3722 }
3723 };
3724
3725 /*******************************************************************************************************************************
3726 * Available units
3727 * ----------------------------------------------------------------------------------------------------------------------------
3728 * | â— GetAllUnits
3729 * | â— Shows all available units
3730 * ----------------------------------------------------------------------------------------------------------------------------
3731 *******************************************************************************************************************************/
3732 var groupUnitArray = {};
3733 // TODO: split Function (getUnits, calcUnitsSum, availableUnits, countBiremes, getTownTypes)?
3734
3735 // Alter Einheitenzähler
3736 function getAllUnits() {
3737 try {
3738 var townArray = uw.ITowns.getTowns(), groupArray = uw.ITowns.townGroups.getGroupsDIO(),
3739
3740 unitArray = {
3741 "sword": 0,
3742 "archer": 0,
3743 "hoplite": 0,
3744 "chariot": 0,
3745 "godsent": 0,
3746 "rider": 0,
3747 "slinger": 0,
3748 "catapult": 0,
3749 "small_transporter": 0,
3750 "big_transporter": 0,
3751 "manticore": 0,
3752 "harpy": 0,
3753 "pegasus": 0,
3754 "cerberus": 0,
3755 "minotaur": 0,
3756 "medusa": 0,
3757 "zyklop": 0,
3758 "centaur": 0,
3759 "fury": 0,
3760 "sea_monster": 0
3761 },
3762
3763 unitArraySea = {"bireme": 0, "trireme": 0, "attack_ship": 0, "demolition_ship": 0, "colonize_ship": 0};
3764
3765 //console.debug("DIO-TOOLS | getAllUnits | GROUP ARRAY", groupArray);
3766
3767
3768 if (uw.Game.hasArtemis) {
3769 unitArray = $.extend(unitArray, {"griffin": 0, "calydonian_boar": 0});
3770 }
3771 unitArray = $.extend(unitArray, unitArraySea);
3772
3773 for (var group in groupArray) {
3774 if (groupArray.hasOwnProperty(group)) {
3775 // Clone Object "unitArray"
3776 groupUnitArray[group] = Object.create(unitArray);
3777
3778 for (var town in groupArray[group].towns) {
3779 if (groupArray[group].towns.hasOwnProperty(town)) {
3780 var type = {lo: 0, ld: 0, so: 0, sd: 0, fo: 0, fd: 0}; // Type for TownList
3781
3782 for (var unit in unitArray) {
3783 if (unitArray.hasOwnProperty(unit)) {
3784 // All Groups: Available units
3785 var tmp = parseInt(uw.ITowns.getTown(town).units()[unit], 10);
3786 groupUnitArray[group][unit] += tmp || 0;
3787 // Only for group "All"
3788 if (group == -1) {
3789 // Bireme counter // old
3790 if (unit === "bireme" && ((biriArray[townArray[town].id] || 0) < (tmp || 0))) {
3791 biriArray[townArray[town].id] = tmp;
3792 }
3793 //TownTypes
3794 if (!uw.GameData.units[unit].is_naval) {
3795 if (uw.GameData.units[unit].flying) {
3796 type.fd += ((uw.GameData.units[unit].def_hack + uw.GameData.units[unit].def_pierce + uw.GameData.units[unit].def_distance) / 3 * (tmp || 0));
3797 type.fo += (uw.GameData.units[unit].attack * (tmp || 0));
3798 } else {
3799 type.ld += ((uw.GameData.units[unit].def_hack + uw.GameData.units[unit].def_pierce + uw.GameData.units[unit].def_distance) / 3 * (tmp || 0));
3800 type.lo += (uw.GameData.units[unit].attack * (tmp || 0));
3801 }
3802 } else {
3803 type.sd += (uw.GameData.units[unit].defense * (tmp || 0));
3804 type.so += (uw.GameData.units[unit].attack * (tmp || 0));
3805 }
3806 }
3807 }
3808 }
3809 // Only for group "All"
3810 if (group == -1) {
3811 // Icon: DEF or OFF?
3812 var z = ((type.sd + type.ld + type.fd) <= (type.so + type.lo + type.fo)) ? "o" : "d",
3813 temp = 0;
3814
3815 for (var t in type) {
3816 if (type.hasOwnProperty(t)) {
3817 // Icon: Land/Sea/Fly (t[0]) + OFF/DEF (z)
3818 if (temp < type[t]) {
3819 autoTownTypes[townArray[town].id] = t[0] + z;
3820 temp = type[t];
3821 }
3822 // Icon: Troops Outside (overwrite)
3823 if (temp < 1000) {
3824 autoTownTypes[townArray[town].id] = "no";
3825 }
3826 }
3827 }
3828 // Icon: Empty Town (overwrite)
3829 var popBuilding = 0, buildVal = uw.GameData.buildings, levelArray = townArray[town].buildings().getLevels(),
3830 popMax = Math.floor(buildVal.farm.farm_factor * Math.pow(townArray[town].buildings().getBuildingLevel("farm"), buildVal.farm.farm_pow)), // Population from farm level
3831 popPlow = townArray[town].getResearches().attributes.plow ? 200 : 0,
3832 popFactor = townArray[town].getBuildings().getBuildingLevel("thermal") ? 1.1 : 1.0, // Thermal
3833 popExtra = townArray[town].getPopulationExtra();
3834
3835 for (var b in levelArray) {
3836 if (levelArray.hasOwnProperty(b)) {
3837 popBuilding += Math.round(buildVal[b].pop * Math.pow(levelArray[b], buildVal[b].pop_factor));
3838 }
3839 }
3840 population[town] = {};
3841
3842 population[town].max = popMax * popFactor + popPlow + popExtra;
3843 population[town].buildings = popBuilding;
3844 population[town].units = parseInt((population[town].max - (popBuilding + townArray[town].getAvailablePopulation()) ), 10);
3845
3846 if (population[town].units < 300) {
3847 autoTownTypes[townArray[town].id] = "po";
3848 }
3849
3850 population[town].percent = Math.round(100 / (population[town].max - popBuilding) * population[town].units);
3851 }
3852 }
3853 }
3854 }
3855 }
3856
3857 // Update Available Units
3858 AvailableUnits.updateBullseye();
3859 if (GPWindowMgr.TYPE_DIO_UNITS) {
3860 if (Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS)) {
3861 AvailableUnits.updateWindow();
3862 }
3863 }
3864 } catch (error) {
3865 errorHandling(error, "getAllUnits"); // TODO: Eventueller Fehler in Funktion
3866 }
3867 }
3868
3869 function addFunctionToITowns() {
3870 // Copy function and prevent an error
3871 uw.ITowns.townGroups.getGroupsDIO = function () {
3872 var town_groups_towns, town_groups, groups = {};
3873
3874 // #Grepolis Fix: 2.75 -> 2.76
3875 if (MM.collections) {
3876 town_groups_towns = MM.collections.TownGroupTown[0];
3877 town_groups = MM.collections.TownGroup[0];
3878 } else {
3879 town_groups_towns = MM.getCollections().TownGroupTown[0];
3880 town_groups = MM.getCollections().TownGroup[0];
3881 }
3882
3883 town_groups_towns.each(function (town_group_town) {
3884 var gid = town_group_town.getGroupId(),
3885 group = groups[gid],
3886 town_id = town_group_town.getTownId();
3887
3888 if (!group) {
3889 groups[gid] = group = {
3890 id: gid,
3891 //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
3892 towns: {}
3893 };
3894 }
3895
3896 group.towns[town_id] = {id: town_id};
3897 //groups[gid].towns[town_id]={id:town_id};
3898 });
3899 //console.log(groups);
3900 return groups;
3901 };
3902 }
3903
3904
3905 // Neuer Einheitenzähler
3906 var UnitCounter = {
3907 units : {"total":{}, "available":{}, "outer":{}, "foreign":{}},
3908
3909 count : function(){
3910 var tooltipHelper = require("helpers/units_tooltip_helper");
3911
3912 var groups = uw.ITowns.townGroups.getGroupsDIO();
3913
3914 for (var groupId in groups) {
3915 if (groups.hasOwnProperty(groupId)) {
3916
3917 UnitCounter.units.total[groupId] = {};
3918 UnitCounter.units.available[groupId] = {};
3919 UnitCounter.units.outer[groupId] = {};
3920
3921
3922 for (var townId in groups[groupId].towns) {
3923 if (groups[groupId].towns.hasOwnProperty(townId)) {
3924
3925 // Einheiten gesamt
3926 UnitCounter.units.total[groupId][townId] = ITowns.towns[townId].units();
3927
3928 // Einheiten verfügbar
3929 UnitCounter.units.available[groupId][townId] = ITowns.towns[townId].units();
3930
3931 // Einheiten außerhalb
3932 UnitCounter.units.outer[groupId][townId] = {};
3933
3934 var supports = tooltipHelper.getDataForSupportingUnitsInOtherTownFromCollection(MM.getTownAgnosticCollectionsByName("Units")[1].fragments[townId], MM.getOnlyCollectionByName("Town"));
3935
3936 for (var supportId in supports) {
3937 if (supports.hasOwnProperty(supportId)) {
3938
3939 for (var attributeId in supports[supportId].attributes) {
3940 if (supports[supportId].attributes.hasOwnProperty(attributeId)) {
3941
3942 // Attribut ist eine Einheit?
3943 if (typeof(GameData.units[attributeId]) !== "undefined" && supports[supportId].attributes[attributeId] > 0) {
3944
3945 UnitCounter.units.outer[groupId][townId][attributeId] = (UnitCounter.units.outer[groupId][townId][attributeId] || 0) + supports[supportId].attributes[attributeId];
3946
3947 UnitCounter.units.total[groupId][townId][attributeId] = (UnitCounter.units.total[groupId][townId][attributeId] || 0) + supports[supportId].attributes[attributeId];
3948 }
3949 }
3950 }
3951 }
3952 }
3953 }
3954 }
3955
3956 // Summen aller Städte berechnen
3957 UnitCounter.summarize(groupId);
3958 }
3959 }
3960
3961 return UnitCounter.units;
3962 },
3963
3964 summarize : function(groupId){
3965 var tooltipHelper = require("helpers/units_tooltip_helper");
3966
3967 UnitCounter.units.total[groupId]["all"] = {};
3968 UnitCounter.units.available[groupId]["all"] = {};
3969 UnitCounter.units.outer[groupId]["all"] = {};
3970
3971 for(var townId in UnitCounter.units.total[groupId]){
3972 if(UnitCounter.units.total[groupId].hasOwnProperty(townId) && townId !== "all"){
3973
3974 // Einheiten gesamt
3975 for(var unitId in UnitCounter.units.total[groupId][townId]){
3976 if(UnitCounter.units.total[groupId][townId].hasOwnProperty(unitId)){
3977
3978 UnitCounter.units.total[groupId]["all"][unitId] = (UnitCounter.units.total[groupId]["all"][unitId] || 0) + UnitCounter.units.total[groupId][townId][unitId];
3979 }
3980 }
3981
3982 // Einheiten verfügbar
3983 for(var unitId in UnitCounter.units.available[groupId][townId]){
3984 if(UnitCounter.units.available[groupId][townId].hasOwnProperty(unitId)){
3985
3986 UnitCounter.units.available[groupId]["all"][unitId] = (UnitCounter.units.available[groupId]["all"][unitId] || 0) + UnitCounter.units.available[groupId][townId][unitId];
3987 }
3988 }
3989
3990 // Einheiten außerhalb
3991 for(var unitId in UnitCounter.units.outer[groupId][townId]){
3992 if(UnitCounter.units.outer[groupId][townId].hasOwnProperty(unitId)){
3993
3994 UnitCounter.units.outer[groupId]["all"][unitId] = (UnitCounter.units.outer[groupId]["all"][unitId] || 0) + UnitCounter.units.outer[groupId][townId][unitId];
3995 }
3996 }
3997 }
3998 }
3999 }
4000 };
4001
4002
4003 var AvailableUnits = {
4004 activate: function () {
4005 var default_title = DM.getl10n("place", "support_overview").options.troop_count + " (" + DM.getl10n("hercules2014", "available") + ")";
4006
4007 $(".picomap_container").prepend("<div id='available_units_bullseye' class='unit_icon90x90 " + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme") + "'><div class='amount'></div></div>");
4008
4009 $('.picomap_overlayer').tooltip(getText("options", "ava")[0]);
4010
4011 // Ab version 2.115
4012 if($(".topleft_navigation_area").get(0)) {
4013
4014 $(".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>");
4015
4016 $('<style id="dio_available_units_style_addition">' +
4017 '.coords_box { top: 117px !important; } ' +
4018 '.nui_grepo_score { top: 150px !important; } ' +
4019 '.nui_left_box { top: 102px !important; } ' +
4020 '.nui_main_menu { top: 293px !important; }' +
4021 '#grcrt_mnu_list .nui_main_menu {top: 0px !important; }'+
4022 '.bull_eye_buttons, .rb_map { height:38px !important; }' +
4023
4024 '#ui_box .btn_change_colors { top: 31px !important; }' +
4025
4026 '.picomap_area { position: absolute; overflow: visible; top: 0; left: 0; width: 156px; height: 161px; z-index: 5; }' +
4027 '.picomap_area .picomap_container, .picomap_area .picomap_overlayer { position: absolute; top: 33px; left: -3px; width: 147px; height: 101px; }' +
4028 //'.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;} '+
4029 '.picomap_area .picomap_overlayer { background: url(' + dio_sprite + '); background-position: 473px 250px; width: 147px; height: 101px; z-index: 5;} ' +
4030 '</style>').appendTo('head');
4031 }
4032
4033 // Style
4034 $('<style id="dio_available_units_style">' +
4035
4036 '@-webkit-keyframes Z { 0% { opacity: 0; } 100% { opacity: 1; } } ' +
4037 '@keyframes Z { 0% { opacity: 0; } 100% { opacity: 1; } } ' +
4038
4039 '@-webkit-keyframes blurr { 0% { -webkit-filter: blur(5px); } 100% { -webkit-filter: blur(0px); } } ' +
4040
4041 '.picomap_overlayer { cursor:pointer; } ' +
4042
4043 '.picomap_area .bull_eye_buttons { height: 55px; } ' +
4044
4045 '#sea_id { background: none; font-size:25px; cursor:default; height:50px; width:50px; position:absolute; top:70px; left:157px; z-index: 30; } ' +
4046
4047 // Available bullseye unit
4048 '#available_units_bullseye { margin: 5px 28px 0px 28px; -webkit-animation: blur 2s; animation: Z 1s; } ' +
4049
4050 '#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; } ' +
4051
4052 '#available_units_bullseye.big_number { font-size: 0.90em; line-height: 1.4; } ' +
4053
4054 '#available_units_bullseye.blur { -webkit-animation: blurr 0.6s; } ' +
4055
4056
4057
4058 // Land units
4059 '#available_units_bullseye.sword .amount { color:#E2D9C1; top:57px; width:90px; } ' +
4060 '#available_units_bullseye.hoplite .amount { color:#E2D9C1; top:57px; width:90px; } ' +
4061 '#available_units_bullseye.archer .amount { color:#E2D0C1; top:47px; width:70px; } ' +
4062 '#available_units_bullseye.chariot { margin-top: 15px; } ' +
4063 '#available_units_bullseye.chariot .amount { color:#F5E8B4; top:38px; width:91px; } ' +
4064 '#available_units_bullseye.rider .amount { color:#DFCC6C; top:52px; width:105px; } ' +
4065 '#available_units_bullseye.slinger .amount { color:#F5E8B4; top:53px; width:91px; } ' +
4066 '#available_units_bullseye.catapult .amount { color:#F5F6C5; top:36px; width:87px; } ' +
4067 '#available_units_bullseye.godsent .amount { color:#F5F6C5; top:57px; width:92px; } ' +
4068
4069 // Mythic units
4070 '#available_units_bullseye.medusa .amount { color:#FBFFBB; top:50px; width:65px; } ' +
4071 '#available_units_bullseye.manticore .amount { color:#ECD181; top:50px; width:55px; } ' +
4072 '#available_units_bullseye.pegasus { margin-top: 16px; } ' +
4073 '#available_units_bullseye.pegasus .amount { color:#F7F8E3; top:36px; width:90px; } ' +
4074 '#available_units_bullseye.minotaur { margin-top: 10px; } ' +
4075 '#available_units_bullseye.minotaur .amount { color:#EAD88A; top:48px; width:78px; } ' +
4076 '#available_units_bullseye.zyklop { margin-top: 3px; } '+
4077 '#available_units_bullseye.zyklop .amount { color:#EDE0B0; top:50px; width:95px; } ' +
4078 '#available_units_bullseye.harpy { margin-top: 16px; } ' +
4079 '#available_units_bullseye.harpy .amount { color:#E7DB79; top:30px; width:78px; } ' +
4080 '#available_units_bullseye.sea_monster .amount { color:#D8EA84; top:58px; width:91px; } ' +
4081 '#available_units_bullseye.cerberus .amount { color:#EC7445; top:25px; width:101px; } ' +
4082 '#available_units_bullseye.centaur { margin-top: 15px; } ' +
4083 '#available_units_bullseye.centaur .amount { color:#ECE0A8; top:29px; width:83px; } ' +
4084 '#available_units_bullseye.fury .amount { color:#E0E0BC; top:57px; width:95px; } ' +
4085 '#available_units_bullseye.griffin { margin-top: 15px; } ' +
4086 '#available_units_bullseye.griffin .amount { color:#FFDC9D; top:40px; width:98px; } ' +
4087 '#available_units_bullseye.calydonian_boar .amount { color:#FFDC9D; top:17px; width:85px; } ' +
4088
4089 // Naval units
4090 '#available_units_bullseye.attack_ship .amount { color:#FFCB00; top:26px; width:99px; } ' +
4091 '#available_units_bullseye.bireme .amount { color:#DFC677; color:azure; top:28px; width:79px; } ' +
4092 '#available_units_bullseye.trireme .amount { color:#F4FFD4; top:24px; width:90px; } ' +
4093 '#available_units_bullseye.small_transporter .amount { color:#F5F6C5; top:26px; width:84px; } ' +
4094 '#available_units_bullseye.big_transporter .amount { color:#FFDC9D; top:27px; width:78px; } ' +
4095 '#available_units_bullseye.colonize_ship .amount { color:#F5F6C5; top:29px; width:76px; } ' +
4096 '#available_units_bullseye.colonize_ship .amount { color:#F5F6C5; top:29px; width:76px; } ' +
4097 '#available_units_bullseye.demolition_ship .amount { color:#F5F6C5; top:35px; width:90px; } ' +
4098
4099 // Available units window
4100 '#available_units { overflow: auto; } ' +
4101 '#available_units .unit { margin: 5px; cursor:pointer; overflow:visible; } ' +
4102 '#available_units .unit.active { border: 2px solid #7f653a; border-radius:30px; margin:4px; } ' +
4103 '#available_units .unit span { text-shadow: 1px 1px 1px black, 1px 1px 2px black;} ' +
4104 '#available_units hr { margin: 5px 0px 5px 0px; } ' +
4105 '#available_units .drop_box .option { float: left; margin-right: 30px; width:100%; } ' +
4106 '#available_units .drop_box { position:absolute; top: -38px; right: 83px; width:90px; z-index:10; } ' +
4107 '#available_units .drop_box .drop_group { width: 120px; } ' +
4108 '#available_units .drop_box .select_group.open { display:block; } ' +
4109 '#available_units .drop_box .item-list { overflow: auto; overflow-x: hidden; } ' +
4110 '#available_units .drop_box .arrow { width:18px; height:18px; background:url(' + drop_out.src + ') no-repeat -1px -1px; position:absolute; } ' +
4111
4112 // Available units button
4113 '#btn_available_units { top:86px; left:119px; z-index:10; position:absolute; } ' +
4114 '#btn_available_units .ico_available_units { margin:5px 0px 0px 4px; width:24px; height:24px; ' +
4115 '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); } ' +
4116
4117 '</style>').appendTo('head');
4118
4119 createWindowType("DIO_UNITS", (LANG.hasOwnProperty(LID) ? getText("options", "ava")[0] : default_title), 365, 310, true, [240, 70]);
4120
4121 // Set Sea-ID beside the bull eye
4122 $('#sea_id').prependTo('#ui_box');
4123
4124 AvailableUnits.addButton();
4125
4126 UnitCounter.count();
4127 AvailableUnits.updateBullseye();
4128 },
4129 deactivate: function () {
4130 $('#available_units_bullseye').remove();
4131 $('#available_units_bullseye_addition').remove();
4132
4133 $('#dio_available_units_style').remove();
4134 $('#dio_available_units_style_addition').remove();
4135
4136 $('#btn_available_units').remove();
4137
4138 if (Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS)) {
4139 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS).close();
4140 }
4141
4142 $('.picomap_overlayer').unbind();
4143
4144 $('#sea_id').appendTo('.picomap_container')
4145 },
4146 addButton: function () {
4147 var default_title = DM.getl10n("place", "support_overview").options.troop_count + " (" + DM.getl10n("hercules2014", "available") + ")";
4148
4149 $('<div id="btn_available_units" class="circle_button"><div class="ico_available_units js-caption"></div></div>').appendTo(".bull_eye_buttons");
4150
4151 // Events
4152 $('#btn_available_units').on('mousedown', function () {
4153 $('#btn_available_units, .ico_available_units').addClass("checked");
4154 }).on('mouseup', function () {
4155 $('#btn_available_units, .ico_available_units').removeClass("checked");
4156 });
4157
4158 $('#btn_available_units, .picomap_overlayer').click(function () {
4159 if (!Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS)) {
4160 AvailableUnits.openWindow();
4161 $('#btn_available_units, .ico_available_units').addClass("checked");
4162 } else {
4163 AvailableUnits.closeWindow();
4164 $('#btn_available_units, .ico_available_units').removeClass("checked");
4165 }
4166 });
4167
4168 // Tooltip
4169 $('#btn_available_units').tooltip(LANG.hasOwnProperty(LID) ? getText("labels", "uni") : default_title);
4170 },
4171 openWindow: function () {
4172 var groupArray = uw.ITowns.townGroups.getGroupsDIO(),
4173
4174 unitArray = {
4175 "sword": 0,
4176 "archer": 0,
4177 "hoplite": 0,
4178 "slinger": 0,
4179 "rider": 0,
4180 "chariot": 0,
4181 "catapult": 0,
4182 "godsent": 0,
4183 "manticore": 0,
4184 "harpy": 0,
4185 "pegasus": 0,
4186 "griffin": 0,
4187 "cerberus": 0,
4188 "minotaur": 0,
4189 "medusa": 0,
4190 "zyklop": 0,
4191 "centaur": 0,
4192 "calydonian_boar": 0,
4193 "fury": 0,
4194 "sea_monster": 0,
4195 "small_transporter": 0,
4196 "big_transporter": 0,
4197 "bireme": 0,
4198 "attack_ship": 0,
4199 "trireme": 0,
4200 "demolition_ship": 0,
4201 "colonize_ship": 0
4202 };
4203
4204 if (!uw.Game.hasArtemis) {
4205 delete unitArray.calydonian_boar;
4206 delete unitArray.griffin;
4207 }
4208
4209 var land_units_str = "", content =
4210 '<div id="available_units">' +
4211 // Dropdown menu
4212 '<div class="drop_box">' +
4213 '<div class="drop_group dropdown default">' +
4214 '<div class="border-left"></div><div class="border-right"></div>' +
4215 '<div class="caption" name="' + groupArray[DATA.bullseyeUnit.current_group].id + '">' + ITowns.town_groups._byId[groupArray[DATA.bullseyeUnit.current_group].id].attributes.name + '</div>' +
4216 '<div class="arrow"></div>' +
4217 '</div>' +
4218 '<div class="select_group dropdown-list default active"><div class="item-list"></div></div>' +
4219 '</div>' +
4220 '<table width="100%" class="radiobutton horizontal rbtn_visibility"><tr>'+
4221 '<td width="40%"><div class="option js-option" name="total"><div class="pointer"></div>'+ getText("labels", "total") +'</div></td>'+
4222 '<td width="40%"><div class="option js-option" name="available"><div class="pointer"></div>'+ getText("labels", "available") +'</div></td>'+
4223 '<td width="20%"><div class="option js-option" name="outer"><div class="pointer"></div>'+ getText("labels", "outer") +'</div></td>'+
4224 '</tr></table>'+
4225 '<hr>'+
4226 // Content
4227 '<div class="box_content">';
4228
4229 for (var unit in unitArray) {
4230 if (unitArray.hasOwnProperty(unit)) {
4231 land_units_str += '<div class="unit index_unit bold unit_icon40x40 ' + unit + '"></div>';
4232 if (unit == "sea_monster") {
4233 land_units_str += '<div style="clear:left;"></div>'; // break
4234 }
4235 }
4236 }
4237 content += land_units_str + '</div></div>';
4238
4239 AvailableUnits.wnd = Layout.wnd.Create(GPWindowMgr.TYPE_DIO_UNITS);
4240
4241 AvailableUnits.wnd.setContent(content);
4242
4243 if (Game.premium_features.curator <= Timestamp.now()) {
4244 $('#available_units .drop_box').css({display: 'none'});
4245 DATA.bullseyeUnit.current_group = -1;
4246 }
4247
4248 // Add groups to dropdown menu
4249 for (var group in groupArray) {
4250 if (groupArray.hasOwnProperty(group)) {
4251 var group_name = ITowns.town_groups._byId[group].attributes.name;
4252 $('<div class="option' + (group == -1 ? " sel" : "") + '" name="' + group + '">' + group_name + '</div>').appendTo('#available_units .item-list');
4253 }
4254 }
4255
4256 // Set active mode
4257 if(typeof(DATA.bullseyeUnit.mode) !== "undefined"){
4258 $('.radiobutton .option[name="'+ DATA.bullseyeUnit.mode +'"]').addClass("checked");
4259 }
4260 else{
4261 $('.radiobutton .option[name="available"]').addClass("checked");
4262 }
4263
4264 // Update
4265 AvailableUnits.updateWindow();
4266
4267 // Dropdown menu Handler
4268 $('#available_units .drop_group').click(function () {
4269 $('#available_units .select_group').toggleClass('open');
4270 });
4271 // Change group
4272 $('#available_units .select_group .option').click(function () {
4273 DATA.bullseyeUnit.current_group = $(this).attr("name");
4274 $('#available_units .select_group').removeClass('open');
4275 $('#available_units .select_group .option.sel').removeClass("sel");
4276 $(this).addClass("sel");
4277
4278 $('#available_units .drop_group .caption').attr("name", DATA.bullseyeUnit.current_group);
4279 $('#available_units .drop_group .caption').get(0).innerHTML = this.innerHTML;
4280
4281 $('#available_units .unit.active').removeClass("active");
4282 $('#available_units .unit.' + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme")).addClass("active");
4283
4284 UnitCounter.count();
4285
4286 AvailableUnits.updateWindow();
4287 AvailableUnits.updateBullseye();
4288 AvailableUnits.save();
4289 });
4290
4291 // Change mode (total, available, outer)
4292 $('.radiobutton .option').click(function(){
4293
4294 DATA.bullseyeUnit.mode = $(this).attr("name");
4295
4296 $('.radiobutton .option.checked').removeClass("checked");
4297 $(this).addClass("checked");
4298
4299 UnitCounter.count();
4300
4301 AvailableUnits.updateWindow();
4302 AvailableUnits.updateBullseye();
4303 AvailableUnits.save();
4304 });
4305
4306 // Set active bullseye unit
4307 $('#available_units .unit.' + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme")).addClass("active");
4308
4309 // Change bullseye unit
4310 $('#available_units .unit').click(function () {
4311 DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] = this.className.split(" ")[4].trim();
4312
4313 $('#available_units .unit.active').removeClass("active");
4314 $(this).addClass("active");
4315
4316 AvailableUnits.updateBullseye();
4317 AvailableUnits.save();
4318
4319 });
4320
4321 // Close button event - uncheck available units button
4322 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS).getJQCloseButton().get(0).onclick = function () {
4323 $('#btn_available_units, .ico_available_units').removeClass("checked");
4324 };
4325 },
4326 closeWindow: function () {
4327 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS).close();
4328 },
4329 save: function () {
4330 // console.debug("BULLSEYE SAVE", DATA.bullseyeUnit);
4331
4332 saveValue(WID + "_bullseyeUnit", JSON.stringify(DATA.bullseyeUnit));
4333 },
4334 updateBullseye: function () {
4335
4336 var sum = 0, str = "", fsize = ['1.4em', '1.2em', '1.15em', '1.1em', '1.0em', '0.95em'], i;
4337
4338 if ($('#available_units_bullseye').get(0)) {
4339 $('#available_units_bullseye').get(0).className = "unit_icon90x90 " + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme");
4340
4341 if (UnitCounter.units[DATA.bullseyeUnit.mode || "available"][DATA.bullseyeUnit.current_group]) {
4342 sum = UnitCounter.units[DATA.bullseyeUnit.mode || "available"][DATA.bullseyeUnit.current_group]["all"][(DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme" )] || 0;
4343 }
4344 sum = sum.toString();
4345
4346 for (i = 0; i < sum.length; i++) {
4347 str += "<span style='font-size:" + fsize[i] + "'>" + sum[i] + "</span>";
4348 }
4349 $('#available_units_bullseye .amount').get(0).innerHTML = str;
4350
4351 if (sum >= 100000) {
4352 $('#available_units_bullseye').addClass("big_number");
4353 } else {
4354 $('#available_units_bullseye').removeClass("big_number");
4355 }
4356 }
4357 },
4358 updateWindow: function () {
4359
4360 $('#available_units .box_content .unit').each(function () {
4361 var unit = this.className.split(" ")[4];
4362
4363 // TODO: Alte Variante entfernen
4364 // Alte Variante:
4365 //this.innerHTML = '<span style="font-size:0.9em">' + groupUnitArray[DATA.bullseyeUnit.current_group][unit] + '</span>';
4366
4367 // Neue Variante
4368 this.innerHTML = '<span style="font-size:0.9em">' + (UnitCounter.units[DATA.bullseyeUnit.mode || "available"][DATA.bullseyeUnit.current_group]["all"][unit] || 0) + '</span>';
4369 });
4370 }
4371 };
4372
4373 /*******************************************************************************************************************************
4374 * Comparison box
4375 * ----------------------------------------------------------------------------------------------------------------------------
4376 * | â— Compares the units of each unit type
4377 * ----------------------------------------------------------------------------------------------------------------------------
4378 *******************************************************************************************************************************/
4379 var UnitComparison = {
4380 activate: function () {
4381 //UnitComparison.addBox();
4382 UnitComparison.addButton();
4383
4384 // Create Window Type
4385 createWindowType("DIO_COMPARISON", getText("labels", "dsc"), 480, 315, true, ["center", "center", 100, 100]);
4386
4387 // Style
4388 $('<style id="dio_comparison_style"> ' +
4389
4390 // Button
4391 '#dio_comparison_button { top:51px; left:120px; z-index:10; position:absolute; } ' +
4392 '#dio_comparison_button .ico_comparison { margin:5px 0px 0px 4px; width:24px; height:24px; ' +
4393 'background:url(http://666kb.com/i/cjq6cxia4ms8mn95r.png) no-repeat 0px 0px; background-size:100%; filter:url(#Hue1); -webkit-filter:hue-rotate(60deg); } ' +
4394 '#dio_comparison_button.checked .ico_comparison { margin-top:6px; } ' +
4395
4396 // Window
4397 '#dio_comparison a { float:left; background-repeat:no-repeat; background-size:25px; line-height:2; margin-right:10px; } ' +
4398 '#dio_comparison .box_content { text-align:center; font-style:normal; } ' +
4399
4400 // Menu tabs
4401 '#dio_comparison_menu .tab_icon { left: 23px;} ' +
4402 '#dio_comparison_menu .tab_label { margin-left: 18px; } ' +
4403
4404 // Content
4405 '#dio_comparison .hidden { display:none; } ' +
4406 '#dio_comparison table { width:480px; } ' +
4407 '#dio_comparison .hack .t_hack, #dio_comparison .pierce .t_pierce, #dio_comparison .distance .t_distance, #dio_comparison .sea .t_sea { display:inline-table; } ' +
4408
4409 '#dio_comparison .box_content { background:url(http://s1.directupload.net/images/140206/8jd9d3ec.png) 94% 94% no-repeat; background-size:140px; } ' +
4410
4411 '#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%; } ' +
4412 '#dio_comparison .compare_type_icon.booty { background:url(http://s14.directupload.net/images/140404/ki4gwd7x.png); background-size:100%; } ' +
4413 '#dio_comparison .compare_type_icon.time { background:url(https://gpall.innogamescdn.com/images/game/res/time.png); background-size:100%; } ' +
4414 '#dio_comparison .compare_type_icon.favor { background:url(https://gpall.innogamescdn.com/images/game/res/favor.png); background-size:100%; } ' +
4415 '</style>').appendTo("head");
4416 },
4417 deactivate: function () {
4418 $('#dio_comparison_button').remove();
4419 $('#dio_comparison_style').remove();
4420
4421 if (Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON)) {
4422 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON).close();
4423 }
4424 },
4425 addButton: function () {
4426 $('<div id="dio_comparison_button" class="circle_button"><div class="ico_comparison js-caption"></div></div>').appendTo(".bull_eye_buttons");
4427
4428 // Events
4429 /*
4430 $('#dio_comparison_button').on('mousedown', function(){
4431 $('#dio_comparison_button').addClass("checked");
4432 }, function(){
4433 $('#dio_comparison_button').removeClass("checked");
4434 });
4435 */
4436 $('#dio_comparison_button').on('click', function () {
4437 if (!Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON)) {
4438 UnitComparison.openWindow();
4439 $('#dio_comparison_button').addClass("checked");
4440 } else {
4441 UnitComparison.closeWindow();
4442 $('#dio_comparison_button').removeClass("checked");
4443 }
4444 });
4445
4446 // Tooltip
4447 $('#dio_comparison_button').tooltip(getText("labels", "dsc"));
4448 },
4449 openWindow: function () {
4450 var content =
4451 // Title tabs
4452 '<ul id="dio_comparison_menu" class="menu_inner" style="top: -36px; right: 35px;">' +
4453 '<li><a class="submenu_link sea" href="#"><span class="left"><span class="right"><span class="middle">' +
4454 '<span class="tab_icon icon_small townicon_so"></span><span class="tab_label">' + getText("labels", "sea") + '</span>' +
4455 '</span></span></span></a></li>' +
4456 '<li><a class="submenu_link distance" href="#"><span class="left"><span class="right"><span class="middle">' +
4457 '<span class="tab_icon icon_small townicon_di"></span><span class="tab_label">' + getText("labels", "dst") + '</span>' +
4458 '</span></span></span></a></li>' +
4459 '<li><a class="submenu_link pierce" href="#"><span class="left"><span class="right"><span class="middle">' +
4460 '<span class="tab_icon icon_small townicon_sh"></span><span class="tab_label">' + getText("labels", "prc") + '</span>' +
4461 '</span></span></span></a></li>' +
4462 '<li><a class="submenu_link hack active" href="#"><span class="left"><span class="right"><span class="middle">' +
4463 '<span class="tab_icon icon_small townicon_lo"></span><span class="tab_label">' + getText("labels", "hck") + '</span>' +
4464 '</span></span></span></a></li>' +
4465 '</ul>' +
4466 // Content
4467 '<div id="dio_comparison" style="margin-bottom:5px; font-style:italic;"><div class="box_content hack"></div></div>';
4468
4469 Layout.wnd.Create(GPWindowMgr.TYPE_DIO_COMPARISON).setContent(content);
4470
4471 UnitComparison.addComparisonTable("hack");
4472 UnitComparison.addComparisonTable("pierce");
4473 UnitComparison.addComparisonTable("distance");
4474 UnitComparison.addComparisonTable("sea");
4475
4476 // Tooltips
4477 var labelArray = DM.getl10n("barracks"),
4478 labelAttack = DM.getl10n("context_menu", "titles").attack,
4479 labelDefense = DM.getl10n("place", "tabs")[0];
4480
4481 $('.tr_att').tooltip(labelAttack);
4482 $('.tr_def').tooltip(labelDefense + " (Ø)");
4483 $('.tr_def_sea').tooltip(labelDefense);
4484 $('.tr_spd').tooltip(labelArray.tooltips.speed);
4485 $('.tr_bty').tooltip(labelArray.tooltips.booty.title);
4486 $('.tr_bty_sea').tooltip(labelArray.tooltips.ship_transport.title);
4487 $('.tr_res').tooltip(labelArray.costs + " (" +
4488 labelArray.cost_details.wood + " + " +
4489 labelArray.cost_details.stone + " + " +
4490 labelArray.cost_details.iron + ")"
4491 );
4492 $('.tr_fav').tooltip(labelArray.costs + " (" + labelArray.cost_details.favor + ")");
4493 $('.tr_tim').tooltip(labelArray.cost_details.buildtime_barracks + " (s)");
4494 $('.tr_tim_sea').tooltip(labelArray.cost_details.buildtime_docks + " (s)");
4495
4496 UnitComparison.switchComparisonTables();
4497
4498 // Close button event - uncheck available units button
4499 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON).getJQCloseButton().get(0).onclick = function () {
4500 $('#dio_comparison_button').removeClass("checked");
4501 $('.ico_comparison').get(0).style.marginTop = "5px";
4502 };
4503 },
4504 closeWindow: function () {
4505 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON).close();
4506 },
4507 switchComparisonTables: function () {
4508 $('#dio_comparison_menu .hack, #dio_comparison_menu .pierce, #dio_comparison_menu .distance, #dio_comparison_menu .sea').click(function () {
4509 $('#dio_comparison .box_content').removeClass($('#dio_comparison .box_content').get(0).className.split(" ")[1]);
4510 //console.debug(this.className.split(" ")[1]);
4511 $('#dio_comparison .box_content').addClass(this.className.split(" ")[1]);
4512
4513 $('#dio_comparison_menu .active').removeClass("active");
4514 $(this).addClass("active");
4515 });
4516 },
4517
4518 tooltips: [], t: 0,
4519
4520 addComparisonTable: function (type) {
4521 var pos = {
4522 att: {hack: "36%", pierce: "27%", distance: "45.5%", sea: "72.5%"},
4523 def: {hack: "18%", pierce: "18%", distance: "18%", sea: "81.5%"}
4524 };
4525 var unitIMG = "https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png";
4526 var strArray = [
4527 "<td></td>",
4528 '<td><div class="compare_type_icon" style="background-position: 0% ' + pos.att[type] + ';"></div></td>',
4529 '<td><div class="compare_type_icon" style="background-position: 0% ' + pos.def[type] + ';"></div></td>',
4530 '<td><div class="compare_type_icon" style="background-position: 0% 63%;"></div></td>',
4531 (type !== "sea") ? '<td><div class="compare_type_icon booty"></div></td>' : '<td><div class="compare_type_icon" style="background-position: 0% 91%;"></div></td>',
4532 '<td><div class="compare_type_icon" style="background-position: 0% 54%;"></div></td>',
4533 '<td><div class="compare_type_icon favor"></div></td>',
4534 '<td><div class="compare_type_icon time"></div></td>'
4535 ];
4536
4537 for (var e in uw.GameData.units) {
4538 if (uw.GameData.units.hasOwnProperty(e)) {
4539 var valArray = [];
4540
4541 if (type === (uw.GameData.units[e].attack_type || "sea") && (e !== "militia")) {
4542 valArray.att = Math.round(uw.GameData.units[e].attack * 10 / uw.GameData.units[e].population) / 10;
4543 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;
4544 valArray.def = valArray.def || Math.round(uw.GameData.units[e].defense * 10 / uw.GameData.units[e].population) / 10;
4545 valArray.speed = uw.GameData.units[e].speed;
4546 valArray.booty = Math.round(((uw.GameData.units[e].booty) * 10) / uw.GameData.units[e].population) / 10;
4547 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;
4548 valArray.favor = Math.round((uw.GameData.units[e].favor * 10) / uw.GameData.units[e].population) / 10;
4549 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));
4550 valArray.time = Math.round(uw.GameData.units[e].build_time / uw.GameData.units[e].population);
4551
4552 // World without Artemis? -> grey griffin and boar
4553 valArray.heroStyle = "";
4554 valArray.heroStyleIMG = "";
4555
4556 if (!uw.Game.hasArtemis && ((e === "griffin") || (e === "calydonian_boar"))) {
4557 valArray.heroStyle = "color:black;opacity: 0.4;";
4558 valArray.heroStyleIMG = "filter: url(#GrayScale); -webkit-filter:grayscale(100%);";
4559 }
4560
4561 strArray[0] += '<td class="un' + (UnitComparison.t) + '"><span class="unit index_unit unit_icon40x40 ' + e + '" style="' + valArray.heroStyle + valArray.heroStyleIMG + '"></span></td>';
4562 strArray[1] += '<td class="bold" style="color:' + ((valArray.att > 19) ? 'green;' : ((valArray.att < 10 && valArray.att !== 0 ) ? 'red;' : 'black;')) + valArray.heroStyle + '">' + valArray.att + '</td>';
4563 strArray[2] += '<td class="bold" style="color:' + ((valArray.def > 19) ? 'green;' : ((valArray.def < 10 && valArray.def !== 0 ) ? 'red;' : 'black;')) + valArray.heroStyle + '">' + valArray.def + '</td>';
4564 strArray[3] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.speed + '</td>';
4565 strArray[4] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.booty + '</td>';
4566 strArray[5] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.res + '</td>';
4567 strArray[6] += '<td class="bold" style="color:' + ((valArray.favor > 0) ? 'rgb(0, 0, 214);' : 'black;') + valArray.heroStyle + ';">' + valArray.favor + '</td>';
4568 strArray[7] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.time + '</td>';
4569
4570 UnitComparison.tooltips[UnitComparison.t] = uw.GameData.units[e].name;
4571 UnitComparison.t++;
4572 }
4573 }
4574 }
4575
4576 $('<table class="hidden t_' + type + '" cellpadding="1px">' +
4577 '<tr>' + strArray[0] + '</tr>' +
4578 '<tr class="tr_att">' + strArray[1] + '</tr><tr class="tr_def' + (type == "sea" ? "_sea" : "") + '">' + strArray[2] + '</tr>' +
4579 '<tr class="tr_spd">' + strArray[3] + '</tr><tr class="tr_bty' + (type == "sea" ? "_sea" : "") + '">' + strArray[4] + '</tr>' +
4580 '<tr class="tr_res">' + strArray[5] + '</tr><tr class="tr_fav">' + strArray[6] + '</tr><tr class="tr_tim' + (type == "sea" ? "_sea" : "") + '">' + strArray[7] + '</tr>' +
4581 '</table>').appendTo('#dio_comparison .box_content');
4582
4583 for (var i = 0; i <= UnitComparison.t; i++) {
4584 $('.un' + i).tooltip(UnitComparison.tooltips[i]);
4585 }
4586 }
4587 };
4588
4589 /*******************************************************************************************************************************
4590 * Reports and Messages
4591 * ----------------------------------------------------------------------------------------------------------------------------
4592 * | â— Storage of the selected filter (only in German Grepolis yet)
4593 * ----------------------------------------------------------------------------------------------------------------------------
4594 *******************************************************************************************************************************/
4595
4596 var filter = "all";
4597
4598 function saveFilter() {
4599 $('#dd_filter_type_list .item-list div').each(function () {
4600 $(this).click(function () {
4601 filter = $(this).attr("name");
4602 });
4603 });
4604 /*
4605 var i = 0;
4606 $("#report_list a").each(function () {
4607 //console.log((i++) +" = " + $(this).attr('data-reportid'));
4608 });
4609 */
4610 }
4611
4612 function loadFilter() {
4613 if ($('#dd_filter_type_list .selected').attr("name") !== filter) {
4614 $('#dd_filter_type .caption').click();
4615 $('#dd_filter_type_list .item-list div[name=' + filter + ']').click();
4616 }
4617 }
4618
4619 function removeReports() {
4620 $("#report_list li:contains('spioniert')").each(function () {
4621 //$(this).remove();
4622 });
4623 }
4624
4625 var zut = 0;
4626 var messageArray = {};
4627
4628 function filterPlayer() {
4629 if (!$('#message_filter_list').get(0)) {
4630 $('<div id="message_filter_list" style="height:300px;overflow-y:scroll; width: 790px;"></div>').appendTo('#folder_container');
4631 $("#message_list").get(0).style.display = "none";
4632 }
4633 if (zut < parseInt($('.es_last_page').get(0).value, 10) - 1) {
4634 $('.es_page_input').get(0).value = zut++;
4635 $('.jump_button').click();
4636 $("#message_list li:contains('')").each(function () {
4637 $(this).appendTo('#message_filter_list');
4638 });
4639 } else {
4640 zut = 1;
4641 }
4642 }
4643
4644
4645 /*******************************************************************************************************************************
4646 * World Wonder Ranking - Change
4647 *******************************************************************************************************************************/
4648
4649 function getWorldWonderTypes() {
4650 $.ajax({
4651 type: "GET",
4652 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 +
4653 "%7D&_=" + uw.Game.server_time,
4654 success: function (text) {
4655 try {
4656 //console.log(JSON.parse(text));
4657 temp = JSON.parse(text).json.data.world_wonders;
4658 for (var t in temp) {
4659 if (temp.hasOwnProperty(t)) {
4660 wonderTypes[temp[t].wonder_type] = temp[t].full_name;
4661 }
4662 }
4663 temp = JSON.parse(text).json.data.buildable_wonders;
4664 for (var x in temp) {
4665 if (temp.hasOwnProperty(x)) {
4666 wonderTypes[x] = temp[x].name;
4667 }
4668 }
4669 saveValue(MID + "_wonderTypes", JSON.stringify(wonderTypes));
4670 } catch (error) {
4671 errorHandling(error, "getWorldWonderTypes");
4672 }
4673 }
4674 });
4675 }
4676
4677 function getWorldWonders() {
4678 $.ajax({
4679 type: "GET",
4680 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 +
4681 "%7D&_=" + uw.Game.server_time
4682 });
4683 }
4684
4685 var WorldWonderRanking = {
4686 activate: function () {
4687 if ($('#dio_wonder_ranking').get(0)) {
4688 $('#dio_wonder_ranking').remove();
4689 }
4690 $('<style id="dio_wonder_ranking" type="text/css"> .wonder_ranking { display: none; } </style>').appendTo('head');
4691 },
4692 deactivate: function () {
4693 if ($('#dio_wonder_ranking').get(0)) {
4694 $('#dio_wonder_ranking').remove();
4695 }
4696 $('<style id="dio_wonder_ranking" type="text/css"> .wonder_ranking { display: block; } </style>').appendTo('head');
4697 },
4698 change: function (html) {
4699 if ($('#ranking_inner tr', html)[0].children.length !== 1) { // world wonders exist?
4700 try {
4701 var ranking = {}, temp_ally, temp_ally_id, temp_ally_link;
4702
4703 // Save world wonder ranking into array
4704 $('#ranking_inner tr', html).each(function () {
4705 try {
4706 if (this.children[0].innerHTML) {
4707 temp_ally = this.children[1].children[0].innerHTML; // das hier
4708
4709 temp_ally_id = this.children[1].children[0].onclick.toString();
4710 temp_ally_id = temp_ally_id.substring(temp_ally_id.indexOf(",") + 1);
4711 temp_ally_id = temp_ally_id.substring(0, temp_ally_id.indexOf(")"));
4712
4713 temp_ally_link = this.children[1].innerHTML;
4714
4715 } else {
4716 //World wonder name
4717 var wonder_name = this.children[3].children[0].innerHTML;
4718
4719 for (var w in wonderTypes) {
4720 if (wonderTypes.hasOwnProperty(w)) {
4721 if (wonder_name == wonderTypes[w]) {
4722 var level = this.children[4].innerHTML, // world wonder level
4723 ww_data = JSON.parse(atob(this.children[3].children[0].href.split("#")[1])), wonder_link;
4724 //console.log(ww_data);
4725
4726 if (!ranking.hasOwnProperty(level)) {
4727 // add wonder types
4728 ranking[level] = {
4729 colossus_of_rhodes: {},
4730 great_pyramid_of_giza: {},
4731 hanging_gardens_of_babylon: {},
4732 lighthouse_of_alexandria: {},
4733 mausoleum_of_halicarnassus: {},
4734 statue_of_zeus_at_olympia: {},
4735 temple_of_artemis_at_ephesus: {}
4736 };
4737 }
4738
4739 if (!ranking[level][w].hasOwnProperty(temp_ally_id)) {
4740 ranking[level][w][temp_ally_id] = {}; // add alliance array
4741 }
4742 // island coordinates of the world wonder:
4743 ranking[level][w][temp_ally_id].ix = ww_data.ix;
4744 ranking[level][w][temp_ally_id].iy = ww_data.iy;
4745 ranking[level][w][temp_ally_id].sea = this.children[5].innerHTML; // world wonder sea
4746
4747 wonder_link = this.children[3].innerHTML;
4748 if (temp_ally.length > 15) {
4749 temp_ally = temp_ally.substring(0, 15) + '.';
4750 }
4751 wonder_link = wonder_link.substr(0, wonder_link.indexOf(">") + 1) + temp_ally + '</a>';
4752
4753 ranking[level][w][temp_ally_id].ww_link = wonder_link;
4754
4755 // other data of the world wonder
4756 ranking[level][w][temp_ally_id].ally_link = temp_ally_link;
4757 ranking[level][w][temp_ally_id].ally_name = temp_ally; // alliance name
4758 ranking[level][w][temp_ally_id].name = wonder_name; // world wonder name
4759
4760 // Save wonder coordinates for wonder icons on map
4761 if (!wonder.map[w]) {
4762 wonder.map[w] = {};
4763 }
4764 wonder.map[w][ww_data.ix + "_" + ww_data.iy] = level;
4765 saveValue(WID + "_wonder", JSON.stringify(wonder));
4766
4767 }
4768 }
4769 }
4770 }
4771 } catch (error) {
4772 errorHandling(error, "WorldWonderRanking.change(function)");
4773 }
4774 });
4775
4776 if ($('#ranking_table_wrapper').get(0)) {
4777 $('#ranking_fixed_table_header').get(0).innerHTML = '<tr>' +
4778 '<td style="width:10px">#</td>' +
4779 '<td>Colossus</td>' +
4780 '<td>Pyramid</td>' +
4781 '<td>Garden</td>' +
4782 '<td>Lighthouse</td>' +
4783 '<td>Mausoleum</td>' +
4784 '<td>Statue</td>' +
4785 '<td>Temple</td>' +
4786 '</tr>';
4787
4788 $('#ranking_fixed_table_header').css({
4789 tableLayout: 'fixed',
4790 width: '100%',
4791 //paddingLeft: '0px',
4792 paddingRight: '15px'
4793 });
4794
4795 var ranking_substr = '', z = 0;
4796 for (var level = 10; level >= 1; level--) {
4797 if (ranking.hasOwnProperty(level)) {
4798 var complete = "";
4799 if (level == 10) {
4800 complete = "background: rgba(255, 236, 108, 0.36);";
4801 }
4802
4803 // Alternate table background color
4804 if (z === 0) {
4805 ranking_substr += '<tr class="game_table_odd" style="' + complete + '"><td style="border-right: 1px solid #d0be97;">' + level + '</td>';
4806 z = 1;
4807 } else {
4808 ranking_substr += '<tr class="game_table_even" style="' + complete + '"><td style="border-right: 1px solid #d0be97;">' + level + '</td>';
4809 z = 0;
4810 }
4811 for (var w in ranking[level]) {
4812 if (ranking[level].hasOwnProperty(w)) {
4813 ranking_substr += '<td>';
4814
4815 for (var a in ranking[level][w]) {
4816 if (ranking[level][w].hasOwnProperty(a)) {
4817 ranking_substr += '<nobr>' + ranking[level][w][a].ww_link + '</nobr><br />'; // ww link
4818 }
4819 }
4820 ranking_substr += '</td>';
4821 }
4822 }
4823 ranking_substr += '</tr>';
4824 }
4825 }
4826
4827 var ranking_str = '<table id="ranking_endless_scroll" class="game_table" cellspacing="0"><tr>' +
4828 '<td style="width:10px;border-right: 1px solid #d0be97;"></td>' +
4829 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.colossus_of_rhodes + ';margin-left:26px"></div></td>' + // Colossus
4830 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.great_pyramid_of_giza + ';margin-left:19px"></div></td>' + // Pyramid
4831 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.hanging_gardens_of_babylon + ';margin-left:19px"></div></td>' + // Garden
4832 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.lighthouse_of_alexandria + ';margin-left:24px"></div></td>' + // Lighthouse
4833 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.mausoleum_of_halicarnassus + ';margin-left:25px"></div></td>' + // Mausoleum
4834 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.statue_of_zeus_at_olympia + ';margin-left:25px"></div></td>' + // Statue
4835 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.temple_of_artemis_at_ephesus + ';margin-left:22px"></div></td>' + // Temple
4836 '</tr>' + ranking_substr + '</table>';
4837
4838 $('#ranking_table_wrapper').get(0).innerHTML = ranking_str;
4839
4840 $('#ranking_endless_scroll .dio_wonder').css({
4841 width: "65px", height: "60px",
4842 backgroundSize: "auto 100%",
4843 backgroundPosition: "64px 0px"
4844 });
4845
4846 $('#ranking_endless_scroll').css({
4847 tableLayout: 'fixed',
4848 width: '100%',
4849 overflowY: 'auto',
4850 overflowX: 'hidden',
4851 fontSize: '0.7em',
4852 lineHeight: '2'
4853 });
4854 $('#ranking_endless_scroll tbody').css({
4855 verticalAlign: 'text-top'
4856 });
4857
4858 $('#ranking_table_wrapper img').css({
4859 width: "60px"
4860 });
4861 $('#ranking_table_wrapper').css({
4862 overflowY: 'scroll'
4863 });
4864 }
4865 } catch (error) {
4866 errorHandling(error, "WorldWonderRanking.change");
4867 }
4868 }
4869 if ($('.wonder_ranking').get(0)) {
4870 $('.wonder_ranking').get(0).style.display = "block";
4871 }
4872 }
4873 };
4874
4875 /*******************************************************************************************************************************
4876 * World Wonder
4877 * ----------------------------------------------------------------------------------------------------------------------------
4878 * | â— click adjustment
4879 * | â— Share calculation (= ratio of player points to alliance points)
4880 * | â— Resources calculation & counter (stores amount)
4881 * | â— Adds missing previous & next buttons on finished world wonders (better browsing through world wonders)
4882 * ----------------------------------------------------------------------------------------------------------------------------
4883 *******************************************************************************************************************************/
4884
4885 // getPointRatio: Default
4886 function getPointRatioFromAllianceProfile() {
4887 if (AID) {
4888 $.ajax({
4889 type: "GET",
4890 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 +
4891 '%2C%22nlreq_id%22%3A' + uw.Game.notification_last_requested_id + '%7D&_=' + uw.Game.server_time,
4892 success: function (text) {
4893 try {
4894 text = text.substr(text.indexOf("/li") + 14).substr(0, text.indexOf("\ "));
4895 var AP = parseInt(text, 10);
4896 wonder.ratio[AID] = 100 / AP * uw.Game.player_points;
4897 saveValue(WID + "_wonder", JSON.stringify(wonder));
4898 } catch (error) {
4899 errorHandling(error, "getPointRatioFromAllianceProfile");
4900 }
4901 }
4902 });
4903 } else {
4904 wonder.ratio[AID] = -1;
4905 saveValue(WID + "_wonder", JSON.stringify(wonder));
4906 }
4907 }
4908
4909 function getPointRatioFromAllianceRanking() {
4910 try {
4911 if (AID && $('.current_player .r_points').get(0)) {
4912 wonder.ratio[AID] = 100 / parseInt($('.current_player .r_points').get(0).innerHTML, 10) * uw.Game.player_points;
4913 saveValue(WID + "_wonder", JSON.stringify(wonder));
4914 }
4915 } catch (error) {
4916 errorHandling(error, "getPointRatioFromAllianceRaking");
4917 }
4918 }
4919
4920 function getPointRatioFromAllianceMembers() {
4921 try {
4922 var ally_points = 0;
4923 $('#ally_members_body tr').each(function () {
4924 ally_points += parseInt($(this).children().eq(2).text(), 10) || 0;
4925 });
4926 wonder.ratio[AID] = 100 / ally_points * uw.Game.player_points;
4927 saveValue(WID + "_wonder", JSON.stringify(wonder));
4928 } catch (error) {
4929 errorHandling(error, "getPointRatioFromAllianceMembers");
4930 }
4931 }
4932
4933 var WorldWonderCalculator = {
4934 activate: function () {
4935 // Style
4936 $('<style id="dio_wonder_calculator"> ' +
4937 '.wonder_controls { height:380px; } ' +
4938 '.wonder_controls .wonder_progress { margin: 0px auto 5px; } ' +
4939 '.wonder_controls .wonder_header { text-align:left; margin:10px -8px 12px 3px; }' +
4940 '.wonder_controls .build_wonder_icon { top:25px !important; }' +
4941 '.wonder_controls .wonder_progress_bar { top:54px; }' +
4942 '.wonder_controls .trade fieldset { float:right; } ' +
4943 '.wonder_controls .wonder_res_container { right:29px; } ' +
4944 '.wonder_controls .ww_ratio {position:relative; height:auto; } ' +
4945 '.wonder_controls fieldset.next_level_res { height:auto; } ' +
4946 '.wonder_controls .town-capacity-indicator { margin-top:0px; } ' +
4947
4948 '.wonder_controls .ww_ratio .progress { line-height:1; color:white; font-size:0.8em; } ' +
4949 '.wonder_controls .ww_perc { position:absolute; width:242px; text-align:center; } ' +
4950 '.wonder_controls .indicator3 { z-index:0; } ' +
4951 '.wonder_controls .indicator3.red { background-position:right -203px; height:10px; width:242px; } ' +
4952 '.wonder_controls .indicator3.green { background-position:right -355px; height:10px; width:242px; } ' +
4953 '.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; } ' +
4954 '.wonder_controls .town-capacity-indicator { margin-top:0px; } ' +
4955 '</style>').appendTo('head');
4956 },
4957 deactivate: function () {
4958 $('#dio_wonder_calculator').remove();
4959 }
4960 };
4961
4962 // TODO: Split function...
4963 function getResWW() {
4964 try {
4965 var wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_WONDERS);
4966
4967 for (var e in wndArray) {
4968 if (wndArray.hasOwnProperty(e)) {
4969 var wndID = "#gpwnd_" + wndArray[e].getID() + " ";
4970
4971 if ($(wndID + '.wonder_progress').get(0)) {
4972 var res = 0,
4973 ww_share = {total: {share: 0, sum: 0}, stage: {share: 0, sum: 0}},
4974 ww_type = $(wndID + '.finished_image_small').attr('src').split("/")[6].split("_")[0], // Which world wonder?
4975 res_stages = [2, 4, 6, 10, 16, 28, 48, 82, 140, 238], // Rohstoffmenge pro Rohstofftyp in 100.000 Einheiten
4976 stage = parseInt($(wndID + '.wonder_expansion_stage span').get(0).innerHTML.split("/")[0], 10) + 1, // Derzeitige Füllstufe
4977 speed = uw.Game.game_speed;
4978
4979 wonder.storage[AID] = wonder.storage[AID] || {};
4980
4981 wonder.storage[AID][ww_type] = wonder.storage[AID][ww_type] || {};
4982
4983 wonder.storage[AID][ww_type][stage] = wonder.storage[AID][ww_type][stage] || 0;
4984
4985 if (!$(wndID + '.ww_ratio').get(0)) {
4986 $('<fieldset class="ww_ratio"></fieldset>').appendTo(wndID + '.wonder_res_container .trade');
4987 $(wndID + '.wonder_header').prependTo(wndID + '.wonder_progress');
4988 $(wndID + '.wonder_res_container .send_res').insertBefore(wndID + '.wonder_res_container .next_level_res');
4989 }
4990
4991 for (var d in res_stages) {
4992 if (res_stages.hasOwnProperty(d)) {
4993 ww_share.total.sum += res_stages[d];
4994 }
4995 }
4996
4997 ww_share.total.sum *= speed * 300000;
4998
4999 ww_share.total.share = parseInt(wonder.ratio[AID] * (ww_share.total.sum / 100), 10);
5000
5001 ww_share.stage.sum = speed * res_stages[stage - 1] * 300000;
5002
5003 ww_share.stage.share = parseInt(wonder.ratio[AID] * (ww_share.stage.sum / 100), 10); // ( 3000 = 3 Rohstofftypen * 100000 Rohstoffe / 100 Prozent)
5004 setResWW(stage, ww_type, ww_share, wndID);
5005
5006
5007 $(wndID + '.wonder_res_container .send_resources_btn').click(function (e) {
5008 try {
5009 wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_wood input:text').get(0).value, 10);
5010 wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_stone input:text').get(0).value, 10);
5011 wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_iron input:text').get(0).value, 10);
5012
5013 setResWW(stage, ww_type, ww_share, wndID);
5014 saveValue(WID + "_wonder", JSON.stringify(wonder));
5015 } catch (error) {
5016 errorHandling(error, "getResWW_Click");
5017 }
5018 });
5019
5020 } else {
5021 $('<div class="prev_ww pos_Y"></div><div class="next_ww pos_Y"></div>').appendTo(wndID + '.wonder_controls');
5022
5023 $(wndID + '.wonder_finished').css({width: '100%'});
5024
5025 $(wndID + '.pos_Y').css({
5026 top: '-266px'
5027 });
5028 }
5029 }
5030 }
5031 } catch (error) {
5032 errorHandling(error, "getResWW");
5033 }
5034 }
5035
5036 function setResWW(stage, ww_type, ww_share, wndID) {
5037 try {
5038 var stage_width, total_width, res_total = 0, stage_color = "red", total_color = "red";
5039
5040 for (var z in wonder.storage[AID][ww_type]) {
5041 if (wonder.storage[AID][ww_type].hasOwnProperty(z)) {
5042 res_total += wonder.storage[AID][ww_type][z];
5043 }
5044 }
5045
5046 // Progressbar
5047 if (ww_share.stage.share > wonder.storage[AID][ww_type][stage]) {
5048 stage_width = (242 / ww_share.stage.share) * wonder.storage[AID][ww_type][stage];
5049 stage_color = "red";
5050 } else {
5051 stage_width = 242;
5052 stage_color = "green"
5053 }
5054 if (ww_share.total.share > res_total) {
5055 total_color = "red";
5056 total_width = (242 / ww_share.total.share) * res_total;
5057 } else {
5058 total_width = 242;
5059 total_color = "green"
5060 }
5061
5062 $(wndID + '.ww_ratio').get(0).innerHTML = "";
5063 $(wndID + '.ww_ratio').append(
5064 '<legend>' + getText("labels", "leg") + ' (<span style="color:#090">' + (Math.round(wonder.ratio[AID] * 100) / 100) + '%</span>):</legend>' +
5065 '<div class="town-capacity-indicator">' +
5066 '<div class="icon all_res"></div>' +
5067 '<div id="ww_town_capacity_stadium" class="tripple-progress-progressbar">' +
5068 '<div class="border_l"></div><div class="border_r"></div><div class="body"></div>' +
5069 '<div class="progress overloaded">' +
5070 '<div class="indicator3 ' + stage_color + '" style="width:' + stage_width + 'px"></div>' +
5071 '<span class="ww_perc">' + Math.round(wonder.storage[AID][ww_type][stage] / ww_share.stage.share * 100) + '%</span>' +
5072 '</div>' +
5073 '<div class="amounts">' + getText("labels", "stg") + ': <span class="curr">' + pointNumber(wonder.storage[AID][ww_type][stage]) + '</span> / ' +
5074 '<span class="max">' + pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) + '</span></div>' +
5075 '</div></div>' +
5076 '<div class="town-capacity-indicator">' +
5077 '<div class="icon all_res"></div>' +
5078 '<div id="ww_town_capacity_total" class="tripple-progress-progressbar">' +
5079 '<div class="border_l"></div><div class="border_r"></div><div class="body"></div>' +
5080 '<div class="progress overloaded">' +
5081 '<div class="indicator3 ' + total_color + '" style="width:' + total_width + 'px;"></div>' +
5082 '<span class="ww_perc">' + Math.round(res_total / ww_share.total.share * 100) + '%</span>' +
5083 '</div>' +
5084 '<div class="amounts">' + getText("labels", "tot") + ': <span class="curr">' + pointNumber(res_total) + '</span> / ' +
5085 '<span class="max">' + pointNumber((Math.round(ww_share.total.share / 1000) * 1000)) + '</span></div>' +
5086 '</div></div>');
5087
5088 $(wndID + '.ww_ratio').tooltip(
5089 "<table style='border-spacing:0px; text-align:right' cellpadding='5px'><tr>" +
5090 "<td align='right' style='border-right: 1px solid;border-bottom: 1px solid'></td>" +
5091 "<td style='border-right: 1px solid; border-bottom: 1px solid'><span class='bbcodes_player bold'>(" + (Math.round((wonder.ratio[AID]) * 100) / 100) + "%)</span></td>" +
5092 "<td style='border-bottom: 1px solid'><span class='bbcodes_ally bold'>(100%)</span></td></tr>" +
5093 "<tr><td class='bold' style='border-right:1px solid;text-align:center'>" + getText("labels", "stg") + " " + stage + "</td>" +
5094 "<td style='border-right: 1px solid'>" + pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) + "</td>" +
5095 "<td>" + pointNumber(Math.round(ww_share.stage.sum / 1000) * 1000) + "</td></tr>" +
5096 "<tr><td class='bold' style='border-right:1px solid;text-align:center'>" + getText("labels", "tot") + "</td>" +
5097 "<td style='border-right: 1px solid'>" + pointNumber(Math.round(ww_share.total.share / 1000) * 1000) + "</td>" +
5098 "<td>" + pointNumber(Math.round(ww_share.total.sum / 1000) * 1000) + "</td>" +
5099 "</tr></table>");
5100
5101 } catch (error) {
5102 errorHandling(error, "setResWW");
5103 }
5104 }
5105
5106 // Adds points to numbers
5107 function pointNumber(number) {
5108 var sep;
5109 if (LID === "de") {
5110 sep = ".";
5111 } else {
5112 sep = ",";
5113 }
5114
5115 number = number.toString();
5116 if (number.length > 3) {
5117 var mod = number.length % 3;
5118 var output = (mod > 0 ? (number.substring(0, mod)) : '');
5119
5120 for (var i = 0; i < Math.floor(number.length / 3); i++) {
5121 if ((mod == 0) && (i == 0)) {
5122 output += number.substring(mod + 3 * i, mod + 3 * i + 3);
5123 } else {
5124 output += sep + number.substring(mod + 3 * i, mod + 3 * i + 3);
5125 }
5126 }
5127 number = output;
5128 }
5129 return number;
5130 }
5131
5132 /*******************************************************************************************************************************
5133 * Farming Village Overview
5134 * ----------------------------------------------------------------------------------------------------------------------------
5135 * | â— Color change on possibility of city festivals
5136 * ----------------------------------------------------------------------------------------------------------------------------
5137 * *****************************************************************************************************************************/
5138
5139 function changeResColor() {
5140 var res, res_min, i = 0;
5141 $('#fto_town_list .fto_resource_count :last-child').reverseList().each(function () {
5142 if ($(this).parent().hasClass("stone")) {
5143 res_min = 18000;
5144 } else {
5145 res_min = 15000;
5146 }
5147 res = parseInt(this.innerHTML, 10);
5148 if ((res >= res_min) && !($(this).hasClass("town_storage_full"))) {
5149 this.style.color = '#0A0';
5150 }
5151 if (res < res_min) {
5152 this.style.color = '#000';
5153 }
5154 });
5155 }
5156
5157 /********************************************************************************************************************************
5158 * Conquest Info
5159 * -----------------------------------------------------------------------------------------------------------------------------
5160 * | â— Amount of supports und attacks in the conquest window
5161 * | â— Layout adjustment (for reasons of clarity)
5162 * | - TODO: conquest window of own cities
5163 * -----------------------------------------------------------------------------------------------------------------------------
5164 * ******************************************************************************************************************************/
5165
5166 function countMovements() {
5167 var sup = 0, att = 0;
5168 $('.tab_content #unit_movements .support').each(function () {
5169 sup++;
5170 });
5171 $('.tab_content #unit_movements .attack_land, .tab_content #unit_movements .attack_sea, .tab_content #unit_movements .attack_takeover').each(function () {
5172 att++;
5173 });
5174
5175 var str = "<div id='move_counter' style=''><div style='float:left;margin-right:5px;'></div>" +
5176 "<div class='movement def'></div>" +
5177 "<div class='movement' style='color:green;'> " + sup + "</div>" +
5178 "<div class='movement off'> </div>" +
5179 "<div style='color:red;'> " + att + "</div></div>" +
5180 "<hr class='move_hr'>";
5181
5182 if ($('.gpwindow_content .tab_content .bold').get(0)) {
5183 $('.gpwindow_content .tab_content .bold').append(str);
5184 } else {
5185 $('.gpwindow_content h4:eq(1)').append(str);
5186
5187 // TODO: set player link ?
5188 /*
5189 $('#unit_movements li div').each(function(){
5190
5191 //console.log(this.innerHTML);
5192 });
5193 */
5194 }
5195
5196 $('<style id="dio_conquest"> ' +
5197 '.move_hr { margin:7px 0px 0px 0px; background-color:#5F5242; height:2px; border:0px solid; } ' +
5198 // Smaller movements
5199 '#unit_movements { font-size: 0.80em; } ' +
5200 '#unit_movements .incoming { width:150px; height:45px; float:left; } ' +
5201 // Counter
5202 '#move_counter { position:relative; width:100px; margin-top:-16px; left: 40%; } ' +
5203 '#move_counter .movement { float:left; margin:0px 5px 0px 0px; height:18px; width:18px; position:relative; } ' +
5204 '#move_counter .def { background:url(https://gpall.innogamescdn.com/images/game/place/losts.png); background-position:0 -36px; } ' +
5205 '#move_counter .off { background:url(https://gpall.innogamescdn.com/images/game/place/losts.png); background-position:0 0px; }' +
5206 '</style>').appendTo("head");
5207
5208 /*
5209 $('#unit_movements div').each(function(){
5210 if($(this).attr('class') === "unit_movements_arrow"){
5211 // delete placeholder for arrow of outgoing movements (there are no outgoing movements)
5212 if(!this.style.background) { this.remove(); }
5213 } else {
5214 // realign texts
5215 $(this).css({
5216 margin: '3px',
5217 paddingLeft: '3px'
5218 });
5219 }
5220 });
5221 */
5222 }
5223
5224 /*******************************************************************************************************************************
5225 * Town window
5226 * ----------------------------------------------------------------------------------------------------------------------------
5227 * | â— TownTabHandler (trade, attack, support,...)
5228 * | â— Sent units box
5229 * | â— Short duration: Display of 30% troop speed improvement in attack/support tab
5230 * | â— Trade options:
5231 * | - Ressource marks on possibility of city festivals
5232 * | - Percentual Trade: Trade button
5233 * | - Recruiting Trade: Selection boxes (ressource ratio of unit type + share of the warehouse capacity of the target town)
5234 * ----------------------------------------------------------------------------------------------------------------------------
5235 *******************************************************************************************************************************/
5236 var arrival_interval = {};
5237 // TODO: Change both functions in MultipleWindowHandler()
5238 function TownTabHandler(action) {
5239 var wndArray, wndID, wndA;
5240 wndArray = Layout.wnd.getOpen(uw.Layout.wnd.TYPE_TOWN);
5241 //console.log(wndArray);
5242 for (var e in wndArray) {
5243 if (wndArray.hasOwnProperty(e)) {
5244 //console.log(wndArray[e].getHandler());
5245 wndA = wndArray[e].getAction();
5246 wndID = "#gpwnd_" + wndArray[e].getID() + " ";
5247 if (!$(wndID).get(0)) {
5248 wndID = "#gpwnd_" + (wndArray[e].getID() + 1) + " ";
5249 }
5250 //console.log(wndID);
5251 if (wndA === action) {
5252 switch (action) {
5253 case "trading":
5254 if ($(wndID + '#trade_tab').get(0)) {
5255 if (!$(wndID + '.rec_trade').get(0) && DATA.options.rec) {
5256 RecruitingTrade.add(wndID);
5257 }
5258 //console.log(DATA.options.per);
5259 if (!$(wndID + '.btn_trade').get(0) && DATA.options.per) {
5260 addPercentTrade(wndID, false);
5261 }
5262 }
5263 //addTradeMarks(wndID, 15, 18, 15, "red"); // town festival
5264 break;
5265 case "support":
5266 case "attack":
5267 //if(!arrival_interval[wndID]){
5268 if (DATA.options.way && !($('.js-casted-powers-viewport .unit_movement_boost').get(0) || $(wndID + '.short_duration').get(0))) {
5269 //if(arrival_interval[wndID]) console.log("add " + wndID);
5270 ShortDuration.add(wndID);
5271 }
5272 if (DATA.options.sen) {
5273 SentUnits.add(wndID, action);
5274 }
5275 //}
5276 break;
5277 case "rec_mark":
5278 //addTradeMarks(wndID, 15, 18, 15, "lime");
5279 break;
5280 }
5281 }
5282 }
5283 }
5284 }
5285
5286 function WWTradeHandler() {
5287 var wndArray, wndID, wndA;
5288 wndArray = uw.GPWindowMgr.getOpen(uw.GPWindowMgr.TYPE_WONDERS);
5289 for (var e in wndArray) {
5290 if (wndArray.hasOwnProperty(e)) {
5291 wndID = "#gpwnd_" + wndArray[e].getID() + " ";
5292 if (DATA.options.per && !($(wndID + '.btn_trade').get(0) || $(wndID + '.next_building_phase').get(0) || $(wndID + '#ww_time_progressbar').get(0))) {
5293 addPercentTrade(wndID, true);
5294 }
5295 }
5296 }
5297 }
5298
5299 /*******************************************************************************************************************************
5300 * â— Sent units box
5301 *******************************************************************************************************************************/
5302 var SentUnits = {
5303 activate: function () {
5304 $.Observer(GameEvents.command.send_unit).subscribe('DIO_SEND_UNITS', function (e, data) {
5305 for (var z in data.params) {
5306 if (data.params.hasOwnProperty(z) && (data.sending_type !== "")) {
5307 if (uw.GameData.units[z]) {
5308 sentUnitsArray[data.sending_type][z] = (sentUnitsArray[data.sending_type][z] == undefined ? 0 : sentUnitsArray[data.sending_type][z]);
5309 sentUnitsArray[data.sending_type][z] += data.params[z];
5310 }
5311 }
5312 }
5313 //SentUnits.update(data.sending_type); ????
5314 });
5315 },
5316 deactivate: function () {
5317 $.Observer(GameEvents.command.send_unit).unsubscribe('DIO_SEND_UNITS');
5318 },
5319 add: function (wndID, action) {
5320 if (!$(wndID + '.sent_units_box').get(0)) {
5321 $('<div class="game_inner_box sent_units_box ' + action + '"><div class="game_border ">' +
5322 '<div class="game_border_top"></div><div class="game_border_bottom"></div><div class="game_border_left"></div><div class="game_border_right"></div>' +
5323 '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
5324 '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
5325 '<div class="game_header bold">' +
5326 '<div class="icon_sent townicon_' + (action == "attack" ? "lo" : "ld") + '"></div><span>' + getText("labels", "lab") + ' (' + (action == "attack" ? "OFF" : "DEF") + ')</span>' +
5327 '</div>' +
5328 '<div class="troops"><div class="units_list"></div><hr style="width: 172px;border: 1px solid rgb(185, 142, 93);margin: 3px 0px 2px -1px;">' +
5329 '<div id="btn_sent_units_reset" class="button_new">' +
5330 '<div class="left"></div>' +
5331 '<div class="right"></div>' +
5332 '<div class="caption js-caption">' + getText("buttons", "res") + '<div class="effect js-effect"></div></div>' +
5333 '</div>' +
5334 '</div></div>').appendTo(wndID + '.attack_support_window');
5335
5336 SentUnits.update(action);
5337
5338 $(wndID + '.icon_sent').css({
5339 height: '20px',
5340 marginTop: '-2px',
5341 width: '20px',
5342 backgroundPositionY: '-26px',
5343 paddingLeft: '0px',
5344 marginLeft: '0px'
5345 });
5346
5347 $(wndID + '.sent_units_box').css({
5348 position: 'absolute',
5349 right: '0px',
5350 bottom: '16px',
5351 width: '192px'
5352 });
5353 $(wndID + '.troops').css({padding: '6px 0px 6px 6px'});
5354
5355 $(wndID + '#btn_sent_units_reset').click(function () {
5356 // Overwrite old array
5357 sentUnitsArray[action] = {};
5358
5359 SentUnits.update(action);
5360 });
5361 }
5362 },
5363 update: function (action) {
5364 try {
5365 // Remove old unit list
5366 $('.sent_units_box.' + action + ' .units_list').each(function () {
5367 this.innerHTML = "";
5368 });
5369 // Add new unit list
5370 for (var x in sentUnitsArray[action]) {
5371 if (sentUnitsArray[action].hasOwnProperty(x)) {
5372 if ((sentUnitsArray[action][x] || 0) > 0) {
5373 $('.sent_units_box.' + action + ' .units_list').each(function () {
5374 $(this).append('<div class="unit_icon25x25 ' + x +
5375 (sentUnitsArray[action][x] >= 1000 ? (sentUnitsArray[action][x] >= 10000 ? " five_digit_number" : " four_digit_number") : "") + '">' +
5376 '<span class="count text_shadow">' + sentUnitsArray[action][x] + '</span>' +
5377 '</div>');
5378 });
5379 }
5380 }
5381 }
5382 saveValue(WID + "_sentUnits", JSON.stringify(sentUnitsArray));
5383 } catch (error) {
5384 errorHandling(error, "updateSentUnitsBox");
5385 }
5386 }
5387 };
5388
5389 /*******************************************************************************************************************************
5390 * â— Short duration
5391 *******************************************************************************************************************************/
5392
5393 // TODO: Calculator implementieren
5394 var DurationCalculator = {
5395 activate: function () {
5396 var speedBoosterSprite = "https://diotools.de/images/game/speed_booster.png";
5397
5398 $('<style id="dio_duration_calculator_style">' +
5399 '.dio_speed_booster { border:1px solid #724B08; border-spacing: 0px;} ' +
5400 '.dio_speed_booster td { border:0; padding:2px; } ' +
5401 '.dio_speed_booster .checkbox_new { margin: 4px 0px 1px 3px; } ' +
5402 '.dio_speed_booster .odd { background: url("https://gpall.innogamescdn.com/images/game/border/brown.png") repeat scroll 0% 0% transparent; } ' +
5403 '.dio_speed_booster .even { background: url("https://gpall.innogamescdn.com/images/game/border/odd.png") repeat scroll 0% 0% transparent; } ' +
5404 '.booster_icon { width:20px; height:20px; background-image:url(' + speedBoosterSprite + ');} ' +
5405 '.booster_icon.improved_speed { background-position:0 0; } ' +
5406 '.booster_icon.cartography { background-position:-20px 0; } ' +
5407 '.booster_icon.meteorology { background-position:-40px 0; } ' +
5408 '.booster_icon.lighthouse { background-position:-60px 0; } ' +
5409 '.booster_icon.set_sail { background-position:-80px 0; } ' +
5410 '.booster_icon.atalanta { background-position:-100px 0; } ' +
5411 '</style>').appendTo('head');
5412
5413 $('<table class="dio_speed_booster"><tr>' +
5414 '<td class="odd"><div class="booster_icon improved_speed"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5415 '<td class="even"><div class="booster_icon cartography"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5416 '<td class="odd"><div class="booster_icon meteorology"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5417 '<td class="even"><div class="booster_icon lighthouse"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5418 '<td class="odd"><div class="booster_icon set_sail"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5419 '<td class="even"><div class="booster_icon atalanta"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5420 '</tr></table>').appendTo(wndID + ".duration_container");
5421 },
5422 deactivate: function () {
5423 $('#dio_duration_calculator_style').remove();
5424 },
5425 add: function (wndID, data) {
5426
5427 }
5428 };
5429
5430
5431 var ShortDuration = {
5432 activate: function () {
5433
5434 $('<style id="dio_short_duration_style">' +
5435 '.attack_support_window .tab_type_support .duration_container { top:0px !important; } ' +
5436 //'.attack_support_window .tab_type_attack .duration_container { width:auto; top:10px; } ' +
5437
5438 '.attack_support_window .dio_duration { border-spacing:0px; margin-bottom:2px; text-align:right; } ' +
5439
5440 '.attack_support_window .way_duration, '+
5441 '.attack_support_window .arrival_time { padding:0px 0px 0px 0px; background:none; } ' +
5442
5443 '.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; } ' +
5444 '.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; } ' +
5445 '.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); } ' +
5446
5447 '.attack_support_window .max_booty { padding:0px 0px 0px 30px; margin:3px 4px 4px 4px; width:auto; } ' +
5448 '.attack_support_window .fight_bonus.morale { margin-top:2px; } ' +
5449
5450 '.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; } ' +
5451 '.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; } ' +
5452
5453 '</style>').appendTo('head');
5454
5455 },
5456 deactivate: function () {
5457 $("#dio_short_duration_style").remove();
5458 },
5459 add: function (wndID) {
5460 //console.log($(wndID + ".duration_container").get(0));
5461 try {
5462 var tooltip = (LANG.hasOwnProperty(LID) ? getText("labels", "improved_movement") : "") + " (+30% " + DM.getl10n("barracks", "tooltips").speed.trim() + ")";
5463
5464 $('<table class="dio_duration">' +
5465 '<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>' +
5466 '<tr class="short_duration_row" style="color:darkgreen">' +
5467 '<td> ╚> </td><td><span class="short_duration">~0:00:00</span></td>' +
5468 '<td> ╚></td><td><span class="short_arrival">~00:00:00</span></td>' +
5469 '<td class="short_icon"></td><td></td></tr>' +
5470 '</table>').prependTo(wndID + ".duration_container");
5471
5472
5473
5474 $(wndID + ".nightbonus").appendTo(wndID + ".dio_night");
5475 $(wndID + '.way_duration').appendTo(wndID + ".dio_way");
5476 $(wndID + ".arrival_time").appendTo(wndID + ".dio_arrival");
5477
5478
5479 // Tooltip
5480 $(wndID + '.short_duration_row').tooltip(tooltip);
5481
5482 // Detection of changes
5483 ShortDuration.change(wndID);
5484 // $(wndID + '.way_duration').bind('DOMSubtreeModified', function(e) { console.log(e); }); // Alternative
5485
5486 } catch (error) {
5487 errorHandling(error, "addShortDuration");
5488 }
5489 },
5490 change: function (wndID) {
5491 var duration = new MutationObserver(function (mutations) {
5492 mutations.forEach(function (mutation) {
5493 if (mutation.addedNodes[0]) {
5494 //console.debug(mutation);
5495 ShortDuration.calculate(wndID);
5496 }
5497 });
5498 });
5499 if ($(wndID + '.way_duration').get(0)) {
5500 duration.observe($(wndID + '.way_duration').get(0), {
5501 attributes: false,
5502 childList: true,
5503 characterData: false
5504 });
5505 }
5506 },
5507 //$('<style> .duration_container { display: block !important } </style>').appendTo("head");
5508 calculate: function (wndID) {
5509 //console.log(wndID);
5510 //console.log($(wndID + '.duration_container .way_duration').get(0));
5511 try {
5512 var setup_time = 900 / Game.game_speed,
5513 duration_time = $(wndID + '.duration_container .way_duration').get(0).innerHTML.replace("~", "").split(":"),
5514 // TODO: hier tritt manchmal Fehler auf TypeError: Cannot read property "innerHTML" of undefined at calcShortDuration (<anonymous>:3073:86)
5515 arrival_time,
5516 h, m, s,
5517 atalanta_factor = 0;
5518
5519 var hasCartography = ITowns.getTown(Game.townId).getResearches().get("cartography");
5520 var hasMeteorology = ITowns.getTown(Game.townId).getResearches().get("meteorology");
5521 var hasSetSail = ITowns.getTown(Game.townId).getResearches().get("set_sail");
5522
5523 var hasLighthouse = ITowns.getTown(Game.townId).buildings().get("lighthouse");
5524
5525 // Atalanta aktiviert?
5526 if ($(wndID + '.unit_container.heroes_pickup .atalanta').get(0)) {
5527 if ($(wndID + '.cbx_include_hero').hasClass("checked")) {
5528 // Beschleunigung hängt vom Level ab, Level 1 = 11%, Level 20 = 30%
5529 var atalanta_level = MM.getCollections().PlayerHero[0].models[1].get("level");
5530
5531 atalanta_factor = (atalanta_level + 10) / 100;
5532 }
5533 }
5534
5535 // Sekunden, Minuten und Stunden zusammenrechnen (-> in Sekunden)
5536 duration_time = ((parseInt(duration_time[0], 10) * 60 + parseInt(duration_time[1], 10)) * 60 + parseInt(duration_time[2], 10));
5537
5538 // Verkürzte Laufzeit berechnen
5539 duration_time = ((duration_time - setup_time) * (1 + atalanta_factor)) / (1 + 0.3 + atalanta_factor) + setup_time;
5540
5541
5542 h = Math.floor(duration_time / 3600);
5543 m = Math.floor((duration_time - h * 3600) / 60);
5544 s = Math.floor(duration_time - h * 3600 - m * 60);
5545
5546 if (m < 10) {
5547 m = "0" + m;
5548 }
5549 if (s < 10) {
5550 s = "0" + s;
5551 }
5552
5553 $(wndID + '.short_duration').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
5554
5555 // Ankunftszeit errechnen
5556 arrival_time = Math.round((Timestamp.server() + Game.server_gmt_offset)) + duration_time;
5557
5558 h = Math.floor(arrival_time / 3600);
5559 m = Math.floor((arrival_time - h * 3600) / 60);
5560 s = Math.floor(arrival_time - h * 3600 - m * 60);
5561
5562 h %= 24;
5563
5564 if (m < 10) {
5565 m = "0" + m;
5566 }
5567 if (s < 10) {
5568 s = "0" + s;
5569 }
5570
5571 $(wndID + '.short_arrival').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
5572
5573 clearInterval(arrival_interval[wndID]);
5574
5575 arrival_interval[wndID] = setInterval(function () {
5576 arrival_time += 1;
5577
5578 h = Math.floor(arrival_time / 3600);
5579 m = Math.floor((arrival_time - h * 3600) / 60);
5580 s = Math.floor(arrival_time - h * 3600 - m * 60);
5581
5582 h %= 24;
5583
5584 if (m < 10) {
5585 m = "0" + m;
5586 }
5587 if (s < 10) {
5588 s = "0" + s;
5589 }
5590
5591 if ($(wndID + '.short_arrival').get(0)) {
5592 $(wndID + '.short_arrival').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
5593 } else {
5594 clearInterval(arrival_interval[wndID]);
5595 }
5596 }, 1000);
5597
5598 } catch (error) {
5599 errorHandling(error, "ShortDuration.calculate");
5600 }
5601 }
5602 };
5603
5604 /*******************************************************************************************************************************
5605 * â— Dropdown menu
5606 *******************************************************************************************************************************/
5607
5608 // TODO: Umstellen!
5609 // Preload images for drop down arrow buttons
5610 var drop_over = new Image();
5611 drop_over.src = "http://s7.directupload.net/images/140107/hna95u8a.png";
5612 var drop_out = new Image();
5613 drop_out.src = "http://s14.directupload.net/images/140107/ppsz5mxk.png";
5614
5615 function changeDropDownButton() {
5616 $('<style id="dio_style_arrow" type="text/css">' +
5617 '#dd_filter_type .arrow, .select_rec_unit .arrow {' +
5618 'width: 18px !important; height: 17px !important; background: url("http://s14.directupload.net/images/140107/ppsz5mxk.png") no-repeat 0px -1px !important;' +
5619 'position: absolute; top: 2px !important; right: 3px; } ' +
5620 '</style>').appendTo('head');
5621
5622 }
5623
5624 /*******************************************************************************************************************************
5625 * â— Recruiting Trade
5626 * *****************************************************************************************************************************/
5627 var trade_count = 0, unit = "FS", percent = "0.0"; // Recruiting Trade
5628
5629 // TODO: Funktion umformen, Style anpassen!
5630 var RecruitingTrade = {
5631 activate: function () {
5632 $('<style id="dio_style_recruiting_trade" type="text/css">' +
5633 '#dio_recruiting_trade .option_s { filter:grayscale(100%); -webkit-filter:grayscale(100%); margin:0px; cursor:pointer; } ' +
5634 '#dio_recruiting_trade .option_s:hover { filter:unset !important; -webkit-filter:unset !important; } ' +
5635 '#dio_recruiting_trade .select_rec_unit .sel { filter:sepia(100%); -webkit-filter:sepia(100%); } ' +
5636
5637 '#dio_recruiting_trade .option {color:#000; background:#FFEEC7; } ' +
5638 '#dio_recruiting_trade .option:hover {color:#fff; background:#328BF1; } ' +
5639
5640 '#dio_recruiting_trade { position:absolute; left:30px; top:70px; } ' +
5641 '#dio_recruiting_trade .select_rec_unit { position:absolute; top:20px; width:84px; display:none; } ' +
5642 '#dio_recruiting_trade .select_rec_perc { position:absolute; top:20px; width:50px; display:none; left:50px; } ' +
5643
5644 '#dio_recruiting_trade .open { display:block !important; } '+
5645
5646 '#dio_recruiting_trade .item-list { max-height:unset; } ' +
5647
5648 '#dio_recruiting_trade .arrow { width:18px; height:18px; background:url(' + drop_out.src + ') no-repeat -1px -1px; position:absolute; } ' +
5649
5650 '#trade_tab .content { height:320px; } ' +
5651
5652 '#dio_recruiting_trade .rec_count { position:absolute; top:25px; } ' +
5653
5654 '#dio_recruiting_trade .drop_rec_unit { position:absolute; display:block; width:50px; overflow:visible; } ' +
5655 '#dio_recruiting_trade .drop_rec_perc { position:absolute; display:block; width:55px; left:49px; color:#000; } ' +
5656
5657 '</style>').appendTo('head');
5658 },
5659 deactivate: function () {
5660 $('#dio_style_recruiting_trade').remove();
5661 },
5662 add: function (wndID) {
5663 var max_amount;
5664
5665 $('<div id="dio_recruiting_trade" class="rec_trade">' +
5666 // DropDown-Button for unit
5667 '<div class="drop_rec_unit dropdown default">' +
5668 '<div class="border-left"></div>' +
5669 '<div class="border-right"></div>' +
5670 '<div class="caption" name="' + unit + '">' + unit + '</div>' +
5671 '<div class="arrow"></div>' +
5672 '</div>' +
5673 '<div class="drop_rec_perc dropdown default">' +
5674 // DropDown-Button for ratio
5675 '<div class="border-left"></div>' +
5676 '<div class="border-right"></div>' +
5677 '<div class="caption" name="' + percent + '">' + Math.round(percent * 100) + '%</div>' +
5678 '<div class="arrow"></div>' +
5679 '</div><span class="rec_count">(' + trade_count + ')</span></div>').appendTo(wndID + ".content");
5680
5681 // Select boxes for unit and ratio
5682 $('<div class="select_rec_unit dropdown-list default active">' +
5683 '<div class="item-list">' +
5684 '<div class="option_s unit index_unit unit_icon40x40 attack_ship" name="FS"></div>' +
5685 '<div class="option_s unit index_unit unit_icon40x40 bireme" name="BI"></div>' +
5686 '<div class="option_s unit index_unit unit_icon40x40 sword" name="SK"></div>' +
5687 '<div class="option_s unit index_unit unit_icon40x40 slinger" name="SL"></div>' +
5688 '<div class="option_s unit index_unit unit_icon40x40 archer" name="BS"></div>' +
5689 '<div class="option_s unit index_unit unit_icon40x40 hoplite" name="HO"></div>' +
5690 '<div class="option_s unit index_unit unit_icon40x40 rider" name="RE"></div>' +
5691 '<div class="option_s unit index_unit unit_icon40x40 chariot" name="SW"></div>' +
5692 '</div></div>').appendTo(wndID + ".rec_trade");
5693 $('<div class="select_rec_perc dropdown-list default inactive">' +
5694 '<div class="item-list">' +
5695 '<div class="option sel" name="0.0"> 0%</div>' +
5696 '<div class="option" name="0.05"> 5%</div>' +
5697 '<div class="option" name="0.1">10%</div>' +
5698 '<div class="option" name="0.16666">17%</div>' +
5699 '<div class="option" name="0.2">20%</div>' +
5700 '<div class="option" name="0.25">25%</div>' +
5701 '<div class="option" name="0.33">33%</div>' +
5702 '<div class="option" name="0.5">50%</div>' +
5703 '</div></div>').appendTo(wndID + ".rec_trade");
5704
5705 $(wndID + ".rec_trade [name='" + unit + "']").toggleClass("sel");
5706
5707 // click events of the drop menu
5708 $(wndID + ' .select_rec_unit .option_s').each(function () {
5709 $(this).click(function (e) {
5710 $(".select_rec_unit .sel").toggleClass("sel");
5711 $("." + this.className.split(" ")[4]).toggleClass("sel");
5712
5713 unit = $(this).attr("name");
5714 $('.drop_rec_unit .caption').attr("name", unit);
5715 $('.drop_rec_unit .caption').each(function () {
5716 this.innerHTML = unit;
5717 });
5718 $($(this).parent().parent().get(0)).removeClass("open");
5719 $('.drop_rec_unit .caption').change();
5720 });
5721 });
5722 $(wndID + ' .select_rec_perc .option').each(function () {
5723 $(this).click(function (e) {
5724 $(this).parent().find(".sel").toggleClass("sel");
5725 $(this).toggleClass("sel");
5726
5727 percent = $(this).attr("name");
5728 $('.drop_rec_perc .caption').attr("name", percent);
5729 $('.drop_rec_perc .caption').each(function () {
5730 this.innerHTML = Math.round(percent * 100) + "%";
5731 });
5732 $($(this).parent().parent().get(0)).removeClass("open")
5733 $('.drop_rec_perc .caption').change();
5734 });
5735 });
5736
5737 // show & hide drop menus on click
5738 $(wndID + '.drop_rec_perc').click(function (e) {
5739
5740 if (!$($(e.target)[0].parentNode.parentNode.childNodes[4]).hasClass("open")) {
5741 $($(e.target)[0].parentNode.parentNode.childNodes[4]).addClass("open");
5742 $($(e.target)[0].parentNode.parentNode.childNodes[3]).removeClass("open");
5743 } else {
5744 $($(e.target)[0].parentNode.parentNode.childNodes[4]).removeClass("open");
5745 }
5746 });
5747 $(wndID + '.drop_rec_unit').click(function (e) {
5748
5749 if (!$($(e.target)[0].parentNode.parentNode.childNodes[3]).hasClass("open")) {
5750 $($(e.target)[0].parentNode.parentNode.childNodes[3]).addClass("open");
5751 $($(e.target)[0].parentNode.parentNode.childNodes[4]).removeClass("open");
5752 } else {
5753 $($(e.target)[0].parentNode.parentNode.childNodes[3]).removeClass("open");
5754 }
5755 });
5756
5757 $(wndID).click(function (e) {
5758 var clicked = $(e.target), element = $('#' + this.id + ' .dropdown-list.open').get(0);
5759 if ((clicked[0].parentNode.className.split(" ")[1] !== "dropdown") && element) {
5760 $(element).removeClass("open");
5761 }
5762 });
5763
5764 // hover arrow change
5765 $(wndID + '.dropdown').hover(function (e) {
5766 $(e.target)[0].parentNode.childNodes[3].style.background = "url('" + drop_over.src + "') no-repeat -1px -1px";
5767 }, function (e) {
5768 $(e.target)[0].parentNode.childNodes[3].style.background = "url('" + drop_out.src + "') no-repeat -1px -1px";
5769 });
5770
5771 $(wndID + ".drop_rec_unit .caption").attr("name", unit);
5772 $(wndID + ".drop_rec_perc .caption").attr("name", percent);
5773
5774 $(wndID + '.drop_rec_unit').tooltip(getText("labels", "rat"));
5775 $(wndID + '.drop_rec_perc').tooltip(getText("labels", "shr"));
5776
5777 var ratio = {
5778 NO: {w: 0, s: 0, i: 0},
5779 FS: {w: 1, s: 0.2308, i: 0.6154},
5780 BI: {w: 1, s: 0.8750, i: 0.2250},
5781 SL: {w: 0.55, s: 1, i: 0.4},
5782 RE: {w: 0.6666, s: 0.3333, i: 1},
5783 SK: {w: 1, s: 0, i: 0.8947},
5784 HO: {w: 0, s: 0.5, i: 1},
5785 BS: {w: 1, s: 0, i: 0.6250},
5786 SW: {w: 0.4545, s: 1, i: 0.7273}
5787 };
5788
5789
5790 if ($('#town_capacity_wood .max').get(0)) {
5791 max_amount = parseInt($('#town_capacity_wood .max').get(0).innerHTML, 10);
5792 } else {
5793 max_amount = 25500;
5794 }
5795
5796 $(wndID + '.caption').change(function (e) {
5797 //console.log($(this).attr('name') + ", " + unit + "; " + percent);
5798 if (!(($(this).attr('name') === unit) || ($(this).attr('name') === percent))) {
5799 //trade_count = 0;
5800 $('.rec_count').get(0).innerHTML = "(" + trade_count + ")";
5801 }
5802
5803 var tmp = $(this).attr('name');
5804
5805 if ($(this).parent().attr('class').split(" ")[0] === "drop_rec_unit") {
5806 unit = tmp;
5807 } else {
5808 percent = tmp;
5809 }
5810 var max = (max_amount - 100) / 1000;
5811 addTradeMarks(max * ratio[unit].w, max * ratio[unit].s, max * ratio[unit].i, "lime");
5812
5813 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)
5814 var rArray = uw.ITowns.getTown(uw.Game.townId).getCurrentResources();
5815 var tradeCapacity = uw.ITowns.getTown(uw.Game.townId).getAvailableTradeCapacity();
5816
5817 var wood = ratio[unit].w * part;
5818 var stone = ratio[unit].s * part;
5819 var iron = ratio[unit].i * part;
5820
5821 if ((wood > rArray.wood) || (stone > rArray.stone) || (iron > rArray.iron) || ( (wood + stone + iron) > tradeCapacity)) {
5822 wood = stone = iron = 0;
5823 $('.drop_rec_perc .caption').css({color: '#f00'});
5824 //$('.' + e.target.parentNode.parentNode.className + ' .select_rec_perc .sel').css({color:'#f00'});
5825 //$('.select_rec_perc .sel').css({color:'#f00'});
5826 } else {
5827 $('.' + e.target.parentNode.parentNode.className + ' .drop_rec_perc .caption').css({color: '#000'});
5828 }
5829 $("#trade_type_wood [type='text']").select().val(wood).blur();
5830 $("#trade_type_stone [type='text']").select().val(stone).blur();
5831 $("#trade_type_iron [type='text']").select().val(iron).blur();
5832 });
5833
5834 $('#trade_button').click(function () {
5835 trade_count++;
5836 $('.rec_count').get(0).innerHTML = "(" + trade_count + ")";
5837
5838 });
5839
5840 $(wndID + '.drop_rec_perc .caption').change();
5841 }
5842 };
5843
5844 /*******************************************************************************************************************************
5845 * â— Ressources marks
5846 *******************************************************************************************************************************/
5847 function addTradeMarks(woodmark, stonemark, ironmark, color) {
5848 var max_amount, limit, wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_TOWN), wndID;
5849 for (var e in wndArray) {
5850 if (wndArray.hasOwnProperty(e)) {
5851 wndID = "#gpwnd_" + wndArray[e].getID() + " ";
5852 if ($(wndID + '.town-capacity-indicator').get(0)) {
5853
5854 max_amount = $(wndID + '.amounts .max').get(0).innerHTML;
5855
5856 $('#trade_tab .c_' + color).each(function () {
5857 this.remove();
5858 });
5859 $('#trade_tab .progress').each(function () {
5860 if ($("p", this).length < 3) {
5861 if ($(this).parent().get(0).id != "big_progressbar") {
5862 limit = 1000 * (242 / parseInt(max_amount, 10));
5863
5864 switch ($(this).parent().get(0).id.split("_")[2]) {
5865 case "wood":
5866 limit = limit * woodmark;
5867 break;
5868 case "stone":
5869 limit = limit * stonemark;
5870 break;
5871 case "iron":
5872 limit = limit * ironmark;
5873 break;
5874 }
5875 $('<p class="c_' + color + '"style="position:absolute;left: ' + limit + 'px; background:' + color + ';width:2px;height:100%;margin:0px"></p>').appendTo(this);
5876 }
5877 }
5878 });
5879 }
5880 }
5881 }
5882 }
5883
5884 /*******************************************************************************************************************************
5885 * â— Percentual Trade
5886 *******************************************************************************************************************************/
5887 var rest_count = 0;
5888
5889 function addPercentTrade(wndID, ww) {
5890
5891 var a = "";
5892 var content = wndID + ".content";
5893 if (ww) {
5894 a = "ww_";
5895 content = wndID + '.trade .send_res';
5896 }
5897 $('<div class="btn btn_trade"><a class="button" href="#">' +
5898 '<span class="left"><span class="right">' +
5899 '<span class="middle mid">' +
5900 '<span class="img_trade"></span></span></span></span>' +
5901 '<span style="clear:both;"></span>' +
5902 '</a></div>').prependTo(content);
5903
5904 $(wndID + '.btn_trade').tooltip(getText("labels", "per"));
5905
5906 setPercentTrade(wndID, ww);
5907
5908 // Style
5909 $(wndID + '.btn').css({width: '20px', overflow: 'visible', position: 'absolute', display: 'block'});
5910
5911 if (!ww) {
5912 $(wndID + '.content').css({height: '320px'});
5913 }
5914
5915 if (ww) {
5916 $(wndID + '.btn_trade').css({left: '678px', top: '154px'});
5917 } else {
5918 $(wndID + '.btn_trade').css({left: '336px', top: '135px'});
5919 }
5920
5921 $(wndID + '.mid').css({minWidth: '26px'});
5922
5923 $(wndID + '.img_trade').css({
5924 width: '27px',
5925 height: '27px',
5926 top: '-3px',
5927 float: 'left',
5928 position: 'relative',
5929 background: 'url("http://666kb.com/i/cjq6d72qk521ig1zz.png") no-repeat'
5930 });
5931
5932 }
5933
5934 var res = {};
5935
5936 function setPercentTrade(wndID, ww) {
5937 var a = ww ? "ww_" : "", own_town = $(wndID + '.town_info').get(0) ? true : false;
5938
5939 $(wndID + '.btn_trade').toggleClick(function () {
5940 res.wood = {};
5941 res.stone = {};
5942 res.iron = {};
5943 res.sum = {};
5944
5945 res.sum.amount = 0;
5946 // Set amount of resources to 0
5947 setAmount(true, a, wndID);
5948 // Total amount of resources // TODO: ITowns.getTown(Game.townId).getCurrentResources(); ?
5949 for (var e in res) {
5950 if (res.hasOwnProperty(e) && e != "sum") {
5951 res[e].rest = false;
5952 res[e].amount = parseInt($('.ui_resources_bar .' + e + ' .amount').get(0).innerHTML, 10);
5953 res.sum.amount += res[e].amount;
5954 }
5955 }
5956 // Percentage of total resources
5957 res.wood.percent = 100 / res.sum.amount * res.wood.amount;
5958 res.stone.percent = 100 / res.sum.amount * res.stone.amount;
5959 res.iron.percent = 100 / res.sum.amount * res.iron.amount;
5960
5961 // Total trading capacity
5962 res.sum.cur = parseInt($(wndID + '#' + a + 'big_progressbar .caption .curr').get(0).innerHTML, 10);
5963
5964 // Amount of resources on the percentage of trading capacity (%)
5965 res.wood.part = parseInt(res.sum.cur / 100 * res.wood.percent, 10);
5966 res.stone.part = parseInt(res.sum.cur / 100 * res.stone.percent, 10);
5967 res.iron.part = parseInt(res.sum.cur / 100 * res.iron.percent, 10);
5968
5969 // Get rest warehouse capacity of each resource type
5970 for (var f in res) {
5971 if (res.hasOwnProperty(f) && f != "sum") {
5972 if (!ww && own_town) { // Own town
5973 var curr = parseInt($(wndID + '#town_capacity_' + f + ' .amounts .curr').get(0).innerHTML.replace('+', '').trim(), 10) || 0,
5974 curr2 = parseInt($(wndID + '#town_capacity_' + f + ' .amounts .curr2').get(0).innerHTML.replace('+', '').trim(), 10) || 0,
5975 max = parseInt($(wndID + '#town_capacity_' + f + ' .amounts .max').get(0).innerHTML.replace('+', '').trim(), 10) || 0;
5976
5977 res[f].cur = curr + curr2;
5978 res[f].max = max - res[f].cur;
5979
5980 if (res[f].max < 0) {
5981 res[f].max = 0;
5982 }
5983
5984 } else { // World wonder or foreign town
5985 res[f].max = 30000;
5986 }
5987 }
5988 }
5989 // Rest of fraction (0-2 units) add to stone amount
5990 res.stone.part += res.sum.cur - (res.wood.part + res.stone.part + res.iron.part);
5991
5992 res.sum.rest = 0;
5993 rest_count = 0;
5994 calcRestAmount();
5995 setAmount(false, a, wndID);
5996 }, function () {
5997 setAmount(true, a, wndID);
5998 });
5999 }
6000
6001 function calcRestAmount() {
6002 // Subdivide rest
6003 if (res.sum.rest > 0) {
6004 for (var e in res) {
6005 if (res.hasOwnProperty(e) && e != "sum" && res[e].rest != true) {
6006 res[e].part += res.sum.rest / (3 - rest_count);
6007 }
6008 }
6009 res.sum.rest = 0;
6010 }
6011 // Calculate new rest
6012 for (var f in res) {
6013 if (res.hasOwnProperty(f) && f != "sum" && res[f].rest != true) {
6014 if (res[f].max <= res[f].part) {
6015 res[f].rest = true;
6016 res.sum.rest += res[f].part - res[f].max;
6017 rest_count += 1;
6018 res[f].part = res[f].max;
6019 }
6020 }
6021 }
6022 // Recursion
6023 if (res.sum.rest > 0 && rest_count < 3) {
6024 calcRestAmount();
6025 }
6026 }
6027
6028 function setAmount(clear, a, wndID) {
6029 for (var e in res) {
6030 if (res.hasOwnProperty(e) && e != "sum") {
6031 if (clear == true) {
6032 res[e].part = 0;
6033 }
6034 $(wndID + "#" + a + "trade_type_" + e + ' [type="text"]').select().val(res[e].part).blur();
6035 }
6036 }
6037 }
6038
6039 /********************************************************************************************************************************
6040 * Unit strength (blunt/sharp/distance) and Transport Capacity
6041 * ----------------------------------------------------------------------------------------------------------------------------
6042 * | â— Unit strength: Menu
6043 * | - Switching of def/off display with buttons
6044 * | - Possible Selection of certain unit types
6045 * | â— Unit strength: Conquest
6046 * | â— Unit strength: Barracks
6047 * | â— Transport capacity: Menu
6048 * | - Switching of transporter speed (+/- big transporter)
6049 * ----------------------------------------------------------------------------------------------------------------------------
6050 * ******************************************************************************************************************************/
6051
6052 var def = true, blunt = 0, sharp = 0, dist = 0, shipsize = false;
6053
6054 var UnitStrength = {
6055 // Calculate defensive strength
6056 calcDef: function (units) {
6057 var e;
6058 blunt = sharp = dist = 0;
6059 for (e in units) {
6060 if (units.hasOwnProperty(e)) {
6061 blunt += units[e] * uw.GameData.units[e].def_hack;
6062 sharp += units[e] * uw.GameData.units[e].def_pierce;
6063 dist += units[e] * uw.GameData.units[e].def_distance;
6064 }
6065 }
6066 },
6067 // Calculate offensive strength
6068 calcOff: function (units, selectedUnits) {
6069 var e;
6070 blunt = sharp = dist = 0;
6071 for (e in selectedUnits) {
6072 if (selectedUnits.hasOwnProperty(e)) {
6073 var attack = (units[e] || 0) * uw.GameData.units[e].attack;
6074 switch (uw.GameData.units[e].attack_type) {
6075 case 'hack':
6076 blunt += attack;
6077 break;
6078 case 'pierce':
6079 sharp += attack;
6080 break;
6081 case 'distance':
6082 dist += attack;
6083 break;
6084 }
6085 }
6086 }
6087 },
6088 /*******************************************************************************************************************************
6089 * â— Unit strength: Unit menu
6090 *******************************************************************************************************************************/
6091 Menu: {
6092 activate: function () {
6093 $('<div id="strength" class="cont def"><hr>' +
6094 '<span class="bold text_shadow cont_left strength_font">' +
6095 '<table style="margin:0px;">' +
6096 '<tr><td><div class="ico units_info_sprite img_hack"></td><td id="blunt">0</td></tr>' +
6097 '<tr><td><div class="ico units_info_sprite img_pierce"></td><td id="sharp">0</td></tr>' +
6098 '<tr><td><div class="ico units_info_sprite img_dist"></td><td id="dist">0</td></tr>' +
6099 '</table>' +
6100 '</span>' +
6101 '<div class="cont_right">' +
6102 '<img id="def_button" class="active img" src="https://gpall.innogamescdn.com/images/game/unit_overview/support.png">' +
6103 '<img id="off_button" class="img" src="https://gpall.innogamescdn.com/images/game/unit_overview/attack.png">' +
6104 '</div></div>').appendTo('.units_land .content');
6105
6106 // Style
6107 $('<style id="dio_strength_style">' +
6108 '#strength.def #off_button, #strength.off #def_button { filter:url(#Sepia); -webkit-filter:sepia(1); }' +
6109 '#strength.off #off_button, #strength.def #def_button { filter:none; -webkit-filter:none; } ' +
6110
6111 '#strength.off .img_hack { background-position:0% 36%;} ' +
6112 '#strength.def .img_hack { background-position:0% 0%;} ' +
6113 '#strength.off .img_pierce { background-position:0% 27%;} ' +
6114 '#strength.def .img_pierce { background-position:0% 9%;} ' +
6115 '#strength.off .img_dist { background-position:0% 45%;} ' +
6116 '#strength.def .img_dist { background-position:0% 18%;} ' +
6117
6118 '#strength .strength_font { font-size: 0.8em; } ' +
6119 '#strength.off .strength_font { color:#edb;} ' +
6120 '#strength.def .strength_font { color:#fc6;} ' +
6121
6122 '#strength .ico { height:20px; width:20px; } ' +
6123 '#strength .units_info_sprite { background:url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png); background-size:100%; } ' +
6124
6125 '#strength .img_pierce { background-position:0px -20px; } ' +
6126 '#strength .img_dist { background-position:0px -40px; } ' +
6127 '#strength hr { margin:0px; background-color:#5F5242; height:2px; border:0px solid; } ' +
6128 '#strength .cont_left { width:65%; display:table-cell; } ' +
6129
6130 '#strength.cont { background:url(https://gpall.innogamescdn.com/images/game/layout/layout_units_nav_border.png); } ' +
6131
6132 '#strength .cont_right { width:30%; display:table-cell; vertical-align:middle; } ' +
6133 '#strength .img { float:right; background:none; margin:2px 8px 2px 0px; } ' +
6134
6135 '</style>').appendTo("head");
6136
6137 // Button events
6138 $('.units_land .units_wrapper, .btn_gods_spells .checked').click(function () {
6139 setTimeout(function () {
6140 UnitStrength.Menu.update();
6141 }, 100);
6142 });
6143
6144 $('#off_button').click(function () {
6145 $('#strength').addClass('off').removeClass('def');
6146
6147 def = false;
6148 UnitStrength.Menu.update();
6149 });
6150 $('#def_button').click(function () {
6151 $('#strength').addClass('def').removeClass('off');
6152
6153 def = true;
6154 UnitStrength.Menu.update();
6155 });
6156 $('#def_button, #off_button').hover(function () {
6157 $(this).css('cursor', 'pointer');
6158 });
6159
6160 UnitStrength.Menu.update();
6161 },
6162 deactivate: function () {
6163 $('#strength').remove();
6164 $('#dio_strength_style').remove();
6165 },
6166 update: function () {
6167 var unitsIn = uw.ITowns.getTown(uw.Game.townId).units(), units = UnitStrength.Menu.getSelected();
6168
6169 // Calculation
6170 if (def === true) {
6171 UnitStrength.calcDef(units);
6172 } else {
6173 UnitStrength.calcOff(unitsIn, units);
6174 }
6175 $('#blunt').get(0).innerHTML = blunt;
6176 $('#sharp').get(0).innerHTML = sharp;
6177 $('#dist').get(0).innerHTML = dist;
6178 },
6179 getSelected: function () {
6180 var units = [];
6181 if ($(".units_land .units_wrapper .selected").length > 0) {
6182 $(".units_land .units_wrapper .selected").each(function () {
6183 units[this.className.split(" ")[1]] = this.children[0].innerHTML;
6184 });
6185 } else {
6186 $(".units_land .units_wrapper .unit").each(function () {
6187 units[this.className.split(" ")[1]] = this.children[0].innerHTML;
6188 });
6189 }
6190 return units;
6191 }
6192 },
6193 /*******************************************************************************************************************************
6194 * â— Unit strength: Conquest
6195 *******************************************************************************************************************************/
6196 Conquest: {
6197 add: function () {
6198 var units = [], str;
6199
6200 // units of the siege
6201 $('#conqueror_units_in_town .unit').each(function () {
6202 str = $(this).attr("class").split(" ")[4];
6203 if (!uw.GameData.units[str].is_naval) {
6204 units[str] = parseInt(this.children[0].innerHTML, 10);
6205 //console.log($(this).attr("class").split(" ")[4]);
6206 }
6207 });
6208 // calculation
6209 UnitStrength.calcDef(units);
6210
6211 $('<div id="strength_eo" class="game_border" style="width:90px; margin: 20px; align:center;">' +
6212 '<div class="game_border_top"></div><div class="game_border_bottom"></div>' +
6213 '<div class="game_border_left"></div><div class="game_border_right"></div>' +
6214 '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
6215 '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
6216 '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">' +
6217 '<tr><td width="1%"><div class="ico units_info_sprite img_hack"></div></td><td id="bl" align="center" width="100%">0</td></tr>' +
6218 '<tr><td><div class="ico units_info_sprite img_pierce"></div></td><td id="sh" align="center">0</td></tr>' +
6219 '<tr><td><div class="ico units_info_sprite img_dist"></div></td><td id="di" align="center">0</td></tr>' +
6220 '</table></span>' +
6221 '</div>').appendTo('#conqueror_units_in_town');
6222
6223 $('#strength_eo').tooltip('Gesamteinheitenstärke der Belagerungstruppen');
6224
6225 // Veröffentlichung-Button-Text
6226 $('#conqueror_units_in_town .publish_conquest_public_id_wrap').css({
6227 marginLeft: '130px'
6228 });
6229
6230 $('#strength_eo .ico').css({
6231 height: '20px',
6232 width: '20px'
6233 });
6234 $('#strength_eo .units_info_sprite').css({
6235 background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
6236 backgroundSize: '100%'
6237 });
6238 $('#strength_eo .img_pierce').css({backgroundPosition: '0% 9%'});
6239 $('#strength_eo .img_dist').css({backgroundPosition: '0% 18%'});
6240
6241
6242 $('#bl').get(0).innerHTML = blunt;
6243 $('#sh').get(0).innerHTML = sharp;
6244 $('#di').get(0).innerHTML = dist;
6245 }
6246 },
6247 /*******************************************************************************************************************************
6248 * â— Unit strength: Barracks
6249 *******************************************************************************************************************************/
6250 Barracks: {
6251 add: function () {
6252 if (!$('#strength_baracks').get(0)) {
6253 var units = [], pop = 0;
6254
6255 // whole units of the town
6256 $('#units .unit_order_total').each(function () {
6257 units[$(this).parent().parent().attr("id")] = this.innerHTML;
6258 });
6259 // calculation
6260 UnitStrength.calcDef(units);
6261
6262 // population space of the units
6263 for (var e in units) {
6264 if (units.hasOwnProperty(e)) {
6265 pop += units[e] * uw.GameData.units[e].population;
6266 }
6267 }
6268 $('<div id="strength_baracks" class="game_border" style="float:right; width:70px; align:center;">' +
6269 '<div class="game_border_top"></div><div class="game_border_bottom"></div>' +
6270 '<div class="game_border_left"></div><div class="game_border_right"></div>' +
6271 '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
6272 '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
6273 '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">' +
6274 '<tr><td width="1%"><div class="ico units_info_sprite img_hack"></div></td><td id="b" align="center" width="100%">0</td></tr>' +
6275 '<tr><td><div class="ico units_info_sprite img_pierce"></div></td><td id="s" align="center">0</td></tr>' +
6276 '<tr><td><div class="ico units_info_sprite img_dist"></div></td><td id="d" align="center">0</td></tr>' +
6277 '</table></span>' +
6278 '</div>').appendTo('.ui-dialog #units');
6279
6280 $('<div id="pop_baracks" class="game_border" style="float:right; width:60px; align:center;">' +
6281 '<div class="game_border_top"></div><div class="game_border_bottom"></div>' +
6282 '<div class="game_border_left"></div><div class="game_border_right"></div>' +
6283 '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
6284 '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
6285 '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">' +
6286 '<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>' +
6287 '</table></span>' +
6288 '</div>').appendTo('.ui-dialog #units');
6289
6290 $('.ui-dialog #units .ico').css({
6291 height: '20px',
6292 width: '20px'
6293 });
6294 $('.ui-dialog #units .units_info_sprite').css({
6295 background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
6296 backgroundSize: '100%'
6297 });
6298 $('.ui-dialog #units .img_pierce').css({backgroundPosition: '0% 9%'});
6299 $('.ui-dialog #units .img_dist').css({backgroundPosition: '0% 18%'});
6300
6301 //$('#pop_baracks').tooltip('Bevölkerungszahl aller Landeinheiten der Stadt');
6302 //$('#strength_baracks').tooltip('Gesamteinheitenstärke stadteigener Truppen');
6303
6304 $('#b').get(0).innerHTML = blunt;
6305 $('#s').get(0).innerHTML = sharp;
6306 $('#d').get(0).innerHTML = dist;
6307 $('#p').get(0).innerHTML = pop;
6308 }
6309 }
6310 }
6311 };
6312
6313 /*******************************************************************************************************************************
6314 * â— Transporter capacity
6315 *******************************************************************************************************************************/
6316 var TransportCapacity = {
6317 activate: function () {
6318 // transporter display
6319 $('<div id="transporter" class="cont" style="height:25px;">' +
6320 '<table style=" margin:0px;"><tr align="center" >' +
6321 '<td><img id="ship_img" class="ico" src="http://s7.directupload.net/images/140724/4pvfuch8.png"></td>' +
6322 '<td><span id="ship" class="bold text_shadow" style="color:#FFCC66;font-size: 10px;line-height: 2.1;"></span></td>' +
6323 '</tr></table>' +
6324 '</div>').appendTo('.units_naval .content');
6325
6326 $('#transporter.cont').css({
6327 background: 'url(https://gpall.innogamescdn.com/images/game/layout/layout_units_nav_border.png)'
6328 });
6329
6330 $('#transporter').hover(function () {
6331 $(this).css('cursor', 'pointer');
6332 });
6333 $('#transporter').toggleClick(
6334 function () {
6335 $('#ship_img').get(0).src = "http://s1.directupload.net/images/140724/b5xl8nmj.png";
6336 shipsize = !shipsize;
6337 TransportCapacity.update();
6338 },
6339 function () {
6340 $('#ship_img').get(0).src = "http://s7.directupload.net/images/140724/4pvfuch8.png";
6341 shipsize = !shipsize;
6342 TransportCapacity.update();
6343 }
6344 );
6345 TransportCapacity.update();
6346 },
6347 deactivate: function () {
6348 $('#transporter').remove();
6349 },
6350 update: function () {
6351 var bigTransp = 0, smallTransp = 0, pop = 0, ship = 0, unit, berth, units = [];
6352 // Ship space (available)
6353 smallTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().small_transporter, 10);
6354 if (isNaN(smallTransp)) smallTransp = 0;
6355 if (shipsize) {
6356 bigTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().big_transporter, 10);
6357 if (isNaN(bigTransp)) bigTransp = 0;
6358 }
6359
6360 // Checking: Research berth
6361 berth = 0;
6362 if (uw.ITowns.getTown(uw.Game.townId).researches().hasBerth()) {
6363 berth = GameData.research_bonus.berth;
6364 }
6365 ship = bigTransp * (GameData.units.big_transporter.capacity + berth) + smallTransp * (GameData.units.small_transporter.capacity + berth);
6366
6367 units = uw.ITowns.getTown(uw.Game.townId).units();
6368
6369 // Ship space (required)
6370 for (var e in units) {
6371 if (units.hasOwnProperty(e)) {
6372 if (uw.GameData.units[e]) { // without Heroes
6373 if (!(uw.GameData.units[e].is_naval || uw.GameData.units[e].flying)) {
6374 pop += units[e] * uw.GameData.units[e].population;
6375 }
6376 }
6377 }
6378 }
6379 $('#ship').get(0).innerHTML = pop + "/" + ship;
6380 }
6381 };
6382
6383
6384 /*******************************************************************************************************************************
6385 * Simulator
6386 * ----------------------------------------------------------------------------------------------------------------------------
6387 * | â— Layout adjustment
6388 * | â— Permanent display of the extended modifier box
6389 * | â— Unit strength for entered units (without modificator influence yet)
6390 * ----------------------------------------------------------------------------------------------------------------------------
6391 *******************************************************************************************************************************/
6392 var Simulator = {
6393 activate: function () {
6394 $('<style id="dio_simulator_style" type="text/css">' +
6395
6396 '#place_simulator { overflow: hidden !important} ' +
6397 '#place_simulator .game_body { height: 417px !important} ' +
6398
6399 '#place_simulator_form h4 { display:none; } '+
6400
6401 '#place_simulator .place_simulator_table { margin: 0px !important } '+
6402
6403 '#place_simulator_form .place_sim_wrap_mods { margin-bottom: 2px; } '+
6404
6405 // Bonus container
6406 '.place_sim_bonuses_heroes { position:absolute; right:3px; top:27px; width: 272px;} ' +
6407 '.place_sim_bonuses_heroes .place_sim_showhide { display:none; } ' + // Hide modifier box button
6408
6409
6410 //'.place_sim_wrap_mods {position: relative; right: -17px !important} '+
6411 '.place_sim_wrap_mods .place_simulator_table :eq(1) { width: 300px;} ' + ////////////// genauer!
6412 '.place_sim_wrap_mods > .place_simulator_table { width: 272px;} ' + ////////////// genauer!
6413
6414 // Wall losses
6415 '.place_sim_wrap_mods tr:last-child { display:none; } ' +
6416
6417 // Extended modifier box
6418 //'@-webkit-keyframes MODBOX { 0% { opacity: 0; } 100% { opacity: 1; } } '+
6419 //'@keyframes MODBOX { 0% { opacity: 0; } 100% { opacity: 1; } } '+
6420
6421 '.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} ' +
6422 '.place_sim_wrap_mods_extended table tr td:eq(0) { width: 18px !important } ' +
6423 '.place_sim_wrap_mods_extended td { border:0px; } ' +
6424 '.place_sim_wrap_mods_extended tr td:first-child { border-left:0px; width:19px; padding-left:0px; } ' +
6425 '.place_sim_wrap_mods_extended .place_simulator_table { margin:0px; border-collapse:separate; border:1px solid #724B08; table-layout:fixed; width:100% } ' +
6426
6427 '.place_simulator_table .place_image { display:block; width: 20px; height:20px; background-size:100%; margin:auto; } ' +
6428
6429 '.place_simulator_table .place_image.pa_commander { background: url(https://diotools.de/images/game/advisors/advisors_22.png); background-position: 0px 44px; } ' +
6430 '.place_simulator_table .place_image.pa_captain { background: url(https://diotools.de/images/game/advisors/advisors_22.png); background-position: 0px 88px; } ' +
6431 '.place_simulator_table .place_image.pa_priest { background: url(https://diotools.de/images/game/advisors/advisors_22.png); background-position: 0px 66px; } ' +
6432
6433 '.place_simulator_table .place_image.is_night { background-position: 0px -40px; } ' +
6434 '.place_simulator_table .place_image.research_ram { background-position: 0px -300px; } ' +
6435 '.place_simulator_table .place_image.research_phalanx { background-position: 0px -280px; }' +
6436 '.place_simulator_table .place_image.research_divine_selection { background-position: 0 -600px; }' +
6437
6438 '.place_sim_wrap_mods_extended .place_cross { height:16px; background:none; } ' +
6439 '.place_sim_wrap_mods_extended .place_checkbox_field { display:table-cell; width:13px; height:13px; } ' +
6440
6441 '.place_sim_wrap_mods_extended tr:last-child { display:none;} ' +
6442
6443 '.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} ' +
6444
6445 '.place_sim_wrap_mods_extended .game_border>div { display:none; } ' +
6446 '.place_sim_wrap_mods_extended .game_border { margin:0px; } ' +
6447
6448 '.place_sim_wrap_mods_extended .game_border { height: 139px; overflow-y: auto; overflow-x: hidden; }' + // Größe der Modfikatorbox begrenzen
6449
6450 '#place_simulator .window_inner_curtain { display: none !important } ' + // Hintergrund entfernen bei offener Modifikatorbox
6451
6452 // Unit container
6453 '#simulator_body .unit_container { height: 50px !important; width: 50px !important; margin: 0px 3px 0px 1px !important} ' +
6454 '.place_simulator_odd, .place_simulator_even { text-align: center !important} ' +
6455 '.place_insert_field { margin: 0px !important} ' +
6456
6457 '#place_sim_ground_units { position:absolute; bottom: 35px;} ' +
6458
6459 // Sea unit box
6460 '#place_sim_naval_units { position: absolute; } ' +
6461 '#place_sim_naval_units tbody tr:last-child { height:auto !important; }' +
6462
6463 // Land unit box
6464 '#place_sim_wrap_units { position: absolute !important; bottom: 35px !important} ' +
6465
6466 '#simulator_body>h4 { position:absolute;bottom:188px;} ' +
6467
6468 // Select boxes
6469 '.place_sim_select_gods_wrap { position:absolute; bottom:182px; } ' +
6470
6471 '.place_sim_select_gods_wrap .place_sim_select_gods { width: 150px; } ' +
6472 '.place_sim_select_gods_wrap select { max-width: 120px; } ' +
6473
6474 '.place_sim_select_gods_wrap .place_symbol, .place_sim_select_strategies .place_symbol { margin: 1px 2px 0px 5px !important} ' +
6475 '.place_sim_insert_units .place_symbol { filter: hue-rotate(330deg); -webkit-filter: hue-rotate(330deg);} ' +
6476 '.place_attack { float: left !important} ' +
6477
6478 // Hero box
6479 '.place_sim_heroes_container { position: absolute; right: 0px; z-index: 1; } ' +
6480 '.place_sim_hero_container { width: 45px !important; height: 25px !important} ' +
6481
6482 '#place_simulator .place_sim_bonuses_heroes h4:nth-of-type(2) { display:none; }' + // Heroes title
6483
6484 // - Hero container
6485 '.place_sim_hero_choose, .place_sim_hero_unit_container { height: 26px !important; width: 30px !important} ' +
6486 '#hero_defense_icon, #hero_attack_icon { height: 25px !important; width: 25px !important; margin: 0px !important} ' +
6487 '#hero_defense_dd, #hero_attack_dd { height: 25px !important; width: 25px !important; margin: 1px !important} ' +
6488 '.place_sim_hero_attack, .place_sim_hero_defense { margin-left: 3px !important} ' +
6489 '#hero_attack_text, #hero_defense_text { font-size: 11px !important; bottom: 0px !important} ' +
6490 '.place_sim_heroes_container .plus { left: 2px; top: 2px !important} ' +
6491
6492 '.place_sim_heroes_container .button_new.square { left: 2px !important; } ' +
6493
6494
6495 // - Hero spinner
6496 '.place_sim_heroes_container .spinner { height: 25px !important; width: 40px !important } ' +
6497 '.place_sim_heroes_container td:nth-child(0) { height: 30px !important} ' +
6498 '.place_sim_heroes_container .spinner { height: 24px !important; position:absolute !important; width:12px !important; left:29px !important; '+
6499 'background:url(https://gpall.innogamescdn.com/images/game/border/odd.png) repeat !important; border: 1px solid rgb(107, 107, 107) !important; } ' +
6500 '.place_sim_heroes_container .spinner .button_down, .place_sim_heroes_container .spinner .button_up { bottom: 2px !important; cursor: pointer !important} ' +
6501 '.place_sim_heroes_container .spinner .border_l, .place_sim_heroes_container .spinner .border_r, .place_sim_heroes_container .spinner .body { display:none; } '+
6502
6503 // Quack
6504 '#q_place_sim_lost_res { display: none; } ' +
6505 '</style>').appendTo('head');
6506
6507 if($('#place_simulator').get(0)) {
6508 Simulator.change();
6509 }
6510
6511 SimulatorStrength.activate();
6512
6513 },
6514 deactivate: function () {
6515 $('#dio_simulator_style').remove();
6516 if($('#simu_table').get(0)) {
6517 $('#simu_table').remove();
6518
6519 // Hero box
6520 if ($('.place_sim_heroes_container').get(0)) {
6521 $('.hero_unit').each(function () {
6522 $(this).addClass('unit_icon40x40').removeClass('unit_icon25x25');
6523 });
6524
6525 // Hero spinner
6526 $('.place_sim_heroes_container .spinner').each(function () {
6527 $(this).addClass('place_sim_hero_spinner');
6528 });
6529 }
6530 }
6531
6532 SimulatorStrength.deactivate();
6533 },
6534 change: function () {
6535 // TODO: Durch CSS ersetzen...
6536
6537 // Wall loss
6538 $('.place_sim_wrap_mods tr:eq(1) td:eq(5)').html('<span id="building_place_def_losses_wall_level" class="place_losses bold"></span>');
6539
6540 // Extended modificator box
6541 $('.place_sim_wrap_mods_extended .power').each(function () {
6542 $(this).removeClass("power_icon45x45").addClass("power_icon16x16");
6543 });
6544 $('.place_sim_wrap_mods_extended td:nth-child(even)').each(function () {
6545 $(this).addClass("left_border place_simulator_odd");
6546 });
6547 $('.place_sim_wrap_mods_extended td:nth-child(odd)').each(function () {
6548 $(this).addClass("left_border place_simulator_even");
6549 });
6550
6551 // Border entfernen
6552 $('.place_sim_wrap_mods_extend td:first-child').each(function () {
6553 $(this).removeClass("left_border");
6554 });
6555
6556 // -> Update percentage each time
6557 $('.place_checkbox_field').click(function () {
6558 FightSimulator.closeModsExtended(); //$('.place_sim_bonuses_more_confirm').get(0).click();
6559 });
6560
6561 // Hero world ?
6562 if (uw.Game.hasArtemis) {
6563 $('.place_sim_wrap_mods_extend tr').each(function () {
6564 this.children[1].style.borderLeft = "none";
6565 this.children[0].remove();
6566 });
6567 }
6568
6569 // Hero box
6570 if ($('.place_sim_heroes_container').get(0)) {
6571 $('.hero_unit').each(function () {
6572 $(this).removeClass('unit_icon40x40').addClass('unit_icon25x25');
6573 });
6574
6575 // Hero spinner
6576 $('.place_sim_heroes_container .spinner').each(function () {
6577 $(this).removeClass('place_sim_hero_spinner');
6578 });
6579 }
6580
6581 setStrengthSimulator();
6582 }
6583 };
6584
6585 function afterSimulation() {
6586 var lossArray = {att: {res: 0, fav: 0, pop: 0}, def: {res: 0, fav: 0, pop: 0}},
6587 wall_level = parseInt($('.place_sim_wrap_mods .place_insert_field[name="sim[mods][def][wall_level]"]').val(), 10),
6588 wall_damage = parseInt($('#building_place_def_losses_wall_level').get(0).innerHTML, 10),
6589 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];
6590
6591 // Calculate unit losses
6592 $('#place_sim_ground_units .place_losses, #place_sim_naval_units .place_losses').each(function () {
6593 var loss = parseInt(this.innerHTML, 10) || 0;
6594 //console.log(this.innerHTML);
6595 if (loss > 0) {
6596 var unit = this.id.substring(26);
6597 var side = this.id.split("_")[2]; // att / def
6598 lossArray[side].res += loss * (uw.GameData.units[unit].resources.wood + uw.GameData.units[unit].resources.stone + uw.GameData.units[unit].resources.iron);
6599 lossArray[side].fav += loss * uw.GameData.units[unit].favor;
6600 lossArray[side].pop += loss * uw.GameData.units[unit].population;
6601 }
6602 });
6603 // Calculate wall resource losses
6604 for (var w = wall_level; w > wall_level - wall_damage; w--) {
6605 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
6606 }
6607
6608 // Insert losses into table
6609 for (var x in lossArray) {
6610 if (lossArray.hasOwnProperty(x)) {
6611 for (var z in lossArray[x]) {
6612 if (lossArray[x].hasOwnProperty(z)) {
6613 //console.log(((z === "res") && (lossArray[x][z] > 10000)) ? (Math.round(lossArray[x][z] / 1000) + "k") : lossArray[x][z]);
6614 $("#" + x + "_" + z).get(0).innerHTML = ((z === "res") && (lossArray[x][z] > 10000)) ? (Math.round(lossArray[x][z] / 1000) + "k") : lossArray[x][z];
6615
6616 }
6617 }
6618 }
6619 }
6620 }
6621
6622 // Stärkeanzeige: Simulator
6623 var unitsGround = {att: {}, def: {}}, unitsNaval = {att: {}, def: {}}, name = "";
6624
6625 var SimulatorStrength = {
6626 unitsGround : {att: {}, def: {}},
6627 unitsNaval : {att: {}, def: {}},
6628
6629 activate : function(){
6630 $('<style id="dio_simulator_strength_style">'+
6631 '#dio_simulator_strength { position:absolute; top:192px; font-size:0.8em; width:63%; } '+
6632 '#dio_simulator_strength .ico { height:20px; width:20px; margin:auto; } '+
6633 '#dio_simulator_strength .units_info_sprite { background:url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png); background-size:100%; } ' +
6634
6635 '#dio_simulator_strength .img_hack { background-position:0% 36%; } '+
6636 '#dio_simulator_strength .img_pierce { background-position:0% 27%; } '+
6637 '#dio_simulator_strength .img_dist { background-position:0% 45% !important; } '+
6638 '#dio_simulator_strength .img_ship { background-position:0% 72%; } '+
6639
6640 '#dio_simulator_strength .img_fav { background: url(https://gpall.innogamescdn.com/images/game/res/favor.png) !important; background-size: 100%; } '+
6641 '#dio_simulator_strength .img_res { background: url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png) 0% 54%; background-size: 100%; } '+
6642 '#dio_simulator_strength .img_pop { background: url(https://gpall.innogamescdn.com/images/game/res/pop.png); background-size:100%; } '+
6643
6644 '#dio_simulator_strength .left_border { width: 54px; } '+
6645 '</style>'
6646 ).appendTo('head');
6647
6648 },
6649 deactivate : function(){
6650 $('#dio_simulator_strength_style').remove();
6651 },
6652 add : function(){
6653 $('<div id="dio_simulator_strength">' +
6654 '<div style="float:left; margin-right:12px;"><h4>' + getText("labels", "str") + '</h4>' +
6655 '<table class="place_simulator_table strength" cellpadding="0px" cellspacing="0px" style="align:center;">' +
6656 '<tr>' +
6657 '<td class="place_simulator_even"></td>' +
6658 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_hack"></div></td>' +
6659 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_pierce"></div></td>' +
6660 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_dist"></div></td>' +
6661 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_ship"></div></td>' +
6662 '</tr><tr>' +
6663 '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>' +
6664 '<td class="left_border place_simulator_odd" id="att_b">0</td>' +
6665 '<td class="left_border place_simulator_even" id="att_s">0</td>' +
6666 '<td class="left_border place_simulator_odd" id="att_d">0</td>' +
6667 '<td class="left_border place_simulator_even" id="att_ship">0</td>' +
6668 '</tr><tr>' +
6669 '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
6670 '<td class="left_border place_simulator_odd" id="def_b">0</td>' +
6671 '<td class="left_border place_simulator_even" id="def_s">0</td>' +
6672 '<td class="left_border place_simulator_odd" id="def_d">0</td>' +
6673 '<td class="left_border place_simulator_even" id="def_ship">0</td>' +
6674 '</tr>' +
6675 '</table>' +
6676 '</div><div><h4>' + getText("labels", "los") + '</h4>' +
6677 '<table class="place_simulator_table loss" cellpadding="0px" cellspacing="0px" style="align:center;">' +
6678 '<tr>' +
6679 '<td class="place_simulator_even"></td>' +
6680 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_res"></div></td>' +
6681 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_fav"></div></td>' +
6682 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_pop"></div></td>' +
6683 '</tr><tr>' +
6684 '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>' +
6685 '<td class="left_border place_simulator_odd" id="att_res">0</td>' +
6686 '<td class="left_border place_simulator_even" id="att_fav">0</td>' +
6687 '<td class="left_border place_simulator_odd" id="att_pop">0</td>' +
6688 '</tr><tr>' +
6689 '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
6690 '<td class="left_border place_simulator_odd" id="def_res">0</td>' +
6691 '<td class="left_border place_simulator_even" id="def_fav">0</td>' +
6692 '<td class="left_border place_simulator_odd" id="def_pop">0</td>' +
6693 '</tr>' +
6694 '</table>' +
6695 '</div></div>').appendTo('#simulator_body');
6696
6697
6698 $('#dio_simulator_strength .left_border').each(function () {
6699 $(this)[0].align = 'center';
6700 });
6701
6702 // Tooltips setzen
6703 $('#dio_simulator_strength .strength').tooltip(getText("labels", "str") + " (" + getText("labels", "mod") + ")");
6704 $('#dio_simulator_strength .loss').tooltip(getText("labels", "los"));
6705
6706 // Klick auf Einheitenbild
6707 $('.index_unit').click(function () {
6708 var type = $(this).attr('class').split(" ")[4];
6709 $('.place_insert_field[name="sim[units][att][' + type + ']"]').change();
6710 });
6711
6712 $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').on('input change', function () {
6713 name = $(this).attr("name").replace(/\]/g, "").split("[");
6714 var str = this;
6715
6716
6717 setTimeout(function () {
6718 var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2],
6719 val, e;
6720
6721 val = parseInt($(str).val(), 10);
6722 val = val || 0;
6723
6724 if (unit_type == "ground") {
6725 unitsGround[name[2]][name[3]] = val;
6726
6727 if (name[2] == "def") {
6728 UnitStrength.calcDef(unitsGround.def);
6729 } else {
6730 UnitStrength.calcOff(unitsGround.att, unitsGround.att);
6731 }
6732 $('#' + name[2] + '_b').get(0).innerHTML = blunt;
6733 $('#' + name[2] + '_s').get(0).innerHTML = sharp;
6734 $('#' + name[2] + '_d').get(0).innerHTML = dist;
6735
6736 } else {
6737 var att = 0, def = 0;
6738 unitsNaval[name[2]][name[3]] = val;
6739
6740 if (name[2] == "def") {
6741 for (e in unitsNaval.def) {
6742 if (unitsNaval.def.hasOwnProperty(e)) {
6743 def += unitsNaval.def[e] * uw.GameData.units[e].defense;
6744 }
6745 }
6746 $('#def_ship').get(0).innerHTML = def;
6747
6748 } else {
6749 for (e in unitsNaval.att) {
6750 if (unitsNaval.att.hasOwnProperty(e)) {
6751 att += unitsNaval.att[e] * uw.GameData.units[e].attack;
6752 }
6753 }
6754 $('#att_ship').get(0).innerHTML = att;
6755 }
6756 }
6757 }, 100);
6758 });
6759
6760 // Abfrage wegen eventueller Spionageweiterleitung
6761 getUnitInputs();
6762 setTimeout(function () {
6763 setChangeUnitInputs("def");
6764 }, 100);
6765
6766 $('#select_insert_units').change(function () {
6767 var side = $(this).find('option:selected').val();
6768
6769 setTimeout(function () {
6770 getUnitInputs();
6771 if (side === "att" || side === "def") {
6772 setChangeUnitInputs(side);
6773 }
6774 }, 200);
6775 });
6776 },
6777
6778 getUnitInputs : function(){
6779 $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').each(function () {
6780 var name = $(this).attr("name").replace(/\]/g, "").split("[");
6781
6782 var str = this;
6783
6784 var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2];
6785
6786 var val = parseInt($(str).val(), 10);
6787
6788 val = val || 0;
6789
6790 if (unit_type === "ground") {
6791 SimulatorStrength.unitsGround[name[2]][name[3]] = val;
6792 } else {
6793 SimulatorStrength.unitsNaval[name[2]][name[3]] = val;
6794 }
6795 });
6796 },
6797
6798 updateStrength : function(){
6799
6800 }
6801 }
6802 function setStrengthSimulator() {
6803 $('<div id="dio_simulator_strength">' +
6804 '<div style="float:left; margin-right:12px;"><h4>' + getText("labels", "str") + '</h4>' +
6805 '<table class="place_simulator_table strength" cellpadding="0px" cellspacing="0px" style="align:center;">' +
6806 '<tr>' +
6807 '<td class="place_simulator_even"></td>' +
6808 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_hack"></div></td>' +
6809 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_pierce"></div></td>' +
6810 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_dist"></div></td>' +
6811 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_ship"></div></td>' +
6812 '</tr><tr>' +
6813 '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>' +
6814 '<td class="left_border place_simulator_odd" id="att_b">0</td>' +
6815 '<td class="left_border place_simulator_even" id="att_s">0</td>' +
6816 '<td class="left_border place_simulator_odd" id="att_d">0</td>' +
6817 '<td class="left_border place_simulator_even" id="att_ship">0</td>' +
6818 '</tr><tr>' +
6819 '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
6820 '<td class="left_border place_simulator_odd" id="def_b">0</td>' +
6821 '<td class="left_border place_simulator_even" id="def_s">0</td>' +
6822 '<td class="left_border place_simulator_odd" id="def_d">0</td>' +
6823 '<td class="left_border place_simulator_even" id="def_ship">0</td>' +
6824 '</tr>' +
6825 '</table>' +
6826 '</div><div><h4>' + getText("labels", "los") + '</h4>' +
6827 '<table class="place_simulator_table loss" cellpadding="0px" cellspacing="0px" style="align:center;">' +
6828 '<tr>' +
6829 '<td class="place_simulator_even"></td>' +
6830 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_res"></div></td>' +
6831 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_fav"></div></td>' +
6832 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_pop"></div></td>' +
6833 '</tr><tr>' +
6834 '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>' +
6835 '<td class="left_border place_simulator_odd" id="att_res">0</td>' +
6836 '<td class="left_border place_simulator_even" id="att_fav">0</td>' +
6837 '<td class="left_border place_simulator_odd" id="att_pop">0</td>' +
6838 '</tr><tr>' +
6839 '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
6840 '<td class="left_border place_simulator_odd" id="def_res">0</td>' +
6841 '<td class="left_border place_simulator_even" id="def_fav">0</td>' +
6842 '<td class="left_border place_simulator_odd" id="def_pop">0</td>' +
6843 '</tr>' +
6844 '</table>' +
6845 '</div></div>').appendTo('#simulator_body');
6846
6847
6848 /*
6849 $('#dio_simulator_strength').css({
6850 position: 'absolute',
6851 top: '192px',
6852 fontSize: '0.8em',
6853 width: '63%'
6854 });
6855 $('#dio_simulator_strength .ico').css({
6856 height: '20px',
6857 width: '20px',
6858 margin: 'auto'
6859 });
6860 $('#dio_simulator_strength .units_info_sprite').css({
6861 background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
6862 backgroundSize: '100%'
6863 });
6864 $('#dio_simulator_strength .img_hack').css({backgroundPosition: '0% 36%'});
6865 $('#dio_simulator_strength .img_pierce').css({backgroundPosition: '0% 27%'});
6866 $('#dio_simulator_strength .img_dist').css({backgroundPosition: '0% 45%'});
6867 $('#dio_simulator_strength .img_ship').css({backgroundPosition: '0% 72%'});
6868
6869 $('#dio_simulator_strength .img_fav').css({
6870 background: 'url(https://gpall.innogamescdn.com/images/game/res/favor.png)',
6871 backgroundSize: '100%'
6872 });
6873 $('#dio_simulator_strength .img_res').css({
6874 background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png) 0% 54%',
6875 backgroundSize: '100%'
6876 });
6877 $('#dio_simulator_strength .img_pop').css({
6878 background: 'url(https://gpall.innogamescdn.com/images/game/res/pop.png)',
6879 backgroundSize: '100%'
6880 });
6881
6882 $('#dio_simulator_strength .left_border').css({
6883 width: '54px'
6884 });
6885 */
6886
6887
6888 $('#dio_simulator_strength .left_border').each(function () {
6889 $(this)[0].align = 'center';
6890 });
6891
6892 $('#dio_simulator_strength .strength').tooltip(getText("labels", "str") + " (" + getText("labels", "mod") + ")");
6893 $('#dio_simulator_strength .loss').tooltip(getText("labels", "los"));
6894
6895 // Klick auf Einheitenbild
6896 $('.index_unit').click(function () {
6897 var type = $(this).attr('class').split(" ")[4];
6898 $('.place_insert_field[name="sim[units][att][' + type + ']"]').change();
6899 });
6900
6901 $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').on('input change', function () {
6902 name = $(this).attr("name").replace(/\]/g, "").split("[");
6903 var str = this;
6904 //console.log(str);
6905 setTimeout(function () {
6906 var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2],
6907 val, e;
6908
6909 val = parseInt($(str).val(), 10);
6910 val = val || 0;
6911
6912 if (unit_type == "ground") {
6913 unitsGround[name[2]][name[3]] = val;
6914
6915 if (name[2] == "def") {
6916 UnitStrength.calcDef(unitsGround.def);
6917 } else {
6918 UnitStrength.calcOff(unitsGround.att, unitsGround.att);
6919 }
6920 $('#' + name[2] + '_b').get(0).innerHTML = blunt;
6921 $('#' + name[2] + '_s').get(0).innerHTML = sharp;
6922 $('#' + name[2] + '_d').get(0).innerHTML = dist;
6923
6924 } else {
6925 var att = 0, def = 0;
6926 unitsNaval[name[2]][name[3]] = val;
6927
6928 if (name[2] == "def") {
6929 for (e in unitsNaval.def) {
6930 if (unitsNaval.def.hasOwnProperty(e)) {
6931 def += unitsNaval.def[e] * uw.GameData.units[e].defense;
6932 }
6933 }
6934 $('#def_ship').get(0).innerHTML = def;
6935
6936 } else {
6937 for (e in unitsNaval.att) {
6938 if (unitsNaval.att.hasOwnProperty(e)) {
6939 att += unitsNaval.att[e] * uw.GameData.units[e].attack;
6940 }
6941 }
6942 $('#att_ship').get(0).innerHTML = att;
6943 }
6944 }
6945 }, 100);
6946 });
6947
6948 // Abfrage wegen eventueller Spionageweiterleitung
6949 getUnitInputs();
6950 setTimeout(function () {
6951 setChangeUnitInputs("def");
6952 }, 100);
6953
6954 $('#select_insert_units').change(function () {
6955 var side = $(this).find('option:selected').val();
6956
6957 setTimeout(function () {
6958 getUnitInputs();
6959 if (side === "att" || side === "def") {
6960 setChangeUnitInputs(side);
6961 }
6962 }, 200);
6963 });
6964 }
6965
6966 function getUnitInputs() {
6967 $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').each(function () {
6968 name = $(this).attr("name").replace(/\]/g, "").split("[");
6969
6970 var str = this;
6971
6972 var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2];
6973
6974 var val = parseInt($(str).val(), 10);
6975
6976 val = val || 0;
6977
6978 if (unit_type === "ground") {
6979 unitsGround[name[2]][name[3]] = val;
6980 } else {
6981 unitsNaval[name[2]][name[3]] = val;
6982 }
6983 });
6984 }
6985
6986 function setChangeUnitInputs(side) {
6987 $('.place_insert_field[name="sim[units][' + side + '][godsent]"]').change();
6988 setTimeout(function () {
6989 $('.place_insert_field[name="sim[units][' + side + '][colonize_ship]"]').change();
6990 }, 100);
6991 }
6992
6993 /*******************************************************************************************************************************
6994 * Defense form
6995 * ----------------------------------------------------------------------------------------------------------------------------
6996 * | â— Adds a defense form to the bbcode bar
6997 * ----------------------------------------------------------------------------------------------------------------------------
6998 *******************************************************************************************************************************/
6999
7000 // Funktion aufteilen...
7001 function addForm(e) {
7002 var textareaId = "", bbcodeBarId = "";
7003
7004 switch (e) {
7005 case "/alliance_forum/forum":
7006 textareaId = "#forum_post_textarea";
7007 bbcodeBarId = "#forum";
7008 break;
7009 case "/message/forward":
7010 textareaId = "#message_message";
7011 bbcodeBarId = "#message_bbcodes";
7012 break;
7013 case "/message/new":
7014 textareaId = "#message_new_message";
7015 bbcodeBarId = "#message_bbcodes";
7016 break;
7017 case "/message/view":
7018 textareaId = "#message_reply_message";
7019 bbcodeBarId = "#message_bbcodes";
7020 break;
7021 case "/player_memo/load_memo_content":
7022 textareaId = "#memo_text_area";
7023 bbcodeBarId = "#memo_edit";
7024 break;
7025 }
7026
7027 $('<a title="Verteidigungsformular" href="#" class="dio_bbcode_option def_form" name="def_form"></a>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
7028
7029 $('.def_form_button').css({
7030 cursor: 'pointer',
7031 marginTop: '3px'
7032 });
7033
7034 $(bbcodeBarId + ' .dio_bbcode_option').css({
7035 background: 'url("http://s14.directupload.net/images/140126/lt3hyb8j.png")',
7036 display: 'block',
7037 float: 'left',
7038 width: '22px',
7039 height: '23px',
7040 margin: '0 3px 0 0',
7041 position: 'relative'
7042 });
7043 $(bbcodeBarId + ' .def_form').css({
7044 backgroundPosition: '-89px 0px'
7045 });
7046 var imgArray = {
7047 wall: 'https://gpall.innogamescdn.com/images/game/main/wall.png',
7048 tower: 'https://gpall.innogamescdn.com/images/game/main/tower.png',
7049 hide: 'https://gpall.innogamescdn.com/images/game/main/hide.png',
7050
7051 spy: 'http://s7.directupload.net/images/140114/yr993xwc.png',
7052 pop: 'http://s7.directupload.net/images/140114/4d6xktxm.png',
7053
7054 rev1: 'http://s7.directupload.net/images/140115/9cv6otiu.png',
7055 rev0: 'http://s7.directupload.net/images/140115/aue4rg6i.png',
7056 eo1: 'http://s1.directupload.net/images/140115/fkzlipyh.png',
7057 eo0: 'http://s1.directupload.net/images/140115/hs2kg59c.png',
7058 att: 'http://s1.directupload.net/images/140115/3t6uy4te.png',
7059 sup: 'http://s7.directupload.net/images/140115/ty6szerx.png',
7060
7061 zeus: 'http://s1.directupload.net/images/140114/cdxecrpu.png',
7062 hera: 'http://s1.directupload.net/images/140114/mve54v2o.png',
7063 athena: 'http://s14.directupload.net/images/140114/kyqyedhe.png',
7064 poseidon: 'http://s7.directupload.net/images/140114/tusr9oyi.png',
7065 hades: 'http://s7.directupload.net/images/140114/huins2gn.png',
7066 artemis: 'http://s7.directupload.net/images/140114/kghjhko8.png',
7067 nogod: 'http://s1.directupload.net/images/140114/e7vmvfap.png',
7068
7069 captain: 'http://s14.directupload.net/images/140114/88gg75rc.png',
7070 commander: 'http://s14.directupload.net/images/140114/slbst52o.png',
7071 priest: 'http://s1.directupload.net/images/140114/glptekkx.png',
7072
7073 phalanx: 'http://s7.directupload.net/images/140114/e97wby6z.png',
7074 ram: 'http://s7.directupload.net/images/140114/s854ds3w.png',
7075
7076 militia: 'http://wiki.en.grepolis.com/images/9/9b/Militia_40x40.png',
7077 sword: 'http://wiki.en.grepolis.com/images/9/9c/Sword_40x40.png',
7078 slinger: 'http://wiki.en.grepolis.com/images/d/dc/Slinger_40x40.png',
7079 archer: 'http://wiki.en.grepolis.com/images/1/1a/Archer_40x40.png',
7080 hoplite: 'http://wiki.en.grepolis.com/images/b/bd/Hoplite_40x40.png',
7081 rider: 'http://wiki.en.grepolis.com/images/e/e9/Rider_40x40.png',
7082 chariot: 'http://wiki.en.grepolis.com/images/b/b8/Chariot_40x40.png',
7083 catapult: 'http://wiki.en.grepolis.com/images/f/f0/Catapult_40x40.png',
7084 godsent: 'http://wiki.de.grepolis.com/images/6/6e/Grepolis_Wiki_225.png',
7085
7086 def_sum: 'http://s14.directupload.net/images/140127/6cxnis9r.png',
7087
7088 minotaur: 'http://wiki.de.grepolis.com/images/7/70/Minotaur_40x40.png',
7089 manticore: 'http://wiki.de.grepolis.com/images/5/5e/Manticore_40x40.png',
7090 zyclop: 'http://wiki.de.grepolis.com/images/6/66/Zyklop_40x40.png',
7091 sea_monster: 'http://wiki.de.grepolis.com/images/7/70/Sea_monster_40x40.png',
7092 harpy: 'http://wiki.de.grepolis.com/images/8/80/Harpy_40x40.png',
7093 medusa: 'http://wiki.de.grepolis.com/images/d/db/Medusa_40x40.png',
7094 centaur: 'http://wiki.de.grepolis.com/images/5/53/Centaur_40x40.png',
7095 pegasus: 'http://wiki.de.grepolis.com/images/5/54/Pegasus_40x40.png',
7096 cerberus: 'http://wiki.de.grepolis.com/images/6/67/Zerberus_40x40.png',
7097 fury: 'http://wiki.de.grepolis.com/images/6/67/Erinys_40x40.png',
7098 griffin: 'http://wiki.de.grepolis.com/images/d/d1/Unit_greif.png',
7099 calydonian_boar: 'http://wiki.de.grepolis.com/images/9/93/Unit_eber.png',
7100
7101 big_transporter: 'http://wiki.en.grepolis.com/images/0/04/Big_transporter_40x40.png',
7102 bireme: 'http://wiki.en.grepolis.com/images/4/44/Bireme_40x40.png',
7103 attack_ship: 'http://wiki.en.grepolis.com/images/e/e6/Attack_ship_40x40.png',
7104 demolition_ship: 'http://wiki.en.grepolis.com/images/e/ec/Demolition_ship_40x40.png',
7105 small_transporter: 'http://wiki.en.grepolis.com/images/8/85/Small_transporter_40x40.png',
7106 trireme: 'http://wiki.en.grepolis.com/images/a/ad/Trireme_40x40.png',
7107 colonize_ship: 'http://wiki.en.grepolis.com/images/d/d1/Colonize_ship_40x40.png',
7108
7109 move_icon: 'https://gpall.innogamescdn.com/images/game/unit_overview/',
7110
7111 bordure: 'http://s1.directupload.net/images/140126/8y6pmetk.png'
7112 };
7113
7114 $('<div class="bb_def_chooser">' +
7115 '<div class="bbcode_box middle_center">' +
7116 '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div>' +
7117 '<div class="bbcode_box top_center"></div><div class="bbcode_box bottom_center"></div>' +
7118 '<div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>' +
7119 '<div class="bbcode_box middle_left"></div><div class="bbcode_box middle_right"></div>' +
7120 '<div class="bbcode_box content clearfix" style="padding:5px">' +
7121 '<div id="f_uni" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "det") + '</div></div><br><br>' +
7122 '<div id="f_prm" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "prm") + '</div></div><br><br>' +
7123 '<div id="f_sil" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "sil") + '</div></div><br><br>' +
7124 '<div id="f_mov" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "mov") + '</div></div><br><br>' +
7125 '<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>' +
7126 '</div></div></div>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
7127
7128 $('.bb_def_chooser').css({
7129 display: 'none',
7130 top: '38px',
7131 left: '510px',
7132 position: 'absolute',
7133 width: '190px',
7134 zIndex: 10000
7135 });
7136
7137 $(bbcodeBarId + " .bb_def_chooser .checkbox_new").click(function () {
7138 $(this).toggleClass("checked");
7139 });
7140
7141 $(bbcodeBarId + ' .def_form').toggleClick(function () {
7142 $(this).parent().find(".bb_def_chooser").get(0).style.display = "block";
7143 }, function () {
7144 $(this).parent().find(".bb_def_chooser").get(0).style.display = "none";
7145 });
7146
7147 $(bbcodeBarId + ' #dio_insert').click(function () {
7148 var textarea = $(textareaId).get(0), text = $(textarea).val(), troop_table = "", troop_img = "", troop_count = "", separator = "", move_table = "", landunit_sum = 0;
7149
7150 $('.def_form').click();
7151
7152 if ($('#f_uni').hasClass("checked")) {
7153 $('.units_land .unit, .units_naval .unit').each(function () {
7154 troop_img += separator + '[img]' + imgArray[this.className.split(" ")[1]] + '[/img]';
7155 troop_count += separator + '[center]' + $(this).find(".value").get(0).innerHTML + '[/center]';
7156 separator = "[||]";
7157 });
7158 } else {
7159 $('.units_land .unit').each(function () {
7160 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);
7161 if (def > 10) {
7162 landunit_sum += parseInt($(this).find(".value").get(0).innerHTML, 10) * uw.GameData.units[a].population * ((def > 20) ? 2 : 1);
7163 }
7164 });
7165 landunit_sum = (landunit_sum > 10000) ? ((Math.round(landunit_sum / 100)) / 10) + "k" : landunit_sum;
7166
7167 troop_img += '[img]' + imgArray.def_sum + '[/img]';
7168 troop_count += '[center]' + landunit_sum + '[/center]';
7169 separator = "[||]";
7170 $('.units_naval .unit').each(function () {
7171 troop_img += separator + '[img]' + imgArray[this.className.split(" ")[1]] + '[/img]';
7172 troop_count += separator + '[center]' + $(this).find(".value").get(0).innerHTML + '[/center]';
7173 });
7174 }
7175 if (troop_img !== "") {
7176 troop_table = "\n[table][**]" + troop_img + "[/**][**]" + troop_count + "[/**][/table]\n";
7177 }
7178
7179 var str = '[img]' + imgArray.bordure + '[/img]' +
7180 '\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' +
7181 //'[table][**][img]'+ imgArray.sup +'[/img][||]'+
7182 '[size=12][town]' + uw.ITowns.getTown(uw.Game.townId).getId() + '[/town] ([player]' + uw.Game.player_name + '[/player])[/size]' +
7183 //'[||][img]'+ imgArray['rev' + (uw.ITowns.getTown(uw.Game.townId).hasConqueror()?1:0)] +'[/img][/**][/table]'+
7184 '\n\n[i][b]' + getText("labels", "inf") + '[/b][/i]' + troop_table +
7185 '[table][*]' +
7186 '[img]' + imgArray.wall + '[/img][|]\n' +
7187 '[img]' + imgArray.tower + '[/img][|]\n' +
7188 '[img]' + imgArray.phalanx + '[/img][|]\n' +
7189 '[img]' + imgArray.ram + '[/img][|]\n' +
7190 ($('#f_prm').hasClass("checked") ? '[img]' + imgArray.commander + '[/img][|]\n' : ' ') +
7191 ($('#f_prm').hasClass("checked") ? '[img]' + imgArray.captain + '[/img][|]\n' : ' ') +
7192 ($('#f_prm').hasClass("checked") ? '[img]' + imgArray.priest + '[/img][|]\n' : ' ') +
7193 ($('#f_sil').hasClass("checked") ? '[center][img]' + imgArray.spy + '[/img][/center][|]\n' : ' ') +
7194 '[img]' + imgArray.pop + '[/img][|]\n' +
7195 '[img]' + imgArray[(uw.ITowns.getTown(uw.Game.townId).god() || "nogod")] + '[/img][/*]\n' +
7196 '[**][center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("wall") + '[/center][||]' +
7197 '[center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("tower") + '[/center][||]' +
7198 '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.phalanx ? '+' : '-') + '[/center][||]' +
7199 '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.ram ? '+' : '-') + '[/center][||]' +
7200 ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.commander >= uw.Timestamp.now()) ? '+' : '-') + '[/center][||]' : ' ') +
7201 ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.captain >= uw.Timestamp.now()) ? '+' : '-') + '[/center][||]' : ' ') +
7202 ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.priest >= uw.Timestamp.now()) ? '+' : '-') + '[/center][||]' : ' ') +
7203 ($('#f_sil').hasClass("checked") ? '[center]' + Math.round(uw.ITowns.getTown(uw.Game.townId).getEspionageStorage() / 1000) + 'k[/center][||]' : ' ') +
7204 '[center]' + uw.ITowns.getTown(uw.Game.townId).getAvailablePopulation() + '[/center][||]' +
7205 '[center]' + $('.gods_favor_amount').get(0).innerHTML + '[/center]' +
7206 '[/**][/table]';
7207
7208 var bb_count_str = parseInt(str.match(/\[/g).length, 10), bb_count_move = 0;
7209
7210 var i = 0;
7211 if ($('#f_mov').hasClass("checked")) {
7212 move_table += '\n[i][b]' + getText("labels", "mov") + '[/b][/i]\n[table]';
7213
7214 $('#toolbar_activity_commands').mouseover();
7215
7216 $('#toolbar_activity_commands_list .content .command').each(function () {
7217 var cl = $(this).children()[0].className.split(" ");
7218 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)) {
7219 move_table += (i % 1) ? "" : "[**]";
7220 i++;
7221 move_table += "[img]" + imgArray.move_icon + cl[2] + ".png[/img][||]";
7222 move_table += getArrivalTime($(this).children()[1].innerHTML) + (uw.Game.market_id === "de" ? " Uhr[||]" : " [||]");
7223 move_table += "[town]" + JSON.parse(atob($(this).children()[2].firstChild.href.split("#")[1])).id + "[/town]";
7224 move_table += (i % 1) ? "[||]" : "[/**]";
7225 }
7226 bb_count_move = parseInt(move_table.match(/\[/g).length, 10);
7227 });
7228 if ((bb_count_str + bb_count_move) > 480) {
7229 move_table += '[**]...[/**]';
7230 }
7231
7232 $('#toolbar_activity_commands').mouseout();
7233
7234 //console.log((bb_count_str + bb_count_move));
7235 move_table += (i % 1) ? "[/**]" : "";
7236 move_table += "[*][|][color=#800000][size=6][i] (" + getText("labels", "dev") + ": ±1s)[/i][/size][/color][/*][/table]\n";
7237 }
7238
7239 str += move_table + '[img]' + imgArray.bordure + '[/img]';
7240
7241
7242 $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + str + text.substring($(textarea).get(0).selectionEnd));
7243 });
7244 }
7245
7246 function getArrivalTime(duration_time) {
7247 /*
7248 var server_time = new Date((uw.Timestamp.server() + 7200) * 1000);
7249
7250 duration_time = duration_time.split(":");
7251
7252 s = server_time.getUTCSeconds() + parseInt(duration_time[2], 10);
7253 m = server_time.getUTCMinutes() + parseInt(duration_time[1], 10) + ((s>=60)? 1 : 0);
7254 h = server_time.getUTCHours() + parseInt(duration_time[0], 10) + ((m>=60)? 1 : 0);
7255 */
7256
7257 var server_time = $('.server_time_area').get(0).innerHTML.split(" ")[0].split(":"), arrival_time, s, m, h;
7258 duration_time = duration_time.split(":");
7259
7260 s = parseInt(server_time[2], 10) + parseInt(duration_time[2], 10);
7261 m = parseInt(server_time[1], 10) + parseInt(duration_time[1], 10) + ((s >= 60) ? 1 : 0);
7262 h = parseInt(server_time[0], 10) + parseInt(duration_time[0], 10) + ((m >= 60) ? 1 : 0);
7263
7264 s = s % 60;
7265 m = m % 60;
7266 h = h % 24;
7267
7268 s = ((s < 10) ? "0" : "") + s;
7269 m = ((m < 10) ? "0" : "") + m;
7270 h = ((h < 10) ? "0" : "") + h;
7271
7272 arrival_time = h + ":" + m + ":" + s;
7273
7274 return arrival_time;
7275 }
7276
7277
7278 /*******************************************************************************************************************************
7279 * Smiley box
7280 * ----------------------------------------------------------------------------------------------------------------------------
7281 * | â— Display of a smiley selection box for text input fields (forum, messages, notes):
7282 * | â— Used smileys: http://www.greensmilies.com/smilie-album/
7283 * | + Own Grepolis smileys
7284 * ----------------------------------------------------------------------------------------------------------------------------
7285 *******************************************************************************************************************************/
7286
7287 var smileyArray = {};
7288
7289 var SmileyBox = {
7290 loading_error: false, isHalloween: false, isXmas: false, isForum: $(".editor_textbox_container").get(0),
7291
7292 activate: function () {
7293 $('<style id="dio_smiley">' +
7294 '.smiley_button { cursor:pointer; margin:3px 2px 2px 2px; } ' +
7295
7296 '.smiley_box.game { z-index:5000; position:absolute; top:27px; left:430px; min-width:300px; display:none; } ' +
7297
7298 // Smiley categories
7299 '.smiley_box .box_header { display: table; width: 100%; text-align:center; } ' +
7300 '.smiley_box .group { display:table-cell; color: #0c450c; cursor: pointer; font-weight:bold; padding: 0px 2px 0px 2px; } ' +
7301 '.smiley_box .group.active { color: #089421; text-decoration:underline;} ' +
7302 '.smiley_box .group:hover { color: #14999E; } ' + // #11AD6C
7303
7304 // Special smiley categories
7305 '.smiley_box .halloween { color: #E25E00; } ' +
7306 '.smiley_box .xmas { color: darkred; } ' +
7307
7308 '.smiley_box hr { margin:3px 0px 0px 0px; color:#086b18; border:1px solid; } ' +
7309
7310 // Smilies
7311 '.smiley_box .box_content { overflow: hidden; } ' +
7312 '.smiley_box .box_content .smiley { border: 1px solid rgba(0,0,0,0); border-radius: 5px;} ' +
7313 '.smiley_box .box_content .smiley:hover { background: rgba(8, 148, 77, 0.2); border: 1px solid rgba(0, 128, 0, 0.5); } ' +
7314
7315 // Smiley page link
7316 '.smiley_box .box_footer { text-align:center; margin-top:4px; } ' +
7317 '.smiley_box a:link, .smiley_box a:visited { color: #086b18; font-size: 0.7em; } ' +
7318 '.smiley_box a:hover { color: #14999E; } ' +
7319
7320 // TODO Forum ...
7321 '.smiley_box.forum .box_header_left { float:left; } ' +
7322 //'.smiley_box.forum .group { padding-right: 10px; } '+
7323 '.smiley_box.forum .box_header_right { text-align:right; margin-top:2px; } ' +
7324
7325 '.smiley_box.forum { max-height:90px; margin-left:5px; width:99%; min-height:10px; } ' +
7326 '.smiley_box.forum .box_content { overflow:overlay; min-height:70px; margin-bottom:10px; } ' +
7327
7328 '.smiley_box.forum a:link, .smiley_box.forum a:visited { font-size: 1em; } ' +
7329
7330 '</style>').appendTo('head');
7331
7332
7333 // Smiley categories
7334 smileyArray.button = ["rollsmiliey", "smile"];
7335
7336 smileyArray.standard = [
7337 "smilenew", "grin", "lol", "neutral_new", "afraid", "freddus_pacman", "auslachen2", "kolobok-sanduhr", "bussi2", "winken4", "flucht2", "panik4", "ins-auge-stechen",
7338 "seb_zunge", "fluch4_GREEN", "baby_junge2", "blush-reloaded6", "frown", "verlegen", "blush-pfeif", "stevieh_rolleyes", "daumendreh2", "baby_taptap",
7339 "sadnew", "hust", "confusednew", "idea2", "irre", "irre4", "sleep", "candle", "nicken", "no_sad",
7340 "thumbs-up_new", "thumbs-down_new", "bravo2", "oh-no2", "kaffee2", "drunk", "saufen", "freu-dance", "hecheln", "headstand", "rollsmiliey", "eazy_cool01", "motz", "cuinlove", "biggrin"
7341 ];
7342 smileyArray.nature = [
7343 "dinosaurier07", "flu-super-gau", "ben_cat", "schwein", "hundeleine01", "blume", "ben_sharky", "ben_cow", "charly_bissig", "gehirnschnecke_confused", "mttao_fische", "mttao_angler",
7344 "insel", "fliegeschnappen", "spider", /* Spinne */ "shipwrecked", /* Schiffbrüchiger */ "plapperhase", "ben_dumbo"
7345 ];
7346 smileyArray.grepolis = [
7347 "mttao_wassermann", "hera", /* Hera */ "medusa", /* Medusa */ "manticore", /* Mantikor */ "cyclops", /* Zyklop */
7348 "minotaur", /* Minotaurus */ "pegasus", /* Pegasus */ "hydra", /* Hydra */
7349 "silvester_cuinlove", "mttao_schuetze", "kleeblatt2", "wallbash", /* "glaskugel4", */ "musketiere_fechtend", /* "krone-hoch",*/ "viking", // Wikinger
7350 "mttao_waage2", "steckenpferd", /* "kinggrin_anbeten2", */ "grepolove", /* Grepo Love */ "skullhaufen", "pferdehaufen" // "i/ckajscggscw4s2u60"
7351 ];
7352 smileyArray.people = [
7353 "seb_hut5", "opa_boese2", "star-wars-yoda1-gruen", "hexefliegend", "snob", "seb_detektiv_ani", "seb_cowboy", "devil", "segen", "pirat5", "borg", "hexe3b",
7354 "pharaoh", "hippie", "eazy_polizei", "stars_elvis", "mttao_chefkoch", "nikolaus", "pirate3_biggrin", "batman_skeptisch", "tubbie1", "tubbie2", "tubbie3", "tubbie4"
7355 ];
7356 smileyArray.other = [
7357 "steinwerfen", "herzen02", "scream-if-you-can", "kolobok", "headbash", "liebeskummer", "bussi", "brautpaar-reis", "grab-schaufler2", "boxen2", "aufsmaul",
7358 "sauf", "mttao_kehren", "sm", "weckruf", "klugscheisser2", "karte2_rot", "dagegen", "party", "dafuer", "outofthebox", "pokal_gold", "koepfler", "transformer"
7359 ];
7360
7361 // TODO: HolidayChecker benutzen!
7362 SmileyBox.checkHolidaySeason();
7363
7364 if (SmileyBox.isHalloween) {
7365 smileyArray.halloween = [
7366 "zombies_alien", "zombies_lol", "zombies_rolleyes", "zombie01", "zombies_smile", "zombie02", "zombies_skeptisch", "zombies_eek", "zombies_frown",
7367 "scream-if-you-can", "geistani", "pfeildurchkopf01", "grab-schaufler", "kuerbisleuchten", "mummy3",
7368 "kuerbishaufen", "halloweenskulljongleur", "fledermausvampir", "frankenstein_lol", "halloween_confused", "zombies_razz",
7369 "halloweenstars_freddykrueger", "zombies_cool", "geist2", "fledermaus2", "halloweenstars_dracula"
7370 // "batman" "halloweenstars_lastsummer"
7371 ];
7372 }
7373 if (SmileyBox.isXmas) {
7374 smileyArray.xmas = [
7375 "schneeballwerfen", "schneeball", "xmas4_advent4", "nikolaus", "weihnachtsmann_junge", "schneewerfen_wald", "weihnachtsmann_nordpol", "xmas_kilroy_kamin",
7376 "xmas4_laola", "xmas4_aufsmaul", "xmas3_smile", "xmas4_paketliebe", "mttao_ruprecht_peitsche", "3hlkoenige", "santa", "xmas4_hurra2", "weihnachtsgeschenk2", "fred_weihnachten-ostern"
7377 //"dafuer", "outofthebox", "pokal_gold", "koepfler", "transformer"
7378 ];
7379 }
7380
7381 //smileyArray.other = smileyArray.halloween.slice();
7382
7383 // Forum: Extra smiley
7384 if (SmileyBox.isForum) {
7385 smileyArray.grepolis.push("i/ckajscggscw4s2u60"); // Pacman
7386 smileyArray.grepolis.push("i/cowqyl57t5o255zli"); // Bugpolis
7387 smileyArray.grepolis.push("i/cowquq2foog1qrbee"); // Inno
7388 }
7389
7390 SmileyBox.loadSmileys();
7391 },
7392 deactivate: function () {
7393 $('#dio_smiley').remove();
7394 },
7395 checkHolidaySeason: function () {
7396 // TODO: HolidaySpecial-Klasse stattdessen benutzen
7397 var daystamp = 1000 * 60 * 60 * 24, today = new Date((new Date()) % (daystamp * (365 + 1 / 4))), // without year
7398
7399 // Halloween-Smileys ->15 days
7400 halloween_start = daystamp * 297, // 25. Oktober
7401 halloween_end = daystamp * 321, // 8. November
7402 // Xmas-Smileys -> 28 Tage
7403 xmas_start = daystamp * 334, // 1. Dezember
7404 xmas_end = daystamp * 361; // 28. Dezember
7405
7406 SmileyBox.isHalloween = (today >= halloween_start) ? (today <= halloween_end) : false;
7407
7408 SmileyBox.isXmas = (today >= xmas_start) ? (today <= xmas_end) : false;
7409 },
7410 // preload images
7411 loadSmileys: function () {
7412 // Replace german sign smilies
7413 if (LID !== "de") {
7414 smileyArray.other[17] = "dagegen2";
7415 smileyArray.other[19] = "dafuer2";
7416 }
7417
7418 for (var e in smileyArray) {
7419 if (smileyArray.hasOwnProperty(e)) {
7420 for (var f in smileyArray[e]) {
7421 if (smileyArray[e].hasOwnProperty(f)) {
7422 var src = smileyArray[e][f];
7423
7424 smileyArray[e][f] = new Image();
7425 smileyArray[e][f].className = "smiley";
7426
7427 if (src.substring(0, 2) == "i/") {
7428 smileyArray[e][f].src = "http://666kb.com/" + src + ".gif";
7429 } else {
7430 if (SmileyBox.loading_error == false) {
7431 smileyArray[e][f].src = "https://diotools.de/images/smileys/"+ e +"/smiley_emoticons_" + src + ".gif";
7432 //console.debug("Smiley", e);
7433 } else {
7434 smileyArray[e][f].src = 'http://s1.directupload.net/images/140128/93x3p4co.gif';
7435 }
7436 }
7437 smileyArray[e][f].onerror = function () {
7438 this.src = 'http://s1.directupload.net/images/140128/93x3p4co.gif';
7439 };
7440 }
7441 }
7442 }
7443 }
7444 },
7445
7446 // Forum smilies
7447 changeForumEditorLayout: function () {
7448 $('.blockrow').css({border: "none"});
7449
7450 // Subject/Title
7451 $($('.section div label[for="title"]').parent()).css({float: "left", width: "36%", marginRight: "20px"});
7452 $($('.section div label[for="subject"]').parent()).css({float: "left", width: "36%", marginRight: "20px"});
7453
7454 $('.section div input').eq(0).css({marginBottom: "-10px", marginTop: "10px"});
7455 $('#display_posticon').remove();
7456
7457 // Posticons
7458 $('.posticons table').css({width: "50%" /* marginTop: "-16px"*/});
7459 $('.posticons').css({marginBottom: "-16px"});
7460 $('.posticons').insertAfter($('.section div label[for="title"]').parent());
7461 $('.posticons').insertAfter($('.section div label[for="subject"]').parent());
7462 // Posticons hint
7463 $('.posticons p').remove();
7464 // Posticons: No Icon - radio button
7465 $(".posticons [colspan='14']").parent().replaceWith($(".posticons [colspan='14']"));
7466 $(".posticons [colspan='14']").children().wrap("<nobr></nobr>");
7467 $(".posticons [colspan='14']").appendTo('.posticons tr:eq(0)');
7468 $(".posticons [colspan='4']").remove();
7469 },
7470
7471 addForum: function () {
7472 $('<div class="smiley_box forum"><div>' +
7473 '<div class="box_header_left">' +
7474 '<span class="group standard active">' + getText("labels", "std") + '</span>' +
7475 '<span class="group grepolis">' + getText("labels", "gre") + '</span>' +
7476 '<span class="group nature">' + getText("labels", "nat") + '</span>' +
7477 '<span class="group people">' + getText("labels", "ppl") + '</span>' +
7478 '<span class="group other">' + getText("labels", "oth") + '</span>' +
7479 (SmileyBox.isHalloween ? '<span class="group halloween">' + getText("labels", "hal") + '</span>' : '') +
7480 (SmileyBox.isXmas ? '<span class="group xmas">' + getText("labels", "xma") + '</span>' : '') +
7481 '</div>' +
7482 '<div class="box_header_right"><a class="smiley_link" href="http://www.greensmilies.com/smilie-album/" target="_blank">WWW.GREENSMILIES.COM</a></div>' +
7483 '<hr>' +
7484 '<div class="box_content" style="overflow: hidden;"><hr></div>' +
7485 '</div></div><br>').insertAfter(".texteditor");
7486
7487 SmileyBox.addSmileys("standard", "");
7488
7489 $('.group').click(function () {
7490 $('.group.active').removeClass("active");
7491 $(this).addClass("active");
7492 // Change smiley group
7493 SmileyBox.addSmileys(this.className.split(" ")[1], "");
7494 });
7495 },
7496
7497 // add smiley box
7498 add: function (e) {
7499 var bbcodeBarId = "";
7500 switch (e) {
7501 case "/alliance_forum/forum":
7502 bbcodeBarId = "#forum";
7503 break;
7504 case "/message/forward":
7505 bbcodeBarId = "#message_bbcodes";
7506 break;
7507 case "/message/new":
7508 bbcodeBarId = "#message_bbcodes";
7509 break;
7510 case "/message/view":
7511 bbcodeBarId = "#message_bbcodes";//setWonderIconsOnMap
7512 break;
7513 case "/player_memo/load_memo_content":
7514 bbcodeBarId = "#memo_edit"; // old notes
7515 break;
7516 case "/frontend_bridge/fetch":
7517 bbcodeBarId = ".notes_container"; // TODO: new notes
7518 break;
7519 }
7520 if (($(bbcodeBarId + ' #emots_popup_7').get(0) || $(bbcodeBarId + ' #emots_popup_15').get(0)) && PID == 84367) {
7521 $(bbcodeBarId + " .bb_button_wrapper").get(0).lastChild.remove();
7522 }
7523 $('<img class="smiley_button" src="http://www.greensmilies.com/smile/smiley_emoticons_smile.gif">').appendTo(bbcodeBarId + ' .bb_button_wrapper');
7524
7525 $('<div class="smiley_box game">' +
7526 '<div class="bbcode_box middle_center"><div class="bbcode_box middle_right"></div><div class="bbcode_box middle_left"></div>' +
7527 '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div><div class="bbcode_box top_center"></div>' +
7528 '<div class="bbcode_box bottom_center"></div><div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>' +
7529 '<div class="box_header">' +
7530 '<span class="group standard active">' + getText("labels", "std") + '</span>' +
7531 '<span class="group grepolis">' + getText("labels", "gre") + '</span>' +
7532 '<span class="group nature">' + getText("labels", "nat") + '</span>' +
7533 '<span class="group people">' + getText("labels", "ppl") + '</span>' +
7534 '<span class="group ' + (SmileyBox.isHalloween ? 'halloween' : (SmileyBox.isXmas ? 'xmas' : 'other')) + '">' + getText("labels", (SmileyBox.isHalloween ? 'hal' : (SmileyBox.isXmas ? 'xma' : 'oth'))) + '</span>' +
7535 '</div>' +
7536 '<hr>' +
7537 '<div class="box_content"></div>' +
7538 '<hr>' +
7539 '<div class="box_footer"><a href="http://www.greensmilies.com/smilie-album/" target="_blank">WWW.GREENSMILIES.COM</a></div>' +
7540 '</div>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
7541
7542
7543 $(bbcodeBarId + ' .group').click(function () {
7544 $('.group.active').removeClass("active");
7545 $(this).addClass("active");
7546 // Change smiley group
7547 SmileyBox.addSmileys(this.className.split(" ")[1], "#" + $(this).closest('.bb_button_wrapper').parent().get(0).id);
7548 });
7549
7550 SmileyBox.addSmileys("standard", bbcodeBarId);
7551
7552 // smiley box toggle
7553 $(bbcodeBarId + " .smiley_button").toggleClick(
7554 function () {
7555 this.src = smileyArray.button[0].src;
7556 $(this).closest('.bb_button_wrapper').find(".smiley_box").get(0).style.display = "block";
7557 },
7558 function () {
7559 this.src = smileyArray.button[1].src;
7560 $(this).closest('.bb_button_wrapper').find(".smiley_box").get(0).style.display = "none";
7561 }
7562 );
7563 },
7564
7565 // insert smileys from arrays into smiley box
7566 addSmileys: function (type, bbcodeBarId) {
7567 // reset smilies
7568 if ($(bbcodeBarId + " .box_content").get(0)) {
7569 $(bbcodeBarId + " .box_content").get(0).innerHTML = '';
7570 }
7571 // add smilies
7572 for (var e in smileyArray[type]) {
7573 if (smileyArray[type].hasOwnProperty(e)) {
7574 $(smileyArray[type][e]).clone().appendTo(bbcodeBarId + " .box_content");
7575 //$('<img class="smiley" src="' + smileyArray[type][e].src + '" alt="" />').appendTo(bbcodeBarId + " .box_content");
7576 }
7577 }
7578 $('.smiley').css({margin: '0px', padding: '2px', maxHeight: '35px', cursor: 'pointer'});
7579
7580 $(bbcodeBarId + " .box_content .smiley").click(function () {
7581 var textarea;
7582 if (uw.location.pathname.indexOf("game") >= 0) {
7583 // hide smiley box
7584 $(this).closest('.bb_button_wrapper').find(".smiley_button").click();
7585 // find textarea
7586 textarea = $(this).closest('.gpwindow_content').find("textarea").get(0);
7587 } else {
7588
7589 if ($('.editor_textbox_container').get(0)) {
7590 textarea = $('.editor_textbox_container .cke_contents textarea').get(0);
7591 } else {
7592 $(this).appendTo('iframe .forum');
7593 }
7594 }
7595 var text = $(textarea).val();
7596 $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + "[img]" + this.src + "[/img]" + text.substring($(textarea).get(0).selectionEnd));
7597 });
7598 }
7599 };
7600
7601
7602 /*******************************************************************************************************************************
7603 * Biremes counter
7604 * ----------------------------------------------------------------------------------------------------------------------------
7605 * | â— Incremental update when calling a city (experimental, especially intended for siege worlds)
7606 * ----------------------------------------------------------------------------------------------------------------------------
7607 * @deprecated
7608 * *****************************************************************************************************************************/
7609
7610 // TODO: Altes Feature entfernen
7611 var BiremeCounter = {
7612 activate: function () {
7613 $(".picomap_container").prepend("<div id='available_units'><div id='bi_count'></div></div>");
7614
7615 $('.picomap_overlayer').tooltip(getText("options", "bir")[0]);
7616 BiremeCounter.update();
7617
7618 // Style
7619 $('<style id="dio_bireme_counter">' +
7620 '#available_units { background: url(https://gpall.innogamescdn.com/images/game/units/units_sprite_90x90_compressed.jpg); height:90px;' +
7621 'width:90px; position: relative; margin: 5px 28px 0px 28px; background-position: -270px 0px; } ' +
7622 '#bi_count { color:#826021; position:relative; top:28px; font-style:italic; width:79px; } ' +
7623 '#sea_id { background: none; font-size:25px; cursor:default; height:50px; width:50px; position:absolute; top:70px; left:157px; z-index: 30; } ' +
7624 '</style>').appendTo('head');
7625
7626 // fs_count: color: #FFC374;position: relative;top: 30px;font-style: italic;width: 101px;text-shadow: 1px 1px 0px rgb(69, 0, 0);
7627 // manti: background-position: -1350px 180px;
7628 // manti-count: color: #ECD181;position: relative;top: 48px;font-style: italic;width: 52px;text-shadow: 2px 2px 0px rgb(0, 0, 0);
7629 // medusa:-1440px 182px;
7630 // med-count: color: #DEECA4;position: relative;top: 50px;font-style: italic;width: 55px;text-shadow: 2px 2px 0px rgb(0, 0, 0);
7631
7632 // Set Sea-ID beside the bull eye
7633 $('#sea_id').prependTo('#ui_box');
7634 },
7635 deactivate: function () {
7636 $('#available_units').remove();
7637 $('#dio_bireme_counter').remove();
7638 $('#sea_id').appendTo('.picomap_container');
7639 },
7640 save: function () {
7641 saveValue(WID + "_biremes", JSON.stringify(biriArray));
7642 },
7643 update: function () {
7644 var sum = 0, e;
7645 if ($('#bi_count').get(0)) {
7646 for (e in biriArray) {
7647 if (biriArray.hasOwnProperty(e)) {
7648 if (!uw.ITowns.getTown(e)) { // town is no longer in possession of user
7649 delete biriArray[e];
7650 BiremeCounter.save();
7651 } else {
7652 sum += parseInt(biriArray[e], 10);
7653 }
7654 }
7655 }
7656
7657 sum = sum.toString();
7658 var str = "", fsize = ['1.4em', '1.2em', '1.15em', '1.1em', '1.0em'], i;
7659
7660 for (i = 0; i < sum.length; i++) {
7661 str += "<span style='font-size:" + fsize[i] + "'>" + sum[i] + "</span>";
7662 }
7663 $('#bi_count').get(0).innerHTML = "<b>" + str + "</b>";
7664 }
7665 },
7666 get: function () {
7667 var biremeIn = parseInt(uw.ITowns.getTown(uw.Game.townId).units().bireme, 10),
7668 biremeOut = parseInt(uw.ITowns.getTown(uw.Game.townId).unitsOuter().bireme, 10);
7669 if (isNaN(biremeIn)) biremeIn = 0;
7670 if (isNaN(biremeOut)) biremeOut = 0;
7671 if (!biriArray[uw.Game.townId] || biriArray[uw.Game.townId] < (biremeIn + biremeOut)) {
7672 biriArray[uw.Game.townId] = biremeIn;
7673 }
7674 BiremeCounter.update();
7675 BiremeCounter.save();
7676 },
7677 getDocks: function () {
7678 var windowID = uw.BuildingWindowFactory.getWnd().getID(),
7679 biremeTotal = parseInt($('#gpwnd_' + windowID + ' #unit_order_tab_bireme .unit_order_total').get(0).innerHTML, 10);
7680
7681 if (!isNaN(biremeTotal)) biriArray[uw.Game.townId] = biremeTotal;
7682 BiremeCounter.update();
7683 BiremeCounter.save();
7684 },
7685 getAgora: function () {
7686 var biremeTotal = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().bireme, 10);
7687 if (isNaN(biremeTotal)) biremeTotal = 0;
7688
7689 $('#units_beyond_list .bireme').each(function () {
7690 biremeTotal += parseInt(this.children[0].innerHTML, 10);
7691 });
7692 biriArray[uw.Game.townId] = biremeTotal;
7693 BiremeCounter.update();
7694 BiremeCounter.save();
7695 }
7696 };
7697
7698 /*******************************************************************************************************************************
7699 * Favor Popup
7700 * ----------------------------------------------------------------------------------------------------------------------------
7701 * | â— Improved favor popup
7702 * ----------------------------------------------------------------------------------------------------------------------------
7703 *******************************************************************************************************************************/
7704 var FavorPopup = {
7705 godArray: {
7706 zeus: '0px',
7707 hera: '-152px',
7708 poseidon: '-101px',
7709 athena: '-50px',
7710 hades: '-203px',
7711 artemis: '-305px'
7712 }, godImg: (new Image()).src = "https://diotools.de/images/game/gods.png",
7713
7714 activate: function () {
7715 $('.gods_favor_button_area, #favor_circular_progress').bind('mouseover mouseout', function () {
7716 return false;
7717 });
7718 $('.gods_area').bind('mouseover', function () {
7719 FavorPopup.setFavorPopup();
7720 });
7721 },
7722
7723 deactivate: function () {
7724 $('.gods_favor_button_area, #favor_circular_progress').unbind('mouseover mouseout');
7725 $('.gods_area').unbind('mouseover');
7726 },
7727
7728 setFavorPopup: function () {
7729 var pic_row = "", fav_row = "", prod_row = "", tooltip_str;
7730
7731 for (var g in FavorPopup.godArray) {
7732 if (FavorPopup.godArray.hasOwnProperty(g)) {
7733 if (uw.ITowns.player_gods.attributes.temples_for_gods[g]) {
7734 pic_row += '<td><div style="width:50px;height:51px;background:url(' + FavorPopup.godImg + ');background-position: 0px ' + FavorPopup.godArray[g] + ';"></td>';
7735 fav_row += '<td class="bold" style="color:blue">' + uw.ITowns.player_gods.attributes[g + "_favor"] + '</td>';
7736 prod_row += '<td class="bold">' + uw.ITowns.player_gods.attributes.production_overview[g].production + '</td>';
7737 }
7738 }
7739 }
7740 tooltip_str = $('<table><tr><td></td>' + pic_row + '</tr>' +
7741 '<tr align="center"><td><img src="https://gpall.innogamescdn.com/images/game/res/favor.png"></td>' + fav_row + '</tr>' +
7742 '<tr align="center"><td>+</td>' + prod_row + '</tr>' +
7743 '</table>');
7744
7745 $('.gods_favor_button_area, #favor_circular_progress').tooltip(tooltip_str);
7746 }
7747 };
7748
7749 /*******************************************************************************************************************************
7750 * GUI Optimization
7751 * ----------------------------------------------------------------------------------------------------------------------------
7752 * | â— Modified spell box (smaller, moveable & position memory)
7753 * | â— Larger taskbar and minimize daily reward-window on startup
7754 * | â— Modify chat
7755 * | â— Improved display of troops and trade activity boxes (movable with position memory on startup)
7756 * ----------------------------------------------------------------------------------------------------------------------------
7757 *******************************************************************************************************************************/
7758
7759 var Spellbox = {
7760 observe: function () {
7761 $.Observer(uw.GameEvents.ui.layout_gods_spells.rendered).subscribe('DIO_SPELLBOX_CHANGE_OPEN', function () {
7762 if (spellbox.show == false) {
7763 spellbox.show = true;
7764 saveValue("spellbox", JSON.stringify(spellbox));
7765 }
7766 Spellbox.change();
7767 });
7768 $.Observer(uw.GameEvents.ui.layout_gods_spells.state_changed).subscribe('DIO_SPELLBOX_CLOSE', function () {
7769 spellbox.show = false;
7770 saveValue("spellbox", JSON.stringify(spellbox));
7771 });
7772
7773 // GRCRT Bug-Fix
7774 if(typeof(RepConv) !== "undefined") {
7775 $.Observer(uw.GameEvents.ui.layout_gods_spells.rendered).unsubscribe('GRCRT_GRC_ui_layout_gods_spells_rendered');
7776
7777 $.Observer(uw.GameEvents.ui.layout_gods_spells.rendered).subscribe('GRCRT_GRC_ui_layout_gods_spells_rendered', function () {
7778 // PlayerGods doesn't exists at game start and the function would call an error
7779 if (typeof(RepConv.models.PlayerGods) !== "undefined") {
7780 RepConvTool.loadPower();
7781 }
7782 });
7783 }
7784 },
7785
7786 activate: function () {
7787 Spellbox.observe();
7788 Spellbox.change();
7789
7790 $('<style id="dio_spellbox_style" type="text/css">' +
7791 // Don't hide hero box, unit time box and hero coin box from GRC
7792 '#ui_box .nui_right_box { overflow: visible; } ' +
7793 // Hide negative spells
7794 '#ui_box .bolt, #ui_box .earthquake, #ui_box .pest { display: none } ' +
7795 // Change spell order
7796 '#ui_box .god_container { float: left } ' +
7797 '#ui_box .god_container[data-god_id="zeus"], #ui_box .god_container[data-god_id="athena"] { float: none } ' +
7798 // Remove background
7799 '#ui_box .powers_container { background: none !important } ' +
7800 // Hide god titles
7801 '#ui_box .content .title { display: none !important } ' +
7802 // Hide border elements
7803 '#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 } ' +
7804 // Layout
7805 '#ui_box .gods_area { height:150px } ' +
7806
7807 '#ui_box .gods_spells_menu { width: 134px; position:absolute; z-index:5000; padding:30px 0px 0px -4px } ' +
7808 '#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 } ' +
7809
7810 '#ui_box .nui_units_box { display:block; margin-top:-8px; position:relative } ' +
7811 '#ui_box .nui_units_box .bottom_ornament { margin-top:-28px; position: relative } ' +
7812 '</style>').appendTo('head');
7813
7814 // Draggable Box
7815 $("#ui_box .gods_spells_menu").draggable({
7816 containment: "body",
7817 distance: 10,
7818 snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, #island_quests_overview",
7819 opacity: 0.7,
7820 stop: function () {
7821 spellbox.top = this.style.top;
7822 spellbox.left = this.style.left;
7823
7824 saveValue("spellbox", JSON.stringify(spellbox));
7825 }
7826 });
7827 $("#ui_box .gods_spells_menu").before($('#ui_box .nui_units_box'));
7828
7829 // Position
7830 $('#ui_box .gods_spells_menu').css({
7831 left: spellbox.left,
7832 top: spellbox.top
7833 });
7834
7835 // Active at game start?
7836 if (spellbox.show && !$('#ui_box .btn_gods_spells').hasClass('active')) {
7837 $('#ui_box .btn_gods_spells').click();
7838 }
7839 },
7840 deactivate: function () {
7841 $('#ui_box .gods_spells_menu').draggable('destroy');
7842
7843 // Position
7844 $('#ui_box .gods_spells_menu').css({
7845 left: "auto",
7846 top: "150px"
7847 });
7848
7849 //$("#ui_box .gods_spells_menu").appendTo('gods_area'); // ?
7850
7851 $('#dio_spellbox_style').remove();
7852
7853 $.Observer(GameEvents.ui.layout_gods_spells.rendered).unsubscribe('DIO_SPELLBOX_CHANGE_OPEN');
7854 $.Observer(GameEvents.ui.layout_gods_spells.state_changed).unsubscribe('DIO_SPELLBOX_CLOSE');
7855 },
7856
7857 change: function () {
7858 //console.log("Unitsbox: "+ $(".nui_units_box").height());
7859 //console.log("Spellbox: "+ $(".gods_spells_menu").height());
7860
7861 // Change spell order
7862 $('#ui_box .god_container[data-god_id="poseidon"]').prependTo('#ui_box .gods_spells_menu .content');
7863 $('#ui_box .god_container[data-god_id="athena"]').appendTo('#ui_box .gods_spells_menu .content');
7864 $('#ui_box .god_container[data-god_id="artemis"]').appendTo('#ui_box .gods_spells_menu .content');
7865 }
7866
7867 };
7868
7869
7870 // Minimize Daily reward window on startup
7871 function minimizeDailyReward() {
7872 /*
7873 $.Observer(uw.GameEvents.window.open).subscribe('DIO_WINDOW', function(u,dato){});
7874 $.Observer(uw.GameEvents.window.reload).subscribe('DIO_WINDOW2', function(f){});
7875 */
7876 if (MutationObserver) {
7877 var startup = new MutationObserver(function (mutations) {
7878 mutations.forEach(function (mutation) {
7879 if (mutation.addedNodes[0]) {
7880 if ($('.daily_login').get(0)) { // && !uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).isMinimized()
7881 $('.daily_login').find(".minimize").click();
7882 //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).minimize();
7883 }
7884 }
7885 });
7886 });
7887 startup.observe($('body').get(0), {attributes: false, childList: true, characterData: false});
7888
7889 setTimeout(function () {
7890 startup.disconnect();
7891 }, 3000);
7892 }
7893 }
7894
7895 // Larger taskbar
7896 var Taskbar = {
7897 activate: function () {
7898 $('.minimized_windows_area').get(0).style.width = "150%";
7899 $('.minimized_windows_area').get(0).style.left = "-25%";
7900 },
7901 deactivate: function () {
7902 $('.minimized_windows_area').get(0).style.width = "100%";
7903 $('.minimized_windows_area').get(0).style.left = "0%";
7904 }
7905 };
7906
7907 // Hide fade out buttons
7908 function hideNavElements() {
7909 if (Game.premium_features.curator <= Timestamp.now()) {
7910 $('.nav').each(function () {
7911 this.style.display = "none";
7912 });
7913 }
7914 }
7915
7916 /*******************************************************************************************************************************
7917 * Chat
7918 *******************************************************************************************************************************/
7919
7920 var Chat = {
7921 user_colors : {},
7922
7923 delay : 10000,
7924
7925 timestamp : 0,
7926
7927 isWindowFocused : true,
7928
7929 isActivated : false,
7930
7931 isOpened : false,
7932
7933 activate : function(){
7934
7935 Chat.isActivated = true;
7936
7937 Chat.isOpened = true;
7938
7939 $('<style id="dio_chat_style">'+
7940 '#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; }'+
7941 '#dio_chat.resize { transition: left 0s; }'+
7942
7943 '#dio_chat .slider { width:100%; height: 6px; top:0; right:1px; position:absolute; margin-left:-8px; cursor: row-resize; }'+
7944
7945 '#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; }'+
7946 '#dio_chat .messagebox .time { float:left; color: #686; }'+
7947 '#dio_chat .messagebox .user { float:left; }'+
7948 '#dio_chat .messagebox .text { word-break: break-word; color: #797; }'+
7949
7950 '#dio_chat .messagebox .welcome .text { color: rgb(200,220,200); }'+
7951
7952 '#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; }'+
7953 '#dio_chat .togglebutton .top { height:4px; width:24px; background: url(https://diotools.de/images/game/button_sprite_vertical.png) 0px -1px; position:absolute;}'+
7954 '#dio_chat .togglebutton:hover .top { background-position: -25px -1px; }'+
7955 '#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; }'+
7956 '#dio_chat .togglebutton:hover .bottom { background-position: -25px 4px; }'+
7957 '#dio_chat .togglebutton .middle { height:100%; width:24px; background: url(https://diotools.de/images/game/button_sprite_vertical.png) -50px 0px; }'+
7958 '#dio_chat .togglebutton:hover .middle { background-position: -75px 0px; }'+
7959 '#dio_chat .togglebutton .arrow { position:absolute; left:6px; top:42.5%; }'+
7960
7961 '#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; }'+
7962
7963 '#dio_chat input { background: rgba(0, 0, 0, 0.5); color: white; border: 0px none; padding: 8px; width: 100%; border-right: 1px solid darkgreen; }'+
7964 '#dio_chat input:hover { background: rgba(0, 0, 10, 0.4); }'+
7965 '#dio_chat input:focus { background: rgba(0, 0, 10, 0.4); }'+
7966 '#dio_chat input::placeholder, '+
7967 '#dio_chat input::-webkit-input-placeholder, '+
7968 '#dio_chat input::-moz-placeholder, ' +
7969 '#dio_chat input:-ms-input-placeholder, '+
7970 '#dio_chat input:-moz-placeholder { color: black; }'+
7971
7972 // Chat im Menü ausblenden
7973 '.nui_main_menu ul { height:auto !important; }'+
7974 '.nui_main_menu li.chat { display:none !important; }'+
7975
7976 '#grcgrc { display:none }'+
7977
7978 '</style>').appendTo('head');
7979
7980 $('<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");
7981
7982 $('<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");
7983
7984 $('<div class="togglebutton"><div class="top"></div><div class="middle"><div class="arrow">â—„</div></div><div class="bottom"></div></div>').appendTo("#dio_chat");
7985
7986 // Texteingabe
7987 $('#dio_chat input').keypress(function(e) {
7988
7989 if (e.keyCode === 13) {
7990
7991 var _time = $('.server_time_area').get(0).innerHTML.split(" ")[0];
7992
7993 var _message = $(this).val();
7994
7995 if(_message.length > 0) {
7996
7997 Chat.sendMessage(_message);
7998
7999 $(this).val('');
8000 }
8001
8002 }
8003 });
8004
8005 /*
8006 $('#dio_chat').draggable({
8007 containment: "body",
8008 distance: 10,
8009 snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, #island_quests_overview",
8010 opacity: 0.7,
8011 stop: function () {}
8012 });
8013 */
8014
8015 // Ein-/Ausblenden der Chatbox
8016 $('#dio_chat .togglebutton').toggleClick(
8017 function () {
8018
8019 var x = -($(window).width() * 0.25 + 16);
8020
8021 $('#dio_chat').css("left", x);
8022
8023 setTimeout(function(){
8024 $('#dio_chat .togglebutton .arrow').get(0).innerHTML = "â–º";
8025 },1300);
8026
8027 // Tooltip
8028 $('#dio_chat .togglebutton').tooltip("Chat öffnen");
8029
8030 },
8031 function (){
8032
8033 $('#dio_chat').css("left", 0);
8034
8035 setTimeout(function(){
8036 $('#dio_chat .togglebutton .arrow').get(0).innerHTML = "â—„";
8037 },1300);
8038
8039 // Tooltip
8040 $('#dio_chat .togglebutton').tooltip("Chat schließen");
8041 }
8042 );
8043 // Wenn sich die Fenstergröße ändert
8044
8045 $(window).on("resize.dio", function(){
8046
8047 if($('#dio_chat').css("left") !== "0px"){
8048
8049 var x = -($(window).width() * 0.25 + 16);
8050
8051 $('#dio_chat').addClass("resize");
8052 $('#dio_chat').css("left", x);
8053
8054 setTimeout(function(){
8055 $('#dio_chat').removeClass("resize");
8056 },0);
8057 }
8058 });
8059
8060 // Tooltip
8061 $('#dio_chat .togglebutton').tooltip("Chat schließen");
8062
8063 // Skalierung der Höhe
8064 $('#dio_chat .slider').mousedown(function (e) {
8065 e.preventDefault();
8066
8067 $('#dio_chat .messagebox').css("max-height", "none");
8068
8069 $(document).on("mousemove.dio", function (e) {
8070 e.preventDefault();
8071
8072 var x = $(window).height() - e.pageY - 49;
8073
8074 if (x > 30 && x < $(window).height() - 400) {
8075 $('#dio_chat .messagebox').css("height", x );
8076 }
8077 });
8078 });
8079
8080 $(document).on("mouseup.dio", function (e) {
8081 $(document).off("mousemove.dio");
8082
8083 //$('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollTopMax;
8084 $('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollHeight
8085 });
8086
8087
8088
8089 Chat.timestamp = Timestamp.server();
8090
8091 // Initialer Start
8092 Chat.getMessages();
8093
8094
8095 // Öfter anfragen, wenn man chatten will
8096 $('#dio_chat').hover(function(){
8097
8098 if(Chat.isOpened === true) {
8099 Chat.delay = 3000; // 3s
8100
8101 clearTimeout(Chat.timeout_A);
8102 clearTimeout(Chat.timeout_B);
8103 }
8104
8105 }, function(){
8106
8107 if(Chat.isOpened === true) {
8108
8109 Chat.delay = 10000; // 10s
8110
8111 // Nach 5min nur noch alle 30s
8112 Chat.timeout_A = setTimeout(function () {
8113 Chat.delay = 30000;
8114 }, 300000);
8115
8116 // Nach 15min nur noch alle 60s
8117 Chat.timeout_B = setTimeout(function () {
8118 Chat.delay = 60000;
8119 }, 900000);
8120 }
8121 });
8122
8123 // Nur wenn Grepolis offen ist aktualisieren
8124 $(window).on("focus.dio", function() {
8125 Chat.isWindowFocused = true;
8126
8127 if(Chat.isOpened === true) {
8128
8129 Chat.getMessages();
8130
8131 Chat.delay = 10000; // 10s
8132
8133 clearTimeout(Chat.timeout_A);
8134 clearTimeout(Chat.timeout_B);
8135
8136 // Nach 5min nur noch alle 30s
8137 Chat.timeout_A = setTimeout(function () {
8138 Chat.delay = 30000;
8139 }, 300000);
8140
8141 // Nach 15min nur noch alle 60s
8142 Chat.timeout_B = setTimeout(function () {
8143 Chat.delay = 60000;
8144 }, 900000);
8145 }
8146
8147 }).on("blur.dio", function() {
8148 Chat.isWindowFocused = false;
8149 });
8150 },
8151 deactivate : function(){
8152 Chat.isActivated = false;
8153
8154 $('#dio_chat_style').remove();
8155 $('#dio_chat').remove();
8156
8157 // Events disconnecten
8158 $(document).off('mouseup.dio');
8159 $(window).off('focus.dio');
8160 $(window).off('blur.dio');
8161 $(window).off('resize.dio');
8162 },
8163 sendMessage : function(_message){
8164
8165 _message = encodeURIComponent(_message.replace(/'/g, "'").replace(/ /g, " "));
8166
8167 $.ajax({
8168 type: "GET",
8169 url: "https://diotools.de/php/sendMessage.php?world=" + Game.world_id + "&time=" + Timestamp.server() + "&player="+ Game.player_name +"&message="+ _message,
8170 dataType: 'text',
8171 success: function (response) {
8172 console.debug("Nachricht wurde erfolgreich gesendet");
8173
8174 //$('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollTopMax;
8175 $('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollHeight
8176
8177 Chat.getMessages();
8178 },
8179 error: function (e) {
8180 console.debug("Nachricht konnte nicht gesendet werden", e);
8181 }
8182 });
8183 },
8184 getMessages : function(){
8185
8186 if(Chat.isActivated === true) {
8187
8188 var _currentTimestamp = Timestamp.server();
8189
8190 var _url = "https://diotools.de/php/getMessages.php?world=" + Game.world_id;
8191
8192 if (typeof(Chat.lastID) !== "undefined") {
8193 _url += "&id=" + Chat.lastID;
8194 }
8195 else {
8196 _url += "&time=" + Chat.timestamp;
8197 }
8198
8199 // Eventuell noch nicht gefeuertes Timeout entfernen
8200 clearTimeout(Chat.timeout);
8201
8202 if (Chat.isWindowFocused) {
8203 $.ajax({
8204 type: "GET",
8205 url: _url,
8206 dataType: 'json',
8207 success: function (_messages) {
8208 if(Chat.isActivated === true) {
8209
8210 // Letzte Abfragezeit speichern
8211 Chat.timestamp = _currentTimestamp;
8212
8213 // console.debug("GET MESSAGES", _messages);
8214
8215 /*
8216 var _scrollDown = false;
8217 if ($('#dio_chat .messagebox')[0].scrollTop === $('#dio_chat .messagebox')[0].scrollTopMax) {
8218 _scrollDown = true;
8219 }
8220 */
8221
8222 for (var m in _messages) {
8223 if (_messages.hasOwnProperty(m)) {
8224
8225 if (typeof(_messages[m].last_id) === "undefined") {
8226
8227 // HTML-Tags ersetzen
8228 var _message = _messages[m].message.replace(/</g, '<').replace(/>/g, '>').replace(/'/g, "\'");
8229
8230 $('#dio_chat .messagebox').append(
8231 '<div class="time">' + Chat.formatTime(_messages[m].time) + ': </div>' +
8232 '<div class="user" style="color:' + Chat.getUserColor(_messages[m].player) + '">' + _messages[m].player + ': </div>' +
8233 '<div class="text"> ' + _message + ' </div>'
8234 );
8235 }
8236 else {
8237 Chat.lastID = _messages[m].last_id;
8238 }
8239 }
8240 }
8241
8242 clearTimeout(Chat.timeout);
8243
8244 Chat.timeout = setTimeout(function () {
8245
8246 if (Chat.isWindowFocused) {
8247 Chat.getMessages();
8248 }
8249
8250 }, Chat.delay);
8251
8252 //if(_scrollDown) {
8253 // $('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollTopMax;
8254 $('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollHeight
8255 //}
8256 }
8257 },
8258 error: function (xhr) {
8259 console.debug("Nachrichten konnten nicht geladen werden", xhr);
8260
8261 clearTimeout(Chat.timeout);
8262
8263 Chat.timeout = setTimeout(function () {
8264
8265 Chat.getMessages();
8266
8267 }, Chat.delay);
8268
8269 }
8270 });
8271
8272 }
8273 }
8274 },
8275 getUserColor : function(_user){
8276
8277 if(typeof(Chat.user_colors[_user]) === "undefined") {
8278
8279 var r = Math.floor(Math.random() * 255);
8280 var g = Math.floor(Math.random() * 255);
8281 var b = Math.floor(Math.random() * 255);
8282
8283 // Bei zu dunkler Farbe neue Farbe ermitteln
8284 if (r + g < 200 && r < 130 && g < 130) {
8285
8286 return Chat.getUserColor(_user);
8287 }
8288
8289 Chat.user_colors[_user] = 'rgb(' + r + ',' + g + ',' + b + ')';
8290 }
8291
8292 return Chat.user_colors[_user];
8293 },
8294 formatTime : function(_timestamp){
8295
8296 var date = new Date(_timestamp*1000);
8297
8298 // Hours part from the timestamp
8299 var hours = "0" + date.getHours();
8300 // Minutes part from the timestamp
8301 var minutes = "0" + date.getMinutes();
8302 // Seconds part from the timestamp
8303 var seconds = "0" + date.getSeconds();
8304
8305 // Will display time in 10:30:23 format
8306 return hours.substr(-2) + ':' + minutes.substr(-2) + ':' + seconds.substr(-2);
8307 }
8308 };
8309
8310 /*******************************************************************************************************************************
8311 * Activity boxes
8312 * ----------------------------------------------------------------------------------------------------------------------------
8313 * | â— Show troops and trade activity boxes
8314 * | â— Boxes are magnetic & movable (position memory)
8315 * ----------------------------------------------------------------------------------------------------------------------------
8316 *******************************************************************************************************************************/
8317 var mut_toolbar, mut_command, mut_trade;
8318
8319 var save_command_mouseout,
8320 save_commandlist_mouseout,
8321 save_trade_mouseout,
8322 save_tradelist_mouseout,
8323
8324 save_command_mouseover,
8325 save_trade_mouseover;
8326
8327
8328 var ActivityBoxes = {
8329 activate: function () {
8330 ActivityBoxes.checkToolbarAtStart();
8331
8332 $('#toolbar_activity_commands_list').css({
8333 left: commandbox.left + "px",
8334 top: commandbox.top + "px"
8335 });
8336
8337 $('<style id="fix_lists" type="text/css">' +
8338 '#toolbar_activity_commands_list, #toolbar_activity_trades_list { width: 160px}' +
8339 '.dropdown-list .content { max-height: 329px}' +
8340 '</style>' +
8341 '<style id="dio_fix_trade" type="text/css">' +
8342 '#toolbar_activity_trades_list {' +
8343 'left:' + tradebox.left + 'px !important;' +
8344 'top: ' + tradebox.top + 'px !important}' +
8345 '</style>').appendTo('head');
8346
8347
8348 ActivityBoxes.draggableTradeBox();
8349 ActivityBoxes.draggableCommandBox();
8350
8351 ActivityBoxes.catchToolbarEvents();
8352 },
8353 deactivate: function () {
8354 ActivityBoxes.hideTradeList();
8355 ActivityBoxes.hideCommandList();
8356
8357 mut_toolbar.disconnect();
8358 mut_command.disconnect();
8359 mut_trade.disconnect();
8360 },
8361 showTradeList: function () {
8362 if (!$('#dio_trades_activity_style').get(0)) {
8363 $('#toolbar_activity_trades').mouseover();
8364 $('<style id="dio_trades_activity_style"> #toolbar_activity_trades_list { display: block !important; } </style>').appendTo("head");
8365 }
8366 },
8367 showCommandList: function () {
8368 if (!$('#dio_commands_activity_style').get(0)) {
8369 $('#toolbar_activity_commands').mouseover();
8370 $('<style id="dio_commands_activity_style"> #toolbar_activity_commands_list { ' +
8371 'display:block !important; left:' + commandbox.left + 'px; top:' + commandbox.top + 'px; }' +
8372 '</style>').appendTo("head");
8373 }
8374 },
8375 hideTradeList: function () {
8376 if ($('#dio_trades_activity_style').get(0)) {
8377 $('#dio_trades_activity_style').remove();
8378 $('#toolbar_activity_trades').mouseout();
8379 }
8380 },
8381 hideCommandList: function () {
8382 if ($('#dio_commands_activity_style').get(0)) {
8383 $('#dio_commands_activity_style').remove();
8384 $('#toolbar_activity_commands').mouseout();
8385 }
8386 },
8387 activate2: function () {
8388 var observe_options = {attributes: false, childList: true, characterData: false};
8389
8390 ActivityBoxes.catchToolbarEvents();
8391
8392 mut_command.observe($('.toolbar_activities .commands .count').get(0), observe_options);
8393 mut_trade.observe($('.toolbar_activities .trades .count').get(0), observe_options);
8394
8395 $('<style id="dio_activity_style"> ' +
8396 '#toolbar_activity_commands_list.active { display: block !important; } ' +
8397 '#toolbar_activity_trades_list.active { display: block !important; } ' +
8398 '</style>').appendTo("head");
8399
8400
8401 $('#toolbar_activity_commands').mouseover();
8402 $('#toolbar_activity_trades').mouseover();
8403
8404 $('#toolbar_activity_commands, #toolbar_activity_trades').off("mouseover");
8405
8406 $('#toolbar_activity_commands, #toolbar_activity_commands_list, #toolbar_activity_trades, #toolbar_activity_trades_list').off("mouseout");
8407
8408 $('#toolbar_activity_trades_list').unbind("click");
8409 //console.log($('#toolbar_activity_commands').data('events')["dd:list:show"][0].handler());
8410
8411 ActivityBoxes.checkToolbarAtStart();
8412
8413 $('#toolbar_activity_commands_list').css({
8414 left: commandbox.left + "px",
8415 top: commandbox.top + "px"
8416 });
8417
8418 $('<style id="fix_lists" type="text/css">' +
8419 '#toolbar_activity_commands_list, #toolbar_activity_trades_list { width: 160px}' +
8420 '.dropdown-list .content { max-height: 329px}' +
8421 '</style>' +
8422 '<style id="dio_fix_trade" type="text/css">' +
8423 '#toolbar_activity_trades_list {' +
8424 'left:' + tradebox.left + 'px !important;' +
8425 'top: ' + tradebox.top + 'px !important}' +
8426 '</style>').appendTo('head');
8427
8428 ActivityBoxes.draggableCommandBox();
8429 ActivityBoxes.draggableTradeBox();
8430
8431
8432 /*
8433 $('.toolbar_activities .commands').on("mouseover.bla", function(){
8434 $('#toolbar_activity_commands_list').addClass("active");
8435 });
8436
8437 $('.toolbar_activities .trades').mouseover(function(){
8438 $('#toolbar_activity_trades_list').addClass("active");
8439 });
8440 */
8441 },
8442 deactivate2: function () {
8443 mut_toolbar.disconnect();
8444 mut_command.disconnect();
8445 mut_trade.disconnect();
8446 /*
8447 $('#toolbar_activity_commands').on("mouseover", save_command_mouseover);
8448 $('#toolbar_activity_trades').on("mouseover", save_trade_mouseover);
8449
8450 $('#toolbar_activity_commands').on("mouseout", save_command_mouseout);
8451 $('#toolbar_activity_commands_list').on("mouseout", save_commandlist_mouseout);
8452 $('#toolbar_activity_trades').on("mouseout", save_trade_mouseout);
8453 $('#toolbar_activity_trades_list').on("mouseout", save_tradelist_mouseout);
8454 */
8455
8456 $('#toolbar_activity_commands').mouseover = save_command_mouseover;
8457 $('#toolbar_activity_trades').mouseover = save_trade_mouseover;
8458
8459 $('#toolbar_activity_commands').mouseout = save_command_mouseout;
8460 $('#toolbar_activity_commands_list').mouseout = save_commandlist_mouseout;
8461 $('#toolbar_activity_trades').mouseout = save_trade_mouseout;
8462 $('#toolbar_activity_trades_list').mouseout = save_tradelist_mouseout;
8463
8464
8465 $('#toolbar_activity_trades_list').removeClass("active");
8466 $('#toolbar_activity_commands_list').removeClass("active");
8467 /*
8468 $('.toolbar_activities .commands').off("mouseover.bla");
8469 */
8470 $('#dio_activity_style').remove();
8471
8472
8473 },
8474 checkToolbarAtStart: function () {
8475 if (parseInt($('.toolbar_activities .commands .count').get(0).innerHTML, 10) > 0) {
8476 ActivityBoxes.showCommandList();
8477 } else {
8478 ActivityBoxes.hideCommandList();
8479 }
8480 if (parseInt($('.toolbar_activities .trades .count').get(0).innerHTML, 10) > 0) {
8481 ActivityBoxes.showTradeList();
8482 } else {
8483 ActivityBoxes.hideTradeList();
8484 }
8485 },
8486 catchToolbarEvents: function () {
8487 var observe_options = {attributes: false, childList: true, characterData: false};
8488
8489 mut_toolbar = new MutationObserver(function (mutations) {
8490 mutations.forEach(function (mutation) {
8491 if (mutation.addedNodes[0]) {
8492 //console.debug(mutation.target.id);
8493 if (mutation.target.id === "toolbar_activity_trades_list") {
8494 ActivityBoxes.draggableTradeBox();
8495 } else {
8496 ActivityBoxes.draggableCommandBox();
8497 }
8498 mutation.addedNodes[0].remove();
8499 }
8500 });
8501 });
8502 //mut_toolbar.observe($('#toolbar_activity_commands_list').get(0), observe_options );
8503 //mut_toolbar.observe($('#toolbar_activity_trades_list').get(0), observe_options );
8504
8505 mut_command = new MutationObserver(function (mutations) {
8506 mutations.forEach(function (mutation) {
8507 if (mutation.addedNodes[0]) {
8508 //console.debug(mutation.addedNodes[0].nodeValue);
8509 if (mutation.addedNodes[0].nodeValue > 0) {
8510 ActivityBoxes.showCommandList();
8511 } else {
8512 //console.debug("hide commands");
8513 ActivityBoxes.hideCommandList();
8514 }
8515 }
8516 });
8517 });
8518 mut_trade = new MutationObserver(function (mutations) {
8519 mutations.forEach(function (mutation) {
8520 if (mutation.addedNodes[0]) {
8521 if (mutation.addedNodes[0].nodeValue > 0) {
8522 ActivityBoxes.showTradeList();
8523 } else {
8524 ActivityBoxes.hideTradeList();
8525 }
8526 }
8527 });
8528 });
8529 mut_command.observe($('.toolbar_activities .commands .count').get(0), observe_options);
8530 mut_trade.observe($('.toolbar_activities .trades .count').get(0), observe_options);
8531 },
8532 // Moveable boxes
8533 draggableTradeBox: function () {
8534 $("#toolbar_activity_trades_list").draggable({
8535 containment: "body",
8536 distance: 20,
8537 snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, .nui_left_box",
8538 opacity: 0.7,
8539 start: function () {
8540 $("#dio_fix_trade").remove();
8541 },
8542 stop: function () {
8543 var pos = $('#toolbar_activity_trades_list').position();
8544
8545 tradebox.left = pos.left;
8546 tradebox.top = pos.top;
8547
8548 saveValue("tradebox", JSON.stringify(tradebox));
8549
8550 $('<style id="dio_fix_trade" type="text/css">' +
8551 '#toolbar_activity_trades_list { left:' + tradebox.left + 'px !important; top:' + tradebox.top + 'px !important; } ' +
8552 '</style>').appendTo('head');
8553 }
8554 });
8555 },
8556 draggableCommandBox: function () {
8557 $("#toolbar_activity_commands_list").draggable({
8558 containment: "body",
8559 distance: 20,
8560 snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, .nui_left_box",
8561 opacity: 0.7,
8562 stop: function () {
8563 var pos = $('#toolbar_activity_commands_list').position();
8564 commandbox.left = pos.left;
8565 commandbox.top = pos.top;
8566
8567 saveValue("commandbox", JSON.stringify(commandbox));
8568 }
8569 });
8570 }
8571 };
8572
8573 /*******************************************************************************************************************************
8574 * Counter
8575 *******************************************************************************************************************************/
8576
8577 function counter(time) {
8578 var type = "", today, counted, year, month, day;
8579 if (uw.Game.market_id !== "zz") {
8580 counted = DATA.count;
8581 today = new Date((time + 7200) * 1000);
8582 year = today.getUTCFullYear();
8583 month = ((today.getUTCMonth() + 1) < 10 ? "0" : "") + (today.getUTCMonth() + 1);
8584 day = (today.getUTCDate() < 10 ? "0" : "") + today.getUTCDate();
8585 today = year + month + day;
8586 //console.log(today);
8587 if (counted[0] !== today) {
8588 type += "d";
8589 }
8590 if (counted[1] == false) {
8591 type += "t";
8592 }
8593 if ((counted[2] == undefined) || (counted[2] == false)) {
8594 type += "b";
8595 }
8596 if (type !== "") {
8597 $.ajax({
8598 type: "GET",
8599 url: "https://diotools.de/game/count.php?type=" + type + "&market=" + uw.Game.market_id + "&date=" + today + "&browser=" + getBrowser(),
8600 dataType: 'text',
8601 success: function (text) {
8602 if (text.indexOf("dly") > -1) {
8603 counted[0] = today;
8604 }
8605 if (text.indexOf("tot") > -1) {
8606 counted[1] = true;
8607 }
8608 if (text.indexOf("bro") > -1) {
8609 counted[2] = true;
8610 }
8611 saveValue("dio_count", JSON.stringify(counted));
8612 }
8613 });
8614 }
8615 }
8616 }
8617
8618
8619 /*******************************************************************************************************************************
8620 * Political Map
8621 *******************************************************************************************************************************/
8622
8623 var PoliticalMap = {
8624 data: null,
8625 activate: function () {
8626 $('<div id="dio_political_map">' +
8627 '<div class="canvas_wrapper"></div>' +
8628 '<select class="zoom_select">' +
8629 '<option value="0.50">1 : 0.50</option>' +
8630 '<option value="0.75">1 : 0.75</option>' +
8631 '<option value="1.00" selected>1 : 1.00</option>' +
8632 '<option value="1.25">1 : 1.25</option>' +
8633 '<option value="1.50">1 : 1.50</option>' +
8634 '<option value="2.00">1 : 2.00</option>' +
8635 '<option value="3.00">1 : 3.00</option>' +
8636 '</select>' +
8637 '<div class="legend sandy-box">' +
8638 '<div class="corner_tl"></div>' +
8639 '<div class="corner_tr"></div>' +
8640 '<div class="corner_bl"></div>' +
8641 '<div class="corner_br"></div>' +
8642 '<div class="border_t"></div>' +
8643 '<div class="border_b"></div>' +
8644 '<div class="border_l"></div>' +
8645 '<div class="border_r"></div>' +
8646 '<div class="middle"></div>' +
8647 '<div class="content"><div class="item"></div></div>' +
8648 '</div></div>').appendTo('#ui_box');
8649
8650 // Style
8651 $('<style id="dio_political_map_style">' +
8652 '#dio_political_map { width:100%; height:100%; z-index:3; background:#123d70; display:none; position:absolute; top:0; } ' +
8653 '#dio_political_map.active { display: block; } ' +
8654 '#dio_political_map .canvas_wrapper { } ' +
8655 '#dio_political_map canvas { position: absolute; cursor:move; top:0; left:0; } ' +
8656 '#dio_political_map .zoom_select { position:absolute; top:70px; left:300px; font-size: 2em; opacity:0.5; } ' +
8657 '#dio_political_map .zoom_select:hover { opacity:1; } ' +
8658 '#dio_political_map .legend { position:absolute; right:200px; top:50px; width:200px; height:auto; text-align:left; } ' +
8659 '#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; } ' +
8660 '#dio_political_map .legend .wonder_icon { float: left; margin: 4px; } ' +
8661
8662 '.btn_political_map { top:56px; left:-4px; z-index:10; position:absolute; } ' +
8663
8664 '.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%; } ' +
8665 // http://s14.directupload.net/images/140408/k4wikrlq.png // http://s7.directupload.net/images/140408/ahfr8227.png
8666 '.btn_political_map .ico_political_map.checked { margin-top:8px; } ' +
8667 '</style>').appendTo('head');
8668
8669 PoliticalMap.addButton();
8670
8671 var zoomSelect = $('.zoom_select');
8672
8673 zoomSelect.change(function () {
8674 //PoliticalMap.zoomToCenter();
8675 });
8676 zoomSelect.on("change", function () {
8677 PoliticalMap.zoomToCenter();
8678 });
8679
8680 ColorPicker.init();
8681 },
8682 deactivate: function () {
8683 $('.btn_political_map').remove();
8684 $('#dio_political_map_style').remove();
8685 },
8686 addButton: function () {
8687 var m_ZoomFactor = 1.0;
8688 $('<div class="btn_political_map circle_button" name="political_map"><div class="ico_political_map js-caption"></div></div>').appendTo(".bull_eye_buttons");
8689
8690 var politicalMapButton = $('.btn_political_map');
8691
8692 // Tooltip
8693 politicalMapButton.tooltip("Political Map"); // TODO: Language
8694
8695 // Events
8696 politicalMapButton.on('mousedown', function () {
8697 //$('.btn_political_map, .ico_political_map').addClass("checked");
8698 }).on('mouseup', function () {
8699 //$('.btn_political_map, .ico_political_map').removeClass("checked");
8700 });
8701
8702 $('.rb_map .option').click(function () {
8703 $('.btn_political_map, .ico_political_map').removeClass("checked");
8704 $('#dio_political_map').removeClass("active");
8705 $(this).addClass("checked");
8706 });
8707
8708 politicalMapButton.click(function () {
8709 $('.rb_map .checked').removeClass("checked");
8710 $('.btn_political_map, .ico_political_map').addClass("checked");
8711 $('#dio_political_map').addClass("active");
8712
8713 if ($('#dio_political_map').hasClass("active")) {
8714 if (PoliticalMap.data == null) {
8715 $('#ajax_loader').css({visibility: "visible"});
8716 // Map-Daten aus DB auslesen
8717 PoliticalMap.loadMapData();
8718 } else {
8719 //PoliticalMap.drawMap(PoliticalMap.data);
8720 }
8721 }
8722 });
8723 },
8724 /**
8725 * Läd die Allianzen und Inseln aus der Datenbank
8726 * @since 3.0
8727 */
8728 loadMapData: function () {
8729 $.ajax({
8730 type: "GET",
8731 url: "https://diotools.de/php/map.php?world_id=" + WID + "&callback=jsonCallback",
8732 //dataType: 'jsonp',
8733 //async: false,
8734 //jsonpCallback: 'jsonCallback',
8735 //contentType: "application/json",
8736 success: function (response) {
8737 if (response !== "") {
8738 PoliticalMap.data = response;
8739
8740 var m_ZoomFactor = $('.zoom_select').get(0)[$('.zoom_select').get(0).selectedIndex].selected;
8741
8742 PoliticalMap.drawMap(PoliticalMap.data, m_ZoomFactor);
8743 PoliticalMap.drawWonders(PoliticalMap.data, m_ZoomFactor);
8744
8745 $('#ajax_loader').css({visibility: "hidden"});
8746
8747 // Überprüfen, ob die Weltdaten geupdatet werden müssen
8748 $.ajax({
8749 type: "GET",
8750 url: "https://diotools.de/php/update_db.php?world_id=" + WID
8751 });
8752 } else {
8753 // Welt existiert noch nicht in DB
8754 $.ajax({
8755 type: "GET", url: "https://diotools.de/php/update_db.php?world_id=" + WID,
8756 success: function () {
8757 // Map-Daten aus DB auslesen, wenn die Weltdaten erfolgreich in die DB geladen wurden
8758 $.ajax({
8759 type: "GET",
8760 url: "https://diotools.de/php/map.php?world_id=" + WID,
8761 success: function (response) {
8762 PoliticalMap.data = response;
8763
8764 var m_ZoomFactor = $('.zoom_select').get(0)[$('.zoom_select').get(0).selectedIndex].selected;
8765
8766 PoliticalMap.drawMap(PoliticalMap.data, m_ZoomFactor);
8767 PoliticalMap.drawWonders(PoliticalMap.data, m_ZoomFactor);
8768
8769 $('#ajax_loader').css({visibility: "hidden"});
8770 }
8771 });
8772 }
8773 });
8774 }
8775 }
8776 });
8777 },
8778 /**
8779 * Ändert die Zoomstufe der Karte zum Zentrum hin
8780 *
8781 * @param _zoom
8782 * @since 3.0
8783 */
8784 zoomToCenter: function () {
8785 var _zoom = $('.zoom_select').get(0)[$('.zoom_select').get(0).selectedIndex].value;
8786
8787 var canvas = $('#dio_political_map canvas'),
8788
8789 canvas_size = parseInt($('#dio_political_map canvas').width(), 10); // Breite und Höhe sind immer gleich
8790
8791 var canvas_style = $('#dio_political_map .canvas_wrapper').get(0).style;
8792
8793 // Berechnung: Alter Abstand + (1000 * Zoomänderung / 2)
8794 canvas_style.top = parseInt(canvas_style.top, 10) + (1000 * (canvas_size / 1000 - _zoom)) / 2 + "px";
8795 canvas_style.left = parseInt(canvas_style.left, 10) + (1000 * (canvas_size / 1000 - _zoom)) / 2 + "px";
8796
8797 PoliticalMap.clearMap();
8798 PoliticalMap.drawMap(PoliticalMap.data, _zoom);
8799 PoliticalMap.drawWonders(PoliticalMap.data, _zoom);
8800
8801 },
8802 /**
8803 * Ändert die Zoomstufe der Karte zur Cursorposition hin
8804 *
8805 * @param _zoom
8806 * @param _pos
8807 *
8808 * @since 3.0
8809 */
8810 zoomToCursorPosition: function (_zoom, _pos) {
8811
8812 },
8813 /**
8814 * Zeichnet die Karte in ein Canvas
8815 *
8816 * @param _islandArray {Array}
8817 * @param _zoom {int}
8818 *
8819 * @since 3.0
8820 */
8821 drawMap: function (_islandArray, _zoom) {
8822
8823 $('<canvas class="canv_map" height="' + (1000 * _zoom) + 'px" width="' + (1000 * _zoom) + "px\"></canvas>").prependTo('.canvas_wrapper')
8824
8825 // TODO: Weite und Höhe vom Fenster ermitteln, Update Containment bei onResizeWindow
8826 $('#dio_political_map .canvas_wrapper').draggable({
8827 // left, top, right, bottom
8828 //containment: [-500 * _zoom, -300 * _zoom, 500 * _zoom, 300 * _zoom],
8829 distance: 10,
8830 grid: [100 * _zoom, 100 * _zoom],
8831 //limit: 500,
8832 cursor: 'pointer'
8833 });
8834
8835 var ally_ranking = JSON.parse(_islandArray)['ally_ranking'];
8836 var island_array = JSON.parse(_islandArray)['ally_island_array'];
8837
8838
8839 var c = $('#dio_political_map .canv_map')[0].getContext('2d');
8840
8841 // Grid
8842 c.strokeStyle = 'rgb(0,100,0)';
8843
8844 for (var l = 0; l <= 10; l++) {
8845 // Horizontal Line
8846 c.moveTo(0, l * 100 * _zoom);
8847 c.lineTo(1000 * _zoom, l * 100 * _zoom);
8848 c.stroke();
8849
8850 // Vertical Line
8851 c.moveTo(l * 100 * _zoom, 0);
8852 c.lineTo(l * 100 * _zoom, 1000 * _zoom);
8853 c.stroke();
8854 }
8855
8856 // Center Circle
8857 c.beginPath();
8858 c.arc(500 * _zoom, 500 * _zoom, 100 * _zoom, 0, Math.PI * 2, true);
8859 c.fillStyle = 'rgba(0,100,0,0.2)';
8860 c.fill();
8861 c.stroke();
8862
8863 // Sea numbers
8864 c.fillStyle = 'rgb(0,100,0)';
8865
8866 for (var y = 0; y <= 10; y++) {
8867 for (var x = 0; x <= 10; x++) {
8868 c.fillText(y + "" + x, y * 100 * _zoom + 2, x * 100 * _zoom + 10);
8869 }
8870 }
8871
8872 // Alliance Colors
8873 var colorArray = ["#00A000", "yellow", "red", "rgb(255, 116, 0)", "cyan", "#784D00", "white", "purple", "#0078FF", "deeppink", "darkslategrey"];
8874
8875 // Islands
8876 for (var t in island_array) {
8877 if (island_array.hasOwnProperty(t)) {
8878 var tmp_points = 0, dom_ally = "";
8879 for (var ally in island_array[t]) {
8880 if (island_array[t].hasOwnProperty(ally)) {
8881 if (tmp_points < island_array[t][ally] && (ally !== "X") && (ally !== "")) {
8882 tmp_points = island_array[t][ally];
8883 dom_ally = ally;
8884 }
8885 }
8886 }
8887
8888 c.fillStyle = colorArray[parseInt(ally_ranking[dom_ally], 10) - 1] || "darkslategrey";
8889 //c.fillRect(t.split("x")[0] * _zoom, t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
8890
8891 //c.beginPath();
8892 //console.info(island_array[t]);
8893 //c.arc(t.split("x")[0], t.split("x")[1], 2, 0, Math.PI * 2, true);
8894 //c.fillRect(t.split("x")[0] * _zoom,t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
8895 //c.fill();
8896
8897 // TEST HEATMAP
8898 //console.debug("Blaaa", c.fillStyle);
8899 if (c.fillStyle !== "#2f4f4f") {
8900 var color = c.fillStyle;
8901
8902 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);
8903 radgrad.addColorStop(0, PoliticalMap.convertHexToRgba(color, 0.2));
8904 radgrad.addColorStop(0.6, PoliticalMap.convertHexToRgba(color, 0.2));
8905 radgrad.addColorStop(1, PoliticalMap.convertHexToRgba(color, 0.0));
8906
8907 // draw shape
8908 c.fillStyle = radgrad;
8909
8910 c.fillRect(t.split("x")[0] * _zoom - 10, t.split("x")[1] * _zoom - 10, 22, 22);
8911
8912 c.fillStyle = PoliticalMap.convertHexToRgba(color, 0.7);
8913 c.fillRect(t.split("x")[0] * _zoom, t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
8914 }
8915 else {
8916 c.fillRect(t.split("x")[0] * _zoom, t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
8917 }
8918 }
8919 }
8920
8921
8922
8923 // Legende
8924 var legend = $('#dio_political_map .legend .content');
8925
8926 legend.get(0).innerHTML = "";
8927
8928 for (var ally in ally_ranking) {
8929 if (ally_ranking.hasOwnProperty(ally)) {
8930 //legend.append("<div class='item' style='color:"+ colorAllyArray[ally] +"'><div class='color_checker' style='background-color:"+ colorAllyArray[ally] +"'></div>...</div>");
8931
8932 if (ally_ranking[ally] > 10) {
8933 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>");
8934
8935 break;
8936 } else {
8937 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>");
8938
8939 }
8940 }
8941 }
8942
8943 $('#dio_political_map .legend .color_checker').click(function (event) {
8944 // getting user coordinates
8945 var x = event.pageX - this.offsetLeft;
8946 var y = event.pageY - this.offsetTop;
8947
8948 console.debug("Color Checker", event.pageX, this.offsetLeft);
8949
8950 ColorPicker.open(x,y);
8951 });
8952
8953
8954 // TODO: Wenn eine Farbe ausgewählt wurde, soll [...]
8955 $(ColorPicker).on("onColorChanged", function(event, color){
8956 console.debug("Farbe setzen", event, color);
8957
8958 $.ajax({
8959 type: "POST",
8960 url: "https://" + Game.world_id + ".grepolis.com/game/alliance?town_id=" + Game.townId + "&action=assign_map_color&h=" + Game.csrfToken,
8961 data: {
8962 "json": "{\"alliance_id\":\"217\",\"color\":"+ color +",\"player_id\":\"8512878\",\"town_id\":\"71047\",\"nl_init\":true}"
8963 },
8964 success: function (response) {
8965 console.debug("Erfolgreich übertragen", response);
8966 }
8967 });
8968 });
8969
8970 },
8971 convertHexToRgba: function (hex, opacity) {
8972 console.debug("hex", hex);
8973 hex = hex.replace('#', '');
8974 r = parseInt(hex.substring(0, 2), 16);
8975 g = parseInt(hex.substring(2, 4), 16);
8976 b = parseInt(hex.substring(4, 6), 16);
8977
8978 result = 'rgba(' + r + ',' + g + ',' + b + ',' + opacity + ')';
8979 return result;
8980 },
8981 /**
8982 * Zeichnet die Weltwunder auf der Karte
8983 *
8984 * @param _islandArray {Array}
8985 * @param _zoom {int}
8986 *
8987 * @since 3.0
8988 */
8989 drawWonders: function (_islandArray, _zoom) {
8990
8991 $('<canvas class="canv_ww" height="' + (1000 * _zoom) + 'px" width="' + (1000 * _zoom) + 'px"></canvas>').appendTo('.canvas_wrapper')
8992
8993 var c = $('#dio_political_map .canv_ww')[0].getContext('2d');
8994
8995 c.strokeStyle = 'rgb(0,100,0)';
8996
8997 // World Wonders
8998 var wonders = {}, wonderImages = {};
8999 //console.debug(JSON.stringify(wonder.map));
9000
9001 for (var wonderType in wonder.map) {
9002 if (wonder.map.hasOwnProperty(wonderType)) {
9003 var tmp = 0;
9004 for (var wonderCoords in wonder.map[wonderType]) {
9005 if (parseInt(wonder.map[wonderType][wonderCoords], 10) > tmp) {
9006 wonders[wonderType] = wonderCoords;
9007 tmp = parseInt(wonder.map[wonderType][wonderCoords], 10)
9008 }
9009 }
9010 }
9011 }
9012
9013 // Legende
9014 var legend = $('#dio_political_map .legend .content');
9015
9016 legend.append("<div class=\"item no_results\"></div>");
9017
9018 for (var w in wonders) {
9019 if (wonders.hasOwnProperty(w)) {
9020 var _w = w;
9021
9022 wonderImages[_w] = new Image();
9023
9024 wonderImages[_w].onload = function () {
9025 c.drawImage(this, this.pos.split("_")[0] * _zoom - 9, this.pos.split("_")[1] * _zoom - 9);
9026 };
9027
9028 wonderImages[_w].pos = wonders[_w];
9029 wonderImages[_w].src = "https://diotools.de/images/icons/ww/" + _w + ".png";
9030
9031 var wonder_string = _w.split("_of")[0].split("_");
9032 wonder_string = wonder_string[wonder_string.length - 1];
9033 wonder_string = wonder_string.substring(0, 1).toUpperCase() + wonder_string.substring(1);
9034
9035 legend.append("<img class='wonder_icon' src='" + wonderImages[_w].src + "'><div class='item'>" + wonder_string + "</div>");
9036 }
9037 }
9038 },
9039 clearMap: function () {
9040 $('#dio_political_map .canv_map').remove();
9041 $('#dio_political_map .canv_ww').remove();
9042 },
9043 getAllianceColors: function () {
9044 $.ajax({
9045 type: "GET",
9046 url: "https://" + Game.world_id + ".grepolis.com/game/map_data?town_id=" + Game.townId + "&action=get_custom_colors&h=" + Game.csrfToken,
9047 dataType: 'json',
9048 success: function (response) {
9049 // Allianzbox herausfiltern
9050 var html_string = $('#alliance_box', $(response.json.list_html));
9051
9052 var flagArray = $('.flag', html_string);
9053 var linkArray = $('a', html_string);
9054
9055 var allianceColorArray = [];
9056
9057 for (var i = 0; i < flagArray.length; i++) {
9058 allianceColorArray[i] = {
9059 "id": parseInt(linkArray[i].attributes.onclick.value.split(",")[1].split(")")[0], 10),
9060 "color": flagArray[i].style.backgroundColor
9061 };
9062 }
9063
9064 // console.debug("ANTWORT", allianceColorArray);
9065 }
9066 });
9067 }
9068 };
9069
9070 var ColorPicker = {
9071 open: function(pos_left, pos_top){
9072 $('#dio_color_picker').removeClass("hidden");
9073 $('#dio_color_picker').css({
9074 left: pos_left,
9075 top: pos_top
9076 });
9077 },
9078 close: function(){
9079 $('#dio_color_picker').addClass("hidden");
9080 },
9081 init: function () {
9082 // Style
9083 $('<style id="dio_color_picker_style">' +
9084 '#dio_color_picker { left:200px;top:300px;position:absolute;z-index:1000;} ' +
9085 '#dio_color_picker.hidden { display:none;} ' +
9086 '#dio_color_picker span.grepo_input, ' +
9087 '#dio_color_picker a.color_table, ' +
9088 '#dio_color_picker a.confirm, ' +
9089 '#dio_color_picker a.cancel' +
9090 ' { float:left; } ' +
9091 '</style>').appendTo('head');
9092
9093 $(
9094 '<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>' +
9095 '<div id="hex">HEX: <input type="text"></input></div>' +
9096 '<div id="rgb">RGB: <input type="text"></input></div>'
9097 ).prependTo('#dio_political_map')
9098
9099 $(
9100 '<div id="dio_color_picker" class="hidden"><table class="bb_popup" cellpadding="0" cellspacing="0"><tbody>' +
9101 '<tr class="bb_popup_top">' +
9102 '<td class="bb_popup_top_left"></td>' +
9103 '<td class="bb_popup_top_middle"></td>' +
9104 '<td class="bb_popup_top_right"></td>' +
9105 '</tr>' +
9106 '<tr>' +
9107 '<td class="bb_popup_middle_left"></td>' +
9108 '<td class="bb_popup_middle_middle">' +
9109 '<div class="bb_color_picker_colors">' +
9110 '<div style="background-color: rgb(255, 0, 0);"></div>' +
9111 '<div style="background-color: rgb(0, 255, 0);"></div>' +
9112 '<div style="background-color: rgb(0, 0, 255);"></div>' +
9113 '</div>' +
9114 '<a href="#" class="cancel"></a>' +
9115 '<span class="grepo_input">' +
9116 '<span class="left">' +
9117 '<span class="right">' +
9118 '<input class="color_string" style="width:50px;" maxlength="6" type="text">' +
9119 '</span>' +
9120 '</span>' +
9121 '</span>' +
9122 '<a href="#" class="color_table"><input type="color" id="c" tabindex=-1 class="hidden"></a>' +
9123 '<a href="#" class="confirm"></a>' +
9124 '</td>' +
9125 '<td class="bb_popup_middle_right"></td>' +
9126 '</tr>' +
9127 '<tr class="bb_popup_bottom">' +
9128 '<td class="bb_popup_bottom_left"></td>' +
9129 '<td class="bb_popup_bottom_middle"></td>' +
9130 '<td class="bb_popup_bottom_right"></td>' +
9131 '</tr>' +
9132 '</tbody></table></div>'
9133 ).prependTo('#dio_political_map');
9134
9135 var canvas = document.getElementById('canvas_picker').getContext('2d');
9136
9137 var count = 5, line = 0, width = 16, height = 12, sep = 1;
9138
9139 var offset = (count - 2) * width;
9140
9141 for (var i = 2, j = 0; i < count; i++, j++) {
9142
9143 line = 0;
9144
9145 // Pinktöne (255,0,255)
9146 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", 0, " + ((i / count * 255) | 0) + ")";
9147 canvas.fillRect(i * width, line, width - sep, height - sep);
9148
9149 canvas.fillStyle = "rgb(255," + ((j / (count - 1) * 255) | 0) + ", 255)";
9150 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9151
9152 line = line + height;
9153
9154 // Rosatöne (255,0,127)
9155 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", 0, " + ((i / count * 127) | 0) + ")";
9156 canvas.fillRect(i * width, line, width - sep, height - sep);
9157
9158 canvas.fillStyle = "rgb(255," + ((j / (count - 1) * 255) | 0) + "," + (127 + ((j / (count - 1) * 127) | 0)) + ")";
9159 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9160
9161 line = line + height;
9162
9163 // Rottöne (255,0,0)
9164 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", 0, 0)";
9165 canvas.fillRect(i * width, line, width - sep, height - sep);
9166
9167 canvas.fillStyle = "rgb(255," + ((j / (count - 1) * 255) | 0) + "," + ((j / (count - 1) * 255) | 0) + ")";
9168 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9169
9170 line = line + height;
9171
9172 // Orangetöne (255, 127, 0)
9173 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", " + ((i / count * 127) | 0) + ", 0)";
9174 canvas.fillRect(i * width, line, width - sep, height - sep);
9175
9176 canvas.fillStyle = "rgb(255, " + (127 + ((j / (count - 1) * 127) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ")";
9177 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9178
9179 line = line + height;
9180
9181 // Dunkelbrauntöne (170, 85, 0)
9182 canvas.fillStyle = "rgb(" + ((i / count * 170) | 0) + ", " + ((i / count * 85) | 0) + ", 0)";
9183 canvas.fillRect(i * width, line, width - sep, height - sep);
9184
9185 canvas.fillStyle = "rgb(" + (170 + (j / (count - 1) * 85) | 0) + ", " + (85 + ((j / (count - 1) * 170) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ")";
9186 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9187
9188 line = line + height;
9189
9190 // Brauntöne (191, 127, 0)
9191 canvas.fillStyle = "rgb(" + ((i / count * 191) | 0) + ", " + ((i / count * 127) | 0) + ", 0)";
9192 canvas.fillRect(i * width, line, width - sep, height - sep);
9193
9194 canvas.fillStyle = "rgb(" + (191 + (j / (count - 1) * 64) | 0) + ", " + (127 + ((j / (count - 1) * 127) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ")";
9195 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9196
9197 line = line + height;
9198
9199 // Gelbtöne (255,255,0)
9200 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ", 0)";
9201 canvas.fillRect(i * width, line, width - sep, height - sep);
9202
9203 canvas.fillStyle = "rgb(255, 255," + ((j / (count - 1) * 255) | 0) + ")";
9204 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9205
9206 line = line + height;
9207
9208 // Gelbgrüntöne (127,255,0)
9209 canvas.fillStyle = "rgb(" + ((i / count * 127) | 0) + "," + ((i / count * 191) | 0) + ", 0)";
9210 canvas.fillRect(i * width, line, width - sep, height - sep);
9211
9212 canvas.fillStyle = "rgb(" + (127 + (j / (count - 1) * 127) | 0) + "," + (191 + (j / (count - 1) * 64) | 0) + "," + ((j / (count - 1) * 255) | 0) + ")";
9213 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9214
9215 line = line + height;
9216
9217 // Dunkelgrasgrüntöne (85, 170, 0)
9218 /*
9219 canvas.fillStyle = "rgb("+ ((i/count*85)|0) +", "+ ((i/count*170)|0) +", 0)";
9220 canvas.fillRect(i * width, line, width-sep, height-sep);
9221
9222 canvas.fillStyle = "rgb("+ (85 + (j/(count-1)*170)|0) +", "+ (170 + ((j/(count-1)*85)|0)) +","+ ((j/(count-1)*255)|0) +")";
9223 canvas.fillRect(i * width + offset, line, width-sep, height-sep);
9224
9225 line = line + height;
9226 */
9227
9228 // Grüntöne (0,255,0)
9229 canvas.fillStyle = "rgb(0," + ((i / count * 255) | 0) + ", 0)";
9230 canvas.fillRect(i * width, line, width - sep, height - sep);
9231
9232 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + ", 255," + ((j / (count - 1) * 255) | 0) + ")";
9233 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9234
9235 line = line + height;
9236
9237 // Türkistöne (0,255,127)
9238 /*
9239 canvas.fillStyle = "rgb(0,"+ ((i/count*255)|0) +","+ ((i/count*127)|0) + ")";
9240 canvas.fillRect(i * width, line, width-sep, height-sep);
9241
9242 canvas.fillStyle = "rgb("+ ((j/(count-1)*255)|0) +", 255,"+ (127 + ((j/(count-1)*127)|0)) +")";
9243 canvas.fillRect(i * width + offset, line, width-sep, height-sep);
9244
9245 line = line + height;
9246 */
9247
9248 // Dunkel-Türkistöne (0,191,127)
9249 canvas.fillStyle = "rgb(0, " + ((i / count * 191) | 0) + "," + ((i / count * 127) | 0) + ")";
9250 canvas.fillRect(i * width, line, width - sep, height - sep);
9251
9252 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + "," + (191 + (j / (count - 1) * 64) | 0) + ", " + (127 + ((j / (count - 1) * 127) | 0)) + ")";
9253 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9254
9255 line = line + height;
9256
9257
9258 // Cyantöne (0,255,255)
9259 canvas.fillStyle = "rgb(0, " + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ")";
9260 canvas.fillRect(i * width, line, width - sep, height - sep);
9261
9262 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + ",255, 255)";
9263 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9264
9265 line = line + height;
9266
9267 // Hellblautöne (0,127,255)
9268 canvas.fillStyle = "rgb(0, " + ((i / count * 127) | 0) + "," + ((i / count * 255) | 0) + ")";
9269 canvas.fillRect(i * width, line, width - sep, height - sep);
9270
9271 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + "," + (127 + ((j / (count - 1) * 127) | 0)) + ", 255)";
9272 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9273
9274 line = line + height;
9275
9276 // Blautöne (0,0,255)
9277 canvas.fillStyle = "rgb(0, 0, " + ((i / count * 255) | 0) + ")";
9278 canvas.fillRect(i * width, line, width - sep, height - sep);
9279
9280 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + "," + ((j / (count - 1) * 255) | 0) + ", 255)";
9281 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9282
9283 line = line + height;
9284
9285 // Lilatöne (127,0,255)
9286 canvas.fillStyle = "rgb(" + ((i / count * 127) | 0) + ", 0, " + ((i / count * 255) | 0) + ")";
9287 canvas.fillRect(i * width, line, width - sep, height - sep);
9288
9289 canvas.fillStyle = "rgb(" + (127 + ((j / (count - 1) * 127) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ", 255)";
9290 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9291
9292 line = line + height;
9293
9294 // Grautöne
9295 /*
9296 canvas.fillStyle = "rgb("+ ((i/count*127)|0) +", "+ ((i/count*127)|0) +", "+ ((i/count*127)|0) +")";
9297 canvas.fillRect(i * width, line, width-sep, height-sep);
9298
9299 canvas.fillStyle = "rgb("+ (127 + ((j/(count-1)*127)|0)) +","+ (127 + ((j/(count-1)*127)|0)) +","+ (127 + ((j/(count-1)*127)|0)) +")";
9300 canvas.fillRect(i * width + offset, line, width-sep, height-sep);
9301
9302 line = line + height;
9303 */
9304
9305 }
9306
9307 line = line + height;
9308
9309 for (var i = 0; i <= count; i++) {
9310 // Grautöne
9311 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ")";
9312 canvas.fillRect(i * width + width * 2, line, width - sep, height - sep);
9313 }
9314
9315
9316 // http://www.javascripter.net/faq/rgbtohex.htm
9317 function rgbToHex(R, G, B) {
9318 return toHex(R) + toHex(G) + toHex(B)
9319 }
9320
9321 function toHex(n) {
9322 n = parseInt(n, 10);
9323 if (isNaN(n)) return "00";
9324 n = Math.max(0, Math.min(n, 255));
9325 return "0123456789ABCDEF".charAt((n - n % 16) / 16) + "0123456789ABCDEF".charAt(n % 16);
9326 }
9327
9328 $('#dio_color_picker a.cancel').click(function () {
9329 ColorPicker.close();
9330 });
9331
9332
9333 $('#dio_color_picker a.confirm').click(function () {
9334 // Custom-Event auslösen
9335 $(ColorPicker).trigger("onColorChanged", [$('#dio_color_picker .color_string')[0].value]);
9336 ColorPicker.close();
9337 });
9338
9339 $('#dio_color_picker a.color_table').click(function () {
9340 document.getElementById("c").click();
9341 });
9342
9343 $('#dio_color_picker a.color_table #c').change(function () {
9344 $('#dio_color_picker input.color_string')[0].value = this.value;
9345 $('#dio_color_picker input.color_string')[0].style.color = this.value;
9346 });
9347 }
9348 };
9349
9350 var UnitImages = {
9351 activate : function(){
9352 $('<style id="dio_unit_images">' +
9353
9354 '.unit_icon25x25 { background-image: url(https://diotools.de/images/game/units/unit_icons_25x25_2.91.png);} ' +
9355 '.unit_icon40x40 { background-image: url(https://diotools.de/images/game/units/unit_icons_40x40_2.91.png);} ' +
9356 '.unit_icon50x50 { background-image: url(https://diotools.de/images/game/units/unit_icons_50x50_2.91.png);} ' +
9357 '.unit_icon90x90 { background-image: url(https://diotools.de/images/game/units/unit_icons_90x90_2.91.png);} ' +
9358
9359 '.unit_icon228x165 { background-image: none; height:0px;} ' +
9360 '.unit_card .deco_statue { background-image: none !important;} ' +
9361 '.grepo_box_silver .border_l, .grepo_box_silver .border_r { background-image: none;} ' +
9362 '.box_corner .box_corner_tl, .grepo_box_silver .box_corner_tr { height:31px; } ' +
9363 '.grepo_box_silver .grepo_box_content { padding: 21px 10px 0px; } ' +
9364
9365 '</style>').appendTo('head');
9366 },
9367 deactivate : function(){
9368 $('#dio_unit_images').remove();
9369
9370 }
9371 };
9372
9373 /*******************************************************************************************************************************
9374 * Holiday Special
9375 *******************************************************************************************************************************/
9376
9377 var HolidaySpecial = {
9378 isHalloween : false, isXmas : false, isNewYear : false, isEaster : false,
9379
9380 activate : function(){
9381 var daystamp = 1000*60*60*24, today = new Date((new Date())%(daystamp*(365+1/4))), // without year
9382
9383 // Halloween -> 15 days
9384 halloween_start = daystamp * 297, // 25. Oktober
9385 halloween_end = daystamp * 321, // 8. November
9386 // Xmas -> 28 days
9387 xmas_start = daystamp * 334, // 1. Dezember
9388 xmas_end = daystamp * 361, // 28. Dezember
9389 // NewYear -> 7 days
9390 newYear_start = daystamp * 0, // 1. Januar
9391 newYear_end = daystamp * 7; // 7. Januar
9392
9393 HolidaySpecial.isHalloween = (today >= halloween_start) ? (today <= halloween_end) : false;
9394
9395 HolidaySpecial.isXmas = (today >= xmas_start) ? (today <= xmas_end) : false;
9396
9397 HolidaySpecial.isNewYear = (today >= newYear_start) ? (today <= newYear_end) : false;
9398
9399 if(HolidaySpecial.isXmas){ HolidaySpecial.XMas.add(); }
9400 if(HolidaySpecial.isNewYear){ HolidaySpecial.NewYear.add(); }
9401
9402 // Calculation Easter
9403
9404 // Jahreszahl
9405 var X = 2016;
9406
9407 // Säkularzahl
9408 var K = parseInt(X / 100, 10);
9409 // Mondparameter
9410 var A = X % 19;
9411
9412 // säkulare Mondschaltung
9413 var M = 15 + parseInt((3 * K + 3)/4, 10) - parseInt((8 * K + 13)/25, 10);
9414
9415 // säkulare Sonnenschaltung
9416 var S = 2 - parseInt((3 * K + 3)/4, 10);
9417
9418 // Erster Vollmond im Frühling
9419 var D = (19 * A + M) % 30;
9420
9421 // Kalendarische Korrekturgröße
9422 var R = parseInt((D + parseInt(A / 11, 10)) / 29, 10);
9423
9424 // Ostergrenze
9425 var OG = 21 + D - R;
9426
9427 // Erster Sonntag im März
9428 var SZ = 7 - ((2016 + parseInt(2016/4, 10) + S) % 7);
9429
9430 // Entfernung des Ostersonntags von der Ostergrenze
9431 var OE = 7 - ((OG - SZ) % 7);
9432
9433 // Ostersonntag als Märzdatum
9434 var OS = OG + OE;
9435
9436 // console.debug("DIO-TOOLS | Ostersonntag: " + OS);
9437
9438 },
9439 XMas : {
9440 add : function(){
9441 $('<a href="http://www.greensmilies.com/smilie-album/weihnachten-smilies/" target="_blank"><div id="dio_xmas"></div></a>').appendTo('#ui_box');
9442
9443 var dioXMAS = $('#dio_xmas');
9444
9445 dioXMAS.css({
9446 background: 'url("http://www.greensmilies.com/smile/smiley_emoticons_weihnachtsmann_nordpol.gif") no-repeat',
9447 height: '51px',
9448 width: '61px',
9449 position:'absolute',
9450 bottom:'10px',
9451 left:'60px',
9452 zIndex:'2000'
9453 });
9454 dioXMAS.tooltip("Ho Ho Ho, Merry Christmas!");
9455 }
9456 },
9457 NewYear : {
9458 add : function(){
9459 // TODO: Jahreszahl dynamisch setzen
9460 $('<a href="http://www.greensmilies.com/smilie-album/" target="_blank"><div id="dio_newYear">'+
9461 '<img src="http://www.greensmilies.com/smile/sign2_2.gif">'+
9462 '<img src="http://www.greensmilies.com/smile/sign2_0.gif">'+
9463 '<img src="http://www.greensmilies.com/smile/sign2_1.gif">'+
9464 '<img src="http://www.greensmilies.com/smile/sign2_9.gif">'+
9465 '</div></a>').appendTo('#ui_box');
9466
9467 var dioNewYear = $('#dio_newYear');
9468
9469 dioNewYear.css({
9470 position:'absolute',
9471 bottom:'10px',
9472 left:'70px',
9473 zIndex:'10'
9474 });
9475 dioNewYear.tooltip("Happy new year!");
9476 }
9477 }
9478 };
9479
9480}