· 8 years ago · Jan 22, 2018, 02:38 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 https://*.grepolis.com/game*
10// @require http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
11// @icon http://s7.directupload.net/images/140128/vqchpigi.gif
12// @icon64 http://diotools.de/images/icon_dio_64x64.png
13// @copyright 2013+, DIONY
14// @grant GM_info
15// @grant GM_setValue
16// @grant GM_getValue
17// @grant GM_deleteValue
18// @grant GM_xmlhttpRequest
19// @grant GM_getResourceURL
20// ==/UserScript==
21
22var version = '3.19';
23
24//if(unsafeWindow.DM) console.dir(unsafeWindow.DM.status('l10n'));
25//console.dir(DM.status('templates'));
26
27//http://s7.directupload.net/images/140128/vqchpigi.gif - DIO-Tools-Smiley
28
29//http://de44.grepolis.com/cache/js/libs/jquery-1.10.2.min.js
30
31
32//console.log(JSON.stringify(DM.getl10n()));
33
34
35//// console.log(GM_getResourceText("dio_sprite"));
36
37/*******************************************************************************************************************************
38 * Changes
39 * ----------------------------------------------------------------------------------------------------------------------------
40 * | ◠Einstellungen und auch das ganze Script komplett überarbeitet
41 * | ◠Features können nun ohne Refresh deaktiviert/aktiviert werden
42 * | ◠Einzelne Features sind unabhängiger voneinander und somit auch fehlerresistenter (einzelne Features können sich bei Fehlerauftreten durch Grepolis-Updates nicht mehr gegenseitig blockieren)
43 * | ◠Fehlerhafter Biremenzähler als Kompromiss für die Erweiterung der "Verfügbare Einheiten"-Anzeige entfernt: es kann nun jede Einheit im Bullauge angezeigt werden
44 * | ◠EO-Zähler hat ATT/UT's doppelt gezählt, wenn nebenher der veröffentlichte Belagerungsbericht im Forum offen war
45 * | ◠3 kleine Layoutfehler beim EO-Zähler behoben
46 * | â— Wenn Zauberfenster und Zauberbox gleichzeitig offen waren, kam es zu einem Layoutfehler
47 * | â— Fehler beim Mausrad-Zoom behoben
48 * | ◠Fehler bei der Transporteranzeige behoben: die Kapazität der großen Transporter wurde durch das Rebalancing nichtmehr korrekt berechnet
49 * | â— Smileybox etwas verbessert
50 * | ◠Weihnachtssmileys hinzugefügt
51 * | ◠Kontextmenü der Stadticons auf der strategischen Karte konnte im Nachtmodus nicht geöffnet werden
52 * | ◠Grüner Fortschrittsbalken beim Weltwunderzähler wurde nicht angezeigt
53 * | ◠Fenster wurden angepasst (Verfügbare Einheiten und Einheitenvergleich)
54 * ----------------------------------------------------------------------------------------------------------------------------
55 *******************************************************************************************************************************/
56
57/*******************************************************************************************************************************
58 * Bugs / TODOs
59 * ----------------------------------------------------------------------------------------------------------------------------
60 * | ◠Aktivitätsbox für Angriffe blendet nicht aus
61 * | â— Smileys verschwinden manchmal? -> bisher nicht reproduzierbar
62 * | â— Performanceeinbruch nach dem Switchen des WW-Fensters
63 * | â— keine Smileys im Grepoforum mit Safari (fehlendes jQuery)
64 * ----------------------------------------------------------------------------------------------------------------------------
65 *******************************************************************************************************************************/
66
67/*******************************************************************************************************************************
68 * Global stuff
69 *******************************************************************************************************************************/
70var uw = unsafeWindow || window, $ = uw.jQuery || jQuery, DATA, GM;
71
72// GM-API?
73GM = (typeof GM_info === 'object');
74
75console.log('%c|= DIO-Tools is active =|', 'color: green; font-size: 1em; font-weight: bolder; ');
76
77function loadValue(name, default_val){
78 var value;
79 if(GM){
80 value = GM_getValue(name, default_val);
81 } else {
82 value = localStorage.getItem(name) || default_val;
83 }
84
85 if(typeof(value) === "string"){
86 value = JSON.parse(value)
87 }
88 return value;
89}
90
91// LOAD DATA
92if(GM && (uw.location.pathname.indexOf("game") >= 0)){
93 var WID = uw.Game.world_id, MID = uw.Game.market_id, AID = uw.Game.alliance_id;
94
95 //GM_deleteValue(WID + "_bullseyeUnit");
96
97 DATA = {
98 // GLOBAL
99 options : loadValue("options", "{}"),
100
101 user : loadValue("dio_user", "{}"),
102 count: loadValue("dio_count", "[]"),
103
104 notification : loadValue('notif', '0'),
105
106 error: loadValue('error', '{}'),
107
108 spellbox : loadValue("spellbox", '{ "top":"23%", "left": "-150%", "show": false }'),
109 commandbox: loadValue("commandbox" , '{ "top":55, "left": 250 }'),
110 tradebox : loadValue("tradebox", '{ "top":55, "left": 450 }'),
111
112 // WORLD
113 townTypes : loadValue(WID + "_townTypes", "{}"),
114 sentUnits : loadValue(WID + "_sentUnits", '{ "attack": {}, "support": {} }'),
115
116 biremes : loadValue(WID + "_biremes", "{}"), //old
117 bullseyeUnit : loadValue(WID + "_bullseyeUnit", '{ "current_group" : -1 }'), // new
118
119 worldWonder : loadValue(WID + "_wonder", '{ "ratio": {}, "storage": {}, "map": {} }'),
120
121 clickCount : loadValue(WID + "_click_count", '{}'), // old
122 statistic : loadValue(WID + "_statistic", '{}'), // new
123
124 // MARKET
125 worldWonderTypes : loadValue(MID + "_wonderTypes", '{}')
126 };
127
128 if(!DATA.worldWonder.map) {
129 DATA.worldWonder.map = {};
130 }
131
132 // Temporary:
133 if(typeof DATA.options.trd == 'boolean') {
134 DATA.options.per = DATA.options.rec = DATA.options.trd; delete DATA.options.trd;
135 }
136 if(typeof DATA.options.mov == 'boolean') {
137 DATA.options.act = DATA.options.mov; delete DATA.options.mov;
138 }
139 if(typeof DATA.options.twn == 'boolean') {
140 DATA.options.tic = DATA.options.til = DATA.options.tim = DATA.options.twn; delete DATA.options.twn;
141 }
142 if(GM) GM_deleteValue("notification");
143}
144
145// GM: EXPORT FUNCTIONS
146uw.saveValueGM = function(name, val){
147 setTimeout(function(){
148 GM_setValue(name, val);
149 }, 0);
150};
151
152uw.deleteValueGM = function(name){
153 setTimeout(function(){
154 GM_deleteValue(name);
155 },0);
156};
157
158uw.getImageDataFromCanvas = function(x, y){
159
160 // console.debug("HEY", document.getElementById('canvas_picker').getContext('2d').getImageData(x, y, 1, 1));
161};
162uw.calculateConcaveHull = function() {
163 var contour = [
164 new poly2tri.Point(100, 100),
165 new poly2tri.Point(100, 300),
166 new poly2tri.Point(300, 300),
167 new poly2tri.Point(300, 100)
168 ];
169
170 var swctx = new poly2tri.SweepContext(contour);
171
172 swctx.triangulate();
173 var triangles = swctx.getTriangles();
174
175 // console.debug(triangles);
176
177 return triangles;
178};
179
180if(typeof exportFunction == 'function'){
181 // Firefox > 30
182 //uw.DATA = cloneInto(DATA, unsafeWindow);
183 exportFunction(uw.saveValueGM, unsafeWindow, {defineAs: "saveValueGM"});
184 exportFunction(uw.deleteValueGM, unsafeWindow, {defineAs: "deleteValueGM"});
185 exportFunction(uw.calculateConcaveHull, unsafeWindow, {defineAs: "calculateConcaveHull"});
186 exportFunction(uw.getImageDataFromCanvas, unsafeWindow, {defineAs: "getImageDataFromCanvas"});
187} else {
188 // Firefox < 30, Chrome, Opera, ...
189 //uw.DATA = DATA;
190}
191
192var time_a, time_b;
193
194// APPEND SCRIPT
195function appendScript(){
196 //console.log("GM-API: " + gm_bool);
197 if(document.getElementsByTagName('body')[0]){
198 var dioscript = document.createElement('script');
199 dioscript.type ='text/javascript';
200 dioscript.id = 'diotools';
201
202 time_a = uw.Timestamp.client();
203 dioscript.textContent = DIO_GAME.toString().replace(/uw\./g, "") + "\n DIO_GAME('"+ version +"', "+ GM +", '" + JSON.stringify(DATA).replace(/'/g, "##") + "', "+ time_a +");";
204 document.body.appendChild(dioscript);
205 } else {
206 setTimeout(function(){
207 appendScript();
208 }, 500);
209 }
210}
211
212if(location.host === "diotools.de"){
213 // PAGE
214 DIO_PAGE();
215}
216else if((uw.location.pathname.indexOf("game") >= 0) && GM){
217 // GAME
218 appendScript();
219}
220else {
221 DIO_FORUM();
222}
223
224function DIO_PAGE(){
225 if(typeof GM_info == 'object') {
226 setTimeout(function() {
227 dio_user = JSON.parse(loadValue("dio_user", ""));
228 console.log(dio_user);
229 uw.dio_version = parseFloat(version);
230 }, 0);
231 } else {
232 dio_user = localStorage.getItem("dio_user") || "";
233
234 dio_version = parseFloat(version);
235 }
236}
237function DIO_FORUM(){
238 var smileyArray = [];
239
240 var _isSmileyButtonClicked = false;
241
242 smileyArray.standard = [
243 "smilenew", "grin", "lol", "neutral_new", "afraid", "freddus_pacman", "auslachen2", "kolobok-sanduhr", "bussi2", "winken4", "flucht2", "panik4", "ins-auge-stechen",
244 "seb_zunge", "fluch4_GREEN", "baby_junge2", "blush-reloaded6", "frown", "verlegen", "blush-pfeif", "stevieh_rolleyes", "daumendreh2", "baby_taptap",
245 "sadnew", "hust", "confusednew", "idea2", "irre", "irre4", "sleep", "candle", "nicken", "no_sad",
246 "thumbs-up_new", "thumbs-down_new", "bravo2", "oh-no2", "kaffee2", "drunk", "saufen", "freu-dance", "hecheln", "headstand", "rollsmiliey", "eazy_cool01", "motz", "cuinlove", "biggrin"
247 ];
248 smileyArray.grepolis = [
249 "mttao_wassermann", "hera", /* Hera */ "medusa", /* Medusa */ "manticore", /* Mantikor */ "cyclops", /* Zyklop */
250 "minotaur", /* Minotaurus */ "pegasus", /* Pegasus */ "hydra", /* Hydra */
251 "silvester_cuinlove", "mttao_schuetze", "kleeblatt2", "wallbash", /* "glaskugel4", */ /* "musketiere_fechtend",*/ /* "krone-hoch",*/ "viking", // Wikinger
252 /* "mttao_waage2", */ "steckenpferd", /* "kinggrin_anbeten2", */ "grepolove", /* Grepo Love */ "skullhaufen", "grepo_pacman" /*, "pferdehaufen" */ // "i/ckajscggscw4s2u60"
253 ];
254
255 var ForumObserver = new MutationObserver(function (mutations) {
256 mutations.forEach(function (mutation) {
257
258 if (mutation.addedNodes[0]) {
259
260 //console.debug("Added Nodes", mutation.addedNodes[0]);
261
262 // Message Box geladen
263 if(mutation.addedNodes[0].className === "redactor_box"){
264
265 //console.debug("Message Box geladen");
266
267 ForumObserver.observe($(".redactor_box").get(0), {
268 attributes: false,
269 childList: true,
270 characterData: false,
271 subtree:true
272 });
273 }
274
275 // Toolbar der Message Box geladen
276 if(_isSmileyButtonClicked === false && mutation.addedNodes[0].className === "redactor_toolbar") {
277 $(".redactor_btn_smilies").click();
278
279 // Soll sich nicht wieder deaktivieren
280 _isSmileyButtonClicked = true;
281 }
282
283 // Smileybar der Toolbar geladen
284 if(mutation.addedNodes[0].className === "redactor_smilies") {
285
286 // Observer soll nicht mehr feuern, wenn die Smileys hinzugefügt werden
287 ForumObserver.disconnect();
288
289 // Hässliche Smileys entfernen
290 $(".smilieCategory ul").empty();
291
292 // Greensmileys hinzufügen
293 for(var smiley in smileyArray.standard){
294 if(smileyArray.standard.hasOwnProperty(smiley)){
295 $(".smilieCategory ul").append(
296 '<li class="Smilie" data-text="">'+
297 '<img src="https://diotools.de/images/smileys/standard/smiley_emoticons_'+ smileyArray.standard[smiley] +'.gif" title="" alt="" data-smilie="yes">'+
298 '</li>'
299 );
300 }
301 }
302
303 $(".smilieCategory ul").append("<br><br>");
304
305 for(var smiley in smileyArray.grepolis){
306 if(smileyArray.grepolis.hasOwnProperty(smiley)){
307 $(".smilieCategory ul").append(
308 '<li class="Smilie" data-text="">'+
309 '<img src="https://diotools.de/images/smileys/grepolis/smiley_emoticons_'+ smileyArray.grepolis[smiley] +'.gif" title="" alt="" data-smilie="yes">'+
310 '</li>'
311 );
312 }
313 }
314
315 _isSmileyBarOpened = true;
316 }
317 }
318 });
319 });
320
321 // Smiley-Button aktivieren, um die Smiley-Toolbar zu öffnen
322 if($(".redactor_btn_smilies").get(0)){
323 $(".redactor_btn_smilies").click();
324
325 _isSmileyButtonClicked = true;
326 }
327
328 // Observer triggern
329 if($("#QuickReply").get(0)) {
330 ForumObserver.observe($("#QuickReply div").get(0), {
331 attributes: false,
332 childList: true,
333 characterData: false,
334 subtree:true
335 });
336 }
337 else if($("#ThreadReply").get(0)) {
338 ForumObserver.observe($("#ThreadReply div").get(0), {
339 attributes: false,
340 childList: true,
341 characterData: false,
342 subtree:true
343 });
344 }
345 /*
346 else if($("#ThreadCreate").get(0)) {
347 ForumObserver.observe($("#ThreadCreate fieldset .ctrlUnit dd div").get(0), {
348 attributes: false,
349 childList: true,
350 characterData: false
351 });
352 }
353 */
354
355 // Threaderstellung, Signatur bearbeiten, Beitrag bearbeiten
356 else if($("form.Preview").get(0)) {
357
358 ForumObserver.observe($("form.Preview .ctrlUnit dd div").get(0), {
359 attributes: false,
360 childList: true,
361 characterData: false
362 });
363 }
364 else if(typeof($("form.AutoValidator").get(0)) !== "undefined") {
365
366 ForumObserver.observe($("form.AutoValidator .messageContainer div").get(0), {
367 attributes: false,
368 childList: true,
369 characterData: false
370 });
371 }
372
373 // TODO: Bearbeiten, Nachrichten
374}
375
376
377
378function DIO_GAME(version, gm, DATA, time_a) {
379 var MutationObserver = uw.MutationObserver || window.MutationObserver,
380
381 WID, MID, AID, PID, LID,
382
383 dio_sprite = "http://666kb.com/i/d9xuhtcctx5fdi8i6.png"; // http://abload.de/img/dio_spritejmqxp.png, http://img1.myimg.de/DIOSPRITEe9708.png -> Forbidden!?
384
385 if (uw.location.pathname.indexOf("game") >= 0) {
386 DATA = JSON.parse(DATA.replace(/##/g, "'"));
387
388 WID = uw.Game.world_id;
389 MID = uw.Game.market_id;
390 AID = uw.Game.alliance_id;
391 PID = uw.Game.player_id;
392 LID = uw.Game.locale_lang.split("_")[0]; // LID ="es";
393
394 // World with Artemis ??
395 Game.hasArtemis = true; //Game.constants.gods.length == 6;
396 }
397
398 $.prototype.reverseList = [].reverse;
399
400 // Implement old jQuery method (version < 1.9)
401 $.fn.toggleClick = function () {
402 var methods = arguments; // Store the passed arguments for future reference
403 var count = methods.length; // Cache the number of methods
404
405 // Use return this to maintain jQuery chainability
406 // For each element you bind to
407 return this.each(function (i, item) {
408 // Create a local counter for that element
409 var index = 0;
410
411 // Bind a click handler to that element
412 $(item).on('click', function () {
413 // That when called will apply the 'index'th method to that element
414 // the index % count means that we constrain our iterator between 0
415 // and (count-1)
416 return methods[index++ % count].apply(this, arguments);
417 });
418 });
419 };
420
421 function saveValue(name, val) {
422 if (gm) {
423 saveValueGM(name, val);
424 } else {
425 localStorage.setItem(name, val);
426 }
427 }
428
429 function deleteValue(name) {
430 if (gm) {
431 deleteValueGM(name);
432 } else {
433 localStorage.removeItem(name);
434 }
435 }
436
437 /*******************************************************************************************************************************
438 * Graphic filters
439 *******************************************************************************************************************************/
440 if (uw.location.pathname.indexOf("game") >= 0) {
441 $('<svg width="0%" height="0%">' +
442 // GREYSCALE
443 '<filter id="GrayScale">' +
444 '<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">' +
445 '</filter>' +
446 // SEPIA
447 '<filter id="Sepia">' +
448 '<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">' +
449 '</filter>' +
450 // SATURATION
451 '<filter id="Saturation"><feColorMatrix type="saturate" values="0.2"></filter>' +
452 '<filter id="Saturation1"><feColorMatrix type="saturate" values="1"></filter>' +
453 '<filter id="Saturation2"><feColorMatrix type="saturate" values="2"></filter>' +
454 // HUE
455 '<filter id="Hue1"><feColorMatrix type="hueRotate" values= "65"></filter>' +
456 '<filter id="Hue2"><feColorMatrix type="hueRotate" values="150"></filter>' +
457 '<filter id="Hue3"><feColorMatrix type="hueRotate" values="-65"></filter>' +
458 // BRIGHTNESS
459 '<filter id="Brightness15">' +
460 '<feComponentTransfer><feFuncR type="linear" slope="1.5"/><feFuncG type="linear" slope="1.5"/><feFuncB type="linear" slope="1.5"/></feComponentTransfer>' +
461 '</filter>' +
462 '<filter id="Brightness12">' +
463 '<feComponentTransfer><feFuncR type="linear" slope="1.2"/><feFuncG type="linear" slope="1.2"/><feFuncB type="linear" slope="1.2"/></feComponentTransfer>' +
464 '</filter>' +
465 '<filter id="Brightness11">' +
466 '<feComponentTransfer><feFuncR type="linear" slope="1.1"/><feFuncG type="linear" slope="1.1"/><feFuncB type="linear" slope="1.1"/></feComponentTransfer>' +
467 '</filter>' +
468 '<filter id="Brightness10">' +
469 '<feComponentTransfer><feFuncR type="linear" slope="1.0"/><feFuncG type="linear" slope="1.0"/><feFuncB type="linear" slope="1.0"/></feComponentTransfer>' +
470 '</filter>' +
471 '<filter id="Brightness07">' +
472 '<feComponentTransfer><feFuncR type="linear" slope="0.7"/><feFuncG type="linear" slope="0.7"/><feFuncB type="linear" slope="0.7"/></feComponentTransfer>' +
473 '</filter>' +
474 '</svg>').appendTo('#ui_box');
475 }
476
477 /*******************************************************************************************************************************
478 * Language versions: german, english, french, russian, polish, spanish
479 *******************************************************************************************************************************/
480 var LANG = {
481 de: {
482 settings: {
483 dsc: "DIO-Tools bietet unter anderem einige Anzeigen, eine Smileyauswahlbox,<br>Handelsoptionen und einige Veränderungen des Layouts.",
484 act: "Funktionen der Toolsammlung aktivieren/deaktivieren:",
485 prv: "Vorschau einzelner Funktionen:",
486
487 version_old: "DIO-Tools-Version ist nicht aktuell",
488 version_new: "DIO-Tools-Version ist aktuell",
489 version_dev: "DIO-Tools-Entwicklerversion",
490
491 version_update: "Aktualisieren",
492
493 link_forum: "http://forum.de.grepolis.com/showthread.php?28838&goto=newpost", //"http://forum.de.grepolis.com/showthread.php?28838"
494 link_contact: "http://forum.de.grepolis.com/private.php?do=newpm&u=10548",
495
496 forum: "Forum",
497 author: "Autor",
498
499 cat_units: "Einheiten",
500 cat_icons: "Stadticons",
501 cat_forum: "Forum",
502 cat_trade: "Handel",
503 cat_wonders: "Weltwunder",
504 cat_layout: "Layout",
505 cat_other: "Sonstiges"
506 },
507 options: {
508 //bir: ["Biremenzähler", "Zählt die jeweiligen Biremen einer Stadt und summiert diese.<br><br>Anzeige im Minimap-Bullauge oben links"],
509 ava: ["Einheitenübersicht", "Zeigt die Einheiten aller Städte an"],
510 sml: ["Smileys", "Erweitert die BBCode-Leiste um eine Smileybox"],
511 str: ["Einheitenstärke", "Fügt mehrere Einheitenstärketabellen in verschiedenen Bereichen hinzu"],
512 tra: ["Transportkapazität", "Zeigt die belegte und verfügbare Transportkapazität im Einheitenmenu an"],
513 per: ["Prozentualer Handel", "Erweitert das Handelsfenster um einen Prozentualer Handel"],
514 rec: ["Rekrutierungshandel", "Erweitert das Handelsfenster um einen Rekrutierungshandel"],
515 cnt: ["EO-Zähler", "Zählt die ATT/UT-Anzahl im EO-Fenster"],
516 way: ["Laufzeit", "Zeigt im ATT/UT-Fenster die Laufzeit bei Verbesserter Truppenbewegung an"],
517 sim: ["Simulator", "Anpassung des Simulatorlayouts & permanente Anzeige der Erweiterten Modifikatorbox"],
518 spl: ["Zauberbox", "Komprimierte verschiebbare & magnetische Zauberbox (Positionsspeicherung)"],
519 act: ["Aktivitätsboxen", "Verbesserte Anzeige der Handels- und Truppenaktivitätsboxen (Positionsspeicherung)"],
520 pop: ["Gunst-Popup", 'Ändert das Aussehen des Gunst-Popups'],
521 tsk: ["Taskleiste", 'Vergrößert die Taskleiste und minimiert das "Tägliche Belohnung"-Fenster beim Start'],
522 cha: ["Chat", "Ersetzt den Allianzchat durch einen Welten-Chat"],
523 bbc: ["DEF-Formular", "Erweitert die BBCode-Leiste um ein automatisches DEF-Formular"],
524 com: ["Einheitenvergleich", "Fügt Einheitenvergleichstabellen hinzu"],
525 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"],
526 til: ["Stadtliste", "Fügt die Stadticons zur Stadtliste hinzu"],
527 tim: ["Karte", "Setzt die Stadticons auf die strategische Karte"],
528 wwc: ["Anteil", "Anteilsrechner & Rohstoffzähler + Vor- & Zurück-Buttons bei fertiggestellten WW's (momentan nicht deaktivierbar!)"],
529 wwr: ["Rangliste", "Überarbeitete Weltwunderrangliste"],
530 wwi: ["Icons", 'Fügt Weltwundericons auf der strategischen Karte hinzu'],
531 con: ["Kontextmenu", 'Vertauscht "Stadt selektieren" und "Stadtübersicht" im Kontextmenu'],
532 sen: ["Abgeschickte Einheiten", 'Zeigt im Angriffs-/Unterstützungsfenster abgeschickte Einheiten an'],
533 tov: ["Stadtübersicht", 'Ersetzt die neue Stadtansicht mit der alten Fensteransicht'],
534 scr: ["Mausrad-Zoom", 'Man kann mit dem Mausrad die 3 Ansichten wechseln'],
535
536 err: ["Automatische Fehlerberichte senden", "Wenn du diese Option aktivierst, kannst du dabei helfen Fehler zu identifizieren."],
537 her: ["Thrakische Eroberung", "Verkleinerung der Karte der Thrakischen Eroberung."]
538 },
539 labels: {
540 uni: "Einheitenübersicht",
541 total: "Gesamt",
542 available: "Verfügbar",
543 outer: "Außerhalb",
544 con: "Selektieren",
545 // Smileys
546 std: "Standard",
547 gre: "Grepolis",
548 nat: "Natur",
549 ppl: "Leute",
550 oth: "Sonstige",
551 // Defense form
552 ttl: "Übersicht: Stadtverteidigung",
553 inf: "Informationen zur Stadt:",
554 dev: "Abweichung",
555 det: "Detailierte Landeinheiten",
556 prm: "Premiumboni",
557 sil: "Silberstand",
558 mov: "Truppenbewegungen:",
559 // WW
560 leg: "WW-Anteil",
561 stg: "Stufe",
562 tot: "Gesamt",
563 // Simulator
564 str: "Einheitenstärke",
565 los: "Verluste",
566 mod: "ohne Modifikatoreinfluss",
567 // Comparison box
568 dsc: "Einheitenvergleich",
569 hck: "Schlag",
570 prc: "Stich",
571 dst: "Distanz",
572 sea: "See",
573 att: "Angriff",
574 def: "Verteidigung",
575 spd: "Geschwindigkeit",
576 bty: "Beute (Rohstoffe)",
577 cap: "Transportkapazität",
578 res: "Baukosten (Rohstoffe)",
579 fav: "Gunst",
580 tim: "Bauzeit (s)",
581 // Trade
582 rat: "Ressourcenverhältnis eines Einheitentyps",
583 shr: "Anteil an der Lagerkapazität der Zielstadt",
584 per: "Prozentualer Handel",
585 // Sent units box
586 lab: "Abgeschickt",
587 improved_movement: "Verbesserte Truppenbewegung"
588 },
589 buttons: {
590 sav: "Speichern", ins: "Einfügen", res: "Zurücksetzen"
591 }
592 },
593
594 en: {
595 settings: {
596 dsc: "DIO-Tools offers, among other things, some displays, a smiley box,<br>trade options and some changes to the layout.",
597 act: "Activate/deactivate features of the toolset:",
598 prv: "Preview of several features:",
599
600 version_old: "Version is not up to date",
601 version_new: "Version is up to date",
602 version_dev: "Developer version",
603
604 version_update: "Update",
605
606 link_forum: "http://forum.en.grepolis.com/showthread.php?52104&goto=newpost",
607 link_contact: "http://forum.en.grepolis.com/private.php?do=newpm&u=46211",
608
609 forum: "Forum",
610 author: "Author",
611
612 cat_units: "Units",
613 cat_icons: "Town icons",
614 cat_forum: "Forum",
615 cat_trade: "Trade",
616 cat_wonders: "World wonder",
617 cat_layout: "Layout",
618 cat_other: "Miscellaneous"
619 },
620 options: {
621 //bir: ["Bireme counter", "Counts the biremes of a city and sums these"],
622 ava: ["Units overview", "Counts the units of all cities"],
623 sml: ["Smilies", "Extends the bbcode bar by a smiley box"],
624 str: ["Unit strength", "Adds unit strength tables in various areas"],
625 tra: ["Transport capacity", "Shows the occupied and available transport capacity in the unit menu"],
626 per: ["Percentual trade", "Extends the trade window by a percentual trade"],
627 rec: ["Recruiting trade", "Extends the trade window by a recruiting trade"],
628 cnt: ["Conquests", "Counts the attacks/supports in the conquest window"],
629 way: ["Troop speed", "Displays improved troop speed in the attack/support window"],
630 sim: ["Simulator", "Adaptation of the simulator layout & permanent display of the extended modifier box"],
631 spl: ["Spell box", "Compressed movable & magnetic spell box (position memory)"],
632 act: ["Activity boxes", "Improved display of trade and troop activity boxes (position memory)"],
633 pop: ["Favor popup", "Changes the favor popup"],
634 tsk: ["Taskbar", "Increases the taskbar and minimizes the daily reward window on startup"],
635 cha: ["Chat", 'Replaced the alliance chat by an world chat. (FlashPlayer required)'],
636 bbc: ["Defense form", "Extends the bbcode bar by an automatic defense form"],
637 com: ["Unit Comparison", "Adds unit comparison tables"],
638 tic: ["Town icons", "Each city receives an icon for the town type (automatic detection)", "Additional icons are available for manual selection"],
639 til: ["Town list", "Adds the town icons to the town list"],
640 tim: ["Map", "Sets the town icons on the strategic map"],
641 wwc: ["Calculator", "Share calculation & resources counter + previous & next buttons on finished world wonders (currently not deactivatable!)"],
642 wwr: ["Ranking", "Redesigned world wonder rankings"],
643 wwi: ["Icons", 'Adds world wonder icons on the strategic map'],
644 con: ["Context menu", 'Swaps "Select town" and "City overview" in the context menu'],
645 sen: ["Sent units", 'Shows sent units in the attack/support window'],
646 tov: ["Town overview", 'Replaces the new town overview with the old window style'],
647 scr: ["Mouse wheel", 'You can change the views with the mouse wheel'],
648
649 err: ["Send bug reports automatically", "If you activate this option, you can help identify bugs."],
650 her: ["Thracian Conquest", "Downsizing of the map of the Thracian conquest."]
651 },
652 labels: {
653 uni: "Units overview",
654 total: "Total",
655 available: "Available",
656 outer: "Outside",
657 con: "Select town",
658 // Smileys
659 std: "Standard",
660 gre: "Grepolis",
661 nat: "Nature",
662 ppl: "People",
663 oth: "Other",
664 hal: "Halloween",
665 xma: "Xmas",
666 // Defense form
667 ttl: "Overview: Town defense",
668 inf: "Town information:",
669 dev: "Deviation",
670 det: "Detailed land units",
671 prm: "Premium bonuses",
672 sil: "Silver volume",
673 mov: "Troop movements:",
674 // WW
675 leg: "WW Share",
676 stg: "Stage",
677 tot: "Total",
678 // Simulator
679 str: "Unit strength",
680 los: "Loss",
681 mod: "without modificator influence",
682 // Comparison box
683 dsc: "Unit comparison",
684 hck: "Blunt",
685 prc: "Sharp",
686 dst: "Distance",
687 sea: "Sea",
688 att: "Offensive",
689 def: "Defensive",
690 spd: "Speed",
691 bty: "Booty (resources)",
692 cap: "Transport capacity",
693 res: "Costs (resources)",
694 fav: "Favor",
695 tim: "Recruiting time (s)",
696 // Trade
697 rat: "Resource ratio of an unit type",
698 shr: "Share of the storage capacity of the target city",
699 per: "Percentage trade",
700 // Sent units box
701 lab: "Sent units",
702 improved_movement: "Improved troop movement"
703 },
704 buttons: {
705 sav: "Save", ins: "Insert", res: "Reset"
706 }
707 },
708 //////////////////////////////////////////////
709 // French Translation by eclat49 //
710 //////////////////////////////////////////////
711 fr: {
712 settings: {
713 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.",
714 act: "Activation/Désactivation des fonctions:",
715 prv: "Aperçu des fonctions séparées:"
716 },
717 options: {
718 //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)"],
719 ava: ["Présentation des unités", "Indique les unités de toutes les villes."],
720 sml: ["Smileys", "Rajoutes une boite de smilies à la boite de bbcode"],
721 str: ["Force unitaire", "Ajoutes des tableaux de force unitaire dans les différentes armes"],
722 //trd: [ "Commerce", "Ajout d'une option par pourcentage, par troupes pour le commerce, ainsi qu'un affichage des limites pour les festivals" ],
723 per: ["Commerce de pourcentage", ""],
724 rec: ["Commerce de recrutement", ""],
725 cnt: ["Compteur conquête", "Comptabilise le nombre d'attaque et de soutien dans la fenêtre de conquête"],
726 way: ["Vitesse des troupes ", "Rajoutes le temps de trajet avec le bonus accélération"],
727 sim: ["Simulateur", "Modification de la présentation du simulateur et affichage permanent des options premium"],
728 spl: ["Boîte de magie", "Boîte de sort cliquable et positionnable"],
729 act: ["Boîte d'activité", "Présentation améliorée du commerce et des mouvement de troupes (mémoire de position)"],
730 pop: ["Popup de faveur", 'Change la popup de faveur'],
731 tsk: ["Barre de tâches ", "La barre de tâches augmente et minimise le fenêtre de bonus journalier"],
732 cha: ["Chat", "Remplace le chat de l'alliance à travers un chat monde."],
733 bbc: ["Formulaire de défense", "Ajout d'un bouton dans la barre BBCode pour un formulaire de défense automatique"],
734 com: ["Comparaison des unités", "Ajoutes des tableaux de comparaison des unités"],
735 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"],
736 til: ["Liste de ville", "Ajoute les icônes de la ville à la liste de la ville"],
737 tim: ["Carte", "Définit les icônes de la ville sur la carte stratégique"],
738 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)"],
739 wwr: ["", ""],
740 //wwi: [ "Icônes",'Adds world wonder icons on the strategic map' ],
741 con: ["Menu contextuel", 'Swaps "Sélectionner ville" et "Aperçu de la ville" dans le menu contextuel'],
742 sen: ["Unités envoyées", 'Affiche unités envoyées dans la fenêtre attaque/support'],
743 tov: ["Aperçu de ville", "Remplace la nouvelle aperçu de la ville avec l'ancien style de fenêtre"],
744 scr: ["Molette de la souris", 'Avec la molette de la souris vous pouvez changer les vues'],
745
746 err: ["Envoyer des rapports de bogues automatiquement", "Si vous activez cette option, vous pouvez aider à identifier les bugs."]
747 },
748 labels: {
749 uni: "Présentation des unités",
750 total: "Global",
751 available: "Disponible",
752 outer: "Extérieur",
753 con: "Sélectionner",
754 // Smileys
755 std: "Standard",
756 gre: "Grepolis",
757 nat: "Nature",
758 ppl: "Gens",
759 oth: "Autres",
760 // Defense form
761 ttl: "Aperçu: Défense de ville",
762 inf: "Renseignements sur la ville:",
763 dev: "Différence",
764 det: "Unités terrestres détaillées",
765 prm: "Bonus premium",
766 sil: "Remplissage de la grotte",
767 mov: "Mouvements de troupes:",
768 // WW
769 leg: "Participation",
770 stg: "Niveau",
771 tot: "Total",
772 // Simulator
773 str: "Force unitaire",
774 los: "Pertes",
775 mod: "sans influence de modificateur",
776 // Comparison box
777 dsc: "Comparaison des unités",
778 hck: "Contond.",
779 prc: "Blanche",
780 dst: "Jet",
781 sea: "Navale",
782 att: "Attaque",
783 def: "Défense",
784 spd: "Vitesse",
785 bty: "Butin",
786 cap: "Capacité de transport",
787 res: "Coût de construction",
788 fav: "Faveur",
789 tim: "Temps de construction (s)",
790 // Trade
791 rat: "Ratio des ressources d'un type d'unité",
792 shr: "Part de la capacité de stockage de la ville cible",
793 per: "Commerce de pourcentage",
794 // Sent units box
795 lab: "Envoyée",
796 improved_movement: "Mouvement des troupes amélioré"
797 },
798 buttons: {
799 sav: "Sauver", ins: "Insertion", res: "Remettre"
800 }
801 },
802 //////////////////////////////////////////////
803 // Russian Translation by MrBobr //
804 //////////////////////////////////////////////
805 ru: {
806 settings: {
807 dsc: "DIO-Tools изменÑет некоторые окна, добавлÑет новые Ñмайлы, отчёты,<br>улучшеные варианты торговли и другие функции.",
808 act: "Включение/выключение функций:",
809 prv: "Примеры внеÑённых изменений:"
810 },
811 options: {
812 //bir: ["Счётчик бирем", "Показывает чиÑло бирем во вÑех городах"],
813 ava: ["Обзор единиц", "Указывает единицы вÑех городов"], // ?
814 sml: ["Смайлы", "ДобавлÑет кнопку Ð´Ð»Ñ Ð²Ñтавки Ñмайлов в ÑообщениÑ"],
815 str: ["Сила отрÑда", "ДобавлÑет таблицу общей Ñилы отрÑда в некоторых окнах"],
816 //trd: [ "ТорговлÑ", "ДобавлÑет маркеры и отправку недоÑтающих реÑурÑов, необходимых Ð´Ð»Ñ Ñ„ÐµÑтивалÑ. ИнÑтрументы Ð´Ð»Ñ Ð´Ð¾Ð»ÐµÐ²Ð¾Ð¹ торговли" ],
817 per: ["Процент торговлÑ", ""],
818 rec: ["Рекрутинг торговлÑ", ""],
819 cnt: ["ЗавоеваниÑ", "Отображение общего чиÑла атак/подкреплений в окне Ð·Ð°Ð²Ð¾ÐµÐ²Ð°Ð½Ð¸Ñ Ð³Ð¾Ñ€Ð¾Ð´Ð°"],
820 way: ["30% уÑкорение", "Отображает примерное Ð²Ñ€ÐµÐ¼Ñ Ð´Ð²Ð¸Ð¶ÐµÐ½Ð¸Ñ Ð¾Ñ‚Ñ€Ñда Ñ 30% бонуÑом"],
821 sim: ["СимулÑтор", "Изменение интерфейÑа ÑимулÑтора, добавление новых функций"],
822 spl: ["ЗаклинаниÑ", "ИзменÑет положение окна заклинаний"],
823 act: ["ПеремещениÑ", "Показывает окна переÑылки реÑурÑов и Ð¿ÐµÑ€ÐµÐ¼ÐµÑ‰ÐµÐ½Ð¸Ñ Ð²Ð¾Ð¹Ñк"],
824 pop: ["БлагоÑклонноÑть", "Отображение окна Ñ ÑƒÑ€Ð¾Ð²Ð½ÐµÐ¼ благоÑклонноÑти богов"],
825 tsk: ["ТаÑкбар", "Увеличение ширины таÑкбара и Ñворачивание окна ежедневной награды при входе в игру"],
826 // cha: ["Чат", 'Замена чата игры на irc-чат'],
827 bbc: ["Форма обороны", "ДобавлÑет кнопку Ð´Ð»Ñ Ð²Ñтавки в Ñообщение отчёта о городе"], // Beschreibung passt nicht ganz
828 com: ["Сравнение юнитов", "ДобавлÑет окно ÑÑ€Ð°Ð²Ð½ÐµÐ½Ð¸Ñ ÑŽÐ½Ð¸Ñ‚Ð¾Ð²"],
829 tic: ["Типы городов", "Каждый город получает значок Ð´Ð»Ñ Ð³Ð¾Ñ€Ð¾Ð´Ñкого типа (автоматичеÑкое определение)", "Дополнительные иконки доÑтупны Ð´Ð»Ñ Ñ€ÑƒÑ‡Ð½Ð¾Ð³Ð¾ выбора"], // ?
830 til: ["СпиÑок город", "ДобавлÑет значки городÑкие в ÑпиÑок города"], // ?
831 tim: ["Карта", "УÑтанавливает городÑкие иконки на ÑтратегичеÑкой карте"], // ?
832 wwc: ["Чудо Ñвета", "Share calculation & resources counter + previous & next buttons on finished world wonders (currently not deactivatable!)"],
833 wwr: ["", ""],
834 //wwi: [ "World wonder icons",'Adds world wonder icons on the strategic map' ],
835 //con: [ "Context menu", 'Swaps "Select town" and "City overview" in the context menu'],
836 //sen: [ "Sent units", 'Shows sent units in the attack/support window'],
837 tov: ["Обзор Город", 'ЗаменÑет новый обзор города Ñ Ñтаром Ñтиле окна'], // ?
838 scr: ["КолеÑо мыши", 'С помощью колеÑа мыши вы можете изменить взглÑды'], // ?
839
840 err: ["Отправить ÑÐ¾Ð¾Ð±Ñ‰ÐµÐ½Ð¸Ñ Ð¾Ð± ошибках автоматичеÑки", "ЕÑли вы включите Ñту опцию, вы можете помочь идентифицировать ошибки"]
841 },
842
843 labels: {
844 uni: "Обзор единиц",
845 total: "Oбщий",
846 available: "доÑтупный",
847 outer: "вне",
848 con: "выбирать",
849 // Smileys
850 std: "",
851 gre: "",
852 nat: "",
853 ppl: "",
854 oth: "",
855 // Defense form
856 ttl: "Обзор: Отчёт о городе",
857 inf: "Ð˜Ð½Ñ„Ð¾Ñ€Ð¼Ð°Ñ†Ð¸Ñ Ð¾ войÑках и поÑтройках:",
858 dev: "Отклонение",
859 det: "Детальный отчёт",
860 prm: "Премиум-бонуÑÑ‹",
861 sil: "Серебро в пещере",
862 mov: "ПеремещениÑ",
863 // WW
864 leg: "",
865 stg: "",
866 tot: "",
867 // Simulator
868 str: "Сила войÑк",
869 los: "Потери",
870 mod: "без учёта заклинаний, бонуÑов, иÑÑледований",
871 // Comparison box
872 dsc: "Сравнение юнитов",
873 hck: "Ударное",
874 prc: "Колющее",
875 dst: "Дальнего боÑ",
876 sea: "МорÑкие",
877 att: "Ðтака",
878 def: "Защита",
879 spd: "СкороÑть",
880 bty: "Добыча (реÑурÑÑ‹)",
881 cap: "ВмеÑтимоÑть транÑпортов",
882 res: "СтоимоÑть (реÑурÑÑ‹)",
883 fav: "БлагоÑклонноÑть",
884 tim: "Ð’Ñ€ÐµÐ¼Ñ Ð½Ð°Ð¹Ð¼Ð° (Ñ)",
885 // Trade
886 rat: "",
887 shr: "",
888 per: "",
889 // Sent units box
890 lab: "Отправлено",
891 improved_movement: "Ð£Ð»ÑƒÑ‡ÑˆÐµÐ½Ð½Ð°Ñ Ð¿ÐµÑ€ÐµÐ¼ÐµÑ‰ÐµÐ½Ð¸Ðµ войÑк"
892 },
893
894 buttons: {
895 sav: "Сохраниить", ins: "Ð’Ñтавка", res: "СброÑ"
896 }
897 },
898 //////////////////////////////////////////////
899 // Polish Translation by anpu //
900 //////////////////////////////////////////////
901 pl: {
902 settings: {
903 dsc: "DIO-Tools oferuje (między innymi) poprawione widoki, nowe uśmieszki,<br>opcje handlu i zmiany w wyglądzie.",
904 act: "Włącz/wyłącz funkcje skryptu:",
905 prv: "podgląd poszczególnych opcji:"
906 },
907 options: {
908 //bir: ["Licznik birem", "Zlicza i sumuje biremy z miast"],
909 ava: ["PrzeglÄ…d jednostek", "Wskazuje jednostki wszystkich miast"], // ?
910 sml: ["Emotki", "Dodaje dodatkowe (zielone) emotikonki"],
911 str: ["Siła jednostek", "dodaje tabelki z siłą jednostek w różnych miejscach gry"],
912 //trd: [ "Handel", "Rozszerza okno handlu o handel procentowy, proporcje surowców wg jednostek, dodaje znaczniki dla festynów" ],
913 per: ["Handel procentowy", ""],
914 rec: ["Handel rekrutacyjne", ""],
915 cnt: ["Podboje", "Zlicza wsparcia/ataki w oknie podboju (tylko własne podboje)"],
916 way: ["Prędkość wojsk", "Wyświetla dodatkowo czas jednostek dla bonusu przyspieszone ruchy wojsk"],
917 sim: ["Symulator", "Dostosowanie wyglądu symulatora oraz dodanie szybkich pól wyboru"],
918 spl: ["Ramka czarów", "Kompaktowa pływająca ramka z czarami (można umieścić w dowolnym miejscu ekranu. Zapamiętuje położenie.)"],
919 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.)"],
920 pop: ["Åaski", "Zmienia wyglÄ…d ramki informacyjnej o iloÅ›ci produkowanych Å‚ask"],
921 tsk: ["Pasek skrótów", "Powiększa pasek skrótów i minimalizuje okienko z bonusem dziennym"],
922 // cha: ["Czat", 'Zastępuje standardowy Chat chatem IRC'],
923 bbc: ["Raportów obronnych", "Rozszerza pasek skrótów BBcode o generator raportów obronnych"],
924 com: ["Porównianie", "Dodaje tabelki z porównaniem jednostek"],
925 tic: ["Ikony miasta", "Każde miasto otrzyma ikonę typu miasta (automatyczne wykrywanie)", "Dodatkowe ikony są dostępne dla ręcznego wyboru"], // ?
926 til: ["Lista miasto", "Dodaje ikony miasta do listy miasta"], // ?
927 tim: ["Mapa", "Zestawy ikon miasta na mapie strategicznej"], // ?
928 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)"],
929 wwr: ["", ""],
930 //wwi: [ "World wonder icons",'Adds world wonder icons on the strategic map' ],
931 con: ["menu kontekstowe", 'Zamiemia miejcami przycisk "wybierz miasto" z przyciskiem "podgląd miasta" po kliknięciu miasta na mapie'],
932 sen: ["Wysłane jednostki", 'Pokaż wysłane jednostki w oknie wysyłania ataków/wsparć'],
933 tov: ["Podgląd miasta", 'Zastępuje nowy podgląd miasta starym'],
934 scr: ["Zoom", 'Możesz zmienić poziom przybliżenia mapy kółkiem myszy'],
935
936 err: ["Automatycznie wysyłać raporty o błędach", "Jeśli włączysz tę opcję, możesz pomóc zidentyfikować błędy"]
937
938 },
939 labels: {
940 uni: "PrzeglÄ…d jednostek",
941 total: "Ogólny",
942 available: "Dostępny",
943 outer: "Na zewnÄ…trz",
944 con: "Wybierz miasto",
945 // Smileys
946 std: "Standard" /* "Standardowe" */,
947 gre: "Grepolis",
948 nat: "Przyroda",
949 ppl: "Ludzie",
950 oth: "Inne",
951 // Defense form
952 ttl: "PodglÄ…d: Obrona miasta",
953 inf: "Informacje o mieście:",
954 dev: "Ochyłka",
955 det: "jednostki lÄ…dowe",
956 prm: "opcje Premium",
957 sil: "Ilość srebra",
958 mov: "Ruchy wojsk",
959 // WW
960 leg: "Udział w Cudzie",
961 stg: "Poziom",
962 tot: "ÅÄ…cznie",
963 // Simulator
964 str: "Siła jednostek",
965 los: "Straty",
966 mod: "bez modyfikatorów",
967 // Comparison box
968 dsc: "Porównianie jednostek",
969 hck: "Obuchowa",
970 prc: "TnÄ…ca",
971 dst: "Dystansowa",
972 sea: "Morskie",
973 att: "Offensywne",
974 def: "Defensywne",
975 spd: "Prędkość",
976 bty: "Åup (surowce)",
977 cap: "Pojemność transportu",
978 res: "Koszta (surowce)",
979 fav: "Åaski",
980 tim: "Czas rekrutacji (s)",
981 // Trade
982 rat: "Stosunek surowców dla wybranej jednostki",
983 shr: "procent zapełnienia magazynu w docelowym mieście",
984 per: "Handel procentowy",
985 // Sent units box
986 lab: "Wysłane jednostki",
987 improved_movement: "Przyspieszone ruchy wojsk"
988 },
989 buttons: {
990 sav: "Zapisz", ins: "Wstaw", res: "Anuluj"
991 }
992 },
993 //////////////////////////////////////////////
994 // Spanish Translation by Juana de Castilla //
995 //////////////////////////////////////////////
996 es: {
997 settings: {
998 dsc: "DIO-Tools ofrece, entre otras cosas, varias pantallas, ventana de <br>emoticones, opciones de comercio y algunos cambios en el diseño.",
999 act: "Activar/desactivar caracterÃsticas de las herramientas:",
1000 prv: "Vista previa de varias caracterÃsticas:"
1001 },
1002 options: {
1003 //bir: ["Contador de birremes", "Cuenta los birremes de una ciudad y los suma"],
1004 ava: ["Información general unidades", "Indica las unidades de todas las ciudades"], // ?
1005 sml: ["Emoticones", "Código BB para emoticones"],
1006 str: ["Fortaleza de la Unidad", "Añade tabla de fortalezas de cada unidad en varias zonas"],
1007 //trd: [ "Comercio", "Añade en la pestaña de comercio un porcentaje de comercio y reclutamiento y limitadores de Mercado por cada ciudad" ],
1008 per: ["Comercio de porcentual", ""],
1009 rec: ["Comercio de reclutamiento", ""],
1010 cnt: ["Conquistas", "contador de ataques y refuerzos en la pestaña de conquista"],
1011 way: ["Velocidad de tropas", "Muestra movimiento de tropas mejorado en la ventana de ataque/refuerzo"],
1012 sim: ["Simulador", "Adaptación de la ventana del simulador incluyendo recuadro de modificadores"],
1013 spl: ["Ventana de hechizos", "Ventana deslizante y comprimida de los hechizos (memoria posicional)"],
1014 act: ["Ventana de actividad", "Mejora las ventanas de comercio y movimiento de tropas (memoria posicional)"],
1015 pop: ["Popup", "Cambia el popup de favores"],
1016 tsk: ["Barra de tareas", "aumenta la barra de tareas y minimice la recompensa al aparecer"],
1017 // cha: ["Chat", 'Sustituye el chat de la alianza con un irc chat.'],
1018 bbc: ["Formulario de defensa", "Añade en la barra de códigos bb un formulario de defensa"],
1019 com: ["Comparación", "añade ventana de comparación de unidades"],
1020 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"],
1021 til: ["Lista de la ciudad", "Agrega los iconos de la ciudad a la lista de la ciudad"],
1022 tim: ["Map", "Establece los iconos de la ciudad en el mapa estratégico"],
1023 wwc: ["Maravillas", "Calcula participación & contador de recursos + antes y después teclas de maravillas terminadas (no desactibable ahora!)"],
1024 wwr: ["", ""],
1025 //wwi: [ "World wonder icons",'Adds world wonder icons on the strategic map' ],
1026 con: ["menú contextual", 'Cambia "Elegir ciudad" y "vista de la ciudad" en el menú contextual '],
1027 sen: ["Unidades enviadas", 'Muestra las unidades enviadas en la ventana de ataque/refuerzos'],
1028 tov: ["Información de la ciudad", 'sustituye la vista nueva de ciudad por la ventana antigua'],
1029 scr: ["Rueda raton", 'Puede cambiar las vistas con la rueda del raton'],
1030
1031 err: ["Enviar informes de errores automáticamente", "Si se activa esta opción, puede ayudar a identificar errores."]
1032 },
1033 labels: {
1034 uni: "Información general unidades",
1035 total: "Total",
1036 available: "Disponible",
1037 outer: "Fuera",
1038 con: "Escoger ciudad",
1039 // Smileys
1040 std: "Standard",
1041 gre: "Grepolis",
1042 nat: "Natura",
1043 ppl: "Gente",
1044 oth: "Otros",
1045 // Defense form
1046 ttl: "Vista general: Defensa de la ciudad",
1047 inf: "Información de la ciudad:",
1048 dev: "Desviación",
1049 det: "Unidades de tierra detalladas",
1050 prm: "Bonos Premium",
1051 sil: "Volumen de plata",
1052 mov: "Movimientos de tropas:",
1053 // WW
1054 leg: "WW cuota",
1055 stg: "Nivel",
1056 tot: "Total",
1057 // Simulator
1058 str: "Fortaleza de la Unidad",
1059 los: "Perdida",
1060 mod: "sin influencia del modificador",
1061 // Comparison box
1062 dsc: "Comparación de Unidades",
1063 hck: "Contundente",
1064 prc: "Punzante",
1065 dst: "Distancia",
1066 sea: "Mar",
1067 att: "Ataque",
1068 def: "Defensa",
1069 spd: "Velocidad",
1070 bty: "BotÃn (recursos)",
1071 cap: "Capacidad de transporte",
1072 res: "Costes (recursos)",
1073 fav: "Favor",
1074 tim: "Tiempo de reclutamiento (s)",
1075 // Trade
1076 rat: "Proporción de recursos de un tipo de unidad",
1077 shr: "Porcentaje de la capacidad de almacenamiento de la ciudad destino",
1078 per: "Porcentaje de comercio",
1079 // Sent units box
1080 lab: "Unidades enviadas",
1081 improved_movement: "Movimiento de tropas mejorados"
1082 },
1083 buttons: {
1084 sav: "Guardar", ins: "Insertar", res: "Reinicio"
1085 }
1086 },
1087 ar: {},
1088 //////////////////////////////////////////////
1089 // Portuguese (BR) Translation by HELL //
1090 //////////////////////////////////////////////
1091 br: {
1092 settings: {
1093 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.",
1094 act: "Ativar/desativar recursos do conjunto de ferramentas:",
1095 prv: "Pré-visualização de vários recursos:",
1096
1097 version_old: "Versão não está atualizada",
1098 version_new: "Versão está atualizada",
1099 version_dev: "Versão do desenvolvedor",
1100
1101 version_update: "Atualização",
1102
1103 link_forum: "http://forum.en.grepolis.com/showthread.php?52104&goto=newpost",
1104 link_contact: "http://forum.en.grepolis.com/private.php?do=newpm&u=46211",
1105
1106 forum: "Forum",
1107 author: "Autor",
1108
1109 cat_units: "Unidades",
1110 cat_icons: "Ãcones nas Cidades",
1111 cat_forum: "Forum",
1112 cat_trade: "Comércio",
1113 cat_wonders: "Maravilhas do Mundo",
1114 cat_layout: "Layout",
1115 cat_other: "Outros"
1116 },
1117 options: {
1118 // bir: ["Contador de Birremes", "Conta as biremes da cidade na cidade"],
1119 ava: ["Visão Geral da unidade", "Indica as unidades de todas as cidades"], // ?
1120 sml: ["Smilies", "Estende o bbcode com uma caixa de smiley"],
1121 str: ["Força das Tropas", "Adiciona quadros de força das tropas em diversas áreas"],
1122 tra: ["Capacidade de Transporte", "Mostra a capacidade de transporte ocupado e disponÃvel no menu de unidades"],
1123 per: ["Percentual de comércio", "Estende-se a janela de comércio com um percentual de comércio"],
1124 rec: ["Comércio para recrutamento", "Estende-se a janela de comércio com um comércio de recrutamento"],
1125 cnt: ["Conquistas", "Conta os ataques/apoios na janela de conquista"],
1126 way: ["Velocidade da Tropa", "Displays mostram a possivél velocidade de tropa na janela de ataque/suporte"],
1127 sim: ["Simulador", "Adaptação do layout simulador & exposição permanente da caixa poderes estendida"],
1128 spl: ["Caixa de Poderes Divinos", "Pequena caixa móvel & magnética de poderes divinos (com memória de posição) "],
1129 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)"],
1130 pop: ["Caixa de favores divino", "Altera a caixa de favores divino por um novo layout"],
1131 tsk: ["Barra de tarefas", "Aumenta a barra de tarefas e minimiza a janela recompensa diária no inicio"],
1132 // cha: ["Chat", 'Substituiu o da bate-papo por um bate-papo IRC.'],
1133 bbc: ["Pedido de Apoio", "Estende a barra de bbcode com uma forma de Pedido de Apoio Automática"],
1134 com: ["Comparação de Unidades", "Adiciona tabelas de comparação de unidade"],
1135 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"],
1136 til: ["Lista das Cidades", "Adiciona os Ãcones da cidade na lista de cidades"],
1137 tim: ["Mapa", "Mostra os Ãcones das cidades no mapa estratégico"],
1138 wwc: ["Calculadora de WW", "Cálculo compartilhado & contador de recursos + botões anterior e próxima maravilhas do mundo (atualmente não desactivável!)"],
1139 wwr: ["Classificação", "Classificação das maravilha do mundo redesenhadas"],
1140 wwi: ["Icones", 'Adiciona Ãcones nas maravilha do mundo no mapa estratégico'],
1141 con: ["Menu de Contexto", 'Troca da "Selecione cidade" e "Visão Geral da Cidade" no menu de contexto'],
1142 sen: ["Unidades Enviadas", 'Shows sent units in the attack/support window'],
1143 tov: ["Visão da Cidade", 'Substitui o novo panorama da cidade, com o estilo da janela antiga'],
1144 scr: ["Roda do Mouse", 'Você pode alterar os pontos de vista com a roda do mouse'],
1145
1146 err: ["Enviar automaticamente relatórios de erros", "Se você ativar essa opção, você pode ajudar a identificar erros."],
1147 her: ["Conquista Thracian", "Redução de tamanho do mapa da conquista Thracian."]
1148 },
1149 labels: {
1150 uni: "Visão Geral da unidade",
1151 total: "Global",
1152 available: "DisponÃvel",
1153 outer: "Fora",
1154 con: "Selecionar cidade",
1155 // Smileys
1156 std: "Padrão",
1157 gre: "Grepolis",
1158 nat: "Natural",
1159 ppl: "Popular",
1160 oth: "Outros",
1161 hal: "Halloween",
1162 xma: "Natal",
1163 // Defense form
1164 ttl: "Pedido de Apoio",
1165 inf: "Informação da cidade:",
1166 dev: "Desvio",
1167 det: "Unidades Detalhadas",
1168 prm: "Bônus Premium",
1169 sil: "Prata na Gruta",
1170 mov: "Movimentação de Tropas:",
1171 // WW
1172 leg: "WW Maravilhas",
1173 stg: "Level",
1174 tot: "Total",
1175 // Simulator
1176 str: "Força das Unidades",
1177 los: "Perdas",
1178 mod: "Sem modificador de influência",
1179 // Comparison box
1180 dsc: "Comparação de unidades",
1181 hck: "Impacto",
1182 prc: "Corte",
1183 dst: "Arremço",
1184 sea: "Naval",
1185 att: "Ofensivo",
1186 def: "Defensivo",
1187 spd: "Velocidade",
1188 bty: "Saque (recursos)",
1189 cap: "Capacidade de trasporte",
1190 res: "Custo (recursos)",
1191 fav: "Favor",
1192 tim: "Tempo de recrutamento (s)",
1193 // Trade
1194 rat: "Proporção de recursos de um tipo de unidade",
1195 shr: "A partir do armazenamento sobre a cidade de destino",
1196 per: "Percentual de comércio",
1197 // Sent units box
1198 lab: "Unidades enviadas",
1199 improved_movement: "Movimentação de tropas com ajuste de bônus"
1200 },
1201 buttons: {
1202 sav: "Salvar", ins: "Inserir", res: "Resetar"
1203 }
1204 },
1205 pt : {},
1206 //////////////////////////////////////////////
1207 // Czech Translation by Piwus //
1208 //////////////////////////////////////////////
1209 cz: {
1210 settings: {
1211 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ů.",
1212 act: "Aktivovat/Deaktivovat funkce sady nástrojů:",
1213 prv: "Ukázka nÄ›kolika funkcÃ:",
1214
1215 version_old: "Verze je zastaralá",
1216 version_new: "Verze je aktuálnÃ",
1217 version_dev: "Vývojářská verze",
1218
1219 version_update: "Aktualizovat",
1220
1221 link_forum: "http://forum.en.grepolis.com/showthread.php?52104&goto=newpost",
1222 link_contact: "http://forum.en.grepolis.com/private.php?do=newpm&u=46211",
1223
1224 forum: "Forum",
1225 author: "Autor",
1226
1227 cat_units: "Jednotky",
1228 cat_icons: "Ikony měst",
1229 cat_forum: "Forum",
1230 cat_trade: "Obchod",
1231 cat_wonders: "Div světa",
1232 cat_layout: "Okna",
1233 cat_other: "OstatnÃ"
1234 },
1235 options: {
1236 // bir: ["PoÄÃtadlo birém", "SpoÄÃtá každé birémy ve mÄ›stech a seÄte je."],
1237 ava: ["Jednotky PÅ™ehled", "OznaÄuje jednotky vÅ¡emi mÄ›sty"], // ?
1238 sml: ["SmajlÃci", "RozÅ¡iÅ™uje panel BBkodů okénkem smajlÃků"],
1239 str: ["SÃla jednotek", "PÅ™idává tabulku sil jednotek v různých oblastech"],
1240 tra: ["Transportnà kapacita", "Zobrazuje obsazenou a dostupnou transportnà kapacitu v nabÃdce jednotek"],
1241 per: ["Procentuálnà obchod", "RozÅ¡iÅ™uje obchodnà okno možnostà procentuálnÃho obchodu"],
1242 rec: ["Obchod rekrutace", "Rozšiřuje obchodnà okno možnostà obchodem pro rekrutaci"],
1243 cnt: ["DobývánÃ", "PoÄÃtá Útok/Obrana v oknÄ› dobývánà (pouze vlastnà dobývánà zatÃm)"],
1244 way: ["Rychlost vojsk", "Zobrazuje vylepšenou rychlost vojsk v okně útoku/obrany"],
1245 sim: ["Simulátor", "PÅ™izpůsobenà rozloženà simulátoru & permanentnà zobrazovánà rozÅ¡ÃÅ™eného okna modifikátoru"],
1246 spl: ["Okénko kouzel", "StlaÄené klouzánà oken & magnetické okénko kouzel (pozice pamÄ›ti)"],
1247 act: ["Aktivnà okénka", "ZlepÅ¡ený zobrazenà obchodů a vojsk aktivnÃmi okénky (pozice pamÄ›ti)"],
1248 pop: ["Vyskakovacà okénko pÅ™ÃznÄ›", "ZmÄ›nà vyskakovacà okno seznamu pÅ™ÃznÃ"],
1249 tsk: ["Hlavnà panel", "ZvyÅ¡uje hlavnà panel a minimalizuje bonus dennà odmÄ›ny po pÅ™ihlášenÃ"],
1250 // cha: ["Chat", 'Nahrazen alianÄnà chat chatem IRC.'],
1251 bbc: ["Obranné hlášenÃ", "RozÅ¡iÅ™uje panel BBkodů automatickém hlášenà obrany mÄ›sta"],
1252 com: ["Porovnánà jednotek", "Přidává tabulku porovnánà jednotek"],
1253 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ě"],
1254 til: ["Seznam měst", "Přidává ikony měst do seznamu měst"],
1255 tim: ["Mapa", "Přidává ikony měst na stategickou mapu"],
1256 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!)"],
1257 wwr: ["ŽebÅ™ÃÄek", "PÅ™edÄ›laný žebÅ™ÃÄek divů svÄ›ta"],
1258 wwi: ["Ikony", 'PÅ™Ãdává ikony divů svÄ›ta na strategickou mapu'],
1259 con: ["Kontextové menu", 'Vyměňuje "Vybrat město" a "Přehled města" v kontextovém menu'],
1260 sen: ["Odeslané jednotky", 'Zobrazuje odeslané jednotky útoku/obrany v okně'],
1261 tov: ["PÅ™ehled mÄ›sta", 'Nahrazuje nový pÅ™ehled mÄ›st starÅ¡Ãm stylem okna'],
1262 scr: ["KoleÄko myÅ¡i", 'MůžeÅ¡ zmÄ›nit pohledy s koleÄkem myÅ¡i'],
1263
1264 err: ["Hlásit chyby automaticky", "Pokud aktivuješ tuto možnost,pomůžeš nám identifikovat chyby."],
1265 her: ["Thrácké dobývánÃ", "Redukuje mapy Thráckého dobývánÃ."]
1266 },
1267 labels: {
1268 uni: "Jednotky Přehled",
1269 total: "Celkový",
1270 available: "K dispozici",
1271 outer: "VnÄ›",
1272 con: "Zvolit město",
1273 // Smileys
1274 std: "StandartnÃ",
1275 gre: "Grepolis",
1276 nat: "PÅ™Ãroda",
1277 ppl: "Lidi",
1278 oth: "OstatnÃ",
1279 hal: "Halloween",
1280 xma: "Vánoce",
1281 // Defense form
1282 ttl: "Přehled: Obrana města",
1283 inf: "Informace o městě:",
1284 dev: "Odchylka",
1285 det: "Podrobné pozemnà jednotky",
1286 prm: "Prémiové bonusy",
1287 sil: "Objem stÅ™Ãbra",
1288 mov: "Pohyby vojsk:",
1289 // WW
1290 leg: "PodÃl divu svÄ›ta",
1291 stg: "Stupeň",
1292 tot: "Celkem",
1293 // Simulator
1294 str: "SÃla jednotek",
1295 los: "Ztráta",
1296 mod: "bez vlivu modifikátoru",
1297 // Comparison box
1298 dsc: "Porovnánà jednotek",
1299 hck: "SeÄné",
1300 prc: "Bodné",
1301 dst: "Střelné",
1302 sea: "Moře",
1303 att: "ÚtoÄné",
1304 def: "Obranné",
1305 spd: "Rychlost",
1306 bty: "Kořist (suroviny)",
1307 cap: "Transportnà kapacita",
1308 res: "Náklady (suroviny)",
1309 fav: "PÅ™Ãzeň",
1310 tim: "Doba rekrutovánà (s)",
1311 // Trade
1312 rat: "Poměr surovin typu jednotky",
1313 shr: "PodÃl na úložné kapacitÄ› cÃlového mÄ›sta",
1314 per: "Procentuálnà obchod",
1315 // Sent units box
1316 lab: "Odeslané jednotky",
1317 improved_movement: "Vylepšený pohyb jednotek"
1318 },
1319 buttons: {
1320 sav: "Uložit", ins: "Vložit", res: "Resetovat"
1321 }
1322 }
1323 };
1324
1325 LANG.ar = LANG.es;
1326 LANG.pt = LANG.br;
1327 LANG.cs = LANG.cz;
1328
1329 // Create JSON
1330 // console.log(JSON.stringify(LANG.en));
1331
1332 // Forum: Choose language
1333 if (!(uw.location.pathname.indexOf("game") >= 0)) {
1334 LID = uw.location.host.split(".")[1];
1335 }
1336
1337 console.debug("SPRACHE", LID);
1338 // Translation GET
1339 function getText(category, name) {
1340 var txt = "???";
1341 if (LANG[LID]) {
1342 if (LANG[LID][category]) {
1343 if (LANG[LID][category][name]) {
1344 txt = LANG[LID][category][name];
1345 } else {
1346 if (LANG.en[category]) {
1347 if (LANG.en[category][name]) {
1348 txt = LANG.en[category][name];
1349 }
1350 }
1351 }
1352 } else {
1353 if (LANG.en[category]) {
1354 if (LANG.en[category][name]) {
1355 txt = LANG.en[category][name];
1356 }
1357 }
1358 }
1359 } else {
1360 if (LANG.en[category]) {
1361 if (LANG.en[category][name]) {
1362 txt = LANG.en[category][name];
1363 }
1364 }
1365 }
1366 return txt;
1367 }
1368
1369 /*******************************************************************************************************************************
1370 * Settings
1371 *******************************************************************************************************************************/
1372
1373 // (De)activation of the features
1374 var options_def = {
1375 bir: true, // Biremes counter
1376 ava: true, // Available units
1377 sml: true, // Smileys
1378 str: true, // Unit strength
1379 tra: true, // Transport capacity
1380 per: true, // Percentual Trade
1381 rec: true, // Recruiting Trade
1382 way: true, // Troop speed
1383 cnt: true, // Attack/support counter
1384 sim: true, // Simulator
1385 spl: true, // Spell box
1386 act: false,// Activity boxes
1387 tsk: true, // Task bar
1388 cha: true, // Chat
1389 pop: true, // Favor popup
1390 bbc: true, // BBCode bar
1391 com: true, // Unit comparison
1392 tic: true, // Town icons
1393 til: true, // Town icons: Town list
1394 tim: true, // Town icons: Map
1395 wwc: true, // World wonder counter
1396 wwr: true, // World wonder ranking
1397 wwi: true, // World wonder icons
1398 con: true, // Context menu
1399 sen: true, // Sent units
1400 tov: false,// Town overview
1401 scr: true, // Mausrad,
1402
1403 err: false,// Error Reports
1404 her: true // Thrakische Eroberung
1405 };
1406
1407 if (uw.location.pathname.indexOf("game") >= 0) {
1408 for (var opt in options_def) {
1409 if (options_def.hasOwnProperty(opt)) {
1410 if (DATA.options[opt] === undefined) {
1411 DATA.options[opt] = options_def[opt];
1412 }
1413 }
1414 }
1415 }
1416
1417 var version_text = '', version_color = 'black';
1418
1419 function getLatestVersion() {
1420 $('<style id="dio_version">' +
1421 '#version_info .version_icon { background: url(http://666kb.com/i/ct1etaz0uyohw402i.png) -50px -50px no-repeat; width:25px; height:25px; float:left; } ' +
1422 '#version_info .version_icon.red { filter:hue-rotate(-100deg); -webkit-filter: hue-rotate(-100deg); } ' +
1423 '#version_info .version_icon.green { filter:hue-rotate(0deg); -webkit-filter: hue-rotate(0deg); } ' +
1424 '#version_info .version_icon.blue { filter:hue-rotate(120deg); -webkit-filter: hue-rotate(120deg); } ' +
1425 '#version_info .version_text { line-height: 2; margin: 0px 6px 0px 6px; float: left;} ' +
1426 '</style>').appendTo("head");
1427
1428 var v_info = $('#version_info');
1429 if (version_text === '') {
1430 $.ajax({
1431 type: "GET", url: "https://diotools.de/scripts/version.php",
1432 success: function (response) {
1433 var latest_version = parseFloat(response),
1434 current_version = parseFloat(version);
1435
1436 if (current_version < latest_version) {
1437 version_text = "<div class='version_icon red'></div><div class='version_text'>" + getText('settings', 'version_old') + "</div><div class='version_icon red'></div>" +
1438 '<a class="version_text" href="https://diotools.de/downloads/DIO-TOOLS.user.js" target="_blank">--> Update</a>';
1439 version_color = 'crimson';
1440 } else if (current_version == latest_version) {
1441 version_text = "<div class='version_icon green'></div><div class='version_text'>" + getText('settings', 'version_new') + "</div><div class='version_icon green'></div>";
1442 version_color = 'darkgreen';
1443 } else {
1444 version_text = "<div class='version_icon blue'></div><div class='version_text'>" + getText('settings', 'version_dev') + "</div><div class='version_icon blue'></div>";
1445 version_color = 'darkblue';
1446 }
1447 v_info.html(version_text).css({color: version_color});
1448 }
1449 });
1450 } else {
1451 v_info.html(version_text).css({color: version_color});
1452 }
1453 }
1454
1455 // Add DIO-Tools to grepo settings
1456 function settings() {
1457 var wid = $(".settings-menu").get(0).parentNode.id;
1458
1459 if (!$("#dio_tools").get(0)) {
1460 $(".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>');
1461 }
1462
1463 $(".settings-link").click(function () {
1464 $('.section').each(function () {
1465 this.style.display = "block";
1466 });
1467 $('.settings-container').removeClass("dio_overflow");
1468
1469 $('#dio_bg_medusa').css({display: "none"});
1470
1471 if ($('#dio_settings').get(0)) {
1472 $('#dio_settings').get(0).style.display = "none";
1473 }
1474 });
1475
1476 $("#dio_tools").click(function () {
1477 if ($('.email').get(0)) {
1478 $('.settings-container').removeClass("email");
1479 }
1480
1481 $('.settings-container').addClass("dio_overflow");
1482
1483 $('#dio_bg_medusa').css({display: "block"});
1484
1485 if (!$('#dio_settings').get(0)) {
1486 // Styles
1487 $('<style id="dio_settings_style">' +
1488 // Chrome Scroollbar Style
1489 '#dio_settings ::-webkit-scrollbar { width: 13px; } ' +
1490 '#dio_settings ::-webkit-scrollbar-track { background-color: rgba(130, 186, 135, 0.5); border-top-right-radius: 4px; border-bottom-right-radius: 4px; } ' +
1491 '#dio_settings ::-webkit-scrollbar-thumb { background-color: rgba(87, 121, 45, 0.5); border-radius: 3px; } ' +
1492 '#dio_settings ::-webkit-scrollbar-thumb:hover { background-color: rgba(87, 121, 45, 0.8); } ' +
1493
1494 '#dio_settings table tr :first-child { text-align:center; vertical-align:top; } ' +
1495
1496 '#dio_settings #version_info { font-weight:bold;height: 35px;margin-top:-5px; } ' +
1497 '#dio_settings #version_info img { margin:-1px 2px -8px 0px; } ' +
1498
1499 '#dio_settings .icon_types_table { font-size:0.7em; line-height:2.5; border:1px solid green; border-spacing:10px 2px; border-radius:5px; } ' +
1500 '#dio_settings .icon_types_table td { text-align:left; } ' +
1501
1502 '#dio_settings table p { margin:0.2em 0em; } ' +
1503
1504 '#dio_settings .checkbox_new .cbx_caption { white-space:nowrap; margin-right:10px; font-weight:bold; } ' +
1505
1506 '#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;} ' +
1507
1508 '#dio_settings .dio_settings_tabs li { float:left; } ' +
1509
1510 '#dio_settings .icon_small { margin:0px; } ' +
1511
1512 '#dio_settings img { max-width:90px; max-height:90px; margin-right:10px; } ' +
1513
1514 '#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; } ' +
1515 '#dio_settings .content .content_category { display:none; border-spacing:5px; } ' +
1516
1517 '#dio_settings .dio_options_table legend { font-weight:bold; } ' +
1518 '#dio_settings .dio_options_table p { margin:0px; } ' +
1519 '#dio_settings #donate_btn { filter: hue-rotate(45deg); -webkit-filter: hue-rotate(45deg); } ' +
1520
1521 '#donate_btn { background: url(' + dio_sprite + '); width:100px; height:26px; background-position: 0px -300px; } ' +
1522 '#donate_btn.de { background-position: 0px -250px; } ' +
1523 '#donate_btn.en { background-position: 0px -300px; } ' +
1524
1525 '#dio_hall table { border-spacing: 9px 3px; } ' +
1526 '#dio_hall table th { text-align:left !important;color:green;text-decoration:underline;padding-bottom:10px; } ' +
1527 '#dio_hall table td.value { text-align: right; } ' +
1528
1529 '#dio_hall table td.laurel.green { background: url("/images/game/ally/founder.png") no-repeat; height:18px; width:18px; background-size:100%; } ' +
1530 '#dio_hall table td.laurel.bronze { background: url("https://diotools.de/images/game/laurel_sprite.png") no-repeat 25%; height:18px; width:18px; } ' +
1531 '#dio_hall table td.laurel.silver { background: url("https://diotools.de/images/game/laurel_sprite.png") no-repeat 50%; height:18px; width:18px; } ' +
1532 '#dio_hall table td.laurel.gold { background: url("https://diotools.de/images/game/laurel_sprite.png") no-repeat 75%; height:18px; width:18px; } ' +
1533 '#dio_hall table td.laurel.blue { background: url("https://diotools.de/images/game/laurel_sprite.png") no-repeat 100%; height:18px; width:18px; } ' +
1534 '</style>').appendTo('head');
1535
1536
1537 $('.settings-container').append(
1538 '<div id="dio_settings" class="player_settings section"><div id="dio_bg_medusa"></div>' +
1539 '<div class="game_header bold"><a href="#" target="_blank" style="color:white">DIO-Tools (v' + version + ')</a></div>' +
1540
1541 // Check latest version
1542 '<div id="version_info"><img src="http://666kb.com/i/csmicltyu4zhiwo5b.gif" /></div>' +
1543
1544 // Donate button
1545 '<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">' +
1546 '<div id="donate_btn" class="' + LID + '" alt="Donate"></div></a></div>' +
1547
1548 // Settings navigation
1549 '<ul class="menu_inner dio_settings_tabs">' +
1550 '<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>' +
1551 '<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>' +
1552 '<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>' +
1553 '<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>' +
1554 '<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>' +
1555 '<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>' +
1556 '<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>' +
1557 '</ul>' +
1558
1559 // Settings content
1560 '<DIV class="content">' +
1561
1562 // Units tab
1563 '<table id="dio_units_table" class="content_category visible"><tr>' +
1564 '<td><img src="https://diotools.de/images/game/settings/units/available_units.png" alt="" /></td>' +
1565 '<td><div id="ava" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "ava")[0] + '</div></div>' +
1566 '<p>' + getText("options", "ava")[1] + '</p></td>' +
1567 '</tr><tr>' +
1568 '<td><img src="https://diotools.de/images/game/settings/units/sent_units.png" alt="" /></td>' +
1569 '<td><div id="sen" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "sen")[0] + '</div></div>' +
1570 '<p>' + getText("options", "sen")[1] + '</p></td>' +
1571 '</tr><tr>' +
1572 '<td><img src="https://diotools.de/images/game/settings/units/unit_strength.png" alt="" /></td>' +
1573 '<td><div id="str" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "str")[0] + '</div></div>' +
1574 '<p>' + getText("options", "str")[1] + '</p></td>' +
1575 '</tr><tr>' +
1576 '<td><img src="https://diotools.de/images/game/settings/units/transport_capacity.png" alt="" /></td>' +
1577 '<td><div id="tra" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "tra")[0] + '</div></div>' +
1578 '<p>' + getText("options", "tra")[1] + '</p></td>' +
1579 '</tr><tr>' +
1580 '<td><img src="https://diotools.de/images/game/settings/units/unit_comparison.png" alt="" /></td>' +
1581 '<td><div id="com" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "com")[0] + '</div></div>' +
1582 '<p>' + getText("options", "com")[1] + '</p></td>' +
1583 '</tr></table>' +
1584
1585 // Icons tab
1586 '<table id="dio_icons_table" class="content_category"><tr>' +
1587 '<td><img src="https://diotools.de/images/game/settings/townicons/townicons.png" alt="" /></td>' +
1588 '<td><div id="tic" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "tic")[0] + '</div></div>' +
1589 '<p>' + getText("options", "tic")[1] + '</p>' +
1590 '<table class="icon_types_table">' +
1591 '<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>' +
1592 '<tr><td><div class="icon_small townicon_ld"></div> Land Defensive</td>' + '<td><div class="icon_small townicon_fd"></div> Fly Defensive</td></tr>' +
1593 '<tr><td><div class="icon_small townicon_so"></div> Navy Offensive</td>' + '<td><div class="icon_small townicon_no"></div> Outside</td></tr>' +
1594 '<tr><td><div class="icon_small townicon_sd"></div> Navy Defensive</td>' + '<td><div class="icon_small townicon_po"></div> Empty</td></tr>' +
1595 '</table><br>' +
1596 '<p>' + getText("options", "tic")[2] + ':</p>' +
1597 '<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>' +
1598 '<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>' +
1599 '<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>' +
1600 '<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>' +
1601 '<div class="icon_small townicon_wo"></div>' +
1602 '</td>' +
1603 '</tr><tr>' +
1604 '<td><img src="https://diotools.de/images/game/settings/townicons/townlist.png" alt="" style="border: 1px solid rgb(158, 133, 78);" /></td>' +
1605 '<td><div id="til" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "til")[0] + '</div></div>' +
1606 '<p>' + getText("options", "til")[1] + '</p></td>' +
1607 '</tr><tr>' +
1608 '<td><img src="https://diotools.de/images/game/settings/townicons/map.png" alt="" /></td>' +
1609 '<td><div id="tim" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "tim")[0] + '</div></div>' +
1610 '<p>' + getText("options", "tim")[1] + '</p></td>' +
1611 '</tr></table>' +
1612
1613 // Forum tab
1614 '<table id="dio_forum_table" class="content_category"><tr>' +
1615 '<td><img src="https://diotools.de/images/game/settings/forum/smiley_box.png" alt="" /></td>' +
1616 '<td><div id="sml" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "sml")[0] + '</div></div>' +
1617 '<p>' + getText("options", "sml")[1] + '</p>' +
1618 '<img src="http://www.greensmilies.com/smile/smiley_emoticons_mttao_wassermann.gif" /> <img src="http://666kb.com/i/cigrqlp2odi2kqo24.gif" /> ' +
1619 '<img src="http://666kb.com/i/cifvfsu3e2sdiipn0.gif" alt="" /> <img src="http://666kb.com/i/cigmv8wnffb3v0ifg.gif" /> ' +
1620 '<img src="http://666kb.com/i/cj2byjendffymp88t.gif" alt="" /> <img src="http://666kb.com/i/cj1l9gndtu3nduyvi.gif" /> ' +
1621 '<img src="http://666kb.com/i/cigrmpfofys5xtiks.gif" alt="" />' + //'<img src="http://666kb.com/i/cifohielywpedbyh8.gif" />'+
1622 '<br><br><br></td>' +
1623 '</tr><tr>' +
1624 '<td><img src="https://diotools.de/images/game/settings/forum/def_formular.png" alt="" /></td>' +
1625 '<td><div id="bbc" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "bbc")[0] + '</div></div>' +
1626 '<p>' + getText("options", "bbc")[1] + '</p><br><img src="http://s1.directupload.net/images/140401/9b2ydh82.png" alt="" style="max-width:none !important;" /></td>' +
1627 '</tr></table>' +
1628
1629 // Trade tab
1630 '<table id="dio_trade_table" class="content_category"><tr>' +
1631 '<td><img src="https://diotools.de/images/game/settings/trade/recruiting_trade.png" /></td>' +
1632 '<td><div id="rec" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "rec")[0] + '</div></div>' +
1633 '<p>' + getText("options", "rec")[1] + '</p><br>' +
1634 /*
1635 '<p><u>Beispiel Feuerschiffe:</u><br>'+
1636 '<p>Verhältnisauswahl</p>'+
1637 '<table style="font-size: 0.7em;line-height: 2.5;border: 1px solid green;border-spacing: 10px 2px;border-radius: 5px;">'+
1638 '<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>'+
1639 '<tr><td>Kosten</td><td>1300</td><td></td><td>300</td><td></td><td>800</td></tr>'+
1640 '<tr><td>Verhältnis</td><td>1</td><td>:</td><td>0.23</td><td>:</td><td>0.62</td></tr>'+
1641 '</table>'+
1642 '<p>Lagergröße Zielstadt: 25500 - 1000 Puffer (=100%)</p>'+
1643 '<p>Handelsmenge 25%: </p>'+
1644 '<table style="font-size: 0.7em;line-height: 2.5;">'+
1645 '<tr><td>4 x 25%</td><td>4 x 25%</td><td>...</td></tr>'+
1646 '<tr><td><img src="http://s7.directupload.net/images/140920/uc4dsyp9.png" style="width:60px" /></td>'+
1647 '<td><img src="http://s7.directupload.net/images/140920/uc4dsyp9.png" style="width:60px" /></td><td>...</td></tr>'+
1648 '</table>'+
1649 //'- 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'+
1650 //'- nach Ankommen von jeweils 5 Portionen, Einheiten in Auftrag geben (19-21 Feuerschiffe bei maximaler Lagerkapazität)'+
1651 //'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.'+
1652 //'Das Ganze beschleunigt das Befüllen der Rekrutierungsschleifen enorm und es gehen dabei keine Rohstoffe verloren.</p>'+
1653 '<br><br><br></td>'+
1654 */
1655 '</tr><tr>' +
1656 '<td><img src="https://diotools.de/images/game/settings/trade/percentage_trade.png" /></td>' +
1657 '<td><div id="per" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "per")[0] + '</div></div>' +
1658 '<p>' + getText("options", "per")[1] + '</p><br></td>' +
1659 /*
1660 '</tr><tr>'+
1661 '<td><img src="http://s7.directupload.net/images/140917/tveb5n33.png" /></td>'+
1662 '<td><div id="trd2" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">Trade Limit Marker</div></div>'+
1663 '<p></p></td>'+
1664 */
1665 '</tr></table>' +
1666
1667 // World wonder tab
1668 '<table id="dio_wonder_table" class="content_category"><tr>' +
1669 '<td><img src="https://diotools.de/images/game/settings/wonders/share.png" alt="" /></td>' +
1670 '<td><div id="wwc" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "wwc")[0] + '</div></div>' +
1671 '<p>' + getText("options", "wwc")[1] + '</p><br/>' +
1672 '<img src="https://diotools.de/images/game/settings/wonders/share_calculator.png" alt="" style="max-width:none !important;" /></td>' +
1673 '</tr><tr>' +
1674 '<td><img src="https://diotools.de/images/game/settings/wonders/ranking.png" alt="" /></td>' +
1675 '<td><div id="wwr" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "wwr")[0] + '</div></div>' +
1676 '<p>' + getText("options", "wwr")[1] + '</p></td>' +
1677 '</tr><tr>' +
1678 '<td><img src="https://diotools.de/images/game/settings/wonders/icons.png" alt="" /></td>' +
1679 '<td><div id="wwi" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "wwi")[0] + '</div></div>' +
1680 '<p>' + getText("options", "wwi")[1] + '</p></td>' +
1681 '</tr></table>' +
1682
1683 // Layout tab
1684 '<table id="dio_layout_table" class="content_category"><tr>' +
1685 '<td><img src="https://diotools.de/images/game/settings/layout/simulator.png" alt="" /></td>' +
1686 '<td><div id="sim" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "sim")[0] + '</div></div>' +
1687 '<p>' + getText("options", "sim")[1] + '</p></td>' +
1688 '</tr><tr>' +
1689 '<td><img src="https://diotools.de/images/game/settings/layout/spellbox.png" alt="" /></td>' +
1690 '<td><div id="spl" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "spl")[0] + '</div></div>' +
1691 '<p>' + getText("options", "spl")[1] + '</p></td>' +
1692 '</tr><tr>' +
1693
1694 ((Game.market_id !== "de" && Game.market_id !== "zz") ? (
1695 '<td><img src="https://diotools.de/images/game/settings/layout/taskbar.png" alt="" /></td>' +
1696 '<td><div id="tsk" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "tsk")[0] + '</div></div>' +
1697 '<p>' + getText("options", "tsk")[1] + '</p></td>' +
1698 '</tr><tr>'
1699 ) : "" ) +
1700
1701 '<td><img src="https://diotools.de/images/game/settings/layout/favor_popup.png" alt="" /></td>' +
1702 '<td><div id="pop" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "pop")[0] + '</div></div>' +
1703 '<p>' + getText("options", "pop")[1] + '</p></td>' +
1704 '</tr><tr>' +
1705 '<td><img src="https://diotools.de/images/game/settings/layout/contextmenu.png" alt="" /></td>' +
1706 '<td><div id="con" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "con")[0] + '</div></div>' +
1707 '<p>' + getText("options", "con")[1] + '</p></td>' +
1708 '</tr><tr>' +
1709 '<td><img src="https://diotools.de/images/game/settings/layout/activity_boxes.png" alt="" /></td>' +
1710 '<td><div id="act" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "act")[0] + '</div></div>' +
1711 '<p>' + getText("options", "act")[1] + '</p></td>' +
1712 '</tr></table>' +
1713
1714 // Other Stuff tab
1715 '<table id="dio_other_table" class="content_category"><tr>' +
1716 '<td><img src="https://diotools.de/images/game/settings/misc/troop_speed.png" style="border: 1px solid rgb(158, 133, 78);" alt="" /></td>' +
1717 '<td><div id="way" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "way")[0] + '</div></div>' +
1718 '<p>' + getText("options", "way")[1] + '</p></td>' +
1719 '</tr><tr>' +
1720
1721 // Betaphase in DE
1722 ((Game.market_id === "de" || Game.market_id === "zz") ? (
1723
1724 '<td><img src="https://diotools.de/images/game/settings/misc/chat_new.png" alt="" /></td>' +
1725 '<td><div id="cha" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "cha")[0] + '</div></div>' +
1726 '<p>' + getText("options", "cha")[1] + '</p></td>' +
1727 '</tr><tr>'
1728
1729 ) : "") +
1730
1731 '<td><img src="https://diotools.de/images/game/settings/misc/conquer_counter.png" style="border: 1px solid rgb(158, 133, 78);" alt="" /></td>' +
1732 '<td><div id="cnt" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "cnt")[0] + '</div></div>' +
1733 '<p>' + getText("options", "cnt")[1] + '</p></td>' +
1734 '</tr><tr>' +
1735 '<td><img src="https://diotools.de/images/game/settings/misc/mousewheel_zoom.png" alt="" /></td>' +
1736 '<td><div id="scr" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "scr")[0] + '</div></div>' +
1737 '<p>' + getText("options", "scr")[1] + '</p><br><br></td>' +
1738 '</tr><tr>' +
1739 '<td><img src="" alt="" /></td>' +
1740 '<td><div id="err" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "err")[0] + '</div></div>' +
1741 '<p>' + getText("options", "err")[1] + '</p></td>' +
1742 '</tr></table>' +
1743
1744
1745 // Hall of DIO-Tools tab
1746 '<div id="dio_hall" class="content_category">'+
1747 "<p>I like to thank all of you who helped the development of DIO-Tools by donating or translating!</p>"+
1748 '<table style="float:left;margin-right: 75px;">'+
1749 '<tr><th colspan="3">Donations</th></tr>'+
1750 (function(){
1751 var donations = [
1752 ["Eduard R", 50],
1753 ["Gregoire L", 25],
1754 ["Renee A", 20], ["Dirk R", 20], ["Patti T", 20],
1755 ["Klaus N", 15],
1756 ["Marco S", 10], ["Richard L", 10], ["Carsten K", 10], ["Tatiana H", 10], ["Ursula S", 10], ["Susanne S", 10], ["Falk T", 10],
1757 ["Belinda M", 8], ["Wolfgang R", 8],
1758 ["Miguel B", 7],
1759 ["Antje S", 5], ["Hans-Jörg S", 5], ["Deanna P", 5], ["ForexTraction", 5], ["Rene F", 5], ["Rüdiger D", 5], ["Hans Hermann S", 5],
1760 ["Siegbert M", 5], ["Wilhelm B", 5], ["Peter P", 5], ["Helga W", 5], ["Lydia R", 5],
1761 ["Michael S", 3],
1762 ["Mario P", 2], ["Artur G", 2], ["Heiko K", 2], ["Alexander B", 2], ["Dick N", 2],
1763 ["Marcel G", 1], ["Ramona L", 1], ["Dennis S", 1], ["Konstandinos K", 1], ["Sarl T", 1], ["Jagadics I", 1], ["Andreas R", 1],
1764 ["Peter F", 1], ["Vinicio G", 1], ["Marielle M", 1], ["Christian B", 1], ["Bernd W", 1], ["Maria N", 1], ["Thomas W", 1],
1765 ["Domenik F", 1], ["Oliver H", 1], ["Jens R", 1], ["Nicole S", 1], ["Hartmut S", 1], ["Alex L", 1], ["Andreas S", 1]
1766 ];
1767 var donation_table = "";
1768
1769 for(var d = 0; d < donations.length; d++){
1770
1771 var donation_class = "";
1772
1773 switch(donations[d][1]){
1774 case 50: donation_class = "gold"; break;
1775 case 25: donation_class = "silver"; break;
1776 case 20: donation_class = "bronze"; break;
1777 default: donation_class = "green"; break;
1778 }
1779
1780 donation_table += '<tr class="donation"><td class="laurel '+ donation_class +'"></td><td>' + donations[d][0] + '</td><td class="value">' + donations[d][1] + '€</td></tr>';
1781 }
1782
1783 return donation_table;
1784 })() +
1785 '</table>'+
1786 '<table>'+
1787 '<tr><th colspan="3">Translations</th></tr>'+
1788 (function(){
1789 var translations = [
1790 ["eclat49", "FR"],
1791 ["MrBobr", "RU"],
1792 ["anpu", "PL"],
1793 ["Juana de Castilla", "ES"],
1794 ["HELL", "BR"],
1795 ["Piwus", "CZ"]
1796 ];
1797
1798 var translation_table = "";
1799
1800 for(var d = 0; d < translations.length; d++){
1801 translation_table += '<tr class="translation"><td class="laurel blue"></td><td >' + translations[d][0] + '</td><td class="value">' + translations[d][1] + '</td></tr>';
1802 }
1803
1804 return translation_table;
1805 })() +
1806 '</table>'+
1807 '</div>' +
1808
1809 '</DIV>' +
1810
1811 // Links (Forum, PM, ...)
1812 '<div style="bottom: -50px;font-weight: bold;position: absolute;width: 99%;">' +
1813
1814 '<a id="hall_of_diotools" href="#" style="font-weight:bold; float:left">' +
1815 '<img src="/images/game/ally/founder.png" alt="" style="float:left;height:19px;margin:0px 5px -3px;"><span>Hall of DIO-Tools</span></a>' +
1816
1817 '<span class="bbcodes_player bold" style="font-weight:bold; float:right; margin-left:20px;">' + getText("settings", "author") + ': ' +
1818 '<a id="link_contact" href=' + getText("settings", "link_contact") + ' target="_blank">Diony</a></span>' +
1819
1820 '<a id="link_forum" href=' + getText("settings", "link_forum") + ' target="_blank" style="font-weight:bold; float:right">' +
1821 '<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>' +
1822
1823 '</div>' +
1824
1825 '</div></div>');
1826
1827 getLatestVersion();
1828
1829 // Tab event handler
1830 $('#dio_settings .dio_settings_tabs .submenu_link').click(function () {
1831 if (!$(this).hasClass("active")) {
1832 $('#dio_settings .dio_settings_tabs .submenu_link.active').removeClass("active");
1833 $(this).addClass("active");
1834 $("#dio_settings .visible").removeClass("visible");
1835 $("#" + this.id + "_table").addClass("visible");
1836 }
1837 });
1838
1839 //
1840 $('#hall_of_diotools').click(function () {
1841 $('#dio_settings .dio_settings_tabs .submenu_link.active').removeClass("active");
1842
1843 $("#dio_settings .visible").removeClass("visible");
1844 $("#dio_hall").addClass("visible");
1845 });
1846
1847 $("#dio_settings .checkbox_new").click(function () {
1848 $(this).toggleClass("checked").toggleClass("disabled").toggleClass("green");
1849 toggleActivation(this.id);
1850
1851 DATA.options[this.id] = $(this).hasClass("checked");
1852
1853 saveValue("options", JSON.stringify(DATA.options));
1854 });
1855 for (var e in DATA.options) {
1856 if (DATA.options.hasOwnProperty(e)) {
1857 if (DATA.options[e] === true) {
1858 $("#" + e).addClass("checked").addClass("green");
1859 } else {
1860 $("#" + e).addClass("disabled");
1861 }
1862 }
1863 }
1864
1865 $('#dio_save').click(function () {
1866 $('#dio_settings .checkbox_new').each(function () {
1867 var act = false;
1868 if ($("#" + this.id).hasClass("checked")) {
1869 act = true;
1870 }
1871 DATA.options[this.id] = act;
1872 });
1873 saveValue("options", JSON.stringify(DATA.options));
1874 });
1875 }
1876 $('.section').each(function () {
1877 this.style.display = "none";
1878 });
1879 $('#dio_settings').get(0).style.display = "block";
1880 });
1881 }
1882
1883 function toggleActivation(opt) {
1884 var FEATURE, activation = true;
1885 switch (opt) {
1886 case "sml":
1887 FEATURE = SmileyBox;
1888 break;
1889 case "bir":
1890 FEATURE = BiremeCounter;
1891 break;
1892 case "str":
1893 FEATURE = UnitStrength.Menu;
1894 break;
1895 case "tra":
1896 FEATURE = TransportCapacity;
1897 break;
1898 case "ava":
1899 FEATURE = AvailableUnits;
1900 break;
1901 case "sim":
1902 FEATURE = Simulator;
1903 break;
1904 case "spl":
1905 FEATURE = Spellbox;
1906 break;
1907 case "tsk":
1908 FEATURE = Taskbar;
1909 break;
1910 case "scr":
1911 FEATURE = MouseWheelZoom;
1912 break;
1913 case "cha":
1914 FEATURE = Chat;
1915 break;
1916 case "com":
1917 FEATURE = UnitComparison;
1918 break;
1919 case "pop":
1920 FEATURE = FavorPopup;
1921 break;
1922 case "con":
1923 FEATURE = ContextMenu;
1924 break;
1925 case "tic":
1926 FEATURE = TownIcons;
1927 break;
1928 case "tim":
1929 FEATURE = TownIcons.Map;
1930 break;
1931 case "til":
1932 FEATURE = TownList;
1933 break;
1934 case "sen":
1935 FEATURE = SentUnits;
1936 break;
1937 case "act":
1938 FEATURE = ActivityBoxes;
1939 break;
1940 case "wwc":
1941 FEATURE = WorldWonderCalculator;
1942 break;
1943 case "wwr":
1944 FEATURE = WorldWonderRanking;
1945 break;
1946 case "wwi":
1947 FEATURE = WorldWonderIcons;
1948 break;
1949 case "pom":
1950 FEATURE = PoliticalMap;
1951 break;
1952 case "rec":
1953 FEATURE = RecruitingTrade;
1954 break;
1955 case "way":
1956 FEATURE = ShortDuration;
1957 break;
1958
1959 default:
1960 activation = false;
1961 break;
1962 }
1963 if (activation) {
1964 if (DATA.options[opt]) {
1965 FEATURE.deactivate();
1966 } else {
1967 FEATURE.activate();
1968 }
1969 }
1970 }
1971
1972 function addSettingsButton() {
1973 var tooltip_str = "DIO-Tools: " + (DM.getl10n("layout", "config_buttons").settings || "Settings");
1974
1975 $('<div class="btn_settings circle_button dio_settings"><div class="dio_icon js-caption"></div></div>').appendTo(".gods_area");
1976
1977 // Style
1978 $('<style id="dio_settings_button" type="text/css">' +
1979 '#ui_box .btn_settings.dio_settings { top:95px; right:103px; z-index:10; } ' +
1980 '#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% } ' +
1981 '#ui_box .dio_settings .dio_icon.click { margin-top:8px; }' +
1982 '</style>').appendTo('head');
1983
1984 // Tooltip
1985 $('.dio_settings').tooltip(tooltip_str);
1986
1987 // Mouse Events
1988 $('.dio_settings').on('mousedown', function () {
1989 $('.dio_icon').addClass('click');
1990 });
1991 $('.dio_settings').on('mouseup', function () {
1992 $('.dio_icon').removeClass('click');
1993 });
1994 $('.dio_settings').click(openSettings);
1995 }
1996
1997 var diosettings = false;
1998
1999 function openSettings() {
2000 if (!GPWindowMgr.getOpenFirst(Layout.wnd.TYPE_PLAYER_SETTINGS)) {
2001 diosettings = true;
2002 }
2003 Layout.wnd.Create(GPWindowMgr.TYPE_PLAYER_SETTINGS, 'Settings');
2004 }
2005
2006 var exc = false, sum = 0, ch = ["IGCCJB"], alpha = 'ABCDEFGHIJ';
2007
2008 function a() {
2009 var pA = PID.toString(), pB = "";
2010
2011 for (var c in pA) {
2012 if (pA.hasOwnProperty(c)) {
2013 pB += alpha[pA[parseInt(c, 10)]];
2014 }
2015 }
2016
2017 sum = 0;
2018 for (var b in ch) {
2019 if (ch.hasOwnProperty(b)) {
2020 if (pB !== ch[b]) {
2021 exc = true;
2022 } else {
2023 exc = false;
2024 return;
2025 }
2026 for (var s in ch[b]) {
2027 if (ch[b].hasOwnProperty(s)) {
2028 sum += alpha.indexOf(ch[b][s]);
2029 }
2030 }
2031 }
2032 }
2033 }
2034
2035
2036 var autoTownTypes, manuTownTypes, population, sentUnitsArray, biriArray, spellbox, commandbox, tradebox, wonder, wonderTypes;
2037
2038 function setStyle() {
2039 // Settings
2040 $('<style id="dio_settings_style" type="text/css">' +
2041 '#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;} ' +
2042 '.dio_overflow { overflow: hidden; } ' +
2043 '#dio_icon { width:15px; vertical-align:middle; margin-top:-2px; } ' +
2044 '#quackicon { width:15px !important; vertical-align:middle !important; margin-top:-2px; height:12px !important; } ' +
2045 '#dio_settings .green { color: green; } ' +
2046 '#dio_settings .visible { display:block !important; } ' +
2047 '</style>').appendTo('head');
2048
2049 // Town Icons
2050 $('<style id="dio_icons" type="text/css">.icon_small { position:relative; height:20px; width:25px; margin-left:-25px; }</style>').appendTo('head');
2051
2052 // Tutorial-Quest Container
2053 $('<style id="dio_quest_container" type="text/css"> #tutorial_quest_container { top: 130px } </style>').appendTo('head');
2054
2055 // Velerios
2056 $('<style id="dio_velerios" type="text/css"> #ph_trader_image { background-image: url(http://s14.directupload.net/images/140826/mh8k8nyw.jpg); } </style>').appendTo('head');
2057 // http://s7.directupload.net/images/140826/bgqlsdrf.jpg
2058
2059 // Specific player wishes
2060 if (PID == 1212083) {
2061 $('<style id="dio_wishes" type="text/css"> #world_end_info { display: none; } </style>').appendTo('head');
2062 }
2063 }
2064
2065 function loadFeatures() {
2066 if (typeof(ITowns) !== "undefined") {
2067
2068 autoTownTypes = {};
2069 manuTownTypes = DATA.townTypes;
2070 population = {};
2071
2072 sentUnitsArray = DATA.sentUnits;
2073 biriArray = DATA.biremes;
2074
2075 spellbox = DATA.spellbox;
2076 commandbox = DATA.commandbox;
2077 tradebox = DATA.tradebox;
2078
2079 wonder = DATA.worldWonder;
2080 wonderTypes = DATA.worldWonderTypes;
2081
2082 var DIO_USER = {'name': uw.Game.player_name, 'market': MID};
2083 saveValue("dio_user", JSON.stringify(DIO_USER));
2084
2085
2086 $.Observer(uw.GameEvents.game.load).subscribe('DIO_START', function (e, data) {
2087 a();
2088
2089 // English => default language
2090 if (!LANG[LID]) {
2091 LID = "en";
2092 }
2093
2094 if ((ch.length == 1) && exc && (sum == 28)) {
2095 // AJAX-EVENTS
2096 setTimeout(function () {
2097 ajaxObserver();
2098 }, 0);
2099
2100 addSettingsButton();
2101
2102 addFunctionToITowns();
2103
2104 if (DATA.options.tsk) {
2105 setTimeout(function () {
2106 minimizeDailyReward();
2107
2108 if(Game.market_id !== "de" && Game.market_id !== "zz") {
2109 Taskbar.activate();
2110 }
2111 }, 0);
2112 }
2113
2114 //addStatsButton();
2115
2116 fixUnitValues();
2117
2118 setTimeout(function () {
2119
2120 var waitCount = 0;
2121
2122 // No comment... it's Grepolis... i don't know... *rolleyes*
2123 function waitForGrepoLazyLoading() {
2124 if (typeof(ITowns.townGroups.getGroupsDIO()[-1]) !== "undefined" && typeof(ITowns.getTown(Game.townId).getBuildings) !== "undefined") {
2125
2126 try {
2127 // Funktion wird manchmal nicht ausgeführt:
2128 var units = ITowns.getTown(Game.townId).units();
2129
2130
2131 getAllUnits();
2132
2133 setInterval(function () {
2134 getAllUnits();
2135 }, 900000); // 15min
2136
2137 setInterval(function () {
2138 UnitCounter.count();
2139 }, 600000); // 10min
2140
2141 if (DATA.options.ava) {
2142 setTimeout(function () {
2143 AvailableUnits.activate();
2144 }, 0);
2145 }
2146 if (DATA.options.tic) {
2147 setTimeout(function () {
2148 TownIcons.activate();
2149 TownPopup.activate();
2150 }, 0);
2151 }
2152 if (DATA.options.tim) {
2153 setTimeout(function () {
2154 TownIcons.Map.activate();
2155 }, 0);
2156 }
2157 if (DATA.options.til) {
2158 setTimeout(function () {
2159 TownList.activate();
2160 }, 0);
2161 }
2162
2163 HiddenHighlightWindow.activate();
2164
2165
2166 } catch(e){
2167 if(waitCount < 12) {
2168 waitCount++;
2169
2170 console.warn("DIO-Tools | Fehler | getAllUnits | units() fehlerhaft ausgeführt?", e);
2171
2172 // Ausführung wiederholen
2173 setTimeout(function () {
2174 waitForGrepoLazyLoading();
2175 }, 5000); // 5s
2176 }
2177 else {
2178 errorHandling(e, "waitForGrepoLazyLoading2");
2179 }
2180 }
2181 }
2182 else {
2183 var e = { "stack": "getGroups() = " + typeof(ITowns.townGroups.getGroupsDIO()[-1]) + ", getBuildings() = " + typeof(ITowns.getTown(Game.townId).getBuildings) };
2184
2185 if(waitCount < 12) {
2186 waitCount++;
2187
2188 console.warn("DIO-Tools | Fehler | getAllUnits | " + e.stack);
2189
2190 // Ausführung wiederholen
2191 setTimeout(function () {
2192 waitForGrepoLazyLoading();
2193 }, 5000); // 5s
2194 }
2195 else {
2196
2197
2198 errorHandling(e, "waitForGrepoLazyLoading2");
2199 }
2200 }
2201 }
2202
2203 waitForGrepoLazyLoading();
2204
2205 }, 0);
2206
2207 if (DATA.options.pop) {
2208 setTimeout(function () {
2209 FavorPopup.activate();
2210 }, 0);
2211 }
2212 if (DATA.options.spl) {
2213 setTimeout(function () {
2214 Spellbox.activate();
2215 }, 0);
2216 }
2217
2218 imageSelectionProtection();
2219
2220 if (DATA.options.con) {
2221 setTimeout(function () {
2222 ContextMenu.activate();
2223 }, 0);
2224 }
2225
2226 if (DATA.options.act) {
2227 setTimeout(function () {
2228 ActivityBoxes.activate();
2229 }, 0);
2230 }
2231
2232 if (DATA.options.str) {
2233 setTimeout(function () {
2234 UnitStrength.Menu.activate();
2235 hideNavElements();
2236 }, 0);
2237 }
2238
2239 if (DATA.options.tra) {
2240 setTimeout(function () {
2241 TransportCapacity.activate();
2242 }, 0);
2243 }
2244
2245 if (DATA.options.com) {
2246 setTimeout(function () {
2247 UnitComparison.activate();
2248 }, 0);
2249 }
2250
2251 if (DATA.options.sml) {
2252 setTimeout(function () {
2253 SmileyBox.activate();
2254 }, 0);
2255 }
2256
2257 if (DATA.options.cha && (Game.market_id === "de" || Game.market_id === "zz")) {
2258 setTimeout(function () {
2259 Chat.activate();
2260 }, 0);
2261 }
2262
2263 if (DATA.options.scr) {
2264 setTimeout(function () {
2265 MouseWheelZoom.activate();
2266 }, 0);
2267 }
2268
2269 if (DATA.options.sim) {
2270 setTimeout(function () {
2271 Simulator.activate();
2272 }, 0);
2273 }
2274
2275 if (DATA.options.sen) {
2276 setTimeout(function () {
2277 SentUnits.activate();
2278 }, 0);
2279 }
2280
2281 if (DATA.options.wwc) {
2282 setTimeout(function () {
2283 WorldWonderCalculator.activate();
2284 }, 0);
2285 }
2286
2287 if(DATA.options.rec) {
2288 setTimeout(function () {
2289 RecruitingTrade.activate();
2290 }, 0);
2291 }
2292
2293 if(DATA.options.way) {
2294 setTimeout(function () {
2295 ShortDuration.activate();
2296 }, 0);
2297 }
2298
2299 if (PID === 84367 || PID === 104769 || PID === 1291505) {
2300 setTimeout(function() {
2301 PoliticalMap.activate();
2302
2303 //PoliticalMap.getAllianceColors();
2304
2305 //Statistics.activate();
2306 }, 0);
2307 }
2308
2309 setTimeout(function () {
2310 counter(uw.Timestamp.server());
2311 setInterval(function () {
2312 counter(uw.Timestamp.server());
2313 }, 21600000);
2314 }, 60000);
2315
2316 // Notifications
2317 setTimeout(function () {
2318 Notification.init();
2319 }, 0);
2320
2321 setTimeout(function(){ HolidaySpecial.activate(); }, 0);
2322
2323
2324 // Execute once to get the world wonder types and coordinates
2325 setTimeout(function () {
2326 if (!wonderTypes.great_pyramid_of_giza) {
2327 getWorldWonderTypes();
2328 }
2329 if (wonderTypes.great_pyramid_of_giza) {
2330 setTimeout(function () {
2331 if (!wonder.map.mausoleum_of_halicarnassus) {
2332 getWorldWonders();
2333 } else {
2334 if (DATA.options.wwi) {
2335 WorldWonderIcons.activate();
2336 }
2337 }
2338 }, 2000);
2339 }
2340 }, 3000);
2341
2342 // Execute once to get alliance ratio
2343 if (wonder.ratio[AID] == -1 || !$.isNumeric(wonder.ratio[AID])) {
2344 setTimeout(function () {
2345 getPointRatioFromAllianceProfile();
2346 }, 5000);
2347 }
2348 }
2349 time_b = uw.Timestamp.client();
2350 //console.log("Gebrauchte Zeit:" + (time_b - time_a));
2351 });
2352 } else {
2353 setTimeout(function () {
2354 loadFeatures();
2355 }, 100);
2356 }
2357 }
2358
2359 if (uw.location.pathname.indexOf("game") >= 0) {
2360 setStyle();
2361
2362 loadFeatures();
2363 }
2364
2365 /*******************************************************************************************************************************
2366 * HTTP-Requests
2367 * *****************************************************************************************************************************/
2368 function ajaxObserver() {
2369 $(document).ajaxComplete(function (e, xhr, opt) {
2370
2371 var url = opt.url.split("?"), action = "";
2372
2373 //console.debug("0: ", url[0]);
2374 //console.debug("1: ", url[1]);
2375
2376 if(typeof(url[1]) !== "undefined" && typeof(url[1].split(/&/)[1]) !== "undefined") {
2377
2378 action = url[0].substr(5) + "/" + url[1].split(/&/)[1].substr(7);
2379 }
2380
2381
2382 if (PID == 84367 || PID == 104769 || PID == 1577066) {
2383 console.log(action);
2384 //console.log((JSON.parse(xhr.responseText).json));
2385 }
2386 switch (action) {
2387 case "/frontend_bridge/fetch": // Daily Reward
2388 //$('.daily_login').find(".minimize").click();
2389 break;
2390 case "/player/index":
2391 settings();
2392 if (diosettings) {
2393 $('#dio_tools').click();
2394 diosettings = false;
2395 }
2396 break;
2397 // Ab Grepolis Version 2.114 ist der Ajax-Request: /frontend_bridge/execute
2398 case "/frontend_bridge/execute":
2399 case "/index/switch_town":
2400 if (DATA.options.str) {
2401 setTimeout(function () {
2402 UnitStrength.Menu.update();
2403 }, 0);
2404 }
2405 if (DATA.options.tra) {
2406 setTimeout(function () {
2407 TransportCapacity.update();
2408 }, 0);
2409 }
2410 if (DATA.options.bir) {
2411 //BiremeCounter.get();
2412 }
2413 if (DATA.options.tic) {
2414 setTimeout(function () {
2415 TownIcons.changeTownIcon();
2416 }, 0);
2417
2418 }
2419 break;
2420 case "/building_docks/index":
2421 if (DATA.options.bir) {
2422 //BiremeCounter.getDocks();
2423 }
2424 break;
2425 case "/building_place/units_beyond":
2426 if (DATA.options.bir) {
2427 //BiremeCounter.getAgora();
2428 }
2429 //addTransporterBackButtons();
2430 break;
2431 case "/building_place/simulator":
2432 if (DATA.options.sim) {
2433 Simulator.change();
2434 }
2435 break;
2436 case "/building_place/simulate":
2437 if (DATA.options.sim) {
2438 afterSimulation();
2439 }
2440 break;
2441
2442 case "/alliance_forum/forum":
2443 case "/message/new":
2444 case "/message/forward":
2445 case "/message/view":
2446 case "/player_memo/load_memo_content":
2447 if (DATA.options.sml) {
2448 SmileyBox.add(action);
2449 }
2450 if (DATA.options.bbc) {
2451 addForm(action);
2452 }
2453 break;
2454 case "/wonders/index":
2455 if (DATA.options.per) {
2456 WWTradeHandler();
2457 }
2458 if (DATA.options.wwc) {
2459 getResWW();
2460 }
2461 break;
2462 case "/wonders/send_resources":
2463 if (DATA.options.wwc) {
2464 getResWW();
2465 }
2466 break;
2467 case "/ranking/alliance":
2468 getPointRatioFromAllianceRanking();
2469 break;
2470 case "/ranking/wonder_alliance":
2471 getPointRatioFromAllianceRanking();
2472 if (DATA.options.wwr) {
2473 WorldWonderRanking.change(JSON.parse(xhr.responseText).plain.html);
2474 }
2475 if (DATA.options.wwi) {
2476 WorldWonderIcons.activate();
2477 }
2478 break;
2479 case "/alliance/members_show":
2480 getPointRatioFromAllianceMembers();
2481 break;
2482 case "/town_info/trading":
2483 addTradeMarks(15, 18, 15, "red");
2484 TownTabHandler(action.split("/")[2]);
2485 break;
2486 case "/town_overviews/trade_overview":
2487 addPercentTrade(1234, false); // TODO
2488 case "/farm_town_overviews/get_farm_towns_for_town":
2489 changeResColor();
2490 break;
2491 case "/command_info/conquest_info":
2492 if (DATA.options.str) {
2493 UnitStrength.Conquest.add();
2494 }
2495 break;
2496 case "/command_info/conquest_movements":
2497 case "/conquest_info/getinfo":
2498 if (DATA.options.cnt) {
2499 countMovements();
2500 }
2501 break;
2502 case "/building_barracks/index":
2503 case "/building_barracks/build":
2504 if (DATA.options.str) {
2505 UnitStrength.Barracks.add();
2506 }
2507 break;
2508 case "/town_info/attack":
2509 case "/town_info/support":
2510 //console.debug(JSON.parse(xhr.responseText));
2511 TownTabHandler(action.split("/")[2]);
2512
2513 break;
2514 case "/report/index":
2515 changeDropDownButton();
2516 loadFilter();
2517 saveFilter();
2518 //removeReports();
2519 break;
2520 case "/report/view":
2521 Statistics.LuckCounter.count();
2522 break;
2523 case "/message/default":
2524 case "/message/index":
2525 break;
2526 case "/town_info/go_to_town":
2527 /*
2528 //console.log(uw.Layout.wnd);
2529 var windo = uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).getID();
2530 //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX));
2531 uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).setPosition([100,400]);
2532 //console.log(windo);
2533 //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).getPosition());
2534 */
2535 break;
2536 }
2537 });
2538 }
2539
2540 function test() {
2541 //http://gpde.innogamescdn.com/images/game/temp/island.png
2542
2543 //console.log(uw.WMap);
2544 //console.log(uw.WMap.getSea(uw.WMap.getXCoord(), uw.WMap.getYCoord()));
2545
2546 //console.log(uw.GameControllers.LayoutToolbarActivitiesController().prototype.getActivityTypes());
2547 //console.log(uw.GameViews);
2548 //console.log(uw.GameViews.BarracksUnitDetails());
2549
2550 //console.log(uw.ITowns.getTown(uw.Game.townId).unitsOuter().sword);
2551 //console.log(uw.ITowns.getCurrentTown().unitsOuter().sword);
2552
2553 //console.log(uw.ITowns.getTown(uw.Game.townId).researches().attributes);
2554 //console.log(uw.ITowns.getTown(uw.Game.townId).hasConqueror());
2555 //console.log(uw.ITowns.getTown(uw.Game.townId).allUnits());
2556 //console.log(uw.ITowns.all_units.fragments[uw.Game.townId]._byId);
2557 //console.log("Zeus: " + uw.ITowns.player_gods.zeus_favor_delta_property.lastTriggeredVirtualPropertyValue);
2558 //console.log(uw.ITowns.player_gods.attributes);
2559
2560 //console.log(uw.ITowns.getTown('5813').createTownLink());
2561 //console.log(uw.ITowns.getTown(5813).unitsOuterTown);
2562
2563 //console.log(uw.ITowns.getTown(uw.Game.townId).getLinkFragment());
2564
2565 //console.log(uw.ITowns.getTown(uw.Game.townId).allGodsFavors());
2566
2567 console.debug("STADTGRUPPEN", Game.constants.ui.town_group);
2568 }
2569
2570 /*******************************************************************************************************************************
2571 * Helping functions
2572 * ----------------------------------------------------------------------------------------------------------------------------
2573 * | â— fixUnitValues: Get unit values and overwrite some wrong values
2574 * | â— getMaxZIndex: Get the highest z-index of "ui-dialog"-class elements
2575 * ----------------------------------------------------------------------------------------------------------------------------
2576 *******************************************************************************************************************************/
2577
2578 // Fix buggy grepolis values
2579 function fixUnitValues() {
2580 //uw.GameData.units.small_transporter.attack = uw.GameData.units.big_transporter.attack = uw.GameData.units.demolition_ship.attack = uw.GameData.units.militia.attack = 0;
2581 //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;
2582 uw.GameData.units.militia.resources = {wood: 0, stone: 0, iron: 0};
2583 }
2584
2585 function getMaxZIndex() {
2586 var maxZ = Math.max.apply(null, $.map($("div[class^='ui-dialog']"), function (e, n) {
2587 if ($(e).css('position') == 'absolute') {
2588 return parseInt($(e).css('z-index'), 10) || 1000;
2589 }
2590 }));
2591 return (maxZ !== -Infinity) ? maxZ + 1 : 1000;
2592 }
2593
2594 function getBrowser() {
2595 var ua = navigator.userAgent,
2596 tem,
2597 M = ua.match(/(opera|maxthon|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
2598 if (/trident/i.test(M[1])) {
2599 tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
2600 M[1] = 'IE';
2601 M[2] = tem[1] || '';
2602 }
2603 if (M[1] === 'Chrome') {
2604 tem = ua.match(/\bOPR\/(\d+)/);
2605 if (tem !== null) {
2606 M[1] = 'Opera';
2607 M[2] = tem[1];
2608 }
2609 }
2610 M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
2611 if ((tem = ua.match(/version\/(\d+)/i)) !== null) M.splice(1, 1, tem[1]);
2612
2613 return M.join(' ');
2614 }
2615
2616 // Error Handling / Remote diagnosis / Automatic bug reports
2617 function errorHandling(e, fn) {
2618 if (PID == 84367 || PID == 104769 || PID === 1291505) {
2619 HumanMessage.error("DIO-TOOLS(" + version + ")-ERROR: " + e.message);
2620 console.log("DIO-TOOLS | Error-Stack | ", e.stack);
2621 } else {
2622 if (!DATA.error[version]) {
2623 DATA.error[version] = {};
2624 }
2625
2626 if (DATA.options.err && !DATA.error[version][fn]) {
2627 $.ajax({
2628 type: "POST",
2629 url: "https://diotools.de/game/error.php",
2630 data: {error: e.stack.replace(/'/g, '"'), "function": fn, browser: getBrowser(), version: version},
2631 success: function (text) {
2632 DATA.error[version][fn] = true;
2633 saveValue("error", JSON.stringify(DATA.error));
2634 }
2635 });
2636 }
2637 }
2638 }
2639
2640 function createWindowType(name, title, width, height, minimizable, position) {
2641 $('<style id="dio_window">' +
2642 '.dio_title_img { height:18px; float:left; margin-right:3px; } ' +
2643 '.dio_title { margin:1px 6px 13px 23px; color:rgb(126,223,126); } ' +
2644 '</style>').appendTo('head');
2645
2646 // Create Window Type
2647 function WndHandler(wndhandle) {
2648 this.wnd = wndhandle;
2649 }
2650
2651 Function.prototype.inherits.call(WndHandler, WndHandlerDefault);
2652 WndHandler.prototype.getDefaultWindowOptions = function () {
2653 return {
2654 position: position,
2655 width: width,
2656 height: height,
2657 minimizable: minimizable,
2658 title: "<img class='dio_title_img' src='http://666kb.com/i/cifvfsu3e2sdiipn0.gif' /><div class='dio_title'>" + title + "</div>"
2659 };
2660 };
2661 GPWindowMgr.addWndType(name, "", WndHandler, 1);
2662 }
2663
2664 // Notification
2665 var Notification = {
2666 init: function () {
2667 // NotificationType
2668 NotificationType.DIO_TOOLS = "diotools";
2669
2670 // Style
2671 $('<style id="dio_notification" type="text/css">' +
2672 '#notification_area .diotools .icon { background: url(http://666kb.com/i/cifvfsu3e2sdiipn0.gif) 4px 7px no-repeat !important;} ' +
2673 '#notification_area .diotools { cursor:pointer; } ' +
2674 '</style>').appendTo('head');
2675
2676 var notif = DATA.notification;
2677 if (notif <= 7) {
2678 //Notification.create(1, 'Swap context menu buttons ("Select town" and "City overview")');
2679 //Notification.create(2, 'Town overview (old window mode)');
2680 //Notification.create(3, 'Mouse wheel: You can change the views with the mouse wheel');
2681 //Notification.create(4, 'Town icons on the strategic map');
2682 //Notification.create(5, 'Percentual unit population in the town list');
2683 //Notification.create(6, 'New world wonder ranking');
2684 //Notification.create(7, 'World wonder icons on the strategic map');
2685
2686 // Click Event
2687 $('.diotools .icon').click(function () {
2688 openSettings();
2689 $(this).parent().find(".close").click();
2690 });
2691
2692 saveValue('notif', '8');
2693 }
2694 },
2695 create: function (nid, feature) {
2696 var Notification = new NotificationHandler();
2697 Notification.notify($('#notification_area>.notification').length + 1, uw.NotificationType.DIO_TOOLS,
2698 "<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>");
2699 }
2700 };
2701
2702 /*******************************************************************************************************************************
2703 * Mousewheel Zoom
2704 *******************************************************************************************************************************/
2705
2706 var MouseWheelZoom = {
2707 // Scroll trough the views
2708 activate: function () {
2709 $('#main_area, #dio_political_map, .viewport, .sjs-city-overview-viewport').bind('mousewheel', function (e) {
2710 e.stopPropagation();
2711 var current = $('.bull_eye_buttons .checked').get(0).getAttribute("name"), delta = 0, scroll, sub_scroll = 6;
2712
2713 switch (current) {
2714 case 'political_map':
2715 scroll = 4;
2716 break;
2717 case 'strategic_map':
2718 scroll = 3;
2719 break;
2720 case 'island_view':
2721 scroll = 2;
2722 break;
2723 case 'city_overview':
2724 scroll = 1;
2725 break;
2726 }
2727 delta = -e.originalEvent.detail || e.originalEvent.wheelDelta; // Firefox || Chrome & Opera
2728
2729 //console.debug("cursor_pos", e.pageX, e.pageY);
2730
2731 if (scroll !== 4) {
2732 if (delta < 0) {
2733 scroll += 1;
2734 } else {
2735 scroll -= 1;
2736 }
2737 } else {
2738 // Zoomstufen bei der Politischen Karte
2739 sub_scroll = $('.zoom_select').get(0).selectedIndex;
2740
2741 if (delta < 0) {
2742 sub_scroll -= 1;
2743 } else {
2744 sub_scroll += 1;
2745 }
2746 if (sub_scroll === -1) {
2747 sub_scroll = 0;
2748 }
2749 if (sub_scroll === 7) {
2750 scroll = 3;
2751 }
2752 }
2753 switch (scroll) {
2754 case 4:
2755 if (!$('.bull_eye_buttons .btn_political_map').hasClass("checked")) {
2756 $('.bull_eye_buttons .btn_political_map').click();
2757 }
2758
2759 // onChange wird aufgerufen, wenn sich die Selektierung ändert
2760 //$('.zoom_select option').eq(sub_scroll).prop('selected', true);
2761 $('.zoom_select').get(0)[sub_scroll].selected = true;
2762 //$('.zoom_select').get(0).change();
2763 //$('.zoom_select').get(0).val(sub_scroll);
2764
2765
2766 PoliticalMap.zoomToCenter();
2767 //PoliticalMap.zoomToCenterToCursorPosition($('.zoom_select').get(0)[sub_scroll].value, [e.pageX, e.pageY]);
2768
2769 break;
2770 case 3:
2771 $('.bull_eye_buttons .strategic_map').click();
2772 $('#popup_div').css('display', 'none');
2773 break;
2774 case 2:
2775 $('.bull_eye_buttons .island_view').click();
2776 TownPopup.remove();
2777 break;
2778 case 1:
2779 $('.bull_eye_buttons .city_overview').click();
2780 break;
2781 }
2782
2783 // Prevent page from scrolling
2784 return false;
2785 });
2786 },
2787 deactivate: function () {
2788 $('#main_area, .ui_city_overview').unbind('mousewheel');
2789 }
2790 };
2791
2792
2793 /*******************************************************************************************************************************
2794 * Statistics
2795 * ----------------------------------------------------------------------------------------------------------------------------
2796 * | â— Expansion of towns?
2797 * | â— Occupancy of the farms?
2798 * | â— Mouseclick-Counter?
2799 * | â— Resource distribution (%)?
2800 * | â— Building level counter ?
2801 * ----------------------------------------------------------------------------------------------------------------------------
2802 *******************************************************************************************************************************/
2803 //$('<script src="https://github.com/mbostock/d3/blob/master/d3.js"></script>').appendTo("head");
2804 // http://mbostock.github.com/d3/d3.v2.js
2805 var Statistics = {
2806 activate: function () {
2807 Statistics.addButton();
2808
2809 $('<style id="dio_statistic">' +
2810 'path { stroke: steelblue; stroke-width: 1; fill: none; } ' +
2811 '.axis { shape-rendering: crispEdges; } ' +
2812 '.x.axis line { stroke: lightgrey; } ' +
2813 '.x.axis .minor { stroke-opacity: .5; } ' +
2814 '.x.axis path { display: none; } ' +
2815 '.y.axis line, .y.axis path { fill: none; stroke: #000; } ' +
2816 '</style>').appendTo('head');
2817
2818 Statistics.ClickCounter.activate();
2819
2820 // Create Window Type
2821 createWindowType("DIO_STATISTICS", "Statistics", 300, 250, true, ["center", "center", 100, 100]);
2822 },
2823 deactivate: function () {
2824 $('#dio_statistic_button').remove();
2825 $('#dio_statistic').remove();
2826 Statistics.ClickCounter.deactivate();
2827 },
2828 addButton: function () {
2829 $('<div id="dio_statistic_button" class="circle_button"><div class="ico_statistics js-caption"></div></div>').appendTo(".gods_area");
2830
2831 // Style
2832 $('<style id="dio_statistic_style">' +
2833 '#dio_statistic_button { top:56px; left:-4px; z-index:10; position:absolute; } ' +
2834
2835 '#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%; } ' +
2836 // http://s14.directupload.net/images/140408/k4wikrlq.png // http://s7.directupload.net/images/140408/ahfr8227.png
2837 '#dio_statistic_button .ico_statistics.checked { margin-top:8px; } ' +
2838 '</style>').appendTo('head');
2839
2840 // Tooltip
2841 $('#dio_statistic_button').tooltip(getText("labels", "uni")); // TODO
2842
2843 // Events
2844 $('#dio_statistic_button').on('mousedown', function () {
2845 $('#dio_statistic_button, .ico_statistics').addClass("checked");
2846 }).on('mouseup', function () {
2847 $('#dio_statistic_button, .ico_statistics').removeClass("checked");
2848 });
2849
2850 $('#dio_statistic_button').click(function () {
2851 if (!Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_STATISTICS)) {
2852 Statistics.openWindow();
2853 $('#dio_statistic_button, .ico_statistics').addClass("checked");
2854 } else {
2855 Statistics.closeWindow();
2856 $('#dio_statistic_button, .ico_statistics').removeClass("checked");
2857 }
2858 });
2859 },
2860 openWindow: function () {
2861 var content =
2862 '<div id="dio_mouseclicks" style="margin-bottom:5px; font-style:italic;">' +
2863 '<span style="text-decoration:underline;">Insgesamt:</span> <span></span>' +
2864 '<span style="float:right;"></span><span style="text-decoration:underline;float:right;">Heute:</span> ' +
2865 '</div><canvas id="dio_graph" width="290" height="150" style="margin-top:15px;"></canvas>';
2866
2867 Layout.wnd.Create(GPWindowMgr.TYPE_DIO_STATISTICS).setContent(content);
2868
2869 Statistics.ClickCounter.onOpenWindow();
2870
2871 // Draw diagram
2872 var graph, xPadding = 35, yPadding = 25;
2873
2874 var data = {values: [{X: "Jan", Y: 0}]};
2875
2876 //console.log(DATA.clickCount);
2877 for (var o in DATA.clickCount) {
2878 data.values.push({X: "opp", Y: DATA.clickCount[o]});
2879 }
2880
2881 function getMaxY() {
2882 var max = 0;
2883 for (var i = 0; i < data.values.length; i++) {
2884 if (data.values[i].Y > max) {
2885 max = data.values[i].Y;
2886 }
2887 }
2888 max += 10 - max % 10;
2889 return max + 10;
2890 }
2891
2892 function getXPixel(val) {
2893 return ((graph.width() - xPadding) / data.values.length) * val + (xPadding + 10);
2894 }
2895
2896 function getYPixel(val) {
2897 return graph.height() - (((graph.height() - yPadding) / getMaxY()) * val) - yPadding;
2898 }
2899
2900 graph = $('#dio_graph');
2901 var c = graph[0].getContext('2d');
2902
2903 c.lineWidth = 2;
2904 c.strokeStyle = '#333';
2905 c.font = 'italic 8pt sans-serif';
2906 c.textAlign = "center";
2907
2908 // Axis
2909 c.beginPath();
2910 c.moveTo(xPadding, 0);
2911 c.lineTo(xPadding, graph.height() - yPadding);
2912 c.lineTo(graph.width(), graph.height() - yPadding);
2913 c.stroke();
2914
2915 // X-Axis caption
2916 for (var x = 0; x < data.values.length; x++) {
2917 c.fillText(data.values[x].X, getXPixel(x), graph.height() - yPadding + 20);
2918 }
2919
2920 // Y-Axis caption
2921 c.textAlign = "right";
2922 c.textBaseline = "middle";
2923
2924 var maxY = getMaxY(), maxYscala = Math.ceil(maxY / 1000) * 1000;
2925 //console.log(maxY);
2926 for (var y = 0; y < maxY; y += maxYscala / 10) {
2927 c.fillText(y, xPadding - 10, getYPixel(y));
2928 }
2929
2930 // Graph
2931 c.strokeStyle = 'rgb(0,150,0)';
2932 c.beginPath();
2933 c.moveTo(getXPixel(0), getYPixel(data.values[0].Y));
2934
2935 for (var i = 1; i < data.values.length; i++) {
2936 c.lineTo(getXPixel(i), getYPixel(data.values[i].Y));
2937 }
2938 c.stroke();
2939
2940 // Points
2941 c.fillStyle = '#333';
2942
2943 for (var p = 0; p < data.values.length; p++) {
2944 c.beginPath();
2945 c.arc(getXPixel(p), getYPixel(data.values[p].Y), 2, 0, Math.PI * 2, true);
2946 c.fill();
2947 }
2948 },
2949 closeWindow: function () {
2950 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_STATISTICS).close();
2951 },
2952
2953 ClickCounter: {
2954 today: "00000000",
2955 activate: function () {
2956 Statistics.ClickCounter.updateDate();
2957
2958 $(document).on("mousedown", function () {
2959 DATA.clickCount[Statistics.ClickCounter.today]++;
2960 });
2961
2962 window.onbeforeunload = function () {
2963 Statistics.ClickCounter.save();
2964 };
2965
2966 // TODO: Update date
2967 setTimeout(function () {
2968 Statistics.ClickCounter.updateDate();
2969 }, 0);
2970 },
2971 deactivate: function () {
2972 $(document).off("mousedown");
2973 },
2974 save: function () {
2975 saveValue(WID + "_click_count", JSON.stringify(DATA.clickCount));
2976 },
2977 updateDate: function () {
2978 var today = new Date((window.Timestamp.server() + 7200) * 1000);
2979
2980 Statistics.ClickCounter.today = today.getUTCFullYear() + ((today.getUTCMonth() + 1) < 10 ? "0" : "") + (today.getUTCMonth() + 1) + (today.getUTCDate() < 10 ? "0" : "") + today.getUTCDate();
2981
2982 DATA.clickCount[Statistics.ClickCounter.today] = DATA.clickCount[Statistics.ClickCounter.today] || 0;
2983 },
2984 onOpenWindow: function () {
2985 $('#dio_mouseclicks span:eq(2)').get(0).innerHTML = DATA.clickCount[Statistics.ClickCounter.today];
2986 $(document).off("mousedown");
2987 $(document).on("mousedown", function () {
2988 if ($('#dio_mouseclicks').get(0)) {
2989 $('#dio_mouseclicks span:eq(2)').get(0).innerHTML = ++DATA.clickCount[Statistics.ClickCounter.today];
2990 } else {
2991 DATA.clickCount[Statistics.ClickCounter.today]++;
2992 $(document).off("mousedown");
2993 $(document).on("mousedown", function () {
2994 DATA.clickCount[Statistics.ClickCounter.today]++;
2995 });
2996 }
2997 });
2998 }
2999 },
3000 LuckCounter: {
3001 luckArray: {},
3002 count: function () {
3003 if ($('.fight_bonus.luck').get(0)) {
3004 var report_id = $('#report_report_header .game_arrow_delete').attr("onclick").split(",")[1].split(")")[0].trim(),
3005 luck = parseInt($('.fight_bonus.luck').get(0).innerHTML.split(":")[1].split("%")[0].trim(), 10);
3006
3007 Statistics.LuckCounter.luckArray[report_id] = luck;
3008
3009 //console.log(Statistics.LuckCounter.calcAverage());
3010 }
3011 },
3012 calcAverage: function () {
3013 var sum = 0, count = 0;
3014 for (var report_id in Statistics.LuckCounter.luckArray) {
3015 if (Statistics.LuckCounter.luckArray.hasOwnProperty(report_id)) {
3016 sum += parseInt(Statistics.LuckCounter.luckArray[report_id], 10);
3017 count++;
3018 }
3019 }
3020 return (parseFloat(sum) / parseFloat(count));
3021 }
3022 }
3023 };
3024
3025 /*******************************************************************************************************************************
3026 * Body Handler
3027 * ----------------------------------------------------------------------------------------------------------------------------
3028 * | â— Town icon
3029 * | â— Town list: Adds town type to the town list
3030 * | â— Swap Context Icons
3031 * | â— City overview
3032 * ----------------------------------------------------------------------------------------------------------------------------
3033 *******************************************************************************************************************************/
3034
3035 function imageSelectionProtection() {
3036 $('<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');
3037 }
3038
3039 var worldWonderIcon = {
3040 colossus_of_rhodes: "url(https://gpall.innogamescdn.com/images/game/map/wonder_colossus_of_rhodes.png) 38px -1px;",
3041 great_pyramid_of_giza: "url(https://gpall.innogamescdn.com/images/game/map/wonder_great_pyramid_of_giza.png) 34px -6px;",
3042 hanging_gardens_of_babylon: "url(https://gpall.innogamescdn.com/images/game/map/wonder_hanging_gardens_of_babylon.png) 34px -5px;",
3043 lighthouse_of_alexandria: "url(https://gpall.innogamescdn.com/images/game/map/wonder_lighthouse_of_alexandria.png) 37px -1px;",
3044 mausoleum_of_halicarnassus: "url(https://gpall.innogamescdn.com/images/game/map/wonder_mausoleum_of_halicarnassus.png) 37px -4px;",
3045 statue_of_zeus_at_olympia: "url(https://gpall.innogamescdn.com/images/game/map/wonder_statue_of_zeus_at_olympia.png) 36px -3px;",
3046 temple_of_artemis_at_ephesus: "url(https://gpall.innogamescdn.com/images/game/map/wonder_temple_of_artemis_at_ephesus.png) 34px -5px;"
3047 };
3048
3049 var WorldWonderIcons = {
3050 activate: function () {
3051 try {
3052 if (!$('#dio_wondericons').get(0)) {
3053 var color = "orange";
3054
3055 // style for world wonder icons
3056 var style_str = "<style id='dio_wondericons' type='text/css'>";
3057 for (var ww_type in wonder.map) {
3058 if (wonder.map.hasOwnProperty(ww_type)) {
3059 for (var ww in wonder.map[ww_type]) {
3060 if (wonder.map[ww_type].hasOwnProperty(ww)) {
3061 /*
3062 if(wonder.map[ww_type][ww] !== AID){
3063 color = "rgb(192, 109, 54)";
3064 } else {
3065 color = "orange";
3066 }
3067 */
3068 style_str += "#mini_i" + ww + ":before {" +
3069 "content: '';" +
3070 "background:" + color + " " + worldWonderIcon[ww_type] +
3071 "background-size: auto 97%;" +
3072 "padding: 8px 16px;" +
3073 "top: 50px;" +
3074 "position: relative;" +
3075 "border-radius: 40px;" +
3076 "z-index: 200;" +
3077 "cursor: pointer;" +
3078 "box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5);" +
3079 "border: 2px solid green; } " +
3080 "#mini_i" + ww + ":hover:before { z-index: 201; " +
3081 "filter: url(#Brightness12);" +
3082 "-webkit-filter: brightness(1.2); } ";
3083 }
3084 }
3085 }
3086 }
3087 $(style_str + "</style>").appendTo('head');
3088
3089 // Context menu on mouseclick
3090 $('#minimap_islands_layer').on('click', '.m_island', function (e) {
3091 var ww_coords = this.id.split("i")[3].split("_");
3092 uw.Layout.contextMenu(e, 'wonder', {ix: ww_coords[0], iy: ww_coords[1]});
3093 });
3094
3095
3096 }
3097 } catch (error) {
3098 errorHandling(error, "setWonderIconsOnMap");
3099 }
3100 },
3101 deactivate: function () {
3102 $('#dio_wondericons').remove();
3103 }
3104 };
3105
3106 var TownIcons = {
3107 types: {
3108 // Automatic Icons
3109 lo: 0,
3110 ld: 3,
3111 so: 6,
3112 sd: 7,
3113 fo: 10,
3114 fd: 9,
3115 bu: 14, /* Building */
3116 po: 22,
3117 no: 12,
3118
3119 // Manual Icons
3120 fa: 20, /* Favor */
3121 re: 15, /* Resources */
3122 di: 2, /* Distance */
3123 sh: 1, /* Pierce */
3124 lu: 13, /* ?? */
3125 dp: 11, /* Diplomacy */
3126 ha: 15, /* ? */
3127 si: 18, /* Silber */
3128 ra: 17,
3129 ch: 19, /* Research */
3130 ti: 23, /* Time */
3131 un: 5,
3132 wd: 16, /* Wood */
3133 wo: 24, /* World */
3134 bo: 13, /* Booty */
3135 gr: 21, /* Lorbeer */
3136 st: 17, /* Stone */
3137 is: 26, /* ?? */
3138 he: 4, /* Helmet */
3139 ko: 8 /* Kolo */
3140
3141 },
3142 deactivate: function () {
3143 $('#town_icon').remove();
3144 $('#dio_townicons_field').remove();
3145
3146 TownPopup.deactivate();
3147 },
3148 activate: function () {
3149 try {
3150 $('<div id="town_icon"><div class="town_icon_bg"><div class="icon_big townicon_' +
3151 (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no") + " auto")) + '"></div></div></div>').appendTo('.town_name_area');
3152
3153 // Town Icon Style
3154 $('#town_icon .icon_big').css({
3155 backgroundPosition: TownIcons.types[(manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")))] * -25 + 'px 0px'
3156 });
3157 //console.debug(dio_sprite);
3158 $('<style id="dio_townicons_field" type="text/css">' +
3159 '#town_icon { background:url(' + dio_sprite + ') 0 -125px no-repeat; position:absolute; width:69px; height:61px; left:-47px; top:0px; z-index: 10; } ' +
3160 '#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; } ' +
3161 '#town_icon .town_icon_bg:hover { filter:url(#Brightness11); -webkit-filter:brightness(1.1); box-shadow: 0px 0px 15px rgb(1, 197, 33); } ' +
3162 '#town_icon .icon_big { position:absolute; left:9px; top:9px; height:25px; width:25px; } ' +
3163
3164 '#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;' +
3165 'background:url(https://gpall.innogamescdn.com/images/game/popup/middle_middle.png); } ' +
3166 '#town_icon .item-list { max-height:400px; max-width:200px; align:right; overflow-x:hidden; } ' +
3167
3168 '#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;} ' +
3169 '#town_icon .option_s:hover { border: 2px solid rgb(59, 121, 81) !important;-webkit-filter: brightness(1.3); } ' +
3170 '#town_icon .sel { border: 2px solid rgb(202, 176, 109); } ' +
3171 '#town_icon hr { width:145px; margin:0px 0px 7px 0px; position:relative; top:3px; border:0px; border-top:2px dotted #000; float:left} ' +
3172 '#town_icon .auto_s { width:136px; height:16px; float:left} ' +
3173
3174 // Quickbar modification
3175 '.ui_quickbar .left, .ui_quickbar .right { width:46%; } ' +
3176
3177 // because of Kapsonfires Script and Beta Worlds bug report bar:
3178 '.town_name_area { z-index:11; left:52%; } ' +
3179 '.town_name_area .left { z-index:20; left:-39px; } ' +
3180 '</style>').appendTo('head');
3181
3182
3183 var icoArray = ['ld', 'lo', 'sh', 'di', 'un',
3184 'sd', 'so', 'ko', 'ti', 'gr',
3185 'fd', 'fo', 'dp', 'no', 'po',
3186 're', 'wd', 'st', 'si', 'bu',
3187 'he', 'ch', 'bo', 'fa', 'wo'];
3188
3189 // Fill select box with town icons
3190 $('<div class="select_town_icon dropdown-list default active"><div class="item-list"></div></div>').appendTo("#town_icon");
3191 for (var i in icoArray) {
3192 if (icoArray.hasOwnProperty(i)) {
3193 $('.select_town_icon .item-list').append('<div class="option_s icon_small townicon_' + icoArray[i] + '" name="' + icoArray[i] + '"></div>');
3194 }
3195 }
3196 $('<hr><div class="option_s auto_s" name="auto"><b>Auto</b></div>').appendTo('.select_town_icon .item-list');
3197
3198 $('#town_icon .option_s').click(function () {
3199 $("#town_icon .sel").removeClass("sel");
3200 $(this).addClass("sel");
3201
3202 if ($(this).attr("name") === "auto") {
3203 delete manuTownTypes[uw.Game.townId];
3204 } else {
3205 manuTownTypes[uw.Game.townId] = $(this).attr("name");
3206 }
3207 TownIcons.changeTownIcon();
3208
3209 // Update town icons on the map
3210 TownIcons.Map.activate(); //setOnMap();
3211
3212 saveValue(WID + "_townTypes", JSON.stringify(manuTownTypes));
3213 });
3214
3215 // Show & hide drop menus on click
3216 $('#town_icon .town_icon_bg').click(function () {
3217 var el = $('#town_icon .select_town_icon').get(0);
3218 if (el.style.display === "none") {
3219 el.style.display = "block";
3220 } else {
3221 el.style.display = "none";
3222 }
3223 });
3224
3225 $('#town_icon .select_town_icon [name="' + (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" : "" )) + '"]').addClass("sel");
3226
3227 } catch (error) {
3228 errorHandling(error, "addTownIcon");
3229 }
3230 },
3231 changeTownIcon: function () {
3232 var townType = (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")));
3233 $('#town_icon .icon_big').removeClass().addClass('icon_big townicon_' + townType + " auto");
3234 $('#town_icon .sel').removeClass("sel");
3235 $('#town_icon .select_town_icon [name="' + (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" : "" )) + '"]').addClass("sel");
3236
3237 $('#town_icon .icon_big').css({
3238 backgroundPosition: TownIcons.types[townType] * -25 + 'px 0px'
3239 });
3240
3241 $('#town_icon .select_town_icon').get(0).style.display = "none";
3242 },
3243 Map: {
3244 // TODO: activate aufspliten in activate und add
3245 activate: function () {
3246 try {
3247 // if town icon changed
3248 if ($('#dio_townicons_map').get(0)) {
3249 $('#dio_townicons_map').remove();
3250 }
3251
3252 // Style for own towns (town icons)
3253 var start = (new Date()).getTime(), end, style_str = "<style id='dio_townicons_map' type='text/css'>";
3254 for (var e in autoTownTypes) {
3255 if (autoTownTypes.hasOwnProperty(e)) {
3256 style_str += "#mini_t" + e + ", #town_flag_"+ e + " .flagpole {"+
3257 "background: rgb(255, 187, 0) url(" + dio_sprite + ") " + (TownIcons.types[(manuTownTypes[e] || autoTownTypes[e])] * -25) + "px -27px repeat !important; } ";
3258 }
3259 }
3260
3261 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); } ";
3262
3263 // Mouseover Effect
3264 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; } ";
3265
3266
3267 // Context menu on mouse click
3268 style_str += "#minimap_islands_layer .m_town { z-index: 99; cursor: pointer; } ";
3269
3270 $('#minimap_islands_layer').off('click', '.m_town');
3271 $('#minimap_islands_layer').on('click', '.m_town', function (z) {
3272 var id = parseInt(this.id.substring(6), 10);
3273
3274 // Town names of foreign towns are unknown
3275 if(typeof(uw.ITowns.getTown(id)) !== "undefined") {
3276 Layout.contextMenu(z, 'determine', {"id": id, "name": uw.ITowns.getTown(id).name});
3277 }
3278 else {
3279 // No town name in the title of the window
3280 Layout.contextMenu(z, 'determine', {"id": id });
3281 }
3282
3283 // Prevent parent world wonder event
3284 z.stopPropagation();
3285 });
3286
3287 $('#minimap_islands_layer').off("mousedown");
3288 $('#minimap_islands_layer').on("mousedown", function(){
3289
3290 if(typeof($('#context_menu').get(0)) !== "undefined"){
3291 $('#context_menu').get(0).remove();
3292 }
3293 });
3294
3295
3296 // Town Popup for own towns
3297 style_str += "#dio_town_popup .count { position: absolute; bottom: 1px; right: 1px; font-size: 10px; } ";
3298
3299 // Town Popups on Strategic map
3300 $('#minimap_islands_layer').off('mouseout', '.m_town');
3301 $('#minimap_islands_layer').on('mouseout', '.m_town', function () {
3302 TownPopup.remove();
3303 });
3304 $('#minimap_islands_layer').off('mouseover', '.m_town');
3305 $('#minimap_islands_layer').on('mouseover', '.m_town', function () {
3306 TownPopup.add(this);
3307 });
3308
3309 // Town Popups on island view
3310 $('#map_towns').off('mouseout', '.own_town .flagpole');
3311 $('#map_towns').on('mouseout', '.own_town .flagpole', function () {
3312 TownPopup.remove();
3313 });
3314 $('#map_towns').off('mouseover', '.own_town .flagpole');
3315 $('#map_towns').on('mouseover', '.own_town .flagpole', function () {
3316 TownPopup.add(this);
3317 });
3318
3319
3320 // Style for foreign cities (shadow)
3321 style_str += "#minimap_islands_layer .m_town { text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.7); } ";
3322
3323 // Style for night mode
3324 style_str += "#minimap_canvas.expanded.night, #map.night .flagpole { filter: brightness(0.7); -webkit-filter: brightness(0.7); } ";
3325 style_str += "#minimap_click_layer { display:none; }";
3326
3327 style_str += "</style>";
3328 $(style_str).appendTo('head');
3329
3330
3331 } catch (error) {
3332 errorHandling(error, "TownIcons.Map.activate");
3333 }
3334 },
3335 deactivate: function () {
3336 $('#dio_townicons_map').remove();
3337
3338 // Events entfernen
3339 $('#minimap_islands_layer').off('click', '.m_town');
3340 $('#minimap_islands_layer').off("mousedown");
3341
3342 $('#minimap_islands_layer').off('mouseout', '.m_town');
3343 $('#minimap_islands_layer').off('mouseover', '.m_town');
3344 }
3345 }
3346 };
3347
3348 var TownPopup = {
3349 activate : function(){
3350
3351 $('<style id="dio_town_popup_style" type="text/css">' +
3352 '#dio_town_popup { position:absolute; z-index:99;max-width: 173px;} ' +
3353
3354 '#dio_town_popup .title { margin:5px;font-weight: bold; } ' +
3355
3356 '#dio_town_popup .dio_branding { position:absolute; right:12px; top:8px; height: 20px; filter:sepia(1); -webkit-filter:sepia(1); opacity:0.5; } ' +
3357
3358 '#dio_town_popup .unit_content, ' +
3359 '#dio_town_popup .spy_content, ' +
3360 '#dio_town_popup .god_content, ' +
3361 '#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; } ' +
3362 '#dio_town_popup .resources_content { text-align: right; margin-top:3px; } ' +
3363
3364 '#dio_town_popup .resources_content table { min-width:95% } ' +
3365
3366 '#dio_town_popup .footer_content { margin-top:3px; } ' +
3367 '#dio_town_popup .footer_content table { width:100%; } ' +
3368
3369 '#dio_town_popup .spy_content { height:25px; margin-right:3px; } ' +
3370 '#dio_town_popup .god_content { width:24px; } ' +
3371
3372 '#dio_town_popup .god_mini { height: 25px; width: 32px; background-size: 75%; background-position: 0px -122px; margin-right: -8px; } ' +
3373
3374 // God Icon
3375 '#dio_town_popup .god_mini.zeus { background-position: 0px 0px; } ' +
3376 '#dio_town_popup .god_mini.athena { background-position: 0px -24px; } ' +
3377 '#dio_town_popup .god_mini.poseidon { background-position: 0px -49px; } ' +
3378 '#dio_town_popup .god_mini.hera { background-position: 0px -73px; } ' +
3379 '#dio_town_popup .god_mini.hades { background-position: 0px -98px; } ' +
3380 '#dio_town_popup .god_mini.artemis { background-position: 0px -146px; } ' +
3381
3382 '#dio_town_popup .count { position: absolute; bottom: -2px; right: 2px; font-size: 10px; font-family: Verdana,Arial,Helvetica,sans-serif; } ' +
3383 '#dio_town_popup .four_digit_number .count { font-size:8px !important; } ' +
3384 '#dio_town_popup .unit_icon25x25 { border: 1px solid #6e4b0b; margin: 1px; } ' +
3385 '#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%; } ' +
3386
3387 // Spy Icon
3388 '#dio_town_popup .support_filter { margin: 0px 4px 0px 0px; float:left; } ' +
3389 '#dio_town_popup .spy_text { line-height: 2.3em; float:left; } ' +
3390
3391 // Bei langen Stadtnamen wird sonst der Rand abgeschnitten:
3392 '#dio_town_popup .popup_middle_right { min-width: 11px; } ' +
3393
3394 '</style>').appendTo('head');
3395
3396 },
3397 deactivate : function(){
3398 $("#dio_town_popup_style").remove();
3399 },
3400 add : function(that){
3401 var townID = 0;
3402 //console.debug("TOWN", $(that).offset(), that.id);
3403
3404 if(that.id === ""){
3405 // Island view
3406 townID = parseInt($(that).parent()[0].id.substring(10), 10);
3407 }
3408 else {
3409 // Strategic map
3410 townID = parseInt(that.id.substring(6), 10);
3411 }
3412
3413 // Own town?
3414 if (typeof(uw.ITowns.getTown(townID)) !== "undefined") {
3415
3416 var units = ITowns.getTowns()[townID].units();
3417
3418 TownPopup.remove();
3419
3420 // var popup = "<div id='dio_town_popup' style='left:" + ($(that).offset().left + 20) + "px; top:" + ($(that).offset().top + 20) + "px; '>";
3421 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'>";
3422
3423 popup += "<tr class='popup_top'><td class='popup_top_left'></td><td class='popup_top_middle'></td><td class='popup_top_right'></td></tr>";
3424
3425 popup += "<tr><td class='popup_middle_left'> </td><td style='width: auto;' class='popup_middle_middle'>";
3426
3427 // Title (town name)
3428 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>";
3429
3430 // Unit Container
3431 popup += "<div class='unit_content'>";
3432 if(!$.isEmptyObject(units)) {
3433
3434 for (var unit_id in units) {
3435 if (units.hasOwnProperty(unit_id)) {
3436
3437 var classSize = "";
3438
3439 if(units[unit_id] > 1000){
3440 classSize = "four_digit_number";
3441 }
3442
3443 // Unit
3444 popup += '<div class="unit_icon25x25 ' + unit_id + ' '+ classSize +'"><span class="count text_shadow">' + units[unit_id] + '</span></div>';
3445 }
3446 }
3447 }
3448
3449 // - Wall
3450 var wallLevel = ITowns.getTowns()[townID].getBuildings().attributes.wall;
3451 popup += '<div class="wall image bold"><span class="count text_shadow">'+ wallLevel +'</span></div>';
3452
3453 popup += "</div>";
3454
3455 // Resources Container
3456 popup += "<div class='resources_content'><table cellspacing='2px' cellpadding='0px'><tr>";
3457
3458 var resources = ITowns.getTowns()[townID].resources();
3459 var storage = ITowns.getTowns()[townID].getStorage();
3460
3461 // - Wood
3462 var textColor = (resources.wood === storage) ? textColor = "color:red;" : textColor = "";
3463 popup += '<td class="resources_small wood"></td><td style="'+ textColor +'; width:1%;">' + resources.wood + '</td>';
3464
3465 popup += '<td style="min-width:15px;"></td>';
3466
3467 // - Population
3468 popup += '<td class="resources_small population"></td><td style="width:1%">' + resources.population + '</td>';
3469
3470 popup += '</tr><tr>';
3471
3472 // - Stone
3473 textColor = (resources.stone === storage) ? textColor = "color:red;" : textColor = "";
3474 popup += '<td class="resources_small stone"></td><td style="'+ textColor +'">' + resources.stone + '</td>';
3475
3476 popup += '</tr><tr>';
3477
3478 // - Iron
3479 textColor = (resources.iron === storage) ? textColor = "color:red;" : textColor = "";
3480 popup += '<td class="resources_small iron"></td><td style="'+ textColor +'">' + resources.iron + '</td>';
3481
3482
3483 popup += "</tr></table></div>";
3484
3485 // console.debug("TOWNINFO", ITowns.getTowns()[townID]);
3486
3487 // Spy and God Container
3488 popup += "<div class='footer_content'><table cellspacing='0px'><tr>";
3489
3490 var spy_storage = ITowns.getTowns()[townID].getEspionageStorage();
3491
3492 // - Spy content
3493 popup += "<td class='spy_content'>";
3494 popup += '<div class="support_filter attack_spy"></div><div class="spy_text">'+ pointNumber(spy_storage) +'</div>';
3495 popup += "</td>";
3496
3497 popup += "<td></td>";
3498
3499 // - God Content
3500 var god = ITowns.getTowns()[townID].god();
3501
3502 popup += "<td class='god_content'>";
3503 popup += '<div class="god_mini '+ god +'"></div>';
3504 popup += "</td>";
3505
3506 popup += "</tr></table></div>";
3507
3508
3509
3510 popup += "</td><td class='popup_middle_right'> </td></tr>";
3511
3512 popup += "<tr class='popup_bottom'><td class='popup_bottom_left'></td><td class='popup_bottom_middle'></td><td class='popup_bottom_right'></td></tr>";
3513
3514 popup += "</table>";
3515
3516 $(popup).appendTo("#popup_div_curtain");
3517 }
3518 },
3519 remove : function(){
3520 $('#dio_town_popup').remove();
3521 }
3522 };
3523
3524 // Style for town icons
3525 var style_str = '<style id="dio_townicons" type="text/css">';
3526 for (var s in TownIcons.types) {
3527 if (TownIcons.types.hasOwnProperty(s)) {
3528 style_str += '.townicon_' + s + ' { background:url(' + dio_sprite + ') ' + (TownIcons.types[s] * -25) + 'px -26px repeat;float:left;} ';
3529 }
3530 }
3531 style_str += '</style>';
3532 $(style_str).appendTo('head');
3533
3534
3535 var ContextMenu = {
3536 activate: function () {
3537 // Set context menu event handler
3538 $.Observer(uw.GameEvents.map.context_menu.click).subscribe('DIO_CONTEXT', function (e, data) {
3539 if (DATA.options.con && $('#context_menu').children().length == 4) {
3540 // Clear animation
3541 $('#context_menu div#goToTown').css({
3542 left: '0px',
3543 top: '0px',
3544 WebkitAnimation: 'none', //'A 0s linear',
3545 animation: 'none' //'B 0s linear'
3546 });
3547 }
3548 // Replace german label of 'select town' button
3549 if (LID === "de" && $('#select_town').get(0)) {
3550 $("#select_town .caption").get(0).innerHTML = "Selektieren";
3551 }
3552 });
3553
3554 // Set context menu animation
3555 $('<style id="dio_context_menu" type="text/css">' +
3556 // set fixed position of 'select town' button
3557 '#select_town { left: 0px !important; top: 0px !important; z-index: 6; } ' +
3558 // set animation of 'goToTown' button
3559 '#context_menu div#goToTown { left: 30px; top: -51px; ' +
3560 '-webkit-animation: A 0.115s linear; animation: B 0.2s;} ' +
3561 '@-webkit-keyframes A { from {left: 0px; top: 0px;} to {left: 30px; top: -51px;} }' +
3562 '@keyframes B { from {left: 0px; top: 0px;} to {left: 30px; top: -51px;} }' +
3563 '</style>').appendTo('head');
3564 },
3565 deactivate: function () {
3566 $.Observer(uw.GameEvents.map.context_menu.click).unsubscribe('DIO_CONTEXT');
3567
3568 $('#dio_context_menu').remove();
3569 }
3570 };
3571
3572
3573 var TownList = {
3574 activate: function () {
3575 // Style town list
3576 $('<style id="dio_town_list" type="text/css">' +
3577 '#town_groups_list .item { text-align: left; padding-left:35px; } ' +
3578 '#town_groups_list .inner_column { border: 1px solid rgba(100, 100, 0, 0.3);margin: -2px 0px 0px 2px; } ' +
3579 '#town_groups_list .island_quest_icon { position: absolute; right: 37px; top: 3px; } ' +
3580 '#town_groups_list .island_quest_icon.hidden_icon { display:none; } ' +
3581 // Quacks Zentrier-Button verschieben
3582 '#town_groups_list .jump_town { right: 37px !important; } ' +
3583 // Population percentage
3584 '#town_groups_list .pop_percent { position: absolute; right: 7px; top:0px; font-size: 0.7em; display:block !important;} ' +
3585 '#town_groups_list .full { color: green; } ' +
3586 '#town_groups_list .threequarter { color: darkgoldenrod; } ' +
3587 '#town_groups_list .half { color: darkred; } ' +
3588 '#town_groups_list .quarter { color: red; } ' +
3589 '</style>').appendTo('head');
3590
3591
3592 // Open town list: hook to grepolis function render()
3593 var i = 0;
3594 while (uw.layout_main_controller.sub_controllers[i].name != 'town_name_area') {
3595 i++;
3596 }
3597
3598 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;
3599
3600 uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render = function () {
3601 uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render_old();
3602 TownList.change();
3603 };
3604
3605 // Town List open?
3606 if ($('#town_groups_list').get(0)) {
3607 TownList.change();
3608 }
3609 },
3610 deactivate: function () {
3611 var i = 0;
3612 while (uw.layout_main_controller.sub_controllers[i].name != 'town_name_area') {
3613 i++;
3614 }
3615
3616 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;
3617
3618 $('#dio_town_list').remove();
3619
3620 $('#town_groups_list .small_icon, #town_groups_list .pop_percent').css({display: 'none'});
3621
3622 //$.Observer(uw.GameEvents.town.town_switch).unsubscribe('DIO_SWITCH_TOWN');
3623
3624 $("#town_groups_list .town_group_town").unbind('mouseenter mouseleave');
3625 },
3626 change: function () {
3627 if (!$('#town_groups_list .icon_small').get(0) && !$('#town_groups_list .pop_percent').get(0)) {
3628 $("#town_groups_list .town_group_town").each(function () {
3629 try {
3630 var town_item = $(this), town_id = town_item.attr('name'), townicon_div, percent_div = "", percent = -1, pop_space = "full";
3631
3632 if (population[town_id]) {
3633 percent = population[town_id].percent;
3634 }
3635 if (percent < 75) {
3636 pop_space = "threequarter";
3637 }
3638 if (percent < 50) {
3639 pop_space = "half";
3640 }
3641 if (percent < 25) {
3642 pop_space = "quarter";
3643 }
3644
3645 if (!town_item.find('icon_small').length) {
3646 townicon_div = '<div class="icon_small townicon_' + (manuTownTypes[town_id] || autoTownTypes[town_id] || "no") + '"></div>';
3647 // TODO: Notlösung...
3648 if (percent != -1) {
3649 percent_div = '<div class="pop_percent ' + pop_space + '">' + percent + '%</div>';
3650 }
3651 town_item.prepend(townicon_div + percent_div);
3652 }
3653
3654 // opening context menu
3655 /*
3656 $(this).click(function(e){
3657 console.log(e);
3658 uw.Layout.contextMenu(e, 'determine', {"id": town_id,"name": uw.ITowns[town_id].getName()});
3659 });
3660 */
3661
3662 } catch (error) {
3663 errorHandling(error, "TownList.change");
3664 }
3665 });
3666
3667 }
3668
3669 // Hover Effect for Quacks Tool:
3670 $("#town_groups_list .town_group_town").hover(function () {
3671 $(this).find('.island_quest_icon').addClass("hidden_icon");
3672 }, function () {
3673 $(this).find('.island_quest_icon').removeClass("hidden_icon");
3674 });
3675
3676 // Add change town list event handler
3677 //$.Observer(uw.GameEvents.town.town_switch).subscribe('DIO_SWITCH_TOWN', function () {
3678 //TownList.change();
3679 //});
3680 }
3681 };
3682
3683 var HiddenHighlightWindow = {
3684 activate : function(){
3685 // Style town list
3686 $('<style id="dio_hidden_highlight_window" type="text/css">' +
3687 '.strategic_map_filter { display:none !important; } ' +
3688 '</style>').appendTo('head');
3689 },
3690 deactivate : function (){
3691 $('#dio_hidden_highlight_window').remove();
3692 }
3693 };
3694
3695 /*******************************************************************************************************************************
3696 * Available units
3697 * ----------------------------------------------------------------------------------------------------------------------------
3698 * | â— GetAllUnits
3699 * | â— Shows all available units
3700 * ----------------------------------------------------------------------------------------------------------------------------
3701 *******************************************************************************************************************************/
3702 var groupUnitArray = {};
3703 // TODO: split Function (getUnits, calcUnitsSum, availableUnits, countBiremes, getTownTypes)?
3704
3705 // Alter Einheitenzähler
3706 function getAllUnits() {
3707 try {
3708 var townArray = uw.ITowns.getTowns(), groupArray = uw.ITowns.townGroups.getGroupsDIO(),
3709
3710 unitArray = {
3711 "sword": 0,
3712 "archer": 0,
3713 "hoplite": 0,
3714 "chariot": 0,
3715 "godsent": 0,
3716 "rider": 0,
3717 "slinger": 0,
3718 "catapult": 0,
3719 "small_transporter": 0,
3720 "big_transporter": 0,
3721 "manticore": 0,
3722 "harpy": 0,
3723 "pegasus": 0,
3724 "cerberus": 0,
3725 "minotaur": 0,
3726 "medusa": 0,
3727 "zyklop": 0,
3728 "centaur": 0,
3729 "fury": 0,
3730 "sea_monster": 0
3731 },
3732
3733 unitArraySea = {"bireme": 0, "trireme": 0, "attack_ship": 0, "demolition_ship": 0, "colonize_ship": 0};
3734
3735 //console.debug("DIO-TOOLS | getAllUnits | GROUP ARRAY", groupArray);
3736
3737
3738 if (uw.Game.hasArtemis) {
3739 unitArray = $.extend(unitArray, {"griffin": 0, "calydonian_boar": 0});
3740 }
3741 unitArray = $.extend(unitArray, unitArraySea);
3742
3743 for (var group in groupArray) {
3744 if (groupArray.hasOwnProperty(group)) {
3745 // Clone Object "unitArray"
3746 groupUnitArray[group] = Object.create(unitArray);
3747
3748 for (var town in groupArray[group].towns) {
3749 if (groupArray[group].towns.hasOwnProperty(town)) {
3750 var type = {lo: 0, ld: 0, so: 0, sd: 0, fo: 0, fd: 0}; // Type for TownList
3751
3752 for (var unit in unitArray) {
3753 if (unitArray.hasOwnProperty(unit)) {
3754 // All Groups: Available units
3755 var tmp = parseInt(uw.ITowns.getTown(town).units()[unit], 10);
3756 groupUnitArray[group][unit] += tmp || 0;
3757 // Only for group "All"
3758 if (group == -1) {
3759 // Bireme counter // old
3760 if (unit === "bireme" && ((biriArray[townArray[town].id] || 0) < (tmp || 0))) {
3761 biriArray[townArray[town].id] = tmp;
3762 }
3763 //TownTypes
3764 if (!uw.GameData.units[unit].is_naval) {
3765 if (uw.GameData.units[unit].flying) {
3766 type.fd += ((uw.GameData.units[unit].def_hack + uw.GameData.units[unit].def_pierce + uw.GameData.units[unit].def_distance) / 3 * (tmp || 0));
3767 type.fo += (uw.GameData.units[unit].attack * (tmp || 0));
3768 } else {
3769 type.ld += ((uw.GameData.units[unit].def_hack + uw.GameData.units[unit].def_pierce + uw.GameData.units[unit].def_distance) / 3 * (tmp || 0));
3770 type.lo += (uw.GameData.units[unit].attack * (tmp || 0));
3771 }
3772 } else {
3773 type.sd += (uw.GameData.units[unit].defense * (tmp || 0));
3774 type.so += (uw.GameData.units[unit].attack * (tmp || 0));
3775 }
3776 }
3777 }
3778 }
3779 // Only for group "All"
3780 if (group == -1) {
3781 // Icon: DEF or OFF?
3782 var z = ((type.sd + type.ld + type.fd) <= (type.so + type.lo + type.fo)) ? "o" : "d",
3783 temp = 0;
3784
3785 for (var t in type) {
3786 if (type.hasOwnProperty(t)) {
3787 // Icon: Land/Sea/Fly (t[0]) + OFF/DEF (z)
3788 if (temp < type[t]) {
3789 autoTownTypes[townArray[town].id] = t[0] + z;
3790 temp = type[t];
3791 }
3792 // Icon: Troops Outside (overwrite)
3793 if (temp < 1000) {
3794 autoTownTypes[townArray[town].id] = "no";
3795 }
3796 }
3797 }
3798 // Icon: Empty Town (overwrite)
3799 var popBuilding = 0, buildVal = uw.GameData.buildings, levelArray = townArray[town].buildings().getLevels(),
3800 popMax = Math.floor(buildVal.farm.farm_factor * Math.pow(townArray[town].buildings().getBuildingLevel("farm"), buildVal.farm.farm_pow)), // Population from farm level
3801 popPlow = townArray[town].getResearches().attributes.plow ? 200 : 0,
3802 popFactor = townArray[town].getBuildings().getBuildingLevel("thermal") ? 1.1 : 1.0, // Thermal
3803 popExtra = townArray[town].getPopulationExtra();
3804
3805 for (var b in levelArray) {
3806 if (levelArray.hasOwnProperty(b)) {
3807 popBuilding += Math.round(buildVal[b].pop * Math.pow(levelArray[b], buildVal[b].pop_factor));
3808 }
3809 }
3810 population[town] = {};
3811
3812 population[town].max = popMax * popFactor + popPlow + popExtra;
3813 population[town].buildings = popBuilding;
3814 population[town].units = parseInt((population[town].max - (popBuilding + townArray[town].getAvailablePopulation()) ), 10);
3815
3816 if (population[town].units < 300) {
3817 autoTownTypes[townArray[town].id] = "po";
3818 }
3819
3820 population[town].percent = Math.round(100 / (population[town].max - popBuilding) * population[town].units);
3821 }
3822 }
3823 }
3824 }
3825 }
3826
3827 // Update Available Units
3828 AvailableUnits.updateBullseye();
3829 if (GPWindowMgr.TYPE_DIO_UNITS) {
3830 if (Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS)) {
3831 AvailableUnits.updateWindow();
3832 }
3833 }
3834 } catch (error) {
3835 errorHandling(error, "getAllUnits"); // TODO: Eventueller Fehler in Funktion
3836 }
3837 }
3838
3839 function addFunctionToITowns() {
3840 // Copy function and prevent an error
3841 uw.ITowns.townGroups.getGroupsDIO = function () {
3842 var town_groups_towns, town_groups, groups = {};
3843
3844 // #Grepolis Fix: 2.75 -> 2.76
3845 if (MM.collections) {
3846 town_groups_towns = MM.collections.TownGroupTown[0];
3847 town_groups = MM.collections.TownGroup[0];
3848 } else {
3849 town_groups_towns = MM.getCollections().TownGroupTown[0];
3850 town_groups = MM.getCollections().TownGroup[0];
3851 }
3852
3853 town_groups_towns.each(function (town_group_town) {
3854 var gid = town_group_town.getGroupId(),
3855 group = groups[gid],
3856 town_id = town_group_town.getTownId();
3857
3858 if (!group) {
3859 groups[gid] = group = {
3860 id: gid,
3861 //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
3862 towns: {}
3863 };
3864 }
3865
3866 group.towns[town_id] = {id: town_id};
3867 //groups[gid].towns[town_id]={id:town_id};
3868 });
3869 //console.log(groups);
3870 return groups;
3871 };
3872 }
3873
3874
3875 // Neuer Einheitenzähler
3876 var UnitCounter = {
3877 units : {"total":{}, "available":{}, "outer":{}, "foreign":{}},
3878
3879 count : function(){
3880 var tooltipHelper = require("helpers/units_tooltip_helper");
3881
3882 var groups = uw.ITowns.townGroups.getGroupsDIO();
3883
3884 for (var groupId in groups) {
3885 if (groups.hasOwnProperty(groupId)) {
3886
3887 UnitCounter.units.total[groupId] = {};
3888 UnitCounter.units.available[groupId] = {};
3889 UnitCounter.units.outer[groupId] = {};
3890
3891
3892 for (var townId in groups[groupId].towns) {
3893 if (groups[groupId].towns.hasOwnProperty(townId)) {
3894
3895 // Einheiten gesamt
3896 UnitCounter.units.total[groupId][townId] = ITowns.towns[townId].units();
3897
3898 // Einheiten verfügbar
3899 UnitCounter.units.available[groupId][townId] = ITowns.towns[townId].units();
3900
3901 // Einheiten außerhalb
3902 UnitCounter.units.outer[groupId][townId] = {};
3903
3904 var supports = tooltipHelper.getDataForSupportingUnitsInOtherTownFromCollection(MM.getTownAgnosticCollectionsByName("Units")[1].fragments[townId], MM.getOnlyCollectionByName("Town"));
3905
3906 for (var supportId in supports) {
3907 if (supports.hasOwnProperty(supportId)) {
3908
3909 for (var attributeId in supports[supportId].attributes) {
3910 if (supports[supportId].attributes.hasOwnProperty(attributeId)) {
3911
3912 // Attribut ist eine Einheit?
3913 if (typeof(GameData.units[attributeId]) !== "undefined" && supports[supportId].attributes[attributeId] > 0) {
3914
3915 UnitCounter.units.outer[groupId][townId][attributeId] = (UnitCounter.units.outer[groupId][townId][attributeId] || 0) + supports[supportId].attributes[attributeId];
3916
3917 UnitCounter.units.total[groupId][townId][attributeId] = (UnitCounter.units.total[groupId][townId][attributeId] || 0) + supports[supportId].attributes[attributeId];
3918 }
3919 }
3920 }
3921 }
3922 }
3923 }
3924 }
3925
3926 // Summen aller Städte berechnen
3927 UnitCounter.summarize(groupId);
3928 }
3929 }
3930
3931 return UnitCounter.units;
3932 },
3933
3934 summarize : function(groupId){
3935 var tooltipHelper = require("helpers/units_tooltip_helper");
3936
3937 UnitCounter.units.total[groupId]["all"] = {};
3938 UnitCounter.units.available[groupId]["all"] = {};
3939 UnitCounter.units.outer[groupId]["all"] = {};
3940
3941 for(var townId in UnitCounter.units.total[groupId]){
3942 if(UnitCounter.units.total[groupId].hasOwnProperty(townId) && townId !== "all"){
3943
3944 // Einheiten gesamt
3945 for(var unitId in UnitCounter.units.total[groupId][townId]){
3946 if(UnitCounter.units.total[groupId][townId].hasOwnProperty(unitId)){
3947
3948 UnitCounter.units.total[groupId]["all"][unitId] = (UnitCounter.units.total[groupId]["all"][unitId] || 0) + UnitCounter.units.total[groupId][townId][unitId];
3949 }
3950 }
3951
3952 // Einheiten verfügbar
3953 for(var unitId in UnitCounter.units.available[groupId][townId]){
3954 if(UnitCounter.units.available[groupId][townId].hasOwnProperty(unitId)){
3955
3956 UnitCounter.units.available[groupId]["all"][unitId] = (UnitCounter.units.available[groupId]["all"][unitId] || 0) + UnitCounter.units.available[groupId][townId][unitId];
3957 }
3958 }
3959
3960 // Einheiten außerhalb
3961 for(var unitId in UnitCounter.units.outer[groupId][townId]){
3962 if(UnitCounter.units.outer[groupId][townId].hasOwnProperty(unitId)){
3963
3964 UnitCounter.units.outer[groupId]["all"][unitId] = (UnitCounter.units.outer[groupId]["all"][unitId] || 0) + UnitCounter.units.outer[groupId][townId][unitId];
3965 }
3966 }
3967 }
3968 }
3969 }
3970 };
3971
3972
3973 var AvailableUnits = {
3974 activate: function () {
3975 var default_title = DM.getl10n("place", "support_overview").options.troop_count + " (" + DM.getl10n("hercules2014", "available") + ")";
3976
3977 $(".picomap_container").prepend("<div id='available_units_bullseye' class='unit_icon90x90 " + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme") + "'><div class='amount'></div></div>");
3978
3979 $('.picomap_overlayer').tooltip(getText("options", "ava")[0]);
3980
3981 // Ab version 2.115
3982 if($(".topleft_navigation_area").get(0)) {
3983
3984 $(".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>");
3985
3986 $('<style id="dio_available_units_style_addition">' +
3987 '.coords_box { top: 117px !important; } ' +
3988 '.nui_grepo_score { top: 150px !important; } ' +
3989 '.nui_left_box { top: 102px !important; } ' +
3990 '.nui_main_menu { top: 293px !important; }' +
3991 '#grcrt_mnu_list .nui_main_menu {top: 0px !important; }'+
3992 '.bull_eye_buttons, .rb_map { height:38px !important; }' +
3993
3994 '#ui_box .btn_change_colors { top: 31px !important; }' +
3995
3996 '.picomap_area { position: absolute; overflow: visible; top: 0; left: 0; width: 156px; height: 161px; z-index: 5; }' +
3997 '.picomap_area .picomap_container, .picomap_area .picomap_overlayer { position: absolute; top: 33px; left: -3px; width: 147px; height: 101px; }' +
3998 //'.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;} '+
3999 '.picomap_area .picomap_overlayer { background: url(' + dio_sprite + '); background-position: 473px 250px; width: 147px; height: 101px; z-index: 5;} ' +
4000 '</style>').appendTo('head');
4001 }
4002
4003 // Style
4004 $('<style id="dio_available_units_style">' +
4005
4006 '@-webkit-keyframes Z { 0% { opacity: 0; } 100% { opacity: 1; } } ' +
4007 '@keyframes Z { 0% { opacity: 0; } 100% { opacity: 1; } } ' +
4008
4009 '@-webkit-keyframes blurr { 0% { -webkit-filter: blur(5px); } 100% { -webkit-filter: blur(0px); } } ' +
4010
4011 '.picomap_overlayer { cursor:pointer; } ' +
4012
4013 '.picomap_area .bull_eye_buttons { height: 55px; } ' +
4014
4015 '#sea_id { background: none; font-size:25px; cursor:default; height:50px; width:50px; position:absolute; top:70px; left:157px; z-index: 30; } ' +
4016
4017 // Available bullseye unit
4018 '#available_units_bullseye { margin: 5px 28px 0px 28px; -webkit-animation: blur 2s; animation: Z 1s; } ' +
4019
4020 '#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; } ' +
4021
4022 '#available_units_bullseye.big_number { font-size: 0.90em; line-height: 1.4; } ' +
4023
4024 '#available_units_bullseye.blur { -webkit-animation: blurr 0.6s; } ' +
4025
4026
4027
4028 // Land units
4029 '#available_units_bullseye.sword .amount { color:#E2D9C1; top:57px; width:90px; } ' +
4030 '#available_units_bullseye.hoplite .amount { color:#E2D9C1; top:57px; width:90px; } ' +
4031 '#available_units_bullseye.archer .amount { color:#E2D0C1; top:47px; width:70px; } ' +
4032 '#available_units_bullseye.chariot { margin-top: 15px; } ' +
4033 '#available_units_bullseye.chariot .amount { color:#F5E8B4; top:38px; width:91px; } ' +
4034 '#available_units_bullseye.rider .amount { color:#DFCC6C; top:52px; width:105px; } ' +
4035 '#available_units_bullseye.slinger .amount { color:#F5E8B4; top:53px; width:91px; } ' +
4036 '#available_units_bullseye.catapult .amount { color:#F5F6C5; top:36px; width:87px; } ' +
4037 '#available_units_bullseye.godsent .amount { color:#F5F6C5; top:57px; width:92px; } ' +
4038
4039 // Mythic units
4040 '#available_units_bullseye.medusa .amount { color:#FBFFBB; top:50px; width:65px; } ' +
4041 '#available_units_bullseye.manticore .amount { color:#ECD181; top:50px; width:55px; } ' +
4042 '#available_units_bullseye.pegasus { margin-top: 16px; } ' +
4043 '#available_units_bullseye.pegasus .amount { color:#F7F8E3; top:36px; width:90px; } ' +
4044 '#available_units_bullseye.minotaur { margin-top: 10px; } ' +
4045 '#available_units_bullseye.minotaur .amount { color:#EAD88A; top:48px; width:78px; } ' +
4046 '#available_units_bullseye.zyklop { margin-top: 3px; } '+
4047 '#available_units_bullseye.zyklop .amount { color:#EDE0B0; top:50px; width:95px; } ' +
4048 '#available_units_bullseye.harpy { margin-top: 16px; } ' +
4049 '#available_units_bullseye.harpy .amount { color:#E7DB79; top:30px; width:78px; } ' +
4050 '#available_units_bullseye.sea_monster .amount { color:#D8EA84; top:58px; width:91px; } ' +
4051 '#available_units_bullseye.cerberus .amount { color:#EC7445; top:25px; width:101px; } ' +
4052 '#available_units_bullseye.centaur { margin-top: 15px; } ' +
4053 '#available_units_bullseye.centaur .amount { color:#ECE0A8; top:29px; width:83px; } ' +
4054 '#available_units_bullseye.fury .amount { color:#E0E0BC; top:57px; width:95px; } ' +
4055 '#available_units_bullseye.griffin { margin-top: 15px; } ' +
4056 '#available_units_bullseye.griffin .amount { color:#FFDC9D; top:40px; width:98px; } ' +
4057 '#available_units_bullseye.calydonian_boar .amount { color:#FFDC9D; top:17px; width:85px; } ' +
4058
4059 // Naval units
4060 '#available_units_bullseye.attack_ship .amount { color:#FFCB00; top:26px; width:99px; } ' +
4061 '#available_units_bullseye.bireme .amount { color:#DFC677; color:azure; top:28px; width:79px; } ' +
4062 '#available_units_bullseye.trireme .amount { color:#F4FFD4; top:24px; width:90px; } ' +
4063 '#available_units_bullseye.small_transporter .amount { color:#F5F6C5; top:26px; width:84px; } ' +
4064 '#available_units_bullseye.big_transporter .amount { color:#FFDC9D; top:27px; width:78px; } ' +
4065 '#available_units_bullseye.colonize_ship .amount { color:#F5F6C5; top:29px; width:76px; } ' +
4066 '#available_units_bullseye.colonize_ship .amount { color:#F5F6C5; top:29px; width:76px; } ' +
4067 '#available_units_bullseye.demolition_ship .amount { color:#F5F6C5; top:35px; width:90px; } ' +
4068
4069 // Available units window
4070 '#available_units { overflow: auto; } ' +
4071 '#available_units .unit { margin: 5px; cursor:pointer; overflow:visible; } ' +
4072 '#available_units .unit.active { border: 2px solid #7f653a; border-radius:30px; margin:4px; } ' +
4073 '#available_units .unit span { text-shadow: 1px 1px 1px black, 1px 1px 2px black;} ' +
4074 '#available_units hr { margin: 5px 0px 5px 0px; } ' +
4075 '#available_units .drop_box .option { float: left; margin-right: 30px; width:100%; } ' +
4076 '#available_units .drop_box { position:absolute; top: -38px; right: 83px; width:90px; z-index:10; } ' +
4077 '#available_units .drop_box .drop_group { width: 120px; } ' +
4078 '#available_units .drop_box .select_group.open { display:block; } ' +
4079 '#available_units .drop_box .item-list { overflow: auto; overflow-x: hidden; } ' +
4080 '#available_units .drop_box .arrow { width:18px; height:18px; background:url(' + drop_out.src + ') no-repeat -1px -1px; position:absolute; } ' +
4081
4082 // Available units button
4083 '#btn_available_units { top:86px; left:119px; z-index:10; position:absolute; } ' +
4084 '#btn_available_units .ico_available_units { margin:5px 0px 0px 4px; width:24px; height:24px; ' +
4085 '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); } ' +
4086
4087 '</style>').appendTo('head');
4088
4089 createWindowType("DIO_UNITS", (LANG.hasOwnProperty(LID) ? getText("options", "ava")[0] : default_title), 365, 310, true, [240, 70]);
4090
4091 // Set Sea-ID beside the bull eye
4092 $('#sea_id').prependTo('#ui_box');
4093
4094 AvailableUnits.addButton();
4095
4096 UnitCounter.count();
4097 AvailableUnits.updateBullseye();
4098 },
4099 deactivate: function () {
4100 $('#available_units_bullseye').remove();
4101 $('#available_units_bullseye_addition').remove();
4102
4103 $('#dio_available_units_style').remove();
4104 $('#dio_available_units_style_addition').remove();
4105
4106 $('#btn_available_units').remove();
4107
4108 if (Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS)) {
4109 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS).close();
4110 }
4111
4112 $('.picomap_overlayer').unbind();
4113
4114 $('#sea_id').appendTo('.picomap_container')
4115 },
4116 addButton: function () {
4117 var default_title = DM.getl10n("place", "support_overview").options.troop_count + " (" + DM.getl10n("hercules2014", "available") + ")";
4118
4119 $('<div id="btn_available_units" class="circle_button"><div class="ico_available_units js-caption"></div></div>').appendTo(".bull_eye_buttons");
4120
4121 // Events
4122 $('#btn_available_units').on('mousedown', function () {
4123 $('#btn_available_units, .ico_available_units').addClass("checked");
4124 }).on('mouseup', function () {
4125 $('#btn_available_units, .ico_available_units').removeClass("checked");
4126 });
4127
4128 $('#btn_available_units, .picomap_overlayer').click(function () {
4129 if (!Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS)) {
4130 AvailableUnits.openWindow();
4131 $('#btn_available_units, .ico_available_units').addClass("checked");
4132 } else {
4133 AvailableUnits.closeWindow();
4134 $('#btn_available_units, .ico_available_units').removeClass("checked");
4135 }
4136 });
4137
4138 // Tooltip
4139 $('#btn_available_units').tooltip(LANG.hasOwnProperty(LID) ? getText("labels", "uni") : default_title);
4140 },
4141 openWindow: function () {
4142 var groupArray = uw.ITowns.townGroups.getGroupsDIO(),
4143
4144 unitArray = {
4145 "sword": 0,
4146 "archer": 0,
4147 "hoplite": 0,
4148 "slinger": 0,
4149 "rider": 0,
4150 "chariot": 0,
4151 "catapult": 0,
4152 "godsent": 0,
4153 "manticore": 0,
4154 "harpy": 0,
4155 "pegasus": 0,
4156 "griffin": 0,
4157 "cerberus": 0,
4158 "minotaur": 0,
4159 "medusa": 0,
4160 "zyklop": 0,
4161 "centaur": 0,
4162 "calydonian_boar": 0,
4163 "fury": 0,
4164 "sea_monster": 0,
4165 "small_transporter": 0,
4166 "big_transporter": 0,
4167 "bireme": 0,
4168 "attack_ship": 0,
4169 "trireme": 0,
4170 "demolition_ship": 0,
4171 "colonize_ship": 0
4172 };
4173
4174 if (!uw.Game.hasArtemis) {
4175 delete unitArray.calydonian_boar;
4176 delete unitArray.griffin;
4177 }
4178
4179 var land_units_str = "", content =
4180 '<div id="available_units">' +
4181 // Dropdown menu
4182 '<div class="drop_box">' +
4183 '<div class="drop_group dropdown default">' +
4184 '<div class="border-left"></div><div class="border-right"></div>' +
4185 '<div class="caption" name="' + groupArray[DATA.bullseyeUnit.current_group].id + '">' + ITowns.town_groups._byId[groupArray[DATA.bullseyeUnit.current_group].id].attributes.name + '</div>' +
4186 '<div class="arrow"></div>' +
4187 '</div>' +
4188 '<div class="select_group dropdown-list default active"><div class="item-list"></div></div>' +
4189 '</div>' +
4190 '<table width="100%" class="radiobutton horizontal rbtn_visibility"><tr>'+
4191 '<td width="40%"><div class="option js-option" name="total"><div class="pointer"></div>'+ getText("labels", "total") +'</div></td>'+
4192 '<td width="40%"><div class="option js-option" name="available"><div class="pointer"></div>'+ getText("labels", "available") +'</div></td>'+
4193 '<td width="20%"><div class="option js-option" name="outer"><div class="pointer"></div>'+ getText("labels", "outer") +'</div></td>'+
4194 '</tr></table>'+
4195 '<hr>'+
4196 // Content
4197 '<div class="box_content">';
4198
4199 for (var unit in unitArray) {
4200 if (unitArray.hasOwnProperty(unit)) {
4201 land_units_str += '<div class="unit index_unit bold unit_icon40x40 ' + unit + '"></div>';
4202 if (unit == "sea_monster") {
4203 land_units_str += '<div style="clear:left;"></div>'; // break
4204 }
4205 }
4206 }
4207 content += land_units_str + '</div></div>';
4208
4209 AvailableUnits.wnd = Layout.wnd.Create(GPWindowMgr.TYPE_DIO_UNITS);
4210
4211 AvailableUnits.wnd.setContent(content);
4212
4213 if (Game.premium_features.curator <= Timestamp.now()) {
4214 $('#available_units .drop_box').css({display: 'none'});
4215 DATA.bullseyeUnit.current_group = -1;
4216 }
4217
4218 // Add groups to dropdown menu
4219 for (var group in groupArray) {
4220 if (groupArray.hasOwnProperty(group)) {
4221 var group_name = ITowns.town_groups._byId[group].attributes.name;
4222 $('<div class="option' + (group == -1 ? " sel" : "") + '" name="' + group + '">' + group_name + '</div>').appendTo('#available_units .item-list');
4223 }
4224 }
4225
4226 // Set active mode
4227 if(typeof(DATA.bullseyeUnit.mode) !== "undefined"){
4228 $('.radiobutton .option[name="'+ DATA.bullseyeUnit.mode +'"]').addClass("checked");
4229 }
4230 else{
4231 $('.radiobutton .option[name="available"]').addClass("checked");
4232 }
4233
4234 // Update
4235 AvailableUnits.updateWindow();
4236
4237 // Dropdown menu Handler
4238 $('#available_units .drop_group').click(function () {
4239 $('#available_units .select_group').toggleClass('open');
4240 });
4241 // Change group
4242 $('#available_units .select_group .option').click(function () {
4243 DATA.bullseyeUnit.current_group = $(this).attr("name");
4244 $('#available_units .select_group').removeClass('open');
4245 $('#available_units .select_group .option.sel').removeClass("sel");
4246 $(this).addClass("sel");
4247
4248 $('#available_units .drop_group .caption').attr("name", DATA.bullseyeUnit.current_group);
4249 $('#available_units .drop_group .caption').get(0).innerHTML = this.innerHTML;
4250
4251 $('#available_units .unit.active').removeClass("active");
4252 $('#available_units .unit.' + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme")).addClass("active");
4253
4254 UnitCounter.count();
4255
4256 AvailableUnits.updateWindow();
4257 AvailableUnits.updateBullseye();
4258 AvailableUnits.save();
4259 });
4260
4261 // Change mode (total, available, outer)
4262 $('.radiobutton .option').click(function(){
4263
4264 DATA.bullseyeUnit.mode = $(this).attr("name");
4265
4266 $('.radiobutton .option.checked').removeClass("checked");
4267 $(this).addClass("checked");
4268
4269 UnitCounter.count();
4270
4271 AvailableUnits.updateWindow();
4272 AvailableUnits.updateBullseye();
4273 AvailableUnits.save();
4274 });
4275
4276 // Set active bullseye unit
4277 $('#available_units .unit.' + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme")).addClass("active");
4278
4279 // Change bullseye unit
4280 $('#available_units .unit').click(function () {
4281 DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] = this.className.split(" ")[4].trim();
4282
4283 $('#available_units .unit.active').removeClass("active");
4284 $(this).addClass("active");
4285
4286 AvailableUnits.updateBullseye();
4287 AvailableUnits.save();
4288
4289 });
4290
4291 // Close button event - uncheck available units button
4292 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS).getJQCloseButton().get(0).onclick = function () {
4293 $('#btn_available_units, .ico_available_units').removeClass("checked");
4294 };
4295 },
4296 closeWindow: function () {
4297 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS).close();
4298 },
4299 save: function () {
4300 // console.debug("BULLSEYE SAVE", DATA.bullseyeUnit);
4301
4302 saveValue(WID + "_bullseyeUnit", JSON.stringify(DATA.bullseyeUnit));
4303 },
4304 updateBullseye: function () {
4305
4306 var sum = 0, str = "", fsize = ['1.4em', '1.2em', '1.15em', '1.1em', '1.0em', '0.95em'], i;
4307
4308 if ($('#available_units_bullseye').get(0)) {
4309 $('#available_units_bullseye').get(0).className = "unit_icon90x90 " + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme");
4310
4311 if (UnitCounter.units[DATA.bullseyeUnit.mode || "available"][DATA.bullseyeUnit.current_group]) {
4312 sum = UnitCounter.units[DATA.bullseyeUnit.mode || "available"][DATA.bullseyeUnit.current_group]["all"][(DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme" )] || 0;
4313 }
4314 sum = sum.toString();
4315
4316 for (i = 0; i < sum.length; i++) {
4317 str += "<span style='font-size:" + fsize[i] + "'>" + sum[i] + "</span>";
4318 }
4319 $('#available_units_bullseye .amount').get(0).innerHTML = str;
4320
4321 if (sum >= 100000) {
4322 $('#available_units_bullseye').addClass("big_number");
4323 } else {
4324 $('#available_units_bullseye').removeClass("big_number");
4325 }
4326 }
4327 },
4328 updateWindow: function () {
4329
4330 $('#available_units .box_content .unit').each(function () {
4331 var unit = this.className.split(" ")[4];
4332
4333 // TODO: Alte Variante entfernen
4334 // Alte Variante:
4335 //this.innerHTML = '<span style="font-size:0.9em">' + groupUnitArray[DATA.bullseyeUnit.current_group][unit] + '</span>';
4336
4337 // Neue Variante
4338 this.innerHTML = '<span style="font-size:0.9em">' + (UnitCounter.units[DATA.bullseyeUnit.mode || "available"][DATA.bullseyeUnit.current_group]["all"][unit] || 0) + '</span>';
4339 });
4340 }
4341 };
4342
4343 /*******************************************************************************************************************************
4344 * Comparison box
4345 * ----------------------------------------------------------------------------------------------------------------------------
4346 * | â— Compares the units of each unit type
4347 * ----------------------------------------------------------------------------------------------------------------------------
4348 *******************************************************************************************************************************/
4349 var UnitComparison = {
4350 activate: function () {
4351 //UnitComparison.addBox();
4352 UnitComparison.addButton();
4353
4354 // Create Window Type
4355 createWindowType("DIO_COMPARISON", getText("labels", "dsc"), 480, 315, true, ["center", "center", 100, 100]);
4356
4357 // Style
4358 $('<style id="dio_comparison_style"> ' +
4359
4360 // Button
4361 '#dio_comparison_button { top:51px; left:120px; z-index:10; position:absolute; } ' +
4362 '#dio_comparison_button .ico_comparison { margin:5px 0px 0px 4px; width:24px; height:24px; ' +
4363 'background:url(http://666kb.com/i/cjq6cxia4ms8mn95r.png) no-repeat 0px 0px; background-size:100%; filter:url(#Hue1); -webkit-filter:hue-rotate(60deg); } ' +
4364 '#dio_comparison_button.checked .ico_comparison { margin-top:6px; } ' +
4365
4366 // Window
4367 '#dio_comparison a { float:left; background-repeat:no-repeat; background-size:25px; line-height:2; margin-right:10px; } ' +
4368 '#dio_comparison .box_content { text-align:center; font-style:normal; } ' +
4369
4370 // Menu tabs
4371 '#dio_comparison_menu .tab_icon { left: 23px;} ' +
4372 '#dio_comparison_menu .tab_label { margin-left: 18px; } ' +
4373
4374 // Content
4375 '#dio_comparison .hidden { display:none; } ' +
4376 '#dio_comparison table { width:480px; } ' +
4377 '#dio_comparison .hack .t_hack, #dio_comparison .pierce .t_pierce, #dio_comparison .distance .t_distance, #dio_comparison .sea .t_sea { display:inline-table; } ' +
4378
4379 '#dio_comparison .box_content { background:url(http://s1.directupload.net/images/140206/8jd9d3ec.png) 94% 94% no-repeat; background-size:140px; } ' +
4380
4381 '#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%; } ' +
4382 '#dio_comparison .compare_type_icon.booty { background:url(http://s14.directupload.net/images/140404/ki4gwd7x.png); background-size:100%; } ' +
4383 '#dio_comparison .compare_type_icon.time { background:url(https://gpall.innogamescdn.com/images/game/res/time.png); background-size:100%; } ' +
4384 '#dio_comparison .compare_type_icon.favor { background:url(https://gpall.innogamescdn.com/images/game/res/favor.png); background-size:100%; } ' +
4385 '</style>').appendTo("head");
4386 },
4387 deactivate: function () {
4388 $('#dio_comparison_button').remove();
4389 $('#dio_comparison_style').remove();
4390
4391 if (Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON)) {
4392 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON).close();
4393 }
4394 },
4395 addButton: function () {
4396 $('<div id="dio_comparison_button" class="circle_button"><div class="ico_comparison js-caption"></div></div>').appendTo(".bull_eye_buttons");
4397
4398 // Events
4399 /*
4400 $('#dio_comparison_button').on('mousedown', function(){
4401 $('#dio_comparison_button').addClass("checked");
4402 }, function(){
4403 $('#dio_comparison_button').removeClass("checked");
4404 });
4405 */
4406 $('#dio_comparison_button').on('click', function () {
4407 if (!Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON)) {
4408 UnitComparison.openWindow();
4409 $('#dio_comparison_button').addClass("checked");
4410 } else {
4411 UnitComparison.closeWindow();
4412 $('#dio_comparison_button').removeClass("checked");
4413 }
4414 });
4415
4416 // Tooltip
4417 $('#dio_comparison_button').tooltip(getText("labels", "dsc"));
4418 },
4419 openWindow: function () {
4420 var content =
4421 // Title tabs
4422 '<ul id="dio_comparison_menu" class="menu_inner" style="top: -36px; right: 35px;">' +
4423 '<li><a class="submenu_link sea" href="#"><span class="left"><span class="right"><span class="middle">' +
4424 '<span class="tab_icon icon_small townicon_so"></span><span class="tab_label">' + getText("labels", "sea") + '</span>' +
4425 '</span></span></span></a></li>' +
4426 '<li><a class="submenu_link distance" href="#"><span class="left"><span class="right"><span class="middle">' +
4427 '<span class="tab_icon icon_small townicon_di"></span><span class="tab_label">' + getText("labels", "dst") + '</span>' +
4428 '</span></span></span></a></li>' +
4429 '<li><a class="submenu_link pierce" href="#"><span class="left"><span class="right"><span class="middle">' +
4430 '<span class="tab_icon icon_small townicon_sh"></span><span class="tab_label">' + getText("labels", "prc") + '</span>' +
4431 '</span></span></span></a></li>' +
4432 '<li><a class="submenu_link hack active" href="#"><span class="left"><span class="right"><span class="middle">' +
4433 '<span class="tab_icon icon_small townicon_lo"></span><span class="tab_label">' + getText("labels", "hck") + '</span>' +
4434 '</span></span></span></a></li>' +
4435 '</ul>' +
4436 // Content
4437 '<div id="dio_comparison" style="margin-bottom:5px; font-style:italic;"><div class="box_content hack"></div></div>';
4438
4439 Layout.wnd.Create(GPWindowMgr.TYPE_DIO_COMPARISON).setContent(content);
4440
4441 UnitComparison.addComparisonTable("hack");
4442 UnitComparison.addComparisonTable("pierce");
4443 UnitComparison.addComparisonTable("distance");
4444 UnitComparison.addComparisonTable("sea");
4445
4446 // Tooltips
4447 var labelArray = DM.getl10n("barracks"),
4448 labelAttack = DM.getl10n("context_menu", "titles").attack,
4449 labelDefense = DM.getl10n("place", "tabs")[0];
4450
4451 $('.tr_att').tooltip(labelAttack);
4452 $('.tr_def').tooltip(labelDefense + " (Ø)");
4453 $('.tr_def_sea').tooltip(labelDefense);
4454 $('.tr_spd').tooltip(labelArray.tooltips.speed);
4455 $('.tr_bty').tooltip(labelArray.tooltips.booty.title);
4456 $('.tr_bty_sea').tooltip(labelArray.tooltips.ship_transport.title);
4457 $('.tr_res').tooltip(labelArray.costs + " (" +
4458 labelArray.cost_details.wood + " + " +
4459 labelArray.cost_details.stone + " + " +
4460 labelArray.cost_details.iron + ")"
4461 );
4462 $('.tr_fav').tooltip(labelArray.costs + " (" + labelArray.cost_details.favor + ")");
4463 $('.tr_tim').tooltip(labelArray.cost_details.buildtime_barracks + " (s)");
4464 $('.tr_tim_sea').tooltip(labelArray.cost_details.buildtime_docks + " (s)");
4465
4466 UnitComparison.switchComparisonTables();
4467
4468 // Close button event - uncheck available units button
4469 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON).getJQCloseButton().get(0).onclick = function () {
4470 $('#dio_comparison_button').removeClass("checked");
4471 $('.ico_comparison').get(0).style.marginTop = "5px";
4472 };
4473 },
4474 closeWindow: function () {
4475 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON).close();
4476 },
4477 switchComparisonTables: function () {
4478 $('#dio_comparison_menu .hack, #dio_comparison_menu .pierce, #dio_comparison_menu .distance, #dio_comparison_menu .sea').click(function () {
4479 $('#dio_comparison .box_content').removeClass($('#dio_comparison .box_content').get(0).className.split(" ")[1]);
4480 //console.debug(this.className.split(" ")[1]);
4481 $('#dio_comparison .box_content').addClass(this.className.split(" ")[1]);
4482
4483 $('#dio_comparison_menu .active').removeClass("active");
4484 $(this).addClass("active");
4485 });
4486 },
4487
4488 tooltips: [], t: 0,
4489
4490 addComparisonTable: function (type) {
4491 var pos = {
4492 att: {hack: "36%", pierce: "27%", distance: "45.5%", sea: "72.5%"},
4493 def: {hack: "18%", pierce: "18%", distance: "18%", sea: "81.5%"}
4494 };
4495 var unitIMG = "https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png";
4496 var strArray = [
4497 "<td></td>",
4498 '<td><div class="compare_type_icon" style="background-position: 0% ' + pos.att[type] + ';"></div></td>',
4499 '<td><div class="compare_type_icon" style="background-position: 0% ' + pos.def[type] + ';"></div></td>',
4500 '<td><div class="compare_type_icon" style="background-position: 0% 63%;"></div></td>',
4501 (type !== "sea") ? '<td><div class="compare_type_icon booty"></div></td>' : '<td><div class="compare_type_icon" style="background-position: 0% 91%;"></div></td>',
4502 '<td><div class="compare_type_icon" style="background-position: 0% 54%;"></div></td>',
4503 '<td><div class="compare_type_icon favor"></div></td>',
4504 '<td><div class="compare_type_icon time"></div></td>'
4505 ];
4506
4507 for (var e in uw.GameData.units) {
4508 if (uw.GameData.units.hasOwnProperty(e)) {
4509 var valArray = [];
4510
4511 if (type === (uw.GameData.units[e].attack_type || "sea") && (e !== "militia")) {
4512 valArray.att = Math.round(uw.GameData.units[e].attack * 10 / uw.GameData.units[e].population) / 10;
4513 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;
4514 valArray.def = valArray.def || Math.round(uw.GameData.units[e].defense * 10 / uw.GameData.units[e].population) / 10;
4515 valArray.speed = uw.GameData.units[e].speed;
4516 valArray.booty = Math.round(((uw.GameData.units[e].booty) * 10) / uw.GameData.units[e].population) / 10;
4517 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;
4518 valArray.favor = Math.round((uw.GameData.units[e].favor * 10) / uw.GameData.units[e].population) / 10;
4519 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));
4520 valArray.time = Math.round(uw.GameData.units[e].build_time / uw.GameData.units[e].population);
4521
4522 // World without Artemis? -> grey griffin and boar
4523 valArray.heroStyle = "";
4524 valArray.heroStyleIMG = "";
4525
4526 if (!uw.Game.hasArtemis && ((e === "griffin") || (e === "calydonian_boar"))) {
4527 valArray.heroStyle = "color:black;opacity: 0.4;";
4528 valArray.heroStyleIMG = "filter: url(#GrayScale); -webkit-filter:grayscale(100%);";
4529 }
4530
4531 strArray[0] += '<td class="un' + (UnitComparison.t) + '"><span class="unit index_unit unit_icon40x40 ' + e + '" style="' + valArray.heroStyle + valArray.heroStyleIMG + '"></span></td>';
4532 strArray[1] += '<td class="bold" style="color:' + ((valArray.att > 19) ? 'green;' : ((valArray.att < 10 && valArray.att !== 0 ) ? 'red;' : 'black;')) + valArray.heroStyle + '">' + valArray.att + '</td>';
4533 strArray[2] += '<td class="bold" style="color:' + ((valArray.def > 19) ? 'green;' : ((valArray.def < 10 && valArray.def !== 0 ) ? 'red;' : 'black;')) + valArray.heroStyle + '">' + valArray.def + '</td>';
4534 strArray[3] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.speed + '</td>';
4535 strArray[4] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.booty + '</td>';
4536 strArray[5] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.res + '</td>';
4537 strArray[6] += '<td class="bold" style="color:' + ((valArray.favor > 0) ? 'rgb(0, 0, 214);' : 'black;') + valArray.heroStyle + ';">' + valArray.favor + '</td>';
4538 strArray[7] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.time + '</td>';
4539
4540 UnitComparison.tooltips[UnitComparison.t] = uw.GameData.units[e].name;
4541 UnitComparison.t++;
4542 }
4543 }
4544 }
4545
4546 $('<table class="hidden t_' + type + '" cellpadding="1px">' +
4547 '<tr>' + strArray[0] + '</tr>' +
4548 '<tr class="tr_att">' + strArray[1] + '</tr><tr class="tr_def' + (type == "sea" ? "_sea" : "") + '">' + strArray[2] + '</tr>' +
4549 '<tr class="tr_spd">' + strArray[3] + '</tr><tr class="tr_bty' + (type == "sea" ? "_sea" : "") + '">' + strArray[4] + '</tr>' +
4550 '<tr class="tr_res">' + strArray[5] + '</tr><tr class="tr_fav">' + strArray[6] + '</tr><tr class="tr_tim' + (type == "sea" ? "_sea" : "") + '">' + strArray[7] + '</tr>' +
4551 '</table>').appendTo('#dio_comparison .box_content');
4552
4553 for (var i = 0; i <= UnitComparison.t; i++) {
4554 $('.un' + i).tooltip(UnitComparison.tooltips[i]);
4555 }
4556 }
4557 };
4558
4559 /*******************************************************************************************************************************
4560 * Reports and Messages
4561 * ----------------------------------------------------------------------------------------------------------------------------
4562 * | â— Storage of the selected filter (only in German Grepolis yet)
4563 * ----------------------------------------------------------------------------------------------------------------------------
4564 *******************************************************************************************************************************/
4565
4566 var filter = "all";
4567
4568 function saveFilter() {
4569 $('#dd_filter_type_list .item-list div').each(function () {
4570 $(this).click(function () {
4571 filter = $(this).attr("name");
4572 });
4573 });
4574 /*
4575 var i = 0;
4576 $("#report_list a").each(function () {
4577 //console.log((i++) +" = " + $(this).attr('data-reportid'));
4578 });
4579 */
4580 }
4581
4582 function loadFilter() {
4583 if ($('#dd_filter_type_list .selected').attr("name") !== filter) {
4584 $('#dd_filter_type .caption').click();
4585 $('#dd_filter_type_list .item-list div[name=' + filter + ']').click();
4586 }
4587 }
4588
4589 function removeReports() {
4590 $("#report_list li:contains('spioniert')").each(function () {
4591 //$(this).remove();
4592 });
4593 }
4594
4595 var zut = 0;
4596 var messageArray = {};
4597
4598 function filterPlayer() {
4599 if (!$('#message_filter_list').get(0)) {
4600 $('<div id="message_filter_list" style="height:300px;overflow-y:scroll; width: 790px;"></div>').appendTo('#folder_container');
4601 $("#message_list").get(0).style.display = "none";
4602 }
4603 if (zut < parseInt($('.es_last_page').get(0).value, 10) - 1) {
4604 $('.es_page_input').get(0).value = zut++;
4605 $('.jump_button').click();
4606 $("#message_list li:contains('')").each(function () {
4607 $(this).appendTo('#message_filter_list');
4608 });
4609 } else {
4610 zut = 1;
4611 }
4612 }
4613
4614
4615 /*******************************************************************************************************************************
4616 * World Wonder Ranking - Change
4617 *******************************************************************************************************************************/
4618
4619 function getWorldWonderTypes() {
4620 $.ajax({
4621 type: "GET",
4622 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 +
4623 "%7D&_=" + uw.Game.server_time,
4624 success: function (text) {
4625 try {
4626 //console.log(JSON.parse(text));
4627 temp = JSON.parse(text).json.data.world_wonders;
4628 for (var t in temp) {
4629 if (temp.hasOwnProperty(t)) {
4630 wonderTypes[temp[t].wonder_type] = temp[t].full_name;
4631 }
4632 }
4633 temp = JSON.parse(text).json.data.buildable_wonders;
4634 for (var x in temp) {
4635 if (temp.hasOwnProperty(x)) {
4636 wonderTypes[x] = temp[x].name;
4637 }
4638 }
4639 saveValue(MID + "_wonderTypes", JSON.stringify(wonderTypes));
4640 } catch (error) {
4641 errorHandling(error, "getWorldWonderTypes");
4642 }
4643 }
4644 });
4645 }
4646
4647 function getWorldWonders() {
4648 $.ajax({
4649 type: "GET",
4650 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 +
4651 "%7D&_=" + uw.Game.server_time
4652 });
4653 }
4654
4655 var WorldWonderRanking = {
4656 activate: function () {
4657 if ($('#dio_wonder_ranking').get(0)) {
4658 $('#dio_wonder_ranking').remove();
4659 }
4660 $('<style id="dio_wonder_ranking" type="text/css"> .wonder_ranking { display: none; } </style>').appendTo('head');
4661 },
4662 deactivate: function () {
4663 if ($('#dio_wonder_ranking').get(0)) {
4664 $('#dio_wonder_ranking').remove();
4665 }
4666 $('<style id="dio_wonder_ranking" type="text/css"> .wonder_ranking { display: block; } </style>').appendTo('head');
4667 },
4668 change: function (html) {
4669 if ($('#ranking_inner tr', html)[0].children.length !== 1) { // world wonders exist?
4670 try {
4671 var ranking = {}, temp_ally, temp_ally_id, temp_ally_link;
4672
4673 // Save world wonder ranking into array
4674 $('#ranking_inner tr', html).each(function () {
4675 try {
4676 if (this.children[0].innerHTML) {
4677 temp_ally = this.children[1].children[0].innerHTML; // das hier
4678
4679 temp_ally_id = this.children[1].children[0].onclick.toString();
4680 temp_ally_id = temp_ally_id.substring(temp_ally_id.indexOf(",") + 1);
4681 temp_ally_id = temp_ally_id.substring(0, temp_ally_id.indexOf(")"));
4682
4683 temp_ally_link = this.children[1].innerHTML;
4684
4685 } else {
4686 //World wonder name
4687 var wonder_name = this.children[3].children[0].innerHTML;
4688
4689 for (var w in wonderTypes) {
4690 if (wonderTypes.hasOwnProperty(w)) {
4691 if (wonder_name == wonderTypes[w]) {
4692 var level = this.children[4].innerHTML, // world wonder level
4693 ww_data = JSON.parse(atob(this.children[3].children[0].href.split("#")[1])), wonder_link;
4694 //console.log(ww_data);
4695
4696 if (!ranking.hasOwnProperty(level)) {
4697 // add wonder types
4698 ranking[level] = {
4699 colossus_of_rhodes: {},
4700 great_pyramid_of_giza: {},
4701 hanging_gardens_of_babylon: {},
4702 lighthouse_of_alexandria: {},
4703 mausoleum_of_halicarnassus: {},
4704 statue_of_zeus_at_olympia: {},
4705 temple_of_artemis_at_ephesus: {}
4706 };
4707 }
4708
4709 if (!ranking[level][w].hasOwnProperty(temp_ally_id)) {
4710 ranking[level][w][temp_ally_id] = {}; // add alliance array
4711 }
4712 // island coordinates of the world wonder:
4713 ranking[level][w][temp_ally_id].ix = ww_data.ix;
4714 ranking[level][w][temp_ally_id].iy = ww_data.iy;
4715 ranking[level][w][temp_ally_id].sea = this.children[5].innerHTML; // world wonder sea
4716
4717 wonder_link = this.children[3].innerHTML;
4718 if (temp_ally.length > 15) {
4719 temp_ally = temp_ally.substring(0, 15) + '.';
4720 }
4721 wonder_link = wonder_link.substr(0, wonder_link.indexOf(">") + 1) + temp_ally + '</a>';
4722
4723 ranking[level][w][temp_ally_id].ww_link = wonder_link;
4724
4725 // other data of the world wonder
4726 ranking[level][w][temp_ally_id].ally_link = temp_ally_link;
4727 ranking[level][w][temp_ally_id].ally_name = temp_ally; // alliance name
4728 ranking[level][w][temp_ally_id].name = wonder_name; // world wonder name
4729
4730 // Save wonder coordinates for wonder icons on map
4731 if (!wonder.map[w]) {
4732 wonder.map[w] = {};
4733 }
4734 wonder.map[w][ww_data.ix + "_" + ww_data.iy] = level;
4735 saveValue(WID + "_wonder", JSON.stringify(wonder));
4736
4737 }
4738 }
4739 }
4740 }
4741 } catch (error) {
4742 errorHandling(error, "WorldWonderRanking.change(function)");
4743 }
4744 });
4745
4746 if ($('#ranking_table_wrapper').get(0)) {
4747 $('#ranking_fixed_table_header').get(0).innerHTML = '<tr>' +
4748 '<td style="width:10px">#</td>' +
4749 '<td>Colossus</td>' +
4750 '<td>Pyramid</td>' +
4751 '<td>Garden</td>' +
4752 '<td>Lighthouse</td>' +
4753 '<td>Mausoleum</td>' +
4754 '<td>Statue</td>' +
4755 '<td>Temple</td>' +
4756 '</tr>';
4757
4758 $('#ranking_fixed_table_header').css({
4759 tableLayout: 'fixed',
4760 width: '100%',
4761 //paddingLeft: '0px',
4762 paddingRight: '15px'
4763 });
4764
4765 var ranking_substr = '', z = 0;
4766 for (var level = 10; level >= 1; level--) {
4767 if (ranking.hasOwnProperty(level)) {
4768 var complete = "";
4769 if (level == 10) {
4770 complete = "background: rgba(255, 236, 108, 0.36);";
4771 }
4772
4773 // Alternate table background color
4774 if (z === 0) {
4775 ranking_substr += '<tr class="game_table_odd" style="' + complete + '"><td style="border-right: 1px solid #d0be97;">' + level + '</td>';
4776 z = 1;
4777 } else {
4778 ranking_substr += '<tr class="game_table_even" style="' + complete + '"><td style="border-right: 1px solid #d0be97;">' + level + '</td>';
4779 z = 0;
4780 }
4781 for (var w in ranking[level]) {
4782 if (ranking[level].hasOwnProperty(w)) {
4783 ranking_substr += '<td>';
4784
4785 for (var a in ranking[level][w]) {
4786 if (ranking[level][w].hasOwnProperty(a)) {
4787 ranking_substr += '<nobr>' + ranking[level][w][a].ww_link + '</nobr><br />'; // ww link
4788 }
4789 }
4790 ranking_substr += '</td>';
4791 }
4792 }
4793 ranking_substr += '</tr>';
4794 }
4795 }
4796
4797 var ranking_str = '<table id="ranking_endless_scroll" class="game_table" cellspacing="0"><tr>' +
4798 '<td style="width:10px;border-right: 1px solid #d0be97;"></td>' +
4799 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.colossus_of_rhodes + ';margin-left:26px"></div></td>' + // Colossus
4800 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.great_pyramid_of_giza + ';margin-left:19px"></div></td>' + // Pyramid
4801 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.hanging_gardens_of_babylon + ';margin-left:19px"></div></td>' + // Garden
4802 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.lighthouse_of_alexandria + ';margin-left:24px"></div></td>' + // Lighthouse
4803 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.mausoleum_of_halicarnassus + ';margin-left:25px"></div></td>' + // Mausoleum
4804 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.statue_of_zeus_at_olympia + ';margin-left:25px"></div></td>' + // Statue
4805 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.temple_of_artemis_at_ephesus + ';margin-left:22px"></div></td>' + // Temple
4806 '</tr>' + ranking_substr + '</table>';
4807
4808 $('#ranking_table_wrapper').get(0).innerHTML = ranking_str;
4809
4810 $('#ranking_endless_scroll .dio_wonder').css({
4811 width: "65px", height: "60px",
4812 backgroundSize: "auto 100%",
4813 backgroundPosition: "64px 0px"
4814 });
4815
4816 $('#ranking_endless_scroll').css({
4817 tableLayout: 'fixed',
4818 width: '100%',
4819 overflowY: 'auto',
4820 overflowX: 'hidden',
4821 fontSize: '0.7em',
4822 lineHeight: '2'
4823 });
4824 $('#ranking_endless_scroll tbody').css({
4825 verticalAlign: 'text-top'
4826 });
4827
4828 $('#ranking_table_wrapper img').css({
4829 width: "60px"
4830 });
4831 $('#ranking_table_wrapper').css({
4832 overflowY: 'scroll'
4833 });
4834 }
4835 } catch (error) {
4836 errorHandling(error, "WorldWonderRanking.change");
4837 }
4838 }
4839 if ($('.wonder_ranking').get(0)) {
4840 $('.wonder_ranking').get(0).style.display = "block";
4841 }
4842 }
4843 };
4844
4845 /*******************************************************************************************************************************
4846 * World Wonder
4847 * ----------------------------------------------------------------------------------------------------------------------------
4848 * | â— click adjustment
4849 * | â— Share calculation (= ratio of player points to alliance points)
4850 * | â— Resources calculation & counter (stores amount)
4851 * | â— Adds missing previous & next buttons on finished world wonders (better browsing through world wonders)
4852 * ----------------------------------------------------------------------------------------------------------------------------
4853 *******************************************************************************************************************************/
4854
4855 // getPointRatio: Default
4856 function getPointRatioFromAllianceProfile() {
4857 if (AID) {
4858 $.ajax({
4859 type: "GET",
4860 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 +
4861 '%2C%22nlreq_id%22%3A' + uw.Game.notification_last_requested_id + '%7D&_=' + uw.Game.server_time,
4862 success: function (text) {
4863 try {
4864 text = text.substr(text.indexOf("/li") + 14).substr(0, text.indexOf("\ "));
4865 var AP = parseInt(text, 10);
4866 wonder.ratio[AID] = 100 / AP * uw.Game.player_points;
4867 saveValue(WID + "_wonder", JSON.stringify(wonder));
4868 } catch (error) {
4869 errorHandling(error, "getPointRatioFromAllianceProfile");
4870 }
4871 }
4872 });
4873 } else {
4874 wonder.ratio[AID] = -1;
4875 saveValue(WID + "_wonder", JSON.stringify(wonder));
4876 }
4877 }
4878
4879 function getPointRatioFromAllianceRanking() {
4880 try {
4881 if (AID && $('.current_player .r_points').get(0)) {
4882 wonder.ratio[AID] = 100 / parseInt($('.current_player .r_points').get(0).innerHTML, 10) * uw.Game.player_points;
4883 saveValue(WID + "_wonder", JSON.stringify(wonder));
4884 }
4885 } catch (error) {
4886 errorHandling(error, "getPointRatioFromAllianceRaking");
4887 }
4888 }
4889
4890 function getPointRatioFromAllianceMembers() {
4891 try {
4892 var ally_points = 0;
4893 $('#ally_members_body tr').each(function () {
4894 ally_points += parseInt($(this).children().eq(2).text(), 10) || 0;
4895 });
4896 wonder.ratio[AID] = 100 / ally_points * uw.Game.player_points;
4897 saveValue(WID + "_wonder", JSON.stringify(wonder));
4898 } catch (error) {
4899 errorHandling(error, "getPointRatioFromAllianceMembers");
4900 }
4901 }
4902
4903 var WorldWonderCalculator = {
4904 activate: function () {
4905 // Style
4906 $('<style id="dio_wonder_calculator"> ' +
4907 '.wonder_controls { height:380px; } ' +
4908 '.wonder_controls .wonder_progress { margin: 0px auto 5px; } ' +
4909 '.wonder_controls .wonder_header { text-align:left; margin:10px -8px 12px 3px; }' +
4910 '.wonder_controls .build_wonder_icon { top:25px !important; }' +
4911 '.wonder_controls .wonder_progress_bar { top:54px; }' +
4912 '.wonder_controls .trade fieldset { float:right; } ' +
4913 '.wonder_controls .wonder_res_container { right:29px; } ' +
4914 '.wonder_controls .ww_ratio {position:relative; height:auto; } ' +
4915 '.wonder_controls fieldset.next_level_res { height:auto; } ' +
4916 '.wonder_controls .town-capacity-indicator { margin-top:0px; } ' +
4917
4918 '.wonder_controls .ww_ratio .progress { line-height:1; color:white; font-size:0.8em; } ' +
4919 '.wonder_controls .ww_perc { position:absolute; width:242px; text-align:center; } ' +
4920 '.wonder_controls .indicator3 { z-index:0; } ' +
4921 '.wonder_controls .indicator3.red { background-position:right -203px; height:10px; width:242px; } ' +
4922 '.wonder_controls .indicator3.green { background-position:right -355px; height:10px; width:242px; } ' +
4923 '.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; } ' +
4924 '.wonder_controls .town-capacity-indicator { margin-top:0px; } ' +
4925 '</style>').appendTo('head');
4926 },
4927 deactivate: function () {
4928 $('#dio_wonder_calculator').remove();
4929 }
4930 };
4931
4932 // TODO: Split function...
4933 function getResWW() {
4934 try {
4935 var wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_WONDERS);
4936
4937 for (var e in wndArray) {
4938 if (wndArray.hasOwnProperty(e)) {
4939 var wndID = "#gpwnd_" + wndArray[e].getID() + " ";
4940
4941 if ($(wndID + '.wonder_progress').get(0)) {
4942 var res = 0,
4943 ww_share = {total: {share: 0, sum: 0}, stage: {share: 0, sum: 0}},
4944 ww_type = $(wndID + '.finished_image_small').attr('src').split("/")[6].split("_")[0], // Which world wonder?
4945 res_stages = [2, 4, 6, 10, 16, 28, 48, 82, 140, 238], // Rohstoffmenge pro Rohstofftyp in 100.000 Einheiten
4946 stage = parseInt($(wndID + '.wonder_expansion_stage span').get(0).innerHTML.split("/")[0], 10) + 1, // Derzeitige Füllstufe
4947 speed = uw.Game.game_speed;
4948
4949 wonder.storage[AID] = wonder.storage[AID] || {};
4950
4951 wonder.storage[AID][ww_type] = wonder.storage[AID][ww_type] || {};
4952
4953 wonder.storage[AID][ww_type][stage] = wonder.storage[AID][ww_type][stage] || 0;
4954
4955 if (!$(wndID + '.ww_ratio').get(0)) {
4956 $('<fieldset class="ww_ratio"></fieldset>').appendTo(wndID + '.wonder_res_container .trade');
4957 $(wndID + '.wonder_header').prependTo(wndID + '.wonder_progress');
4958 $(wndID + '.wonder_res_container .send_res').insertBefore(wndID + '.wonder_res_container .next_level_res');
4959 }
4960
4961 for (var d in res_stages) {
4962 if (res_stages.hasOwnProperty(d)) {
4963 ww_share.total.sum += res_stages[d];
4964 }
4965 }
4966
4967 ww_share.total.sum *= speed * 300000;
4968
4969 ww_share.total.share = parseInt(wonder.ratio[AID] * (ww_share.total.sum / 100), 10);
4970
4971 ww_share.stage.sum = speed * res_stages[stage - 1] * 300000;
4972
4973 ww_share.stage.share = parseInt(wonder.ratio[AID] * (ww_share.stage.sum / 100), 10); // ( 3000 = 3 Rohstofftypen * 100000 Rohstoffe / 100 Prozent)
4974 setResWW(stage, ww_type, ww_share, wndID);
4975
4976
4977 $(wndID + '.wonder_res_container .send_resources_btn').click(function (e) {
4978 try {
4979 wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_wood input:text').get(0).value, 10);
4980 wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_stone input:text').get(0).value, 10);
4981 wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_iron input:text').get(0).value, 10);
4982
4983 setResWW(stage, ww_type, ww_share, wndID);
4984 saveValue(WID + "_wonder", JSON.stringify(wonder));
4985 } catch (error) {
4986 errorHandling(error, "getResWW_Click");
4987 }
4988 });
4989
4990 } else {
4991 $('<div class="prev_ww pos_Y"></div><div class="next_ww pos_Y"></div>').appendTo(wndID + '.wonder_controls');
4992
4993 $(wndID + '.wonder_finished').css({width: '100%'});
4994
4995 $(wndID + '.pos_Y').css({
4996 top: '-266px'
4997 });
4998 }
4999 }
5000 }
5001 } catch (error) {
5002 errorHandling(error, "getResWW");
5003 }
5004 }
5005
5006 function setResWW(stage, ww_type, ww_share, wndID) {
5007 try {
5008 var stage_width, total_width, res_total = 0, stage_color = "red", total_color = "red";
5009
5010 for (var z in wonder.storage[AID][ww_type]) {
5011 if (wonder.storage[AID][ww_type].hasOwnProperty(z)) {
5012 res_total += wonder.storage[AID][ww_type][z];
5013 }
5014 }
5015
5016 // Progressbar
5017 if (ww_share.stage.share > wonder.storage[AID][ww_type][stage]) {
5018 stage_width = (242 / ww_share.stage.share) * wonder.storage[AID][ww_type][stage];
5019 stage_color = "red";
5020 } else {
5021 stage_width = 242;
5022 stage_color = "green"
5023 }
5024 if (ww_share.total.share > res_total) {
5025 total_color = "red";
5026 total_width = (242 / ww_share.total.share) * res_total;
5027 } else {
5028 total_width = 242;
5029 total_color = "green"
5030 }
5031
5032 $(wndID + '.ww_ratio').get(0).innerHTML = "";
5033 $(wndID + '.ww_ratio').append(
5034 '<legend>' + getText("labels", "leg") + ' (<span style="color:#090">' + (Math.round(wonder.ratio[AID] * 100) / 100) + '%</span>):</legend>' +
5035 '<div class="town-capacity-indicator">' +
5036 '<div class="icon all_res"></div>' +
5037 '<div id="ww_town_capacity_stadium" class="tripple-progress-progressbar">' +
5038 '<div class="border_l"></div><div class="border_r"></div><div class="body"></div>' +
5039 '<div class="progress overloaded">' +
5040 '<div class="indicator3 ' + stage_color + '" style="width:' + stage_width + 'px"></div>' +
5041 '<span class="ww_perc">' + Math.round(wonder.storage[AID][ww_type][stage] / ww_share.stage.share * 100) + '%</span>' +
5042 '</div>' +
5043 '<div class="amounts">' + getText("labels", "stg") + ': <span class="curr">' + pointNumber(wonder.storage[AID][ww_type][stage]) + '</span> / ' +
5044 '<span class="max">' + pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) + '</span></div>' +
5045 '</div></div>' +
5046 '<div class="town-capacity-indicator">' +
5047 '<div class="icon all_res"></div>' +
5048 '<div id="ww_town_capacity_total" class="tripple-progress-progressbar">' +
5049 '<div class="border_l"></div><div class="border_r"></div><div class="body"></div>' +
5050 '<div class="progress overloaded">' +
5051 '<div class="indicator3 ' + total_color + '" style="width:' + total_width + 'px;"></div>' +
5052 '<span class="ww_perc">' + Math.round(res_total / ww_share.total.share * 100) + '%</span>' +
5053 '</div>' +
5054 '<div class="amounts">' + getText("labels", "tot") + ': <span class="curr">' + pointNumber(res_total) + '</span> / ' +
5055 '<span class="max">' + pointNumber((Math.round(ww_share.total.share / 1000) * 1000)) + '</span></div>' +
5056 '</div></div>');
5057
5058 $(wndID + '.ww_ratio').tooltip(
5059 "<table style='border-spacing:0px; text-align:right' cellpadding='5px'><tr>" +
5060 "<td align='right' style='border-right: 1px solid;border-bottom: 1px solid'></td>" +
5061 "<td style='border-right: 1px solid; border-bottom: 1px solid'><span class='bbcodes_player bold'>(" + (Math.round((wonder.ratio[AID]) * 100) / 100) + "%)</span></td>" +
5062 "<td style='border-bottom: 1px solid'><span class='bbcodes_ally bold'>(100%)</span></td></tr>" +
5063 "<tr><td class='bold' style='border-right:1px solid;text-align:center'>" + getText("labels", "stg") + " " + stage + "</td>" +
5064 "<td style='border-right: 1px solid'>" + pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) + "</td>" +
5065 "<td>" + pointNumber(Math.round(ww_share.stage.sum / 1000) * 1000) + "</td></tr>" +
5066 "<tr><td class='bold' style='border-right:1px solid;text-align:center'>" + getText("labels", "tot") + "</td>" +
5067 "<td style='border-right: 1px solid'>" + pointNumber(Math.round(ww_share.total.share / 1000) * 1000) + "</td>" +
5068 "<td>" + pointNumber(Math.round(ww_share.total.sum / 1000) * 1000) + "</td>" +
5069 "</tr></table>");
5070
5071 } catch (error) {
5072 errorHandling(error, "setResWW");
5073 }
5074 }
5075
5076 // Adds points to numbers
5077 function pointNumber(number) {
5078 var sep;
5079 if (LID === "de") {
5080 sep = ".";
5081 } else {
5082 sep = ",";
5083 }
5084
5085 number = number.toString();
5086 if (number.length > 3) {
5087 var mod = number.length % 3;
5088 var output = (mod > 0 ? (number.substring(0, mod)) : '');
5089
5090 for (var i = 0; i < Math.floor(number.length / 3); i++) {
5091 if ((mod == 0) && (i == 0)) {
5092 output += number.substring(mod + 3 * i, mod + 3 * i + 3);
5093 } else {
5094 output += sep + number.substring(mod + 3 * i, mod + 3 * i + 3);
5095 }
5096 }
5097 number = output;
5098 }
5099 return number;
5100 }
5101
5102 /*******************************************************************************************************************************
5103 * Farming Village Overview
5104 * ----------------------------------------------------------------------------------------------------------------------------
5105 * | â— Color change on possibility of city festivals
5106 * ----------------------------------------------------------------------------------------------------------------------------
5107 * *****************************************************************************************************************************/
5108
5109 function changeResColor() {
5110 var res, res_min, i = 0;
5111 $('#fto_town_list .fto_resource_count :last-child').reverseList().each(function () {
5112 if ($(this).parent().hasClass("stone")) {
5113 res_min = 18000;
5114 } else {
5115 res_min = 15000;
5116 }
5117 res = parseInt(this.innerHTML, 10);
5118 if ((res >= res_min) && !($(this).hasClass("town_storage_full"))) {
5119 this.style.color = '#0A0';
5120 }
5121 if (res < res_min) {
5122 this.style.color = '#000';
5123 }
5124 });
5125 }
5126
5127 /********************************************************************************************************************************
5128 * Conquest Info
5129 * -----------------------------------------------------------------------------------------------------------------------------
5130 * | â— Amount of supports und attacks in the conquest window
5131 * | â— Layout adjustment (for reasons of clarity)
5132 * | - TODO: conquest window of own cities
5133 * -----------------------------------------------------------------------------------------------------------------------------
5134 * ******************************************************************************************************************************/
5135
5136 function countMovements() {
5137 var sup = 0, att = 0;
5138 $('.tab_content #unit_movements .support').each(function () {
5139 sup++;
5140 });
5141 $('.tab_content #unit_movements .attack_land, .tab_content #unit_movements .attack_sea, .tab_content #unit_movements .attack_takeover').each(function () {
5142 att++;
5143 });
5144
5145 var str = "<div id='move_counter' style=''><div style='float:left;margin-right:5px;'></div>" +
5146 "<div class='movement def'></div>" +
5147 "<div class='movement' style='color:green;'> " + sup + "</div>" +
5148 "<div class='movement off'> </div>" +
5149 "<div style='color:red;'> " + att + "</div></div>" +
5150 "<hr class='move_hr'>";
5151
5152 if ($('.gpwindow_content .tab_content .bold').get(0)) {
5153 $('.gpwindow_content .tab_content .bold').append(str);
5154 } else {
5155 $('.gpwindow_content h4:eq(1)').append(str);
5156
5157 // TODO: set player link ?
5158 /*
5159 $('#unit_movements li div').each(function(){
5160
5161 //console.log(this.innerHTML);
5162 });
5163 */
5164 }
5165
5166 $('<style id="dio_conquest"> ' +
5167 '.move_hr { margin:7px 0px 0px 0px; background-color:#5F5242; height:2px; border:0px solid; } ' +
5168 // Smaller movements
5169 '#unit_movements { font-size: 0.80em; } ' +
5170 '#unit_movements .incoming { width:150px; height:45px; float:left; } ' +
5171 // Counter
5172 '#move_counter { position:relative; width:100px; margin-top:-16px; left: 40%; } ' +
5173 '#move_counter .movement { float:left; margin:0px 5px 0px 0px; height:18px; width:18px; position:relative; } ' +
5174 '#move_counter .def { background:url(https://gpall.innogamescdn.com/images/game/place/losts.png); background-position:0 -36px; } ' +
5175 '#move_counter .off { background:url(https://gpall.innogamescdn.com/images/game/place/losts.png); background-position:0 0px; }' +
5176 '</style>').appendTo("head");
5177
5178 /*
5179 $('#unit_movements div').each(function(){
5180 if($(this).attr('class') === "unit_movements_arrow"){
5181 // delete placeholder for arrow of outgoing movements (there are no outgoing movements)
5182 if(!this.style.background) { this.remove(); }
5183 } else {
5184 // realign texts
5185 $(this).css({
5186 margin: '3px',
5187 paddingLeft: '3px'
5188 });
5189 }
5190 });
5191 */
5192 }
5193
5194 /*******************************************************************************************************************************
5195 * Town window
5196 * ----------------------------------------------------------------------------------------------------------------------------
5197 * | â— TownTabHandler (trade, attack, support,...)
5198 * | â— Sent units box
5199 * | â— Short duration: Display of 30% troop speed improvement in attack/support tab
5200 * | â— Trade options:
5201 * | - Ressource marks on possibility of city festivals
5202 * | - Percentual Trade: Trade button
5203 * | - Recruiting Trade: Selection boxes (ressource ratio of unit type + share of the warehouse capacity of the target town)
5204 * ----------------------------------------------------------------------------------------------------------------------------
5205 *******************************************************************************************************************************/
5206 var arrival_interval = {};
5207 // TODO: Change both functions in MultipleWindowHandler()
5208 function TownTabHandler(action) {
5209 var wndArray, wndID, wndA;
5210 wndArray = Layout.wnd.getOpen(uw.Layout.wnd.TYPE_TOWN);
5211 //console.log(wndArray);
5212 for (var e in wndArray) {
5213 if (wndArray.hasOwnProperty(e)) {
5214 //console.log(wndArray[e].getHandler());
5215 wndA = wndArray[e].getAction();
5216 wndID = "#gpwnd_" + wndArray[e].getID() + " ";
5217 if (!$(wndID).get(0)) {
5218 wndID = "#gpwnd_" + (wndArray[e].getID() + 1) + " ";
5219 }
5220 //console.log(wndID);
5221 if (wndA === action) {
5222 switch (action) {
5223 case "trading":
5224 if ($(wndID + '#trade_tab').get(0)) {
5225 if (!$(wndID + '.rec_trade').get(0) && DATA.options.rec) {
5226 RecruitingTrade.add(wndID);
5227 }
5228 //console.log(DATA.options.per);
5229 if (!$(wndID + '.btn_trade').get(0) && DATA.options.per) {
5230 addPercentTrade(wndID, false);
5231 }
5232 }
5233 //addTradeMarks(wndID, 15, 18, 15, "red"); // town festival
5234 break;
5235 case "support":
5236 case "attack":
5237 //if(!arrival_interval[wndID]){
5238 if (DATA.options.way && !($('.js-casted-powers-viewport .unit_movement_boost').get(0) || $(wndID + '.short_duration').get(0))) {
5239 //if(arrival_interval[wndID]) console.log("add " + wndID);
5240 ShortDuration.add(wndID);
5241 }
5242 if (DATA.options.sen) {
5243 SentUnits.add(wndID, action);
5244 }
5245 //}
5246 break;
5247 case "rec_mark":
5248 //addTradeMarks(wndID, 15, 18, 15, "lime");
5249 break;
5250 }
5251 }
5252 }
5253 }
5254 }
5255
5256 function WWTradeHandler() {
5257 var wndArray, wndID, wndA;
5258 wndArray = uw.GPWindowMgr.getOpen(uw.GPWindowMgr.TYPE_WONDERS);
5259 for (var e in wndArray) {
5260 if (wndArray.hasOwnProperty(e)) {
5261 wndID = "#gpwnd_" + wndArray[e].getID() + " ";
5262 if (DATA.options.per && !($(wndID + '.btn_trade').get(0) || $(wndID + '.next_building_phase').get(0) || $(wndID + '#ww_time_progressbar').get(0))) {
5263 addPercentTrade(wndID, true);
5264 }
5265 }
5266 }
5267 }
5268
5269 /*******************************************************************************************************************************
5270 * â— Sent units box
5271 *******************************************************************************************************************************/
5272 var SentUnits = {
5273 activate: function () {
5274 $.Observer(GameEvents.command.send_unit).subscribe('DIO_SEND_UNITS', function (e, data) {
5275 for (var z in data.params) {
5276 if (data.params.hasOwnProperty(z) && (data.sending_type !== "")) {
5277 if (uw.GameData.units[z]) {
5278 sentUnitsArray[data.sending_type][z] = (sentUnitsArray[data.sending_type][z] == undefined ? 0 : sentUnitsArray[data.sending_type][z]);
5279 sentUnitsArray[data.sending_type][z] += data.params[z];
5280 }
5281 }
5282 }
5283 //SentUnits.update(data.sending_type); ????
5284 });
5285 },
5286 deactivate: function () {
5287 $.Observer(GameEvents.command.send_unit).unsubscribe('DIO_SEND_UNITS');
5288 },
5289 add: function (wndID, action) {
5290 if (!$(wndID + '.sent_units_box').get(0)) {
5291 $('<div class="game_inner_box sent_units_box ' + action + '"><div class="game_border ">' +
5292 '<div class="game_border_top"></div><div class="game_border_bottom"></div><div class="game_border_left"></div><div class="game_border_right"></div>' +
5293 '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
5294 '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
5295 '<div class="game_header bold">' +
5296 '<div class="icon_sent townicon_' + (action == "attack" ? "lo" : "ld") + '"></div><span>' + getText("labels", "lab") + ' (' + (action == "attack" ? "OFF" : "DEF") + ')</span>' +
5297 '</div>' +
5298 '<div class="troops"><div class="units_list"></div><hr style="width: 172px;border: 1px solid rgb(185, 142, 93);margin: 3px 0px 2px -1px;">' +
5299 '<div id="btn_sent_units_reset" class="button_new">' +
5300 '<div class="left"></div>' +
5301 '<div class="right"></div>' +
5302 '<div class="caption js-caption">' + getText("buttons", "res") + '<div class="effect js-effect"></div></div>' +
5303 '</div>' +
5304 '</div></div>').appendTo(wndID + '.attack_support_window');
5305
5306 SentUnits.update(action);
5307
5308 $(wndID + '.icon_sent').css({
5309 height: '20px',
5310 marginTop: '-2px',
5311 width: '20px',
5312 backgroundPositionY: '-26px',
5313 paddingLeft: '0px',
5314 marginLeft: '0px'
5315 });
5316
5317 $(wndID + '.sent_units_box').css({
5318 position: 'absolute',
5319 right: '0px',
5320 bottom: '16px',
5321 width: '192px'
5322 });
5323 $(wndID + '.troops').css({padding: '6px 0px 6px 6px'});
5324
5325 $(wndID + '#btn_sent_units_reset').click(function () {
5326 // Overwrite old array
5327 sentUnitsArray[action] = {};
5328
5329 SentUnits.update(action);
5330 });
5331 }
5332 },
5333 update: function (action) {
5334 try {
5335 // Remove old unit list
5336 $('.sent_units_box.' + action + ' .units_list').each(function () {
5337 this.innerHTML = "";
5338 });
5339 // Add new unit list
5340 for (var x in sentUnitsArray[action]) {
5341 if (sentUnitsArray[action].hasOwnProperty(x)) {
5342 if ((sentUnitsArray[action][x] || 0) > 0) {
5343 $('.sent_units_box.' + action + ' .units_list').each(function () {
5344 $(this).append('<div class="unit_icon25x25 ' + x +
5345 (sentUnitsArray[action][x] >= 1000 ? (sentUnitsArray[action][x] >= 10000 ? " five_digit_number" : " four_digit_number") : "") + '">' +
5346 '<span class="count text_shadow">' + sentUnitsArray[action][x] + '</span>' +
5347 '</div>');
5348 });
5349 }
5350 }
5351 }
5352 saveValue(WID + "_sentUnits", JSON.stringify(sentUnitsArray));
5353 } catch (error) {
5354 errorHandling(error, "updateSentUnitsBox");
5355 }
5356 }
5357 };
5358
5359 /*******************************************************************************************************************************
5360 * â— Short duration
5361 *******************************************************************************************************************************/
5362
5363 // TODO: Calculator implementieren
5364 var DurationCalculator = {
5365 activate: function () {
5366 var speedBoosterSprite = "https://diotools.de/images/game/speed_booster.png";
5367
5368 $('<style id="dio_duration_calculator_style">' +
5369 '.dio_speed_booster { border:1px solid #724B08; border-spacing: 0px;} ' +
5370 '.dio_speed_booster td { border:0; padding:2px; } ' +
5371 '.dio_speed_booster .checkbox_new { margin: 4px 0px 1px 3px; } ' +
5372 '.dio_speed_booster .odd { background: url("https://gpall.innogamescdn.com/images/game/border/brown.png") repeat scroll 0% 0% transparent; } ' +
5373 '.dio_speed_booster .even { background: url("https://gpall.innogamescdn.com/images/game/border/odd.png") repeat scroll 0% 0% transparent; } ' +
5374 '.booster_icon { width:20px; height:20px; background-image:url(' + speedBoosterSprite + ');} ' +
5375 '.booster_icon.improved_speed { background-position:0 0; } ' +
5376 '.booster_icon.cartography { background-position:-20px 0; } ' +
5377 '.booster_icon.meteorology { background-position:-40px 0; } ' +
5378 '.booster_icon.lighthouse { background-position:-60px 0; } ' +
5379 '.booster_icon.set_sail { background-position:-80px 0; } ' +
5380 '.booster_icon.atalanta { background-position:-100px 0; } ' +
5381 '</style>').appendTo('head');
5382
5383 $('<table class="dio_speed_booster"><tr>' +
5384 '<td class="odd"><div class="booster_icon improved_speed"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5385 '<td class="even"><div class="booster_icon cartography"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5386 '<td class="odd"><div class="booster_icon meteorology"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5387 '<td class="even"><div class="booster_icon lighthouse"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5388 '<td class="odd"><div class="booster_icon set_sail"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5389 '<td class="even"><div class="booster_icon atalanta"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5390 '</tr></table>').appendTo(wndID + ".duration_container");
5391 },
5392 deactivate: function () {
5393 $('#dio_duration_calculator_style').remove();
5394 },
5395 add: function (wndID, data) {
5396
5397 }
5398 };
5399
5400
5401 var ShortDuration = {
5402 activate: function () {
5403
5404 $('<style id="dio_short_duration_style">' +
5405 '.attack_support_window .tab_type_support .duration_container { top:0px !important; } ' +
5406 //'.attack_support_window .tab_type_attack .duration_container { width:auto; top:10px; } ' +
5407
5408 '.attack_support_window .dio_duration { border-spacing:0px; margin-bottom:2px; text-align:right; } ' +
5409
5410 '.attack_support_window .way_duration, '+
5411 '.attack_support_window .arrival_time { padding:0px 0px 0px 0px; background:none; } ' +
5412
5413 '.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; } ' +
5414 '.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; } ' +
5415 '.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); } ' +
5416
5417 '.attack_support_window .max_booty { padding:0px 0px 0px 30px; margin:3px 4px 4px 4px; width:auto; } ' +
5418 '.attack_support_window .fight_bonus.morale { margin-top:2px; } ' +
5419
5420 '.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; } ' +
5421 '.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; } ' +
5422
5423 '</style>').appendTo('head');
5424
5425 },
5426 deactivate: function () {
5427 $("#dio_short_duration_style").remove();
5428 },
5429 add: function (wndID) {
5430 //console.log($(wndID + ".duration_container").get(0));
5431 try {
5432 var tooltip = (LANG.hasOwnProperty(LID) ? getText("labels", "improved_movement") : "") + " (+30% " + DM.getl10n("barracks", "tooltips").speed.trim() + ")";
5433
5434 $('<table class="dio_duration">' +
5435 '<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>' +
5436 '<tr class="short_duration_row" style="color:darkgreen">' +
5437 '<td> ╚> </td><td><span class="short_duration">~0:00:00</span></td>' +
5438 '<td> ╚></td><td><span class="short_arrival">~00:00:00</span></td>' +
5439 '<td class="short_icon"></td><td></td></tr>' +
5440 '</table>').prependTo(wndID + ".duration_container");
5441
5442
5443
5444 $(wndID + ".nightbonus").appendTo(wndID + ".dio_night");
5445 $(wndID + '.way_duration').appendTo(wndID + ".dio_way");
5446 $(wndID + ".arrival_time").appendTo(wndID + ".dio_arrival");
5447
5448
5449 // Tooltip
5450 $(wndID + '.short_duration_row').tooltip(tooltip);
5451
5452 // Detection of changes
5453 ShortDuration.change(wndID);
5454 // $(wndID + '.way_duration').bind('DOMSubtreeModified', function(e) { console.log(e); }); // Alternative
5455
5456 } catch (error) {
5457 errorHandling(error, "addShortDuration");
5458 }
5459 },
5460 change: function (wndID) {
5461 var duration = new MutationObserver(function (mutations) {
5462 mutations.forEach(function (mutation) {
5463 if (mutation.addedNodes[0]) {
5464 //console.debug(mutation);
5465 ShortDuration.calculate(wndID);
5466 }
5467 });
5468 });
5469 if ($(wndID + '.way_duration').get(0)) {
5470 duration.observe($(wndID + '.way_duration').get(0), {
5471 attributes: false,
5472 childList: true,
5473 characterData: false
5474 });
5475 }
5476 },
5477 //$('<style> .duration_container { display: block !important } </style>').appendTo("head");
5478 calculate: function (wndID) {
5479 //console.log(wndID);
5480 //console.log($(wndID + '.duration_container .way_duration').get(0));
5481 try {
5482 var setup_time = 900 / Game.game_speed,
5483 duration_time = $(wndID + '.duration_container .way_duration').get(0).innerHTML.replace("~", "").split(":"),
5484 // TODO: hier tritt manchmal Fehler auf TypeError: Cannot read property "innerHTML" of undefined at calcShortDuration (<anonymous>:3073:86)
5485 arrival_time,
5486 h, m, s,
5487 atalanta_factor = 0;
5488
5489 var hasCartography = ITowns.getTown(Game.townId).getResearches().get("cartography");
5490 var hasMeteorology = ITowns.getTown(Game.townId).getResearches().get("meteorology");
5491 var hasSetSail = ITowns.getTown(Game.townId).getResearches().get("set_sail");
5492
5493 var hasLighthouse = ITowns.getTown(Game.townId).buildings().get("lighthouse");
5494
5495 // Atalanta aktiviert?
5496 if ($(wndID + '.unit_container.heroes_pickup .atalanta').get(0)) {
5497 if ($(wndID + '.cbx_include_hero').hasClass("checked")) {
5498 // Beschleunigung hängt vom Level ab, Level 1 = 11%, Level 20 = 30%
5499 var atalanta_level = MM.getCollections().PlayerHero[0].models[1].get("level");
5500
5501 atalanta_factor = (atalanta_level + 10) / 100;
5502 }
5503 }
5504
5505 // Sekunden, Minuten und Stunden zusammenrechnen (-> in Sekunden)
5506 duration_time = ((parseInt(duration_time[0], 10) * 60 + parseInt(duration_time[1], 10)) * 60 + parseInt(duration_time[2], 10));
5507
5508 // Verkürzte Laufzeit berechnen
5509 duration_time = ((duration_time - setup_time) * (1 + atalanta_factor)) / (1 + 0.3 + atalanta_factor) + setup_time;
5510
5511
5512 h = Math.floor(duration_time / 3600);
5513 m = Math.floor((duration_time - h * 3600) / 60);
5514 s = Math.floor(duration_time - h * 3600 - m * 60);
5515
5516 if (m < 10) {
5517 m = "0" + m;
5518 }
5519 if (s < 10) {
5520 s = "0" + s;
5521 }
5522
5523 $(wndID + '.short_duration').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
5524
5525 // Ankunftszeit errechnen
5526 arrival_time = Math.round((Timestamp.server() + Game.server_gmt_offset)) + duration_time;
5527
5528 h = Math.floor(arrival_time / 3600);
5529 m = Math.floor((arrival_time - h * 3600) / 60);
5530 s = Math.floor(arrival_time - h * 3600 - m * 60);
5531
5532 h %= 24;
5533
5534 if (m < 10) {
5535 m = "0" + m;
5536 }
5537 if (s < 10) {
5538 s = "0" + s;
5539 }
5540
5541 $(wndID + '.short_arrival').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
5542
5543 clearInterval(arrival_interval[wndID]);
5544
5545 arrival_interval[wndID] = setInterval(function () {
5546 arrival_time += 1;
5547
5548 h = Math.floor(arrival_time / 3600);
5549 m = Math.floor((arrival_time - h * 3600) / 60);
5550 s = Math.floor(arrival_time - h * 3600 - m * 60);
5551
5552 h %= 24;
5553
5554 if (m < 10) {
5555 m = "0" + m;
5556 }
5557 if (s < 10) {
5558 s = "0" + s;
5559 }
5560
5561 if ($(wndID + '.short_arrival').get(0)) {
5562 $(wndID + '.short_arrival').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
5563 } else {
5564 clearInterval(arrival_interval[wndID]);
5565 }
5566 }, 1000);
5567
5568 } catch (error) {
5569 errorHandling(error, "ShortDuration.calculate");
5570 }
5571 }
5572 };
5573
5574 /*******************************************************************************************************************************
5575 * â— Dropdown menu
5576 *******************************************************************************************************************************/
5577
5578 // TODO: Umstellen!
5579 // Preload images for drop down arrow buttons
5580 var drop_over = new Image();
5581 drop_over.src = "http://s7.directupload.net/images/140107/hna95u8a.png";
5582 var drop_out = new Image();
5583 drop_out.src = "http://s14.directupload.net/images/140107/ppsz5mxk.png";
5584
5585 function changeDropDownButton() {
5586 $('<style id="dio_style_arrow" type="text/css">' +
5587 '#dd_filter_type .arrow, .select_rec_unit .arrow {' +
5588 'width: 18px !important; height: 17px !important; background: url("http://s14.directupload.net/images/140107/ppsz5mxk.png") no-repeat 0px -1px !important;' +
5589 'position: absolute; top: 2px !important; right: 3px; } ' +
5590 '</style>').appendTo('head');
5591
5592 }
5593
5594 /*******************************************************************************************************************************
5595 * â— Recruiting Trade
5596 * *****************************************************************************************************************************/
5597 var trade_count = 0, unit = "FS", percent = "0.0"; // Recruiting Trade
5598
5599 // TODO: Funktion umformen, Style anpassen!
5600 var RecruitingTrade = {
5601 activate: function () {
5602 $('<style id="dio_style_recruiting_trade" type="text/css">' +
5603 '#dio_recruiting_trade .option_s { filter:grayscale(100%); -webkit-filter:grayscale(100%); margin:0px; cursor:pointer; } ' +
5604 '#dio_recruiting_trade .option_s:hover { filter:unset !important; -webkit-filter:unset !important; } ' +
5605 '#dio_recruiting_trade .select_rec_unit .sel { filter:sepia(100%); -webkit-filter:sepia(100%); } ' +
5606
5607 '#dio_recruiting_trade .option {color:#000; background:#FFEEC7; } ' +
5608 '#dio_recruiting_trade .option:hover {color:#fff; background:#328BF1; } ' +
5609
5610 '#dio_recruiting_trade { position:absolute; left:30px; top:70px; } ' +
5611 '#dio_recruiting_trade .select_rec_unit { position:absolute; top:20px; width:84px; display:none; } ' +
5612 '#dio_recruiting_trade .select_rec_perc { position:absolute; top:20px; width:50px; display:none; left:50px; } ' +
5613
5614 '#dio_recruiting_trade .open { display:block !important; } '+
5615
5616 '#dio_recruiting_trade .item-list { max-height:unset; } ' +
5617
5618 '#dio_recruiting_trade .arrow { width:18px; height:18px; background:url(' + drop_out.src + ') no-repeat -1px -1px; position:absolute; } ' +
5619
5620 '#trade_tab .content { height:320px; } ' +
5621
5622 '#dio_recruiting_trade .rec_count { position:absolute; top:25px; } ' +
5623
5624 '#dio_recruiting_trade .drop_rec_unit { position:absolute; display:block; width:50px; overflow:visible; } ' +
5625 '#dio_recruiting_trade .drop_rec_perc { position:absolute; display:block; width:55px; left:49px; color:#000; } ' +
5626
5627 '</style>').appendTo('head');
5628 },
5629 deactivate: function () {
5630 $('#dio_style_recruiting_trade').remove();
5631 },
5632 add: function (wndID) {
5633 var max_amount;
5634
5635 $('<div id="dio_recruiting_trade" class="rec_trade">' +
5636 // DropDown-Button for unit
5637 '<div class="drop_rec_unit dropdown default">' +
5638 '<div class="border-left"></div>' +
5639 '<div class="border-right"></div>' +
5640 '<div class="caption" name="' + unit + '">' + unit + '</div>' +
5641 '<div class="arrow"></div>' +
5642 '</div>' +
5643 '<div class="drop_rec_perc dropdown default">' +
5644 // DropDown-Button for ratio
5645 '<div class="border-left"></div>' +
5646 '<div class="border-right"></div>' +
5647 '<div class="caption" name="' + percent + '">' + Math.round(percent * 100) + '%</div>' +
5648 '<div class="arrow"></div>' +
5649 '</div><span class="rec_count">(' + trade_count + ')</span></div>').appendTo(wndID + ".content");
5650
5651 // Select boxes for unit and ratio
5652 $('<div class="select_rec_unit dropdown-list default active">' +
5653 '<div class="item-list">' +
5654 '<div class="option_s unit index_unit unit_icon40x40 attack_ship" name="FS"></div>' +
5655 '<div class="option_s unit index_unit unit_icon40x40 bireme" name="BI"></div>' +
5656 '<div class="option_s unit index_unit unit_icon40x40 sword" name="SK"></div>' +
5657 '<div class="option_s unit index_unit unit_icon40x40 slinger" name="SL"></div>' +
5658 '<div class="option_s unit index_unit unit_icon40x40 archer" name="BS"></div>' +
5659 '<div class="option_s unit index_unit unit_icon40x40 hoplite" name="HO"></div>' +
5660 '<div class="option_s unit index_unit unit_icon40x40 rider" name="RE"></div>' +
5661 '<div class="option_s unit index_unit unit_icon40x40 chariot" name="SW"></div>' +
5662 '</div></div>').appendTo(wndID + ".rec_trade");
5663 $('<div class="select_rec_perc dropdown-list default inactive">' +
5664 '<div class="item-list">' +
5665 '<div class="option sel" name="0.0"> 0%</div>' +
5666 '<div class="option" name="0.05"> 5%</div>' +
5667 '<div class="option" name="0.1">10%</div>' +
5668 '<div class="option" name="0.16666">17%</div>' +
5669 '<div class="option" name="0.2">20%</div>' +
5670 '<div class="option" name="0.25">25%</div>' +
5671 '<div class="option" name="0.33">33%</div>' +
5672 '<div class="option" name="0.5">50%</div>' +
5673 '</div></div>').appendTo(wndID + ".rec_trade");
5674
5675 $(wndID + ".rec_trade [name='" + unit + "']").toggleClass("sel");
5676
5677 // click events of the drop menu
5678 $(wndID + ' .select_rec_unit .option_s').each(function () {
5679 $(this).click(function (e) {
5680 $(".select_rec_unit .sel").toggleClass("sel");
5681 $("." + this.className.split(" ")[4]).toggleClass("sel");
5682
5683 unit = $(this).attr("name");
5684 $('.drop_rec_unit .caption').attr("name", unit);
5685 $('.drop_rec_unit .caption').each(function () {
5686 this.innerHTML = unit;
5687 });
5688 $($(this).parent().parent().get(0)).removeClass("open");
5689 $('.drop_rec_unit .caption').change();
5690 });
5691 });
5692 $(wndID + ' .select_rec_perc .option').each(function () {
5693 $(this).click(function (e) {
5694 $(this).parent().find(".sel").toggleClass("sel");
5695 $(this).toggleClass("sel");
5696
5697 percent = $(this).attr("name");
5698 $('.drop_rec_perc .caption').attr("name", percent);
5699 $('.drop_rec_perc .caption').each(function () {
5700 this.innerHTML = Math.round(percent * 100) + "%";
5701 });
5702 $($(this).parent().parent().get(0)).removeClass("open")
5703 $('.drop_rec_perc .caption').change();
5704 });
5705 });
5706
5707 // show & hide drop menus on click
5708 $(wndID + '.drop_rec_perc').click(function (e) {
5709
5710 if (!$($(e.target)[0].parentNode.parentNode.childNodes[4]).hasClass("open")) {
5711 $($(e.target)[0].parentNode.parentNode.childNodes[4]).addClass("open");
5712 $($(e.target)[0].parentNode.parentNode.childNodes[3]).removeClass("open");
5713 } else {
5714 $($(e.target)[0].parentNode.parentNode.childNodes[4]).removeClass("open");
5715 }
5716 });
5717 $(wndID + '.drop_rec_unit').click(function (e) {
5718
5719 if (!$($(e.target)[0].parentNode.parentNode.childNodes[3]).hasClass("open")) {
5720 $($(e.target)[0].parentNode.parentNode.childNodes[3]).addClass("open");
5721 $($(e.target)[0].parentNode.parentNode.childNodes[4]).removeClass("open");
5722 } else {
5723 $($(e.target)[0].parentNode.parentNode.childNodes[3]).removeClass("open");
5724 }
5725 });
5726
5727 $(wndID).click(function (e) {
5728 var clicked = $(e.target), element = $('#' + this.id + ' .dropdown-list.open').get(0);
5729 if ((clicked[0].parentNode.className.split(" ")[1] !== "dropdown") && element) {
5730 $(element).removeClass("open");
5731 }
5732 });
5733
5734 // hover arrow change
5735 $(wndID + '.dropdown').hover(function (e) {
5736 $(e.target)[0].parentNode.childNodes[3].style.background = "url('" + drop_over.src + "') no-repeat -1px -1px";
5737 }, function (e) {
5738 $(e.target)[0].parentNode.childNodes[3].style.background = "url('" + drop_out.src + "') no-repeat -1px -1px";
5739 });
5740
5741 $(wndID + ".drop_rec_unit .caption").attr("name", unit);
5742 $(wndID + ".drop_rec_perc .caption").attr("name", percent);
5743
5744 $(wndID + '.drop_rec_unit').tooltip(getText("labels", "rat"));
5745 $(wndID + '.drop_rec_perc').tooltip(getText("labels", "shr"));
5746
5747 var ratio = {
5748 NO: {w: 0, s: 0, i: 0},
5749 FS: {w: 1, s: 0.2308, i: 0.6154},
5750 BI: {w: 1, s: 0.8750, i: 0.2250},
5751 SL: {w: 0.55, s: 1, i: 0.4},
5752 RE: {w: 0.6666, s: 0.3333, i: 1},
5753 SK: {w: 1, s: 0, i: 0.8947},
5754 HO: {w: 0, s: 0.5, i: 1},
5755 BS: {w: 1, s: 0, i: 0.6250},
5756 SW: {w: 0.4545, s: 1, i: 0.7273}
5757 };
5758
5759
5760 if ($('#town_capacity_wood .max').get(0)) {
5761 max_amount = parseInt($('#town_capacity_wood .max').get(0).innerHTML, 10);
5762 } else {
5763 max_amount = 25500;
5764 }
5765
5766 $(wndID + '.caption').change(function (e) {
5767 //console.log($(this).attr('name') + ", " + unit + "; " + percent);
5768 if (!(($(this).attr('name') === unit) || ($(this).attr('name') === percent))) {
5769 //trade_count = 0;
5770 $('.rec_count').get(0).innerHTML = "(" + trade_count + ")";
5771 }
5772
5773 var tmp = $(this).attr('name');
5774
5775 if ($(this).parent().attr('class').split(" ")[0] === "drop_rec_unit") {
5776 unit = tmp;
5777 } else {
5778 percent = tmp;
5779 }
5780 var max = (max_amount - 100) / 1000;
5781 addTradeMarks(max * ratio[unit].w, max * ratio[unit].s, max * ratio[unit].i, "lime");
5782
5783 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)
5784 var rArray = uw.ITowns.getTown(uw.Game.townId).getCurrentResources();
5785 var tradeCapacity = uw.ITowns.getTown(uw.Game.townId).getAvailableTradeCapacity();
5786
5787 var wood = ratio[unit].w * part;
5788 var stone = ratio[unit].s * part;
5789 var iron = ratio[unit].i * part;
5790
5791 if ((wood > rArray.wood) || (stone > rArray.stone) || (iron > rArray.iron) || ( (wood + stone + iron) > tradeCapacity)) {
5792 wood = stone = iron = 0;
5793 $('.drop_rec_perc .caption').css({color: '#f00'});
5794 //$('.' + e.target.parentNode.parentNode.className + ' .select_rec_perc .sel').css({color:'#f00'});
5795 //$('.select_rec_perc .sel').css({color:'#f00'});
5796 } else {
5797 $('.' + e.target.parentNode.parentNode.className + ' .drop_rec_perc .caption').css({color: '#000'});
5798 }
5799 $("#trade_type_wood [type='text']").select().val(wood).blur();
5800 $("#trade_type_stone [type='text']").select().val(stone).blur();
5801 $("#trade_type_iron [type='text']").select().val(iron).blur();
5802 });
5803
5804 $('#trade_button').click(function () {
5805 trade_count++;
5806 $('.rec_count').get(0).innerHTML = "(" + trade_count + ")";
5807
5808 });
5809
5810 $(wndID + '.drop_rec_perc .caption').change();
5811 }
5812 };
5813
5814 /*******************************************************************************************************************************
5815 * â— Ressources marks
5816 *******************************************************************************************************************************/
5817 function addTradeMarks(woodmark, stonemark, ironmark, color) {
5818 var max_amount, limit, wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_TOWN), wndID;
5819 for (var e in wndArray) {
5820 if (wndArray.hasOwnProperty(e)) {
5821 wndID = "#gpwnd_" + wndArray[e].getID() + " ";
5822 if ($(wndID + '.town-capacity-indicator').get(0)) {
5823
5824 max_amount = $(wndID + '.amounts .max').get(0).innerHTML;
5825
5826 $('#trade_tab .c_' + color).each(function () {
5827 this.remove();
5828 });
5829 $('#trade_tab .progress').each(function () {
5830 if ($("p", this).length < 3) {
5831 if ($(this).parent().get(0).id != "big_progressbar") {
5832 limit = 1000 * (242 / parseInt(max_amount, 10));
5833
5834 switch ($(this).parent().get(0).id.split("_")[2]) {
5835 case "wood":
5836 limit = limit * woodmark;
5837 break;
5838 case "stone":
5839 limit = limit * stonemark;
5840 break;
5841 case "iron":
5842 limit = limit * ironmark;
5843 break;
5844 }
5845 $('<p class="c_' + color + '"style="position:absolute;left: ' + limit + 'px; background:' + color + ';width:2px;height:100%;margin:0px"></p>').appendTo(this);
5846 }
5847 }
5848 });
5849 }
5850 }
5851 }
5852 }
5853
5854 /*******************************************************************************************************************************
5855 * â— Percentual Trade
5856 *******************************************************************************************************************************/
5857 var rest_count = 0;
5858
5859 function addPercentTrade(wndID, ww) {
5860
5861 var a = "";
5862 var content = wndID + ".content";
5863 if (ww) {
5864 a = "ww_";
5865 content = wndID + '.trade .send_res';
5866 }
5867 $('<div class="btn btn_trade"><a class="button" href="#">' +
5868 '<span class="left"><span class="right">' +
5869 '<span class="middle mid">' +
5870 '<span class="img_trade"></span></span></span></span>' +
5871 '<span style="clear:both;"></span>' +
5872 '</a></div>').prependTo(content);
5873
5874 $(wndID + '.btn_trade').tooltip(getText("labels", "per"));
5875
5876 setPercentTrade(wndID, ww);
5877
5878 // Style
5879 $(wndID + '.btn').css({width: '20px', overflow: 'visible', position: 'absolute', display: 'block'});
5880
5881 if (!ww) {
5882 $(wndID + '.content').css({height: '320px'});
5883 }
5884
5885 if (ww) {
5886 $(wndID + '.btn_trade').css({left: '678px', top: '154px'});
5887 } else {
5888 $(wndID + '.btn_trade').css({left: '336px', top: '135px'});
5889 }
5890
5891 $(wndID + '.mid').css({minWidth: '26px'});
5892
5893 $(wndID + '.img_trade').css({
5894 width: '27px',
5895 height: '27px',
5896 top: '-3px',
5897 float: 'left',
5898 position: 'relative',
5899 background: 'url("http://666kb.com/i/cjq6d72qk521ig1zz.png") no-repeat'
5900 });
5901
5902 }
5903
5904 var res = {};
5905
5906 function setPercentTrade(wndID, ww) {
5907 var a = ww ? "ww_" : "", own_town = $(wndID + '.town_info').get(0) ? true : false;
5908
5909 $(wndID + '.btn_trade').toggleClick(function () {
5910 res.wood = {};
5911 res.stone = {};
5912 res.iron = {};
5913 res.sum = {};
5914
5915 res.sum.amount = 0;
5916 // Set amount of resources to 0
5917 setAmount(true, a, wndID);
5918 // Total amount of resources // TODO: ITowns.getTown(Game.townId).getCurrentResources(); ?
5919 for (var e in res) {
5920 if (res.hasOwnProperty(e) && e != "sum") {
5921 res[e].rest = false;
5922 res[e].amount = parseInt($('.ui_resources_bar .' + e + ' .amount').get(0).innerHTML, 10);
5923 res.sum.amount += res[e].amount;
5924 }
5925 }
5926 // Percentage of total resources
5927 res.wood.percent = 100 / res.sum.amount * res.wood.amount;
5928 res.stone.percent = 100 / res.sum.amount * res.stone.amount;
5929 res.iron.percent = 100 / res.sum.amount * res.iron.amount;
5930
5931 // Total trading capacity
5932 res.sum.cur = parseInt($(wndID + '#' + a + 'big_progressbar .caption .curr').get(0).innerHTML, 10);
5933
5934 // Amount of resources on the percentage of trading capacity (%)
5935 res.wood.part = parseInt(res.sum.cur / 100 * res.wood.percent, 10);
5936 res.stone.part = parseInt(res.sum.cur / 100 * res.stone.percent, 10);
5937 res.iron.part = parseInt(res.sum.cur / 100 * res.iron.percent, 10);
5938
5939 // Get rest warehouse capacity of each resource type
5940 for (var f in res) {
5941 if (res.hasOwnProperty(f) && f != "sum") {
5942 if (!ww && own_town) { // Own town
5943 var curr = parseInt($(wndID + '#town_capacity_' + f + ' .amounts .curr').get(0).innerHTML.replace('+', '').trim(), 10) || 0,
5944 curr2 = parseInt($(wndID + '#town_capacity_' + f + ' .amounts .curr2').get(0).innerHTML.replace('+', '').trim(), 10) || 0,
5945 max = parseInt($(wndID + '#town_capacity_' + f + ' .amounts .max').get(0).innerHTML.replace('+', '').trim(), 10) || 0;
5946
5947 res[f].cur = curr + curr2;
5948 res[f].max = max - res[f].cur;
5949
5950 if (res[f].max < 0) {
5951 res[f].max = 0;
5952 }
5953
5954 } else { // World wonder or foreign town
5955 res[f].max = 30000;
5956 }
5957 }
5958 }
5959 // Rest of fraction (0-2 units) add to stone amount
5960 res.stone.part += res.sum.cur - (res.wood.part + res.stone.part + res.iron.part);
5961
5962 res.sum.rest = 0;
5963 rest_count = 0;
5964 calcRestAmount();
5965 setAmount(false, a, wndID);
5966 }, function () {
5967 setAmount(true, a, wndID);
5968 });
5969 }
5970
5971 function calcRestAmount() {
5972 // Subdivide rest
5973 if (res.sum.rest > 0) {
5974 for (var e in res) {
5975 if (res.hasOwnProperty(e) && e != "sum" && res[e].rest != true) {
5976 res[e].part += res.sum.rest / (3 - rest_count);
5977 }
5978 }
5979 res.sum.rest = 0;
5980 }
5981 // Calculate new rest
5982 for (var f in res) {
5983 if (res.hasOwnProperty(f) && f != "sum" && res[f].rest != true) {
5984 if (res[f].max <= res[f].part) {
5985 res[f].rest = true;
5986 res.sum.rest += res[f].part - res[f].max;
5987 rest_count += 1;
5988 res[f].part = res[f].max;
5989 }
5990 }
5991 }
5992 // Recursion
5993 if (res.sum.rest > 0 && rest_count < 3) {
5994 calcRestAmount();
5995 }
5996 }
5997
5998 function setAmount(clear, a, wndID) {
5999 for (var e in res) {
6000 if (res.hasOwnProperty(e) && e != "sum") {
6001 if (clear == true) {
6002 res[e].part = 0;
6003 }
6004 $(wndID + "#" + a + "trade_type_" + e + ' [type="text"]').select().val(res[e].part).blur();
6005 }
6006 }
6007 }
6008
6009 /********************************************************************************************************************************
6010 * Unit strength (blunt/sharp/distance) and Transport Capacity
6011 * ----------------------------------------------------------------------------------------------------------------------------
6012 * | â— Unit strength: Menu
6013 * | - Switching of def/off display with buttons
6014 * | - Possible Selection of certain unit types
6015 * | â— Unit strength: Conquest
6016 * | â— Unit strength: Barracks
6017 * | â— Transport capacity: Menu
6018 * | - Switching of transporter speed (+/- big transporter)
6019 * ----------------------------------------------------------------------------------------------------------------------------
6020 * ******************************************************************************************************************************/
6021
6022 var def = true, blunt = 0, sharp = 0, dist = 0, shipsize = false;
6023
6024 var UnitStrength = {
6025 // Calculate defensive strength
6026 calcDef: function (units) {
6027 var e;
6028 blunt = sharp = dist = 0;
6029 for (e in units) {
6030 if (units.hasOwnProperty(e)) {
6031 blunt += units[e] * uw.GameData.units[e].def_hack;
6032 sharp += units[e] * uw.GameData.units[e].def_pierce;
6033 dist += units[e] * uw.GameData.units[e].def_distance;
6034 }
6035 }
6036 },
6037 // Calculate offensive strength
6038 calcOff: function (units, selectedUnits) {
6039 var e;
6040 blunt = sharp = dist = 0;
6041 for (e in selectedUnits) {
6042 if (selectedUnits.hasOwnProperty(e)) {
6043 var attack = (units[e] || 0) * uw.GameData.units[e].attack;
6044 switch (uw.GameData.units[e].attack_type) {
6045 case 'hack':
6046 blunt += attack;
6047 break;
6048 case 'pierce':
6049 sharp += attack;
6050 break;
6051 case 'distance':
6052 dist += attack;
6053 break;
6054 }
6055 }
6056 }
6057 },
6058 /*******************************************************************************************************************************
6059 * â— Unit strength: Unit menu
6060 *******************************************************************************************************************************/
6061 Menu: {
6062 activate: function () {
6063 $('<div id="strength" class="cont def"><hr>' +
6064 '<span class="bold text_shadow cont_left strength_font">' +
6065 '<table style="margin:0px;">' +
6066 '<tr><td><div class="ico units_info_sprite img_hack"></td><td id="blunt">0</td></tr>' +
6067 '<tr><td><div class="ico units_info_sprite img_pierce"></td><td id="sharp">0</td></tr>' +
6068 '<tr><td><div class="ico units_info_sprite img_dist"></td><td id="dist">0</td></tr>' +
6069 '</table>' +
6070 '</span>' +
6071 '<div class="cont_right">' +
6072 '<img id="def_button" class="active img" src="https://gpall.innogamescdn.com/images/game/unit_overview/support.png">' +
6073 '<img id="off_button" class="img" src="https://gpall.innogamescdn.com/images/game/unit_overview/attack.png">' +
6074 '</div></div>').appendTo('.units_land .content');
6075
6076 // Style
6077 $('<style id="dio_strength_style">' +
6078 '#strength.def #off_button, #strength.off #def_button { filter:url(#Sepia); -webkit-filter:sepia(1); }' +
6079 '#strength.off #off_button, #strength.def #def_button { filter:none; -webkit-filter:none; } ' +
6080
6081 '#strength.off .img_hack { background-position:0% 36%;} ' +
6082 '#strength.def .img_hack { background-position:0% 0%;} ' +
6083 '#strength.off .img_pierce { background-position:0% 27%;} ' +
6084 '#strength.def .img_pierce { background-position:0% 9%;} ' +
6085 '#strength.off .img_dist { background-position:0% 45%;} ' +
6086 '#strength.def .img_dist { background-position:0% 18%;} ' +
6087
6088 '#strength .strength_font { font-size: 0.8em; } ' +
6089 '#strength.off .strength_font { color:#edb;} ' +
6090 '#strength.def .strength_font { color:#fc6;} ' +
6091
6092 '#strength .ico { height:20px; width:20px; } ' +
6093 '#strength .units_info_sprite { background:url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png); background-size:100%; } ' +
6094
6095 '#strength .img_pierce { background-position:0px -20px; } ' +
6096 '#strength .img_dist { background-position:0px -40px; } ' +
6097 '#strength hr { margin:0px; background-color:#5F5242; height:2px; border:0px solid; } ' +
6098 '#strength .cont_left { width:65%; display:table-cell; } ' +
6099
6100 '#strength.cont { background:url(https://gpall.innogamescdn.com/images/game/layout/layout_units_nav_border.png); } ' +
6101
6102 '#strength .cont_right { width:30%; display:table-cell; vertical-align:middle; } ' +
6103 '#strength .img { float:right; background:none; margin:2px 8px 2px 0px; } ' +
6104
6105 '</style>').appendTo("head");
6106
6107 // Button events
6108 $('.units_land .units_wrapper, .btn_gods_spells .checked').click(function () {
6109 setTimeout(function () {
6110 UnitStrength.Menu.update();
6111 }, 100);
6112 });
6113
6114 $('#off_button').click(function () {
6115 $('#strength').addClass('off').removeClass('def');
6116
6117 def = false;
6118 UnitStrength.Menu.update();
6119 });
6120 $('#def_button').click(function () {
6121 $('#strength').addClass('def').removeClass('off');
6122
6123 def = true;
6124 UnitStrength.Menu.update();
6125 });
6126 $('#def_button, #off_button').hover(function () {
6127 $(this).css('cursor', 'pointer');
6128 });
6129
6130 UnitStrength.Menu.update();
6131 },
6132 deactivate: function () {
6133 $('#strength').remove();
6134 $('#dio_strength_style').remove();
6135 },
6136 update: function () {
6137 var unitsIn = uw.ITowns.getTown(uw.Game.townId).units(), units = UnitStrength.Menu.getSelected();
6138
6139 // Calculation
6140 if (def === true) {
6141 UnitStrength.calcDef(units);
6142 } else {
6143 UnitStrength.calcOff(unitsIn, units);
6144 }
6145 $('#blunt').get(0).innerHTML = blunt;
6146 $('#sharp').get(0).innerHTML = sharp;
6147 $('#dist').get(0).innerHTML = dist;
6148 },
6149 getSelected: function () {
6150 var units = [];
6151 if ($(".units_land .units_wrapper .selected").length > 0) {
6152 $(".units_land .units_wrapper .selected").each(function () {
6153 units[this.className.split(" ")[1]] = this.children[0].innerHTML;
6154 });
6155 } else {
6156 $(".units_land .units_wrapper .unit").each(function () {
6157 units[this.className.split(" ")[1]] = this.children[0].innerHTML;
6158 });
6159 }
6160 return units;
6161 }
6162 },
6163 /*******************************************************************************************************************************
6164 * â— Unit strength: Conquest
6165 *******************************************************************************************************************************/
6166 Conquest: {
6167 add: function () {
6168 var units = [], str;
6169
6170 // units of the siege
6171 $('#conqueror_units_in_town .unit').each(function () {
6172 str = $(this).attr("class").split(" ")[4];
6173 if (!uw.GameData.units[str].is_naval) {
6174 units[str] = parseInt(this.children[0].innerHTML, 10);
6175 //console.log($(this).attr("class").split(" ")[4]);
6176 }
6177 });
6178 // calculation
6179 UnitStrength.calcDef(units);
6180
6181 $('<div id="strength_eo" class="game_border" style="width:90px; margin: 20px; align:center;">' +
6182 '<div class="game_border_top"></div><div class="game_border_bottom"></div>' +
6183 '<div class="game_border_left"></div><div class="game_border_right"></div>' +
6184 '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
6185 '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
6186 '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">' +
6187 '<tr><td width="1%"><div class="ico units_info_sprite img_hack"></div></td><td id="bl" align="center" width="100%">0</td></tr>' +
6188 '<tr><td><div class="ico units_info_sprite img_pierce"></div></td><td id="sh" align="center">0</td></tr>' +
6189 '<tr><td><div class="ico units_info_sprite img_dist"></div></td><td id="di" align="center">0</td></tr>' +
6190 '</table></span>' +
6191 '</div>').appendTo('#conqueror_units_in_town');
6192
6193 $('#strength_eo').tooltip('Gesamteinheitenstärke der Belagerungstruppen');
6194
6195 // Veröffentlichung-Button-Text
6196 $('#conqueror_units_in_town .publish_conquest_public_id_wrap').css({
6197 marginLeft: '130px'
6198 });
6199
6200 $('#strength_eo .ico').css({
6201 height: '20px',
6202 width: '20px'
6203 });
6204 $('#strength_eo .units_info_sprite').css({
6205 background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
6206 backgroundSize: '100%'
6207 });
6208 $('#strength_eo .img_pierce').css({backgroundPosition: '0% 9%'});
6209 $('#strength_eo .img_dist').css({backgroundPosition: '0% 18%'});
6210
6211
6212 $('#bl').get(0).innerHTML = blunt;
6213 $('#sh').get(0).innerHTML = sharp;
6214 $('#di').get(0).innerHTML = dist;
6215 }
6216 },
6217 /*******************************************************************************************************************************
6218 * â— Unit strength: Barracks
6219 *******************************************************************************************************************************/
6220 Barracks: {
6221 add: function () {
6222 if (!$('#strength_baracks').get(0)) {
6223 var units = [], pop = 0;
6224
6225 // whole units of the town
6226 $('#units .unit_order_total').each(function () {
6227 units[$(this).parent().parent().attr("id")] = this.innerHTML;
6228 });
6229 // calculation
6230 UnitStrength.calcDef(units);
6231
6232 // population space of the units
6233 for (var e in units) {
6234 if (units.hasOwnProperty(e)) {
6235 pop += units[e] * uw.GameData.units[e].population;
6236 }
6237 }
6238 $('<div id="strength_baracks" class="game_border" style="float:right; width:70px; align:center;">' +
6239 '<div class="game_border_top"></div><div class="game_border_bottom"></div>' +
6240 '<div class="game_border_left"></div><div class="game_border_right"></div>' +
6241 '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
6242 '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
6243 '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">' +
6244 '<tr><td width="1%"><div class="ico units_info_sprite img_hack"></div></td><td id="b" align="center" width="100%">0</td></tr>' +
6245 '<tr><td><div class="ico units_info_sprite img_pierce"></div></td><td id="s" align="center">0</td></tr>' +
6246 '<tr><td><div class="ico units_info_sprite img_dist"></div></td><td id="d" align="center">0</td></tr>' +
6247 '</table></span>' +
6248 '</div>').appendTo('.ui-dialog #units');
6249
6250 $('<div id="pop_baracks" class="game_border" style="float:right; width:60px; align:center;">' +
6251 '<div class="game_border_top"></div><div class="game_border_bottom"></div>' +
6252 '<div class="game_border_left"></div><div class="game_border_right"></div>' +
6253 '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
6254 '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
6255 '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">' +
6256 '<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>' +
6257 '</table></span>' +
6258 '</div>').appendTo('.ui-dialog #units');
6259
6260 $('.ui-dialog #units .ico').css({
6261 height: '20px',
6262 width: '20px'
6263 });
6264 $('.ui-dialog #units .units_info_sprite').css({
6265 background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
6266 backgroundSize: '100%'
6267 });
6268 $('.ui-dialog #units .img_pierce').css({backgroundPosition: '0% 9%'});
6269 $('.ui-dialog #units .img_dist').css({backgroundPosition: '0% 18%'});
6270
6271 //$('#pop_baracks').tooltip('Bevölkerungszahl aller Landeinheiten der Stadt');
6272 //$('#strength_baracks').tooltip('Gesamteinheitenstärke stadteigener Truppen');
6273
6274 $('#b').get(0).innerHTML = blunt;
6275 $('#s').get(0).innerHTML = sharp;
6276 $('#d').get(0).innerHTML = dist;
6277 $('#p').get(0).innerHTML = pop;
6278 }
6279 }
6280 }
6281 };
6282
6283 /*******************************************************************************************************************************
6284 * â— Transporter capacity
6285 *******************************************************************************************************************************/
6286 var TransportCapacity = {
6287 activate: function () {
6288 // transporter display
6289 $('<div id="transporter" class="cont" style="height:25px;">' +
6290 '<table style=" margin:0px;"><tr align="center" >' +
6291 '<td><img id="ship_img" class="ico" src="http://s7.directupload.net/images/140724/4pvfuch8.png"></td>' +
6292 '<td><span id="ship" class="bold text_shadow" style="color:#FFCC66;font-size: 10px;line-height: 2.1;"></span></td>' +
6293 '</tr></table>' +
6294 '</div>').appendTo('.units_naval .content');
6295
6296 $('#transporter.cont').css({
6297 background: 'url(https://gpall.innogamescdn.com/images/game/layout/layout_units_nav_border.png)'
6298 });
6299
6300 $('#transporter').hover(function () {
6301 $(this).css('cursor', 'pointer');
6302 });
6303 $('#transporter').toggleClick(
6304 function () {
6305 $('#ship_img').get(0).src = "http://s1.directupload.net/images/140724/b5xl8nmj.png";
6306 shipsize = !shipsize;
6307 TransportCapacity.update();
6308 },
6309 function () {
6310 $('#ship_img').get(0).src = "http://s7.directupload.net/images/140724/4pvfuch8.png";
6311 shipsize = !shipsize;
6312 TransportCapacity.update();
6313 }
6314 );
6315 TransportCapacity.update();
6316 },
6317 deactivate: function () {
6318 $('#transporter').remove();
6319 },
6320 update: function () {
6321 var bigTransp = 0, smallTransp = 0, pop = 0, ship = 0, unit, berth, units = [];
6322 // Ship space (available)
6323 smallTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().small_transporter, 10);
6324 if (isNaN(smallTransp)) smallTransp = 0;
6325 if (shipsize) {
6326 bigTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().big_transporter, 10);
6327 if (isNaN(bigTransp)) bigTransp = 0;
6328 }
6329
6330 // Checking: Research berth
6331 berth = 0;
6332 if (uw.ITowns.getTown(uw.Game.townId).researches().hasBerth()) {
6333 berth = GameData.research_bonus.berth;
6334 }
6335 ship = bigTransp * (GameData.units.big_transporter.capacity + berth) + smallTransp * (GameData.units.small_transporter.capacity + berth);
6336
6337 units = uw.ITowns.getTown(uw.Game.townId).units();
6338
6339 // Ship space (required)
6340 for (var e in units) {
6341 if (units.hasOwnProperty(e)) {
6342 if (uw.GameData.units[e]) { // without Heroes
6343 if (!(uw.GameData.units[e].is_naval || uw.GameData.units[e].flying)) {
6344 pop += units[e] * uw.GameData.units[e].population;
6345 }
6346 }
6347 }
6348 }
6349 $('#ship').get(0).innerHTML = pop + "/" + ship;
6350 }
6351 };
6352
6353
6354 /*******************************************************************************************************************************
6355 * Simulator
6356 * ----------------------------------------------------------------------------------------------------------------------------
6357 * | â— Layout adjustment
6358 * | â— Permanent display of the extended modifier box
6359 * | â— Unit strength for entered units (without modificator influence yet)
6360 * ----------------------------------------------------------------------------------------------------------------------------
6361 *******************************************************************************************************************************/
6362 var Simulator = {
6363 activate: function () {
6364 $('<style id="dio_simulator_style" type="text/css">' +
6365
6366 '#place_simulator { overflow: hidden !important} ' +
6367 '#place_simulator .game_body { height: 417px !important} ' +
6368
6369 '#place_simulator_form h4 { display:none; } '+
6370
6371 '#place_simulator .place_simulator_table { margin: 0px !important } '+
6372
6373 '#place_simulator_form .place_sim_wrap_mods { margin-bottom: 2px; } '+
6374
6375 // Bonus container
6376 '.place_sim_bonuses_heroes { position:absolute; right:3px; top:27px; width: 272px;} ' +
6377 '.place_sim_bonuses_heroes .place_sim_showhide { display:none; } ' + // Hide modifier box button
6378
6379
6380 //'.place_sim_wrap_mods {position: relative; right: -17px !important} '+
6381 '.place_sim_wrap_mods .place_simulator_table :eq(1) { width: 300px;} ' + ////////////// genauer!
6382 '.place_sim_wrap_mods > .place_simulator_table { width: 272px;} ' + ////////////// genauer!
6383
6384 // Wall losses
6385 '.place_sim_wrap_mods tr:last-child { display:none; } ' +
6386
6387 // Extended modifier box
6388 //'@-webkit-keyframes MODBOX { 0% { opacity: 0; } 100% { opacity: 1; } } '+
6389 //'@keyframes MODBOX { 0% { opacity: 0; } 100% { opacity: 1; } } '+
6390
6391 '.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} ' +
6392 '.place_sim_wrap_mods_extended table tr td:eq(0) { width: 18px !important } ' +
6393 '.place_sim_wrap_mods_extended td { border:0px; } ' +
6394 '.place_sim_wrap_mods_extended tr td:first-child { border-left:0px; width:19px; padding-left:0px; } ' +
6395 '.place_sim_wrap_mods_extended .place_simulator_table { margin:0px; border-collapse:separate; border:1px solid #724B08; table-layout:fixed; width:100% } ' +
6396
6397 '.place_simulator_table .place_image { display:block; width: 20px; height:20px; background-size:100%; margin:auto; } ' +
6398
6399 '.place_simulator_table .place_image.pa_commander { background: url(https://diotools.de/images/game/advisors/advisors_22.png); background-position: 0px 44px; } ' +
6400 '.place_simulator_table .place_image.pa_captain { background: url(https://diotools.de/images/game/advisors/advisors_22.png); background-position: 0px 88px; } ' +
6401 '.place_simulator_table .place_image.pa_priest { background: url(https://diotools.de/images/game/advisors/advisors_22.png); background-position: 0px 66px; } ' +
6402
6403 '.place_simulator_table .place_image.is_night { background-position: 0px -40px; } ' +
6404 '.place_simulator_table .place_image.research_ram { background-position: 0px -300px; } ' +
6405 '.place_simulator_table .place_image.research_phalanx { background-position: 0px -280px; }' +
6406 '.place_simulator_table .place_image.research_divine_selection { background-position: 0 -600px; }' +
6407
6408 '.place_sim_wrap_mods_extended .place_cross { height:16px; background:none; } ' +
6409 '.place_sim_wrap_mods_extended .place_checkbox_field { display:table-cell; width:13px; height:13px; } ' +
6410
6411 '.place_sim_wrap_mods_extended tr:last-child { display:none;} ' +
6412
6413 '.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} ' +
6414
6415 '.place_sim_wrap_mods_extended .game_border>div { display:none; } ' +
6416 '.place_sim_wrap_mods_extended .game_border { margin:0px; } ' +
6417
6418 '.place_sim_wrap_mods_extended .game_border { height: 139px; overflow-y: auto; overflow-x: hidden; }' + // Größe der Modfikatorbox begrenzen
6419
6420 '#place_simulator .window_inner_curtain { display: none !important } ' + // Hintergrund entfernen bei offener Modifikatorbox
6421
6422 // Unit container
6423 '#simulator_body .unit_container { height: 50px !important; width: 50px !important; margin: 0px 3px 0px 1px !important} ' +
6424 '.place_simulator_odd, .place_simulator_even { text-align: center !important} ' +
6425 '.place_insert_field { margin: 0px !important} ' +
6426
6427 '#place_sim_ground_units { position:absolute; bottom: 35px;} ' +
6428
6429 // Sea unit box
6430 '#place_sim_naval_units { position: absolute; } ' +
6431 '#place_sim_naval_units tbody tr:last-child { height:auto !important; }' +
6432
6433 // Land unit box
6434 '#place_sim_wrap_units { position: absolute !important; bottom: 35px !important} ' +
6435
6436 '#simulator_body>h4 { position:absolute;bottom:188px;} ' +
6437
6438 // Select boxes
6439 '.place_sim_select_gods_wrap { position:absolute; bottom:182px; } ' +
6440
6441 '.place_sim_select_gods_wrap .place_sim_select_gods { width: 150px; } ' +
6442 '.place_sim_select_gods_wrap select { max-width: 120px; } ' +
6443
6444 '.place_sim_select_gods_wrap .place_symbol, .place_sim_select_strategies .place_symbol { margin: 1px 2px 0px 5px !important} ' +
6445 '.place_sim_insert_units .place_symbol { filter: hue-rotate(330deg); -webkit-filter: hue-rotate(330deg);} ' +
6446 '.place_attack { float: left !important} ' +
6447
6448 // Hero box
6449 '.place_sim_heroes_container { position: absolute; right: 0px; z-index: 1; } ' +
6450 '.place_sim_hero_container { width: 45px !important; height: 25px !important} ' +
6451
6452 '#place_simulator .place_sim_bonuses_heroes h4:nth-of-type(2) { display:none; }' + // Heroes title
6453
6454 // - Hero container
6455 '.place_sim_hero_choose, .place_sim_hero_unit_container { height: 26px !important; width: 30px !important} ' +
6456 '#hero_defense_icon, #hero_attack_icon { height: 25px !important; width: 25px !important; margin: 0px !important} ' +
6457 '#hero_defense_dd, #hero_attack_dd { height: 25px !important; width: 25px !important; margin: 1px !important} ' +
6458 '.place_sim_hero_attack, .place_sim_hero_defense { margin-left: 3px !important} ' +
6459 '#hero_attack_text, #hero_defense_text { font-size: 11px !important; bottom: 0px !important} ' +
6460 '.place_sim_heroes_container .plus { left: 2px; top: 2px !important} ' +
6461
6462 '.place_sim_heroes_container .button_new.square { left: 2px !important; } ' +
6463
6464
6465 // - Hero spinner
6466 '.place_sim_heroes_container .spinner { height: 25px !important; width: 40px !important } ' +
6467 '.place_sim_heroes_container td:nth-child(0) { height: 30px !important} ' +
6468 '.place_sim_heroes_container .spinner { height: 24px !important; position:absolute !important; width:12px !important; left:29px !important; '+
6469 'background:url(https://gpall.innogamescdn.com/images/game/border/odd.png) repeat !important; border: 1px solid rgb(107, 107, 107) !important; } ' +
6470 '.place_sim_heroes_container .spinner .button_down, .place_sim_heroes_container .spinner .button_up { bottom: 2px !important; cursor: pointer !important} ' +
6471 '.place_sim_heroes_container .spinner .border_l, .place_sim_heroes_container .spinner .border_r, .place_sim_heroes_container .spinner .body { display:none; } '+
6472
6473 // Quack
6474 '#q_place_sim_lost_res { display: none; } ' +
6475 '</style>').appendTo('head');
6476
6477 if($('#place_simulator').get(0)) {
6478 Simulator.change();
6479 }
6480
6481 SimulatorStrength.activate();
6482
6483 },
6484 deactivate: function () {
6485 $('#dio_simulator_style').remove();
6486 if($('#simu_table').get(0)) {
6487 $('#simu_table').remove();
6488
6489 // Hero box
6490 if ($('.place_sim_heroes_container').get(0)) {
6491 $('.hero_unit').each(function () {
6492 $(this).addClass('unit_icon40x40').removeClass('unit_icon25x25');
6493 });
6494
6495 // Hero spinner
6496 $('.place_sim_heroes_container .spinner').each(function () {
6497 $(this).addClass('place_sim_hero_spinner');
6498 });
6499 }
6500 }
6501
6502 SimulatorStrength.deactivate();
6503 },
6504 change: function () {
6505 // TODO: Durch CSS ersetzen...
6506
6507 // Wall loss
6508 $('.place_sim_wrap_mods tr:eq(1) td:eq(5)').html('<span id="building_place_def_losses_wall_level" class="place_losses bold"></span>');
6509
6510 // Extended modificator box
6511 $('.place_sim_wrap_mods_extended .power').each(function () {
6512 $(this).removeClass("power_icon45x45").addClass("power_icon16x16");
6513 });
6514 $('.place_sim_wrap_mods_extended td:nth-child(even)').each(function () {
6515 $(this).addClass("left_border place_simulator_odd");
6516 });
6517 $('.place_sim_wrap_mods_extended td:nth-child(odd)').each(function () {
6518 $(this).addClass("left_border place_simulator_even");
6519 });
6520
6521 // Border entfernen
6522 $('.place_sim_wrap_mods_extend td:first-child').each(function () {
6523 $(this).removeClass("left_border");
6524 });
6525
6526 // -> Update percentage each time
6527 $('.place_checkbox_field').click(function () {
6528 FightSimulator.closeModsExtended(); //$('.place_sim_bonuses_more_confirm').get(0).click();
6529 });
6530
6531 // Hero world ?
6532 if (uw.Game.hasArtemis) {
6533 $('.place_sim_wrap_mods_extend tr').each(function () {
6534 this.children[1].style.borderLeft = "none";
6535 this.children[0].remove();
6536 });
6537 }
6538
6539 // Hero box
6540 if ($('.place_sim_heroes_container').get(0)) {
6541 $('.hero_unit').each(function () {
6542 $(this).removeClass('unit_icon40x40').addClass('unit_icon25x25');
6543 });
6544
6545 // Hero spinner
6546 $('.place_sim_heroes_container .spinner').each(function () {
6547 $(this).removeClass('place_sim_hero_spinner');
6548 });
6549 }
6550
6551 setStrengthSimulator();
6552 }
6553 };
6554
6555 function afterSimulation() {
6556 var lossArray = {att: {res: 0, fav: 0, pop: 0}, def: {res: 0, fav: 0, pop: 0}},
6557 wall_level = parseInt($('.place_sim_wrap_mods .place_insert_field[name="sim[mods][def][wall_level]"]').val(), 10),
6558 wall_damage = parseInt($('#building_place_def_losses_wall_level').get(0).innerHTML, 10),
6559 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];
6560
6561 // Calculate unit losses
6562 $('#place_sim_ground_units .place_losses, #place_sim_naval_units .place_losses').each(function () {
6563 var loss = parseInt(this.innerHTML, 10) || 0;
6564 //console.log(this.innerHTML);
6565 if (loss > 0) {
6566 var unit = this.id.substring(26);
6567 var side = this.id.split("_")[2]; // att / def
6568 lossArray[side].res += loss * (uw.GameData.units[unit].resources.wood + uw.GameData.units[unit].resources.stone + uw.GameData.units[unit].resources.iron);
6569 lossArray[side].fav += loss * uw.GameData.units[unit].favor;
6570 lossArray[side].pop += loss * uw.GameData.units[unit].population;
6571 }
6572 });
6573 // Calculate wall resource losses
6574 for (var w = wall_level; w > wall_level - wall_damage; w--) {
6575 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
6576 }
6577
6578 // Insert losses into table
6579 for (var x in lossArray) {
6580 if (lossArray.hasOwnProperty(x)) {
6581 for (var z in lossArray[x]) {
6582 if (lossArray[x].hasOwnProperty(z)) {
6583 //console.log(((z === "res") && (lossArray[x][z] > 10000)) ? (Math.round(lossArray[x][z] / 1000) + "k") : lossArray[x][z]);
6584 $("#" + x + "_" + z).get(0).innerHTML = ((z === "res") && (lossArray[x][z] > 10000)) ? (Math.round(lossArray[x][z] / 1000) + "k") : lossArray[x][z];
6585
6586 }
6587 }
6588 }
6589 }
6590 }
6591
6592 // Stärkeanzeige: Simulator
6593 var unitsGround = {att: {}, def: {}}, unitsNaval = {att: {}, def: {}}, name = "";
6594
6595 var SimulatorStrength = {
6596 unitsGround : {att: {}, def: {}},
6597 unitsNaval : {att: {}, def: {}},
6598
6599 activate : function(){
6600 $('<style id="dio_simulator_strength_style">'+
6601 '#dio_simulator_strength { position:absolute; top:192px; font-size:0.8em; width:63%; } '+
6602 '#dio_simulator_strength .ico { height:20px; width:20px; margin:auto; } '+
6603 '#dio_simulator_strength .units_info_sprite { background:url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png); background-size:100%; } ' +
6604
6605 '#dio_simulator_strength .img_hack { background-position:0% 36%; } '+
6606 '#dio_simulator_strength .img_pierce { background-position:0% 27%; } '+
6607 '#dio_simulator_strength .img_dist { background-position:0% 45% !important; } '+
6608 '#dio_simulator_strength .img_ship { background-position:0% 72%; } '+
6609
6610 '#dio_simulator_strength .img_fav { background: url(https://gpall.innogamescdn.com/images/game/res/favor.png) !important; background-size: 100%; } '+
6611 '#dio_simulator_strength .img_res { background: url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png) 0% 54%; background-size: 100%; } '+
6612 '#dio_simulator_strength .img_pop { background: url(https://gpall.innogamescdn.com/images/game/res/pop.png); background-size:100%; } '+
6613
6614 '#dio_simulator_strength .left_border { width: 54px; } '+
6615 '</style>'
6616 ).appendTo('head');
6617
6618 },
6619 deactivate : function(){
6620 $('#dio_simulator_strength_style').remove();
6621 },
6622 add : function(){
6623 $('<div id="dio_simulator_strength">' +
6624 '<div style="float:left; margin-right:12px;"><h4>' + getText("labels", "str") + '</h4>' +
6625 '<table class="place_simulator_table strength" cellpadding="0px" cellspacing="0px" style="align:center;">' +
6626 '<tr>' +
6627 '<td class="place_simulator_even"></td>' +
6628 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_hack"></div></td>' +
6629 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_pierce"></div></td>' +
6630 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_dist"></div></td>' +
6631 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_ship"></div></td>' +
6632 '</tr><tr>' +
6633 '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>' +
6634 '<td class="left_border place_simulator_odd" id="att_b">0</td>' +
6635 '<td class="left_border place_simulator_even" id="att_s">0</td>' +
6636 '<td class="left_border place_simulator_odd" id="att_d">0</td>' +
6637 '<td class="left_border place_simulator_even" id="att_ship">0</td>' +
6638 '</tr><tr>' +
6639 '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
6640 '<td class="left_border place_simulator_odd" id="def_b">0</td>' +
6641 '<td class="left_border place_simulator_even" id="def_s">0</td>' +
6642 '<td class="left_border place_simulator_odd" id="def_d">0</td>' +
6643 '<td class="left_border place_simulator_even" id="def_ship">0</td>' +
6644 '</tr>' +
6645 '</table>' +
6646 '</div><div><h4>' + getText("labels", "los") + '</h4>' +
6647 '<table class="place_simulator_table loss" cellpadding="0px" cellspacing="0px" style="align:center;">' +
6648 '<tr>' +
6649 '<td class="place_simulator_even"></td>' +
6650 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_res"></div></td>' +
6651 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_fav"></div></td>' +
6652 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_pop"></div></td>' +
6653 '</tr><tr>' +
6654 '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>' +
6655 '<td class="left_border place_simulator_odd" id="att_res">0</td>' +
6656 '<td class="left_border place_simulator_even" id="att_fav">0</td>' +
6657 '<td class="left_border place_simulator_odd" id="att_pop">0</td>' +
6658 '</tr><tr>' +
6659 '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
6660 '<td class="left_border place_simulator_odd" id="def_res">0</td>' +
6661 '<td class="left_border place_simulator_even" id="def_fav">0</td>' +
6662 '<td class="left_border place_simulator_odd" id="def_pop">0</td>' +
6663 '</tr>' +
6664 '</table>' +
6665 '</div></div>').appendTo('#simulator_body');
6666
6667
6668 $('#dio_simulator_strength .left_border').each(function () {
6669 $(this)[0].align = 'center';
6670 });
6671
6672 // Tooltips setzen
6673 $('#dio_simulator_strength .strength').tooltip(getText("labels", "str") + " (" + getText("labels", "mod") + ")");
6674 $('#dio_simulator_strength .loss').tooltip(getText("labels", "los"));
6675
6676 // Klick auf Einheitenbild
6677 $('.index_unit').click(function () {
6678 var type = $(this).attr('class').split(" ")[4];
6679 $('.place_insert_field[name="sim[units][att][' + type + ']"]').change();
6680 });
6681
6682 $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').on('input change', function () {
6683 name = $(this).attr("name").replace(/\]/g, "").split("[");
6684 var str = this;
6685
6686
6687 setTimeout(function () {
6688 var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2],
6689 val, e;
6690
6691 val = parseInt($(str).val(), 10);
6692 val = val || 0;
6693
6694 if (unit_type == "ground") {
6695 unitsGround[name[2]][name[3]] = val;
6696
6697 if (name[2] == "def") {
6698 UnitStrength.calcDef(unitsGround.def);
6699 } else {
6700 UnitStrength.calcOff(unitsGround.att, unitsGround.att);
6701 }
6702 $('#' + name[2] + '_b').get(0).innerHTML = blunt;
6703 $('#' + name[2] + '_s').get(0).innerHTML = sharp;
6704 $('#' + name[2] + '_d').get(0).innerHTML = dist;
6705
6706 } else {
6707 var att = 0, def = 0;
6708 unitsNaval[name[2]][name[3]] = val;
6709
6710 if (name[2] == "def") {
6711 for (e in unitsNaval.def) {
6712 if (unitsNaval.def.hasOwnProperty(e)) {
6713 def += unitsNaval.def[e] * uw.GameData.units[e].defense;
6714 }
6715 }
6716 $('#def_ship').get(0).innerHTML = def;
6717
6718 } else {
6719 for (e in unitsNaval.att) {
6720 if (unitsNaval.att.hasOwnProperty(e)) {
6721 att += unitsNaval.att[e] * uw.GameData.units[e].attack;
6722 }
6723 }
6724 $('#att_ship').get(0).innerHTML = att;
6725 }
6726 }
6727 }, 100);
6728 });
6729
6730 // Abfrage wegen eventueller Spionageweiterleitung
6731 getUnitInputs();
6732 setTimeout(function () {
6733 setChangeUnitInputs("def");
6734 }, 100);
6735
6736 $('#select_insert_units').change(function () {
6737 var side = $(this).find('option:selected').val();
6738
6739 setTimeout(function () {
6740 getUnitInputs();
6741 if (side === "att" || side === "def") {
6742 setChangeUnitInputs(side);
6743 }
6744 }, 200);
6745 });
6746 },
6747
6748 getUnitInputs : function(){
6749 $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').each(function () {
6750 var name = $(this).attr("name").replace(/\]/g, "").split("[");
6751
6752 var str = this;
6753
6754 var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2];
6755
6756 var val = parseInt($(str).val(), 10);
6757
6758 val = val || 0;
6759
6760 if (unit_type === "ground") {
6761 SimulatorStrength.unitsGround[name[2]][name[3]] = val;
6762 } else {
6763 SimulatorStrength.unitsNaval[name[2]][name[3]] = val;
6764 }
6765 });
6766 },
6767
6768 updateStrength : function(){
6769
6770 }
6771 }
6772 function setStrengthSimulator() {
6773 $('<div id="dio_simulator_strength">' +
6774 '<div style="float:left; margin-right:12px;"><h4>' + getText("labels", "str") + '</h4>' +
6775 '<table class="place_simulator_table strength" cellpadding="0px" cellspacing="0px" style="align:center;">' +
6776 '<tr>' +
6777 '<td class="place_simulator_even"></td>' +
6778 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_hack"></div></td>' +
6779 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_pierce"></div></td>' +
6780 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_dist"></div></td>' +
6781 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_ship"></div></td>' +
6782 '</tr><tr>' +
6783 '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>' +
6784 '<td class="left_border place_simulator_odd" id="att_b">0</td>' +
6785 '<td class="left_border place_simulator_even" id="att_s">0</td>' +
6786 '<td class="left_border place_simulator_odd" id="att_d">0</td>' +
6787 '<td class="left_border place_simulator_even" id="att_ship">0</td>' +
6788 '</tr><tr>' +
6789 '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
6790 '<td class="left_border place_simulator_odd" id="def_b">0</td>' +
6791 '<td class="left_border place_simulator_even" id="def_s">0</td>' +
6792 '<td class="left_border place_simulator_odd" id="def_d">0</td>' +
6793 '<td class="left_border place_simulator_even" id="def_ship">0</td>' +
6794 '</tr>' +
6795 '</table>' +
6796 '</div><div><h4>' + getText("labels", "los") + '</h4>' +
6797 '<table class="place_simulator_table loss" cellpadding="0px" cellspacing="0px" style="align:center;">' +
6798 '<tr>' +
6799 '<td class="place_simulator_even"></td>' +
6800 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_res"></div></td>' +
6801 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_fav"></div></td>' +
6802 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_pop"></div></td>' +
6803 '</tr><tr>' +
6804 '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>' +
6805 '<td class="left_border place_simulator_odd" id="att_res">0</td>' +
6806 '<td class="left_border place_simulator_even" id="att_fav">0</td>' +
6807 '<td class="left_border place_simulator_odd" id="att_pop">0</td>' +
6808 '</tr><tr>' +
6809 '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
6810 '<td class="left_border place_simulator_odd" id="def_res">0</td>' +
6811 '<td class="left_border place_simulator_even" id="def_fav">0</td>' +
6812 '<td class="left_border place_simulator_odd" id="def_pop">0</td>' +
6813 '</tr>' +
6814 '</table>' +
6815 '</div></div>').appendTo('#simulator_body');
6816
6817
6818 /*
6819 $('#dio_simulator_strength').css({
6820 position: 'absolute',
6821 top: '192px',
6822 fontSize: '0.8em',
6823 width: '63%'
6824 });
6825 $('#dio_simulator_strength .ico').css({
6826 height: '20px',
6827 width: '20px',
6828 margin: 'auto'
6829 });
6830 $('#dio_simulator_strength .units_info_sprite').css({
6831 background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
6832 backgroundSize: '100%'
6833 });
6834 $('#dio_simulator_strength .img_hack').css({backgroundPosition: '0% 36%'});
6835 $('#dio_simulator_strength .img_pierce').css({backgroundPosition: '0% 27%'});
6836 $('#dio_simulator_strength .img_dist').css({backgroundPosition: '0% 45%'});
6837 $('#dio_simulator_strength .img_ship').css({backgroundPosition: '0% 72%'});
6838
6839 $('#dio_simulator_strength .img_fav').css({
6840 background: 'url(https://gpall.innogamescdn.com/images/game/res/favor.png)',
6841 backgroundSize: '100%'
6842 });
6843 $('#dio_simulator_strength .img_res').css({
6844 background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png) 0% 54%',
6845 backgroundSize: '100%'
6846 });
6847 $('#dio_simulator_strength .img_pop').css({
6848 background: 'url(https://gpall.innogamescdn.com/images/game/res/pop.png)',
6849 backgroundSize: '100%'
6850 });
6851
6852 $('#dio_simulator_strength .left_border').css({
6853 width: '54px'
6854 });
6855 */
6856
6857
6858 $('#dio_simulator_strength .left_border').each(function () {
6859 $(this)[0].align = 'center';
6860 });
6861
6862 $('#dio_simulator_strength .strength').tooltip(getText("labels", "str") + " (" + getText("labels", "mod") + ")");
6863 $('#dio_simulator_strength .loss').tooltip(getText("labels", "los"));
6864
6865 // Klick auf Einheitenbild
6866 $('.index_unit').click(function () {
6867 var type = $(this).attr('class').split(" ")[4];
6868 $('.place_insert_field[name="sim[units][att][' + type + ']"]').change();
6869 });
6870
6871 $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').on('input change', function () {
6872 name = $(this).attr("name").replace(/\]/g, "").split("[");
6873 var str = this;
6874 //console.log(str);
6875 setTimeout(function () {
6876 var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2],
6877 val, e;
6878
6879 val = parseInt($(str).val(), 10);
6880 val = val || 0;
6881
6882 if (unit_type == "ground") {
6883 unitsGround[name[2]][name[3]] = val;
6884
6885 if (name[2] == "def") {
6886 UnitStrength.calcDef(unitsGround.def);
6887 } else {
6888 UnitStrength.calcOff(unitsGround.att, unitsGround.att);
6889 }
6890 $('#' + name[2] + '_b').get(0).innerHTML = blunt;
6891 $('#' + name[2] + '_s').get(0).innerHTML = sharp;
6892 $('#' + name[2] + '_d').get(0).innerHTML = dist;
6893
6894 } else {
6895 var att = 0, def = 0;
6896 unitsNaval[name[2]][name[3]] = val;
6897
6898 if (name[2] == "def") {
6899 for (e in unitsNaval.def) {
6900 if (unitsNaval.def.hasOwnProperty(e)) {
6901 def += unitsNaval.def[e] * uw.GameData.units[e].defense;
6902 }
6903 }
6904 $('#def_ship').get(0).innerHTML = def;
6905
6906 } else {
6907 for (e in unitsNaval.att) {
6908 if (unitsNaval.att.hasOwnProperty(e)) {
6909 att += unitsNaval.att[e] * uw.GameData.units[e].attack;
6910 }
6911 }
6912 $('#att_ship').get(0).innerHTML = att;
6913 }
6914 }
6915 }, 100);
6916 });
6917
6918 // Abfrage wegen eventueller Spionageweiterleitung
6919 getUnitInputs();
6920 setTimeout(function () {
6921 setChangeUnitInputs("def");
6922 }, 100);
6923
6924 $('#select_insert_units').change(function () {
6925 var side = $(this).find('option:selected').val();
6926
6927 setTimeout(function () {
6928 getUnitInputs();
6929 if (side === "att" || side === "def") {
6930 setChangeUnitInputs(side);
6931 }
6932 }, 200);
6933 });
6934 }
6935
6936 function getUnitInputs() {
6937 $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').each(function () {
6938 name = $(this).attr("name").replace(/\]/g, "").split("[");
6939
6940 var str = this;
6941
6942 var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2];
6943
6944 var val = parseInt($(str).val(), 10);
6945
6946 val = val || 0;
6947
6948 if (unit_type === "ground") {
6949 unitsGround[name[2]][name[3]] = val;
6950 } else {
6951 unitsNaval[name[2]][name[3]] = val;
6952 }
6953 });
6954 }
6955
6956 function setChangeUnitInputs(side) {
6957 $('.place_insert_field[name="sim[units][' + side + '][godsent]"]').change();
6958 setTimeout(function () {
6959 $('.place_insert_field[name="sim[units][' + side + '][colonize_ship]"]').change();
6960 }, 100);
6961 }
6962
6963 /*******************************************************************************************************************************
6964 * Defense form
6965 * ----------------------------------------------------------------------------------------------------------------------------
6966 * | â— Adds a defense form to the bbcode bar
6967 * ----------------------------------------------------------------------------------------------------------------------------
6968 *******************************************************************************************************************************/
6969
6970 // Funktion aufteilen...
6971 function addForm(e) {
6972 var textareaId = "", bbcodeBarId = "";
6973
6974 switch (e) {
6975 case "/alliance_forum/forum":
6976 textareaId = "#forum_post_textarea";
6977 bbcodeBarId = "#forum";
6978 break;
6979 case "/message/forward":
6980 textareaId = "#message_message";
6981 bbcodeBarId = "#message_bbcodes";
6982 break;
6983 case "/message/new":
6984 textareaId = "#message_new_message";
6985 bbcodeBarId = "#message_bbcodes";
6986 break;
6987 case "/message/view":
6988 textareaId = "#message_reply_message";
6989 bbcodeBarId = "#message_bbcodes";
6990 break;
6991 case "/player_memo/load_memo_content":
6992 textareaId = "#memo_text_area";
6993 bbcodeBarId = "#memo_edit";
6994 break;
6995 }
6996
6997 $('<a title="Verteidigungsformular" href="#" class="dio_bbcode_option def_form" name="def_form"></a>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
6998
6999 $('.def_form_button').css({
7000 cursor: 'pointer',
7001 marginTop: '3px'
7002 });
7003
7004 $(bbcodeBarId + ' .dio_bbcode_option').css({
7005 background: 'url("http://s14.directupload.net/images/140126/lt3hyb8j.png")',
7006 display: 'block',
7007 float: 'left',
7008 width: '22px',
7009 height: '23px',
7010 margin: '0 3px 0 0',
7011 position: 'relative'
7012 });
7013 $(bbcodeBarId + ' .def_form').css({
7014 backgroundPosition: '-89px 0px'
7015 });
7016 var imgArray = {
7017 wall: 'https://gpall.innogamescdn.com/images/game/main/wall.png',
7018 tower: 'https://gpall.innogamescdn.com/images/game/main/tower.png',
7019 hide: 'https://gpall.innogamescdn.com/images/game/main/hide.png',
7020
7021 spy: 'http://s7.directupload.net/images/140114/yr993xwc.png',
7022 pop: 'http://s7.directupload.net/images/140114/4d6xktxm.png',
7023
7024 rev1: 'http://s7.directupload.net/images/140115/9cv6otiu.png',
7025 rev0: 'http://s7.directupload.net/images/140115/aue4rg6i.png',
7026 eo1: 'http://s1.directupload.net/images/140115/fkzlipyh.png',
7027 eo0: 'http://s1.directupload.net/images/140115/hs2kg59c.png',
7028 att: 'http://s1.directupload.net/images/140115/3t6uy4te.png',
7029 sup: 'http://s7.directupload.net/images/140115/ty6szerx.png',
7030
7031 zeus: 'http://s1.directupload.net/images/140114/cdxecrpu.png',
7032 hera: 'http://s1.directupload.net/images/140114/mve54v2o.png',
7033 athena: 'http://s14.directupload.net/images/140114/kyqyedhe.png',
7034 poseidon: 'http://s7.directupload.net/images/140114/tusr9oyi.png',
7035 hades: 'http://s7.directupload.net/images/140114/huins2gn.png',
7036 artemis: 'http://s7.directupload.net/images/140114/kghjhko8.png',
7037 nogod: 'http://s1.directupload.net/images/140114/e7vmvfap.png',
7038
7039 captain: 'http://s14.directupload.net/images/140114/88gg75rc.png',
7040 commander: 'http://s14.directupload.net/images/140114/slbst52o.png',
7041 priest: 'http://s1.directupload.net/images/140114/glptekkx.png',
7042
7043 phalanx: 'http://s7.directupload.net/images/140114/e97wby6z.png',
7044 ram: 'http://s7.directupload.net/images/140114/s854ds3w.png',
7045
7046 militia: 'http://wiki.en.grepolis.com/images/9/9b/Militia_40x40.png',
7047 sword: 'http://wiki.en.grepolis.com/images/9/9c/Sword_40x40.png',
7048 slinger: 'http://wiki.en.grepolis.com/images/d/dc/Slinger_40x40.png',
7049 archer: 'http://wiki.en.grepolis.com/images/1/1a/Archer_40x40.png',
7050 hoplite: 'http://wiki.en.grepolis.com/images/b/bd/Hoplite_40x40.png',
7051 rider: 'http://wiki.en.grepolis.com/images/e/e9/Rider_40x40.png',
7052 chariot: 'http://wiki.en.grepolis.com/images/b/b8/Chariot_40x40.png',
7053 catapult: 'http://wiki.en.grepolis.com/images/f/f0/Catapult_40x40.png',
7054 godsent: 'http://wiki.de.grepolis.com/images/6/6e/Grepolis_Wiki_225.png',
7055
7056 def_sum: 'http://s14.directupload.net/images/140127/6cxnis9r.png',
7057
7058 minotaur: 'http://wiki.de.grepolis.com/images/7/70/Minotaur_40x40.png',
7059 manticore: 'http://wiki.de.grepolis.com/images/5/5e/Manticore_40x40.png',
7060 zyclop: 'http://wiki.de.grepolis.com/images/6/66/Zyklop_40x40.png',
7061 sea_monster: 'http://wiki.de.grepolis.com/images/7/70/Sea_monster_40x40.png',
7062 harpy: 'http://wiki.de.grepolis.com/images/8/80/Harpy_40x40.png',
7063 medusa: 'http://wiki.de.grepolis.com/images/d/db/Medusa_40x40.png',
7064 centaur: 'http://wiki.de.grepolis.com/images/5/53/Centaur_40x40.png',
7065 pegasus: 'http://wiki.de.grepolis.com/images/5/54/Pegasus_40x40.png',
7066 cerberus: 'http://wiki.de.grepolis.com/images/6/67/Zerberus_40x40.png',
7067 fury: 'http://wiki.de.grepolis.com/images/6/67/Erinys_40x40.png',
7068 griffin: 'http://wiki.de.grepolis.com/images/d/d1/Unit_greif.png',
7069 calydonian_boar: 'http://wiki.de.grepolis.com/images/9/93/Unit_eber.png',
7070
7071 big_transporter: 'http://wiki.en.grepolis.com/images/0/04/Big_transporter_40x40.png',
7072 bireme: 'http://wiki.en.grepolis.com/images/4/44/Bireme_40x40.png',
7073 attack_ship: 'http://wiki.en.grepolis.com/images/e/e6/Attack_ship_40x40.png',
7074 demolition_ship: 'http://wiki.en.grepolis.com/images/e/ec/Demolition_ship_40x40.png',
7075 small_transporter: 'http://wiki.en.grepolis.com/images/8/85/Small_transporter_40x40.png',
7076 trireme: 'http://wiki.en.grepolis.com/images/a/ad/Trireme_40x40.png',
7077 colonize_ship: 'http://wiki.en.grepolis.com/images/d/d1/Colonize_ship_40x40.png',
7078
7079 move_icon: 'https://gpall.innogamescdn.com/images/game/unit_overview/',
7080
7081 bordure: 'http://s1.directupload.net/images/140126/8y6pmetk.png'
7082 };
7083
7084 $('<div class="bb_def_chooser">' +
7085 '<div class="bbcode_box middle_center">' +
7086 '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div>' +
7087 '<div class="bbcode_box top_center"></div><div class="bbcode_box bottom_center"></div>' +
7088 '<div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>' +
7089 '<div class="bbcode_box middle_left"></div><div class="bbcode_box middle_right"></div>' +
7090 '<div class="bbcode_box content clearfix" style="padding:5px">' +
7091 '<div id="f_uni" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "det") + '</div></div><br><br>' +
7092 '<div id="f_prm" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "prm") + '</div></div><br><br>' +
7093 '<div id="f_sil" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "sil") + '</div></div><br><br>' +
7094 '<div id="f_mov" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "mov") + '</div></div><br><br>' +
7095 '<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>' +
7096 '</div></div></div>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
7097
7098 $('.bb_def_chooser').css({
7099 display: 'none',
7100 top: '38px',
7101 left: '510px',
7102 position: 'absolute',
7103 width: '190px',
7104 zIndex: 10000
7105 });
7106
7107 $(bbcodeBarId + " .bb_def_chooser .checkbox_new").click(function () {
7108 $(this).toggleClass("checked");
7109 });
7110
7111 $(bbcodeBarId + ' .def_form').toggleClick(function () {
7112 $(this).parent().find(".bb_def_chooser").get(0).style.display = "block";
7113 }, function () {
7114 $(this).parent().find(".bb_def_chooser").get(0).style.display = "none";
7115 });
7116
7117 $(bbcodeBarId + ' #dio_insert').click(function () {
7118 var textarea = $(textareaId).get(0), text = $(textarea).val(), troop_table = "", troop_img = "", troop_count = "", separator = "", move_table = "", landunit_sum = 0;
7119
7120 $('.def_form').click();
7121
7122 if ($('#f_uni').hasClass("checked")) {
7123 $('.units_land .unit, .units_naval .unit').each(function () {
7124 troop_img += separator + '[img]' + imgArray[this.className.split(" ")[1]] + '[/img]';
7125 troop_count += separator + '[center]' + $(this).find(".value").get(0).innerHTML + '[/center]';
7126 separator = "[||]";
7127 });
7128 } else {
7129 $('.units_land .unit').each(function () {
7130 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);
7131 if (def > 10) {
7132 landunit_sum += parseInt($(this).find(".value").get(0).innerHTML, 10) * uw.GameData.units[a].population * ((def > 20) ? 2 : 1);
7133 }
7134 });
7135 landunit_sum = (landunit_sum > 10000) ? ((Math.round(landunit_sum / 100)) / 10) + "k" : landunit_sum;
7136
7137 troop_img += '[img]' + imgArray.def_sum + '[/img]';
7138 troop_count += '[center]' + landunit_sum + '[/center]';
7139 separator = "[||]";
7140 $('.units_naval .unit').each(function () {
7141 troop_img += separator + '[img]' + imgArray[this.className.split(" ")[1]] + '[/img]';
7142 troop_count += separator + '[center]' + $(this).find(".value").get(0).innerHTML + '[/center]';
7143 });
7144 }
7145 if (troop_img !== "") {
7146 troop_table = "\n[table][**]" + troop_img + "[/**][**]" + troop_count + "[/**][/table]\n";
7147 }
7148
7149 var str = '[img]' + imgArray.bordure + '[/img]' +
7150 '\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' +
7151 //'[table][**][img]'+ imgArray.sup +'[/img][||]'+
7152 '[size=12][town]' + uw.ITowns.getTown(uw.Game.townId).getId() + '[/town] ([player]' + uw.Game.player_name + '[/player])[/size]' +
7153 //'[||][img]'+ imgArray['rev' + (uw.ITowns.getTown(uw.Game.townId).hasConqueror()?1:0)] +'[/img][/**][/table]'+
7154 '\n\n[i][b]' + getText("labels", "inf") + '[/b][/i]' + troop_table +
7155 '[table][*]' +
7156 '[img]' + imgArray.wall + '[/img][|]\n' +
7157 '[img]' + imgArray.tower + '[/img][|]\n' +
7158 '[img]' + imgArray.phalanx + '[/img][|]\n' +
7159 '[img]' + imgArray.ram + '[/img][|]\n' +
7160 ($('#f_prm').hasClass("checked") ? '[img]' + imgArray.commander + '[/img][|]\n' : ' ') +
7161 ($('#f_prm').hasClass("checked") ? '[img]' + imgArray.captain + '[/img][|]\n' : ' ') +
7162 ($('#f_prm').hasClass("checked") ? '[img]' + imgArray.priest + '[/img][|]\n' : ' ') +
7163 ($('#f_sil').hasClass("checked") ? '[center][img]' + imgArray.spy + '[/img][/center][|]\n' : ' ') +
7164 '[img]' + imgArray.pop + '[/img][|]\n' +
7165 '[img]' + imgArray[(uw.ITowns.getTown(uw.Game.townId).god() || "nogod")] + '[/img][/*]\n' +
7166 '[**][center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("wall") + '[/center][||]' +
7167 '[center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("tower") + '[/center][||]' +
7168 '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.phalanx ? '+' : '-') + '[/center][||]' +
7169 '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.ram ? '+' : '-') + '[/center][||]' +
7170 ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.commander >= uw.Timestamp.now()) ? '+' : '-') + '[/center][||]' : ' ') +
7171 ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.captain >= uw.Timestamp.now()) ? '+' : '-') + '[/center][||]' : ' ') +
7172 ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.priest >= uw.Timestamp.now()) ? '+' : '-') + '[/center][||]' : ' ') +
7173 ($('#f_sil').hasClass("checked") ? '[center]' + Math.round(uw.ITowns.getTown(uw.Game.townId).getEspionageStorage() / 1000) + 'k[/center][||]' : ' ') +
7174 '[center]' + uw.ITowns.getTown(uw.Game.townId).getAvailablePopulation() + '[/center][||]' +
7175 '[center]' + $('.gods_favor_amount').get(0).innerHTML + '[/center]' +
7176 '[/**][/table]';
7177
7178 var bb_count_str = parseInt(str.match(/\[/g).length, 10), bb_count_move = 0;
7179
7180 var i = 0;
7181 if ($('#f_mov').hasClass("checked")) {
7182 move_table += '\n[i][b]' + getText("labels", "mov") + '[/b][/i]\n[table]';
7183
7184 $('#toolbar_activity_commands').mouseover();
7185
7186 $('#toolbar_activity_commands_list .content .command').each(function () {
7187 var cl = $(this).children()[0].className.split(" ");
7188 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)) {
7189 move_table += (i % 1) ? "" : "[**]";
7190 i++;
7191 move_table += "[img]" + imgArray.move_icon + cl[2] + ".png[/img][||]";
7192 move_table += getArrivalTime($(this).children()[1].innerHTML) + (uw.Game.market_id === "de" ? " Uhr[||]" : " [||]");
7193 move_table += "[town]" + JSON.parse(atob($(this).children()[2].firstChild.href.split("#")[1])).id + "[/town]";
7194 move_table += (i % 1) ? "[||]" : "[/**]";
7195 }
7196 bb_count_move = parseInt(move_table.match(/\[/g).length, 10);
7197 });
7198 if ((bb_count_str + bb_count_move) > 480) {
7199 move_table += '[**]...[/**]';
7200 }
7201
7202 $('#toolbar_activity_commands').mouseout();
7203
7204 //console.log((bb_count_str + bb_count_move));
7205 move_table += (i % 1) ? "[/**]" : "";
7206 move_table += "[*][|][color=#800000][size=6][i] (" + getText("labels", "dev") + ": ±1s)[/i][/size][/color][/*][/table]\n";
7207 }
7208
7209 str += move_table + '[img]' + imgArray.bordure + '[/img]';
7210
7211
7212 $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + str + text.substring($(textarea).get(0).selectionEnd));
7213 });
7214 }
7215
7216 function getArrivalTime(duration_time) {
7217 /*
7218 var server_time = new Date((uw.Timestamp.server() + 7200) * 1000);
7219
7220 duration_time = duration_time.split(":");
7221
7222 s = server_time.getUTCSeconds() + parseInt(duration_time[2], 10);
7223 m = server_time.getUTCMinutes() + parseInt(duration_time[1], 10) + ((s>=60)? 1 : 0);
7224 h = server_time.getUTCHours() + parseInt(duration_time[0], 10) + ((m>=60)? 1 : 0);
7225 */
7226
7227 var server_time = $('.server_time_area').get(0).innerHTML.split(" ")[0].split(":"), arrival_time, s, m, h;
7228 duration_time = duration_time.split(":");
7229
7230 s = parseInt(server_time[2], 10) + parseInt(duration_time[2], 10);
7231 m = parseInt(server_time[1], 10) + parseInt(duration_time[1], 10) + ((s >= 60) ? 1 : 0);
7232 h = parseInt(server_time[0], 10) + parseInt(duration_time[0], 10) + ((m >= 60) ? 1 : 0);
7233
7234 s = s % 60;
7235 m = m % 60;
7236 h = h % 24;
7237
7238 s = ((s < 10) ? "0" : "") + s;
7239 m = ((m < 10) ? "0" : "") + m;
7240 h = ((h < 10) ? "0" : "") + h;
7241
7242 arrival_time = h + ":" + m + ":" + s;
7243
7244 return arrival_time;
7245 }
7246
7247
7248 /*******************************************************************************************************************************
7249 * Smiley box
7250 * ----------------------------------------------------------------------------------------------------------------------------
7251 * | â— Display of a smiley selection box for text input fields (forum, messages, notes):
7252 * | â— Used smileys: http://www.greensmilies.com/smilie-album/
7253 * | + Own Grepolis smileys
7254 * ----------------------------------------------------------------------------------------------------------------------------
7255 *******************************************************************************************************************************/
7256
7257 var smileyArray = {};
7258
7259 var SmileyBox = {
7260 loading_error: false, isHalloween: false, isXmas: false, isForum: $(".editor_textbox_container").get(0),
7261
7262 activate: function () {
7263 $('<style id="dio_smiley">' +
7264 '.smiley_button { cursor:pointer; margin:3px 2px 2px 2px; } ' +
7265
7266 '.smiley_box.game { z-index:5000; position:absolute; top:27px; left:430px; min-width:300px; display:none; } ' +
7267
7268 // Smiley categories
7269 '.smiley_box .box_header { display: table; width: 100%; text-align:center; } ' +
7270 '.smiley_box .group { display:table-cell; color: #0c450c; cursor: pointer; font-weight:bold; padding: 0px 2px 0px 2px; } ' +
7271 '.smiley_box .group.active { color: #089421; text-decoration:underline;} ' +
7272 '.smiley_box .group:hover { color: #14999E; } ' + // #11AD6C
7273
7274 // Special smiley categories
7275 '.smiley_box .halloween { color: #E25E00; } ' +
7276 '.smiley_box .xmas { color: darkred; } ' +
7277
7278 '.smiley_box hr { margin:3px 0px 0px 0px; color:#086b18; border:1px solid; } ' +
7279
7280 // Smilies
7281 '.smiley_box .box_content { overflow: hidden; } ' +
7282 '.smiley_box .box_content .smiley { border: 1px solid rgba(0,0,0,0); border-radius: 5px;} ' +
7283 '.smiley_box .box_content .smiley:hover { background: rgba(8, 148, 77, 0.2); border: 1px solid rgba(0, 128, 0, 0.5); } ' +
7284
7285 // Smiley page link
7286 '.smiley_box .box_footer { text-align:center; margin-top:4px; } ' +
7287 '.smiley_box a:link, .smiley_box a:visited { color: #086b18; font-size: 0.7em; } ' +
7288 '.smiley_box a:hover { color: #14999E; } ' +
7289
7290 // TODO Forum ...
7291 '.smiley_box.forum .box_header_left { float:left; } ' +
7292 //'.smiley_box.forum .group { padding-right: 10px; } '+
7293 '.smiley_box.forum .box_header_right { text-align:right; margin-top:2px; } ' +
7294
7295 '.smiley_box.forum { max-height:90px; margin-left:5px; width:99%; min-height:10px; } ' +
7296 '.smiley_box.forum .box_content { overflow:overlay; min-height:70px; margin-bottom:10px; } ' +
7297
7298 '.smiley_box.forum a:link, .smiley_box.forum a:visited { font-size: 1em; } ' +
7299
7300 '</style>').appendTo('head');
7301
7302
7303 // Smiley categories
7304 smileyArray.button = ["rollsmiliey", "smile"];
7305
7306 smileyArray.standard = [
7307 "smilenew", "grin", "lol", "neutral_new", "afraid", "freddus_pacman", "auslachen2", "kolobok-sanduhr", "bussi2", "winken4", "flucht2", "panik4", "ins-auge-stechen",
7308 "seb_zunge", "fluch4_GREEN", "baby_junge2", "blush-reloaded6", "frown", "verlegen", "blush-pfeif", "stevieh_rolleyes", "daumendreh2", "baby_taptap",
7309 "sadnew", "hust", "confusednew", "idea2", "irre", "irre4", "sleep", "candle", "nicken", "no_sad",
7310 "thumbs-up_new", "thumbs-down_new", "bravo2", "oh-no2", "kaffee2", "drunk", "saufen", "freu-dance", "hecheln", "headstand", "rollsmiliey", "eazy_cool01", "motz", "cuinlove", "biggrin"
7311 ];
7312 smileyArray.nature = [
7313 "dinosaurier07", "flu-super-gau", "ben_cat", "schwein", "hundeleine01", "blume", "ben_sharky", "ben_cow", "charly_bissig", "gehirnschnecke_confused", "mttao_fische", "mttao_angler",
7314 "insel", "fliegeschnappen", "spider", /* Spinne */ "shipwrecked", /* Schiffbrüchiger */ "plapperhase", "ben_dumbo"
7315 ];
7316 smileyArray.grepolis = [
7317 "mttao_wassermann", "hera", /* Hera */ "medusa", /* Medusa */ "manticore", /* Mantikor */ "cyclops", /* Zyklop */
7318 "minotaur", /* Minotaurus */ "pegasus", /* Pegasus */ "hydra", /* Hydra */
7319 "silvester_cuinlove", "mttao_schuetze", "kleeblatt2", "wallbash", /* "glaskugel4", */ "musketiere_fechtend", /* "krone-hoch",*/ "viking", // Wikinger
7320 "mttao_waage2", "steckenpferd", /* "kinggrin_anbeten2", */ "grepolove", /* Grepo Love */ "skullhaufen", "pferdehaufen" // "i/ckajscggscw4s2u60"
7321 ];
7322 smileyArray.people = [
7323 "seb_hut5", "opa_boese2", "star-wars-yoda1-gruen", "hexefliegend", "snob", "seb_detektiv_ani", "seb_cowboy", "devil", "segen", "pirat5", "borg", "hexe3b",
7324 "pharaoh", "hippie", "eazy_polizei", "stars_elvis", "mttao_chefkoch", "nikolaus", "pirate3_biggrin", "batman_skeptisch", "tubbie1", "tubbie2", "tubbie3", "tubbie4"
7325 ];
7326 smileyArray.other = [
7327 "steinwerfen", "herzen02", "scream-if-you-can", "kolobok", "headbash", "liebeskummer", "bussi", "brautpaar-reis", "grab-schaufler2", "boxen2", "aufsmaul",
7328 "sauf", "mttao_kehren", "sm", "weckruf", "klugscheisser2", "karte2_rot", "dagegen", "party", "dafuer", "outofthebox", "pokal_gold", "koepfler", "transformer"
7329 ];
7330
7331 // TODO: HolidayChecker benutzen!
7332 SmileyBox.checkHolidaySeason();
7333
7334 if (SmileyBox.isHalloween) {
7335 smileyArray.halloween = [
7336 "zombies_alien", "zombies_lol", "zombies_rolleyes", "zombie01", "zombies_smile", "zombie02", "zombies_skeptisch", "zombies_eek", "zombies_frown",
7337 "scream-if-you-can", "geistani", "pfeildurchkopf01", "grab-schaufler", "kuerbisleuchten", "mummy3",
7338 "kuerbishaufen", "halloweenskulljongleur", "fledermausvampir", "frankenstein_lol", "halloween_confused", "zombies_razz",
7339 "halloweenstars_freddykrueger", "zombies_cool", "geist2", "fledermaus2", "halloweenstars_dracula"
7340 // "batman" "halloweenstars_lastsummer"
7341 ];
7342 }
7343 if (SmileyBox.isXmas) {
7344 smileyArray.xmas = [
7345 "schneeballwerfen", "schneeball", "xmas4_advent4", "nikolaus", "weihnachtsmann_junge", "schneewerfen_wald", "weihnachtsmann_nordpol", "xmas_kilroy_kamin",
7346 "xmas4_laola", "xmas4_aufsmaul", "xmas3_smile", "xmas4_paketliebe", "mttao_ruprecht_peitsche", "3hlkoenige", "santa", "xmas4_hurra2", "weihnachtsgeschenk2", "fred_weihnachten-ostern"
7347 //"dafuer", "outofthebox", "pokal_gold", "koepfler", "transformer"
7348 ];
7349 }
7350
7351 //smileyArray.other = smileyArray.halloween.slice();
7352
7353 // Forum: Extra smiley
7354 if (SmileyBox.isForum) {
7355 smileyArray.grepolis.push("i/ckajscggscw4s2u60"); // Pacman
7356 smileyArray.grepolis.push("i/cowqyl57t5o255zli"); // Bugpolis
7357 smileyArray.grepolis.push("i/cowquq2foog1qrbee"); // Inno
7358 }
7359
7360 SmileyBox.loadSmileys();
7361 },
7362 deactivate: function () {
7363 $('#dio_smiley').remove();
7364 },
7365 checkHolidaySeason: function () {
7366 // TODO: HolidaySpecial-Klasse stattdessen benutzen
7367 var daystamp = 1000 * 60 * 60 * 24, today = new Date((new Date()) % (daystamp * (365 + 1 / 4))), // without year
7368
7369 // Halloween-Smileys ->15 days
7370 halloween_start = daystamp * 297, // 25. Oktober
7371 halloween_end = daystamp * 321, // 8. November
7372 // Xmas-Smileys -> 28 Tage
7373 xmas_start = daystamp * 334, // 1. Dezember
7374 xmas_end = daystamp * 361; // 28. Dezember
7375
7376 SmileyBox.isHalloween = (today >= halloween_start) ? (today <= halloween_end) : false;
7377
7378 SmileyBox.isXmas = (today >= xmas_start) ? (today <= xmas_end) : false;
7379 },
7380 // preload images
7381 loadSmileys: function () {
7382 // Replace german sign smilies
7383 if (LID !== "de") {
7384 smileyArray.other[17] = "dagegen2";
7385 smileyArray.other[19] = "dafuer2";
7386 }
7387
7388 for (var e in smileyArray) {
7389 if (smileyArray.hasOwnProperty(e)) {
7390 for (var f in smileyArray[e]) {
7391 if (smileyArray[e].hasOwnProperty(f)) {
7392 var src = smileyArray[e][f];
7393
7394 smileyArray[e][f] = new Image();
7395 smileyArray[e][f].className = "smiley";
7396
7397 if (src.substring(0, 2) == "i/") {
7398 smileyArray[e][f].src = "http://666kb.com/" + src + ".gif";
7399 } else {
7400 if (SmileyBox.loading_error == false) {
7401 smileyArray[e][f].src = "https://diotools.de/images/smileys/"+ e +"/smiley_emoticons_" + src + ".gif";
7402 //console.debug("Smiley", e);
7403 } else {
7404 smileyArray[e][f].src = 'http://s1.directupload.net/images/140128/93x3p4co.gif';
7405 }
7406 }
7407 smileyArray[e][f].onerror = function () {
7408 this.src = 'http://s1.directupload.net/images/140128/93x3p4co.gif';
7409 };
7410 }
7411 }
7412 }
7413 }
7414 },
7415
7416 // Forum smilies
7417 changeForumEditorLayout: function () {
7418 $('.blockrow').css({border: "none"});
7419
7420 // Subject/Title
7421 $($('.section div label[for="title"]').parent()).css({float: "left", width: "36%", marginRight: "20px"});
7422 $($('.section div label[for="subject"]').parent()).css({float: "left", width: "36%", marginRight: "20px"});
7423
7424 $('.section div input').eq(0).css({marginBottom: "-10px", marginTop: "10px"});
7425 $('#display_posticon').remove();
7426
7427 // Posticons
7428 $('.posticons table').css({width: "50%" /* marginTop: "-16px"*/});
7429 $('.posticons').css({marginBottom: "-16px"});
7430 $('.posticons').insertAfter($('.section div label[for="title"]').parent());
7431 $('.posticons').insertAfter($('.section div label[for="subject"]').parent());
7432 // Posticons hint
7433 $('.posticons p').remove();
7434 // Posticons: No Icon - radio button
7435 $(".posticons [colspan='14']").parent().replaceWith($(".posticons [colspan='14']"));
7436 $(".posticons [colspan='14']").children().wrap("<nobr></nobr>");
7437 $(".posticons [colspan='14']").appendTo('.posticons tr:eq(0)');
7438 $(".posticons [colspan='4']").remove();
7439 },
7440
7441 addForum: function () {
7442 $('<div class="smiley_box forum"><div>' +
7443 '<div class="box_header_left">' +
7444 '<span class="group standard active">' + getText("labels", "std") + '</span>' +
7445 '<span class="group grepolis">' + getText("labels", "gre") + '</span>' +
7446 '<span class="group nature">' + getText("labels", "nat") + '</span>' +
7447 '<span class="group people">' + getText("labels", "ppl") + '</span>' +
7448 '<span class="group other">' + getText("labels", "oth") + '</span>' +
7449 (SmileyBox.isHalloween ? '<span class="group halloween">' + getText("labels", "hal") + '</span>' : '') +
7450 (SmileyBox.isXmas ? '<span class="group xmas">' + getText("labels", "xma") + '</span>' : '') +
7451 '</div>' +
7452 '<div class="box_header_right"><a class="smiley_link" href="http://www.greensmilies.com/smilie-album/" target="_blank">WWW.GREENSMILIES.COM</a></div>' +
7453 '<hr>' +
7454 '<div class="box_content" style="overflow: hidden;"><hr></div>' +
7455 '</div></div><br>').insertAfter(".texteditor");
7456
7457 SmileyBox.addSmileys("standard", "");
7458
7459 $('.group').click(function () {
7460 $('.group.active').removeClass("active");
7461 $(this).addClass("active");
7462 // Change smiley group
7463 SmileyBox.addSmileys(this.className.split(" ")[1], "");
7464 });
7465 },
7466
7467 // add smiley box
7468 add: function (e) {
7469 var bbcodeBarId = "";
7470 switch (e) {
7471 case "/alliance_forum/forum":
7472 bbcodeBarId = "#forum";
7473 break;
7474 case "/message/forward":
7475 bbcodeBarId = "#message_bbcodes";
7476 break;
7477 case "/message/new":
7478 bbcodeBarId = "#message_bbcodes";
7479 break;
7480 case "/message/view":
7481 bbcodeBarId = "#message_bbcodes";//setWonderIconsOnMap
7482 break;
7483 case "/player_memo/load_memo_content":
7484 bbcodeBarId = "#memo_edit"; // old notes
7485 break;
7486 case "/frontend_bridge/fetch":
7487 bbcodeBarId = ".notes_container"; // TODO: new notes
7488 break;
7489 }
7490 if (($(bbcodeBarId + ' #emots_popup_7').get(0) || $(bbcodeBarId + ' #emots_popup_15').get(0)) && PID == 84367) {
7491 $(bbcodeBarId + " .bb_button_wrapper").get(0).lastChild.remove();
7492 }
7493 $('<img class="smiley_button" src="http://www.greensmilies.com/smile/smiley_emoticons_smile.gif">').appendTo(bbcodeBarId + ' .bb_button_wrapper');
7494
7495 $('<div class="smiley_box game">' +
7496 '<div class="bbcode_box middle_center"><div class="bbcode_box middle_right"></div><div class="bbcode_box middle_left"></div>' +
7497 '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div><div class="bbcode_box top_center"></div>' +
7498 '<div class="bbcode_box bottom_center"></div><div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>' +
7499 '<div class="box_header">' +
7500 '<span class="group standard active">' + getText("labels", "std") + '</span>' +
7501 '<span class="group grepolis">' + getText("labels", "gre") + '</span>' +
7502 '<span class="group nature">' + getText("labels", "nat") + '</span>' +
7503 '<span class="group people">' + getText("labels", "ppl") + '</span>' +
7504 '<span class="group ' + (SmileyBox.isHalloween ? 'halloween' : (SmileyBox.isXmas ? 'xmas' : 'other')) + '">' + getText("labels", (SmileyBox.isHalloween ? 'hal' : (SmileyBox.isXmas ? 'xma' : 'oth'))) + '</span>' +
7505 '</div>' +
7506 '<hr>' +
7507 '<div class="box_content"></div>' +
7508 '<hr>' +
7509 '<div class="box_footer"><a href="http://www.greensmilies.com/smilie-album/" target="_blank">WWW.GREENSMILIES.COM</a></div>' +
7510 '</div>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
7511
7512
7513 $(bbcodeBarId + ' .group').click(function () {
7514 $('.group.active').removeClass("active");
7515 $(this).addClass("active");
7516 // Change smiley group
7517 SmileyBox.addSmileys(this.className.split(" ")[1], "#" + $(this).closest('.bb_button_wrapper').parent().get(0).id);
7518 });
7519
7520 SmileyBox.addSmileys("standard", bbcodeBarId);
7521
7522 // smiley box toggle
7523 $(bbcodeBarId + " .smiley_button").toggleClick(
7524 function () {
7525 this.src = smileyArray.button[0].src;
7526 $(this).closest('.bb_button_wrapper').find(".smiley_box").get(0).style.display = "block";
7527 },
7528 function () {
7529 this.src = smileyArray.button[1].src;
7530 $(this).closest('.bb_button_wrapper').find(".smiley_box").get(0).style.display = "none";
7531 }
7532 );
7533 },
7534
7535 // insert smileys from arrays into smiley box
7536 addSmileys: function (type, bbcodeBarId) {
7537 // reset smilies
7538 if ($(bbcodeBarId + " .box_content").get(0)) {
7539 $(bbcodeBarId + " .box_content").get(0).innerHTML = '';
7540 }
7541 // add smilies
7542 for (var e in smileyArray[type]) {
7543 if (smileyArray[type].hasOwnProperty(e)) {
7544 $(smileyArray[type][e]).clone().appendTo(bbcodeBarId + " .box_content");
7545 //$('<img class="smiley" src="' + smileyArray[type][e].src + '" alt="" />').appendTo(bbcodeBarId + " .box_content");
7546 }
7547 }
7548 $('.smiley').css({margin: '0px', padding: '2px', maxHeight: '35px', cursor: 'pointer'});
7549
7550 $(bbcodeBarId + " .box_content .smiley").click(function () {
7551 var textarea;
7552 if (uw.location.pathname.indexOf("game") >= 0) {
7553 // hide smiley box
7554 $(this).closest('.bb_button_wrapper').find(".smiley_button").click();
7555 // find textarea
7556 textarea = $(this).closest('.gpwindow_content').find("textarea").get(0);
7557 } else {
7558
7559 if ($('.editor_textbox_container').get(0)) {
7560 textarea = $('.editor_textbox_container .cke_contents textarea').get(0);
7561 } else {
7562 $(this).appendTo('iframe .forum');
7563 }
7564 }
7565 var text = $(textarea).val();
7566 $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + "[img]" + this.src + "[/img]" + text.substring($(textarea).get(0).selectionEnd));
7567 });
7568 }
7569 };
7570
7571
7572 /*******************************************************************************************************************************
7573 * Biremes counter
7574 * ----------------------------------------------------------------------------------------------------------------------------
7575 * | â— Incremental update when calling a city (experimental, especially intended for siege worlds)
7576 * ----------------------------------------------------------------------------------------------------------------------------
7577 * @deprecated
7578 * *****************************************************************************************************************************/
7579
7580 // TODO: Altes Feature entfernen
7581 var BiremeCounter = {
7582 activate: function () {
7583 $(".picomap_container").prepend("<div id='available_units'><div id='bi_count'></div></div>");
7584
7585 $('.picomap_overlayer').tooltip(getText("options", "bir")[0]);
7586 BiremeCounter.update();
7587
7588 // Style
7589 $('<style id="dio_bireme_counter">' +
7590 '#available_units { background: url(https://gpall.innogamescdn.com/images/game/units/units_sprite_90x90_compressed.jpg); height:90px;' +
7591 'width:90px; position: relative; margin: 5px 28px 0px 28px; background-position: -270px 0px; } ' +
7592 '#bi_count { color:#826021; position:relative; top:28px; font-style:italic; width:79px; } ' +
7593 '#sea_id { background: none; font-size:25px; cursor:default; height:50px; width:50px; position:absolute; top:70px; left:157px; z-index: 30; } ' +
7594 '</style>').appendTo('head');
7595
7596 // fs_count: color: #FFC374;position: relative;top: 30px;font-style: italic;width: 101px;text-shadow: 1px 1px 0px rgb(69, 0, 0);
7597 // manti: background-position: -1350px 180px;
7598 // manti-count: color: #ECD181;position: relative;top: 48px;font-style: italic;width: 52px;text-shadow: 2px 2px 0px rgb(0, 0, 0);
7599 // medusa:-1440px 182px;
7600 // med-count: color: #DEECA4;position: relative;top: 50px;font-style: italic;width: 55px;text-shadow: 2px 2px 0px rgb(0, 0, 0);
7601
7602 // Set Sea-ID beside the bull eye
7603 $('#sea_id').prependTo('#ui_box');
7604 },
7605 deactivate: function () {
7606 $('#available_units').remove();
7607 $('#dio_bireme_counter').remove();
7608 $('#sea_id').appendTo('.picomap_container');
7609 },
7610 save: function () {
7611 saveValue(WID + "_biremes", JSON.stringify(biriArray));
7612 },
7613 update: function () {
7614 var sum = 0, e;
7615 if ($('#bi_count').get(0)) {
7616 for (e in biriArray) {
7617 if (biriArray.hasOwnProperty(e)) {
7618 if (!uw.ITowns.getTown(e)) { // town is no longer in possession of user
7619 delete biriArray[e];
7620 BiremeCounter.save();
7621 } else {
7622 sum += parseInt(biriArray[e], 10);
7623 }
7624 }
7625 }
7626
7627 sum = sum.toString();
7628 var str = "", fsize = ['1.4em', '1.2em', '1.15em', '1.1em', '1.0em'], i;
7629
7630 for (i = 0; i < sum.length; i++) {
7631 str += "<span style='font-size:" + fsize[i] + "'>" + sum[i] + "</span>";
7632 }
7633 $('#bi_count').get(0).innerHTML = "<b>" + str + "</b>";
7634 }
7635 },
7636 get: function () {
7637 var biremeIn = parseInt(uw.ITowns.getTown(uw.Game.townId).units().bireme, 10),
7638 biremeOut = parseInt(uw.ITowns.getTown(uw.Game.townId).unitsOuter().bireme, 10);
7639 if (isNaN(biremeIn)) biremeIn = 0;
7640 if (isNaN(biremeOut)) biremeOut = 0;
7641 if (!biriArray[uw.Game.townId] || biriArray[uw.Game.townId] < (biremeIn + biremeOut)) {
7642 biriArray[uw.Game.townId] = biremeIn;
7643 }
7644 BiremeCounter.update();
7645 BiremeCounter.save();
7646 },
7647 getDocks: function () {
7648 var windowID = uw.BuildingWindowFactory.getWnd().getID(),
7649 biremeTotal = parseInt($('#gpwnd_' + windowID + ' #unit_order_tab_bireme .unit_order_total').get(0).innerHTML, 10);
7650
7651 if (!isNaN(biremeTotal)) biriArray[uw.Game.townId] = biremeTotal;
7652 BiremeCounter.update();
7653 BiremeCounter.save();
7654 },
7655 getAgora: function () {
7656 var biremeTotal = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().bireme, 10);
7657 if (isNaN(biremeTotal)) biremeTotal = 0;
7658
7659 $('#units_beyond_list .bireme').each(function () {
7660 biremeTotal += parseInt(this.children[0].innerHTML, 10);
7661 });
7662 biriArray[uw.Game.townId] = biremeTotal;
7663 BiremeCounter.update();
7664 BiremeCounter.save();
7665 }
7666 };
7667
7668 /*******************************************************************************************************************************
7669 * Favor Popup
7670 * ----------------------------------------------------------------------------------------------------------------------------
7671 * | â— Improved favor popup
7672 * ----------------------------------------------------------------------------------------------------------------------------
7673 *******************************************************************************************************************************/
7674 var FavorPopup = {
7675 godArray: {
7676 zeus: '0px',
7677 hera: '-152px',
7678 poseidon: '-101px',
7679 athena: '-50px',
7680 hades: '-203px',
7681 artemis: '-305px'
7682 }, godImg: (new Image()).src = "https://diotools.de/images/game/gods.png",
7683
7684 activate: function () {
7685 $('.gods_favor_button_area, #favor_circular_progress').bind('mouseover mouseout', function () {
7686 return false;
7687 });
7688 $('.gods_area').bind('mouseover', function () {
7689 FavorPopup.setFavorPopup();
7690 });
7691 },
7692
7693 deactivate: function () {
7694 $('.gods_favor_button_area, #favor_circular_progress').unbind('mouseover mouseout');
7695 $('.gods_area').unbind('mouseover');
7696 },
7697
7698 setFavorPopup: function () {
7699 var pic_row = "", fav_row = "", prod_row = "", tooltip_str;
7700
7701 for (var g in FavorPopup.godArray) {
7702 if (FavorPopup.godArray.hasOwnProperty(g)) {
7703 if (uw.ITowns.player_gods.attributes.temples_for_gods[g]) {
7704 pic_row += '<td><div style="width:50px;height:51px;background:url(' + FavorPopup.godImg + ');background-position: 0px ' + FavorPopup.godArray[g] + ';"></td>';
7705 fav_row += '<td class="bold" style="color:blue">' + uw.ITowns.player_gods.attributes[g + "_favor"] + '</td>';
7706 prod_row += '<td class="bold">' + uw.ITowns.player_gods.attributes.production_overview[g].production + '</td>';
7707 }
7708 }
7709 }
7710 tooltip_str = $('<table><tr><td></td>' + pic_row + '</tr>' +
7711 '<tr align="center"><td><img src="https://gpall.innogamescdn.com/images/game/res/favor.png"></td>' + fav_row + '</tr>' +
7712 '<tr align="center"><td>+</td>' + prod_row + '</tr>' +
7713 '</table>');
7714
7715 $('.gods_favor_button_area, #favor_circular_progress').tooltip(tooltip_str);
7716 }
7717 };
7718
7719 /*******************************************************************************************************************************
7720 * GUI Optimization
7721 * ----------------------------------------------------------------------------------------------------------------------------
7722 * | â— Modified spell box (smaller, moveable & position memory)
7723 * | â— Larger taskbar and minimize daily reward-window on startup
7724 * | â— Modify chat
7725 * | â— Improved display of troops and trade activity boxes (movable with position memory on startup)
7726 * ----------------------------------------------------------------------------------------------------------------------------
7727 *******************************************************************************************************************************/
7728
7729 var Spellbox = {
7730 observe: function () {
7731 $.Observer(uw.GameEvents.ui.layout_gods_spells.rendered).subscribe('DIO_SPELLBOX_CHANGE_OPEN', function () {
7732 if (spellbox.show == false) {
7733 spellbox.show = true;
7734 saveValue("spellbox", JSON.stringify(spellbox));
7735 }
7736 Spellbox.change();
7737 });
7738 $.Observer(uw.GameEvents.ui.layout_gods_spells.state_changed).subscribe('DIO_SPELLBOX_CLOSE', function () {
7739 spellbox.show = false;
7740 saveValue("spellbox", JSON.stringify(spellbox));
7741 });
7742
7743 // GRCRT Bug-Fix
7744 if(typeof(RepConv) !== "undefined") {
7745 $.Observer(uw.GameEvents.ui.layout_gods_spells.rendered).unsubscribe('GRCRT_GRC_ui_layout_gods_spells_rendered');
7746
7747 $.Observer(uw.GameEvents.ui.layout_gods_spells.rendered).subscribe('GRCRT_GRC_ui_layout_gods_spells_rendered', function () {
7748 // PlayerGods doesn't exists at game start and the function would call an error
7749 if (typeof(RepConv.models.PlayerGods) !== "undefined") {
7750 RepConvTool.loadPower();
7751 }
7752 });
7753 }
7754 },
7755
7756 activate: function () {
7757 Spellbox.observe();
7758 Spellbox.change();
7759
7760 $('<style id="dio_spellbox_style" type="text/css">' +
7761 // Don't hide hero box, unit time box and hero coin box from GRC
7762 '#ui_box .nui_right_box { overflow: visible; } ' +
7763 // Hide negative spells
7764 '#ui_box .bolt, #ui_box .earthquake, #ui_box .pest { display: none } ' +
7765 // Change spell order
7766 '#ui_box .god_container { float: left } ' +
7767 '#ui_box .god_container[data-god_id="zeus"], #ui_box .god_container[data-god_id="athena"] { float: none } ' +
7768 // Remove background
7769 '#ui_box .powers_container { background: none !important } ' +
7770 // Hide god titles
7771 '#ui_box .content .title { display: none !important } ' +
7772 // Hide border elements
7773 '#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 } ' +
7774 // Layout
7775 '#ui_box .gods_area { height:150px } ' +
7776
7777 '#ui_box .gods_spells_menu { width: 134px; position:absolute; z-index:5000; padding:30px 0px 0px -4px } ' +
7778 '#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 } ' +
7779
7780 '#ui_box .nui_units_box { display:block; margin-top:-8px; position:relative } ' +
7781 '#ui_box .nui_units_box .bottom_ornament { margin-top:-28px; position: relative } ' +
7782 '</style>').appendTo('head');
7783
7784 // Draggable Box
7785 $("#ui_box .gods_spells_menu").draggable({
7786 containment: "body",
7787 distance: 10,
7788 snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, #island_quests_overview",
7789 opacity: 0.7,
7790 stop: function () {
7791 spellbox.top = this.style.top;
7792 spellbox.left = this.style.left;
7793
7794 saveValue("spellbox", JSON.stringify(spellbox));
7795 }
7796 });
7797 $("#ui_box .gods_spells_menu").before($('#ui_box .nui_units_box'));
7798
7799 // Position
7800 $('#ui_box .gods_spells_menu').css({
7801 left: spellbox.left,
7802 top: spellbox.top
7803 });
7804
7805 // Active at game start?
7806 if (spellbox.show && !$('#ui_box .btn_gods_spells').hasClass('active')) {
7807 $('#ui_box .btn_gods_spells').click();
7808 }
7809 },
7810 deactivate: function () {
7811 $('#ui_box .gods_spells_menu').draggable('destroy');
7812
7813 // Position
7814 $('#ui_box .gods_spells_menu').css({
7815 left: "auto",
7816 top: "150px"
7817 });
7818
7819 //$("#ui_box .gods_spells_menu").appendTo('gods_area'); // ?
7820
7821 $('#dio_spellbox_style').remove();
7822
7823 $.Observer(GameEvents.ui.layout_gods_spells.rendered).unsubscribe('DIO_SPELLBOX_CHANGE_OPEN');
7824 $.Observer(GameEvents.ui.layout_gods_spells.state_changed).unsubscribe('DIO_SPELLBOX_CLOSE');
7825 },
7826
7827 change: function () {
7828 //console.log("Unitsbox: "+ $(".nui_units_box").height());
7829 //console.log("Spellbox: "+ $(".gods_spells_menu").height());
7830
7831 // Change spell order
7832 $('#ui_box .god_container[data-god_id="poseidon"]').prependTo('#ui_box .gods_spells_menu .content');
7833 $('#ui_box .god_container[data-god_id="athena"]').appendTo('#ui_box .gods_spells_menu .content');
7834 $('#ui_box .god_container[data-god_id="artemis"]').appendTo('#ui_box .gods_spells_menu .content');
7835 }
7836
7837 };
7838
7839
7840 // Minimize Daily reward window on startup
7841 function minimizeDailyReward() {
7842 /*
7843 $.Observer(uw.GameEvents.window.open).subscribe('DIO_WINDOW', function(u,dato){});
7844 $.Observer(uw.GameEvents.window.reload).subscribe('DIO_WINDOW2', function(f){});
7845 */
7846 if (MutationObserver) {
7847 var startup = new MutationObserver(function (mutations) {
7848 mutations.forEach(function (mutation) {
7849 if (mutation.addedNodes[0]) {
7850 if ($('.daily_login').get(0)) { // && !uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).isMinimized()
7851 $('.daily_login').find(".minimize").click();
7852 //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).minimize();
7853 }
7854 }
7855 });
7856 });
7857 startup.observe($('body').get(0), {attributes: false, childList: true, characterData: false});
7858
7859 setTimeout(function () {
7860 startup.disconnect();
7861 }, 3000);
7862 }
7863 }
7864
7865 // Larger taskbar
7866 var Taskbar = {
7867 activate: function () {
7868 $('.minimized_windows_area').get(0).style.width = "150%";
7869 $('.minimized_windows_area').get(0).style.left = "-25%";
7870 },
7871 deactivate: function () {
7872 $('.minimized_windows_area').get(0).style.width = "100%";
7873 $('.minimized_windows_area').get(0).style.left = "0%";
7874 }
7875 };
7876
7877 // Hide fade out buttons
7878 function hideNavElements() {
7879 if (Game.premium_features.curator <= Timestamp.now()) {
7880 $('.nav').each(function () {
7881 this.style.display = "none";
7882 });
7883 }
7884 }
7885
7886 /*******************************************************************************************************************************
7887 * Chat
7888 *******************************************************************************************************************************/
7889
7890 var Chat = {
7891 user_colors : {},
7892
7893 delay : 10000,
7894
7895 timestamp : 0,
7896
7897 isWindowFocused : true,
7898
7899 isActivated : false,
7900
7901 isOpened : false,
7902
7903 activate : function(){
7904
7905 Chat.isActivated = true;
7906
7907 Chat.isOpened = true;
7908
7909 $('<style id="dio_chat_style">'+
7910 '#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; }'+
7911 '#dio_chat.resize { transition: left 0s; }'+
7912
7913 '#dio_chat .slider { width:100%; height: 6px; top:0; right:1px; position:absolute; margin-left:-8px; cursor: row-resize; }'+
7914
7915 '#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; }'+
7916 '#dio_chat .messagebox .time { float:left; color: #686; }'+
7917 '#dio_chat .messagebox .user { float:left; }'+
7918 '#dio_chat .messagebox .text { word-break: break-word; color: #797; }'+
7919
7920 '#dio_chat .messagebox .welcome .text { color: rgb(200,220,200); }'+
7921
7922 '#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; }'+
7923 '#dio_chat .togglebutton .top { height:4px; width:24px; background: url(https://diotools.de/images/game/button_sprite_vertical.png) 0px -1px; position:absolute;}'+
7924 '#dio_chat .togglebutton:hover .top { background-position: -25px -1px; }'+
7925 '#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; }'+
7926 '#dio_chat .togglebutton:hover .bottom { background-position: -25px 4px; }'+
7927 '#dio_chat .togglebutton .middle { height:100%; width:24px; background: url(https://diotools.de/images/game/button_sprite_vertical.png) -50px 0px; }'+
7928 '#dio_chat .togglebutton:hover .middle { background-position: -75px 0px; }'+
7929 '#dio_chat .togglebutton .arrow { position:absolute; left:6px; top:42.5%; }'+
7930
7931 '#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; }'+
7932
7933 '#dio_chat input { background: rgba(0, 0, 0, 0.5); color: white; border: 0px none; padding: 8px; width: 100%; border-right: 1px solid darkgreen; }'+
7934 '#dio_chat input:hover { background: rgba(0, 0, 10, 0.4); }'+
7935 '#dio_chat input:focus { background: rgba(0, 0, 10, 0.4); }'+
7936 '#dio_chat input::placeholder, '+
7937 '#dio_chat input::-webkit-input-placeholder, '+
7938 '#dio_chat input::-moz-placeholder, ' +
7939 '#dio_chat input:-ms-input-placeholder, '+
7940 '#dio_chat input:-moz-placeholder { color: black; }'+
7941
7942 // Chat im Menü ausblenden
7943 '.nui_main_menu ul { height:auto !important; }'+
7944 '.nui_main_menu li.chat { display:none !important; }'+
7945
7946 '#grcgrc { display:none }'+
7947
7948 '</style>').appendTo('head');
7949
7950 $('<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");
7951
7952 $('<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");
7953
7954 $('<div class="togglebutton"><div class="top"></div><div class="middle"><div class="arrow">â—„</div></div><div class="bottom"></div></div>').appendTo("#dio_chat");
7955
7956 // Texteingabe
7957 $('#dio_chat input').keypress(function(e) {
7958
7959 if (e.keyCode === 13) {
7960
7961 var _time = $('.server_time_area').get(0).innerHTML.split(" ")[0];
7962
7963 var _message = $(this).val();
7964
7965 if(_message.length > 0) {
7966
7967 Chat.sendMessage(_message);
7968
7969 $(this).val('');
7970 }
7971
7972 }
7973 });
7974
7975 /*
7976 $('#dio_chat').draggable({
7977 containment: "body",
7978 distance: 10,
7979 snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, #island_quests_overview",
7980 opacity: 0.7,
7981 stop: function () {}
7982 });
7983 */
7984
7985 // Ein-/Ausblenden der Chatbox
7986 $('#dio_chat .togglebutton').toggleClick(
7987 function () {
7988
7989 var x = -($(window).width() * 0.25 + 16);
7990
7991 $('#dio_chat').css("left", x);
7992
7993 setTimeout(function(){
7994 $('#dio_chat .togglebutton .arrow').get(0).innerHTML = "â–º";
7995 },1300);
7996
7997 // Tooltip
7998 $('#dio_chat .togglebutton').tooltip("Chat öffnen");
7999
8000 },
8001 function (){
8002
8003 $('#dio_chat').css("left", 0);
8004
8005 setTimeout(function(){
8006 $('#dio_chat .togglebutton .arrow').get(0).innerHTML = "â—„";
8007 },1300);
8008
8009 // Tooltip
8010 $('#dio_chat .togglebutton').tooltip("Chat schließen");
8011 }
8012 );
8013 // Wenn sich die Fenstergröße ändert
8014
8015 $(window).on("resize.dio", function(){
8016
8017 if($('#dio_chat').css("left") !== "0px"){
8018
8019 var x = -($(window).width() * 0.25 + 16);
8020
8021 $('#dio_chat').addClass("resize");
8022 $('#dio_chat').css("left", x);
8023
8024 setTimeout(function(){
8025 $('#dio_chat').removeClass("resize");
8026 },0);
8027 }
8028 });
8029
8030 // Tooltip
8031 $('#dio_chat .togglebutton').tooltip("Chat schließen");
8032
8033 // Skalierung der Höhe
8034 $('#dio_chat .slider').mousedown(function (e) {
8035 e.preventDefault();
8036
8037 $('#dio_chat .messagebox').css("max-height", "none");
8038
8039 $(document).on("mousemove.dio", function (e) {
8040 e.preventDefault();
8041
8042 var x = $(window).height() - e.pageY - 49;
8043
8044 if (x > 30 && x < $(window).height() - 400) {
8045 $('#dio_chat .messagebox').css("height", x );
8046 }
8047 });
8048 });
8049
8050 $(document).on("mouseup.dio", function (e) {
8051 $(document).off("mousemove.dio");
8052
8053 //$('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollTopMax;
8054 $('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollHeight
8055 });
8056
8057
8058
8059 Chat.timestamp = Timestamp.server();
8060
8061 // Initialer Start
8062 Chat.getMessages();
8063
8064
8065 // Öfter anfragen, wenn man chatten will
8066 $('#dio_chat').hover(function(){
8067
8068 if(Chat.isOpened === true) {
8069 Chat.delay = 3000; // 3s
8070
8071 clearTimeout(Chat.timeout_A);
8072 clearTimeout(Chat.timeout_B);
8073 }
8074
8075 }, function(){
8076
8077 if(Chat.isOpened === true) {
8078
8079 Chat.delay = 10000; // 10s
8080
8081 // Nach 5min nur noch alle 30s
8082 Chat.timeout_A = setTimeout(function () {
8083 Chat.delay = 30000;
8084 }, 300000);
8085
8086 // Nach 15min nur noch alle 60s
8087 Chat.timeout_B = setTimeout(function () {
8088 Chat.delay = 60000;
8089 }, 900000);
8090 }
8091 });
8092
8093 // Nur wenn Grepolis offen ist aktualisieren
8094 $(window).on("focus.dio", function() {
8095 Chat.isWindowFocused = true;
8096
8097 if(Chat.isOpened === true) {
8098
8099 Chat.getMessages();
8100
8101 Chat.delay = 10000; // 10s
8102
8103 clearTimeout(Chat.timeout_A);
8104 clearTimeout(Chat.timeout_B);
8105
8106 // Nach 5min nur noch alle 30s
8107 Chat.timeout_A = setTimeout(function () {
8108 Chat.delay = 30000;
8109 }, 300000);
8110
8111 // Nach 15min nur noch alle 60s
8112 Chat.timeout_B = setTimeout(function () {
8113 Chat.delay = 60000;
8114 }, 900000);
8115 }
8116
8117 }).on("blur.dio", function() {
8118 Chat.isWindowFocused = false;
8119 });
8120 },
8121 deactivate : function(){
8122 Chat.isActivated = false;
8123
8124 $('#dio_chat_style').remove();
8125 $('#dio_chat').remove();
8126
8127 // Events disconnecten
8128 $(document).off('mouseup.dio');
8129 $(window).off('focus.dio');
8130 $(window).off('blur.dio');
8131 $(window).off('resize.dio');
8132 },
8133 sendMessage : function(_message){
8134
8135 _message = encodeURIComponent(_message.replace(/'/g, "'").replace(/ /g, " "));
8136
8137 $.ajax({
8138 type: "GET",
8139 url: "https://diotools.de/php/sendMessage.php?world=" + Game.world_id + "&time=" + Timestamp.server() + "&player="+ Game.player_name +"&message="+ _message,
8140 dataType: 'text',
8141 success: function (response) {
8142 console.debug("Nachricht wurde erfolgreich gesendet");
8143
8144 //$('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollTopMax;
8145 $('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollHeight
8146
8147 Chat.getMessages();
8148 },
8149 error: function (e) {
8150 console.debug("Nachricht konnte nicht gesendet werden", e);
8151 }
8152 });
8153 },
8154 getMessages : function(){
8155
8156 if(Chat.isActivated === true) {
8157
8158 var _currentTimestamp = Timestamp.server();
8159
8160 var _url = "https://diotools.de/php/getMessages.php?world=" + Game.world_id;
8161
8162 if (typeof(Chat.lastID) !== "undefined") {
8163 _url += "&id=" + Chat.lastID;
8164 }
8165 else {
8166 _url += "&time=" + Chat.timestamp;
8167 }
8168
8169 // Eventuell noch nicht gefeuertes Timeout entfernen
8170 clearTimeout(Chat.timeout);
8171
8172 if (Chat.isWindowFocused) {
8173 $.ajax({
8174 type: "GET",
8175 url: _url,
8176 dataType: 'json',
8177 success: function (_messages) {
8178 if(Chat.isActivated === true) {
8179
8180 // Letzte Abfragezeit speichern
8181 Chat.timestamp = _currentTimestamp;
8182
8183 // console.debug("GET MESSAGES", _messages);
8184
8185 /*
8186 var _scrollDown = false;
8187 if ($('#dio_chat .messagebox')[0].scrollTop === $('#dio_chat .messagebox')[0].scrollTopMax) {
8188 _scrollDown = true;
8189 }
8190 */
8191
8192 for (var m in _messages) {
8193 if (_messages.hasOwnProperty(m)) {
8194
8195 if (typeof(_messages[m].last_id) === "undefined") {
8196
8197 // HTML-Tags ersetzen
8198 var _message = _messages[m].message.replace(/</g, '<').replace(/>/g, '>').replace(/'/g, "\'");
8199
8200 $('#dio_chat .messagebox').append(
8201 '<div class="time">' + Chat.formatTime(_messages[m].time) + ': </div>' +
8202 '<div class="user" style="color:' + Chat.getUserColor(_messages[m].player) + '">' + _messages[m].player + ': </div>' +
8203 '<div class="text"> ' + _message + ' </div>'
8204 );
8205 }
8206 else {
8207 Chat.lastID = _messages[m].last_id;
8208 }
8209 }
8210 }
8211
8212 clearTimeout(Chat.timeout);
8213
8214 Chat.timeout = setTimeout(function () {
8215
8216 if (Chat.isWindowFocused) {
8217 Chat.getMessages();
8218 }
8219
8220 }, Chat.delay);
8221
8222 //if(_scrollDown) {
8223 // $('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollTopMax;
8224 $('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollHeight
8225 //}
8226 }
8227 },
8228 error: function (xhr) {
8229 console.debug("Nachrichten konnten nicht geladen werden", xhr);
8230
8231 clearTimeout(Chat.timeout);
8232
8233 Chat.timeout = setTimeout(function () {
8234
8235 Chat.getMessages();
8236
8237 }, Chat.delay);
8238
8239 }
8240 });
8241
8242 }
8243 }
8244 },
8245 getUserColor : function(_user){
8246
8247 if(typeof(Chat.user_colors[_user]) === "undefined") {
8248
8249 var r = Math.floor(Math.random() * 255);
8250 var g = Math.floor(Math.random() * 255);
8251 var b = Math.floor(Math.random() * 255);
8252
8253 // Bei zu dunkler Farbe neue Farbe ermitteln
8254 if (r + g < 200 && r < 130 && g < 130) {
8255
8256 return Chat.getUserColor(_user);
8257 }
8258
8259 Chat.user_colors[_user] = 'rgb(' + r + ',' + g + ',' + b + ')';
8260 }
8261
8262 return Chat.user_colors[_user];
8263 },
8264 formatTime : function(_timestamp){
8265
8266 var date = new Date(_timestamp*1000);
8267
8268 // Hours part from the timestamp
8269 var hours = "0" + date.getHours();
8270 // Minutes part from the timestamp
8271 var minutes = "0" + date.getMinutes();
8272 // Seconds part from the timestamp
8273 var seconds = "0" + date.getSeconds();
8274
8275 // Will display time in 10:30:23 format
8276 return hours.substr(-2) + ':' + minutes.substr(-2) + ':' + seconds.substr(-2);
8277 }
8278 };
8279
8280 /*******************************************************************************************************************************
8281 * Activity boxes
8282 * ----------------------------------------------------------------------------------------------------------------------------
8283 * | â— Show troops and trade activity boxes
8284 * | â— Boxes are magnetic & movable (position memory)
8285 * ----------------------------------------------------------------------------------------------------------------------------
8286 *******************************************************************************************************************************/
8287 var mut_toolbar, mut_command, mut_trade;
8288
8289 var save_command_mouseout,
8290 save_commandlist_mouseout,
8291 save_trade_mouseout,
8292 save_tradelist_mouseout,
8293
8294 save_command_mouseover,
8295 save_trade_mouseover;
8296
8297
8298 var ActivityBoxes = {
8299 activate: function () {
8300 ActivityBoxes.checkToolbarAtStart();
8301
8302 $('#toolbar_activity_commands_list').css({
8303 left: commandbox.left + "px",
8304 top: commandbox.top + "px"
8305 });
8306
8307 $('<style id="fix_lists" type="text/css">' +
8308 '#toolbar_activity_commands_list, #toolbar_activity_trades_list { width: 160px}' +
8309 '.dropdown-list .content { max-height: 329px}' +
8310 '</style>' +
8311 '<style id="dio_fix_trade" type="text/css">' +
8312 '#toolbar_activity_trades_list {' +
8313 'left:' + tradebox.left + 'px !important;' +
8314 'top: ' + tradebox.top + 'px !important}' +
8315 '</style>').appendTo('head');
8316
8317
8318 ActivityBoxes.draggableTradeBox();
8319 ActivityBoxes.draggableCommandBox();
8320
8321 ActivityBoxes.catchToolbarEvents();
8322 },
8323 deactivate: function () {
8324 ActivityBoxes.hideTradeList();
8325 ActivityBoxes.hideCommandList();
8326
8327 mut_toolbar.disconnect();
8328 mut_command.disconnect();
8329 mut_trade.disconnect();
8330 },
8331 showTradeList: function () {
8332 if (!$('#dio_trades_activity_style').get(0)) {
8333 $('#toolbar_activity_trades').mouseover();
8334 $('<style id="dio_trades_activity_style"> #toolbar_activity_trades_list { display: block !important; } </style>').appendTo("head");
8335 }
8336 },
8337 showCommandList: function () {
8338 if (!$('#dio_commands_activity_style').get(0)) {
8339 $('#toolbar_activity_commands').mouseover();
8340 $('<style id="dio_commands_activity_style"> #toolbar_activity_commands_list { ' +
8341 'display:block !important; left:' + commandbox.left + 'px; top:' + commandbox.top + 'px; }' +
8342 '</style>').appendTo("head");
8343 }
8344 },
8345 hideTradeList: function () {
8346 if ($('#dio_trades_activity_style').get(0)) {
8347 $('#dio_trades_activity_style').remove();
8348 $('#toolbar_activity_trades').mouseout();
8349 }
8350 },
8351 hideCommandList: function () {
8352 if ($('#dio_commands_activity_style').get(0)) {
8353 $('#dio_commands_activity_style').remove();
8354 $('#toolbar_activity_commands').mouseout();
8355 }
8356 },
8357 activate2: function () {
8358 var observe_options = {attributes: false, childList: true, characterData: false};
8359
8360 ActivityBoxes.catchToolbarEvents();
8361
8362 mut_command.observe($('.toolbar_activities .commands .count').get(0), observe_options);
8363 mut_trade.observe($('.toolbar_activities .trades .count').get(0), observe_options);
8364
8365 $('<style id="dio_activity_style"> ' +
8366 '#toolbar_activity_commands_list.active { display: block !important; } ' +
8367 '#toolbar_activity_trades_list.active { display: block !important; } ' +
8368 '</style>').appendTo("head");
8369
8370
8371 $('#toolbar_activity_commands').mouseover();
8372 $('#toolbar_activity_trades').mouseover();
8373
8374 $('#toolbar_activity_commands, #toolbar_activity_trades').off("mouseover");
8375
8376 $('#toolbar_activity_commands, #toolbar_activity_commands_list, #toolbar_activity_trades, #toolbar_activity_trades_list').off("mouseout");
8377
8378 $('#toolbar_activity_trades_list').unbind("click");
8379 //console.log($('#toolbar_activity_commands').data('events')["dd:list:show"][0].handler());
8380
8381 ActivityBoxes.checkToolbarAtStart();
8382
8383 $('#toolbar_activity_commands_list').css({
8384 left: commandbox.left + "px",
8385 top: commandbox.top + "px"
8386 });
8387
8388 $('<style id="fix_lists" type="text/css">' +
8389 '#toolbar_activity_commands_list, #toolbar_activity_trades_list { width: 160px}' +
8390 '.dropdown-list .content { max-height: 329px}' +
8391 '</style>' +
8392 '<style id="dio_fix_trade" type="text/css">' +
8393 '#toolbar_activity_trades_list {' +
8394 'left:' + tradebox.left + 'px !important;' +
8395 'top: ' + tradebox.top + 'px !important}' +
8396 '</style>').appendTo('head');
8397
8398 ActivityBoxes.draggableCommandBox();
8399 ActivityBoxes.draggableTradeBox();
8400
8401
8402 /*
8403 $('.toolbar_activities .commands').on("mouseover.bla", function(){
8404 $('#toolbar_activity_commands_list').addClass("active");
8405 });
8406
8407 $('.toolbar_activities .trades').mouseover(function(){
8408 $('#toolbar_activity_trades_list').addClass("active");
8409 });
8410 */
8411 },
8412 deactivate2: function () {
8413 mut_toolbar.disconnect();
8414 mut_command.disconnect();
8415 mut_trade.disconnect();
8416 /*
8417 $('#toolbar_activity_commands').on("mouseover", save_command_mouseover);
8418 $('#toolbar_activity_trades').on("mouseover", save_trade_mouseover);
8419
8420 $('#toolbar_activity_commands').on("mouseout", save_command_mouseout);
8421 $('#toolbar_activity_commands_list').on("mouseout", save_commandlist_mouseout);
8422 $('#toolbar_activity_trades').on("mouseout", save_trade_mouseout);
8423 $('#toolbar_activity_trades_list').on("mouseout", save_tradelist_mouseout);
8424 */
8425
8426 $('#toolbar_activity_commands').mouseover = save_command_mouseover;
8427 $('#toolbar_activity_trades').mouseover = save_trade_mouseover;
8428
8429 $('#toolbar_activity_commands').mouseout = save_command_mouseout;
8430 $('#toolbar_activity_commands_list').mouseout = save_commandlist_mouseout;
8431 $('#toolbar_activity_trades').mouseout = save_trade_mouseout;
8432 $('#toolbar_activity_trades_list').mouseout = save_tradelist_mouseout;
8433
8434
8435 $('#toolbar_activity_trades_list').removeClass("active");
8436 $('#toolbar_activity_commands_list').removeClass("active");
8437 /*
8438 $('.toolbar_activities .commands').off("mouseover.bla");
8439 */
8440 $('#dio_activity_style').remove();
8441
8442
8443 },
8444 checkToolbarAtStart: function () {
8445 if (parseInt($('.toolbar_activities .commands .count').get(0).innerHTML, 10) > 0) {
8446 ActivityBoxes.showCommandList();
8447 } else {
8448 ActivityBoxes.hideCommandList();
8449 }
8450 if (parseInt($('.toolbar_activities .trades .count').get(0).innerHTML, 10) > 0) {
8451 ActivityBoxes.showTradeList();
8452 } else {
8453 ActivityBoxes.hideTradeList();
8454 }
8455 },
8456 catchToolbarEvents: function () {
8457 var observe_options = {attributes: false, childList: true, characterData: false};
8458
8459 mut_toolbar = new MutationObserver(function (mutations) {
8460 mutations.forEach(function (mutation) {
8461 if (mutation.addedNodes[0]) {
8462 //console.debug(mutation.target.id);
8463 if (mutation.target.id === "toolbar_activity_trades_list") {
8464 ActivityBoxes.draggableTradeBox();
8465 } else {
8466 ActivityBoxes.draggableCommandBox();
8467 }
8468 mutation.addedNodes[0].remove();
8469 }
8470 });
8471 });
8472 //mut_toolbar.observe($('#toolbar_activity_commands_list').get(0), observe_options );
8473 //mut_toolbar.observe($('#toolbar_activity_trades_list').get(0), observe_options );
8474
8475 mut_command = new MutationObserver(function (mutations) {
8476 mutations.forEach(function (mutation) {
8477 if (mutation.addedNodes[0]) {
8478 //console.debug(mutation.addedNodes[0].nodeValue);
8479 if (mutation.addedNodes[0].nodeValue > 0) {
8480 ActivityBoxes.showCommandList();
8481 } else {
8482 //console.debug("hide commands");
8483 ActivityBoxes.hideCommandList();
8484 }
8485 }
8486 });
8487 });
8488 mut_trade = new MutationObserver(function (mutations) {
8489 mutations.forEach(function (mutation) {
8490 if (mutation.addedNodes[0]) {
8491 if (mutation.addedNodes[0].nodeValue > 0) {
8492 ActivityBoxes.showTradeList();
8493 } else {
8494 ActivityBoxes.hideTradeList();
8495 }
8496 }
8497 });
8498 });
8499 mut_command.observe($('.toolbar_activities .commands .count').get(0), observe_options);
8500 mut_trade.observe($('.toolbar_activities .trades .count').get(0), observe_options);
8501 },
8502 // Moveable boxes
8503 draggableTradeBox: function () {
8504 $("#toolbar_activity_trades_list").draggable({
8505 containment: "body",
8506 distance: 20,
8507 snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, .nui_left_box",
8508 opacity: 0.7,
8509 start: function () {
8510 $("#dio_fix_trade").remove();
8511 },
8512 stop: function () {
8513 var pos = $('#toolbar_activity_trades_list').position();
8514
8515 tradebox.left = pos.left;
8516 tradebox.top = pos.top;
8517
8518 saveValue("tradebox", JSON.stringify(tradebox));
8519
8520 $('<style id="dio_fix_trade" type="text/css">' +
8521 '#toolbar_activity_trades_list { left:' + tradebox.left + 'px !important; top:' + tradebox.top + 'px !important; } ' +
8522 '</style>').appendTo('head');
8523 }
8524 });
8525 },
8526 draggableCommandBox: function () {
8527 $("#toolbar_activity_commands_list").draggable({
8528 containment: "body",
8529 distance: 20,
8530 snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, .nui_left_box",
8531 opacity: 0.7,
8532 stop: function () {
8533 var pos = $('#toolbar_activity_commands_list').position();
8534 commandbox.left = pos.left;
8535 commandbox.top = pos.top;
8536
8537 saveValue("commandbox", JSON.stringify(commandbox));
8538 }
8539 });
8540 }
8541 };
8542
8543 /*******************************************************************************************************************************
8544 * Counter
8545 *******************************************************************************************************************************/
8546
8547 function counter(time) {
8548 var type = "", today, counted, year, month, day;
8549 if (uw.Game.market_id !== "zz") {
8550 counted = DATA.count;
8551 today = new Date((time + 7200) * 1000);
8552 year = today.getUTCFullYear();
8553 month = ((today.getUTCMonth() + 1) < 10 ? "0" : "") + (today.getUTCMonth() + 1);
8554 day = (today.getUTCDate() < 10 ? "0" : "") + today.getUTCDate();
8555 today = year + month + day;
8556 //console.log(today);
8557 if (counted[0] !== today) {
8558 type += "d";
8559 }
8560 if (counted[1] == false) {
8561 type += "t";
8562 }
8563 if ((counted[2] == undefined) || (counted[2] == false)) {
8564 type += "b";
8565 }
8566 if (type !== "") {
8567 $.ajax({
8568 type: "GET",
8569 url: "https://diotools.de/game/count.php?type=" + type + "&market=" + uw.Game.market_id + "&date=" + today + "&browser=" + getBrowser(),
8570 dataType: 'text',
8571 success: function (text) {
8572 if (text.indexOf("dly") > -1) {
8573 counted[0] = today;
8574 }
8575 if (text.indexOf("tot") > -1) {
8576 counted[1] = true;
8577 }
8578 if (text.indexOf("bro") > -1) {
8579 counted[2] = true;
8580 }
8581 saveValue("dio_count", JSON.stringify(counted));
8582 }
8583 });
8584 }
8585 }
8586 }
8587
8588
8589 /*******************************************************************************************************************************
8590 * Political Map
8591 *******************************************************************************************************************************/
8592
8593 var PoliticalMap = {
8594 data: null,
8595 activate: function () {
8596 $('<div id="dio_political_map">' +
8597 '<div class="canvas_wrapper"></div>' +
8598 '<select class="zoom_select">' +
8599 '<option value="0.50">1 : 0.50</option>' +
8600 '<option value="0.75">1 : 0.75</option>' +
8601 '<option value="1.00" selected>1 : 1.00</option>' +
8602 '<option value="1.25">1 : 1.25</option>' +
8603 '<option value="1.50">1 : 1.50</option>' +
8604 '<option value="2.00">1 : 2.00</option>' +
8605 '<option value="3.00">1 : 3.00</option>' +
8606 '</select>' +
8607 '<div class="legend sandy-box">' +
8608 '<div class="corner_tl"></div>' +
8609 '<div class="corner_tr"></div>' +
8610 '<div class="corner_bl"></div>' +
8611 '<div class="corner_br"></div>' +
8612 '<div class="border_t"></div>' +
8613 '<div class="border_b"></div>' +
8614 '<div class="border_l"></div>' +
8615 '<div class="border_r"></div>' +
8616 '<div class="middle"></div>' +
8617 '<div class="content"><div class="item"></div></div>' +
8618 '</div></div>').appendTo('#ui_box');
8619
8620 // Style
8621 $('<style id="dio_political_map_style">' +
8622 '#dio_political_map { width:100%; height:100%; z-index:3; background:#123d70; display:none; position:absolute; top:0; } ' +
8623 '#dio_political_map.active { display: block; } ' +
8624 '#dio_political_map .canvas_wrapper { } ' +
8625 '#dio_political_map canvas { position: absolute; cursor:move; top:0; left:0; } ' +
8626 '#dio_political_map .zoom_select { position:absolute; top:70px; left:300px; font-size: 2em; opacity:0.5; } ' +
8627 '#dio_political_map .zoom_select:hover { opacity:1; } ' +
8628 '#dio_political_map .legend { position:absolute; right:200px; top:50px; width:200px; height:auto; text-align:left; } ' +
8629 '#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; } ' +
8630 '#dio_political_map .legend .wonder_icon { float: left; margin: 4px; } ' +
8631
8632 '.btn_political_map { top:56px; left:-4px; z-index:10; position:absolute; } ' +
8633
8634 '.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%; } ' +
8635 // http://s14.directupload.net/images/140408/k4wikrlq.png // http://s7.directupload.net/images/140408/ahfr8227.png
8636 '.btn_political_map .ico_political_map.checked { margin-top:8px; } ' +
8637 '</style>').appendTo('head');
8638
8639 PoliticalMap.addButton();
8640
8641 var zoomSelect = $('.zoom_select');
8642
8643 zoomSelect.change(function () {
8644 //PoliticalMap.zoomToCenter();
8645 });
8646 zoomSelect.on("change", function () {
8647 PoliticalMap.zoomToCenter();
8648 });
8649
8650 ColorPicker.init();
8651 },
8652 deactivate: function () {
8653 $('.btn_political_map').remove();
8654 $('#dio_political_map_style').remove();
8655 },
8656 addButton: function () {
8657 var m_ZoomFactor = 1.0;
8658 $('<div class="btn_political_map circle_button" name="political_map"><div class="ico_political_map js-caption"></div></div>').appendTo(".bull_eye_buttons");
8659
8660 var politicalMapButton = $('.btn_political_map');
8661
8662 // Tooltip
8663 politicalMapButton.tooltip("Political Map"); // TODO: Language
8664
8665 // Events
8666 politicalMapButton.on('mousedown', function () {
8667 //$('.btn_political_map, .ico_political_map').addClass("checked");
8668 }).on('mouseup', function () {
8669 //$('.btn_political_map, .ico_political_map').removeClass("checked");
8670 });
8671
8672 $('.rb_map .option').click(function () {
8673 $('.btn_political_map, .ico_political_map').removeClass("checked");
8674 $('#dio_political_map').removeClass("active");
8675 $(this).addClass("checked");
8676 });
8677
8678 politicalMapButton.click(function () {
8679 $('.rb_map .checked').removeClass("checked");
8680 $('.btn_political_map, .ico_political_map').addClass("checked");
8681 $('#dio_political_map').addClass("active");
8682
8683 if ($('#dio_political_map').hasClass("active")) {
8684 if (PoliticalMap.data == null) {
8685 $('#ajax_loader').css({visibility: "visible"});
8686 // Map-Daten aus DB auslesen
8687 PoliticalMap.loadMapData();
8688 } else {
8689 //PoliticalMap.drawMap(PoliticalMap.data);
8690 }
8691 }
8692 });
8693 },
8694 /**
8695 * Läd die Allianzen und Inseln aus der Datenbank
8696 * @since 3.0
8697 */
8698 loadMapData: function () {
8699 $.ajax({
8700 type: "GET",
8701 url: "https://diotools.de/php/map.php?world_id=" + WID + "&callback=jsonCallback",
8702 //dataType: 'jsonp',
8703 //async: false,
8704 //jsonpCallback: 'jsonCallback',
8705 //contentType: "application/json",
8706 success: function (response) {
8707 if (response !== "") {
8708 PoliticalMap.data = response;
8709
8710 var m_ZoomFactor = $('.zoom_select').get(0)[$('.zoom_select').get(0).selectedIndex].selected;
8711
8712 PoliticalMap.drawMap(PoliticalMap.data, m_ZoomFactor);
8713 PoliticalMap.drawWonders(PoliticalMap.data, m_ZoomFactor);
8714
8715 $('#ajax_loader').css({visibility: "hidden"});
8716
8717 // Überprüfen, ob die Weltdaten geupdatet werden müssen
8718 $.ajax({
8719 type: "GET",
8720 url: "https://diotools.de/php/update_db.php?world_id=" + WID
8721 });
8722 } else {
8723 // Welt existiert noch nicht in DB
8724 $.ajax({
8725 type: "GET", url: "https://diotools.de/php/update_db.php?world_id=" + WID,
8726 success: function () {
8727 // Map-Daten aus DB auslesen, wenn die Weltdaten erfolgreich in die DB geladen wurden
8728 $.ajax({
8729 type: "GET",
8730 url: "https://diotools.de/php/map.php?world_id=" + WID,
8731 success: function (response) {
8732 PoliticalMap.data = response;
8733
8734 var m_ZoomFactor = $('.zoom_select').get(0)[$('.zoom_select').get(0).selectedIndex].selected;
8735
8736 PoliticalMap.drawMap(PoliticalMap.data, m_ZoomFactor);
8737 PoliticalMap.drawWonders(PoliticalMap.data, m_ZoomFactor);
8738
8739 $('#ajax_loader').css({visibility: "hidden"});
8740 }
8741 });
8742 }
8743 });
8744 }
8745 }
8746 });
8747 },
8748 /**
8749 * Ändert die Zoomstufe der Karte zum Zentrum hin
8750 *
8751 * @param _zoom
8752 * @since 3.0
8753 */
8754 zoomToCenter: function () {
8755 var _zoom = $('.zoom_select').get(0)[$('.zoom_select').get(0).selectedIndex].value;
8756
8757 var canvas = $('#dio_political_map canvas'),
8758
8759 canvas_size = parseInt($('#dio_political_map canvas').width(), 10); // Breite und Höhe sind immer gleich
8760
8761 var canvas_style = $('#dio_political_map .canvas_wrapper').get(0).style;
8762
8763 // Berechnung: Alter Abstand + (1000 * Zoomänderung / 2)
8764 canvas_style.top = parseInt(canvas_style.top, 10) + (1000 * (canvas_size / 1000 - _zoom)) / 2 + "px";
8765 canvas_style.left = parseInt(canvas_style.left, 10) + (1000 * (canvas_size / 1000 - _zoom)) / 2 + "px";
8766
8767 PoliticalMap.clearMap();
8768 PoliticalMap.drawMap(PoliticalMap.data, _zoom);
8769 PoliticalMap.drawWonders(PoliticalMap.data, _zoom);
8770
8771 },
8772 /**
8773 * Ändert die Zoomstufe der Karte zur Cursorposition hin
8774 *
8775 * @param _zoom
8776 * @param _pos
8777 *
8778 * @since 3.0
8779 */
8780 zoomToCursorPosition: function (_zoom, _pos) {
8781
8782 },
8783 /**
8784 * Zeichnet die Karte in ein Canvas
8785 *
8786 * @param _islandArray {Array}
8787 * @param _zoom {int}
8788 *
8789 * @since 3.0
8790 */
8791 drawMap: function (_islandArray, _zoom) {
8792
8793 $('<canvas class="canv_map" height="' + (1000 * _zoom) + 'px" width="' + (1000 * _zoom) + "px\"></canvas>").prependTo('.canvas_wrapper')
8794
8795 // TODO: Weite und Höhe vom Fenster ermitteln, Update Containment bei onResizeWindow
8796 $('#dio_political_map .canvas_wrapper').draggable({
8797 // left, top, right, bottom
8798 //containment: [-500 * _zoom, -300 * _zoom, 500 * _zoom, 300 * _zoom],
8799 distance: 10,
8800 grid: [100 * _zoom, 100 * _zoom],
8801 //limit: 500,
8802 cursor: 'pointer'
8803 });
8804
8805 var ally_ranking = JSON.parse(_islandArray)['ally_ranking'];
8806 var island_array = JSON.parse(_islandArray)['ally_island_array'];
8807
8808
8809 var c = $('#dio_political_map .canv_map')[0].getContext('2d');
8810
8811 // Grid
8812 c.strokeStyle = 'rgb(0,100,0)';
8813
8814 for (var l = 0; l <= 10; l++) {
8815 // Horizontal Line
8816 c.moveTo(0, l * 100 * _zoom);
8817 c.lineTo(1000 * _zoom, l * 100 * _zoom);
8818 c.stroke();
8819
8820 // Vertical Line
8821 c.moveTo(l * 100 * _zoom, 0);
8822 c.lineTo(l * 100 * _zoom, 1000 * _zoom);
8823 c.stroke();
8824 }
8825
8826 // Center Circle
8827 c.beginPath();
8828 c.arc(500 * _zoom, 500 * _zoom, 100 * _zoom, 0, Math.PI * 2, true);
8829 c.fillStyle = 'rgba(0,100,0,0.2)';
8830 c.fill();
8831 c.stroke();
8832
8833 // Sea numbers
8834 c.fillStyle = 'rgb(0,100,0)';
8835
8836 for (var y = 0; y <= 10; y++) {
8837 for (var x = 0; x <= 10; x++) {
8838 c.fillText(y + "" + x, y * 100 * _zoom + 2, x * 100 * _zoom + 10);
8839 }
8840 }
8841
8842 // Alliance Colors
8843 var colorArray = ["#00A000", "yellow", "red", "rgb(255, 116, 0)", "cyan", "#784D00", "white", "purple", "#0078FF", "deeppink", "darkslategrey"];
8844
8845 // Islands
8846 for (var t in island_array) {
8847 if (island_array.hasOwnProperty(t)) {
8848 var tmp_points = 0, dom_ally = "";
8849 for (var ally in island_array[t]) {
8850 if (island_array[t].hasOwnProperty(ally)) {
8851 if (tmp_points < island_array[t][ally] && (ally !== "X") && (ally !== "")) {
8852 tmp_points = island_array[t][ally];
8853 dom_ally = ally;
8854 }
8855 }
8856 }
8857
8858 c.fillStyle = colorArray[parseInt(ally_ranking[dom_ally], 10) - 1] || "darkslategrey";
8859 //c.fillRect(t.split("x")[0] * _zoom, t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
8860
8861 //c.beginPath();
8862 //console.info(island_array[t]);
8863 //c.arc(t.split("x")[0], t.split("x")[1], 2, 0, Math.PI * 2, true);
8864 //c.fillRect(t.split("x")[0] * _zoom,t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
8865 //c.fill();
8866
8867 // TEST HEATMAP
8868 //console.debug("Blaaa", c.fillStyle);
8869 if (c.fillStyle !== "#2f4f4f") {
8870 var color = c.fillStyle;
8871
8872 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);
8873 radgrad.addColorStop(0, PoliticalMap.convertHexToRgba(color, 0.2));
8874 radgrad.addColorStop(0.6, PoliticalMap.convertHexToRgba(color, 0.2));
8875 radgrad.addColorStop(1, PoliticalMap.convertHexToRgba(color, 0.0));
8876
8877 // draw shape
8878 c.fillStyle = radgrad;
8879
8880 c.fillRect(t.split("x")[0] * _zoom - 10, t.split("x")[1] * _zoom - 10, 22, 22);
8881
8882 c.fillStyle = PoliticalMap.convertHexToRgba(color, 0.7);
8883 c.fillRect(t.split("x")[0] * _zoom, t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
8884 }
8885 else {
8886 c.fillRect(t.split("x")[0] * _zoom, t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
8887 }
8888 }
8889 }
8890
8891
8892
8893 // Legende
8894 var legend = $('#dio_political_map .legend .content');
8895
8896 legend.get(0).innerHTML = "";
8897
8898 for (var ally in ally_ranking) {
8899 if (ally_ranking.hasOwnProperty(ally)) {
8900 //legend.append("<div class='item' style='color:"+ colorAllyArray[ally] +"'><div class='color_checker' style='background-color:"+ colorAllyArray[ally] +"'></div>...</div>");
8901
8902 if (ally_ranking[ally] > 10) {
8903 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>");
8904
8905 break;
8906 } else {
8907 legend.append("<div class='item' style='color:" + colorArray[ally_ranking[ally] - 1] + "'><div class='color_checker' style='background-color:" + colorArray[ally_ranking[ally] - 1] + "'></div>" + ally + "</div>");
8908
8909 }
8910 }
8911 }
8912
8913 $('#dio_political_map .legend .color_checker').click(function (event) {
8914 // getting user coordinates
8915 var x = event.pageX - this.offsetLeft;
8916 var y = event.pageY - this.offsetTop;
8917
8918 console.debug("Color Checker", event.pageX, this.offsetLeft);
8919
8920 ColorPicker.open(x,y);
8921 });
8922
8923
8924 // TODO: Wenn eine Farbe ausgewählt wurde, soll [...]
8925 $(ColorPicker).on("onColorChanged", function(event, color){
8926 console.debug("Farbe setzen", event, color);
8927
8928 $.ajax({
8929 type: "POST",
8930 url: "https://" + Game.world_id + ".grepolis.com/game/alliance?town_id=" + Game.townId + "&action=assign_map_color&h=" + Game.csrfToken,
8931 data: {
8932 "json": "{\"alliance_id\":\"217\",\"color\":"+ color +",\"player_id\":\"8512878\",\"town_id\":\"71047\",\"nl_init\":true}"
8933 },
8934 success: function (response) {
8935 console.debug("Erfolgreich übertragen", response);
8936 }
8937 });
8938 });
8939
8940 },
8941 convertHexToRgba: function (hex, opacity) {
8942 console.debug("hex", hex);
8943 hex = hex.replace('#', '');
8944 r = parseInt(hex.substring(0, 2), 16);
8945 g = parseInt(hex.substring(2, 4), 16);
8946 b = parseInt(hex.substring(4, 6), 16);
8947
8948 result = 'rgba(' + r + ',' + g + ',' + b + ',' + opacity + ')';
8949 return result;
8950 },
8951 /**
8952 * Zeichnet die Weltwunder auf der Karte
8953 *
8954 * @param _islandArray {Array}
8955 * @param _zoom {int}
8956 *
8957 * @since 3.0
8958 */
8959 drawWonders: function (_islandArray, _zoom) {
8960
8961 $('<canvas class="canv_ww" height="' + (1000 * _zoom) + 'px" width="' + (1000 * _zoom) + 'px"></canvas>').appendTo('.canvas_wrapper')
8962
8963 var c = $('#dio_political_map .canv_ww')[0].getContext('2d');
8964
8965 c.strokeStyle = 'rgb(0,100,0)';
8966
8967 // World Wonders
8968 var wonders = {}, wonderImages = {};
8969 //console.debug(JSON.stringify(wonder.map));
8970
8971 for (var wonderType in wonder.map) {
8972 if (wonder.map.hasOwnProperty(wonderType)) {
8973 var tmp = 0;
8974 for (var wonderCoords in wonder.map[wonderType]) {
8975 if (parseInt(wonder.map[wonderType][wonderCoords], 10) > tmp) {
8976 wonders[wonderType] = wonderCoords;
8977 tmp = parseInt(wonder.map[wonderType][wonderCoords], 10)
8978 }
8979 }
8980 }
8981 }
8982
8983 // Legende
8984 var legend = $('#dio_political_map .legend .content');
8985
8986 legend.append("<div class=\"item no_results\"></div>");
8987
8988 for (var w in wonders) {
8989 if (wonders.hasOwnProperty(w)) {
8990 var _w = w;
8991
8992 wonderImages[_w] = new Image();
8993
8994 wonderImages[_w].onload = function () {
8995 c.drawImage(this, this.pos.split("_")[0] * _zoom - 9, this.pos.split("_")[1] * _zoom - 9);
8996 };
8997
8998 wonderImages[_w].pos = wonders[_w];
8999 wonderImages[_w].src = "https://diotools.de/images/icons/ww/" + _w + ".png";
9000
9001 var wonder_string = _w.split("_of")[0].split("_");
9002 wonder_string = wonder_string[wonder_string.length - 1];
9003 wonder_string = wonder_string.substring(0, 1).toUpperCase() + wonder_string.substring(1);
9004
9005 legend.append("<img class='wonder_icon' src='" + wonderImages[_w].src + "'><div class='item'>" + wonder_string + "</div>");
9006 }
9007 }
9008 },
9009 clearMap: function () {
9010 $('#dio_political_map .canv_map').remove();
9011 $('#dio_political_map .canv_ww').remove();
9012 },
9013 getAllianceColors: function () {
9014 $.ajax({
9015 type: "GET",
9016 url: "https://" + Game.world_id + ".grepolis.com/game/map_data?town_id=" + Game.townId + "&action=get_custom_colors&h=" + Game.csrfToken,
9017 dataType: 'json',
9018 success: function (response) {
9019 // Allianzbox herausfiltern
9020 var html_string = $('#alliance_box', $(response.json.list_html));
9021
9022 var flagArray = $('.flag', html_string);
9023 var linkArray = $('a', html_string);
9024
9025 var allianceColorArray = [];
9026
9027 for (var i = 0; i < flagArray.length; i++) {
9028 allianceColorArray[i] = {
9029 "id": parseInt(linkArray[i].attributes.onclick.value.split(",")[1].split(")")[0], 10),
9030 "color": flagArray[i].style.backgroundColor
9031 };
9032 }
9033
9034 // console.debug("ANTWORT", allianceColorArray);
9035 }
9036 });
9037 }
9038 };
9039
9040 var ColorPicker = {
9041 open: function(pos_left, pos_top){
9042 $('#dio_color_picker').removeClass("hidden");
9043 $('#dio_color_picker').css({
9044 left: pos_left,
9045 top: pos_top
9046 });
9047 },
9048 close: function(){
9049 $('#dio_color_picker').addClass("hidden");
9050 },
9051 init: function () {
9052 // Style
9053 $('<style id="dio_color_picker_style">' +
9054 '#dio_color_picker { left:200px;top:300px;position:absolute;z-index:1000;} ' +
9055 '#dio_color_picker.hidden { display:none;} ' +
9056 '#dio_color_picker span.grepo_input, ' +
9057 '#dio_color_picker a.color_table, ' +
9058 '#dio_color_picker a.confirm, ' +
9059 '#dio_color_picker a.cancel' +
9060 ' { float:left; } ' +
9061 '</style>').appendTo('head');
9062
9063 $(
9064 '<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>' +
9065 '<div id="hex">HEX: <input type="text"></input></div>' +
9066 '<div id="rgb">RGB: <input type="text"></input></div>'
9067 ).prependTo('#dio_political_map')
9068
9069 $(
9070 '<div id="dio_color_picker" class="hidden"><table class="bb_popup" cellpadding="0" cellspacing="0"><tbody>' +
9071 '<tr class="bb_popup_top">' +
9072 '<td class="bb_popup_top_left"></td>' +
9073 '<td class="bb_popup_top_middle"></td>' +
9074 '<td class="bb_popup_top_right"></td>' +
9075 '</tr>' +
9076 '<tr>' +
9077 '<td class="bb_popup_middle_left"></td>' +
9078 '<td class="bb_popup_middle_middle">' +
9079 '<div class="bb_color_picker_colors">' +
9080 '<div style="background-color: rgb(255, 0, 0);"></div>' +
9081 '<div style="background-color: rgb(0, 255, 0);"></div>' +
9082 '<div style="background-color: rgb(0, 0, 255);"></div>' +
9083 '</div>' +
9084 '<a href="#" class="cancel"></a>' +
9085 '<span class="grepo_input">' +
9086 '<span class="left">' +
9087 '<span class="right">' +
9088 '<input class="color_string" style="width:50px;" maxlength="6" type="text">' +
9089 '</span>' +
9090 '</span>' +
9091 '</span>' +
9092 '<a href="#" class="color_table"><input type="color" id="c" tabindex=-1 class="hidden"></a>' +
9093 '<a href="#" class="confirm"></a>' +
9094 '</td>' +
9095 '<td class="bb_popup_middle_right"></td>' +
9096 '</tr>' +
9097 '<tr class="bb_popup_bottom">' +
9098 '<td class="bb_popup_bottom_left"></td>' +
9099 '<td class="bb_popup_bottom_middle"></td>' +
9100 '<td class="bb_popup_bottom_right"></td>' +
9101 '</tr>' +
9102 '</tbody></table></div>'
9103 ).prependTo('#dio_political_map');
9104
9105 var canvas = document.getElementById('canvas_picker').getContext('2d');
9106
9107 var count = 5, line = 0, width = 16, height = 12, sep = 1;
9108
9109 var offset = (count - 2) * width;
9110
9111 for (var i = 2, j = 0; i < count; i++, j++) {
9112
9113 line = 0;
9114
9115 // Pinktöne (255,0,255)
9116 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", 0, " + ((i / count * 255) | 0) + ")";
9117 canvas.fillRect(i * width, line, width - sep, height - sep);
9118
9119 canvas.fillStyle = "rgb(255," + ((j / (count - 1) * 255) | 0) + ", 255)";
9120 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9121
9122 line = line + height;
9123
9124 // Rosatöne (255,0,127)
9125 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", 0, " + ((i / count * 127) | 0) + ")";
9126 canvas.fillRect(i * width, line, width - sep, height - sep);
9127
9128 canvas.fillStyle = "rgb(255," + ((j / (count - 1) * 255) | 0) + "," + (127 + ((j / (count - 1) * 127) | 0)) + ")";
9129 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9130
9131 line = line + height;
9132
9133 // Rottöne (255,0,0)
9134 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", 0, 0)";
9135 canvas.fillRect(i * width, line, width - sep, height - sep);
9136
9137 canvas.fillStyle = "rgb(255," + ((j / (count - 1) * 255) | 0) + "," + ((j / (count - 1) * 255) | 0) + ")";
9138 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9139
9140 line = line + height;
9141
9142 // Orangetöne (255, 127, 0)
9143 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", " + ((i / count * 127) | 0) + ", 0)";
9144 canvas.fillRect(i * width, line, width - sep, height - sep);
9145
9146 canvas.fillStyle = "rgb(255, " + (127 + ((j / (count - 1) * 127) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ")";
9147 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9148
9149 line = line + height;
9150
9151 // Dunkelbrauntöne (170, 85, 0)
9152 canvas.fillStyle = "rgb(" + ((i / count * 170) | 0) + ", " + ((i / count * 85) | 0) + ", 0)";
9153 canvas.fillRect(i * width, line, width - sep, height - sep);
9154
9155 canvas.fillStyle = "rgb(" + (170 + (j / (count - 1) * 85) | 0) + ", " + (85 + ((j / (count - 1) * 170) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ")";
9156 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9157
9158 line = line + height;
9159
9160 // Brauntöne (191, 127, 0)
9161 canvas.fillStyle = "rgb(" + ((i / count * 191) | 0) + ", " + ((i / count * 127) | 0) + ", 0)";
9162 canvas.fillRect(i * width, line, width - sep, height - sep);
9163
9164 canvas.fillStyle = "rgb(" + (191 + (j / (count - 1) * 64) | 0) + ", " + (127 + ((j / (count - 1) * 127) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ")";
9165 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9166
9167 line = line + height;
9168
9169 // Gelbtöne (255,255,0)
9170 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ", 0)";
9171 canvas.fillRect(i * width, line, width - sep, height - sep);
9172
9173 canvas.fillStyle = "rgb(255, 255," + ((j / (count - 1) * 255) | 0) + ")";
9174 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9175
9176 line = line + height;
9177
9178 // Gelbgrüntöne (127,255,0)
9179 canvas.fillStyle = "rgb(" + ((i / count * 127) | 0) + "," + ((i / count * 191) | 0) + ", 0)";
9180 canvas.fillRect(i * width, line, width - sep, height - sep);
9181
9182 canvas.fillStyle = "rgb(" + (127 + (j / (count - 1) * 127) | 0) + "," + (191 + (j / (count - 1) * 64) | 0) + "," + ((j / (count - 1) * 255) | 0) + ")";
9183 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9184
9185 line = line + height;
9186
9187 // Dunkelgrasgrüntöne (85, 170, 0)
9188 /*
9189 canvas.fillStyle = "rgb("+ ((i/count*85)|0) +", "+ ((i/count*170)|0) +", 0)";
9190 canvas.fillRect(i * width, line, width-sep, height-sep);
9191
9192 canvas.fillStyle = "rgb("+ (85 + (j/(count-1)*170)|0) +", "+ (170 + ((j/(count-1)*85)|0)) +","+ ((j/(count-1)*255)|0) +")";
9193 canvas.fillRect(i * width + offset, line, width-sep, height-sep);
9194
9195 line = line + height;
9196 */
9197
9198 // Grüntöne (0,255,0)
9199 canvas.fillStyle = "rgb(0," + ((i / count * 255) | 0) + ", 0)";
9200 canvas.fillRect(i * width, line, width - sep, height - sep);
9201
9202 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + ", 255," + ((j / (count - 1) * 255) | 0) + ")";
9203 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9204
9205 line = line + height;
9206
9207 // Türkistöne (0,255,127)
9208 /*
9209 canvas.fillStyle = "rgb(0,"+ ((i/count*255)|0) +","+ ((i/count*127)|0) + ")";
9210 canvas.fillRect(i * width, line, width-sep, height-sep);
9211
9212 canvas.fillStyle = "rgb("+ ((j/(count-1)*255)|0) +", 255,"+ (127 + ((j/(count-1)*127)|0)) +")";
9213 canvas.fillRect(i * width + offset, line, width-sep, height-sep);
9214
9215 line = line + height;
9216 */
9217
9218 // Dunkel-Türkistöne (0,191,127)
9219 canvas.fillStyle = "rgb(0, " + ((i / count * 191) | 0) + "," + ((i / count * 127) | 0) + ")";
9220 canvas.fillRect(i * width, line, width - sep, height - sep);
9221
9222 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + "," + (191 + (j / (count - 1) * 64) | 0) + ", " + (127 + ((j / (count - 1) * 127) | 0)) + ")";
9223 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9224
9225 line = line + height;
9226
9227
9228 // Cyantöne (0,255,255)
9229 canvas.fillStyle = "rgb(0, " + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ")";
9230 canvas.fillRect(i * width, line, width - sep, height - sep);
9231
9232 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + ",255, 255)";
9233 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9234
9235 line = line + height;
9236
9237 // Hellblautöne (0,127,255)
9238 canvas.fillStyle = "rgb(0, " + ((i / count * 127) | 0) + "," + ((i / count * 255) | 0) + ")";
9239 canvas.fillRect(i * width, line, width - sep, height - sep);
9240
9241 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + "," + (127 + ((j / (count - 1) * 127) | 0)) + ", 255)";
9242 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9243
9244 line = line + height;
9245
9246 // Blautöne (0,0,255)
9247 canvas.fillStyle = "rgb(0, 0, " + ((i / count * 255) | 0) + ")";
9248 canvas.fillRect(i * width, line, width - sep, height - sep);
9249
9250 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + "," + ((j / (count - 1) * 255) | 0) + ", 255)";
9251 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9252
9253 line = line + height;
9254
9255 // Lilatöne (127,0,255)
9256 canvas.fillStyle = "rgb(" + ((i / count * 127) | 0) + ", 0, " + ((i / count * 255) | 0) + ")";
9257 canvas.fillRect(i * width, line, width - sep, height - sep);
9258
9259 canvas.fillStyle = "rgb(" + (127 + ((j / (count - 1) * 127) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ", 255)";
9260 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9261
9262 line = line + height;
9263
9264 // Grautöne
9265 /*
9266 canvas.fillStyle = "rgb("+ ((i/count*127)|0) +", "+ ((i/count*127)|0) +", "+ ((i/count*127)|0) +")";
9267 canvas.fillRect(i * width, line, width-sep, height-sep);
9268
9269 canvas.fillStyle = "rgb("+ (127 + ((j/(count-1)*127)|0)) +","+ (127 + ((j/(count-1)*127)|0)) +","+ (127 + ((j/(count-1)*127)|0)) +")";
9270 canvas.fillRect(i * width + offset, line, width-sep, height-sep);
9271
9272 line = line + height;
9273 */
9274
9275 }
9276
9277 line = line + height;
9278
9279 for (var i = 0; i <= count; i++) {
9280 // Grautöne
9281 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ")";
9282 canvas.fillRect(i * width + width * 2, line, width - sep, height - sep);
9283 }
9284
9285
9286 // http://www.javascripter.net/faq/rgbtohex.htm
9287 function rgbToHex(R, G, B) {
9288 return toHex(R) + toHex(G) + toHex(B)
9289 }
9290
9291 function toHex(n) {
9292 n = parseInt(n, 10);
9293 if (isNaN(n)) return "00";
9294 n = Math.max(0, Math.min(n, 255));
9295 return "0123456789ABCDEF".charAt((n - n % 16) / 16) + "0123456789ABCDEF".charAt(n % 16);
9296 }
9297
9298 $('#dio_color_picker a.cancel').click(function () {
9299 ColorPicker.close();
9300 });
9301
9302
9303 $('#dio_color_picker a.confirm').click(function () {
9304 // Custom-Event auslösen
9305 $(ColorPicker).trigger("onColorChanged", [$('#dio_color_picker .color_string')[0].value]);
9306 ColorPicker.close();
9307 });
9308
9309 $('#dio_color_picker a.color_table').click(function () {
9310 document.getElementById("c").click();
9311 });
9312
9313 $('#dio_color_picker a.color_table #c').change(function () {
9314 $('#dio_color_picker input.color_string')[0].value = this.value;
9315 $('#dio_color_picker input.color_string')[0].style.color = this.value;
9316 });
9317 }
9318 };
9319
9320 var UnitImages = {
9321 activate : function(){
9322 $('<style id="dio_unit_images">' +
9323
9324 '.unit_icon25x25 { background-image: url(https://diotools.de/images/game/units/unit_icons_25x25_2.91.png);} ' +
9325 '.unit_icon40x40 { background-image: url(https://diotools.de/images/game/units/unit_icons_40x40_2.91.png);} ' +
9326 '.unit_icon50x50 { background-image: url(https://diotools.de/images/game/units/unit_icons_50x50_2.91.png);} ' +
9327 '.unit_icon90x90 { background-image: url(https://diotools.de/images/game/units/unit_icons_90x90_2.91.png);} ' +
9328
9329 '.unit_icon228x165 { background-image: none; height:0px;} ' +
9330 '.unit_card .deco_statue { background-image: none !important;} ' +
9331 '.grepo_box_silver .border_l, .grepo_box_silver .border_r { background-image: none;} ' +
9332 '.box_corner .box_corner_tl, .grepo_box_silver .box_corner_tr { height:31px; } ' +
9333 '.grepo_box_silver .grepo_box_content { padding: 21px 10px 0px; } ' +
9334
9335 '</style>').appendTo('head');
9336 },
9337 deactivate : function(){
9338 $('#dio_unit_images').remove();
9339
9340 }
9341 };
9342
9343 /*******************************************************************************************************************************
9344 * Holiday Special
9345 *******************************************************************************************************************************/
9346
9347 var HolidaySpecial = {
9348 isHalloween : false, isXmas : false, isNewYear : false, isEaster : false,
9349
9350 activate : function(){
9351 var daystamp = 1000*60*60*24, today = new Date((new Date())%(daystamp*(365+1/4))), // without year
9352
9353 // Halloween -> 15 days
9354 halloween_start = daystamp * 297, // 25. Oktober
9355 halloween_end = daystamp * 321, // 8. November
9356 // Xmas -> 28 days
9357 xmas_start = daystamp * 334, // 1. Dezember
9358 xmas_end = daystamp * 361, // 28. Dezember
9359 // NewYear -> 7 days
9360 newYear_start = daystamp * 0, // 1. Januar
9361 newYear_end = daystamp * 7; // 7. Januar
9362
9363 HolidaySpecial.isHalloween = (today >= halloween_start) ? (today <= halloween_end) : false;
9364
9365 HolidaySpecial.isXmas = (today >= xmas_start) ? (today <= xmas_end) : false;
9366
9367 HolidaySpecial.isNewYear = (today >= newYear_start) ? (today <= newYear_end) : false;
9368
9369 if(HolidaySpecial.isXmas){ HolidaySpecial.XMas.add(); }
9370 if(HolidaySpecial.isNewYear){ HolidaySpecial.NewYear.add(); }
9371
9372 // Calculation Easter
9373
9374 // Jahreszahl
9375 var X = 2016;
9376
9377 // Säkularzahl
9378 var K = parseInt(X / 100, 10);
9379 // Mondparameter
9380 var A = X % 19;
9381
9382 // säkulare Mondschaltung
9383 var M = 15 + parseInt((3 * K + 3)/4, 10) - parseInt((8 * K + 13)/25, 10);
9384
9385 // säkulare Sonnenschaltung
9386 var S = 2 - parseInt((3 * K + 3)/4, 10);
9387
9388 // Erster Vollmond im Frühling
9389 var D = (19 * A + M) % 30;
9390
9391 // Kalendarische Korrekturgröße
9392 var R = parseInt((D + parseInt(A / 11, 10)) / 29, 10);
9393
9394 // Ostergrenze
9395 var OG = 21 + D - R;
9396
9397 // Erster Sonntag im März
9398 var SZ = 7 - ((2016 + parseInt(2016/4, 10) + S) % 7);
9399
9400 // Entfernung des Ostersonntags von der Ostergrenze
9401 var OE = 7 - ((OG - SZ) % 7);
9402
9403 // Ostersonntag als Märzdatum
9404 var OS = OG + OE;
9405
9406 // console.debug("DIO-TOOLS | Ostersonntag: " + OS);
9407
9408 },
9409 XMas : {
9410 add : function(){
9411 $('<a href="http://www.greensmilies.com/smilie-album/weihnachten-smilies/" target="_blank"><div id="dio_xmas"></div></a>').appendTo('#ui_box');
9412
9413 var dioXMAS = $('#dio_xmas');
9414
9415 dioXMAS.css({
9416 background: 'url("http://www.greensmilies.com/smile/smiley_emoticons_weihnachtsmann_nordpol.gif") no-repeat',
9417 height: '51px',
9418 width: '61px',
9419 position:'absolute',
9420 bottom:'10px',
9421 left:'60px',
9422 zIndex:'2000'
9423 });
9424 dioXMAS.tooltip("Ho Ho Ho, Merry Christmas!");
9425 }
9426 },
9427 NewYear : {
9428 add : function(){
9429 // TODO: Jahreszahl dynamisch setzen
9430 $('<a href="http://www.greensmilies.com/smilie-album/" target="_blank"><div id="dio_newYear">'+
9431 '<img src="http://www.greensmilies.com/smile/sign2_2.gif">'+
9432 '<img src="http://www.greensmilies.com/smile/sign2_0.gif">'+
9433 '<img src="http://www.greensmilies.com/smile/sign2_1.gif">'+
9434 '<img src="http://www.greensmilies.com/smile/sign2_7.gif">'+
9435 '</div></a>').appendTo('#ui_box');
9436
9437 var dioNewYear = $('#dio_newYear');
9438
9439 dioNewYear.css({
9440 position:'absolute',
9441 bottom:'10px',
9442 left:'70px',
9443 zIndex:'10'
9444 });
9445 dioNewYear.tooltip("Happy new year!");
9446 }
9447 }
9448 };
9449
9450}