· 7 years ago · Feb 08, 2019, 01:52 PM
1// ==UserScript==
2// @name DIO-TOOLS
3// @namespace DIO
4// @version 3.19
5// @author Diony
6// @updateURL https://diotools.de/downloads/DIO-TOOLS.user.js
7// @downloadURL https://diotools.de/downloads/DIO-TOOLS.user.js
8// @description DIO-Tools is a small extension for the browser game Grepolis. (counter, displays, smilies, trade options, changes to the layout)
9// @include http://de.grepolis.com/game*
10// @include /http[s]{0,1}://[a-z]{2}[0-9]{1,3}\.grepolis\.com/game*/
11// @include https://*.forum.grepolis.com/*
12// @include http://diotools.de/*
13// @require http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
14// @icon http://s7.directupload.net/images/140128/vqchpigi.gif
15// @icon64 http://diotools.de/images/icon_dio_64x64.png
16// @copyright 2013+, DIONY
17// @grant GM_info
18// @grant GM_setValue
19// @grant GM_getValue
20// @grant GM_deleteValue
21// @grant GM_xmlhttpRequest
22// @grant GM_getResourceURL
23// ==/UserScript==
24
25var version = '3.19';
26
27//if(unsafeWindow.DM) console.dir(unsafeWindow.DM.status('l10n'));
28//console.dir(DM.status('templates'));
29
30//http://s7.directupload.net/images/140128/vqchpigi.gif - DIO-Tools-Smiley
31
32//http://de44.grepolis.com/cache/js/libs/jquery-1.10.2.min.js
33
34
35//console.log(JSON.stringify(DM.getl10n()));
36
37
38//// console.log(GM_getResourceText("dio_sprite"));
39
40/*******************************************************************************************************************************
41 * Changes
42 * ----------------------------------------------------------------------------------------------------------------------------
43 * | ◠Einstellungen und auch das ganze Script komplett überarbeitet
44 * | ◠Features können nun ohne Refresh deaktiviert/aktiviert werden
45 * | ◠Einzelne Features sind unabhängiger voneinander und somit auch fehlerresistenter (einzelne Features können sich bei Fehlerauftreten durch Grepolis-Updates nicht mehr gegenseitig blockieren)
46 * | ◠Fehlerhafter Biremenzähler als Kompromiss für die Erweiterung der "Verfügbare Einheiten"-Anzeige entfernt: es kann nun jede Einheit im Bullauge angezeigt werden
47 * | ◠EO-Zähler hat ATT/UT's doppelt gezählt, wenn nebenher der veröffentlichte Belagerungsbericht im Forum offen war
48 * | ◠3 kleine Layoutfehler beim EO-Zähler behoben
49 * | â— Wenn Zauberfenster und Zauberbox gleichzeitig offen waren, kam es zu einem Layoutfehler
50 * | â— Fehler beim Mausrad-Zoom behoben
51 * | ◠Fehler bei der Transporteranzeige behoben: die Kapazität der großen Transporter wurde durch das Rebalancing nichtmehr korrekt berechnet
52 * | â— Smileybox etwas verbessert
53 * | ◠Weihnachtssmileys hinzugefügt
54 * | ◠Kontextmenü der Stadticons auf der strategischen Karte konnte im Nachtmodus nicht geöffnet werden
55 * | ◠Grüner Fortschrittsbalken beim Weltwunderzähler wurde nicht angezeigt
56 * | ◠Fenster wurden angepasst (Verfügbare Einheiten und Einheitenvergleich)
57 * ----------------------------------------------------------------------------------------------------------------------------
58 *******************************************************************************************************************************/
59
60/*******************************************************************************************************************************
61 * Bugs / TODOs
62 * ----------------------------------------------------------------------------------------------------------------------------
63 * | ◠Aktivitätsbox für Angriffe blendet nicht aus
64 * | â— Smileys verschwinden manchmal? -> bisher nicht reproduzierbar
65 * | â— Performanceeinbruch nach dem Switchen des WW-Fensters
66 * | â— keine Smileys im Grepoforum mit Safari (fehlendes jQuery)
67 * ----------------------------------------------------------------------------------------------------------------------------
68 *******************************************************************************************************************************/
69
70/*******************************************************************************************************************************
71 * Global stuff
72 *******************************************************************************************************************************/
73var uw = unsafeWindow || window, $ = uw.jQuery || jQuery, DATA, GM;
74
75// GM-API?
76GM = (typeof GM_info === 'object');
77
78console.log('%c|= DIO-Tools is active =|', 'color: green; font-size: 1em; font-weight: bolder; ');
79
80function loadValue(name, default_val){
81 var value;
82 if(GM){
83 value = GM_getValue(name, default_val);
84 } else {
85 value = localStorage.getItem(name) || default_val;
86 }
87
88 if(typeof(value) === "string"){
89 value = JSON.parse(value)
90 }
91 return value;
92}
93
94// LOAD DATA
95if(GM && (uw.location.pathname.indexOf("game") >= 0)){
96 var WID = uw.Game.world_id, MID = uw.Game.market_id, AID = uw.Game.alliance_id;
97
98 //GM_deleteValue(WID + "_bullseyeUnit");
99
100 DATA = {
101 // GLOBAL
102 options : loadValue("options", "{}"),
103
104 user : loadValue("dio_user", "{}"),
105 count: loadValue("dio_count", "[]"),
106
107 notification : loadValue('notif', '0'),
108
109 error: loadValue('error', '{}'),
110
111 spellbox : loadValue("spellbox", '{ "top":"23%", "left": "-150%", "show": false }'),
112 commandbox: loadValue("commandbox" , '{ "top":55, "left": 250 }'),
113 tradebox : loadValue("tradebox", '{ "top":55, "left": 450 }'),
114
115 // WORLD
116 townTypes : loadValue(WID + "_townTypes", "{}"),
117 sentUnits : loadValue(WID + "_sentUnits", '{ "attack": {}, "support": {} }'),
118
119 biremes : loadValue(WID + "_biremes", "{}"), //old
120 bullseyeUnit : loadValue(WID + "_bullseyeUnit", '{ "current_group" : -1 }'), // new
121
122 worldWonder : loadValue(WID + "_wonder", '{ "ratio": {}, "storage": {}, "map": {} }'),
123
124 clickCount : loadValue(WID + "_click_count", '{}'), // old
125 statistic : loadValue(WID + "_statistic", '{}'), // new
126
127 // MARKET
128 worldWonderTypes : loadValue(MID + "_wonderTypes", '{}')
129 };
130
131 if(!DATA.worldWonder.map) {
132 DATA.worldWonder.map = {};
133 }
134
135 // Temporary:
136 if(typeof DATA.options.trd == 'boolean') {
137 DATA.options.per = DATA.options.rec = DATA.options.trd; delete DATA.options.trd;
138 }
139 if(typeof DATA.options.mov == 'boolean') {
140 DATA.options.act = DATA.options.mov; delete DATA.options.mov;
141 }
142 if(typeof DATA.options.twn == 'boolean') {
143 DATA.options.tic = DATA.options.til = DATA.options.tim = DATA.options.twn; delete DATA.options.twn;
144 }
145 if(GM) GM_deleteValue("notification");
146}
147
148// GM: EXPORT FUNCTIONS
149uw.saveValueGM = function(name, val){
150 setTimeout(function(){
151 GM_setValue(name, val);
152 }, 0);
153};
154
155uw.deleteValueGM = function(name){
156 setTimeout(function(){
157 GM_deleteValue(name);
158 },0);
159};
160
161uw.getImageDataFromCanvas = function(x, y){
162
163 // console.debug("HEY", document.getElementById('canvas_picker').getContext('2d').getImageData(x, y, 1, 1));
164};
165uw.calculateConcaveHull = function() {
166 var contour = [
167 new poly2tri.Point(100, 100),
168 new poly2tri.Point(100, 300),
169 new poly2tri.Point(300, 300),
170 new poly2tri.Point(300, 100)
171 ];
172
173 var swctx = new poly2tri.SweepContext(contour);
174
175 swctx.triangulate();
176 var triangles = swctx.getTriangles();
177
178 // console.debug(triangles);
179
180 return triangles;
181};
182
183if(typeof exportFunction == 'function'){
184 // Firefox > 30
185 //uw.DATA = cloneInto(DATA, unsafeWindow);
186 exportFunction(uw.saveValueGM, unsafeWindow, {defineAs: "saveValueGM"});
187 exportFunction(uw.deleteValueGM, unsafeWindow, {defineAs: "deleteValueGM"});
188 exportFunction(uw.calculateConcaveHull, unsafeWindow, {defineAs: "calculateConcaveHull"});
189 exportFunction(uw.getImageDataFromCanvas, unsafeWindow, {defineAs: "getImageDataFromCanvas"});
190} else {
191 // Firefox < 30, Chrome, Opera, ...
192 //uw.DATA = DATA;
193}
194
195var time_a, time_b;
196
197// APPEND SCRIPT
198function appendScript(){
199 //console.log("GM-API: " + gm_bool);
200 if(document.getElementsByTagName('body')[0]){
201 var dioscript = document.createElement('script');
202 dioscript.type ='text/javascript';
203 dioscript.id = 'diotools';
204
205 time_a = uw.Timestamp.client();
206 dioscript.textContent = DIO_GAME.toString().replace(/uw\./g, "") + "\n DIO_GAME('"+ version +"', "+ GM +", '" + JSON.stringify(DATA).replace(/'/g, "##") + "', "+ time_a +");";
207 document.body.appendChild(dioscript);
208 } else {
209 setTimeout(function(){
210 appendScript();
211 }, 500);
212 }
213}
214
215if(location.host === "diotools.de"){
216 // PAGE
217 DIO_PAGE();
218}
219else if((uw.location.pathname.indexOf("game") >= 0) && GM){
220 // GAME
221 appendScript();
222}
223else {
224 DIO_FORUM();
225}
226
227function DIO_PAGE(){
228 if(typeof GM_info == 'object') {
229 setTimeout(function() {
230 dio_user = JSON.parse(loadValue("dio_user", ""));
231 console.log(dio_user);
232 uw.dio_version = parseFloat(version);
233 }, 0);
234 } else {
235 dio_user = localStorage.getItem("dio_user") || "";
236
237 dio_version = parseFloat(version);
238 }
239}
240function DIO_FORUM(){
241 var smileyArray = [];
242
243 var _isSmileyButtonClicked = false;
244
245 smileyArray.standard = [
246 "smilenew", "grin", "lol", "neutral_new", "afraid", "freddus_pacman", "auslachen2", "kolobok-sanduhr", "bussi2", "winken4", "flucht2", "panik4", "ins-auge-stechen",
247 "seb_zunge", "fluch4_GREEN", "baby_junge2", "blush-reloaded6", "frown", "verlegen", "blush-pfeif", "stevieh_rolleyes", "daumendreh2", "baby_taptap",
248 "sadnew", "hust", "confusednew", "idea2", "irre", "irre4", "sleep", "candle", "nicken", "no_sad",
249 "thumbs-up_new", "thumbs-down_new", "bravo2", "oh-no2", "kaffee2", "drunk", "saufen", "freu-dance", "hecheln", "headstand", "rollsmiliey", "eazy_cool01", "motz", "cuinlove", "biggrin"
250 ];
251 smileyArray.grepolis = [
252 "mttao_wassermann", "hera", /* Hera */ "medusa", /* Medusa */ "manticore", /* Mantikor */ "cyclops", /* Zyklop */
253 "minotaur", /* Minotaurus */ "pegasus", /* Pegasus */ "hydra", /* Hydra */
254 "silvester_cuinlove", "mttao_schuetze", "kleeblatt2", "wallbash", /* "glaskugel4", */ /* "musketiere_fechtend",*/ /* "krone-hoch",*/ "viking", // Wikinger
255 /* "mttao_waage2", */ "steckenpferd", /* "kinggrin_anbeten2", */ "grepolove", /* Grepo Love */ "skullhaufen", "grepo_pacman" /*, "pferdehaufen" */ // "i/ckajscggscw4s2u60"
256 ];
257
258 var ForumObserver = new MutationObserver(function (mutations) {
259 mutations.forEach(function (mutation) {
260
261 if (mutation.addedNodes[0]) {
262
263 //console.debug("Added Nodes", mutation.addedNodes[0]);
264
265 // Message Box geladen
266 if(mutation.addedNodes[0].className === "redactor_box"){
267
268 //console.debug("Message Box geladen");
269
270 ForumObserver.observe($(".redactor_box").get(0), {
271 attributes: false,
272 childList: true,
273 characterData: false,
274 subtree:true
275 });
276 }
277
278 // Toolbar der Message Box geladen
279 if(_isSmileyButtonClicked === false && mutation.addedNodes[0].className === "redactor_toolbar") {
280 $(".redactor_btn_smilies").click();
281
282 // Soll sich nicht wieder deaktivieren
283 _isSmileyButtonClicked = true;
284 }
285
286 // Smileybar der Toolbar geladen
287 if(mutation.addedNodes[0].className === "redactor_smilies") {
288
289 // Observer soll nicht mehr feuern, wenn die Smileys hinzugefügt werden
290 ForumObserver.disconnect();
291
292 // Hässliche Smileys entfernen
293 $(".smilieCategory ul").empty();
294
295 // Greensmileys hinzufügen
296 for(var smiley in smileyArray.standard){
297 if(smileyArray.standard.hasOwnProperty(smiley)){
298 $(".smilieCategory ul").append(
299 '<li class="Smilie" data-text="">'+
300 '<img src="https://diotools.de/images/smileys/standard/smiley_emoticons_'+ smileyArray.standard[smiley] +'.gif" title="" alt="" data-smilie="yes">'+
301 '</li>'
302 );
303 }
304 }
305
306 $(".smilieCategory ul").append("<br><br>");
307
308 for(var smiley in smileyArray.grepolis){
309 if(smileyArray.grepolis.hasOwnProperty(smiley)){
310 $(".smilieCategory ul").append(
311 '<li class="Smilie" data-text="">'+
312 '<img src="https://diotools.de/images/smileys/grepolis/smiley_emoticons_'+ smileyArray.grepolis[smiley] +'.gif" title="" alt="" data-smilie="yes">'+
313 '</li>'
314 );
315 }
316 }
317
318 _isSmileyBarOpened = true;
319 }
320 }
321 });
322 });
323
324 // Smiley-Button aktivieren, um die Smiley-Toolbar zu öffnen
325 if($(".redactor_btn_smilies").get(0)){
326 $(".redactor_btn_smilies").click();
327
328 _isSmileyButtonClicked = true;
329 }
330
331 // Observer triggern
332 if($("#QuickReply").get(0)) {
333 ForumObserver.observe($("#QuickReply div").get(0), {
334 attributes: false,
335 childList: true,
336 characterData: false,
337 subtree:true
338 });
339 }
340 else if($("#ThreadReply").get(0)) {
341 ForumObserver.observe($("#ThreadReply div").get(0), {
342 attributes: false,
343 childList: true,
344 characterData: false,
345 subtree:true
346 });
347 }
348 /*
349 else if($("#ThreadCreate").get(0)) {
350 ForumObserver.observe($("#ThreadCreate fieldset .ctrlUnit dd div").get(0), {
351 attributes: false,
352 childList: true,
353 characterData: false
354 });
355 }
356 */
357
358 // Threaderstellung, Signatur bearbeiten, Beitrag bearbeiten
359 else if($("form.Preview").get(0)) {
360
361 ForumObserver.observe($("form.Preview .ctrlUnit dd div").get(0), {
362 attributes: false,
363 childList: true,
364 characterData: false
365 });
366 }
367 else if(typeof($("form.AutoValidator").get(0)) !== "undefined") {
368
369 ForumObserver.observe($("form.AutoValidator .messageContainer div").get(0), {
370 attributes: false,
371 childList: true,
372 characterData: false
373 });
374 }
375
376 // TODO: Bearbeiten, Nachrichten
377}
378
379
380
381function DIO_GAME(version, gm, DATA, time_a) {
382 var MutationObserver = uw.MutationObserver || window.MutationObserver,
383
384 WID, MID, AID, PID, LID,
385
386 dio_sprite = "http://666kb.com/i/d9xuhtcctx5fdi8i6.png"; // http://abload.de/img/dio_spritejmqxp.png, http://img1.myimg.de/DIOSPRITEe9708.png -> Forbidden!?
387
388 if (uw.location.pathname.indexOf("game") >= 0) {
389 DATA = JSON.parse(DATA.replace(/##/g, "'"));
390
391 WID = uw.Game.world_id;
392 MID = uw.Game.market_id;
393 AID = uw.Game.alliance_id;
394 PID = uw.Game.player_id;
395 LID = uw.Game.locale_lang.split("_")[0]; // LID ="es";
396
397 // World with Artemis ??
398 Game.hasArtemis = true; //Game.constants.gods.length == 6;
399 }
400
401 $.prototype.reverseList = [].reverse;
402
403 // Implement old jQuery method (version < 1.9)
404 $.fn.toggleClick = function () {
405 var methods = arguments; // Store the passed arguments for future reference
406 var count = methods.length; // Cache the number of methods
407
408 // Use return this to maintain jQuery chainability
409 // For each element you bind to
410 return this.each(function (i, item) {
411 // Create a local counter for that element
412 var index = 0;
413
414 // Bind a click handler to that element
415 $(item).on('click', function () {
416 // That when called will apply the 'index'th method to that element
417 // the index % count means that we constrain our iterator between 0
418 // and (count-1)
419 return methods[index++ % count].apply(this, arguments);
420 });
421 });
422 };
423
424 function saveValue(name, val) {
425 if (gm) {
426 saveValueGM(name, val);
427 } else {
428 localStorage.setItem(name, val);
429 }
430 }
431
432 function deleteValue(name) {
433 if (gm) {
434 deleteValueGM(name);
435 } else {
436 localStorage.removeItem(name);
437 }
438 }
439
440 /*******************************************************************************************************************************
441 * Graphic filters
442 *******************************************************************************************************************************/
443 if (uw.location.pathname.indexOf("game") >= 0) {
444 $('<svg width="0%" height="0%">' +
445 // GREYSCALE
446 '<filter id="GrayScale">' +
447 '<feColorMatrix type="matrix" values="0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0">' +
448 '</filter>' +
449 // SEPIA
450 '<filter id="Sepia">' +
451 '<feColorMatrix type="matrix" values="0.343 0.669 0.119 0 0 0.249 0.626 0.130 0 0 0.172 0.334 0.111 0 0 0.000 0.000 0.000 1 0">' +
452 '</filter>' +
453 // SATURATION
454 '<filter id="Saturation"><feColorMatrix type="saturate" values="0.2"></filter>' +
455 '<filter id="Saturation1"><feColorMatrix type="saturate" values="1"></filter>' +
456 '<filter id="Saturation2"><feColorMatrix type="saturate" values="2"></filter>' +
457 // HUE
458 '<filter id="Hue1"><feColorMatrix type="hueRotate" values= "65"></filter>' +
459 '<filter id="Hue2"><feColorMatrix type="hueRotate" values="150"></filter>' +
460 '<filter id="Hue3"><feColorMatrix type="hueRotate" values="-65"></filter>' +
461 // BRIGHTNESS
462 '<filter id="Brightness15">' +
463 '<feComponentTransfer><feFuncR type="linear" slope="1.5"/><feFuncG type="linear" slope="1.5"/><feFuncB type="linear" slope="1.5"/></feComponentTransfer>' +
464 '</filter>' +
465 '<filter id="Brightness12">' +
466 '<feComponentTransfer><feFuncR type="linear" slope="1.2"/><feFuncG type="linear" slope="1.2"/><feFuncB type="linear" slope="1.2"/></feComponentTransfer>' +
467 '</filter>' +
468 '<filter id="Brightness11">' +
469 '<feComponentTransfer><feFuncR type="linear" slope="1.1"/><feFuncG type="linear" slope="1.1"/><feFuncB type="linear" slope="1.1"/></feComponentTransfer>' +
470 '</filter>' +
471 '<filter id="Brightness10">' +
472 '<feComponentTransfer><feFuncR type="linear" slope="1.0"/><feFuncG type="linear" slope="1.0"/><feFuncB type="linear" slope="1.0"/></feComponentTransfer>' +
473 '</filter>' +
474 '<filter id="Brightness07">' +
475 '<feComponentTransfer><feFuncR type="linear" slope="0.7"/><feFuncG type="linear" slope="0.7"/><feFuncB type="linear" slope="0.7"/></feComponentTransfer>' +
476 '</filter>' +
477 '</svg>').appendTo('#ui_box');
478 }
479
480 /*******************************************************************************************************************************
481 * Language versions: german, english, french, russian, polish, spanish
482 *******************************************************************************************************************************/
483 var LANG = {
484 de: {
485 settings: {
486 dsc: "DIO-Tools bietet unter anderem einige Anzeigen, eine Smileyauswahlbox,<br>Handelsoptionen und einige Veränderungen des Layouts.",
487 act: "Funktionen der Toolsammlung aktivieren/deaktivieren:",
488 prv: "Vorschau einzelner Funktionen:",
489
490 version_old: "DIO-Tools-Version ist nicht aktuell",
491 version_new: "DIO-Tools-Version ist aktuell",
492 version_dev: "DIO-Tools-Entwicklerversion",
493
494 version_update: "Aktualisieren",
495
496 link_forum: "http://forum.de.grepolis.com/showthread.php?28838&goto=newpost", //"http://forum.de.grepolis.com/showthread.php?28838"
497 link_contact: "http://forum.de.grepolis.com/private.php?do=newpm&u=10548",
498
499 forum: "Forum",
500 author: "Autor",
501
502 cat_units: "Einheiten",
503 cat_icons: "Stadticons",
504 cat_forum: "Forum",
505 cat_trade: "Handel",
506 cat_wonders: "Weltwunder",
507 cat_layout: "Layout",
508 cat_other: "Sonstiges"
509 },
510 options: {
511 //bir: ["Biremenzähler", "Zählt die jeweiligen Biremen einer Stadt und summiert diese.<br><br>Anzeige im Minimap-Bullauge oben links"],
512 ava: ["Einheitenübersicht", "Zeigt die Einheiten aller Städte an"],
513 sml: ["Smileys", "Erweitert die BBCode-Leiste um eine Smileybox"],
514 str: ["Einheitenstärke", "Fügt mehrere Einheitenstärketabellen in verschiedenen Bereichen hinzu"],
515 tra: ["Transportkapazität", "Zeigt die belegte und verfügbare Transportkapazität im Einheitenmenu an"],
516 per: ["Prozentualer Handel", "Erweitert das Handelsfenster um einen Prozentualer Handel"],
517 rec: ["Rekrutierungshandel", "Erweitert das Handelsfenster um einen Rekrutierungshandel"],
518 cnt: ["EO-Zähler", "Zählt die ATT/UT-Anzahl im EO-Fenster"],
519 way: ["Laufzeit", "Zeigt im ATT/UT-Fenster die Laufzeit bei Verbesserter Truppenbewegung an"],
520 sim: ["Simulator", "Anpassung des Simulatorlayouts & permanente Anzeige der Erweiterten Modifikatorbox"],
521 spl: ["Zauberbox", "Komprimierte verschiebbare & magnetische Zauberbox (Positionsspeicherung)"],
522 act: ["Aktivitätsboxen", "Verbesserte Anzeige der Handels- und Truppenaktivitätsboxen (Positionsspeicherung)"],
523 pop: ["Gunst-Popup", 'Ändert das Aussehen des Gunst-Popups'],
524 tsk: ["Taskleiste", 'Vergrößert die Taskleiste und minimiert das "Tägliche Belohnung"-Fenster beim Start'],
525 cha: ["Chat", "Ersetzt den Allianzchat durch einen Welten-Chat"],
526 bbc: ["DEF-Formular", "Erweitert die BBCode-Leiste um ein automatisches DEF-Formular"],
527 com: ["Einheitenvergleich", "Fügt Einheitenvergleichstabellen hinzu"],
528 tic: ["Stadticons", "Jede Stadt erhält ein Icon für den Stadttyp (Automatische Erkennung)", "Zusätzliche Icons stehen bei der manuellen Auswahl zur Verfügung"],
529 til: ["Stadtliste", "Fügt die Stadticons zur Stadtliste hinzu"],
530 tim: ["Karte", "Setzt die Stadticons auf die strategische Karte"],
531 wwc: ["Anteil", "Anteilsrechner & Rohstoffzähler + Vor- & Zurück-Buttons bei fertiggestellten WW's (momentan nicht deaktivierbar!)"],
532 wwr: ["Rangliste", "Überarbeitete Weltwunderrangliste"],
533 wwi: ["Icons", 'Fügt Weltwundericons auf der strategischen Karte hinzu'],
534 con: ["Kontextmenu", 'Vertauscht "Stadt selektieren" und "Stadtübersicht" im Kontextmenu'],
535 sen: ["Abgeschickte Einheiten", 'Zeigt im Angriffs-/Unterstützungsfenster abgeschickte Einheiten an'],
536 tov: ["Stadtübersicht", 'Ersetzt die neue Stadtansicht mit der alten Fensteransicht'],
537 scr: ["Mausrad-Zoom", 'Man kann mit dem Mausrad die 3 Ansichten wechseln'],
538
539 err: ["Automatische Fehlerberichte senden", "Wenn du diese Option aktivierst, kannst du dabei helfen Fehler zu identifizieren."],
540 her: ["Thrakische Eroberung", "Verkleinerung der Karte der Thrakischen Eroberung."]
541 },
542 labels: {
543 uni: "Einheitenübersicht",
544 total: "Gesamt",
545 available: "Verfügbar",
546 outer: "Außerhalb",
547 con: "Selektieren",
548 // Smileys
549 std: "Standard",
550 gre: "Grepolis",
551 nat: "Natur",
552 ppl: "Leute",
553 oth: "Sonstige",
554 // Defense form
555 ttl: "Übersicht: Stadtverteidigung",
556 inf: "Informationen zur Stadt:",
557 dev: "Abweichung",
558 det: "Detailierte Landeinheiten",
559 prm: "Premiumboni",
560 sil: "Silberstand",
561 mov: "Truppenbewegungen:",
562 // WW
563 leg: "WW-Anteil",
564 stg: "Stufe",
565 tot: "Gesamt",
566 // Simulator
567 str: "Einheitenstärke",
568 los: "Verluste",
569 mod: "ohne Modifikatoreinfluss",
570 // Comparison box
571 dsc: "Einheitenvergleich",
572 hck: "Schlag",
573 prc: "Stich",
574 dst: "Distanz",
575 sea: "See",
576 att: "Angriff",
577 def: "Verteidigung",
578 spd: "Geschwindigkeit",
579 bty: "Beute (Rohstoffe)",
580 cap: "Transportkapazität",
581 res: "Baukosten (Rohstoffe)",
582 fav: "Gunst",
583 tim: "Bauzeit (s)",
584 // Trade
585 rat: "Ressourcenverhältnis eines Einheitentyps",
586 shr: "Anteil an der Lagerkapazität der Zielstadt",
587 per: "Prozentualer Handel",
588 // Sent units box
589 lab: "Abgeschickt",
590 improved_movement: "Verbesserte Truppenbewegung"
591 },
592 buttons: {
593 sav: "Speichern", ins: "Einfügen", res: "Zurücksetzen"
594 }
595 },
596
597 en: {
598 settings: {
599 dsc: "DIO-Tools offers, among other things, some displays, a smiley box,<br>trade options and some changes to the layout.",
600 act: "Activate/deactivate features of the toolset:",
601 prv: "Preview of several features:",
602
603 version_old: "Version is not up to date",
604 version_new: "Version is up to date",
605 version_dev: "Developer version",
606
607 version_update: "Update",
608
609 link_forum: "http://forum.en.grepolis.com/showthread.php?52104&goto=newpost",
610 link_contact: "http://forum.en.grepolis.com/private.php?do=newpm&u=46211",
611
612 forum: "Forum",
613 author: "Author",
614
615 cat_units: "Units",
616 cat_icons: "Town icons",
617 cat_forum: "Forum",
618 cat_trade: "Trade",
619 cat_wonders: "World wonder",
620 cat_layout: "Layout",
621 cat_other: "Miscellaneous"
622 },
623 options: {
624 //bir: ["Bireme counter", "Counts the biremes of a city and sums these"],
625 ava: ["Units overview", "Counts the units of all cities"],
626 sml: ["Smilies", "Extends the bbcode bar by a smiley box"],
627 str: ["Unit strength", "Adds unit strength tables in various areas"],
628 tra: ["Transport capacity", "Shows the occupied and available transport capacity in the unit menu"],
629 per: ["Percentual trade", "Extends the trade window by a percentual trade"],
630 rec: ["Recruiting trade", "Extends the trade window by a recruiting trade"],
631 cnt: ["Conquests", "Counts the attacks/supports in the conquest window"],
632 way: ["Troop speed", "Displays improved troop speed in the attack/support window"],
633 sim: ["Simulator", "Adaptation of the simulator layout & permanent display of the extended modifier box"],
634 spl: ["Spell box", "Compressed movable & magnetic spell box (position memory)"],
635 act: ["Activity boxes", "Improved display of trade and troop activity boxes (position memory)"],
636 pop: ["Favor popup", "Changes the favor popup"],
637 tsk: ["Taskbar", "Increases the taskbar and minimizes the daily reward window on startup"],
638 cha: ["Chat", 'Replaced the alliance chat by an world chat. (FlashPlayer required)'],
639 bbc: ["Defense form", "Extends the bbcode bar by an automatic defense form"],
640 com: ["Unit Comparison", "Adds unit comparison tables"],
641 tic: ["Town icons", "Each city receives an icon for the town type (automatic detection)", "Additional icons are available for manual selection"],
642 til: ["Town list", "Adds the town icons to the town list"],
643 tim: ["Map", "Sets the town icons on the strategic map"],
644 wwc: ["Calculator", "Share calculation & resources counter + previous & next buttons on finished world wonders (currently not deactivatable!)"],
645 wwr: ["Ranking", "Redesigned world wonder rankings"],
646 wwi: ["Icons", 'Adds world wonder icons on the strategic map'],
647 con: ["Context menu", 'Swaps "Select town" and "City overview" in the context menu'],
648 sen: ["Sent units", 'Shows sent units in the attack/support window'],
649 tov: ["Town overview", 'Replaces the new town overview with the old window style'],
650 scr: ["Mouse wheel", 'You can change the views with the mouse wheel'],
651
652 err: ["Send bug reports automatically", "If you activate this option, you can help identify bugs."],
653 her: ["Thracian Conquest", "Downsizing of the map of the Thracian conquest."]
654 },
655 labels: {
656 uni: "Units overview",
657 total: "Total",
658 available: "Available",
659 outer: "Outside",
660 con: "Select town",
661 // Smileys
662 std: "Standard",
663 gre: "Grepolis",
664 nat: "Nature",
665 ppl: "People",
666 oth: "Other",
667 hal: "Halloween",
668 xma: "Xmas",
669 // Defense form
670 ttl: "Overview: Town defense",
671 inf: "Town information:",
672 dev: "Deviation",
673 det: "Detailed land units",
674 prm: "Premium bonuses",
675 sil: "Silver volume",
676 mov: "Troop movements:",
677 // WW
678 leg: "WW Share",
679 stg: "Stage",
680 tot: "Total",
681 // Simulator
682 str: "Unit strength",
683 los: "Loss",
684 mod: "without modificator influence",
685 // Comparison box
686 dsc: "Unit comparison",
687 hck: "Blunt",
688 prc: "Sharp",
689 dst: "Distance",
690 sea: "Sea",
691 att: "Offensive",
692 def: "Defensive",
693 spd: "Speed",
694 bty: "Booty (resources)",
695 cap: "Transport capacity",
696 res: "Costs (resources)",
697 fav: "Favor",
698 tim: "Recruiting time (s)",
699 // Trade
700 rat: "Resource ratio of an unit type",
701 shr: "Share of the storage capacity of the target city",
702 per: "Percentage trade",
703 // Sent units box
704 lab: "Sent units",
705 improved_movement: "Improved troop movement"
706 },
707 buttons: {
708 sav: "Save", ins: "Insert", res: "Reset"
709 }
710 },
711 //////////////////////////////////////////////
712 // French Translation by eclat49 //
713 //////////////////////////////////////////////
714 fr: {
715 settings: {
716 dsc: "DIO-Tools offres certains écrans, une boîte de smiley, les options <br>commerciales, des changements à la mise en page et d'autres choses.",
717 act: "Activation/Désactivation des fonctions:",
718 prv: "Aperçu des fonctions séparées:"
719 },
720 options: {
721 //bir: ["Compteur de birèmes ", "Totalise l'ensemble des birèmes présentent en villes et les résume. (Remplace la mini carte dans le cadran)"],
722 ava: ["Présentation des unités", "Indique les unités de toutes les villes."],
723 sml: ["Smileys", "Rajoutes une boite de smilies à la boite de bbcode"],
724 str: ["Force unitaire", "Ajoutes des tableaux de force unitaire dans les différentes armes"],
725 //trd: [ "Commerce", "Ajout d'une option par pourcentage, par troupes pour le commerce, ainsi qu'un affichage des limites pour les festivals" ],
726 per: ["Commerce de pourcentage", ""],
727 rec: ["Commerce de recrutement", ""],
728 cnt: ["Compteur conquête", "Comptabilise le nombre d'attaque et de soutien dans la fenêtre de conquête"],
729 way: ["Vitesse des troupes ", "Rajoutes le temps de trajet avec le bonus accélération"],
730 sim: ["Simulateur", "Modification de la présentation du simulateur et affichage permanent des options premium"],
731 spl: ["Boîte de magie", "Boîte de sort cliquable et positionnable"],
732 act: ["Boîte d'activité", "Présentation améliorée du commerce et des mouvement de troupes (mémoire de position)"],
733 pop: ["Popup de faveur", 'Change la popup de faveur'],
734 tsk: ["Barre de tâches ", "La barre de tâches augmente et minimise le fenêtre de bonus journalier"],
735 cha: ["Chat", "Remplace le chat de l'alliance à travers un chat monde."],
736 bbc: ["Formulaire de défense", "Ajout d'un bouton dans la barre BBCode pour un formulaire de défense automatique"],
737 com: ["Comparaison des unités", "Ajoutes des tableaux de comparaison des unités"],
738 tic: ["Icônes des villes", "Chaque ville reçoit une icône pour le type de ville (détection automatique)", "Des icônes supplémentaires sont disponibles pour la sélection manuelle"],
739 til: ["Liste de ville", "Ajoute les icônes de la ville à la liste de la ville"],
740 tim: ["Carte", "Définit les icônes de la ville sur la carte stratégique"],
741 wwc: ["Merveille du monde", "Compteur de ressource et calcul d'envoi + bouton précédent et suivant sur les merveilles finies(ne peut être désactivé pour le moment)"],
742 wwr: ["", ""],
743 //wwi: [ "Icônes",'Adds world wonder icons on the strategic map' ],
744 con: ["Menu contextuel", 'Swaps "Sélectionner ville" et "Aperçu de la ville" dans le menu contextuel'],
745 sen: ["Unités envoyées", 'Affiche unités envoyées dans la fenêtre attaque/support'],
746 tov: ["Aperçu de ville", "Remplace la nouvelle aperçu de la ville avec l'ancien style de fenêtre"],
747 scr: ["Molette de la souris", 'Avec la molette de la souris vous pouvez changer les vues'],
748
749 err: ["Envoyer des rapports de bogues automatiquement", "Si vous activez cette option, vous pouvez aider à identifier les bugs."]
750 },
751 labels: {
752 uni: "Présentation des unités",
753 total: "Global",
754 available: "Disponible",
755 outer: "Extérieur",
756 con: "Sélectionner",
757 // Smileys
758 std: "Standard",
759 gre: "Grepolis",
760 nat: "Nature",
761 ppl: "Gens",
762 oth: "Autres",
763 // Defense form
764 ttl: "Aperçu: Défense de ville",
765 inf: "Renseignements sur la ville:",
766 dev: "Différence",
767 det: "Unités terrestres détaillées",
768 prm: "Bonus premium",
769 sil: "Remplissage de la grotte",
770 mov: "Mouvements de troupes:",
771 // WW
772 leg: "Participation",
773 stg: "Niveau",
774 tot: "Total",
775 // Simulator
776 str: "Force unitaire",
777 los: "Pertes",
778 mod: "sans influence de modificateur",
779 // Comparison box
780 dsc: "Comparaison des unités",
781 hck: "Contond.",
782 prc: "Blanche",
783 dst: "Jet",
784 sea: "Navale",
785 att: "Attaque",
786 def: "Défense",
787 spd: "Vitesse",
788 bty: "Butin",
789 cap: "Capacité de transport",
790 res: "Coût de construction",
791 fav: "Faveur",
792 tim: "Temps de construction (s)",
793 // Trade
794 rat: "Ratio des ressources d'un type d'unité",
795 shr: "Part de la capacité de stockage de la ville cible",
796 per: "Commerce de pourcentage",
797 // Sent units box
798 lab: "Envoyée",
799 improved_movement: "Mouvement des troupes amélioré"
800 },
801 buttons: {
802 sav: "Sauver", ins: "Insertion", res: "Remettre"
803 }
804 },
805 //////////////////////////////////////////////
806 // Russian Translation by MrBobr //
807 //////////////////////////////////////////////
808 ru: {
809 settings: {
810 dsc: "DIO-Tools изменÑет некоторые окна, добавлÑет новые Ñмайлы, отчёты,<br>улучшеные варианты торговли и другие функции.",
811 act: "Включение/выключение функций:",
812 prv: "Примеры внеÑённых изменений:"
813 },
814 options: {
815 //bir: ["Счётчик бирем", "Показывает чиÑло бирем во вÑех городах"],
816 ava: ["Обзор единиц", "Указывает единицы вÑех городов"], // ?
817 sml: ["Смайлы", "ДобавлÑет кнопку Ð´Ð»Ñ Ð²Ñтавки Ñмайлов в ÑообщениÑ"],
818 str: ["Сила отрÑда", "ДобавлÑет таблицу общей Ñилы отрÑда в некоторых окнах"],
819 //trd: [ "ТорговлÑ", "ДобавлÑет маркеры и отправку недоÑтающих реÑурÑов, необходимых Ð´Ð»Ñ Ñ„ÐµÑтивалÑ. ИнÑтрументы Ð´Ð»Ñ Ð´Ð¾Ð»ÐµÐ²Ð¾Ð¹ торговли" ],
820 per: ["Процент торговлÑ", ""],
821 rec: ["Рекрутинг торговлÑ", ""],
822 cnt: ["ЗавоеваниÑ", "Отображение общего чиÑла атак/подкреплений в окне Ð·Ð°Ð²Ð¾ÐµÐ²Ð°Ð½Ð¸Ñ Ð³Ð¾Ñ€Ð¾Ð´Ð°"],
823 way: ["30% уÑкорение", "Отображает примерное Ð²Ñ€ÐµÐ¼Ñ Ð´Ð²Ð¸Ð¶ÐµÐ½Ð¸Ñ Ð¾Ñ‚Ñ€Ñда Ñ 30% бонуÑом"],
824 sim: ["СимулÑтор", "Изменение интерфейÑа ÑимулÑтора, добавление новых функций"],
825 spl: ["ЗаклинаниÑ", "ИзменÑет положение окна заклинаний"],
826 act: ["ПеремещениÑ", "Показывает окна переÑылки реÑурÑов и Ð¿ÐµÑ€ÐµÐ¼ÐµÑ‰ÐµÐ½Ð¸Ñ Ð²Ð¾Ð¹Ñк"],
827 pop: ["БлагоÑклонноÑть", "Отображение окна Ñ ÑƒÑ€Ð¾Ð²Ð½ÐµÐ¼ благоÑклонноÑти богов"],
828 tsk: ["ТаÑкбар", "Увеличение ширины таÑкбара и Ñворачивание окна ежедневной награды при входе в игру"],
829 // cha: ["Чат", 'Замена чата игры на irc-чат'],
830 bbc: ["Форма обороны", "ДобавлÑет кнопку Ð´Ð»Ñ Ð²Ñтавки в Ñообщение отчёта о городе"], // Beschreibung passt nicht ganz
831 com: ["Сравнение юнитов", "ДобавлÑет окно ÑÑ€Ð°Ð²Ð½ÐµÐ½Ð¸Ñ ÑŽÐ½Ð¸Ñ‚Ð¾Ð²"],
832 tic: ["Типы городов", "Каждый город получает значок Ð´Ð»Ñ Ð³Ð¾Ñ€Ð¾Ð´Ñкого типа (автоматичеÑкое определение)", "Дополнительные иконки доÑтупны Ð´Ð»Ñ Ñ€ÑƒÑ‡Ð½Ð¾Ð³Ð¾ выбора"], // ?
833 til: ["СпиÑок город", "ДобавлÑет значки городÑкие в ÑпиÑок города"], // ?
834 tim: ["Карта", "УÑтанавливает городÑкие иконки на ÑтратегичеÑкой карте"], // ?
835 wwc: ["Чудо Ñвета", "Share calculation & resources counter + previous & next buttons on finished world wonders (currently not deactivatable!)"],
836 wwr: ["", ""],
837 //wwi: [ "World wonder icons",'Adds world wonder icons on the strategic map' ],
838 //con: [ "Context menu", 'Swaps "Select town" and "City overview" in the context menu'],
839 //sen: [ "Sent units", 'Shows sent units in the attack/support window'],
840 tov: ["Обзор Город", 'ЗаменÑет новый обзор города Ñ Ñтаром Ñтиле окна'], // ?
841 scr: ["КолеÑо мыши", 'С помощью колеÑа мыши вы можете изменить взглÑды'], // ?
842
843 err: ["Отправить ÑÐ¾Ð¾Ð±Ñ‰ÐµÐ½Ð¸Ñ Ð¾Ð± ошибках автоматичеÑки", "ЕÑли вы включите Ñту опцию, вы можете помочь идентифицировать ошибки"]
844 },
845
846 labels: {
847 uni: "Обзор единиц",
848 total: "Oбщий",
849 available: "доÑтупный",
850 outer: "вне",
851 con: "выбирать",
852 // Smileys
853 std: "",
854 gre: "",
855 nat: "",
856 ppl: "",
857 oth: "",
858 // Defense form
859 ttl: "Обзор: Отчёт о городе",
860 inf: "Ð˜Ð½Ñ„Ð¾Ñ€Ð¼Ð°Ñ†Ð¸Ñ Ð¾ войÑках и поÑтройках:",
861 dev: "Отклонение",
862 det: "Детальный отчёт",
863 prm: "Премиум-бонуÑÑ‹",
864 sil: "Серебро в пещере",
865 mov: "ПеремещениÑ",
866 // WW
867 leg: "",
868 stg: "",
869 tot: "",
870 // Simulator
871 str: "Сила войÑк",
872 los: "Потери",
873 mod: "без учёта заклинаний, бонуÑов, иÑÑледований",
874 // Comparison box
875 dsc: "Сравнение юнитов",
876 hck: "Ударное",
877 prc: "Колющее",
878 dst: "Дальнего боÑ",
879 sea: "МорÑкие",
880 att: "Ðтака",
881 def: "Защита",
882 spd: "СкороÑть",
883 bty: "Добыча (реÑурÑÑ‹)",
884 cap: "ВмеÑтимоÑть транÑпортов",
885 res: "СтоимоÑть (реÑурÑÑ‹)",
886 fav: "БлагоÑклонноÑть",
887 tim: "Ð’Ñ€ÐµÐ¼Ñ Ð½Ð°Ð¹Ð¼Ð° (Ñ)",
888 // Trade
889 rat: "",
890 shr: "",
891 per: "",
892 // Sent units box
893 lab: "Отправлено",
894 improved_movement: "Ð£Ð»ÑƒÑ‡ÑˆÐµÐ½Ð½Ð°Ñ Ð¿ÐµÑ€ÐµÐ¼ÐµÑ‰ÐµÐ½Ð¸Ðµ войÑк"
895 },
896
897 buttons: {
898 sav: "Сохраниить", ins: "Ð’Ñтавка", res: "СброÑ"
899 }
900 },
901 //////////////////////////////////////////////
902 // Polish Translation by anpu //
903 //////////////////////////////////////////////
904 pl: {
905 settings: {
906 dsc: "DIO-Tools oferuje (między innymi) poprawione widoki, nowe uśmieszki,<br>opcje handlu i zmiany w wyglądzie.",
907 act: "Włącz/wyłącz funkcje skryptu:",
908 prv: "podgląd poszczególnych opcji:"
909 },
910 options: {
911 //bir: ["Licznik birem", "Zlicza i sumuje biremy z miast"],
912 ava: ["PrzeglÄ…d jednostek", "Wskazuje jednostki wszystkich miast"], // ?
913 sml: ["Emotki", "Dodaje dodatkowe (zielone) emotikonki"],
914 str: ["Siła jednostek", "dodaje tabelki z siłą jednostek w różnych miejscach gry"],
915 //trd: [ "Handel", "Rozszerza okno handlu o handel procentowy, proporcje surowców wg jednostek, dodaje znaczniki dla festynów" ],
916 per: ["Handel procentowy", ""],
917 rec: ["Handel rekrutacyjne", ""],
918 cnt: ["Podboje", "Zlicza wsparcia/ataki w oknie podboju (tylko własne podboje)"],
919 way: ["Prędkość wojsk", "Wyświetla dodatkowo czas jednostek dla bonusu przyspieszone ruchy wojsk"],
920 sim: ["Symulator", "Dostosowanie wyglądu symulatora oraz dodanie szybkich pól wyboru"],
921 spl: ["Ramka czarów", "Kompaktowa pływająca ramka z czarami (można umieścić w dowolnym miejscu ekranu. Zapamiętuje położenie.)"],
922 act: ["Ramki aktywności", "Ulepszony podgląd ruchów wojsk i handlu (można umieścić w dowolnym miejscu ekranu. Zapamiętuje położenie.)"],
923 pop: ["Åaski", "Zmienia wyglÄ…d ramki informacyjnej o iloÅ›ci produkowanych Å‚ask"],
924 tsk: ["Pasek skrótów", "Powiększa pasek skrótów i minimalizuje okienko z bonusem dziennym"],
925 // cha: ["Czat", 'Zastępuje standardowy Chat chatem IRC'],
926 bbc: ["Raportów obronnych", "Rozszerza pasek skrótów BBcode o generator raportów obronnych"],
927 com: ["Porównianie", "Dodaje tabelki z porównaniem jednostek"],
928 tic: ["Ikony miasta", "Każde miasto otrzyma ikonę typu miasta (automatyczne wykrywanie)", "Dodatkowe ikony są dostępne dla ręcznego wyboru"], // ?
929 til: ["Lista miasto", "Dodaje ikony miasta do listy miasta"], // ?
930 tim: ["Mapa", "Zestawy ikon miasta na mapie strategicznej"], // ?
931 wwc: ["Cuda Świata", "Liczy udział w budowie oraz ilość wysłanych surowców na budowę Cudu Świata oraz dodaje przyciski do szybkiego przełączania między cudami (obecnie nie możliwe do wyłączenia)"],
932 wwr: ["", ""],
933 //wwi: [ "World wonder icons",'Adds world wonder icons on the strategic map' ],
934 con: ["menu kontekstowe", 'Zamiemia miejcami przycisk "wybierz miasto" z przyciskiem "podgląd miasta" po kliknięciu miasta na mapie'],
935 sen: ["Wysłane jednostki", 'Pokaż wysłane jednostki w oknie wysyłania ataków/wsparć'],
936 tov: ["Podgląd miasta", 'Zastępuje nowy podgląd miasta starym'],
937 scr: ["Zoom", 'Możesz zmienić poziom przybliżenia mapy kółkiem myszy'],
938
939 err: ["Automatycznie wysyłać raporty o błędach", "Jeśli włączysz tę opcję, możesz pomóc zidentyfikować błędy"]
940
941 },
942 labels: {
943 uni: "PrzeglÄ…d jednostek",
944 total: "Ogólny",
945 available: "Dostępny",
946 outer: "Na zewnÄ…trz",
947 con: "Wybierz miasto",
948 // Smileys
949 std: "Standard" /* "Standardowe" */,
950 gre: "Grepolis",
951 nat: "Przyroda",
952 ppl: "Ludzie",
953 oth: "Inne",
954 // Defense form
955 ttl: "PodglÄ…d: Obrona miasta",
956 inf: "Informacje o mieście:",
957 dev: "Ochyłka",
958 det: "jednostki lÄ…dowe",
959 prm: "opcje Premium",
960 sil: "Ilość srebra",
961 mov: "Ruchy wojsk",
962 // WW
963 leg: "Udział w Cudzie",
964 stg: "Poziom",
965 tot: "ÅÄ…cznie",
966 // Simulator
967 str: "Siła jednostek",
968 los: "Straty",
969 mod: "bez modyfikatorów",
970 // Comparison box
971 dsc: "Porównianie jednostek",
972 hck: "Obuchowa",
973 prc: "TnÄ…ca",
974 dst: "Dystansowa",
975 sea: "Morskie",
976 att: "Offensywne",
977 def: "Defensywne",
978 spd: "Prędkość",
979 bty: "Åup (surowce)",
980 cap: "Pojemność transportu",
981 res: "Koszta (surowce)",
982 fav: "Åaski",
983 tim: "Czas rekrutacji (s)",
984 // Trade
985 rat: "Stosunek surowców dla wybranej jednostki",
986 shr: "procent zapełnienia magazynu w docelowym mieście",
987 per: "Handel procentowy",
988 // Sent units box
989 lab: "Wysłane jednostki",
990 improved_movement: "Przyspieszone ruchy wojsk"
991 },
992 buttons: {
993 sav: "Zapisz", ins: "Wstaw", res: "Anuluj"
994 }
995 },
996 //////////////////////////////////////////////
997 // Spanish Translation by Juana de Castilla //
998 //////////////////////////////////////////////
999 es: {
1000 settings: {
1001 dsc: "DIO-Tools ofrece, entre otras cosas, varias pantallas, ventana de <br>emoticones, opciones de comercio y algunos cambios en el diseño.",
1002 act: "Activar/desactivar caracterÃsticas de las herramientas:",
1003 prv: "Vista previa de varias caracterÃsticas:"
1004 },
1005 options: {
1006 //bir: ["Contador de birremes", "Cuenta los birremes de una ciudad y los suma"],
1007 ava: ["Información general unidades", "Indica las unidades de todas las ciudades"], // ?
1008 sml: ["Emoticones", "Código BB para emoticones"],
1009 str: ["Fortaleza de la Unidad", "Añade tabla de fortalezas de cada unidad en varias zonas"],
1010 //trd: [ "Comercio", "Añade en la pestaña de comercio un porcentaje de comercio y reclutamiento y limitadores de Mercado por cada ciudad" ],
1011 per: ["Comercio de porcentual", ""],
1012 rec: ["Comercio de reclutamiento", ""],
1013 cnt: ["Conquistas", "contador de ataques y refuerzos en la pestaña de conquista"],
1014 way: ["Velocidad de tropas", "Muestra movimiento de tropas mejorado en la ventana de ataque/refuerzo"],
1015 sim: ["Simulador", "Adaptación de la ventana del simulador incluyendo recuadro de modificadores"],
1016 spl: ["Ventana de hechizos", "Ventana deslizante y comprimida de los hechizos (memoria posicional)"],
1017 act: ["Ventana de actividad", "Mejora las ventanas de comercio y movimiento de tropas (memoria posicional)"],
1018 pop: ["Popup", "Cambia el popup de favores"],
1019 tsk: ["Barra de tareas", "aumenta la barra de tareas y minimice la recompensa al aparecer"],
1020 // cha: ["Chat", 'Sustituye el chat de la alianza con un irc chat.'],
1021 bbc: ["Formulario de defensa", "Añade en la barra de códigos bb un formulario de defensa"],
1022 com: ["Comparación", "añade ventana de comparación de unidades"],
1023 tic: ["Iconos de la ciudad", "Cada ciudad recibe un icono para el tipo de la ciudad (detección automática)", "Iconos adicionales están disponibles para la selección manual"],
1024 til: ["Lista de la ciudad", "Agrega los iconos de la ciudad a la lista de la ciudad"],
1025 tim: ["Map", "Establece los iconos de la ciudad en el mapa estratégico"],
1026 wwc: ["Maravillas", "Calcula participación & contador de recursos + antes y después teclas de maravillas terminadas (no desactibable ahora!)"],
1027 wwr: ["", ""],
1028 //wwi: [ "World wonder icons",'Adds world wonder icons on the strategic map' ],
1029 con: ["menú contextual", 'Cambia "Elegir ciudad" y "vista de la ciudad" en el menú contextual '],
1030 sen: ["Unidades enviadas", 'Muestra las unidades enviadas en la ventana de ataque/refuerzos'],
1031 tov: ["Información de la ciudad", 'sustituye la vista nueva de ciudad por la ventana antigua'],
1032 scr: ["Rueda raton", 'Puede cambiar las vistas con la rueda del raton'],
1033
1034 err: ["Enviar informes de errores automáticamente", "Si se activa esta opción, puede ayudar a identificar errores."]
1035 },
1036 labels: {
1037 uni: "Información general unidades",
1038 total: "Total",
1039 available: "Disponible",
1040 outer: "Fuera",
1041 con: "Escoger ciudad",
1042 // Smileys
1043 std: "Standard",
1044 gre: "Grepolis",
1045 nat: "Natura",
1046 ppl: "Gente",
1047 oth: "Otros",
1048 // Defense form
1049 ttl: "Vista general: Defensa de la ciudad",
1050 inf: "Información de la ciudad:",
1051 dev: "Desviación",
1052 det: "Unidades de tierra detalladas",
1053 prm: "Bonos Premium",
1054 sil: "Volumen de plata",
1055 mov: "Movimientos de tropas:",
1056 // WW
1057 leg: "WW cuota",
1058 stg: "Nivel",
1059 tot: "Total",
1060 // Simulator
1061 str: "Fortaleza de la Unidad",
1062 los: "Perdida",
1063 mod: "sin influencia del modificador",
1064 // Comparison box
1065 dsc: "Comparación de Unidades",
1066 hck: "Contundente",
1067 prc: "Punzante",
1068 dst: "Distancia",
1069 sea: "Mar",
1070 att: "Ataque",
1071 def: "Defensa",
1072 spd: "Velocidad",
1073 bty: "BotÃn (recursos)",
1074 cap: "Capacidad de transporte",
1075 res: "Costes (recursos)",
1076 fav: "Favor",
1077 tim: "Tiempo de reclutamiento (s)",
1078 // Trade
1079 rat: "Proporción de recursos de un tipo de unidad",
1080 shr: "Porcentaje de la capacidad de almacenamiento de la ciudad destino",
1081 per: "Porcentaje de comercio",
1082 // Sent units box
1083 lab: "Unidades enviadas",
1084 improved_movement: "Movimiento de tropas mejorados"
1085 },
1086 buttons: {
1087 sav: "Guardar", ins: "Insertar", res: "Reinicio"
1088 }
1089 },
1090 ar: {},
1091 //////////////////////////////////////////////
1092 // Portuguese (BR) Translation by HELL //
1093 //////////////////////////////////////////////
1094 br: {
1095 settings: {
1096 dsc: "DIO-Tools oferece, entre outras coisas, algumas telas, uma caixa de smiley, opções de comércio <br> e algumas alterações no layout.",
1097 act: "Ativar/desativar recursos do conjunto de ferramentas:",
1098 prv: "Pré-visualização de vários recursos:",
1099
1100 version_old: "Versão não está atualizada",
1101 version_new: "Versão está atualizada",
1102 version_dev: "Versão do desenvolvedor",
1103
1104 version_update: "Atualização",
1105
1106 link_forum: "http://forum.en.grepolis.com/showthread.php?52104&goto=newpost",
1107 link_contact: "http://forum.en.grepolis.com/private.php?do=newpm&u=46211",
1108
1109 forum: "Forum",
1110 author: "Autor",
1111
1112 cat_units: "Unidades",
1113 cat_icons: "Ãcones nas Cidades",
1114 cat_forum: "Forum",
1115 cat_trade: "Comércio",
1116 cat_wonders: "Maravilhas do Mundo",
1117 cat_layout: "Layout",
1118 cat_other: "Outros"
1119 },
1120 options: {
1121 // bir: ["Contador de Birremes", "Conta as biremes da cidade na cidade"],
1122 ava: ["Visão Geral da unidade", "Indica as unidades de todas as cidades"], // ?
1123 sml: ["Smilies", "Estende o bbcode com uma caixa de smiley"],
1124 str: ["Força das Tropas", "Adiciona quadros de força das tropas em diversas áreas"],
1125 tra: ["Capacidade de Transporte", "Mostra a capacidade de transporte ocupado e disponÃvel no menu de unidades"],
1126 per: ["Percentual de comércio", "Estende-se a janela de comércio com um percentual de comércio"],
1127 rec: ["Comércio para recrutamento", "Estende-se a janela de comércio com um comércio de recrutamento"],
1128 cnt: ["Conquistas", "Conta os ataques/apoios na janela de conquista"],
1129 way: ["Velocidade da Tropa", "Displays mostram a possivél velocidade de tropa na janela de ataque/suporte"],
1130 sim: ["Simulador", "Adaptação do layout simulador & exposição permanente da caixa poderes estendida"],
1131 spl: ["Caixa de Poderes Divinos", "Pequena caixa móvel & magnética de poderes divinos (com memória de posição) "],
1132 act: ["Ativar caixas suspensas de comércio e ataque", "Melhorias da exibição de caixas de comércio e atividade tropa (com memória de posição)"],
1133 pop: ["Caixa de favores divino", "Altera a caixa de favores divino por um novo layout"],
1134 tsk: ["Barra de tarefas", "Aumenta a barra de tarefas e minimiza a janela recompensa diária no inicio"],
1135 // cha: ["Chat", 'Substituiu o da bate-papo por um bate-papo IRC.'],
1136 bbc: ["Pedido de Apoio", "Estende a barra de bbcode com uma forma de Pedido de Apoio Automática"],
1137 com: ["Comparação de Unidades", "Adiciona tabelas de comparação de unidade"],
1138 tic: ["Ãcones nas Cidades", "Cada cidade recebe um Ãcone para o tipo de tropas na cidade (detecção automática) "," Ãcones adicionais estão disponÃveis para seleção manual"],
1139 til: ["Lista das Cidades", "Adiciona os Ãcones da cidade na lista de cidades"],
1140 tim: ["Mapa", "Mostra os Ãcones das cidades no mapa estratégico"],
1141 wwc: ["Calculadora de WW", "Cálculo compartilhado & contador de recursos + botões anterior e próxima maravilhas do mundo (atualmente não desactivável!)"],
1142 wwr: ["Classificação", "Classificação das maravilha do mundo redesenhadas"],
1143 wwi: ["Icones", 'Adiciona Ãcones nas maravilha do mundo no mapa estratégico'],
1144 con: ["Menu de Contexto", 'Troca da "Selecione cidade" e "Visão Geral da Cidade" no menu de contexto'],
1145 sen: ["Unidades Enviadas", 'Shows sent units in the attack/support window'],
1146 tov: ["Visão da Cidade", 'Substitui o novo panorama da cidade, com o estilo da janela antiga'],
1147 scr: ["Roda do Mouse", 'Você pode alterar os pontos de vista com a roda do mouse'],
1148
1149 err: ["Enviar automaticamente relatórios de erros", "Se você ativar essa opção, você pode ajudar a identificar erros."],
1150 her: ["Conquista Thracian", "Redução de tamanho do mapa da conquista Thracian."]
1151 },
1152 labels: {
1153 uni: "Visão Geral da unidade",
1154 total: "Global",
1155 available: "DisponÃvel",
1156 outer: "Fora",
1157 con: "Selecionar cidade",
1158 // Smileys
1159 std: "Padrão",
1160 gre: "Grepolis",
1161 nat: "Natural",
1162 ppl: "Popular",
1163 oth: "Outros",
1164 hal: "Halloween",
1165 xma: "Natal",
1166 // Defense form
1167 ttl: "Pedido de Apoio",
1168 inf: "Informação da cidade:",
1169 dev: "Desvio",
1170 det: "Unidades Detalhadas",
1171 prm: "Bônus Premium",
1172 sil: "Prata na Gruta",
1173 mov: "Movimentação de Tropas:",
1174 // WW
1175 leg: "WW Maravilhas",
1176 stg: "Level",
1177 tot: "Total",
1178 // Simulator
1179 str: "Força das Unidades",
1180 los: "Perdas",
1181 mod: "Sem modificador de influência",
1182 // Comparison box
1183 dsc: "Comparação de unidades",
1184 hck: "Impacto",
1185 prc: "Corte",
1186 dst: "Arremço",
1187 sea: "Naval",
1188 att: "Ofensivo",
1189 def: "Defensivo",
1190 spd: "Velocidade",
1191 bty: "Saque (recursos)",
1192 cap: "Capacidade de trasporte",
1193 res: "Custo (recursos)",
1194 fav: "Favor",
1195 tim: "Tempo de recrutamento (s)",
1196 // Trade
1197 rat: "Proporção de recursos de um tipo de unidade",
1198 shr: "A partir do armazenamento sobre a cidade de destino",
1199 per: "Percentual de comércio",
1200 // Sent units box
1201 lab: "Unidades enviadas",
1202 improved_movement: "Movimentação de tropas com ajuste de bônus"
1203 },
1204 buttons: {
1205 sav: "Salvar", ins: "Inserir", res: "Resetar"
1206 }
1207 },
1208 pt : {},
1209 //////////////////////////////////////////////
1210 // Czech Translation by Piwus //
1211 //////////////////////////////////////////////
1212 cz: {
1213 settings: {
1214 dsc: "DIO-Tools nabÃzÃ,mimo jiné,nÄ›která nová zobrazenÃ,okénko smajlÃků,<br>obchodnà možnosti a nÄ›které zmÄ›ny v rozloženà panelů.",
1215 act: "Aktivovat/Deaktivovat funkce sady nástrojů:",
1216 prv: "Ukázka nÄ›kolika funkcÃ:",
1217
1218 version_old: "Verze je zastaralá",
1219 version_new: "Verze je aktuálnÃ",
1220 version_dev: "Vývojářská verze",
1221
1222 version_update: "Aktualizovat",
1223
1224 link_forum: "http://forum.en.grepolis.com/showthread.php?52104&goto=newpost",
1225 link_contact: "http://forum.en.grepolis.com/private.php?do=newpm&u=46211",
1226
1227 forum: "Forum",
1228 author: "Autor",
1229
1230 cat_units: "Jednotky",
1231 cat_icons: "Ikony měst",
1232 cat_forum: "Forum",
1233 cat_trade: "Obchod",
1234 cat_wonders: "Div světa",
1235 cat_layout: "Okna",
1236 cat_other: "OstatnÃ"
1237 },
1238 options: {
1239 // bir: ["PoÄÃtadlo birém", "SpoÄÃtá každé birémy ve mÄ›stech a seÄte je."],
1240 ava: ["Jednotky PÅ™ehled", "OznaÄuje jednotky vÅ¡emi mÄ›sty"], // ?
1241 sml: ["SmajlÃci", "RozÅ¡iÅ™uje panel BBkodů okénkem smajlÃků"],
1242 str: ["SÃla jednotek", "PÅ™idává tabulku sil jednotek v různých oblastech"],
1243 tra: ["Transportnà kapacita", "Zobrazuje obsazenou a dostupnou transportnà kapacitu v nabÃdce jednotek"],
1244 per: ["Procentuálnà obchod", "RozÅ¡iÅ™uje obchodnà okno možnostà procentuálnÃho obchodu"],
1245 rec: ["Obchod rekrutace", "Rozšiřuje obchodnà okno možnostà obchodem pro rekrutaci"],
1246 cnt: ["DobývánÃ", "PoÄÃtá Útok/Obrana v oknÄ› dobývánà (pouze vlastnà dobývánà zatÃm)"],
1247 way: ["Rychlost vojsk", "Zobrazuje vylepšenou rychlost vojsk v okně útoku/obrany"],
1248 sim: ["Simulátor", "PÅ™izpůsobenà rozloženà simulátoru & permanentnà zobrazovánà rozÅ¡ÃÅ™eného okna modifikátoru"],
1249 spl: ["Okénko kouzel", "StlaÄené klouzánà oken & magnetické okénko kouzel (pozice pamÄ›ti)"],
1250 act: ["Aktivnà okénka", "ZlepÅ¡ený zobrazenà obchodů a vojsk aktivnÃmi okénky (pozice pamÄ›ti)"],
1251 pop: ["Vyskakovacà okénko pÅ™ÃznÄ›", "ZmÄ›nà vyskakovacà okno seznamu pÅ™ÃznÃ"],
1252 tsk: ["Hlavnà panel", "ZvyÅ¡uje hlavnà panel a minimalizuje bonus dennà odmÄ›ny po pÅ™ihlášenÃ"],
1253 // cha: ["Chat", 'Nahrazen alianÄnà chat chatem IRC.'],
1254 bbc: ["Obranné hlášenÃ", "RozÅ¡iÅ™uje panel BBkodů automatickém hlášenà obrany mÄ›sta"],
1255 com: ["Porovnánà jednotek", "Přidává tabulku porovnánà jednotek"],
1256 tic: ["Ikony měst", "Každé město dostává svojà ikonku dle typu města (automatická detekce)", "Dalšà ikonky jsou k dispozici manuálně"],
1257 til: ["Seznam měst", "Přidává ikony měst do seznamu měst"],
1258 tim: ["Mapa", "Přidává ikony měst na stategickou mapu"],
1259 wwc: ["KalkulaÄka", "VýpoÄet podÃlu & poÄÃtadlo surovin + pÅ™edchozà & dalšà tlaÄÃtka na dokonÄených divech svÄ›ta (aktuálnÄ› nelze deaktivovat!)"],
1260 wwr: ["ŽebÅ™ÃÄek", "PÅ™edÄ›laný žebÅ™ÃÄek divů svÄ›ta"],
1261 wwi: ["Ikony", 'PÅ™Ãdává ikony divů svÄ›ta na strategickou mapu'],
1262 con: ["Kontextové menu", 'Vyměňuje "Vybrat město" a "Přehled města" v kontextovém menu'],
1263 sen: ["Odeslané jednotky", 'Zobrazuje odeslané jednotky útoku/obrany v okně'],
1264 tov: ["PÅ™ehled mÄ›sta", 'Nahrazuje nový pÅ™ehled mÄ›st starÅ¡Ãm stylem okna'],
1265 scr: ["KoleÄko myÅ¡i", 'MůžeÅ¡ zmÄ›nit pohledy s koleÄkem myÅ¡i'],
1266
1267 err: ["Hlásit chyby automaticky", "Pokud aktivuješ tuto možnost,pomůžeš nám identifikovat chyby."],
1268 her: ["Thrácké dobývánÃ", "Redukuje mapy Thráckého dobývánÃ."]
1269 },
1270 labels: {
1271 uni: "Jednotky Přehled",
1272 total: "Celkový",
1273 available: "K dispozici",
1274 outer: "VnÄ›",
1275 con: "Zvolit město",
1276 // Smileys
1277 std: "StandartnÃ",
1278 gre: "Grepolis",
1279 nat: "PÅ™Ãroda",
1280 ppl: "Lidi",
1281 oth: "OstatnÃ",
1282 hal: "Halloween",
1283 xma: "Vánoce",
1284 // Defense form
1285 ttl: "Přehled: Obrana města",
1286 inf: "Informace o městě:",
1287 dev: "Odchylka",
1288 det: "Podrobné pozemnà jednotky",
1289 prm: "Prémiové bonusy",
1290 sil: "Objem stÅ™Ãbra",
1291 mov: "Pohyby vojsk:",
1292 // WW
1293 leg: "PodÃl divu svÄ›ta",
1294 stg: "Stupeň",
1295 tot: "Celkem",
1296 // Simulator
1297 str: "SÃla jednotek",
1298 los: "Ztráta",
1299 mod: "bez vlivu modifikátoru",
1300 // Comparison box
1301 dsc: "Porovnánà jednotek",
1302 hck: "SeÄné",
1303 prc: "Bodné",
1304 dst: "Střelné",
1305 sea: "Moře",
1306 att: "ÚtoÄné",
1307 def: "Obranné",
1308 spd: "Rychlost",
1309 bty: "Kořist (suroviny)",
1310 cap: "Transportnà kapacita",
1311 res: "Náklady (suroviny)",
1312 fav: "PÅ™Ãzeň",
1313 tim: "Doba rekrutovánà (s)",
1314 // Trade
1315 rat: "Poměr surovin typu jednotky",
1316 shr: "PodÃl na úložné kapacitÄ› cÃlového mÄ›sta",
1317 per: "Procentuálnà obchod",
1318 // Sent units box
1319 lab: "Odeslané jednotky",
1320 improved_movement: "Vylepšený pohyb jednotek"
1321 },
1322 buttons: {
1323 sav: "Uložit", ins: "Vložit", res: "Resetovat"
1324 }
1325 }
1326 };
1327
1328 LANG.ar = LANG.es;
1329 LANG.pt = LANG.br;
1330 LANG.cs = LANG.cz;
1331
1332 // Create JSON
1333 // console.log(JSON.stringify(LANG.en));
1334
1335 // Forum: Choose language
1336 if (!(uw.location.pathname.indexOf("game") >= 0)) {
1337 LID = uw.location.host.split(".")[1];
1338 }
1339
1340 console.debug("SPRACHE", LID);
1341 // Translation GET
1342 function getText(category, name) {
1343 var txt = "???";
1344 if (LANG[LID]) {
1345 if (LANG[LID][category]) {
1346 if (LANG[LID][category][name]) {
1347 txt = LANG[LID][category][name];
1348 } else {
1349 if (LANG.en[category]) {
1350 if (LANG.en[category][name]) {
1351 txt = LANG.en[category][name];
1352 }
1353 }
1354 }
1355 } else {
1356 if (LANG.en[category]) {
1357 if (LANG.en[category][name]) {
1358 txt = LANG.en[category][name];
1359 }
1360 }
1361 }
1362 } else {
1363 if (LANG.en[category]) {
1364 if (LANG.en[category][name]) {
1365 txt = LANG.en[category][name];
1366 }
1367 }
1368 }
1369 return txt;
1370 }
1371
1372 /*******************************************************************************************************************************
1373 * Settings
1374 *******************************************************************************************************************************/
1375
1376 // (De)activation of the features
1377 var options_def = {
1378 bir: true, // Biremes counter
1379 ava: true, // Available units
1380 sml: true, // Smileys
1381 str: true, // Unit strength
1382 tra: true, // Transport capacity
1383 per: true, // Percentual Trade
1384 rec: true, // Recruiting Trade
1385 way: true, // Troop speed
1386 cnt: true, // Attack/support counter
1387 sim: true, // Simulator
1388 spl: true, // Spell box
1389 act: false,// Activity boxes
1390 tsk: true, // Task bar
1391 cha: true, // Chat
1392 pop: true, // Favor popup
1393 bbc: true, // BBCode bar
1394 com: true, // Unit comparison
1395 tic: true, // Town icons
1396 til: true, // Town icons: Town list
1397 tim: true, // Town icons: Map
1398 wwc: true, // World wonder counter
1399 wwr: true, // World wonder ranking
1400 wwi: true, // World wonder icons
1401 con: true, // Context menu
1402 sen: true, // Sent units
1403 tov: false,// Town overview
1404 scr: true, // Mausrad,
1405
1406 err: false,// Error Reports
1407 her: true // Thrakische Eroberung
1408 };
1409
1410 if (uw.location.pathname.indexOf("game") >= 0) {
1411 for (var opt in options_def) {
1412 if (options_def.hasOwnProperty(opt)) {
1413 if (DATA.options[opt] === undefined) {
1414 DATA.options[opt] = options_def[opt];
1415 }
1416 }
1417 }
1418 }
1419
1420 var version_text = '', version_color = 'black';
1421
1422 function getLatestVersion() {
1423 $('<style id="dio_version">' +
1424 '#version_info .version_icon { background: url(http://666kb.com/i/ct1etaz0uyohw402i.png) -50px -50px no-repeat; width:25px; height:25px; float:left; } ' +
1425 '#version_info .version_icon.red { filter:hue-rotate(-100deg); -webkit-filter: hue-rotate(-100deg); } ' +
1426 '#version_info .version_icon.green { filter:hue-rotate(0deg); -webkit-filter: hue-rotate(0deg); } ' +
1427 '#version_info .version_icon.blue { filter:hue-rotate(120deg); -webkit-filter: hue-rotate(120deg); } ' +
1428 '#version_info .version_text { line-height: 2; margin: 0px 6px 0px 6px; float: left;} ' +
1429 '</style>').appendTo("head");
1430
1431 var v_info = $('#version_info');
1432 if (version_text === '') {
1433 $.ajax({
1434 type: "GET", url: "https://diotools.de/scripts/version.php",
1435 success: function (response) {
1436 var latest_version = parseFloat(response),
1437 current_version = parseFloat(version);
1438
1439 if (current_version < latest_version) {
1440 version_text = "<div class='version_icon red'></div><div class='version_text'>" + getText('settings', 'version_old') + "</div><div class='version_icon red'></div>" +
1441 '<a class="version_text" href="https://diotools.de/downloads/DIO-TOOLS.user.js" target="_blank">--> Update</a>';
1442 version_color = 'crimson';
1443 } else if (current_version == latest_version) {
1444 version_text = "<div class='version_icon green'></div><div class='version_text'>" + getText('settings', 'version_new') + "</div><div class='version_icon green'></div>";
1445 version_color = 'darkgreen';
1446 } else {
1447 version_text = "<div class='version_icon blue'></div><div class='version_text'>" + getText('settings', 'version_dev') + "</div><div class='version_icon blue'></div>";
1448 version_color = 'darkblue';
1449 }
1450 v_info.html(version_text).css({color: version_color});
1451 }
1452 });
1453 } else {
1454 v_info.html(version_text).css({color: version_color});
1455 }
1456 }
1457
1458 // Add DIO-Tools to grepo settings
1459 function settings() {
1460 var wid = $(".settings-menu").get(0).parentNode.id;
1461
1462 if (!$("#dio_tools").get(0)) {
1463 $(".settings-menu ul:last").append('<li id="dio_li"><img id="dio_icon" src="http://www.greensmilies.com/smile/smiley_emoticons_smile.gif"></div> <a id="dio_tools" href="#"> DIO-Tools</a></li>');
1464 }
1465
1466 $(".settings-link").click(function () {
1467 $('.section').each(function () {
1468 this.style.display = "block";
1469 });
1470 $('.settings-container').removeClass("dio_overflow");
1471
1472 $('#dio_bg_medusa').css({display: "none"});
1473
1474 if ($('#dio_settings').get(0)) {
1475 $('#dio_settings').get(0).style.display = "none";
1476 }
1477 });
1478
1479 $("#dio_tools").click(function () {
1480 if ($('.email').get(0)) {
1481 $('.settings-container').removeClass("email");
1482 }
1483
1484 $('.settings-container').addClass("dio_overflow");
1485
1486 $('#dio_bg_medusa').css({display: "block"});
1487
1488 if (!$('#dio_settings').get(0)) {
1489 // Styles
1490 $('<style id="dio_settings_style">' +
1491 // Chrome Scroollbar Style
1492 '#dio_settings ::-webkit-scrollbar { width: 13px; } ' +
1493 '#dio_settings ::-webkit-scrollbar-track { background-color: rgba(130, 186, 135, 0.5); border-top-right-radius: 4px; border-bottom-right-radius: 4px; } ' +
1494 '#dio_settings ::-webkit-scrollbar-thumb { background-color: rgba(87, 121, 45, 0.5); border-radius: 3px; } ' +
1495 '#dio_settings ::-webkit-scrollbar-thumb:hover { background-color: rgba(87, 121, 45, 0.8); } ' +
1496
1497 '#dio_settings table tr :first-child { text-align:center; vertical-align:top; } ' +
1498
1499 '#dio_settings #version_info { font-weight:bold;height: 35px;margin-top:-5px; } ' +
1500 '#dio_settings #version_info img { margin:-1px 2px -8px 0px; } ' +
1501
1502 '#dio_settings .icon_types_table { font-size:0.7em; line-height:2.5; border:1px solid green; border-spacing:10px 2px; border-radius:5px; } ' +
1503 '#dio_settings .icon_types_table td { text-align:left; } ' +
1504
1505 '#dio_settings table p { margin:0.2em 0em; } ' +
1506
1507 '#dio_settings .checkbox_new .cbx_caption { white-space:nowrap; margin-right:10px; font-weight:bold; } ' +
1508
1509 '#dio_settings .dio_settings_tabs {width:auto; border:2px solid darkgreen; background:#2B241A; padding:1px 1px 0px 1px; right:auto; border-top-left-radius:5px; border-top-right-radius:5px; border-bottom:0px;} ' +
1510
1511 '#dio_settings .dio_settings_tabs li { float:left; } ' +
1512
1513 '#dio_settings .icon_small { margin:0px; } ' +
1514
1515 '#dio_settings img { max-width:90px; max-height:90px; margin-right:10px; } ' +
1516
1517 '#dio_settings .content { border:2px solid darkgreen; border-radius:5px; border-top-left-radius:0px; background:rgba(31, 25, 12, 0.1); top:23px; position:relative; padding:10px; height:350px; overflow-y:auto; } ' +
1518 '#dio_settings .content .content_category { display:none; border-spacing:5px; } ' +
1519
1520 '#dio_settings .dio_options_table legend { font-weight:bold; } ' +
1521 '#dio_settings .dio_options_table p { margin:0px; } ' +
1522 '#dio_settings #donate_btn { filter: hue-rotate(45deg); -webkit-filter: hue-rotate(45deg); } ' +
1523
1524 '#donate_btn { background: url(' + dio_sprite + '); width:100px; height:26px; background-position: 0px -300px; } ' +
1525 '#donate_btn.de { background-position: 0px -250px; } ' +
1526 '#donate_btn.en { background-position: 0px -300px; } ' +
1527
1528 '#dio_hall table { border-spacing: 9px 3px; } ' +
1529 '#dio_hall table th { text-align:left !important;color:green;text-decoration:underline;padding-bottom:10px; } ' +
1530 '#dio_hall table td.value { text-align: right; } ' +
1531
1532 '#dio_hall table td.laurel.green { background: url("/images/game/ally/founder.png") no-repeat; height:18px; width:18px; background-size:100%; } ' +
1533 '#dio_hall table td.laurel.bronze { background: url("https://diotools.de/images/game/laurel_sprite.png") no-repeat 25%; height:18px; width:18px; } ' +
1534 '#dio_hall table td.laurel.silver { background: url("https://diotools.de/images/game/laurel_sprite.png") no-repeat 50%; height:18px; width:18px; } ' +
1535 '#dio_hall table td.laurel.gold { background: url("https://diotools.de/images/game/laurel_sprite.png") no-repeat 75%; height:18px; width:18px; } ' +
1536 '#dio_hall table td.laurel.blue { background: url("https://diotools.de/images/game/laurel_sprite.png") no-repeat 100%; height:18px; width:18px; } ' +
1537 '</style>').appendTo('head');
1538
1539
1540 $('.settings-container').append(
1541 '<div id="dio_settings" class="player_settings section"><div id="dio_bg_medusa"></div>' +
1542 '<div class="game_header bold"><a href="#" target="_blank" style="color:white">DIO-Tools (v' + version + ')</a></div>' +
1543
1544 // Check latest version
1545 '<div id="version_info"><img src="http://666kb.com/i/csmicltyu4zhiwo5b.gif" /></div>' +
1546
1547 // Donate button
1548 '<div style="position:absolute; left: 495px;top: 40px;"><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3EWUQUTMC5VKS" target="_blank">' +
1549 '<div id="donate_btn" class="' + LID + '" alt="Donate"></div></a></div>' +
1550
1551 // Settings navigation
1552 '<ul class="menu_inner dio_settings_tabs">' +
1553 '<li><a class="submenu_link active" href="#" id="dio_units"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_units") + '</span></span></span></a></li>' +
1554 '<li><a class="submenu_link" href="#" id="dio_icons"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_icons") + '</span></span></span></a></li>' +
1555 '<li><a class="submenu_link" href="#" id="dio_forum"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_forum") + '</span></span></span></a></li>' +
1556 '<li><a class="submenu_link" href="#" id="dio_trade"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_trade") + '</span></span></span></a></li>' +
1557 '<li><a class="submenu_link" href="#" id="dio_wonder"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_wonders") + '</span></span></span></a></li>' +
1558 '<li><a class="submenu_link" href="#" id="dio_layout"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_layout") + '</span></span></span></a></li>' +
1559 '<li><a class="submenu_link" href="#" id="dio_other"><span class="left"><span class="right"><span class="middle">' + getText("settings", "cat_other") + '</span></span></span></a></li>' +
1560 '</ul>' +
1561
1562 // Settings content
1563 '<DIV class="content">' +
1564
1565 // Units tab
1566 '<table id="dio_units_table" class="content_category visible"><tr>' +
1567 '<td><img src="https://diotools.de/images/game/settings/units/available_units.png" alt="" /></td>' +
1568 '<td><div id="ava" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "ava")[0] + '</div></div>' +
1569 '<p>' + getText("options", "ava")[1] + '</p></td>' +
1570 '</tr><tr>' +
1571 '<td><img src="https://diotools.de/images/game/settings/units/sent_units.png" alt="" /></td>' +
1572 '<td><div id="sen" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "sen")[0] + '</div></div>' +
1573 '<p>' + getText("options", "sen")[1] + '</p></td>' +
1574 '</tr><tr>' +
1575 '<td><img src="https://diotools.de/images/game/settings/units/unit_strength.png" alt="" /></td>' +
1576 '<td><div id="str" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "str")[0] + '</div></div>' +
1577 '<p>' + getText("options", "str")[1] + '</p></td>' +
1578 '</tr><tr>' +
1579 '<td><img src="https://diotools.de/images/game/settings/units/transport_capacity.png" alt="" /></td>' +
1580 '<td><div id="tra" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "tra")[0] + '</div></div>' +
1581 '<p>' + getText("options", "tra")[1] + '</p></td>' +
1582 '</tr><tr>' +
1583 '<td><img src="https://diotools.de/images/game/settings/units/unit_comparison.png" alt="" /></td>' +
1584 '<td><div id="com" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "com")[0] + '</div></div>' +
1585 '<p>' + getText("options", "com")[1] + '</p></td>' +
1586 '</tr></table>' +
1587
1588 // Icons tab
1589 '<table id="dio_icons_table" class="content_category"><tr>' +
1590 '<td><img src="https://diotools.de/images/game/settings/townicons/townicons.png" alt="" /></td>' +
1591 '<td><div id="tic" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "tic")[0] + '</div></div>' +
1592 '<p>' + getText("options", "tic")[1] + '</p>' +
1593 '<table class="icon_types_table">' +
1594 '<tr><td style="width:115px"><div class="icon_small townicon_lo"></div> Land Offensive</td>' + '<td><div class="icon_small townicon_fo"></div> Fly Offensive</td></tr>' +
1595 '<tr><td><div class="icon_small townicon_ld"></div> Land Defensive</td>' + '<td><div class="icon_small townicon_fd"></div> Fly Defensive</td></tr>' +
1596 '<tr><td><div class="icon_small townicon_so"></div> Navy Offensive</td>' + '<td><div class="icon_small townicon_no"></div> Outside</td></tr>' +
1597 '<tr><td><div class="icon_small townicon_sd"></div> Navy Defensive</td>' + '<td><div class="icon_small townicon_po"></div> Empty</td></tr>' +
1598 '</table><br>' +
1599 '<p>' + getText("options", "tic")[2] + ':</p>' +
1600 '<div class="icon_small townicon_sh"></div><div class="icon_small townicon_di"></div><div class="icon_small townicon_un"></div><div class="icon_small townicon_ko"></div>' +
1601 '<div class="icon_small townicon_ti"></div><div class="icon_small townicon_gr"></div><div class="icon_small townicon_dp"></div><div class="icon_small townicon_re"></div>' +
1602 '<div class="icon_small townicon_wd"></div><div class="icon_small townicon_st"></div><div class="icon_small townicon_si"></div><div class="icon_small townicon_bu"></div>' +
1603 '<div class="icon_small townicon_he"></div><div class="icon_small townicon_ch"></div><div class="icon_small townicon_bo"></div><div class="icon_small townicon_fa"></div>' +
1604 '<div class="icon_small townicon_wo"></div>' +
1605 '</td>' +
1606 '</tr><tr>' +
1607 '<td><img src="https://diotools.de/images/game/settings/townicons/townlist.png" alt="" style="border: 1px solid rgb(158, 133, 78);" /></td>' +
1608 '<td><div id="til" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "til")[0] + '</div></div>' +
1609 '<p>' + getText("options", "til")[1] + '</p></td>' +
1610 '</tr><tr>' +
1611 '<td><img src="https://diotools.de/images/game/settings/townicons/map.png" alt="" /></td>' +
1612 '<td><div id="tim" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "tim")[0] + '</div></div>' +
1613 '<p>' + getText("options", "tim")[1] + '</p></td>' +
1614 '</tr></table>' +
1615
1616 // Forum tab
1617 '<table id="dio_forum_table" class="content_category"><tr>' +
1618 '<td><img src="https://diotools.de/images/game/settings/forum/smiley_box.png" alt="" /></td>' +
1619 '<td><div id="sml" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "sml")[0] + '</div></div>' +
1620 '<p>' + getText("options", "sml")[1] + '</p>' +
1621 '<img src="http://www.greensmilies.com/smile/smiley_emoticons_mttao_wassermann.gif" /> <img src="http://666kb.com/i/cigrqlp2odi2kqo24.gif" /> ' +
1622 '<img src="http://666kb.com/i/cifvfsu3e2sdiipn0.gif" alt="" /> <img src="http://666kb.com/i/cigmv8wnffb3v0ifg.gif" /> ' +
1623 '<img src="http://666kb.com/i/cj2byjendffymp88t.gif" alt="" /> <img src="http://666kb.com/i/cj1l9gndtu3nduyvi.gif" /> ' +
1624 '<img src="http://666kb.com/i/cigrmpfofys5xtiks.gif" alt="" />' + //'<img src="http://666kb.com/i/cifohielywpedbyh8.gif" />'+
1625 '<br><br><br></td>' +
1626 '</tr><tr>' +
1627 '<td><img src="https://diotools.de/images/game/settings/forum/def_formular.png" alt="" /></td>' +
1628 '<td><div id="bbc" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "bbc")[0] + '</div></div>' +
1629 '<p>' + getText("options", "bbc")[1] + '</p><br><img src="http://s1.directupload.net/images/140401/9b2ydh82.png" alt="" style="max-width:none !important;" /></td>' +
1630 '</tr></table>' +
1631
1632 // Trade tab
1633 '<table id="dio_trade_table" class="content_category"><tr>' +
1634 '<td><img src="https://diotools.de/images/game/settings/trade/recruiting_trade.png" /></td>' +
1635 '<td><div id="rec" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "rec")[0] + '</div></div>' +
1636 '<p>' + getText("options", "rec")[1] + '</p><br>' +
1637 /*
1638 '<p><u>Beispiel Feuerschiffe:</u><br>'+
1639 '<p>Verhältnisauswahl</p>'+
1640 '<table style="font-size: 0.7em;line-height: 2.5;border: 1px solid green;border-spacing: 10px 2px;border-radius: 5px;">'+
1641 '<tr><th></th><th><div class="icon_small townicon_wd"></div></th><td></td><th><div class="icon_small townicon_st"></div></th><td></td><th><div class="icon_small townicon_si"></div></th></tr>'+
1642 '<tr><td>Kosten</td><td>1300</td><td></td><td>300</td><td></td><td>800</td></tr>'+
1643 '<tr><td>Verhältnis</td><td>1</td><td>:</td><td>0.23</td><td>:</td><td>0.62</td></tr>'+
1644 '</table>'+
1645 '<p>Lagergröße Zielstadt: 25500 - 1000 Puffer (=100%)</p>'+
1646 '<p>Handelsmenge 25%: </p>'+
1647 '<table style="font-size: 0.7em;line-height: 2.5;">'+
1648 '<tr><td>4 x 25%</td><td>4 x 25%</td><td>...</td></tr>'+
1649 '<tr><td><img src="http://s7.directupload.net/images/140920/uc4dsyp9.png" style="width:60px" /></td>'+
1650 '<td><img src="http://s7.directupload.net/images/140920/uc4dsyp9.png" style="width:60px" /></td><td>...</td></tr>'+
1651 '</table>'+
1652 //'- Versenden von 35 einzelnen Rohstoffportionen im Anteil 20% (z.B. 4900 Holz, 1130 Stein, 3015 Silber bei Lagerkapazität von 25.500), das heißt 5 Portionen für einen Rekrutierungsslot'+
1653 //'- nach Ankommen von jeweils 5 Portionen, Einheiten in Auftrag geben (19-21 Feuerschiffe bei maximaler Lagerkapazität)'+
1654 //'Ein Puffer von 1000 Rohstoffeinheiten wird dabei von der Lagerkapazität der Zielstadt abgezogen, damit Rekrutierungsreste und neu produzierte Rohstoffe nicht gleich zum Überlaufen des Lagers führen.'+
1655 //'Das Ganze beschleunigt das Befüllen der Rekrutierungsschleifen enorm und es gehen dabei keine Rohstoffe verloren.</p>'+
1656 '<br><br><br></td>'+
1657 */
1658 '</tr><tr>' +
1659 '<td><img src="https://diotools.de/images/game/settings/trade/percentage_trade.png" /></td>' +
1660 '<td><div id="per" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "per")[0] + '</div></div>' +
1661 '<p>' + getText("options", "per")[1] + '</p><br></td>' +
1662 /*
1663 '</tr><tr>'+
1664 '<td><img src="http://s7.directupload.net/images/140917/tveb5n33.png" /></td>'+
1665 '<td><div id="trd2" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">Trade Limit Marker</div></div>'+
1666 '<p></p></td>'+
1667 */
1668 '</tr></table>' +
1669
1670 // World wonder tab
1671 '<table id="dio_wonder_table" class="content_category"><tr>' +
1672 '<td><img src="https://diotools.de/images/game/settings/wonders/share.png" alt="" /></td>' +
1673 '<td><div id="wwc" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "wwc")[0] + '</div></div>' +
1674 '<p>' + getText("options", "wwc")[1] + '</p><br/>' +
1675 '<img src="https://diotools.de/images/game/settings/wonders/share_calculator.png" alt="" style="max-width:none !important;" /></td>' +
1676 '</tr><tr>' +
1677 '<td><img src="https://diotools.de/images/game/settings/wonders/ranking.png" alt="" /></td>' +
1678 '<td><div id="wwr" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "wwr")[0] + '</div></div>' +
1679 '<p>' + getText("options", "wwr")[1] + '</p></td>' +
1680 '</tr><tr>' +
1681 '<td><img src="https://diotools.de/images/game/settings/wonders/icons.png" alt="" /></td>' +
1682 '<td><div id="wwi" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "wwi")[0] + '</div></div>' +
1683 '<p>' + getText("options", "wwi")[1] + '</p></td>' +
1684 '</tr></table>' +
1685
1686 // Layout tab
1687 '<table id="dio_layout_table" class="content_category"><tr>' +
1688 '<td><img src="https://diotools.de/images/game/settings/layout/simulator.png" alt="" /></td>' +
1689 '<td><div id="sim" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "sim")[0] + '</div></div>' +
1690 '<p>' + getText("options", "sim")[1] + '</p></td>' +
1691 '</tr><tr>' +
1692 '<td><img src="https://diotools.de/images/game/settings/layout/spellbox.png" alt="" /></td>' +
1693 '<td><div id="spl" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "spl")[0] + '</div></div>' +
1694 '<p>' + getText("options", "spl")[1] + '</p></td>' +
1695 '</tr><tr>' +
1696
1697 ((Game.market_id !== "de" && Game.market_id !== "zz") ? (
1698 '<td><img src="https://diotools.de/images/game/settings/layout/taskbar.png" alt="" /></td>' +
1699 '<td><div id="tsk" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "tsk")[0] + '</div></div>' +
1700 '<p>' + getText("options", "tsk")[1] + '</p></td>' +
1701 '</tr><tr>'
1702 ) : "" ) +
1703
1704 '<td><img src="https://diotools.de/images/game/settings/layout/favor_popup.png" alt="" /></td>' +
1705 '<td><div id="pop" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "pop")[0] + '</div></div>' +
1706 '<p>' + getText("options", "pop")[1] + '</p></td>' +
1707 '</tr><tr>' +
1708 '<td><img src="https://diotools.de/images/game/settings/layout/contextmenu.png" alt="" /></td>' +
1709 '<td><div id="con" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "con")[0] + '</div></div>' +
1710 '<p>' + getText("options", "con")[1] + '</p></td>' +
1711 '</tr><tr>' +
1712 '<td><img src="https://diotools.de/images/game/settings/layout/activity_boxes.png" alt="" /></td>' +
1713 '<td><div id="act" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "act")[0] + '</div></div>' +
1714 '<p>' + getText("options", "act")[1] + '</p></td>' +
1715 '</tr></table>' +
1716
1717 // Other Stuff tab
1718 '<table id="dio_other_table" class="content_category"><tr>' +
1719 '<td><img src="https://diotools.de/images/game/settings/misc/troop_speed.png" style="border: 1px solid rgb(158, 133, 78);" alt="" /></td>' +
1720 '<td><div id="way" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "way")[0] + '</div></div>' +
1721 '<p>' + getText("options", "way")[1] + '</p></td>' +
1722 '</tr><tr>' +
1723
1724 // Betaphase in DE
1725 ((Game.market_id === "de" || Game.market_id === "zz") ? (
1726
1727 '<td><img src="https://diotools.de/images/game/settings/misc/chat_new.png" alt="" /></td>' +
1728 '<td><div id="cha" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "cha")[0] + '</div></div>' +
1729 '<p>' + getText("options", "cha")[1] + '</p></td>' +
1730 '</tr><tr>'
1731
1732 ) : "") +
1733
1734 '<td><img src="https://diotools.de/images/game/settings/misc/conquer_counter.png" style="border: 1px solid rgb(158, 133, 78);" alt="" /></td>' +
1735 '<td><div id="cnt" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "cnt")[0] + '</div></div>' +
1736 '<p>' + getText("options", "cnt")[1] + '</p></td>' +
1737 '</tr><tr>' +
1738 '<td><img src="https://diotools.de/images/game/settings/misc/mousewheel_zoom.png" alt="" /></td>' +
1739 '<td><div id="scr" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "scr")[0] + '</div></div>' +
1740 '<p>' + getText("options", "scr")[1] + '</p><br><br></td>' +
1741 '</tr><tr>' +
1742 '<td><img src="" alt="" /></td>' +
1743 '<td><div id="err" class="checkbox_new"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("options", "err")[0] + '</div></div>' +
1744 '<p>' + getText("options", "err")[1] + '</p></td>' +
1745 '</tr></table>' +
1746
1747
1748 // Hall of DIO-Tools tab
1749 '<div id="dio_hall" class="content_category">'+
1750 "<p>I like to thank all of you who helped the development of DIO-Tools by donating or translating!</p>"+
1751 '<table style="float:left;margin-right: 75px;">'+
1752 '<tr><th colspan="3">Donations</th></tr>'+
1753 (function(){
1754 var donations = [
1755 ["Eduard R", 50],
1756 ["Gregoire L", 25],
1757 ["Renee A", 20], ["Dirk R", 20], ["Patti T", 20],
1758 ["Klaus N", 15],
1759 ["Marco S", 10], ["Richard L", 10], ["Carsten K", 10], ["Tatiana H", 10], ["Ursula S", 10], ["Susanne S", 10], ["Falk T", 10],
1760 ["Belinda M", 8], ["Wolfgang R", 8],
1761 ["Miguel B", 7],
1762 ["Antje S", 5], ["Hans-Jörg S", 5], ["Deanna P", 5], ["ForexTraction", 5], ["Rene F", 5], ["Rüdiger D", 5], ["Hans Hermann S", 5],
1763 ["Siegbert M", 5], ["Wilhelm B", 5], ["Peter P", 5], ["Helga W", 5], ["Lydia R", 5],
1764 ["Michael S", 3],
1765 ["Mario P", 2], ["Artur G", 2], ["Heiko K", 2], ["Alexander B", 2], ["Dick N", 2],
1766 ["Marcel G", 1], ["Ramona L", 1], ["Dennis S", 1], ["Konstandinos K", 1], ["Sarl T", 1], ["Jagadics I", 1], ["Andreas R", 1],
1767 ["Peter F", 1], ["Vinicio G", 1], ["Marielle M", 1], ["Christian B", 1], ["Bernd W", 1], ["Maria N", 1], ["Thomas W", 1],
1768 ["Domenik F", 1], ["Oliver H", 1], ["Jens R", 1], ["Nicole S", 1], ["Hartmut S", 1], ["Alex L", 1], ["Andreas S", 1]
1769 ];
1770 var donation_table = "";
1771
1772 for(var d = 0; d < donations.length; d++){
1773
1774 var donation_class = "";
1775
1776 switch(donations[d][1]){
1777 case 50: donation_class = "gold"; break;
1778 case 25: donation_class = "silver"; break;
1779 case 20: donation_class = "bronze"; break;
1780 default: donation_class = "green"; break;
1781 }
1782
1783 donation_table += '<tr class="donation"><td class="laurel '+ donation_class +'"></td><td>' + donations[d][0] + '</td><td class="value">' + donations[d][1] + '€</td></tr>';
1784 }
1785
1786 return donation_table;
1787 })() +
1788 '</table>'+
1789 '<table>'+
1790 '<tr><th colspan="3">Translations</th></tr>'+
1791 (function(){
1792 var translations = [
1793 ["eclat49", "FR"],
1794 ["MrBobr", "RU"],
1795 ["anpu", "PL"],
1796 ["Juana de Castilla", "ES"],
1797 ["HELL", "BR"],
1798 ["Piwus", "CZ"]
1799 ];
1800
1801 var translation_table = "";
1802
1803 for(var d = 0; d < translations.length; d++){
1804 translation_table += '<tr class="translation"><td class="laurel blue"></td><td >' + translations[d][0] + '</td><td class="value">' + translations[d][1] + '</td></tr>';
1805 }
1806
1807 return translation_table;
1808 })() +
1809 '</table>'+
1810 '</div>' +
1811
1812 '</DIV>' +
1813
1814 // Links (Forum, PM, ...)
1815 '<div style="bottom: -50px;font-weight: bold;position: absolute;width: 99%;">' +
1816
1817 '<a id="hall_of_diotools" href="#" style="font-weight:bold; float:left">' +
1818 '<img src="/images/game/ally/founder.png" alt="" style="float:left;height:19px;margin:0px 5px -3px;"><span>Hall of DIO-Tools</span></a>' +
1819
1820 '<span class="bbcodes_player bold" style="font-weight:bold; float:right; margin-left:20px;">' + getText("settings", "author") + ': ' +
1821 '<a id="link_contact" href=' + getText("settings", "link_contact") + ' target="_blank">Diony</a></span>' +
1822
1823 '<a id="link_forum" href=' + getText("settings", "link_forum") + ' target="_blank" style="font-weight:bold; float:right">' +
1824 '<img src="http://forum.de.grepolis.com/grepolis/statusicon/forum_new-16.png" alt="" style="margin: 0px 5px -3px 5px;" /><span>' + getText("settings", "forum") + '</span></a>' +
1825
1826 '</div>' +
1827
1828 '</div></div>');
1829
1830 getLatestVersion();
1831
1832 // Tab event handler
1833 $('#dio_settings .dio_settings_tabs .submenu_link').click(function () {
1834 if (!$(this).hasClass("active")) {
1835 $('#dio_settings .dio_settings_tabs .submenu_link.active').removeClass("active");
1836 $(this).addClass("active");
1837 $("#dio_settings .visible").removeClass("visible");
1838 $("#" + this.id + "_table").addClass("visible");
1839 }
1840 });
1841
1842 //
1843 $('#hall_of_diotools').click(function () {
1844 $('#dio_settings .dio_settings_tabs .submenu_link.active').removeClass("active");
1845
1846 $("#dio_settings .visible").removeClass("visible");
1847 $("#dio_hall").addClass("visible");
1848 });
1849
1850 $("#dio_settings .checkbox_new").click(function () {
1851 $(this).toggleClass("checked").toggleClass("disabled").toggleClass("green");
1852 toggleActivation(this.id);
1853
1854 DATA.options[this.id] = $(this).hasClass("checked");
1855
1856 saveValue("options", JSON.stringify(DATA.options));
1857 });
1858 for (var e in DATA.options) {
1859 if (DATA.options.hasOwnProperty(e)) {
1860 if (DATA.options[e] === true) {
1861 $("#" + e).addClass("checked").addClass("green");
1862 } else {
1863 $("#" + e).addClass("disabled");
1864 }
1865 }
1866 }
1867
1868 $('#dio_save').click(function () {
1869 $('#dio_settings .checkbox_new').each(function () {
1870 var act = false;
1871 if ($("#" + this.id).hasClass("checked")) {
1872 act = true;
1873 }
1874 DATA.options[this.id] = act;
1875 });
1876 saveValue("options", JSON.stringify(DATA.options));
1877 });
1878 }
1879 $('.section').each(function () {
1880 this.style.display = "none";
1881 });
1882 $('#dio_settings').get(0).style.display = "block";
1883 });
1884 }
1885
1886 function toggleActivation(opt) {
1887 var FEATURE, activation = true;
1888 switch (opt) {
1889 case "sml":
1890 FEATURE = SmileyBox;
1891 break;
1892 case "bir":
1893 FEATURE = BiremeCounter;
1894 break;
1895 case "str":
1896 FEATURE = UnitStrength.Menu;
1897 break;
1898 case "tra":
1899 FEATURE = TransportCapacity;
1900 break;
1901 case "ava":
1902 FEATURE = AvailableUnits;
1903 break;
1904 case "sim":
1905 FEATURE = Simulator;
1906 break;
1907 case "spl":
1908 FEATURE = Spellbox;
1909 break;
1910 case "tsk":
1911 FEATURE = Taskbar;
1912 break;
1913 case "scr":
1914 FEATURE = MouseWheelZoom;
1915 break;
1916 case "cha":
1917 FEATURE = Chat;
1918 break;
1919 case "com":
1920 FEATURE = UnitComparison;
1921 break;
1922 case "pop":
1923 FEATURE = FavorPopup;
1924 break;
1925 case "con":
1926 FEATURE = ContextMenu;
1927 break;
1928 case "tic":
1929 FEATURE = TownIcons;
1930 break;
1931 case "tim":
1932 FEATURE = TownIcons.Map;
1933 break;
1934 case "til":
1935 FEATURE = TownList;
1936 break;
1937 case "sen":
1938 FEATURE = SentUnits;
1939 break;
1940 case "act":
1941 FEATURE = ActivityBoxes;
1942 break;
1943 case "wwc":
1944 FEATURE = WorldWonderCalculator;
1945 break;
1946 case "wwr":
1947 FEATURE = WorldWonderRanking;
1948 break;
1949 case "wwi":
1950 FEATURE = WorldWonderIcons;
1951 break;
1952 case "pom":
1953 FEATURE = PoliticalMap;
1954 break;
1955 case "rec":
1956 FEATURE = RecruitingTrade;
1957 break;
1958 case "way":
1959 FEATURE = ShortDuration;
1960 break;
1961
1962 default:
1963 activation = false;
1964 break;
1965 }
1966 if (activation) {
1967 if (DATA.options[opt]) {
1968 FEATURE.deactivate();
1969 } else {
1970 FEATURE.activate();
1971 }
1972 }
1973 }
1974
1975 function addSettingsButton() {
1976 var tooltip_str = "DIO-Tools: " + (DM.getl10n("layout", "config_buttons").settings || "Settings");
1977
1978 $('<div class="btn_settings circle_button dio_settings"><div class="dio_icon js-caption"></div></div>').appendTo(".gods_area");
1979
1980 // Style
1981 $('<style id="dio_settings_button" type="text/css">' +
1982 '#ui_box .btn_settings.dio_settings { top:95px; right:103px; z-index:10; } ' +
1983 '#ui_box .dio_settings .dio_icon { margin:7px 0px 0px 4px; width:24px; height:24px; background:url(http://666kb.com/i/cifvfsu3e2sdiipn0.gif) no-repeat 0px 0px; background-size:100% } ' +
1984 '#ui_box .dio_settings .dio_icon.click { margin-top:8px; }' +
1985 '</style>').appendTo('head');
1986
1987 // Tooltip
1988 $('.dio_settings').tooltip(tooltip_str);
1989
1990 // Mouse Events
1991 $('.dio_settings').on('mousedown', function () {
1992 $('.dio_icon').addClass('click');
1993 });
1994 $('.dio_settings').on('mouseup', function () {
1995 $('.dio_icon').removeClass('click');
1996 });
1997 $('.dio_settings').click(openSettings);
1998 }
1999
2000 var diosettings = false;
2001
2002 function openSettings() {
2003 if (!GPWindowMgr.getOpenFirst(Layout.wnd.TYPE_PLAYER_SETTINGS)) {
2004 diosettings = true;
2005 }
2006 Layout.wnd.Create(GPWindowMgr.TYPE_PLAYER_SETTINGS, 'Settings');
2007 }
2008
2009 var exc = false, sum = 0, ch = ["IGCCJB"], alpha = 'ABCDEFGHIJ';
2010
2011 function a() {
2012 var pA = PID.toString(), pB = "";
2013
2014 for (var c in pA) {
2015 if (pA.hasOwnProperty(c)) {
2016 pB += alpha[pA[parseInt(c, 10)]];
2017 }
2018 }
2019
2020 sum = 0;
2021 for (var b in ch) {
2022 if (ch.hasOwnProperty(b)) {
2023 if (pB !== ch[b]) {
2024 exc = true;
2025 } else {
2026 exc = false;
2027 return;
2028 }
2029 for (var s in ch[b]) {
2030 if (ch[b].hasOwnProperty(s)) {
2031 sum += alpha.indexOf(ch[b][s]);
2032 }
2033 }
2034 }
2035 }
2036 }
2037
2038
2039 var autoTownTypes, manuTownTypes, population, sentUnitsArray, biriArray, spellbox, commandbox, tradebox, wonder, wonderTypes;
2040
2041 function setStyle() {
2042 // Settings
2043 $('<style id="dio_settings_style" type="text/css">' +
2044 '#dio_bg_medusa { background:url(http://diotools.de/images/game/settings/medusa_transp.png) no-repeat; height: 510px; width: 380px; right: -10px; top:6px; z-index: -1; position: absolute;} ' +
2045 '.dio_overflow { overflow: hidden; } ' +
2046 '#dio_icon { width:15px; vertical-align:middle; margin-top:-2px; } ' +
2047 '#quackicon { width:15px !important; vertical-align:middle !important; margin-top:-2px; height:12px !important; } ' +
2048 '#dio_settings .green { color: green; } ' +
2049 '#dio_settings .visible { display:block !important; } ' +
2050 '</style>').appendTo('head');
2051
2052 // Town Icons
2053 $('<style id="dio_icons" type="text/css">.icon_small { position:relative; height:20px; width:25px; margin-left:-25px; }</style>').appendTo('head');
2054
2055 // Tutorial-Quest Container
2056 $('<style id="dio_quest_container" type="text/css"> #tutorial_quest_container { top: 130px } </style>').appendTo('head');
2057
2058 // Velerios
2059 $('<style id="dio_velerios" type="text/css"> #ph_trader_image { background-image: url(http://s14.directupload.net/images/140826/mh8k8nyw.jpg); } </style>').appendTo('head');
2060 // http://s7.directupload.net/images/140826/bgqlsdrf.jpg
2061
2062 // Specific player wishes
2063 if (PID == 1212083) {
2064 $('<style id="dio_wishes" type="text/css"> #world_end_info { display: none; } </style>').appendTo('head');
2065 }
2066 }
2067
2068 function loadFeatures() {
2069 if (typeof(ITowns) !== "undefined") {
2070
2071 autoTownTypes = {};
2072 manuTownTypes = DATA.townTypes;
2073 population = {};
2074
2075 sentUnitsArray = DATA.sentUnits;
2076 biriArray = DATA.biremes;
2077
2078 spellbox = DATA.spellbox;
2079 commandbox = DATA.commandbox;
2080 tradebox = DATA.tradebox;
2081
2082 wonder = DATA.worldWonder;
2083 wonderTypes = DATA.worldWonderTypes;
2084
2085 var DIO_USER = {'name': uw.Game.player_name, 'market': MID};
2086 saveValue("dio_user", JSON.stringify(DIO_USER));
2087
2088
2089 $.Observer(uw.GameEvents.game.load).subscribe('DIO_START', function (e, data) {
2090 a();
2091
2092 // English => default language
2093 if (!LANG[LID]) {
2094 LID = "en";
2095 }
2096
2097 if ((ch.length == 1) && exc && (sum == 28)) {
2098 // AJAX-EVENTS
2099 setTimeout(function () {
2100 ajaxObserver();
2101 }, 0);
2102
2103 addSettingsButton();
2104
2105 addFunctionToITowns();
2106
2107 if (DATA.options.tsk) {
2108 setTimeout(function () {
2109 minimizeDailyReward();
2110
2111 if(Game.market_id !== "de" && Game.market_id !== "zz") {
2112 Taskbar.activate();
2113 }
2114 }, 0);
2115 }
2116
2117 //addStatsButton();
2118
2119 fixUnitValues();
2120
2121 setTimeout(function () {
2122
2123 var waitCount = 0;
2124
2125 // No comment... it's Grepolis... i don't know... *rolleyes*
2126 function waitForGrepoLazyLoading() {
2127 if (typeof(ITowns.townGroups.getGroupsDIO()[-1]) !== "undefined" && typeof(ITowns.getTown(Game.townId).getBuildings) !== "undefined") {
2128
2129 try {
2130 // Funktion wird manchmal nicht ausgeführt:
2131 var units = ITowns.getTown(Game.townId).units();
2132
2133
2134 getAllUnits();
2135
2136 setInterval(function () {
2137 getAllUnits();
2138 }, 900000); // 15min
2139
2140 setInterval(function () {
2141 UnitCounter.count();
2142 }, 600000); // 10min
2143
2144 if (DATA.options.ava) {
2145 setTimeout(function () {
2146 AvailableUnits.activate();
2147 }, 0);
2148 }
2149 if (DATA.options.tic) {
2150 setTimeout(function () {
2151 TownIcons.activate();
2152 TownPopup.activate();
2153 }, 0);
2154 }
2155 if (DATA.options.tim) {
2156 setTimeout(function () {
2157 TownIcons.Map.activate();
2158 }, 0);
2159 }
2160 if (DATA.options.til) {
2161 setTimeout(function () {
2162 TownList.activate();
2163 }, 0);
2164 }
2165
2166 HiddenHighlightWindow.activate();
2167
2168
2169 } catch(e){
2170 if(waitCount < 12) {
2171 waitCount++;
2172
2173 console.warn("DIO-Tools | Fehler | getAllUnits | units() fehlerhaft ausgeführt?", e);
2174
2175 // Ausführung wiederholen
2176 setTimeout(function () {
2177 waitForGrepoLazyLoading();
2178 }, 5000); // 5s
2179 }
2180 else {
2181 errorHandling(e, "waitForGrepoLazyLoading2");
2182 }
2183 }
2184 }
2185 else {
2186 var e = { "stack": "getGroups() = " + typeof(ITowns.townGroups.getGroupsDIO()[-1]) + ", getBuildings() = " + typeof(ITowns.getTown(Game.townId).getBuildings) };
2187
2188 if(waitCount < 12) {
2189 waitCount++;
2190
2191 console.warn("DIO-Tools | Fehler | getAllUnits | " + e.stack);
2192
2193 // Ausführung wiederholen
2194 setTimeout(function () {
2195 waitForGrepoLazyLoading();
2196 }, 5000); // 5s
2197 }
2198 else {
2199
2200
2201 errorHandling(e, "waitForGrepoLazyLoading2");
2202 }
2203 }
2204 }
2205
2206 waitForGrepoLazyLoading();
2207
2208 }, 0);
2209
2210 if (DATA.options.pop) {
2211 setTimeout(function () {
2212 FavorPopup.activate();
2213 }, 0);
2214 }
2215 if (DATA.options.spl) {
2216 setTimeout(function () {
2217 Spellbox.activate();
2218 }, 0);
2219 }
2220
2221 imageSelectionProtection();
2222
2223 if (DATA.options.con) {
2224 setTimeout(function () {
2225 ContextMenu.activate();
2226 }, 0);
2227 }
2228
2229 if (DATA.options.act) {
2230 setTimeout(function () {
2231 ActivityBoxes.activate();
2232 }, 0);
2233 }
2234
2235 if (DATA.options.str) {
2236 setTimeout(function () {
2237 UnitStrength.Menu.activate();
2238 hideNavElements();
2239 }, 0);
2240 }
2241
2242 if (DATA.options.tra) {
2243 setTimeout(function () {
2244 TransportCapacity.activate();
2245 }, 0);
2246 }
2247
2248 if (DATA.options.com) {
2249 setTimeout(function () {
2250 UnitComparison.activate();
2251 }, 0);
2252 }
2253
2254 if (DATA.options.sml) {
2255 setTimeout(function () {
2256 SmileyBox.activate();
2257 }, 0);
2258 }
2259
2260 if (DATA.options.cha && (Game.market_id === "de" || Game.market_id === "zz")) {
2261 setTimeout(function () {
2262 Chat.activate();
2263 }, 0);
2264 }
2265
2266 if (DATA.options.scr) {
2267 setTimeout(function () {
2268 MouseWheelZoom.activate();
2269 }, 0);
2270 }
2271
2272 if (DATA.options.sim) {
2273 setTimeout(function () {
2274 Simulator.activate();
2275 }, 0);
2276 }
2277
2278 if (DATA.options.sen) {
2279 setTimeout(function () {
2280 SentUnits.activate();
2281 }, 0);
2282 }
2283
2284 if (DATA.options.wwc) {
2285 setTimeout(function () {
2286 WorldWonderCalculator.activate();
2287 }, 0);
2288 }
2289
2290 if(DATA.options.rec) {
2291 setTimeout(function () {
2292 RecruitingTrade.activate();
2293 }, 0);
2294 }
2295
2296 if(DATA.options.way) {
2297 setTimeout(function () {
2298 ShortDuration.activate();
2299 }, 0);
2300 }
2301
2302 if (PID === 84367 || PID === 104769 || PID === 1291505) {
2303 setTimeout(function() {
2304 PoliticalMap.activate();
2305
2306 //PoliticalMap.getAllianceColors();
2307
2308 //Statistics.activate();
2309 }, 0);
2310 }
2311
2312 setTimeout(function () {
2313 counter(uw.Timestamp.server());
2314 setInterval(function () {
2315 counter(uw.Timestamp.server());
2316 }, 21600000);
2317 }, 60000);
2318
2319 // Notifications
2320 setTimeout(function () {
2321 Notification.init();
2322 }, 0);
2323
2324 setTimeout(function(){ HolidaySpecial.activate(); }, 0);
2325
2326
2327 // Execute once to get the world wonder types and coordinates
2328 setTimeout(function () {
2329 if (!wonderTypes.great_pyramid_of_giza) {
2330 getWorldWonderTypes();
2331 }
2332 if (wonderTypes.great_pyramid_of_giza) {
2333 setTimeout(function () {
2334 if (!wonder.map.mausoleum_of_halicarnassus) {
2335 getWorldWonders();
2336 } else {
2337 if (DATA.options.wwi) {
2338 WorldWonderIcons.activate();
2339 }
2340 }
2341 }, 2000);
2342 }
2343 }, 3000);
2344
2345 // Execute once to get alliance ratio
2346 if (wonder.ratio[AID] == -1 || !$.isNumeric(wonder.ratio[AID])) {
2347 setTimeout(function () {
2348 getPointRatioFromAllianceProfile();
2349 }, 5000);
2350 }
2351 }
2352 time_b = uw.Timestamp.client();
2353 //console.log("Gebrauchte Zeit:" + (time_b - time_a));
2354 });
2355 } else {
2356 setTimeout(function () {
2357 loadFeatures();
2358 }, 100);
2359 }
2360 }
2361
2362 if (uw.location.pathname.indexOf("game") >= 0) {
2363 setStyle();
2364
2365 loadFeatures();
2366 }
2367
2368 /*******************************************************************************************************************************
2369 * HTTP-Requests
2370 * *****************************************************************************************************************************/
2371 function ajaxObserver() {
2372 $(document).ajaxComplete(function (e, xhr, opt) {
2373
2374 var url = opt.url.split("?"), action = "";
2375
2376 //console.debug("0: ", url[0]);
2377 //console.debug("1: ", url[1]);
2378
2379 if(typeof(url[1]) !== "undefined" && typeof(url[1].split(/&/)[1]) !== "undefined") {
2380
2381 action = url[0].substr(5) + "/" + url[1].split(/&/)[1].substr(7);
2382 }
2383
2384
2385 if (PID == 84367 || PID == 104769 || PID == 1577066) {
2386 console.log(action);
2387 //console.log((JSON.parse(xhr.responseText).json));
2388 }
2389 switch (action) {
2390 case "/frontend_bridge/fetch": // Daily Reward
2391 //$('.daily_login').find(".minimize").click();
2392 break;
2393 case "/player/index":
2394 settings();
2395 if (diosettings) {
2396 $('#dio_tools').click();
2397 diosettings = false;
2398 }
2399 break;
2400 // Ab Grepolis Version 2.114 ist der Ajax-Request: /frontend_bridge/execute
2401 case "/frontend_bridge/execute":
2402 case "/index/switch_town":
2403 if (DATA.options.str) {
2404 setTimeout(function () {
2405 UnitStrength.Menu.update();
2406 }, 0);
2407 }
2408 if (DATA.options.tra) {
2409 setTimeout(function () {
2410 TransportCapacity.update();
2411 }, 0);
2412 }
2413 if (DATA.options.bir) {
2414 //BiremeCounter.get();
2415 }
2416 if (DATA.options.tic) {
2417 setTimeout(function () {
2418 TownIcons.changeTownIcon();
2419 }, 0);
2420
2421 }
2422 break;
2423 case "/building_docks/index":
2424 if (DATA.options.bir) {
2425 //BiremeCounter.getDocks();
2426 }
2427 break;
2428 case "/building_place/units_beyond":
2429 if (DATA.options.bir) {
2430 //BiremeCounter.getAgora();
2431 }
2432 //addTransporterBackButtons();
2433 break;
2434 case "/building_place/simulator":
2435 if (DATA.options.sim) {
2436 Simulator.change();
2437 }
2438 break;
2439 case "/building_place/simulate":
2440 if (DATA.options.sim) {
2441 afterSimulation();
2442 }
2443 break;
2444
2445 case "/alliance_forum/forum":
2446 case "/message/new":
2447 case "/message/forward":
2448 case "/message/view":
2449 case "/player_memo/load_memo_content":
2450 if (DATA.options.sml) {
2451 SmileyBox.add(action);
2452 }
2453 if (DATA.options.bbc) {
2454 addForm(action);
2455 }
2456 break;
2457 case "/wonders/index":
2458 if (DATA.options.per) {
2459 WWTradeHandler();
2460 }
2461 if (DATA.options.wwc) {
2462 getResWW();
2463 }
2464 break;
2465 case "/wonders/send_resources":
2466 if (DATA.options.wwc) {
2467 getResWW();
2468 }
2469 break;
2470 case "/ranking/alliance":
2471 getPointRatioFromAllianceRanking();
2472 break;
2473 case "/ranking/wonder_alliance":
2474 getPointRatioFromAllianceRanking();
2475 if (DATA.options.wwr) {
2476 WorldWonderRanking.change(JSON.parse(xhr.responseText).plain.html);
2477 }
2478 if (DATA.options.wwi) {
2479 WorldWonderIcons.activate();
2480 }
2481 break;
2482 case "/alliance/members_show":
2483 getPointRatioFromAllianceMembers();
2484 break;
2485 case "/town_info/trading":
2486 addTradeMarks(15, 18, 15, "red");
2487 TownTabHandler(action.split("/")[2]);
2488 break;
2489 case "/town_overviews/trade_overview":
2490 addPercentTrade(1234, false); // TODO
2491 case "/farm_town_overviews/get_farm_towns_for_town":
2492 changeResColor();
2493 break;
2494 case "/command_info/conquest_info":
2495 if (DATA.options.str) {
2496 UnitStrength.Conquest.add();
2497 }
2498 break;
2499 case "/command_info/conquest_movements":
2500 case "/conquest_info/getinfo":
2501 if (DATA.options.cnt) {
2502 countMovements();
2503 }
2504 break;
2505 case "/building_barracks/index":
2506 case "/building_barracks/build":
2507 if (DATA.options.str) {
2508 UnitStrength.Barracks.add();
2509 }
2510 break;
2511 case "/town_info/attack":
2512 case "/town_info/support":
2513 //console.debug(JSON.parse(xhr.responseText));
2514 TownTabHandler(action.split("/")[2]);
2515
2516 break;
2517 case "/report/index":
2518 changeDropDownButton();
2519 loadFilter();
2520 saveFilter();
2521 //removeReports();
2522 break;
2523 case "/report/view":
2524 Statistics.LuckCounter.count();
2525 break;
2526 case "/message/default":
2527 case "/message/index":
2528 break;
2529 case "/town_info/go_to_town":
2530 /*
2531 //console.log(uw.Layout.wnd);
2532 var windo = uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).getID();
2533 //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX));
2534 uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).setPosition([100,400]);
2535 //console.log(windo);
2536 //console.log(uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_TOWNINDEX).getPosition());
2537 */
2538 break;
2539 }
2540 });
2541 }
2542
2543 function test() {
2544 //http://gpde.innogamescdn.com/images/game/temp/island.png
2545
2546 //console.log(uw.WMap);
2547 //console.log(uw.WMap.getSea(uw.WMap.getXCoord(), uw.WMap.getYCoord()));
2548
2549 //console.log(uw.GameControllers.LayoutToolbarActivitiesController().prototype.getActivityTypes());
2550 //console.log(uw.GameViews);
2551 //console.log(uw.GameViews.BarracksUnitDetails());
2552
2553 //console.log(uw.ITowns.getTown(uw.Game.townId).unitsOuter().sword);
2554 //console.log(uw.ITowns.getCurrentTown().unitsOuter().sword);
2555
2556 //console.log(uw.ITowns.getTown(uw.Game.townId).researches().attributes);
2557 //console.log(uw.ITowns.getTown(uw.Game.townId).hasConqueror());
2558 //console.log(uw.ITowns.getTown(uw.Game.townId).allUnits());
2559 //console.log(uw.ITowns.all_units.fragments[uw.Game.townId]._byId);
2560 //console.log("Zeus: " + uw.ITowns.player_gods.zeus_favor_delta_property.lastTriggeredVirtualPropertyValue);
2561 //console.log(uw.ITowns.player_gods.attributes);
2562
2563 //console.log(uw.ITowns.getTown('5813').createTownLink());
2564 //console.log(uw.ITowns.getTown(5813).unitsOuterTown);
2565
2566 //console.log(uw.ITowns.getTown(uw.Game.townId).getLinkFragment());
2567
2568 //console.log(uw.ITowns.getTown(uw.Game.townId).allGodsFavors());
2569
2570 console.debug("STADTGRUPPEN", Game.constants.ui.town_group);
2571 }
2572
2573 /*******************************************************************************************************************************
2574 * Helping functions
2575 * ----------------------------------------------------------------------------------------------------------------------------
2576 * | â— fixUnitValues: Get unit values and overwrite some wrong values
2577 * | â— getMaxZIndex: Get the highest z-index of "ui-dialog"-class elements
2578 * ----------------------------------------------------------------------------------------------------------------------------
2579 *******************************************************************************************************************************/
2580
2581 // Fix buggy grepolis values
2582 function fixUnitValues() {
2583 //uw.GameData.units.small_transporter.attack = uw.GameData.units.big_transporter.attack = uw.GameData.units.demolition_ship.attack = uw.GameData.units.militia.attack = 0;
2584 //uw.GameData.units.small_transporter.defense = uw.GameData.units.big_transporter.defense = uw.GameData.units.demolition_ship.defense = uw.GameData.units.colonize_ship.defense = 0;
2585 uw.GameData.units.militia.resources = {wood: 0, stone: 0, iron: 0};
2586 }
2587
2588 function getMaxZIndex() {
2589 var maxZ = Math.max.apply(null, $.map($("div[class^='ui-dialog']"), function (e, n) {
2590 if ($(e).css('position') == 'absolute') {
2591 return parseInt($(e).css('z-index'), 10) || 1000;
2592 }
2593 }));
2594 return (maxZ !== -Infinity) ? maxZ + 1 : 1000;
2595 }
2596
2597 function getBrowser() {
2598 var ua = navigator.userAgent,
2599 tem,
2600 M = ua.match(/(opera|maxthon|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
2601 if (/trident/i.test(M[1])) {
2602 tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
2603 M[1] = 'IE';
2604 M[2] = tem[1] || '';
2605 }
2606 if (M[1] === 'Chrome') {
2607 tem = ua.match(/\bOPR\/(\d+)/);
2608 if (tem !== null) {
2609 M[1] = 'Opera';
2610 M[2] = tem[1];
2611 }
2612 }
2613 M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
2614 if ((tem = ua.match(/version\/(\d+)/i)) !== null) M.splice(1, 1, tem[1]);
2615
2616 return M.join(' ');
2617 }
2618
2619 // Error Handling / Remote diagnosis / Automatic bug reports
2620 function errorHandling(e, fn) {
2621 if (PID == 84367 || PID == 104769 || PID === 1291505) {
2622 HumanMessage.error("DIO-TOOLS(" + version + ")-ERROR: " + e.message);
2623 console.log("DIO-TOOLS | Error-Stack | ", e.stack);
2624 } else {
2625 if (!DATA.error[version]) {
2626 DATA.error[version] = {};
2627 }
2628
2629 if (DATA.options.err && !DATA.error[version][fn]) {
2630 $.ajax({
2631 type: "POST",
2632 url: "https://diotools.de/game/error.php",
2633 data: {error: e.stack.replace(/'/g, '"'), "function": fn, browser: getBrowser(), version: version},
2634 success: function (text) {
2635 DATA.error[version][fn] = true;
2636 saveValue("error", JSON.stringify(DATA.error));
2637 }
2638 });
2639 }
2640 }
2641 }
2642
2643 function createWindowType(name, title, width, height, minimizable, position) {
2644 $('<style id="dio_window">' +
2645 '.dio_title_img { height:18px; float:left; margin-right:3px; } ' +
2646 '.dio_title { margin:1px 6px 13px 23px; color:rgb(126,223,126); } ' +
2647 '</style>').appendTo('head');
2648
2649 // Create Window Type
2650 function WndHandler(wndhandle) {
2651 this.wnd = wndhandle;
2652 }
2653
2654 Function.prototype.inherits.call(WndHandler, WndHandlerDefault);
2655 WndHandler.prototype.getDefaultWindowOptions = function () {
2656 return {
2657 position: position,
2658 width: width,
2659 height: height,
2660 minimizable: minimizable,
2661 title: "<img class='dio_title_img' src='http://666kb.com/i/cifvfsu3e2sdiipn0.gif' /><div class='dio_title'>" + title + "</div>"
2662 };
2663 };
2664 GPWindowMgr.addWndType(name, "", WndHandler, 1);
2665 }
2666
2667 // Notification
2668 var Notification = {
2669 init: function () {
2670 // NotificationType
2671 NotificationType.DIO_TOOLS = "diotools";
2672
2673 // Style
2674 $('<style id="dio_notification" type="text/css">' +
2675 '#notification_area .diotools .icon { background: url(http://666kb.com/i/cifvfsu3e2sdiipn0.gif) 4px 7px no-repeat !important;} ' +
2676 '#notification_area .diotools { cursor:pointer; } ' +
2677 '</style>').appendTo('head');
2678
2679 var notif = DATA.notification;
2680 if (notif <= 7) {
2681 //Notification.create(1, 'Swap context menu buttons ("Select town" and "City overview")');
2682 //Notification.create(2, 'Town overview (old window mode)');
2683 //Notification.create(3, 'Mouse wheel: You can change the views with the mouse wheel');
2684 //Notification.create(4, 'Town icons on the strategic map');
2685 //Notification.create(5, 'Percentual unit population in the town list');
2686 //Notification.create(6, 'New world wonder ranking');
2687 //Notification.create(7, 'World wonder icons on the strategic map');
2688
2689 // Click Event
2690 $('.diotools .icon').click(function () {
2691 openSettings();
2692 $(this).parent().find(".close").click();
2693 });
2694
2695 saveValue('notif', '8');
2696 }
2697 },
2698 create: function (nid, feature) {
2699 var Notification = new NotificationHandler();
2700 Notification.notify($('#notification_area>.notification').length + 1, uw.NotificationType.DIO_TOOLS,
2701 "<span style='color:rgb(8, 207, 0)'><b><u>New Feature!</u></b></span>" + feature + "<span class='small notification_date'>DIO-Tools: v" + version + "</span>");
2702 }
2703 };
2704
2705 /*******************************************************************************************************************************
2706 * Mousewheel Zoom
2707 *******************************************************************************************************************************/
2708
2709 var MouseWheelZoom = {
2710 // Scroll trough the views
2711 activate: function () {
2712 $('#main_area, #dio_political_map, .viewport, .sjs-city-overview-viewport').bind('mousewheel', function (e) {
2713 e.stopPropagation();
2714 var current = $('.bull_eye_buttons .checked').get(0).getAttribute("name"), delta = 0, scroll, sub_scroll = 6;
2715
2716 switch (current) {
2717 case 'political_map':
2718 scroll = 4;
2719 break;
2720 case 'strategic_map':
2721 scroll = 3;
2722 break;
2723 case 'island_view':
2724 scroll = 2;
2725 break;
2726 case 'city_overview':
2727 scroll = 1;
2728 break;
2729 }
2730 delta = -e.originalEvent.detail || e.originalEvent.wheelDelta; // Firefox || Chrome & Opera
2731
2732 //console.debug("cursor_pos", e.pageX, e.pageY);
2733
2734 if (scroll !== 4) {
2735 if (delta < 0) {
2736 scroll += 1;
2737 } else {
2738 scroll -= 1;
2739 }
2740 } else {
2741 // Zoomstufen bei der Politischen Karte
2742 sub_scroll = $('.zoom_select').get(0).selectedIndex;
2743
2744 if (delta < 0) {
2745 sub_scroll -= 1;
2746 } else {
2747 sub_scroll += 1;
2748 }
2749 if (sub_scroll === -1) {
2750 sub_scroll = 0;
2751 }
2752 if (sub_scroll === 7) {
2753 scroll = 3;
2754 }
2755 }
2756 switch (scroll) {
2757 case 4:
2758 if (!$('.bull_eye_buttons .btn_political_map').hasClass("checked")) {
2759 $('.bull_eye_buttons .btn_political_map').click();
2760 }
2761
2762 // onChange wird aufgerufen, wenn sich die Selektierung ändert
2763 //$('.zoom_select option').eq(sub_scroll).prop('selected', true);
2764 $('.zoom_select').get(0)[sub_scroll].selected = true;
2765 //$('.zoom_select').get(0).change();
2766 //$('.zoom_select').get(0).val(sub_scroll);
2767
2768
2769 PoliticalMap.zoomToCenter();
2770 //PoliticalMap.zoomToCenterToCursorPosition($('.zoom_select').get(0)[sub_scroll].value, [e.pageX, e.pageY]);
2771
2772 break;
2773 case 3:
2774 $('.bull_eye_buttons .strategic_map').click();
2775 $('#popup_div').css('display', 'none');
2776 break;
2777 case 2:
2778 $('.bull_eye_buttons .island_view').click();
2779 TownPopup.remove();
2780 break;
2781 case 1:
2782 $('.bull_eye_buttons .city_overview').click();
2783 break;
2784 }
2785
2786 // Prevent page from scrolling
2787 return false;
2788 });
2789 },
2790 deactivate: function () {
2791 $('#main_area, .ui_city_overview').unbind('mousewheel');
2792 }
2793 };
2794
2795
2796 /*******************************************************************************************************************************
2797 * Statistics
2798 * ----------------------------------------------------------------------------------------------------------------------------
2799 * | â— Expansion of towns?
2800 * | â— Occupancy of the farms?
2801 * | â— Mouseclick-Counter?
2802 * | â— Resource distribution (%)?
2803 * | â— Building level counter ?
2804 * ----------------------------------------------------------------------------------------------------------------------------
2805 *******************************************************************************************************************************/
2806 //$('<script src="https://github.com/mbostock/d3/blob/master/d3.js"></script>').appendTo("head");
2807 // http://mbostock.github.com/d3/d3.v2.js
2808 var Statistics = {
2809 activate: function () {
2810 Statistics.addButton();
2811
2812 $('<style id="dio_statistic">' +
2813 'path { stroke: steelblue; stroke-width: 1; fill: none; } ' +
2814 '.axis { shape-rendering: crispEdges; } ' +
2815 '.x.axis line { stroke: lightgrey; } ' +
2816 '.x.axis .minor { stroke-opacity: .5; } ' +
2817 '.x.axis path { display: none; } ' +
2818 '.y.axis line, .y.axis path { fill: none; stroke: #000; } ' +
2819 '</style>').appendTo('head');
2820
2821 Statistics.ClickCounter.activate();
2822
2823 // Create Window Type
2824 createWindowType("DIO_STATISTICS", "Statistics", 300, 250, true, ["center", "center", 100, 100]);
2825 },
2826 deactivate: function () {
2827 $('#dio_statistic_button').remove();
2828 $('#dio_statistic').remove();
2829 Statistics.ClickCounter.deactivate();
2830 },
2831 addButton: function () {
2832 $('<div id="dio_statistic_button" class="circle_button"><div class="ico_statistics js-caption"></div></div>').appendTo(".gods_area");
2833
2834 // Style
2835 $('<style id="dio_statistic_style">' +
2836 '#dio_statistic_button { top:56px; left:-4px; z-index:10; position:absolute; } ' +
2837
2838 '#dio_statistic_button .ico_statistics { margin:7px 0px 0px 8px; width:17px; height:17px; background:url(http://s1.directupload.net/images/140408/pltgqlaw.png) no-repeat 0px 0px; background-size:100%; } ' +
2839 // http://s14.directupload.net/images/140408/k4wikrlq.png // http://s7.directupload.net/images/140408/ahfr8227.png
2840 '#dio_statistic_button .ico_statistics.checked { margin-top:8px; } ' +
2841 '</style>').appendTo('head');
2842
2843 // Tooltip
2844 $('#dio_statistic_button').tooltip(getText("labels", "uni")); // TODO
2845
2846 // Events
2847 $('#dio_statistic_button').on('mousedown', function () {
2848 $('#dio_statistic_button, .ico_statistics').addClass("checked");
2849 }).on('mouseup', function () {
2850 $('#dio_statistic_button, .ico_statistics').removeClass("checked");
2851 });
2852
2853 $('#dio_statistic_button').click(function () {
2854 if (!Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_STATISTICS)) {
2855 Statistics.openWindow();
2856 $('#dio_statistic_button, .ico_statistics').addClass("checked");
2857 } else {
2858 Statistics.closeWindow();
2859 $('#dio_statistic_button, .ico_statistics').removeClass("checked");
2860 }
2861 });
2862 },
2863 openWindow: function () {
2864 var content =
2865 '<div id="dio_mouseclicks" style="margin-bottom:5px; font-style:italic;">' +
2866 '<span style="text-decoration:underline;">Insgesamt:</span> <span></span>' +
2867 '<span style="float:right;"></span><span style="text-decoration:underline;float:right;">Heute:</span> ' +
2868 '</div><canvas id="dio_graph" width="290" height="150" style="margin-top:15px;"></canvas>';
2869
2870 Layout.wnd.Create(GPWindowMgr.TYPE_DIO_STATISTICS).setContent(content);
2871
2872 Statistics.ClickCounter.onOpenWindow();
2873
2874 // Draw diagram
2875 var graph, xPadding = 35, yPadding = 25;
2876
2877 var data = {values: [{X: "Jan", Y: 0}]};
2878
2879 //console.log(DATA.clickCount);
2880 for (var o in DATA.clickCount) {
2881 data.values.push({X: "opp", Y: DATA.clickCount[o]});
2882 }
2883
2884 function getMaxY() {
2885 var max = 0;
2886 for (var i = 0; i < data.values.length; i++) {
2887 if (data.values[i].Y > max) {
2888 max = data.values[i].Y;
2889 }
2890 }
2891 max += 10 - max % 10;
2892 return max + 10;
2893 }
2894
2895 function getXPixel(val) {
2896 return ((graph.width() - xPadding) / data.values.length) * val + (xPadding + 10);
2897 }
2898
2899 function getYPixel(val) {
2900 return graph.height() - (((graph.height() - yPadding) / getMaxY()) * val) - yPadding;
2901 }
2902
2903 graph = $('#dio_graph');
2904 var c = graph[0].getContext('2d');
2905
2906 c.lineWidth = 2;
2907 c.strokeStyle = '#333';
2908 c.font = 'italic 8pt sans-serif';
2909 c.textAlign = "center";
2910
2911 // Axis
2912 c.beginPath();
2913 c.moveTo(xPadding, 0);
2914 c.lineTo(xPadding, graph.height() - yPadding);
2915 c.lineTo(graph.width(), graph.height() - yPadding);
2916 c.stroke();
2917
2918 // X-Axis caption
2919 for (var x = 0; x < data.values.length; x++) {
2920 c.fillText(data.values[x].X, getXPixel(x), graph.height() - yPadding + 20);
2921 }
2922
2923 // Y-Axis caption
2924 c.textAlign = "right";
2925 c.textBaseline = "middle";
2926
2927 var maxY = getMaxY(), maxYscala = Math.ceil(maxY / 1000) * 1000;
2928 //console.log(maxY);
2929 for (var y = 0; y < maxY; y += maxYscala / 10) {
2930 c.fillText(y, xPadding - 10, getYPixel(y));
2931 }
2932
2933 // Graph
2934 c.strokeStyle = 'rgb(0,150,0)';
2935 c.beginPath();
2936 c.moveTo(getXPixel(0), getYPixel(data.values[0].Y));
2937
2938 for (var i = 1; i < data.values.length; i++) {
2939 c.lineTo(getXPixel(i), getYPixel(data.values[i].Y));
2940 }
2941 c.stroke();
2942
2943 // Points
2944 c.fillStyle = '#333';
2945
2946 for (var p = 0; p < data.values.length; p++) {
2947 c.beginPath();
2948 c.arc(getXPixel(p), getYPixel(data.values[p].Y), 2, 0, Math.PI * 2, true);
2949 c.fill();
2950 }
2951 },
2952 closeWindow: function () {
2953 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_STATISTICS).close();
2954 },
2955
2956 ClickCounter: {
2957 today: "00000000",
2958 activate: function () {
2959 Statistics.ClickCounter.updateDate();
2960
2961 $(document).on("mousedown", function () {
2962 DATA.clickCount[Statistics.ClickCounter.today]++;
2963 });
2964
2965 window.onbeforeunload = function () {
2966 Statistics.ClickCounter.save();
2967 };
2968
2969 // TODO: Update date
2970 setTimeout(function () {
2971 Statistics.ClickCounter.updateDate();
2972 }, 0);
2973 },
2974 deactivate: function () {
2975 $(document).off("mousedown");
2976 },
2977 save: function () {
2978 saveValue(WID + "_click_count", JSON.stringify(DATA.clickCount));
2979 },
2980 updateDate: function () {
2981 var today = new Date((window.Timestamp.server() + 7200) * 1000);
2982
2983 Statistics.ClickCounter.today = today.getUTCFullYear() + ((today.getUTCMonth() + 1) < 10 ? "0" : "") + (today.getUTCMonth() + 1) + (today.getUTCDate() < 10 ? "0" : "") + today.getUTCDate();
2984
2985 DATA.clickCount[Statistics.ClickCounter.today] = DATA.clickCount[Statistics.ClickCounter.today] || 0;
2986 },
2987 onOpenWindow: function () {
2988 $('#dio_mouseclicks span:eq(2)').get(0).innerHTML = DATA.clickCount[Statistics.ClickCounter.today];
2989 $(document).off("mousedown");
2990 $(document).on("mousedown", function () {
2991 if ($('#dio_mouseclicks').get(0)) {
2992 $('#dio_mouseclicks span:eq(2)').get(0).innerHTML = ++DATA.clickCount[Statistics.ClickCounter.today];
2993 } else {
2994 DATA.clickCount[Statistics.ClickCounter.today]++;
2995 $(document).off("mousedown");
2996 $(document).on("mousedown", function () {
2997 DATA.clickCount[Statistics.ClickCounter.today]++;
2998 });
2999 }
3000 });
3001 }
3002 },
3003 LuckCounter: {
3004 luckArray: {},
3005 count: function () {
3006 if ($('.fight_bonus.luck').get(0)) {
3007 var report_id = $('#report_report_header .game_arrow_delete').attr("onclick").split(",")[1].split(")")[0].trim(),
3008 luck = parseInt($('.fight_bonus.luck').get(0).innerHTML.split(":")[1].split("%")[0].trim(), 10);
3009
3010 Statistics.LuckCounter.luckArray[report_id] = luck;
3011
3012 //console.log(Statistics.LuckCounter.calcAverage());
3013 }
3014 },
3015 calcAverage: function () {
3016 var sum = 0, count = 0;
3017 for (var report_id in Statistics.LuckCounter.luckArray) {
3018 if (Statistics.LuckCounter.luckArray.hasOwnProperty(report_id)) {
3019 sum += parseInt(Statistics.LuckCounter.luckArray[report_id], 10);
3020 count++;
3021 }
3022 }
3023 return (parseFloat(sum) / parseFloat(count));
3024 }
3025 }
3026 };
3027
3028 /*******************************************************************************************************************************
3029 * Body Handler
3030 * ----------------------------------------------------------------------------------------------------------------------------
3031 * | â— Town icon
3032 * | â— Town list: Adds town type to the town list
3033 * | â— Swap Context Icons
3034 * | â— City overview
3035 * ----------------------------------------------------------------------------------------------------------------------------
3036 *******************************************************************************************************************************/
3037
3038 function imageSelectionProtection() {
3039 $('<style id="dio_image_selection" type="text/css"> img { -moz-user-select: -moz-none; -khtml-user-select: none; -webkit-user-select: none;} </style>').appendTo('head');
3040 }
3041
3042 var worldWonderIcon = {
3043 colossus_of_rhodes: "url(https://gpall.innogamescdn.com/images/game/map/wonder_colossus_of_rhodes.png) 38px -1px;",
3044 great_pyramid_of_giza: "url(https://gpall.innogamescdn.com/images/game/map/wonder_great_pyramid_of_giza.png) 34px -6px;",
3045 hanging_gardens_of_babylon: "url(https://gpall.innogamescdn.com/images/game/map/wonder_hanging_gardens_of_babylon.png) 34px -5px;",
3046 lighthouse_of_alexandria: "url(https://gpall.innogamescdn.com/images/game/map/wonder_lighthouse_of_alexandria.png) 37px -1px;",
3047 mausoleum_of_halicarnassus: "url(https://gpall.innogamescdn.com/images/game/map/wonder_mausoleum_of_halicarnassus.png) 37px -4px;",
3048 statue_of_zeus_at_olympia: "url(https://gpall.innogamescdn.com/images/game/map/wonder_statue_of_zeus_at_olympia.png) 36px -3px;",
3049 temple_of_artemis_at_ephesus: "url(https://gpall.innogamescdn.com/images/game/map/wonder_temple_of_artemis_at_ephesus.png) 34px -5px;"
3050 };
3051
3052 var WorldWonderIcons = {
3053 activate: function () {
3054 try {
3055 if (!$('#dio_wondericons').get(0)) {
3056 var color = "orange";
3057
3058 // style for world wonder icons
3059 var style_str = "<style id='dio_wondericons' type='text/css'>";
3060 for (var ww_type in wonder.map) {
3061 if (wonder.map.hasOwnProperty(ww_type)) {
3062 for (var ww in wonder.map[ww_type]) {
3063 if (wonder.map[ww_type].hasOwnProperty(ww)) {
3064 /*
3065 if(wonder.map[ww_type][ww] !== AID){
3066 color = "rgb(192, 109, 54)";
3067 } else {
3068 color = "orange";
3069 }
3070 */
3071 style_str += "#mini_i" + ww + ":before {" +
3072 "content: '';" +
3073 "background:" + color + " " + worldWonderIcon[ww_type] +
3074 "background-size: auto 97%;" +
3075 "padding: 8px 16px;" +
3076 "top: 50px;" +
3077 "position: relative;" +
3078 "border-radius: 40px;" +
3079 "z-index: 200;" +
3080 "cursor: pointer;" +
3081 "box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5);" +
3082 "border: 2px solid green; } " +
3083 "#mini_i" + ww + ":hover:before { z-index: 201; " +
3084 "filter: url(#Brightness12);" +
3085 "-webkit-filter: brightness(1.2); } ";
3086 }
3087 }
3088 }
3089 }
3090 $(style_str + "</style>").appendTo('head');
3091
3092 // Context menu on mouseclick
3093 $('#minimap_islands_layer').on('click', '.m_island', function (e) {
3094 var ww_coords = this.id.split("i")[3].split("_");
3095 uw.Layout.contextMenu(e, 'wonder', {ix: ww_coords[0], iy: ww_coords[1]});
3096 });
3097
3098
3099 }
3100 } catch (error) {
3101 errorHandling(error, "setWonderIconsOnMap");
3102 }
3103 },
3104 deactivate: function () {
3105 $('#dio_wondericons').remove();
3106 }
3107 };
3108
3109 var TownIcons = {
3110 types: {
3111 // Automatic Icons
3112 lo: 0,
3113 ld: 3,
3114 so: 6,
3115 sd: 7,
3116 fo: 10,
3117 fd: 9,
3118 bu: 14, /* Building */
3119 po: 22,
3120 no: 12,
3121
3122 // Manual Icons
3123 fa: 20, /* Favor */
3124 re: 15, /* Resources */
3125 di: 2, /* Distance */
3126 sh: 1, /* Pierce */
3127 lu: 13, /* ?? */
3128 dp: 11, /* Diplomacy */
3129 ha: 15, /* ? */
3130 si: 18, /* Silber */
3131 ra: 17,
3132 ch: 19, /* Research */
3133 ti: 23, /* Time */
3134 un: 5,
3135 wd: 16, /* Wood */
3136 wo: 24, /* World */
3137 bo: 13, /* Booty */
3138 gr: 21, /* Lorbeer */
3139 st: 17, /* Stone */
3140 is: 26, /* ?? */
3141 he: 4, /* Helmet */
3142 ko: 8 /* Kolo */
3143
3144 },
3145 deactivate: function () {
3146 $('#town_icon').remove();
3147 $('#dio_townicons_field').remove();
3148
3149 TownPopup.deactivate();
3150 },
3151 activate: function () {
3152 try {
3153 $('<div id="town_icon"><div class="town_icon_bg"><div class="icon_big townicon_' +
3154 (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no") + " auto")) + '"></div></div></div>').appendTo('.town_name_area');
3155
3156 // Town Icon Style
3157 $('#town_icon .icon_big').css({
3158 backgroundPosition: TownIcons.types[(manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")))] * -25 + 'px 0px'
3159 });
3160 //console.debug(dio_sprite);
3161 $('<style id="dio_townicons_field" type="text/css">' +
3162 '#town_icon { background:url(' + dio_sprite + ') 0 -125px no-repeat; position:absolute; width:69px; height:61px; left:-47px; top:0px; z-index: 10; } ' +
3163 '#town_icon .town_icon_bg { background:url(' + dio_sprite + ') -76px -129px no-repeat; width:43px; height:43px; left:25px; top:4px; cursor:pointer; position: relative; } ' +
3164 '#town_icon .town_icon_bg:hover { filter:url(#Brightness11); -webkit-filter:brightness(1.1); box-shadow: 0px 0px 15px rgb(1, 197, 33); } ' +
3165 '#town_icon .icon_big { position:absolute; left:9px; top:9px; height:25px; width:25px; } ' +
3166
3167 '#town_icon .select_town_icon {position: absolute; top:47px; left:23px; width:145px; display:none; padding:2px; border:3px inset rgb(7, 99, 12); box-shadow:rgba(0, 0, 0, 0.5) 4px 4px 6px; border-radius:0px 10px 10px 10px;' +
3168 'background:url(https://gpall.innogamescdn.com/images/game/popup/middle_middle.png); } ' +
3169 '#town_icon .item-list { max-height:400px; max-width:200px; align:right; overflow-x:hidden; } ' +
3170
3171 '#town_icon .option_s { cursor:pointer; width:20px; height:20px; margin:0px; padding:2px 2px 3px 3px; border:2px solid rgba(0,0,0,0); border-radius:5px; background-origin:content-box; background-clip:content-box;} ' +
3172 '#town_icon .option_s:hover { border: 2px solid rgb(59, 121, 81) !important;-webkit-filter: brightness(1.3); } ' +
3173 '#town_icon .sel { border: 2px solid rgb(202, 176, 109); } ' +
3174 '#town_icon hr { width:145px; margin:0px 0px 7px 0px; position:relative; top:3px; border:0px; border-top:2px dotted #000; float:left} ' +
3175 '#town_icon .auto_s { width:136px; height:16px; float:left} ' +
3176
3177 // Quickbar modification
3178 '.ui_quickbar .left, .ui_quickbar .right { width:46%; } ' +
3179
3180 // because of Kapsonfires Script and Beta Worlds bug report bar:
3181 '.town_name_area { z-index:11; left:52%; } ' +
3182 '.town_name_area .left { z-index:20; left:-39px; } ' +
3183 '</style>').appendTo('head');
3184
3185
3186 var icoArray = ['ld', 'lo', 'sh', 'di', 'un',
3187 'sd', 'so', 'ko', 'ti', 'gr',
3188 'fd', 'fo', 'dp', 'no', 'po',
3189 're', 'wd', 'st', 'si', 'bu',
3190 'he', 'ch', 'bo', 'fa', 'wo'];
3191
3192 // Fill select box with town icons
3193 $('<div class="select_town_icon dropdown-list default active"><div class="item-list"></div></div>').appendTo("#town_icon");
3194 for (var i in icoArray) {
3195 if (icoArray.hasOwnProperty(i)) {
3196 $('.select_town_icon .item-list').append('<div class="option_s icon_small townicon_' + icoArray[i] + '" name="' + icoArray[i] + '"></div>');
3197 }
3198 }
3199 $('<hr><div class="option_s auto_s" name="auto"><b>Auto</b></div>').appendTo('.select_town_icon .item-list');
3200
3201 $('#town_icon .option_s').click(function () {
3202 $("#town_icon .sel").removeClass("sel");
3203 $(this).addClass("sel");
3204
3205 if ($(this).attr("name") === "auto") {
3206 delete manuTownTypes[uw.Game.townId];
3207 } else {
3208 manuTownTypes[uw.Game.townId] = $(this).attr("name");
3209 }
3210 TownIcons.changeTownIcon();
3211
3212 // Update town icons on the map
3213 TownIcons.Map.activate(); //setOnMap();
3214
3215 saveValue(WID + "_townTypes", JSON.stringify(manuTownTypes));
3216 });
3217
3218 // Show & hide drop menus on click
3219 $('#town_icon .town_icon_bg').click(function () {
3220 var el = $('#town_icon .select_town_icon').get(0);
3221 if (el.style.display === "none") {
3222 el.style.display = "block";
3223 } else {
3224 el.style.display = "none";
3225 }
3226 });
3227
3228 $('#town_icon .select_town_icon [name="' + (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" : "" )) + '"]').addClass("sel");
3229
3230 } catch (error) {
3231 errorHandling(error, "addTownIcon");
3232 }
3233 },
3234 changeTownIcon: function () {
3235 var townType = (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")));
3236 $('#town_icon .icon_big').removeClass().addClass('icon_big townicon_' + townType + " auto");
3237 $('#town_icon .sel').removeClass("sel");
3238 $('#town_icon .select_town_icon [name="' + (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" : "" )) + '"]').addClass("sel");
3239
3240 $('#town_icon .icon_big').css({
3241 backgroundPosition: TownIcons.types[townType] * -25 + 'px 0px'
3242 });
3243
3244 $('#town_icon .select_town_icon').get(0).style.display = "none";
3245 },
3246 Map: {
3247 // TODO: activate aufspliten in activate und add
3248 activate: function () {
3249 try {
3250 // if town icon changed
3251 if ($('#dio_townicons_map').get(0)) {
3252 $('#dio_townicons_map').remove();
3253 }
3254
3255 // Style for own towns (town icons)
3256 var start = (new Date()).getTime(), end, style_str = "<style id='dio_townicons_map' type='text/css'>";
3257 for (var e in autoTownTypes) {
3258 if (autoTownTypes.hasOwnProperty(e)) {
3259 style_str += "#mini_t" + e + ", #town_flag_"+ e + " .flagpole {"+
3260 "background: rgb(255, 187, 0) url(" + dio_sprite + ") " + (TownIcons.types[(manuTownTypes[e] || autoTownTypes[e])] * -25) + "px -27px repeat !important; } ";
3261 }
3262 }
3263
3264 style_str += ".own_town .flagpole, #main_area .m_town.player_"+ PID +" { z-index: 100 !important; cursor: pointer; width:19px; height:19px; border-radius: 11px; border: 2px solid rgb(16, 133, 0); margin: -4px !important; font-size: 0em !important; box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.5); } ";
3265
3266 // Mouseover Effect
3267 style_str += ".own_town .flagpole:hover, .m_town:hover { z-index: 101 !important; filter: brightness(1.2); -webkit-filter: brightness(1.2); font-size: 2em; margin-top: -1px; } ";
3268
3269
3270 // Context menu on mouse click
3271 style_str += "#minimap_islands_layer .m_town { z-index: 99; cursor: pointer; } ";
3272
3273 $('#minimap_islands_layer').off('click', '.m_town');
3274 $('#minimap_islands_layer').on('click', '.m_town', function (z) {
3275 var id = parseInt(this.id.substring(6), 10);
3276
3277 // Town names of foreign towns are unknown
3278 if(typeof(uw.ITowns.getTown(id)) !== "undefined") {
3279 Layout.contextMenu(z, 'determine', {"id": id, "name": uw.ITowns.getTown(id).name});
3280 }
3281 else {
3282 // No town name in the title of the window
3283 Layout.contextMenu(z, 'determine', {"id": id });
3284 }
3285
3286 // Prevent parent world wonder event
3287 z.stopPropagation();
3288 });
3289
3290 $('#minimap_islands_layer').off("mousedown");
3291 $('#minimap_islands_layer').on("mousedown", function(){
3292
3293 if(typeof($('#context_menu').get(0)) !== "undefined"){
3294 $('#context_menu').get(0).remove();
3295 }
3296 });
3297
3298
3299 // Town Popup for own towns
3300 style_str += "#dio_town_popup .count { position: absolute; bottom: 1px; right: 1px; font-size: 10px; } ";
3301
3302 // Town Popups on Strategic map
3303 $('#minimap_islands_layer').off('mouseout', '.m_town');
3304 $('#minimap_islands_layer').on('mouseout', '.m_town', function () {
3305 TownPopup.remove();
3306 });
3307 $('#minimap_islands_layer').off('mouseover', '.m_town');
3308 $('#minimap_islands_layer').on('mouseover', '.m_town', function () {
3309 TownPopup.add(this);
3310 });
3311
3312 // Town Popups on island view
3313 $('#map_towns').off('mouseout', '.own_town .flagpole');
3314 $('#map_towns').on('mouseout', '.own_town .flagpole', function () {
3315 TownPopup.remove();
3316 });
3317 $('#map_towns').off('mouseover', '.own_town .flagpole');
3318 $('#map_towns').on('mouseover', '.own_town .flagpole', function () {
3319 TownPopup.add(this);
3320 });
3321
3322
3323 // Style for foreign cities (shadow)
3324 style_str += "#minimap_islands_layer .m_town { text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.7); } ";
3325
3326 // Style for night mode
3327 style_str += "#minimap_canvas.expanded.night, #map.night .flagpole { filter: brightness(0.7); -webkit-filter: brightness(0.7); } ";
3328 style_str += "#minimap_click_layer { display:none; }";
3329
3330 style_str += "</style>";
3331 $(style_str).appendTo('head');
3332
3333
3334 } catch (error) {
3335 errorHandling(error, "TownIcons.Map.activate");
3336 }
3337 },
3338 deactivate: function () {
3339 $('#dio_townicons_map').remove();
3340
3341 // Events entfernen
3342 $('#minimap_islands_layer').off('click', '.m_town');
3343 $('#minimap_islands_layer').off("mousedown");
3344
3345 $('#minimap_islands_layer').off('mouseout', '.m_town');
3346 $('#minimap_islands_layer').off('mouseover', '.m_town');
3347 }
3348 }
3349 };
3350
3351 function updateIcon() {
3352 setTimeout(function() {
3353 var townType = (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")));
3354 $('#town_icon .icon_big').removeClass().addClass('icon_big townicon_' + townType + " auto");
3355 $('#town_icon .icon_big').css({
3356 backgroundPosition: TownIcons.types[townType] * -25 + 'px 0px'
3357 });
3358 },80);
3359 }
3360
3361 $(".btn_next_town").click(function () {
3362 updateIcon();
3363 });
3364 $(".btn_prev_town").click(function () {
3365 updateIcon();
3366 });
3367
3368
3369 var TownPopup = {
3370 activate : function(){
3371
3372 $('<style id="dio_town_popup_style" type="text/css">' +
3373 '#dio_town_popup { position:absolute; z-index:99;max-width: 173px;} ' +
3374
3375 '#dio_town_popup .title { margin:5px;font-weight: bold; } ' +
3376
3377 '#dio_town_popup .dio_branding { position:absolute; right:12px; top:8px; height: 20px; filter:sepia(1); -webkit-filter:sepia(1); opacity:0.5; } ' +
3378
3379 '#dio_town_popup .unit_content, ' +
3380 '#dio_town_popup .spy_content, ' +
3381 '#dio_town_popup .god_content, ' +
3382 '#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; } ' +
3383 '#dio_town_popup .resources_content { text-align: right; margin-top:3px; } ' +
3384
3385 '#dio_town_popup .resources_content table { min-width:95% } ' +
3386
3387 '#dio_town_popup .footer_content { margin-top:3px; } ' +
3388 '#dio_town_popup .footer_content table { width:100%; } ' +
3389
3390 '#dio_town_popup .spy_content { height:25px; margin-right:3px; } ' +
3391 '#dio_town_popup .god_content { width:24px; } ' +
3392
3393 '#dio_town_popup .god_mini { height: 25px; width: 32px; background-size: 75%; background-position: 0px -122px; margin-right: -8px; } ' +
3394
3395 // God Icon
3396 '#dio_town_popup .god_mini.zeus { background-position: 0px 0px; } ' +
3397 '#dio_town_popup .god_mini.athena { background-position: 0px -24px; } ' +
3398 '#dio_town_popup .god_mini.poseidon { background-position: 0px -49px; } ' +
3399 '#dio_town_popup .god_mini.hera { background-position: 0px -73px; } ' +
3400 '#dio_town_popup .god_mini.hades { background-position: 0px -98px; } ' +
3401 '#dio_town_popup .god_mini.artemis { background-position: 0px -146px; } ' +
3402
3403 '#dio_town_popup .count { position: absolute; bottom: -2px; right: 2px; font-size: 10px; font-family: Verdana,Arial,Helvetica,sans-serif; } ' +
3404 '#dio_town_popup .four_digit_number .count { font-size:8px !important; } ' +
3405 '#dio_town_popup .unit_icon25x25 { border: 1px solid #6e4b0b; margin: 1px; } ' +
3406 '#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%; } ' +
3407
3408 // Spy Icon
3409 '#dio_town_popup .support_filter { margin: 0px 4px 0px 0px; float:left; } ' +
3410 '#dio_town_popup .spy_text { line-height: 2.3em; float:left; } ' +
3411
3412 // Bei langen Stadtnamen wird sonst der Rand abgeschnitten:
3413 '#dio_town_popup .popup_middle_right { min-width: 11px; } ' +
3414
3415 '</style>').appendTo('head');
3416
3417 },
3418 deactivate : function(){
3419 $("#dio_town_popup_style").remove();
3420 },
3421 add : function(that){
3422 var townID = 0;
3423 //console.debug("TOWN", $(that).offset(), that.id);
3424
3425 if(that.id === ""){
3426 // Island view
3427 townID = parseInt($(that).parent()[0].id.substring(10), 10);
3428 }
3429 else {
3430 // Strategic map
3431 townID = parseInt(that.id.substring(6), 10);
3432 }
3433
3434 // Own town?
3435 if (typeof(uw.ITowns.getTown(townID)) !== "undefined") {
3436
3437 var units = ITowns.getTowns()[townID].units();
3438
3439 TownPopup.remove();
3440
3441 // var popup = "<div id='dio_town_popup' style='left:" + ($(that).offset().left + 20) + "px; top:" + ($(that).offset().top + 20) + "px; '>";
3442 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'>";
3443
3444 popup += "<tr class='popup_top'><td class='popup_top_left'></td><td class='popup_top_middle'></td><td class='popup_top_right'></td></tr>";
3445
3446 popup += "<tr><td class='popup_middle_left'> </td><td style='width: auto;' class='popup_middle_middle'>";
3447
3448 // Title (town name)
3449 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>";
3450
3451 // Unit Container
3452 popup += "<div class='unit_content'>";
3453 if(!$.isEmptyObject(units)) {
3454
3455 for (var unit_id in units) {
3456 if (units.hasOwnProperty(unit_id)) {
3457
3458 var classSize = "";
3459
3460 if(units[unit_id] > 1000){
3461 classSize = "four_digit_number";
3462 }
3463
3464 // Unit
3465 popup += '<div class="unit_icon25x25 ' + unit_id + ' '+ classSize +'"><span class="count text_shadow">' + units[unit_id] + '</span></div>';
3466 }
3467 }
3468 }
3469
3470 // - Wall
3471 var wallLevel = ITowns.getTowns()[townID].getBuildings().attributes.wall;
3472 popup += '<div class="wall image bold"><span class="count text_shadow">'+ wallLevel +'</span></div>';
3473
3474 popup += "</div>";
3475
3476 // Resources Container
3477 popup += "<div class='resources_content'><table cellspacing='2px' cellpadding='0px'><tr>";
3478
3479 var resources = ITowns.getTowns()[townID].resources();
3480 var storage = ITowns.getTowns()[townID].getStorage();
3481
3482 // - Wood
3483 var textColor = (resources.wood === storage) ? textColor = "color:red;" : textColor = "";
3484 popup += '<td class="resources_small wood"></td><td style="'+ textColor +'; width:1%;">' + resources.wood + '</td>';
3485
3486 popup += '<td style="min-width:15px;"></td>';
3487
3488 // - Population
3489 popup += '<td class="resources_small population"></td><td style="width:1%">' + resources.population + '</td>';
3490
3491 popup += '</tr><tr>';
3492
3493 // - Stone
3494 textColor = (resources.stone === storage) ? textColor = "color:red;" : textColor = "";
3495 popup += '<td class="resources_small stone"></td><td style="'+ textColor +'">' + resources.stone + '</td>';
3496
3497 popup += '</tr><tr>';
3498
3499 // - Iron
3500 textColor = (resources.iron === storage) ? textColor = "color:red;" : textColor = "";
3501 popup += '<td class="resources_small iron"></td><td style="'+ textColor +'">' + resources.iron + '</td>';
3502
3503
3504 popup += "</tr></table></div>";
3505
3506 // console.debug("TOWNINFO", ITowns.getTowns()[townID]);
3507
3508 // Spy and God Container
3509 popup += "<div class='footer_content'><table cellspacing='0px'><tr>";
3510
3511 var spy_storage = ITowns.getTowns()[townID].getEspionageStorage();
3512
3513 // - Spy content
3514 popup += "<td class='spy_content'>";
3515 popup += '<div class="support_filter attack_spy"></div><div class="spy_text">'+ pointNumber(spy_storage) +'</div>';
3516 popup += "</td>";
3517
3518 popup += "<td></td>";
3519
3520 // - God Content
3521 var god = ITowns.getTowns()[townID].god();
3522
3523 popup += "<td class='god_content'>";
3524 popup += '<div class="god_mini '+ god +'"></div>';
3525 popup += "</td>";
3526
3527 popup += "</tr></table></div>";
3528
3529
3530
3531 popup += "</td><td class='popup_middle_right'> </td></tr>";
3532
3533 popup += "<tr class='popup_bottom'><td class='popup_bottom_left'></td><td class='popup_bottom_middle'></td><td class='popup_bottom_right'></td></tr>";
3534
3535 popup += "</table>";
3536
3537 $(popup).appendTo("#popup_div_curtain");
3538 }
3539 },
3540 remove : function(){
3541 $('#dio_town_popup').remove();
3542 }
3543 };
3544
3545 // Style for town icons
3546 var style_str = '<style id="dio_townicons" type="text/css">';
3547 for (var s in TownIcons.types) {
3548 if (TownIcons.types.hasOwnProperty(s)) {
3549 style_str += '.townicon_' + s + ' { background:url(' + dio_sprite + ') ' + (TownIcons.types[s] * -25) + 'px -26px repeat;float:left;} ';
3550 }
3551 }
3552 style_str += '</style>';
3553 $(style_str).appendTo('head');
3554
3555
3556 var ContextMenu = {
3557 activate: function () {
3558 // Set context menu event handler
3559 $.Observer(uw.GameEvents.map.context_menu.click).subscribe('DIO_CONTEXT', function (e, data) {
3560 if (DATA.options.con && $('#context_menu').children().length == 4) {
3561 // Clear animation
3562 $('#context_menu div#goToTown').css({
3563 left: '0px',
3564 top: '0px',
3565 WebkitAnimation: 'none', //'A 0s linear',
3566 animation: 'none' //'B 0s linear'
3567 });
3568 }
3569 // Replace german label of 'select town' button
3570 if (LID === "de" && $('#select_town').get(0)) {
3571 $("#select_town .caption").get(0).innerHTML = "Selektieren";
3572 }
3573 });
3574
3575 // Set context menu animation
3576 $('<style id="dio_context_menu" type="text/css">' +
3577 // set fixed position of 'select town' button
3578 '#select_town { left: 0px !important; top: 0px !important; z-index: 6; } ' +
3579 // set animation of 'goToTown' button
3580 '#context_menu div#goToTown { left: 30px; top: -51px; ' +
3581 '-webkit-animation: A 0.115s linear; animation: B 0.2s;} ' +
3582 '@-webkit-keyframes A { from {left: 0px; top: 0px;} to {left: 30px; top: -51px;} }' +
3583 '@keyframes B { from {left: 0px; top: 0px;} to {left: 30px; top: -51px;} }' +
3584 '</style>').appendTo('head');
3585 },
3586 deactivate: function () {
3587 $.Observer(uw.GameEvents.map.context_menu.click).unsubscribe('DIO_CONTEXT');
3588
3589 $('#dio_context_menu').remove();
3590 }
3591 };
3592
3593
3594 var TownList = {
3595 activate: function () {
3596 // Style town list
3597 $('<style id="dio_town_list" type="text/css">' +
3598 '#town_groups_list .item { text-align: left; padding-left:35px; } ' +
3599 '#town_groups_list .inner_column { border: 1px solid rgba(100, 100, 0, 0.3);margin: -2px 0px 0px 2px; } ' +
3600 '#town_groups_list .island_quest_icon { position: absolute; right: 37px; top: 3px; } ' +
3601 '#town_groups_list .island_quest_icon.hidden_icon { display:none; } ' +
3602 // Quacks Zentrier-Button verschieben
3603 '#town_groups_list .jump_town { right: 37px !important; } ' +
3604 // Population percentage
3605 '#town_groups_list .pop_percent { position: absolute; right: 7px; top:0px; font-size: 0.7em; display:block !important;} ' +
3606 '#town_groups_list .full { color: green; } ' +
3607 '#town_groups_list .threequarter { color: darkgoldenrod; } ' +
3608 '#town_groups_list .half { color: darkred; } ' +
3609 '#town_groups_list .quarter { color: red; } ' +
3610 '</style>').appendTo('head');
3611
3612
3613 // Open town list: hook to grepolis function render()
3614 var i = 0;
3615 while (uw.layout_main_controller.sub_controllers[i].name != 'town_name_area') {
3616 i++;
3617 }
3618
3619 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;
3620
3621 uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render = function () {
3622 uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render_old();
3623 TownList.change();
3624 };
3625
3626 // Town List open?
3627 if ($('#town_groups_list').get(0)) {
3628 TownList.change();
3629 }
3630 },
3631 deactivate: function () {
3632 var i = 0;
3633 while (uw.layout_main_controller.sub_controllers[i].name != 'town_name_area') {
3634 i++;
3635 }
3636
3637 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;
3638
3639 $('#dio_town_list').remove();
3640
3641 $('#town_groups_list .small_icon, #town_groups_list .pop_percent').css({display: 'none'});
3642
3643 //$.Observer(uw.GameEvents.town.town_switch).unsubscribe('DIO_SWITCH_TOWN');
3644
3645 $("#town_groups_list .town_group_town").unbind('mouseenter mouseleave');
3646 },
3647 change: function () {
3648 if (!$('#town_groups_list .icon_small').get(0) && !$('#town_groups_list .pop_percent').get(0)) {
3649 $("#town_groups_list .town_group_town").each(function () {
3650 try {
3651 var town_item = $(this), town_id = town_item.attr('name'), townicon_div, percent_div = "", percent = -1, pop_space = "full";
3652
3653 if (population[town_id]) {
3654 percent = population[town_id].percent;
3655 }
3656 if (percent < 75) {
3657 pop_space = "threequarter";
3658 }
3659 if (percent < 50) {
3660 pop_space = "half";
3661 }
3662 if (percent < 25) {
3663 pop_space = "quarter";
3664 }
3665
3666 if (!town_item.find('icon_small').length) {
3667 townicon_div = '<div class="icon_small townicon_' + (manuTownTypes[town_id] || autoTownTypes[town_id] || "no") + '"></div>';
3668 // TODO: Notlösung...
3669 if (percent != -1) {
3670 percent_div = '<div class="pop_percent ' + pop_space + '">' + percent + '%</div>';
3671 }
3672 town_item.prepend(townicon_div + percent_div);
3673 }
3674
3675 // opening context menu
3676 /*
3677 $(this).click(function(e){
3678 console.log(e);
3679 uw.Layout.contextMenu(e, 'determine', {"id": town_id,"name": uw.ITowns[town_id].getName()});
3680 });
3681 */
3682
3683 } catch (error) {
3684 errorHandling(error, "TownList.change");
3685 }
3686 });
3687
3688 }
3689
3690 // Hover Effect for Quacks Tool:
3691 $("#town_groups_list .town_group_town").hover(function () {
3692 $(this).find('.island_quest_icon').addClass("hidden_icon");
3693 }, function () {
3694 $(this).find('.island_quest_icon').removeClass("hidden_icon");
3695 });
3696
3697 // Add change town list event handler
3698 //$.Observer(uw.GameEvents.town.town_switch).subscribe('DIO_SWITCH_TOWN', function () {
3699 //TownList.change();
3700 //});
3701 }
3702 };
3703
3704 var HiddenHighlightWindow = {
3705 activate : function(){
3706 // Style town list
3707 $('<style id="dio_hidden_highlight_window" type="text/css">' +
3708 '.strategic_map_filter { display:none !important; } ' +
3709 '</style>').appendTo('head');
3710 },
3711 deactivate : function (){
3712 $('#dio_hidden_highlight_window').remove();
3713 }
3714 };
3715
3716 /*******************************************************************************************************************************
3717 * Available units
3718 * ----------------------------------------------------------------------------------------------------------------------------
3719 * | â— GetAllUnits
3720 * | â— Shows all available units
3721 * ----------------------------------------------------------------------------------------------------------------------------
3722 *******************************************************************************************************************************/
3723 var groupUnitArray = {};
3724 // TODO: split Function (getUnits, calcUnitsSum, availableUnits, countBiremes, getTownTypes)?
3725
3726 // Alter Einheitenzähler
3727 function getAllUnits() {
3728 try {
3729 var townArray = uw.ITowns.getTowns(), groupArray = uw.ITowns.townGroups.getGroupsDIO(),
3730
3731 unitArray = {
3732 "sword": 0,
3733 "archer": 0,
3734 "hoplite": 0,
3735 "chariot": 0,
3736 "godsent": 0,
3737 "rider": 0,
3738 "slinger": 0,
3739 "catapult": 0,
3740 "small_transporter": 0,
3741 "big_transporter": 0,
3742 "manticore": 0,
3743 "harpy": 0,
3744 "pegasus": 0,
3745 "cerberus": 0,
3746 "minotaur": 0,
3747 "medusa": 0,
3748 "zyklop": 0,
3749 "centaur": 0,
3750 "fury": 0,
3751 "sea_monster": 0
3752 },
3753
3754 unitArraySea = {"bireme": 0, "trireme": 0, "attack_ship": 0, "demolition_ship": 0, "colonize_ship": 0};
3755
3756 //console.debug("DIO-TOOLS | getAllUnits | GROUP ARRAY", groupArray);
3757
3758
3759 if (uw.Game.hasArtemis) {
3760 unitArray = $.extend(unitArray, {"griffin": 0, "calydonian_boar": 0});
3761 }
3762 unitArray = $.extend(unitArray, unitArraySea);
3763
3764 for (var group in groupArray) {
3765 if (groupArray.hasOwnProperty(group)) {
3766 // Clone Object "unitArray"
3767 groupUnitArray[group] = Object.create(unitArray);
3768
3769 for (var town in groupArray[group].towns) {
3770 if (groupArray[group].towns.hasOwnProperty(town)) {
3771 var type = {lo: 0, ld: 0, so: 0, sd: 0, fo: 0, fd: 0}; // Type for TownList
3772
3773 for (var unit in unitArray) {
3774 if (unitArray.hasOwnProperty(unit)) {
3775 // All Groups: Available units
3776 var tmp = parseInt(uw.ITowns.getTown(town).units()[unit], 10);
3777 groupUnitArray[group][unit] += tmp || 0;
3778 // Only for group "All"
3779 if (group == -1) {
3780 // Bireme counter // old
3781 if (unit === "bireme" && ((biriArray[townArray[town].id] || 0) < (tmp || 0))) {
3782 biriArray[townArray[town].id] = tmp;
3783 }
3784 //TownTypes
3785 if (!uw.GameData.units[unit].is_naval) {
3786 if (uw.GameData.units[unit].flying) {
3787 type.fd += ((uw.GameData.units[unit].def_hack + uw.GameData.units[unit].def_pierce + uw.GameData.units[unit].def_distance) / 3 * (tmp || 0));
3788 type.fo += (uw.GameData.units[unit].attack * (tmp || 0));
3789 } else {
3790 type.ld += ((uw.GameData.units[unit].def_hack + uw.GameData.units[unit].def_pierce + uw.GameData.units[unit].def_distance) / 3 * (tmp || 0));
3791 type.lo += (uw.GameData.units[unit].attack * (tmp || 0));
3792 }
3793 } else {
3794 type.sd += (uw.GameData.units[unit].defense * (tmp || 0));
3795 type.so += (uw.GameData.units[unit].attack * (tmp || 0));
3796 }
3797 }
3798 }
3799 }
3800 // Only for group "All"
3801 if (group == -1) {
3802 // Icon: DEF or OFF?
3803 var z = ((type.sd + type.ld + type.fd) <= (type.so + type.lo + type.fo)) ? "o" : "d",
3804 temp = 0;
3805
3806 for (var t in type) {
3807 if (type.hasOwnProperty(t)) {
3808 // Icon: Land/Sea/Fly (t[0]) + OFF/DEF (z)
3809 if (temp < type[t]) {
3810 autoTownTypes[townArray[town].id] = t[0] + z;
3811 temp = type[t];
3812 }
3813 // Icon: Troops Outside (overwrite)
3814 if (temp < 1000) {
3815 autoTownTypes[townArray[town].id] = "no";
3816 }
3817 }
3818 }
3819 // Icon: Empty Town (overwrite)
3820 var popBuilding = 0, buildVal = uw.GameData.buildings, levelArray = townArray[town].buildings().getLevels(),
3821 popMax = Math.floor(buildVal.farm.farm_factor * Math.pow(townArray[town].buildings().getBuildingLevel("farm"), buildVal.farm.farm_pow)), // Population from farm level
3822 popPlow = townArray[town].getResearches().attributes.plow ? 200 : 0,
3823 popFactor = townArray[town].getBuildings().getBuildingLevel("thermal") ? 1.1 : 1.0, // Thermal
3824 popExtra = townArray[town].getPopulationExtra();
3825
3826 for (var b in levelArray) {
3827 if (levelArray.hasOwnProperty(b)) {
3828 popBuilding += Math.round(buildVal[b].pop * Math.pow(levelArray[b], buildVal[b].pop_factor));
3829 }
3830 }
3831 population[town] = {};
3832
3833 population[town].max = popMax * popFactor + popPlow + popExtra;
3834 population[town].buildings = popBuilding;
3835 population[town].units = parseInt((population[town].max - (popBuilding + townArray[town].getAvailablePopulation()) ), 10);
3836
3837 if (population[town].units < 300) {
3838 autoTownTypes[townArray[town].id] = "po";
3839 }
3840
3841 population[town].percent = Math.round(100 / (population[town].max - popBuilding) * population[town].units);
3842 }
3843 }
3844 }
3845 }
3846 }
3847
3848 // Update Available Units
3849 AvailableUnits.updateBullseye();
3850 if (GPWindowMgr.TYPE_DIO_UNITS) {
3851 if (Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS)) {
3852 AvailableUnits.updateWindow();
3853 }
3854 }
3855 } catch (error) {
3856 errorHandling(error, "getAllUnits"); // TODO: Eventueller Fehler in Funktion
3857 }
3858 }
3859
3860 function addFunctionToITowns() {
3861 // Copy function and prevent an error
3862 uw.ITowns.townGroups.getGroupsDIO = function () {
3863 var town_groups_towns, town_groups, groups = {};
3864
3865 // #Grepolis Fix: 2.75 -> 2.76
3866 if (MM.collections) {
3867 town_groups_towns = MM.collections.TownGroupTown[0];
3868 town_groups = MM.collections.TownGroup[0];
3869 } else {
3870 town_groups_towns = MM.getCollections().TownGroupTown[0];
3871 town_groups = MM.getCollections().TownGroup[0];
3872 }
3873
3874 town_groups_towns.each(function (town_group_town) {
3875 var gid = town_group_town.getGroupId(),
3876 group = groups[gid],
3877 town_id = town_group_town.getTownId();
3878
3879 if (!group) {
3880 groups[gid] = group = {
3881 id: gid,
3882 //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
3883 towns: {}
3884 };
3885 }
3886
3887 group.towns[town_id] = {id: town_id};
3888 //groups[gid].towns[town_id]={id:town_id};
3889 });
3890 //console.log(groups);
3891 return groups;
3892 };
3893 }
3894
3895
3896 // Neuer Einheitenzähler
3897 var UnitCounter = {
3898 units : {"total":{}, "available":{}, "outer":{}, "foreign":{}},
3899
3900 count : function(){
3901 var tooltipHelper = require("helpers/units_tooltip_helper");
3902
3903 var groups = uw.ITowns.townGroups.getGroupsDIO();
3904
3905 for (var groupId in groups) {
3906 if (groups.hasOwnProperty(groupId)) {
3907
3908 UnitCounter.units.total[groupId] = {};
3909 UnitCounter.units.available[groupId] = {};
3910 UnitCounter.units.outer[groupId] = {};
3911
3912
3913 for (var townId in groups[groupId].towns) {
3914 if (groups[groupId].towns.hasOwnProperty(townId)) {
3915
3916 // Einheiten gesamt
3917 UnitCounter.units.total[groupId][townId] = ITowns.towns[townId].units();
3918
3919 // Einheiten verfügbar
3920 UnitCounter.units.available[groupId][townId] = ITowns.towns[townId].units();
3921
3922 // Einheiten außerhalb
3923 UnitCounter.units.outer[groupId][townId] = {};
3924
3925 var supports = tooltipHelper.getDataForSupportingUnitsInOtherTownFromCollection(MM.getTownAgnosticCollectionsByName("Units")[1].fragments[townId], MM.getOnlyCollectionByName("Town"));
3926
3927 for (var supportId in supports) {
3928 if (supports.hasOwnProperty(supportId)) {
3929
3930 for (var attributeId in supports[supportId].attributes) {
3931 if (supports[supportId].attributes.hasOwnProperty(attributeId)) {
3932
3933 // Attribut ist eine Einheit?
3934 if (typeof(GameData.units[attributeId]) !== "undefined" && supports[supportId].attributes[attributeId] > 0) {
3935
3936 UnitCounter.units.outer[groupId][townId][attributeId] = (UnitCounter.units.outer[groupId][townId][attributeId] || 0) + supports[supportId].attributes[attributeId];
3937
3938 UnitCounter.units.total[groupId][townId][attributeId] = (UnitCounter.units.total[groupId][townId][attributeId] || 0) + supports[supportId].attributes[attributeId];
3939 }
3940 }
3941 }
3942 }
3943 }
3944 }
3945 }
3946
3947 // Summen aller Städte berechnen
3948 UnitCounter.summarize(groupId);
3949 }
3950 }
3951
3952 return UnitCounter.units;
3953 },
3954
3955 summarize : function(groupId){
3956 var tooltipHelper = require("helpers/units_tooltip_helper");
3957
3958 UnitCounter.units.total[groupId]["all"] = {};
3959 UnitCounter.units.available[groupId]["all"] = {};
3960 UnitCounter.units.outer[groupId]["all"] = {};
3961
3962 for(var townId in UnitCounter.units.total[groupId]){
3963 if(UnitCounter.units.total[groupId].hasOwnProperty(townId) && townId !== "all"){
3964
3965 // Einheiten gesamt
3966 for(var unitId in UnitCounter.units.total[groupId][townId]){
3967 if(UnitCounter.units.total[groupId][townId].hasOwnProperty(unitId)){
3968
3969 UnitCounter.units.total[groupId]["all"][unitId] = (UnitCounter.units.total[groupId]["all"][unitId] || 0) + UnitCounter.units.total[groupId][townId][unitId];
3970 }
3971 }
3972
3973 // Einheiten verfügbar
3974 for(var unitId in UnitCounter.units.available[groupId][townId]){
3975 if(UnitCounter.units.available[groupId][townId].hasOwnProperty(unitId)){
3976
3977 UnitCounter.units.available[groupId]["all"][unitId] = (UnitCounter.units.available[groupId]["all"][unitId] || 0) + UnitCounter.units.available[groupId][townId][unitId];
3978 }
3979 }
3980
3981 // Einheiten außerhalb
3982 for(var unitId in UnitCounter.units.outer[groupId][townId]){
3983 if(UnitCounter.units.outer[groupId][townId].hasOwnProperty(unitId)){
3984
3985 UnitCounter.units.outer[groupId]["all"][unitId] = (UnitCounter.units.outer[groupId]["all"][unitId] || 0) + UnitCounter.units.outer[groupId][townId][unitId];
3986 }
3987 }
3988 }
3989 }
3990 }
3991 };
3992
3993
3994 var AvailableUnits = {
3995 activate: function () {
3996 var default_title = DM.getl10n("place", "support_overview").options.troop_count + " (" + DM.getl10n("hercules2014", "available") + ")";
3997
3998 $(".picomap_container").prepend("<div id='available_units_bullseye' class='unit_icon90x90 " + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme") + "'><div class='amount'></div></div>");
3999
4000 $('.picomap_overlayer').tooltip(getText("options", "ava")[0]);
4001
4002 // Ab version 2.115
4003 if($(".topleft_navigation_area").get(0)) {
4004
4005 $(".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>");
4006
4007 $('<style id="dio_available_units_style_addition">' +
4008 '.coords_box { top: 117px !important; } ' +
4009 '.nui_grepo_score { top: 150px !important; } ' +
4010 '.nui_left_box { top: 102px !important; } ' +
4011 '.nui_main_menu { top: 293px !important; }' +
4012 '#grcrt_mnu_list .nui_main_menu {top: 0px !important; }'+
4013 '.bull_eye_buttons, .rb_map { height:38px !important; }' +
4014
4015 '#ui_box .btn_change_colors { top: 31px !important; }' +
4016
4017 '.picomap_area { position: absolute; overflow: visible; top: 0; left: 0; width: 156px; height: 161px; z-index: 5; }' +
4018 '.picomap_area .picomap_container, .picomap_area .picomap_overlayer { position: absolute; top: 33px; left: -3px; width: 147px; height: 101px; }' +
4019 //'.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;} '+
4020 '.picomap_area .picomap_overlayer { background: url(' + dio_sprite + '); background-position: 473px 250px; width: 147px; height: 101px; z-index: 5;} ' +
4021 '</style>').appendTo('head');
4022 }
4023
4024 // Style
4025 $('<style id="dio_available_units_style">' +
4026
4027 '@-webkit-keyframes Z { 0% { opacity: 0; } 100% { opacity: 1; } } ' +
4028 '@keyframes Z { 0% { opacity: 0; } 100% { opacity: 1; } } ' +
4029
4030 '@-webkit-keyframes blurr { 0% { -webkit-filter: blur(5px); } 100% { -webkit-filter: blur(0px); } } ' +
4031
4032 '.picomap_overlayer { cursor:pointer; } ' +
4033
4034 '.picomap_area .bull_eye_buttons { height: 55px; } ' +
4035
4036 '#sea_id { background: none; font-size:25px; cursor:default; height:50px; width:50px; position:absolute; top:70px; left:157px; z-index: 30; } ' +
4037
4038 // Available bullseye unit
4039 '#available_units_bullseye { margin: 5px 28px 0px 28px; -webkit-animation: blur 2s; animation: Z 1s; } ' +
4040
4041 '#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; } ' +
4042
4043 '#available_units_bullseye.big_number { font-size: 0.90em; line-height: 1.4; } ' +
4044
4045 '#available_units_bullseye.blur { -webkit-animation: blurr 0.6s; } ' +
4046
4047
4048
4049 // Land units
4050 '#available_units_bullseye.sword .amount { color:#E2D9C1; top:57px; width:90px; } ' +
4051 '#available_units_bullseye.hoplite .amount { color:#E2D9C1; top:57px; width:90px; } ' +
4052 '#available_units_bullseye.archer .amount { color:#E2D0C1; top:47px; width:70px; } ' +
4053 '#available_units_bullseye.chariot { margin-top: 15px; } ' +
4054 '#available_units_bullseye.chariot .amount { color:#F5E8B4; top:38px; width:91px; } ' +
4055 '#available_units_bullseye.rider .amount { color:#DFCC6C; top:52px; width:105px; } ' +
4056 '#available_units_bullseye.slinger .amount { color:#F5E8B4; top:53px; width:91px; } ' +
4057 '#available_units_bullseye.catapult .amount { color:#F5F6C5; top:36px; width:87px; } ' +
4058 '#available_units_bullseye.godsent .amount { color:#F5F6C5; top:57px; width:92px; } ' +
4059
4060 // Mythic units
4061 '#available_units_bullseye.medusa .amount { color:#FBFFBB; top:50px; width:65px; } ' +
4062 '#available_units_bullseye.manticore .amount { color:#ECD181; top:50px; width:55px; } ' +
4063 '#available_units_bullseye.pegasus { margin-top: 16px; } ' +
4064 '#available_units_bullseye.pegasus .amount { color:#F7F8E3; top:36px; width:90px; } ' +
4065 '#available_units_bullseye.minotaur { margin-top: 10px; } ' +
4066 '#available_units_bullseye.minotaur .amount { color:#EAD88A; top:48px; width:78px; } ' +
4067 '#available_units_bullseye.zyklop { margin-top: 3px; } '+
4068 '#available_units_bullseye.zyklop .amount { color:#EDE0B0; top:50px; width:95px; } ' +
4069 '#available_units_bullseye.harpy { margin-top: 16px; } ' +
4070 '#available_units_bullseye.harpy .amount { color:#E7DB79; top:30px; width:78px; } ' +
4071 '#available_units_bullseye.sea_monster .amount { color:#D8EA84; top:58px; width:91px; } ' +
4072 '#available_units_bullseye.cerberus .amount { color:#EC7445; top:25px; width:101px; } ' +
4073 '#available_units_bullseye.centaur { margin-top: 15px; } ' +
4074 '#available_units_bullseye.centaur .amount { color:#ECE0A8; top:29px; width:83px; } ' +
4075 '#available_units_bullseye.fury .amount { color:#E0E0BC; top:57px; width:95px; } ' +
4076 '#available_units_bullseye.griffin { margin-top: 15px; } ' +
4077 '#available_units_bullseye.griffin .amount { color:#FFDC9D; top:40px; width:98px; } ' +
4078 '#available_units_bullseye.calydonian_boar .amount { color:#FFDC9D; top:17px; width:85px; } ' +
4079
4080 // Naval units
4081 '#available_units_bullseye.attack_ship .amount { color:#FFCB00; top:26px; width:99px; } ' +
4082 '#available_units_bullseye.bireme .amount { color:#DFC677; color:azure; top:28px; width:79px; } ' +
4083 '#available_units_bullseye.trireme .amount { color:#F4FFD4; top:24px; width:90px; } ' +
4084 '#available_units_bullseye.small_transporter .amount { color:#F5F6C5; top:26px; width:84px; } ' +
4085 '#available_units_bullseye.big_transporter .amount { color:#FFDC9D; top:27px; width:78px; } ' +
4086 '#available_units_bullseye.colonize_ship .amount { color:#F5F6C5; top:29px; width:76px; } ' +
4087 '#available_units_bullseye.colonize_ship .amount { color:#F5F6C5; top:29px; width:76px; } ' +
4088 '#available_units_bullseye.demolition_ship .amount { color:#F5F6C5; top:35px; width:90px; } ' +
4089
4090 // Available units window
4091 '#available_units { overflow: auto; } ' +
4092 '#available_units .unit { margin: 5px; cursor:pointer; overflow:visible; } ' +
4093 '#available_units .unit.active { border: 2px solid #7f653a; border-radius:30px; margin:4px; } ' +
4094 '#available_units .unit span { text-shadow: 1px 1px 1px black, 1px 1px 2px black;} ' +
4095 '#available_units hr { margin: 5px 0px 5px 0px; } ' +
4096 '#available_units .drop_box .option { float: left; margin-right: 30px; width:100%; } ' +
4097 '#available_units .drop_box { position:absolute; top: -38px; right: 83px; width:90px; z-index:10; } ' +
4098 '#available_units .drop_box .drop_group { width: 120px; } ' +
4099 '#available_units .drop_box .select_group.open { display:block; } ' +
4100 '#available_units .drop_box .item-list { overflow: auto; overflow-x: hidden; } ' +
4101 '#available_units .drop_box .arrow { width:18px; height:18px; background:url(' + drop_out.src + ') no-repeat -1px -1px; position:absolute; } ' +
4102
4103 // Available units button
4104 '#btn_available_units { top:86px; left:119px; z-index:10; position:absolute; } ' +
4105 '#btn_available_units .ico_available_units { margin:5px 0px 0px 4px; width:24px; height:24px; ' +
4106 '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); } ' +
4107
4108 '</style>').appendTo('head');
4109
4110 createWindowType("DIO_UNITS", (LANG.hasOwnProperty(LID) ? getText("options", "ava")[0] : default_title), 365, 310, true, [240, 70]);
4111
4112 // Set Sea-ID beside the bull eye
4113 $('#sea_id').prependTo('#ui_box');
4114
4115 AvailableUnits.addButton();
4116
4117 UnitCounter.count();
4118 AvailableUnits.updateBullseye();
4119 },
4120 deactivate: function () {
4121 $('#available_units_bullseye').remove();
4122 $('#available_units_bullseye_addition').remove();
4123
4124 $('#dio_available_units_style').remove();
4125 $('#dio_available_units_style_addition').remove();
4126
4127 $('#btn_available_units').remove();
4128
4129 if (Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS)) {
4130 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS).close();
4131 }
4132
4133 $('.picomap_overlayer').unbind();
4134
4135 $('#sea_id').appendTo('.picomap_container')
4136 },
4137 addButton: function () {
4138 var default_title = DM.getl10n("place", "support_overview").options.troop_count + " (" + DM.getl10n("hercules2014", "available") + ")";
4139
4140 $('<div id="btn_available_units" class="circle_button"><div class="ico_available_units js-caption"></div></div>').appendTo(".bull_eye_buttons");
4141
4142 // Events
4143 $('#btn_available_units').on('mousedown', function () {
4144 $('#btn_available_units, .ico_available_units').addClass("checked");
4145 }).on('mouseup', function () {
4146 $('#btn_available_units, .ico_available_units').removeClass("checked");
4147 });
4148
4149 $('#btn_available_units, .picomap_overlayer').click(function () {
4150 if (!Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS)) {
4151 AvailableUnits.openWindow();
4152 $('#btn_available_units, .ico_available_units').addClass("checked");
4153 } else {
4154 AvailableUnits.closeWindow();
4155 $('#btn_available_units, .ico_available_units').removeClass("checked");
4156 }
4157 });
4158
4159 // Tooltip
4160 $('#btn_available_units').tooltip(LANG.hasOwnProperty(LID) ? getText("labels", "uni") : default_title);
4161 },
4162 openWindow: function () {
4163 var groupArray = uw.ITowns.townGroups.getGroupsDIO(),
4164
4165 unitArray = {
4166 "sword": 0,
4167 "archer": 0,
4168 "hoplite": 0,
4169 "slinger": 0,
4170 "rider": 0,
4171 "chariot": 0,
4172 "catapult": 0,
4173 "godsent": 0,
4174 "manticore": 0,
4175 "harpy": 0,
4176 "pegasus": 0,
4177 "griffin": 0,
4178 "cerberus": 0,
4179 "minotaur": 0,
4180 "medusa": 0,
4181 "zyklop": 0,
4182 "centaur": 0,
4183 "calydonian_boar": 0,
4184 "fury": 0,
4185 "sea_monster": 0,
4186 "small_transporter": 0,
4187 "big_transporter": 0,
4188 "bireme": 0,
4189 "attack_ship": 0,
4190 "trireme": 0,
4191 "demolition_ship": 0,
4192 "colonize_ship": 0
4193 };
4194
4195 if (!uw.Game.hasArtemis) {
4196 delete unitArray.calydonian_boar;
4197 delete unitArray.griffin;
4198 }
4199
4200 var land_units_str = "", content =
4201 '<div id="available_units">' +
4202 // Dropdown menu
4203 '<div class="drop_box">' +
4204 '<div class="drop_group dropdown default">' +
4205 '<div class="border-left"></div><div class="border-right"></div>' +
4206 '<div class="caption" name="' + groupArray[DATA.bullseyeUnit.current_group].id + '">' + ITowns.town_groups._byId[groupArray[DATA.bullseyeUnit.current_group].id].attributes.name + '</div>' +
4207 '<div class="arrow"></div>' +
4208 '</div>' +
4209 '<div class="select_group dropdown-list default active"><div class="item-list"></div></div>' +
4210 '</div>' +
4211 '<table width="100%" class="radiobutton horizontal rbtn_visibility"><tr>'+
4212 '<td width="40%"><div class="option js-option" name="total"><div class="pointer"></div>'+ getText("labels", "total") +'</div></td>'+
4213 '<td width="40%"><div class="option js-option" name="available"><div class="pointer"></div>'+ getText("labels", "available") +'</div></td>'+
4214 '<td width="20%"><div class="option js-option" name="outer"><div class="pointer"></div>'+ getText("labels", "outer") +'</div></td>'+
4215 '</tr></table>'+
4216 '<hr>'+
4217 // Content
4218 '<div class="box_content">';
4219
4220 for (var unit in unitArray) {
4221 if (unitArray.hasOwnProperty(unit)) {
4222 land_units_str += '<div class="unit index_unit bold unit_icon40x40 ' + unit + '"></div>';
4223 if (unit == "sea_monster") {
4224 land_units_str += '<div style="clear:left;"></div>'; // break
4225 }
4226 }
4227 }
4228 content += land_units_str + '</div></div>';
4229
4230 AvailableUnits.wnd = Layout.wnd.Create(GPWindowMgr.TYPE_DIO_UNITS);
4231
4232 AvailableUnits.wnd.setContent(content);
4233
4234 if (Game.premium_features.curator <= Timestamp.now()) {
4235 $('#available_units .drop_box').css({display: 'none'});
4236 DATA.bullseyeUnit.current_group = -1;
4237 }
4238
4239 // Add groups to dropdown menu
4240 for (var group in groupArray) {
4241 if (groupArray.hasOwnProperty(group)) {
4242 var group_name = ITowns.town_groups._byId[group].attributes.name;
4243 $('<div class="option' + (group == -1 ? " sel" : "") + '" name="' + group + '">' + group_name + '</div>').appendTo('#available_units .item-list');
4244 }
4245 }
4246
4247 // Set active mode
4248 if(typeof(DATA.bullseyeUnit.mode) !== "undefined"){
4249 $('.radiobutton .option[name="'+ DATA.bullseyeUnit.mode +'"]').addClass("checked");
4250 }
4251 else{
4252 $('.radiobutton .option[name="available"]').addClass("checked");
4253 }
4254
4255 // Update
4256 AvailableUnits.updateWindow();
4257
4258 // Dropdown menu Handler
4259 $('#available_units .drop_group').click(function () {
4260 $('#available_units .select_group').toggleClass('open');
4261 });
4262 // Change group
4263 $('#available_units .select_group .option').click(function () {
4264 DATA.bullseyeUnit.current_group = $(this).attr("name");
4265 $('#available_units .select_group').removeClass('open');
4266 $('#available_units .select_group .option.sel').removeClass("sel");
4267 $(this).addClass("sel");
4268
4269 $('#available_units .drop_group .caption').attr("name", DATA.bullseyeUnit.current_group);
4270 $('#available_units .drop_group .caption').get(0).innerHTML = this.innerHTML;
4271
4272 $('#available_units .unit.active').removeClass("active");
4273 $('#available_units .unit.' + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme")).addClass("active");
4274
4275 UnitCounter.count();
4276
4277 AvailableUnits.updateWindow();
4278 AvailableUnits.updateBullseye();
4279 AvailableUnits.save();
4280 });
4281
4282 // Change mode (total, available, outer)
4283 $('.radiobutton .option').click(function(){
4284
4285 DATA.bullseyeUnit.mode = $(this).attr("name");
4286
4287 $('.radiobutton .option.checked').removeClass("checked");
4288 $(this).addClass("checked");
4289
4290 UnitCounter.count();
4291
4292 AvailableUnits.updateWindow();
4293 AvailableUnits.updateBullseye();
4294 AvailableUnits.save();
4295 });
4296
4297 // Set active bullseye unit
4298 $('#available_units .unit.' + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme")).addClass("active");
4299
4300 // Change bullseye unit
4301 $('#available_units .unit').click(function () {
4302 DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] = this.className.split(" ")[4].trim();
4303
4304 $('#available_units .unit.active').removeClass("active");
4305 $(this).addClass("active");
4306
4307 AvailableUnits.updateBullseye();
4308 AvailableUnits.save();
4309
4310 });
4311
4312 // Close button event - uncheck available units button
4313 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS).getJQCloseButton().get(0).onclick = function () {
4314 $('#btn_available_units, .ico_available_units').removeClass("checked");
4315 };
4316 },
4317 closeWindow: function () {
4318 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_UNITS).close();
4319 },
4320 save: function () {
4321 // console.debug("BULLSEYE SAVE", DATA.bullseyeUnit);
4322
4323 saveValue(WID + "_bullseyeUnit", JSON.stringify(DATA.bullseyeUnit));
4324 },
4325 updateBullseye: function () {
4326
4327 var sum = 0, str = "", fsize = ['1.4em', '1.2em', '1.15em', '1.1em', '1.0em', '0.95em'], i;
4328
4329 if ($('#available_units_bullseye').get(0)) {
4330 $('#available_units_bullseye').get(0).className = "unit_icon90x90 " + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme");
4331
4332 if (UnitCounter.units[DATA.bullseyeUnit.mode || "available"][DATA.bullseyeUnit.current_group]) {
4333 sum = UnitCounter.units[DATA.bullseyeUnit.mode || "available"][DATA.bullseyeUnit.current_group]["all"][(DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme" )] || 0;
4334 }
4335 sum = sum.toString();
4336
4337 for (i = 0; i < sum.length; i++) {
4338 str += "<span style='font-size:" + fsize[i] + "'>" + sum[i] + "</span>";
4339 }
4340 $('#available_units_bullseye .amount').get(0).innerHTML = str;
4341
4342 if (sum >= 100000) {
4343 $('#available_units_bullseye').addClass("big_number");
4344 } else {
4345 $('#available_units_bullseye').removeClass("big_number");
4346 }
4347 }
4348 },
4349 updateWindow: function () {
4350
4351 $('#available_units .box_content .unit').each(function () {
4352 var unit = this.className.split(" ")[4];
4353
4354 // TODO: Alte Variante entfernen
4355 // Alte Variante:
4356 //this.innerHTML = '<span style="font-size:0.9em">' + groupUnitArray[DATA.bullseyeUnit.current_group][unit] + '</span>';
4357
4358 // Neue Variante
4359 this.innerHTML = '<span style="font-size:0.9em">' + (UnitCounter.units[DATA.bullseyeUnit.mode || "available"][DATA.bullseyeUnit.current_group]["all"][unit] || 0) + '</span>';
4360 });
4361 }
4362 };
4363
4364 /*******************************************************************************************************************************
4365 * Comparison box
4366 * ----------------------------------------------------------------------------------------------------------------------------
4367 * | â— Compares the units of each unit type
4368 * ----------------------------------------------------------------------------------------------------------------------------
4369 *******************************************************************************************************************************/
4370 var UnitComparison = {
4371 activate: function () {
4372 //UnitComparison.addBox();
4373 UnitComparison.addButton();
4374
4375 // Create Window Type
4376 createWindowType("DIO_COMPARISON", getText("labels", "dsc"), 480, 315, true, ["center", "center", 100, 100]);
4377
4378 // Style
4379 $('<style id="dio_comparison_style"> ' +
4380
4381 // Button
4382 '#dio_comparison_button { top:51px; left:120px; z-index:10; position:absolute; } ' +
4383 '#dio_comparison_button .ico_comparison { margin:5px 0px 0px 4px; width:24px; height:24px; ' +
4384 'background:url(http://666kb.com/i/cjq6cxia4ms8mn95r.png) no-repeat 0px 0px; background-size:100%; filter:url(#Hue1); -webkit-filter:hue-rotate(60deg); } ' +
4385 '#dio_comparison_button.checked .ico_comparison { margin-top:6px; } ' +
4386
4387 // Window
4388 '#dio_comparison a { float:left; background-repeat:no-repeat; background-size:25px; line-height:2; margin-right:10px; } ' +
4389 '#dio_comparison .box_content { text-align:center; font-style:normal; } ' +
4390
4391 // Menu tabs
4392 '#dio_comparison_menu .tab_icon { left: 23px;} ' +
4393 '#dio_comparison_menu .tab_label { margin-left: 18px; } ' +
4394
4395 // Content
4396 '#dio_comparison .hidden { display:none; } ' +
4397 '#dio_comparison table { width:480px; } ' +
4398 '#dio_comparison .hack .t_hack, #dio_comparison .pierce .t_pierce, #dio_comparison .distance .t_distance, #dio_comparison .sea .t_sea { display:inline-table; } ' +
4399
4400 '#dio_comparison .box_content { background:url(http://s1.directupload.net/images/140206/8jd9d3ec.png) 94% 94% no-repeat; background-size:140px; } ' +
4401
4402 '#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%; } ' +
4403 '#dio_comparison .compare_type_icon.booty { background:url(http://s14.directupload.net/images/140404/ki4gwd7x.png); background-size:100%; } ' +
4404 '#dio_comparison .compare_type_icon.time { background:url(https://gpall.innogamescdn.com/images/game/res/time.png); background-size:100%; } ' +
4405 '#dio_comparison .compare_type_icon.favor { background:url(https://gpall.innogamescdn.com/images/game/res/favor.png); background-size:100%; } ' +
4406 '</style>').appendTo("head");
4407 },
4408 deactivate: function () {
4409 $('#dio_comparison_button').remove();
4410 $('#dio_comparison_style').remove();
4411
4412 if (Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON)) {
4413 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON).close();
4414 }
4415 },
4416 addButton: function () {
4417 $('<div id="dio_comparison_button" class="circle_button"><div class="ico_comparison js-caption"></div></div>').appendTo(".bull_eye_buttons");
4418
4419 // Events
4420 /*
4421 $('#dio_comparison_button').on('mousedown', function(){
4422 $('#dio_comparison_button').addClass("checked");
4423 }, function(){
4424 $('#dio_comparison_button').removeClass("checked");
4425 });
4426 */
4427 $('#dio_comparison_button').on('click', function () {
4428 if (!Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON)) {
4429 UnitComparison.openWindow();
4430 $('#dio_comparison_button').addClass("checked");
4431 } else {
4432 UnitComparison.closeWindow();
4433 $('#dio_comparison_button').removeClass("checked");
4434 }
4435 });
4436
4437 // Tooltip
4438 $('#dio_comparison_button').tooltip(getText("labels", "dsc"));
4439 },
4440 openWindow: function () {
4441 var content =
4442 // Title tabs
4443 '<ul id="dio_comparison_menu" class="menu_inner" style="top: -36px; right: 35px;">' +
4444 '<li><a class="submenu_link sea" href="#"><span class="left"><span class="right"><span class="middle">' +
4445 '<span class="tab_icon icon_small townicon_so"></span><span class="tab_label">' + getText("labels", "sea") + '</span>' +
4446 '</span></span></span></a></li>' +
4447 '<li><a class="submenu_link distance" href="#"><span class="left"><span class="right"><span class="middle">' +
4448 '<span class="tab_icon icon_small townicon_di"></span><span class="tab_label">' + getText("labels", "dst") + '</span>' +
4449 '</span></span></span></a></li>' +
4450 '<li><a class="submenu_link pierce" href="#"><span class="left"><span class="right"><span class="middle">' +
4451 '<span class="tab_icon icon_small townicon_sh"></span><span class="tab_label">' + getText("labels", "prc") + '</span>' +
4452 '</span></span></span></a></li>' +
4453 '<li><a class="submenu_link hack active" href="#"><span class="left"><span class="right"><span class="middle">' +
4454 '<span class="tab_icon icon_small townicon_lo"></span><span class="tab_label">' + getText("labels", "hck") + '</span>' +
4455 '</span></span></span></a></li>' +
4456 '</ul>' +
4457 // Content
4458 '<div id="dio_comparison" style="margin-bottom:5px; font-style:italic;"><div class="box_content hack"></div></div>';
4459
4460 Layout.wnd.Create(GPWindowMgr.TYPE_DIO_COMPARISON).setContent(content);
4461
4462 UnitComparison.addComparisonTable("hack");
4463 UnitComparison.addComparisonTable("pierce");
4464 UnitComparison.addComparisonTable("distance");
4465 UnitComparison.addComparisonTable("sea");
4466
4467 // Tooltips
4468 var labelArray = DM.getl10n("barracks"),
4469 labelAttack = DM.getl10n("context_menu", "titles").attack,
4470 labelDefense = DM.getl10n("place", "tabs")[0];
4471
4472 $('.tr_att').tooltip(labelAttack);
4473 $('.tr_def').tooltip(labelDefense + " (Ø)");
4474 $('.tr_def_sea').tooltip(labelDefense);
4475 $('.tr_spd').tooltip(labelArray.tooltips.speed);
4476 $('.tr_bty').tooltip(labelArray.tooltips.booty.title);
4477 $('.tr_bty_sea').tooltip(labelArray.tooltips.ship_transport.title);
4478 $('.tr_res').tooltip(labelArray.costs + " (" +
4479 labelArray.cost_details.wood + " + " +
4480 labelArray.cost_details.stone + " + " +
4481 labelArray.cost_details.iron + ")"
4482 );
4483 $('.tr_fav').tooltip(labelArray.costs + " (" + labelArray.cost_details.favor + ")");
4484 $('.tr_tim').tooltip(labelArray.cost_details.buildtime_barracks + " (s)");
4485 $('.tr_tim_sea').tooltip(labelArray.cost_details.buildtime_docks + " (s)");
4486
4487 UnitComparison.switchComparisonTables();
4488
4489 // Close button event - uncheck available units button
4490 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON).getJQCloseButton().get(0).onclick = function () {
4491 $('#dio_comparison_button').removeClass("checked");
4492 $('.ico_comparison').get(0).style.marginTop = "5px";
4493 };
4494 },
4495 closeWindow: function () {
4496 Layout.wnd.getOpenFirst(GPWindowMgr.TYPE_DIO_COMPARISON).close();
4497 },
4498 switchComparisonTables: function () {
4499 $('#dio_comparison_menu .hack, #dio_comparison_menu .pierce, #dio_comparison_menu .distance, #dio_comparison_menu .sea').click(function () {
4500 $('#dio_comparison .box_content').removeClass($('#dio_comparison .box_content').get(0).className.split(" ")[1]);
4501 //console.debug(this.className.split(" ")[1]);
4502 $('#dio_comparison .box_content').addClass(this.className.split(" ")[1]);
4503
4504 $('#dio_comparison_menu .active').removeClass("active");
4505 $(this).addClass("active");
4506 });
4507 },
4508
4509 tooltips: [], t: 0,
4510
4511 addComparisonTable: function (type) {
4512 var pos = {
4513 att: {hack: "36%", pierce: "27%", distance: "45.5%", sea: "72.5%"},
4514 def: {hack: "18%", pierce: "18%", distance: "18%", sea: "81.5%"}
4515 };
4516 var unitIMG = "https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png";
4517 var strArray = [
4518 "<td></td>",
4519 '<td><div class="compare_type_icon" style="background-position: 0% ' + pos.att[type] + ';"></div></td>',
4520 '<td><div class="compare_type_icon" style="background-position: 0% ' + pos.def[type] + ';"></div></td>',
4521 '<td><div class="compare_type_icon" style="background-position: 0% 63%;"></div></td>',
4522 (type !== "sea") ? '<td><div class="compare_type_icon booty"></div></td>' : '<td><div class="compare_type_icon" style="background-position: 0% 91%;"></div></td>',
4523 '<td><div class="compare_type_icon" style="background-position: 0% 54%;"></div></td>',
4524 '<td><div class="compare_type_icon favor"></div></td>',
4525 '<td><div class="compare_type_icon time"></div></td>'
4526 ];
4527
4528 for (var e in uw.GameData.units) {
4529 if (uw.GameData.units.hasOwnProperty(e)) {
4530 var valArray = [];
4531
4532 if (type === (uw.GameData.units[e].attack_type || "sea") && (e !== "militia")) {
4533 valArray.att = Math.round(uw.GameData.units[e].attack * 10 / uw.GameData.units[e].population) / 10;
4534 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;
4535 valArray.def = valArray.def || Math.round(uw.GameData.units[e].defense * 10 / uw.GameData.units[e].population) / 10;
4536 valArray.speed = uw.GameData.units[e].speed;
4537 valArray.booty = Math.round(((uw.GameData.units[e].booty) * 10) / uw.GameData.units[e].population) / 10;
4538 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;
4539 valArray.favor = Math.round((uw.GameData.units[e].favor * 10) / uw.GameData.units[e].population) / 10;
4540 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));
4541 valArray.time = Math.round(uw.GameData.units[e].build_time / uw.GameData.units[e].population);
4542
4543 // World without Artemis? -> grey griffin and boar
4544 valArray.heroStyle = "";
4545 valArray.heroStyleIMG = "";
4546
4547 if (!uw.Game.hasArtemis && ((e === "griffin") || (e === "calydonian_boar"))) {
4548 valArray.heroStyle = "color:black;opacity: 0.4;";
4549 valArray.heroStyleIMG = "filter: url(#GrayScale); -webkit-filter:grayscale(100%);";
4550 }
4551
4552 strArray[0] += '<td class="un' + (UnitComparison.t) + '"><span class="unit index_unit unit_icon40x40 ' + e + '" style="' + valArray.heroStyle + valArray.heroStyleIMG + '"></span></td>';
4553 strArray[1] += '<td class="bold" style="color:' + ((valArray.att > 19) ? 'green;' : ((valArray.att < 10 && valArray.att !== 0 ) ? 'red;' : 'black;')) + valArray.heroStyle + '">' + valArray.att + '</td>';
4554 strArray[2] += '<td class="bold" style="color:' + ((valArray.def > 19) ? 'green;' : ((valArray.def < 10 && valArray.def !== 0 ) ? 'red;' : 'black;')) + valArray.heroStyle + '">' + valArray.def + '</td>';
4555 strArray[3] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.speed + '</td>';
4556 strArray[4] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.booty + '</td>';
4557 strArray[5] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.res + '</td>';
4558 strArray[6] += '<td class="bold" style="color:' + ((valArray.favor > 0) ? 'rgb(0, 0, 214);' : 'black;') + valArray.heroStyle + ';">' + valArray.favor + '</td>';
4559 strArray[7] += '<td class="bold" style="' + valArray.heroStyle + '">' + valArray.time + '</td>';
4560
4561 UnitComparison.tooltips[UnitComparison.t] = uw.GameData.units[e].name;
4562 UnitComparison.t++;
4563 }
4564 }
4565 }
4566
4567 $('<table class="hidden t_' + type + '" cellpadding="1px">' +
4568 '<tr>' + strArray[0] + '</tr>' +
4569 '<tr class="tr_att">' + strArray[1] + '</tr><tr class="tr_def' + (type == "sea" ? "_sea" : "") + '">' + strArray[2] + '</tr>' +
4570 '<tr class="tr_spd">' + strArray[3] + '</tr><tr class="tr_bty' + (type == "sea" ? "_sea" : "") + '">' + strArray[4] + '</tr>' +
4571 '<tr class="tr_res">' + strArray[5] + '</tr><tr class="tr_fav">' + strArray[6] + '</tr><tr class="tr_tim' + (type == "sea" ? "_sea" : "") + '">' + strArray[7] + '</tr>' +
4572 '</table>').appendTo('#dio_comparison .box_content');
4573
4574 for (var i = 0; i <= UnitComparison.t; i++) {
4575 $('.un' + i).tooltip(UnitComparison.tooltips[i]);
4576 }
4577 }
4578 };
4579
4580 /*******************************************************************************************************************************
4581 * Reports and Messages
4582 * ----------------------------------------------------------------------------------------------------------------------------
4583 * | â— Storage of the selected filter (only in German Grepolis yet)
4584 * ----------------------------------------------------------------------------------------------------------------------------
4585 *******************************************************************************************************************************/
4586
4587 var filter = "all";
4588
4589 function saveFilter() {
4590 $('#dd_filter_type_list .item-list div').each(function () {
4591 $(this).click(function () {
4592 filter = $(this).attr("name");
4593 });
4594 });
4595 /*
4596 var i = 0;
4597 $("#report_list a").each(function () {
4598 //console.log((i++) +" = " + $(this).attr('data-reportid'));
4599 });
4600 */
4601 }
4602
4603 function loadFilter() {
4604 if ($('#dd_filter_type_list .selected').attr("name") !== filter) {
4605 $('#dd_filter_type .caption').click();
4606 $('#dd_filter_type_list .item-list div[name=' + filter + ']').click();
4607 }
4608 }
4609
4610 function removeReports() {
4611 $("#report_list li:contains('spioniert')").each(function () {
4612 //$(this).remove();
4613 });
4614 }
4615
4616 var zut = 0;
4617 var messageArray = {};
4618
4619 function filterPlayer() {
4620 if (!$('#message_filter_list').get(0)) {
4621 $('<div id="message_filter_list" style="height:300px;overflow-y:scroll; width: 790px;"></div>').appendTo('#folder_container');
4622 $("#message_list").get(0).style.display = "none";
4623 }
4624 if (zut < parseInt($('.es_last_page').get(0).value, 10) - 1) {
4625 $('.es_page_input').get(0).value = zut++;
4626 $('.jump_button').click();
4627 $("#message_list li:contains('')").each(function () {
4628 $(this).appendTo('#message_filter_list');
4629 });
4630 } else {
4631 zut = 1;
4632 }
4633 }
4634
4635
4636 /*******************************************************************************************************************************
4637 * World Wonder Ranking - Change
4638 *******************************************************************************************************************************/
4639
4640 function getWorldWonderTypes() {
4641 $.ajax({
4642 type: "GET",
4643 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 +
4644 "%7D&_=" + uw.Game.server_time,
4645 success: function (text) {
4646 try {
4647 //console.log(JSON.parse(text));
4648 temp = JSON.parse(text).json.data.world_wonders;
4649 for (var t in temp) {
4650 if (temp.hasOwnProperty(t)) {
4651 wonderTypes[temp[t].wonder_type] = temp[t].full_name;
4652 }
4653 }
4654 temp = JSON.parse(text).json.data.buildable_wonders;
4655 for (var x in temp) {
4656 if (temp.hasOwnProperty(x)) {
4657 wonderTypes[x] = temp[x].name;
4658 }
4659 }
4660 saveValue(MID + "_wonderTypes", JSON.stringify(wonderTypes));
4661 } catch (error) {
4662 errorHandling(error, "getWorldWonderTypes");
4663 }
4664 }
4665 });
4666 }
4667
4668 function getWorldWonders() {
4669 $.ajax({
4670 type: "GET",
4671 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 +
4672 "%7D&_=" + uw.Game.server_time
4673 });
4674 }
4675
4676 var WorldWonderRanking = {
4677 activate: function () {
4678 if ($('#dio_wonder_ranking').get(0)) {
4679 $('#dio_wonder_ranking').remove();
4680 }
4681 $('<style id="dio_wonder_ranking" type="text/css"> .wonder_ranking { display: none; } </style>').appendTo('head');
4682 },
4683 deactivate: function () {
4684 if ($('#dio_wonder_ranking').get(0)) {
4685 $('#dio_wonder_ranking').remove();
4686 }
4687 $('<style id="dio_wonder_ranking" type="text/css"> .wonder_ranking { display: block; } </style>').appendTo('head');
4688 },
4689 change: function (html) {
4690 if ($('#ranking_inner tr', html)[0].children.length !== 1) { // world wonders exist?
4691 try {
4692 var ranking = {}, temp_ally, temp_ally_id, temp_ally_link;
4693
4694 // Save world wonder ranking into array
4695 $('#ranking_inner tr', html).each(function () {
4696 try {
4697 if (this.children[0].innerHTML) {
4698 temp_ally = this.children[1].children[0].innerHTML; // das hier
4699
4700 temp_ally_id = this.children[1].children[0].onclick.toString();
4701 temp_ally_id = temp_ally_id.substring(temp_ally_id.indexOf(",") + 1);
4702 temp_ally_id = temp_ally_id.substring(0, temp_ally_id.indexOf(")"));
4703
4704 temp_ally_link = this.children[1].innerHTML;
4705
4706 } else {
4707 //World wonder name
4708 var wonder_name = this.children[3].children[0].innerHTML;
4709
4710 for (var w in wonderTypes) {
4711 if (wonderTypes.hasOwnProperty(w)) {
4712 if (wonder_name == wonderTypes[w]) {
4713 var level = this.children[4].innerHTML, // world wonder level
4714 ww_data = JSON.parse(atob(this.children[3].children[0].href.split("#")[1])), wonder_link;
4715 //console.log(ww_data);
4716
4717 if (!ranking.hasOwnProperty(level)) {
4718 // add wonder types
4719 ranking[level] = {
4720 colossus_of_rhodes: {},
4721 great_pyramid_of_giza: {},
4722 hanging_gardens_of_babylon: {},
4723 lighthouse_of_alexandria: {},
4724 mausoleum_of_halicarnassus: {},
4725 statue_of_zeus_at_olympia: {},
4726 temple_of_artemis_at_ephesus: {}
4727 };
4728 }
4729
4730 if (!ranking[level][w].hasOwnProperty(temp_ally_id)) {
4731 ranking[level][w][temp_ally_id] = {}; // add alliance array
4732 }
4733 // island coordinates of the world wonder:
4734 ranking[level][w][temp_ally_id].ix = ww_data.ix;
4735 ranking[level][w][temp_ally_id].iy = ww_data.iy;
4736 ranking[level][w][temp_ally_id].sea = this.children[5].innerHTML; // world wonder sea
4737
4738 wonder_link = this.children[3].innerHTML;
4739 if (temp_ally.length > 15) {
4740 temp_ally = temp_ally.substring(0, 15) + '.';
4741 }
4742 wonder_link = wonder_link.substr(0, wonder_link.indexOf(">") + 1) + temp_ally + '</a>';
4743
4744 ranking[level][w][temp_ally_id].ww_link = wonder_link;
4745
4746 // other data of the world wonder
4747 ranking[level][w][temp_ally_id].ally_link = temp_ally_link;
4748 ranking[level][w][temp_ally_id].ally_name = temp_ally; // alliance name
4749 ranking[level][w][temp_ally_id].name = wonder_name; // world wonder name
4750
4751 // Save wonder coordinates for wonder icons on map
4752 if (!wonder.map[w]) {
4753 wonder.map[w] = {};
4754 }
4755 wonder.map[w][ww_data.ix + "_" + ww_data.iy] = level;
4756 saveValue(WID + "_wonder", JSON.stringify(wonder));
4757
4758 }
4759 }
4760 }
4761 }
4762 } catch (error) {
4763 errorHandling(error, "WorldWonderRanking.change(function)");
4764 }
4765 });
4766
4767 if ($('#ranking_table_wrapper').get(0)) {
4768 $('#ranking_fixed_table_header').get(0).innerHTML = '<tr>' +
4769 '<td style="width:10px">#</td>' +
4770 '<td>Colossus</td>' +
4771 '<td>Pyramid</td>' +
4772 '<td>Garden</td>' +
4773 '<td>Lighthouse</td>' +
4774 '<td>Mausoleum</td>' +
4775 '<td>Statue</td>' +
4776 '<td>Temple</td>' +
4777 '</tr>';
4778
4779 $('#ranking_fixed_table_header').css({
4780 tableLayout: 'fixed',
4781 width: '100%',
4782 //paddingLeft: '0px',
4783 paddingRight: '15px'
4784 });
4785
4786 var ranking_substr = '', z = 0;
4787 for (var level = 10; level >= 1; level--) {
4788 if (ranking.hasOwnProperty(level)) {
4789 var complete = "";
4790 if (level == 10) {
4791 complete = "background: rgba(255, 236, 108, 0.36);";
4792 }
4793
4794 // Alternate table background color
4795 if (z === 0) {
4796 ranking_substr += '<tr class="game_table_odd" style="' + complete + '"><td style="border-right: 1px solid #d0be97;">' + level + '</td>';
4797 z = 1;
4798 } else {
4799 ranking_substr += '<tr class="game_table_even" style="' + complete + '"><td style="border-right: 1px solid #d0be97;">' + level + '</td>';
4800 z = 0;
4801 }
4802 for (var w in ranking[level]) {
4803 if (ranking[level].hasOwnProperty(w)) {
4804 ranking_substr += '<td>';
4805
4806 for (var a in ranking[level][w]) {
4807 if (ranking[level][w].hasOwnProperty(a)) {
4808 ranking_substr += '<nobr>' + ranking[level][w][a].ww_link + '</nobr><br />'; // ww link
4809 }
4810 }
4811 ranking_substr += '</td>';
4812 }
4813 }
4814 ranking_substr += '</tr>';
4815 }
4816 }
4817
4818 var ranking_str = '<table id="ranking_endless_scroll" class="game_table" cellspacing="0"><tr>' +
4819 '<td style="width:10px;border-right: 1px solid #d0be97;"></td>' +
4820 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.colossus_of_rhodes + ';margin-left:26px"></div></td>' + // Colossus
4821 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.great_pyramid_of_giza + ';margin-left:19px"></div></td>' + // Pyramid
4822 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.hanging_gardens_of_babylon + ';margin-left:19px"></div></td>' + // Garden
4823 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.lighthouse_of_alexandria + ';margin-left:24px"></div></td>' + // Lighthouse
4824 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.mausoleum_of_halicarnassus + ';margin-left:25px"></div></td>' + // Mausoleum
4825 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.statue_of_zeus_at_olympia + ';margin-left:25px"></div></td>' + // Statue
4826 '<td><div class="dio_wonder" style="background:' + worldWonderIcon.temple_of_artemis_at_ephesus + ';margin-left:22px"></div></td>' + // Temple
4827 '</tr>' + ranking_substr + '</table>';
4828
4829 $('#ranking_table_wrapper').get(0).innerHTML = ranking_str;
4830
4831 $('#ranking_endless_scroll .dio_wonder').css({
4832 width: "65px", height: "60px",
4833 backgroundSize: "auto 100%",
4834 backgroundPosition: "64px 0px"
4835 });
4836
4837 $('#ranking_endless_scroll').css({
4838 tableLayout: 'fixed',
4839 width: '100%',
4840 overflowY: 'auto',
4841 overflowX: 'hidden',
4842 fontSize: '0.7em',
4843 lineHeight: '2'
4844 });
4845 $('#ranking_endless_scroll tbody').css({
4846 verticalAlign: 'text-top'
4847 });
4848
4849 $('#ranking_table_wrapper img').css({
4850 width: "60px"
4851 });
4852 $('#ranking_table_wrapper').css({
4853 overflowY: 'scroll'
4854 });
4855 }
4856 } catch (error) {
4857 errorHandling(error, "WorldWonderRanking.change");
4858 }
4859 }
4860 if ($('.wonder_ranking').get(0)) {
4861 $('.wonder_ranking').get(0).style.display = "block";
4862 }
4863 }
4864 };
4865
4866 /*******************************************************************************************************************************
4867 * World Wonder
4868 * ----------------------------------------------------------------------------------------------------------------------------
4869 * | â— click adjustment
4870 * | â— Share calculation (= ratio of player points to alliance points)
4871 * | â— Resources calculation & counter (stores amount)
4872 * | â— Adds missing previous & next buttons on finished world wonders (better browsing through world wonders)
4873 * ----------------------------------------------------------------------------------------------------------------------------
4874 *******************************************************************************************************************************/
4875
4876 // getPointRatio: Default
4877 function getPointRatioFromAllianceProfile() {
4878 if (AID) {
4879 $.ajax({
4880 type: "GET",
4881 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 +
4882 '%2C%22nlreq_id%22%3A' + uw.Game.notification_last_requested_id + '%7D&_=' + uw.Game.server_time,
4883 success: function (text) {
4884 try {
4885 text = text.substr(text.indexOf("/li") + 14).substr(0, text.indexOf("\ "));
4886 var AP = parseInt(text, 10);
4887 wonder.ratio[AID] = 100 / AP * uw.Game.player_points;
4888 saveValue(WID + "_wonder", JSON.stringify(wonder));
4889 } catch (error) {
4890 errorHandling(error, "getPointRatioFromAllianceProfile");
4891 }
4892 }
4893 });
4894 } else {
4895 wonder.ratio[AID] = -1;
4896 saveValue(WID + "_wonder", JSON.stringify(wonder));
4897 }
4898 }
4899
4900 function getPointRatioFromAllianceRanking() {
4901 try {
4902 if (AID && $('.current_player .r_points').get(0)) {
4903 wonder.ratio[AID] = 100 / parseInt($('.current_player .r_points').get(0).innerHTML, 10) * uw.Game.player_points;
4904 saveValue(WID + "_wonder", JSON.stringify(wonder));
4905 }
4906 } catch (error) {
4907 errorHandling(error, "getPointRatioFromAllianceRaking");
4908 }
4909 }
4910
4911 function getPointRatioFromAllianceMembers() {
4912 try {
4913 var ally_points = 0;
4914 $('#ally_members_body tr').each(function () {
4915 ally_points += parseInt($(this).children().eq(2).text(), 10) || 0;
4916 });
4917 wonder.ratio[AID] = 100 / ally_points * uw.Game.player_points;
4918 saveValue(WID + "_wonder", JSON.stringify(wonder));
4919 } catch (error) {
4920 errorHandling(error, "getPointRatioFromAllianceMembers");
4921 }
4922 }
4923
4924 var WorldWonderCalculator = {
4925 activate: function () {
4926 // Style
4927 $('<style id="dio_wonder_calculator"> ' +
4928 '.wonder_controls { height:380px; } ' +
4929 '.wonder_controls .wonder_progress { margin: 0px auto 5px; } ' +
4930 '.wonder_controls .wonder_header { text-align:left; margin:10px -8px 12px 3px; }' +
4931 '.wonder_controls .build_wonder_icon { top:25px !important; }' +
4932 '.wonder_controls .wonder_progress_bar { top:54px; }' +
4933 '.wonder_controls .trade fieldset { float:right; } ' +
4934 '.wonder_controls .wonder_res_container { right:29px; } ' +
4935 '.wonder_controls .ww_ratio {position:relative; height:auto; } ' +
4936 '.wonder_controls fieldset.next_level_res { height:auto; } ' +
4937 '.wonder_controls .town-capacity-indicator { margin-top:0px; } ' +
4938
4939 '.wonder_controls .ww_ratio .progress { line-height:1; color:white; font-size:0.8em; } ' +
4940 '.wonder_controls .ww_perc { position:absolute; width:242px; text-align:center; } ' +
4941 '.wonder_controls .indicator3 { z-index:0; } ' +
4942 '.wonder_controls .indicator3.red { background-position:right -203px; height:10px; width:242px; } ' +
4943 '.wonder_controls .indicator3.green { background-position:right -355px; height:10px; width:242px; } ' +
4944 '.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; } ' +
4945 '.wonder_controls .town-capacity-indicator { margin-top:0px; } ' +
4946 '</style>').appendTo('head');
4947 },
4948 deactivate: function () {
4949 $('#dio_wonder_calculator').remove();
4950 }
4951 };
4952
4953 // TODO: Split function...
4954 function getResWW() {
4955 try {
4956 var wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_WONDERS);
4957
4958 for (var e in wndArray) {
4959 if (wndArray.hasOwnProperty(e)) {
4960 var wndID = "#gpwnd_" + wndArray[e].getID() + " ";
4961
4962 if ($(wndID + '.wonder_progress').get(0)) {
4963 var res = 0,
4964 ww_share = {total: {share: 0, sum: 0}, stage: {share: 0, sum: 0}},
4965 ww_type = $(wndID + '.finished_image_small').attr('src').split("/")[6].split("_")[0], // Which world wonder?
4966 res_stages = [2, 4, 6, 10, 16, 28, 48, 82, 140, 238], // Rohstoffmenge pro Rohstofftyp in 100.000 Einheiten
4967 stage = parseInt($(wndID + '.wonder_expansion_stage span').get(0).innerHTML.split("/")[0], 10) + 1, // Derzeitige Füllstufe
4968 speed = uw.Game.game_speed;
4969
4970 wonder.storage[AID] = wonder.storage[AID] || {};
4971
4972 wonder.storage[AID][ww_type] = wonder.storage[AID][ww_type] || {};
4973
4974 wonder.storage[AID][ww_type][stage] = wonder.storage[AID][ww_type][stage] || 0;
4975
4976 if (!$(wndID + '.ww_ratio').get(0)) {
4977 $('<fieldset class="ww_ratio"></fieldset>').appendTo(wndID + '.wonder_res_container .trade');
4978 $(wndID + '.wonder_header').prependTo(wndID + '.wonder_progress');
4979 $(wndID + '.wonder_res_container .send_res').insertBefore(wndID + '.wonder_res_container .next_level_res');
4980 }
4981
4982 for (var d in res_stages) {
4983 if (res_stages.hasOwnProperty(d)) {
4984 ww_share.total.sum += res_stages[d];
4985 }
4986 }
4987
4988 ww_share.total.sum *= speed * 300000;
4989
4990 ww_share.total.share = parseInt(wonder.ratio[AID] * (ww_share.total.sum / 100), 10);
4991
4992 ww_share.stage.sum = speed * res_stages[stage - 1] * 300000;
4993
4994 ww_share.stage.share = parseInt(wonder.ratio[AID] * (ww_share.stage.sum / 100), 10); // ( 3000 = 3 Rohstofftypen * 100000 Rohstoffe / 100 Prozent)
4995 setResWW(stage, ww_type, ww_share, wndID);
4996
4997
4998 $(wndID + '.wonder_res_container .send_resources_btn').click(function (e) {
4999 try {
5000 wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_wood input:text').get(0).value, 10);
5001 wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_stone input:text').get(0).value, 10);
5002 wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_iron input:text').get(0).value, 10);
5003
5004 setResWW(stage, ww_type, ww_share, wndID);
5005 saveValue(WID + "_wonder", JSON.stringify(wonder));
5006 } catch (error) {
5007 errorHandling(error, "getResWW_Click");
5008 }
5009 });
5010
5011 } else {
5012 $('<div class="prev_ww pos_Y"></div><div class="next_ww pos_Y"></div>').appendTo(wndID + '.wonder_controls');
5013
5014 $(wndID + '.wonder_finished').css({width: '100%'});
5015
5016 $(wndID + '.pos_Y').css({
5017 top: '-266px'
5018 });
5019 }
5020 }
5021 }
5022 } catch (error) {
5023 errorHandling(error, "getResWW");
5024 }
5025 }
5026
5027 function setResWW(stage, ww_type, ww_share, wndID) {
5028 try {
5029 var stage_width, total_width, res_total = 0, stage_color = "red", total_color = "red";
5030
5031 for (var z in wonder.storage[AID][ww_type]) {
5032 if (wonder.storage[AID][ww_type].hasOwnProperty(z)) {
5033 res_total += wonder.storage[AID][ww_type][z];
5034 }
5035 }
5036
5037 // Progressbar
5038 if (ww_share.stage.share > wonder.storage[AID][ww_type][stage]) {
5039 stage_width = (242 / ww_share.stage.share) * wonder.storage[AID][ww_type][stage];
5040 stage_color = "red";
5041 } else {
5042 stage_width = 242;
5043 stage_color = "green"
5044 }
5045 if (ww_share.total.share > res_total) {
5046 total_color = "red";
5047 total_width = (242 / ww_share.total.share) * res_total;
5048 } else {
5049 total_width = 242;
5050 total_color = "green"
5051 }
5052
5053 $(wndID + '.ww_ratio').get(0).innerHTML = "";
5054 $(wndID + '.ww_ratio').append(
5055 '<legend>' + getText("labels", "leg") + ' (<span style="color:#090">' + (Math.round(wonder.ratio[AID] * 100) / 100) + '%</span>):</legend>' +
5056 '<div class="town-capacity-indicator">' +
5057 '<div class="icon all_res"></div>' +
5058 '<div id="ww_town_capacity_stadium" class="tripple-progress-progressbar">' +
5059 '<div class="border_l"></div><div class="border_r"></div><div class="body"></div>' +
5060 '<div class="progress overloaded">' +
5061 '<div class="indicator3 ' + stage_color + '" style="width:' + stage_width + 'px"></div>' +
5062 '<span class="ww_perc">' + Math.round(wonder.storage[AID][ww_type][stage] / ww_share.stage.share * 100) + '%</span>' +
5063 '</div>' +
5064 '<div class="amounts">' + getText("labels", "stg") + ': <span class="curr">' + pointNumber(wonder.storage[AID][ww_type][stage]) + '</span> / ' +
5065 '<span class="max">' + pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) + '</span></div>' +
5066 '</div></div>' +
5067 '<div class="town-capacity-indicator">' +
5068 '<div class="icon all_res"></div>' +
5069 '<div id="ww_town_capacity_total" class="tripple-progress-progressbar">' +
5070 '<div class="border_l"></div><div class="border_r"></div><div class="body"></div>' +
5071 '<div class="progress overloaded">' +
5072 '<div class="indicator3 ' + total_color + '" style="width:' + total_width + 'px;"></div>' +
5073 '<span class="ww_perc">' + Math.round(res_total / ww_share.total.share * 100) + '%</span>' +
5074 '</div>' +
5075 '<div class="amounts">' + getText("labels", "tot") + ': <span class="curr">' + pointNumber(res_total) + '</span> / ' +
5076 '<span class="max">' + pointNumber((Math.round(ww_share.total.share / 1000) * 1000)) + '</span></div>' +
5077 '</div></div>');
5078
5079 $(wndID + '.ww_ratio').tooltip(
5080 "<table style='border-spacing:0px; text-align:right' cellpadding='5px'><tr>" +
5081 "<td align='right' style='border-right: 1px solid;border-bottom: 1px solid'></td>" +
5082 "<td style='border-right: 1px solid; border-bottom: 1px solid'><span class='bbcodes_player bold'>(" + (Math.round((wonder.ratio[AID]) * 100) / 100) + "%)</span></td>" +
5083 "<td style='border-bottom: 1px solid'><span class='bbcodes_ally bold'>(100%)</span></td></tr>" +
5084 "<tr><td class='bold' style='border-right:1px solid;text-align:center'>" + getText("labels", "stg") + " " + stage + "</td>" +
5085 "<td style='border-right: 1px solid'>" + pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) + "</td>" +
5086 "<td>" + pointNumber(Math.round(ww_share.stage.sum / 1000) * 1000) + "</td></tr>" +
5087 "<tr><td class='bold' style='border-right:1px solid;text-align:center'>" + getText("labels", "tot") + "</td>" +
5088 "<td style='border-right: 1px solid'>" + pointNumber(Math.round(ww_share.total.share / 1000) * 1000) + "</td>" +
5089 "<td>" + pointNumber(Math.round(ww_share.total.sum / 1000) * 1000) + "</td>" +
5090 "</tr></table>");
5091
5092 } catch (error) {
5093 errorHandling(error, "setResWW");
5094 }
5095 }
5096
5097 // Adds points to numbers
5098 function pointNumber(number) {
5099 var sep;
5100 if (LID === "de") {
5101 sep = ".";
5102 } else {
5103 sep = ",";
5104 }
5105
5106 number = number.toString();
5107 if (number.length > 3) {
5108 var mod = number.length % 3;
5109 var output = (mod > 0 ? (number.substring(0, mod)) : '');
5110
5111 for (var i = 0; i < Math.floor(number.length / 3); i++) {
5112 if ((mod == 0) && (i == 0)) {
5113 output += number.substring(mod + 3 * i, mod + 3 * i + 3);
5114 } else {
5115 output += sep + number.substring(mod + 3 * i, mod + 3 * i + 3);
5116 }
5117 }
5118 number = output;
5119 }
5120 return number;
5121 }
5122
5123 /*******************************************************************************************************************************
5124 * Farming Village Overview
5125 * ----------------------------------------------------------------------------------------------------------------------------
5126 * | â— Color change on possibility of city festivals
5127 * ----------------------------------------------------------------------------------------------------------------------------
5128 * *****************************************************************************************************************************/
5129
5130 function changeResColor() {
5131 var res, res_min, i = 0;
5132 $('#fto_town_list .fto_resource_count :last-child').reverseList().each(function () {
5133 if ($(this).parent().hasClass("stone")) {
5134 res_min = 18000;
5135 } else {
5136 res_min = 15000;
5137 }
5138 res = parseInt(this.innerHTML, 10);
5139 if ((res >= res_min) && !($(this).hasClass("town_storage_full"))) {
5140 this.style.color = '#0A0';
5141 }
5142 if (res < res_min) {
5143 this.style.color = '#000';
5144 }
5145 });
5146 }
5147
5148 /********************************************************************************************************************************
5149 * Conquest Info
5150 * -----------------------------------------------------------------------------------------------------------------------------
5151 * | â— Amount of supports und attacks in the conquest window
5152 * | â— Layout adjustment (for reasons of clarity)
5153 * | - TODO: conquest window of own cities
5154 * -----------------------------------------------------------------------------------------------------------------------------
5155 * ******************************************************************************************************************************/
5156
5157 function countMovements() {
5158 var sup = 0, att = 0;
5159 $('.tab_content #unit_movements .support').each(function () {
5160 sup++;
5161 });
5162 $('.tab_content #unit_movements .attack_land, .tab_content #unit_movements .attack_sea, .tab_content #unit_movements .attack_takeover').each(function () {
5163 att++;
5164 });
5165
5166 var str = "<div id='move_counter' style=''><div style='float:left;margin-right:5px;'></div>" +
5167 "<div class='movement def'></div>" +
5168 "<div class='movement' style='color:green;'> " + sup + "</div>" +
5169 "<div class='movement off'> </div>" +
5170 "<div style='color:red;'> " + att + "</div></div>" +
5171 "<hr class='move_hr'>";
5172
5173 if ($('.gpwindow_content .tab_content .bold').get(0)) {
5174 $('.gpwindow_content .tab_content .bold').append(str);
5175 } else {
5176 $('.gpwindow_content h4:eq(1)').append(str);
5177
5178 // TODO: set player link ?
5179 /*
5180 $('#unit_movements li div').each(function(){
5181
5182 //console.log(this.innerHTML);
5183 });
5184 */
5185 }
5186
5187 $('<style id="dio_conquest"> ' +
5188 '.move_hr { margin:7px 0px 0px 0px; background-color:#5F5242; height:2px; border:0px solid; } ' +
5189 // Smaller movements
5190 '#unit_movements { font-size: 0.80em; } ' +
5191 '#unit_movements .incoming { width:150px; height:45px; float:left; } ' +
5192 // Counter
5193 '#move_counter { position:relative; width:100px; margin-top:-16px; left: 40%; } ' +
5194 '#move_counter .movement { float:left; margin:0px 5px 0px 0px; height:18px; width:18px; position:relative; } ' +
5195 '#move_counter .def { background:url(https://gpall.innogamescdn.com/images/game/place/losts.png); background-position:0 -36px; } ' +
5196 '#move_counter .off { background:url(https://gpall.innogamescdn.com/images/game/place/losts.png); background-position:0 0px; }' +
5197 '</style>').appendTo("head");
5198
5199 /*
5200 $('#unit_movements div').each(function(){
5201 if($(this).attr('class') === "unit_movements_arrow"){
5202 // delete placeholder for arrow of outgoing movements (there are no outgoing movements)
5203 if(!this.style.background) { this.remove(); }
5204 } else {
5205 // realign texts
5206 $(this).css({
5207 margin: '3px',
5208 paddingLeft: '3px'
5209 });
5210 }
5211 });
5212 */
5213 }
5214
5215 /*******************************************************************************************************************************
5216 * Town window
5217 * ----------------------------------------------------------------------------------------------------------------------------
5218 * | â— TownTabHandler (trade, attack, support,...)
5219 * | â— Sent units box
5220 * | â— Short duration: Display of 30% troop speed improvement in attack/support tab
5221 * | â— Trade options:
5222 * | - Ressource marks on possibility of city festivals
5223 * | - Percentual Trade: Trade button
5224 * | - Recruiting Trade: Selection boxes (ressource ratio of unit type + share of the warehouse capacity of the target town)
5225 * ----------------------------------------------------------------------------------------------------------------------------
5226 *******************************************************************************************************************************/
5227 var arrival_interval = {};
5228 // TODO: Change both functions in MultipleWindowHandler()
5229 function TownTabHandler(action) {
5230 var wndArray, wndID, wndA;
5231 wndArray = Layout.wnd.getOpen(uw.Layout.wnd.TYPE_TOWN);
5232 //console.log(wndArray);
5233 for (var e in wndArray) {
5234 if (wndArray.hasOwnProperty(e)) {
5235 //console.log(wndArray[e].getHandler());
5236 wndA = wndArray[e].getAction();
5237 wndID = "#gpwnd_" + wndArray[e].getID() + " ";
5238 if (!$(wndID).get(0)) {
5239 wndID = "#gpwnd_" + (wndArray[e].getID() + 1) + " ";
5240 }
5241 //console.log(wndID);
5242 if (wndA === action) {
5243 switch (action) {
5244 case "trading":
5245 if ($(wndID + '#trade_tab').get(0)) {
5246 if (!$(wndID + '.rec_trade').get(0) && DATA.options.rec) {
5247 RecruitingTrade.add(wndID);
5248 }
5249 //console.log(DATA.options.per);
5250 if (!$(wndID + '.btn_trade').get(0) && DATA.options.per) {
5251 addPercentTrade(wndID, false);
5252 }
5253 }
5254 //addTradeMarks(wndID, 15, 18, 15, "red"); // town festival
5255 break;
5256 case "support":
5257 case "attack":
5258 //if(!arrival_interval[wndID]){
5259 if (DATA.options.way && !($('.js-casted-powers-viewport .unit_movement_boost').get(0) || $(wndID + '.short_duration').get(0))) {
5260 //if(arrival_interval[wndID]) console.log("add " + wndID);
5261 ShortDuration.add(wndID);
5262 }
5263 if (DATA.options.sen) {
5264 SentUnits.add(wndID, action);
5265 }
5266 //}
5267 break;
5268 case "rec_mark":
5269 //addTradeMarks(wndID, 15, 18, 15, "lime");
5270 break;
5271 }
5272 }
5273 }
5274 }
5275 }
5276
5277 function WWTradeHandler() {
5278 var wndArray, wndID, wndA;
5279 wndArray = uw.GPWindowMgr.getOpen(uw.GPWindowMgr.TYPE_WONDERS);
5280 for (var e in wndArray) {
5281 if (wndArray.hasOwnProperty(e)) {
5282 wndID = "#gpwnd_" + wndArray[e].getID() + " ";
5283 if (DATA.options.per && !($(wndID + '.btn_trade').get(0) || $(wndID + '.next_building_phase').get(0) || $(wndID + '#ww_time_progressbar').get(0))) {
5284 addPercentTrade(wndID, true);
5285 }
5286 }
5287 }
5288 }
5289
5290 /*******************************************************************************************************************************
5291 * â— Sent units box
5292 *******************************************************************************************************************************/
5293 var SentUnits = {
5294 activate: function () {
5295 $.Observer(GameEvents.command.send_unit).subscribe('DIO_SEND_UNITS', function (e, data) {
5296 for (var z in data.params) {
5297 if (data.params.hasOwnProperty(z) && (data.sending_type !== "")) {
5298 if (uw.GameData.units[z]) {
5299 sentUnitsArray[data.sending_type][z] = (sentUnitsArray[data.sending_type][z] == undefined ? 0 : sentUnitsArray[data.sending_type][z]);
5300 sentUnitsArray[data.sending_type][z] += data.params[z];
5301 }
5302 }
5303 }
5304 //SentUnits.update(data.sending_type); ????
5305 });
5306 },
5307 deactivate: function () {
5308 $.Observer(GameEvents.command.send_unit).unsubscribe('DIO_SEND_UNITS');
5309 },
5310 add: function (wndID, action) {
5311 if (!$(wndID + '.sent_units_box').get(0)) {
5312 $('<div class="game_inner_box sent_units_box ' + action + '"><div class="game_border ">' +
5313 '<div class="game_border_top"></div><div class="game_border_bottom"></div><div class="game_border_left"></div><div class="game_border_right"></div>' +
5314 '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
5315 '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
5316 '<div class="game_header bold">' +
5317 '<div class="icon_sent townicon_' + (action == "attack" ? "lo" : "ld") + '"></div><span>' + getText("labels", "lab") + ' (' + (action == "attack" ? "OFF" : "DEF") + ')</span>' +
5318 '</div>' +
5319 '<div class="troops"><div class="units_list"></div><hr style="width: 172px;border: 1px solid rgb(185, 142, 93);margin: 3px 0px 2px -1px;">' +
5320 '<div id="btn_sent_units_reset" class="button_new">' +
5321 '<div class="left"></div>' +
5322 '<div class="right"></div>' +
5323 '<div class="caption js-caption">' + getText("buttons", "res") + '<div class="effect js-effect"></div></div>' +
5324 '</div>' +
5325 '</div></div>').appendTo(wndID + '.attack_support_window');
5326
5327 SentUnits.update(action);
5328
5329 $(wndID + '.icon_sent').css({
5330 height: '20px',
5331 marginTop: '-2px',
5332 width: '20px',
5333 backgroundPositionY: '-26px',
5334 paddingLeft: '0px',
5335 marginLeft: '0px'
5336 });
5337
5338 $(wndID + '.sent_units_box').css({
5339 position: 'absolute',
5340 right: '0px',
5341 bottom: '16px',
5342 width: '192px'
5343 });
5344 $(wndID + '.troops').css({padding: '6px 0px 6px 6px'});
5345
5346 $(wndID + '#btn_sent_units_reset').click(function () {
5347 // Overwrite old array
5348 sentUnitsArray[action] = {};
5349
5350 SentUnits.update(action);
5351 });
5352 }
5353 },
5354 update: function (action) {
5355 try {
5356 // Remove old unit list
5357 $('.sent_units_box.' + action + ' .units_list').each(function () {
5358 this.innerHTML = "";
5359 });
5360 // Add new unit list
5361 for (var x in sentUnitsArray[action]) {
5362 if (sentUnitsArray[action].hasOwnProperty(x)) {
5363 if ((sentUnitsArray[action][x] || 0) > 0) {
5364 $('.sent_units_box.' + action + ' .units_list').each(function () {
5365 $(this).append('<div class="unit_icon25x25 ' + x +
5366 (sentUnitsArray[action][x] >= 1000 ? (sentUnitsArray[action][x] >= 10000 ? " five_digit_number" : " four_digit_number") : "") + '">' +
5367 '<span class="count text_shadow">' + sentUnitsArray[action][x] + '</span>' +
5368 '</div>');
5369 });
5370 }
5371 }
5372 }
5373 saveValue(WID + "_sentUnits", JSON.stringify(sentUnitsArray));
5374 } catch (error) {
5375 errorHandling(error, "updateSentUnitsBox");
5376 }
5377 }
5378 };
5379
5380 /*******************************************************************************************************************************
5381 * â— Short duration
5382 *******************************************************************************************************************************/
5383
5384 // TODO: Calculator implementieren
5385 var DurationCalculator = {
5386 activate: function () {
5387 var speedBoosterSprite = "https://diotools.de/images/game/speed_booster.png";
5388
5389 $('<style id="dio_duration_calculator_style">' +
5390 '.dio_speed_booster { border:1px solid #724B08; border-spacing: 0px;} ' +
5391 '.dio_speed_booster td { border:0; padding:2px; } ' +
5392 '.dio_speed_booster .checkbox_new { margin: 4px 0px 1px 3px; } ' +
5393 '.dio_speed_booster .odd { background: url("https://gpall.innogamescdn.com/images/game/border/brown.png") repeat scroll 0% 0% transparent; } ' +
5394 '.dio_speed_booster .even { background: url("https://gpall.innogamescdn.com/images/game/border/odd.png") repeat scroll 0% 0% transparent; } ' +
5395 '.booster_icon { width:20px; height:20px; background-image:url(' + speedBoosterSprite + ');} ' +
5396 '.booster_icon.improved_speed { background-position:0 0; } ' +
5397 '.booster_icon.cartography { background-position:-20px 0; } ' +
5398 '.booster_icon.meteorology { background-position:-40px 0; } ' +
5399 '.booster_icon.lighthouse { background-position:-60px 0; } ' +
5400 '.booster_icon.set_sail { background-position:-80px 0; } ' +
5401 '.booster_icon.atalanta { background-position:-100px 0; } ' +
5402 '</style>').appendTo('head');
5403
5404 $('<table class="dio_speed_booster"><tr>' +
5405 '<td class="odd"><div class="booster_icon improved_speed"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5406 '<td class="even"><div class="booster_icon cartography"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5407 '<td class="odd"><div class="booster_icon meteorology"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5408 '<td class="even"><div class="booster_icon lighthouse"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5409 '<td class="odd"><div class="booster_icon set_sail"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5410 '<td class="even"><div class="booster_icon atalanta"></div><div class="checkbox_new checked"><div class="cbx_icon"></div></div></td>' +
5411 '</tr></table>').appendTo(wndID + ".duration_container");
5412 },
5413 deactivate: function () {
5414 $('#dio_duration_calculator_style').remove();
5415 },
5416 add: function (wndID, data) {
5417
5418 }
5419 };
5420
5421
5422 var ShortDuration = {
5423 activate: function () {
5424
5425 $('<style id="dio_short_duration_style">' +
5426 '.attack_support_window .tab_type_support .duration_container { top:0px !important; } ' +
5427 //'.attack_support_window .tab_type_attack .duration_container { width:auto; top:10px; } ' +
5428
5429 '.attack_support_window .dio_duration { border-spacing:0px; margin-bottom:2px; text-align:right; } ' +
5430
5431 '.attack_support_window .way_duration, '+
5432 '.attack_support_window .arrival_time { padding:0px 0px 0px 0px; background:none; } ' +
5433
5434 '.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; } ' +
5435 '.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; } ' +
5436 '.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); } ' +
5437
5438 '.attack_support_window .max_booty { padding:0px 0px 0px 30px; margin:3px 4px 4px 4px; width:auto; } ' +
5439 '.attack_support_window .fight_bonus.morale { margin-top:2px; } ' +
5440
5441 '.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; } ' +
5442 '.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; } ' +
5443
5444 '</style>').appendTo('head');
5445
5446 },
5447 deactivate: function () {
5448 $("#dio_short_duration_style").remove();
5449 },
5450 add: function (wndID) {
5451 //console.log($(wndID + ".duration_container").get(0));
5452 try {
5453 var tooltip = (LANG.hasOwnProperty(LID) ? getText("labels", "improved_movement") : "") + " (+30% " + DM.getl10n("barracks", "tooltips").speed.trim() + ")";
5454
5455 $('<table class="dio_duration">' +
5456 '<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>' +
5457 '<tr class="short_duration_row" style="color:darkgreen">' +
5458 '<td> ╚> </td><td><span class="short_duration">~0:00:00</span></td>' +
5459 '<td> ╚></td><td><span class="short_arrival">~00:00:00</span></td>' +
5460 '<td class="short_icon"></td><td></td></tr>' +
5461 '</table>').prependTo(wndID + ".duration_container");
5462
5463
5464
5465 $(wndID + ".nightbonus").appendTo(wndID + ".dio_night");
5466 $(wndID + '.way_duration').appendTo(wndID + ".dio_way");
5467 $(wndID + ".arrival_time").appendTo(wndID + ".dio_arrival");
5468
5469
5470 // Tooltip
5471 $(wndID + '.short_duration_row').tooltip(tooltip);
5472
5473 // Detection of changes
5474 ShortDuration.change(wndID);
5475 // $(wndID + '.way_duration').bind('DOMSubtreeModified', function(e) { console.log(e); }); // Alternative
5476
5477 } catch (error) {
5478 errorHandling(error, "addShortDuration");
5479 }
5480 },
5481 change: function (wndID) {
5482 var duration = new MutationObserver(function (mutations) {
5483 mutations.forEach(function (mutation) {
5484 if (mutation.addedNodes[0]) {
5485 //console.debug(mutation);
5486 ShortDuration.calculate(wndID);
5487 }
5488 });
5489 });
5490 if ($(wndID + '.way_duration').get(0)) {
5491 duration.observe($(wndID + '.way_duration').get(0), {
5492 attributes: false,
5493 childList: true,
5494 characterData: false
5495 });
5496 }
5497 },
5498 //$('<style> .duration_container { display: block !important } </style>').appendTo("head");
5499 calculate: function (wndID) {
5500 //console.log(wndID);
5501 //console.log($(wndID + '.duration_container .way_duration').get(0));
5502 try {
5503 var setup_time = 900 / Game.game_speed,
5504 duration_time = $(wndID + '.duration_container .way_duration').get(0).innerHTML.replace("~", "").split(":"),
5505 // TODO: hier tritt manchmal Fehler auf TypeError: Cannot read property "innerHTML" of undefined at calcShortDuration (<anonymous>:3073:86)
5506 arrival_time,
5507 h, m, s,
5508 atalanta_factor = 0;
5509
5510 var hasCartography = ITowns.getTown(Game.townId).getResearches().get("cartography");
5511 var hasMeteorology = ITowns.getTown(Game.townId).getResearches().get("meteorology");
5512 var hasSetSail = ITowns.getTown(Game.townId).getResearches().get("set_sail");
5513
5514 var hasLighthouse = ITowns.getTown(Game.townId).buildings().get("lighthouse");
5515
5516 // Atalanta aktiviert?
5517 if ($(wndID + '.unit_container.heroes_pickup .atalanta').get(0)) {
5518 if ($(wndID + '.cbx_include_hero').hasClass("checked")) {
5519 // Beschleunigung hängt vom Level ab, Level 1 = 11%, Level 20 = 30%
5520 var atalanta_level = MM.getCollections().PlayerHero[0].models[1].get("level");
5521
5522 atalanta_factor = (atalanta_level + 10) / 100;
5523 }
5524 }
5525
5526 // Sekunden, Minuten und Stunden zusammenrechnen (-> in Sekunden)
5527 duration_time = ((parseInt(duration_time[0], 10) * 60 + parseInt(duration_time[1], 10)) * 60 + parseInt(duration_time[2], 10));
5528
5529 // Verkürzte Laufzeit berechnen
5530 duration_time = ((duration_time - setup_time) * (1 + atalanta_factor)) / (1 + 0.3 + atalanta_factor) + setup_time;
5531
5532
5533 h = Math.floor(duration_time / 3600);
5534 m = Math.floor((duration_time - h * 3600) / 60);
5535 s = Math.floor(duration_time - h * 3600 - m * 60);
5536
5537 if (m < 10) {
5538 m = "0" + m;
5539 }
5540 if (s < 10) {
5541 s = "0" + s;
5542 }
5543
5544 $(wndID + '.short_duration').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
5545
5546 // Ankunftszeit errechnen
5547 arrival_time = Math.round((Timestamp.server() + Game.server_gmt_offset)) + duration_time;
5548
5549 h = Math.floor(arrival_time / 3600);
5550 m = Math.floor((arrival_time - h * 3600) / 60);
5551 s = Math.floor(arrival_time - h * 3600 - m * 60);
5552
5553 h %= 24;
5554
5555 if (m < 10) {
5556 m = "0" + m;
5557 }
5558 if (s < 10) {
5559 s = "0" + s;
5560 }
5561
5562 $(wndID + '.short_arrival').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
5563
5564 clearInterval(arrival_interval[wndID]);
5565
5566 arrival_interval[wndID] = setInterval(function () {
5567 arrival_time += 1;
5568
5569 h = Math.floor(arrival_time / 3600);
5570 m = Math.floor((arrival_time - h * 3600) / 60);
5571 s = Math.floor(arrival_time - h * 3600 - m * 60);
5572
5573 h %= 24;
5574
5575 if (m < 10) {
5576 m = "0" + m;
5577 }
5578 if (s < 10) {
5579 s = "0" + s;
5580 }
5581
5582 if ($(wndID + '.short_arrival').get(0)) {
5583 $(wndID + '.short_arrival').get(0).innerHTML = "~" + h + ":" + m + ":" + s;
5584 } else {
5585 clearInterval(arrival_interval[wndID]);
5586 }
5587 }, 1000);
5588
5589 } catch (error) {
5590 errorHandling(error, "ShortDuration.calculate");
5591 }
5592 }
5593 };
5594
5595 /*******************************************************************************************************************************
5596 * â— Dropdown menu
5597 *******************************************************************************************************************************/
5598
5599 // TODO: Umstellen!
5600 // Preload images for drop down arrow buttons
5601 var drop_over = new Image();
5602 drop_over.src = "http://s7.directupload.net/images/140107/hna95u8a.png";
5603 var drop_out = new Image();
5604 drop_out.src = "http://s14.directupload.net/images/140107/ppsz5mxk.png";
5605
5606 function changeDropDownButton() {
5607 $('<style id="dio_style_arrow" type="text/css">' +
5608 '#dd_filter_type .arrow, .select_rec_unit .arrow {' +
5609 'width: 18px !important; height: 17px !important; background: url("http://s14.directupload.net/images/140107/ppsz5mxk.png") no-repeat 0px -1px !important;' +
5610 'position: absolute; top: 2px !important; right: 3px; } ' +
5611 '</style>').appendTo('head');
5612
5613 }
5614
5615 /*******************************************************************************************************************************
5616 * â— Recruiting Trade
5617 * *****************************************************************************************************************************/
5618 var trade_count = 0, unit = "FS", percent = "0.0"; // Recruiting Trade
5619
5620 // TODO: Funktion umformen, Style anpassen!
5621 var RecruitingTrade = {
5622 activate: function () {
5623 $('<style id="dio_style_recruiting_trade" type="text/css">' +
5624 '#dio_recruiting_trade .option_s { filter:grayscale(100%); -webkit-filter:grayscale(100%); margin:0px; cursor:pointer; } ' +
5625 '#dio_recruiting_trade .option_s:hover { filter:unset !important; -webkit-filter:unset !important; } ' +
5626 '#dio_recruiting_trade .select_rec_unit .sel { filter:sepia(100%); -webkit-filter:sepia(100%); } ' +
5627
5628 '#dio_recruiting_trade .option {color:#000; background:#FFEEC7; } ' +
5629 '#dio_recruiting_trade .option:hover {color:#fff; background:#328BF1; } ' +
5630
5631 '#dio_recruiting_trade { position:absolute; left:30px; top:70px; } ' +
5632 '#dio_recruiting_trade .select_rec_unit { position:absolute; top:20px; width:84px; display:none; } ' +
5633 '#dio_recruiting_trade .select_rec_perc { position:absolute; top:20px; width:50px; display:none; left:50px; } ' +
5634
5635 '#dio_recruiting_trade .open { display:block !important; } '+
5636
5637 '#dio_recruiting_trade .item-list { max-height:unset; } ' +
5638
5639 '#dio_recruiting_trade .arrow { width:18px; height:18px; background:url(' + drop_out.src + ') no-repeat -1px -1px; position:absolute; } ' +
5640
5641 '#trade_tab .content { height:320px; } ' +
5642
5643 '#dio_recruiting_trade .rec_count { position:absolute; top:25px; } ' +
5644
5645 '#dio_recruiting_trade .drop_rec_unit { position:absolute; display:block; width:50px; overflow:visible; } ' +
5646 '#dio_recruiting_trade .drop_rec_perc { position:absolute; display:block; width:55px; left:49px; color:#000; } ' +
5647
5648 '</style>').appendTo('head');
5649 },
5650 deactivate: function () {
5651 $('#dio_style_recruiting_trade').remove();
5652 },
5653 add: function (wndID) {
5654 var max_amount;
5655
5656 $('<div id="dio_recruiting_trade" class="rec_trade">' +
5657 // DropDown-Button for unit
5658 '<div class="drop_rec_unit dropdown default">' +
5659 '<div class="border-left"></div>' +
5660 '<div class="border-right"></div>' +
5661 '<div class="caption" name="' + unit + '">' + unit + '</div>' +
5662 '<div class="arrow"></div>' +
5663 '</div>' +
5664 '<div class="drop_rec_perc dropdown default">' +
5665 // DropDown-Button for ratio
5666 '<div class="border-left"></div>' +
5667 '<div class="border-right"></div>' +
5668 '<div class="caption" name="' + percent + '">' + Math.round(percent * 100) + '%</div>' +
5669 '<div class="arrow"></div>' +
5670 '</div><span class="rec_count">(' + trade_count + ')</span></div>').appendTo(wndID + ".content");
5671
5672 // Select boxes for unit and ratio
5673 $('<div class="select_rec_unit dropdown-list default active">' +
5674 '<div class="item-list">' +
5675 '<div class="option_s unit index_unit unit_icon40x40 attack_ship" name="FS"></div>' +
5676 '<div class="option_s unit index_unit unit_icon40x40 bireme" name="BI"></div>' +
5677 '<div class="option_s unit index_unit unit_icon40x40 sword" name="SK"></div>' +
5678 '<div class="option_s unit index_unit unit_icon40x40 slinger" name="SL"></div>' +
5679 '<div class="option_s unit index_unit unit_icon40x40 archer" name="BS"></div>' +
5680 '<div class="option_s unit index_unit unit_icon40x40 hoplite" name="HO"></div>' +
5681 '<div class="option_s unit index_unit unit_icon40x40 rider" name="RE"></div>' +
5682 '<div class="option_s unit index_unit unit_icon40x40 chariot" name="SW"></div>' +
5683 '</div></div>').appendTo(wndID + ".rec_trade");
5684 $('<div class="select_rec_perc dropdown-list default inactive">' +
5685 '<div class="item-list">' +
5686 '<div class="option sel" name="0.0"> 0%</div>' +
5687 '<div class="option" name="0.05"> 5%</div>' +
5688 '<div class="option" name="0.1">10%</div>' +
5689 '<div class="option" name="0.16666">17%</div>' +
5690 '<div class="option" name="0.2">20%</div>' +
5691 '<div class="option" name="0.25">25%</div>' +
5692 '<div class="option" name="0.33">33%</div>' +
5693 '<div class="option" name="0.5">50%</div>' +
5694 '</div></div>').appendTo(wndID + ".rec_trade");
5695
5696 $(wndID + ".rec_trade [name='" + unit + "']").toggleClass("sel");
5697
5698 // click events of the drop menu
5699 $(wndID + ' .select_rec_unit .option_s').each(function () {
5700 $(this).click(function (e) {
5701 $(".select_rec_unit .sel").toggleClass("sel");
5702 $("." + this.className.split(" ")[4]).toggleClass("sel");
5703
5704 unit = $(this).attr("name");
5705 $('.drop_rec_unit .caption').attr("name", unit);
5706 $('.drop_rec_unit .caption').each(function () {
5707 this.innerHTML = unit;
5708 });
5709 $($(this).parent().parent().get(0)).removeClass("open");
5710 $('.drop_rec_unit .caption').change();
5711 });
5712 });
5713 $(wndID + ' .select_rec_perc .option').each(function () {
5714 $(this).click(function (e) {
5715 $(this).parent().find(".sel").toggleClass("sel");
5716 $(this).toggleClass("sel");
5717
5718 percent = $(this).attr("name");
5719 $('.drop_rec_perc .caption').attr("name", percent);
5720 $('.drop_rec_perc .caption').each(function () {
5721 this.innerHTML = Math.round(percent * 100) + "%";
5722 });
5723 $($(this).parent().parent().get(0)).removeClass("open")
5724 $('.drop_rec_perc .caption').change();
5725 });
5726 });
5727
5728 // show & hide drop menus on click
5729 $(wndID + '.drop_rec_perc').click(function (e) {
5730
5731 if (!$($(e.target)[0].parentNode.parentNode.childNodes[4]).hasClass("open")) {
5732 $($(e.target)[0].parentNode.parentNode.childNodes[4]).addClass("open");
5733 $($(e.target)[0].parentNode.parentNode.childNodes[3]).removeClass("open");
5734 } else {
5735 $($(e.target)[0].parentNode.parentNode.childNodes[4]).removeClass("open");
5736 }
5737 });
5738 $(wndID + '.drop_rec_unit').click(function (e) {
5739
5740 if (!$($(e.target)[0].parentNode.parentNode.childNodes[3]).hasClass("open")) {
5741 $($(e.target)[0].parentNode.parentNode.childNodes[3]).addClass("open");
5742 $($(e.target)[0].parentNode.parentNode.childNodes[4]).removeClass("open");
5743 } else {
5744 $($(e.target)[0].parentNode.parentNode.childNodes[3]).removeClass("open");
5745 }
5746 });
5747
5748 $(wndID).click(function (e) {
5749 var clicked = $(e.target), element = $('#' + this.id + ' .dropdown-list.open').get(0);
5750 if ((clicked[0].parentNode.className.split(" ")[1] !== "dropdown") && element) {
5751 $(element).removeClass("open");
5752 }
5753 });
5754
5755 // hover arrow change
5756 $(wndID + '.dropdown').hover(function (e) {
5757 $(e.target)[0].parentNode.childNodes[3].style.background = "url('" + drop_over.src + "') no-repeat -1px -1px";
5758 }, function (e) {
5759 $(e.target)[0].parentNode.childNodes[3].style.background = "url('" + drop_out.src + "') no-repeat -1px -1px";
5760 });
5761
5762 $(wndID + ".drop_rec_unit .caption").attr("name", unit);
5763 $(wndID + ".drop_rec_perc .caption").attr("name", percent);
5764
5765 $(wndID + '.drop_rec_unit').tooltip(getText("labels", "rat"));
5766 $(wndID + '.drop_rec_perc').tooltip(getText("labels", "shr"));
5767
5768 var ratio = {
5769 NO: {w: 0, s: 0, i: 0},
5770 FS: {w: 1, s: 0.2308, i: 0.6154},
5771 BI: {w: 1, s: 0.8750, i: 0.2250},
5772 SL: {w: 0.55, s: 1, i: 0.4},
5773 RE: {w: 0.6666, s: 0.3333, i: 1},
5774 SK: {w: 1, s: 0, i: 0.8947},
5775 HO: {w: 0, s: 0.5, i: 1},
5776 BS: {w: 1, s: 0, i: 0.6250},
5777 SW: {w: 0.4545, s: 1, i: 0.7273}
5778 };
5779
5780
5781 if ($('#town_capacity_wood .max').get(0)) {
5782 max_amount = parseInt($('#town_capacity_wood .max').get(0).innerHTML, 10);
5783 } else {
5784 max_amount = 25500;
5785 }
5786
5787 $(wndID + '.caption').change(function (e) {
5788 //console.log($(this).attr('name') + ", " + unit + "; " + percent);
5789 if (!(($(this).attr('name') === unit) || ($(this).attr('name') === percent))) {
5790 //trade_count = 0;
5791 $('.rec_count').get(0).innerHTML = "(" + trade_count + ")";
5792 }
5793
5794 var tmp = $(this).attr('name');
5795
5796 if ($(this).parent().attr('class').split(" ")[0] === "drop_rec_unit") {
5797 unit = tmp;
5798 } else {
5799 percent = tmp;
5800 }
5801 var max = (max_amount - 100) / 1000;
5802 addTradeMarks(max * ratio[unit].w, max * ratio[unit].s, max * ratio[unit].i, "lime");
5803
5804 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)
5805 var rArray = uw.ITowns.getTown(uw.Game.townId).getCurrentResources();
5806 var tradeCapacity = uw.ITowns.getTown(uw.Game.townId).getAvailableTradeCapacity();
5807
5808 var wood = ratio[unit].w * part;
5809 var stone = ratio[unit].s * part;
5810 var iron = ratio[unit].i * part;
5811
5812 if ((wood > rArray.wood) || (stone > rArray.stone) || (iron > rArray.iron) || ( (wood + stone + iron) > tradeCapacity)) {
5813 wood = stone = iron = 0;
5814 $('.drop_rec_perc .caption').css({color: '#f00'});
5815 //$('.' + e.target.parentNode.parentNode.className + ' .select_rec_perc .sel').css({color:'#f00'});
5816 //$('.select_rec_perc .sel').css({color:'#f00'});
5817 } else {
5818 $('.' + e.target.parentNode.parentNode.className + ' .drop_rec_perc .caption').css({color: '#000'});
5819 }
5820 $("#trade_type_wood [type='text']").select().val(wood).blur();
5821 $("#trade_type_stone [type='text']").select().val(stone).blur();
5822 $("#trade_type_iron [type='text']").select().val(iron).blur();
5823 });
5824
5825 $('#trade_button').click(function () {
5826 trade_count++;
5827 $('.rec_count').get(0).innerHTML = "(" + trade_count + ")";
5828
5829 });
5830
5831 $(wndID + '.drop_rec_perc .caption').change();
5832 }
5833 };
5834
5835 /*******************************************************************************************************************************
5836 * â— Ressources marks
5837 *******************************************************************************************************************************/
5838 function addTradeMarks(woodmark, stonemark, ironmark, color) {
5839 var max_amount, limit, wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_TOWN), wndID;
5840 for (var e in wndArray) {
5841 if (wndArray.hasOwnProperty(e)) {
5842 wndID = "#gpwnd_" + wndArray[e].getID() + " ";
5843 if ($(wndID + '.town-capacity-indicator').get(0)) {
5844
5845 max_amount = $(wndID + '.amounts .max').get(0).innerHTML;
5846
5847 $('#trade_tab .c_' + color).each(function () {
5848 this.remove();
5849 });
5850 $('#trade_tab .progress').each(function () {
5851 if ($("p", this).length < 3) {
5852 if ($(this).parent().get(0).id != "big_progressbar") {
5853 limit = 1000 * (242 / parseInt(max_amount, 10));
5854
5855 switch ($(this).parent().get(0).id.split("_")[2]) {
5856 case "wood":
5857 limit = limit * woodmark;
5858 break;
5859 case "stone":
5860 limit = limit * stonemark;
5861 break;
5862 case "iron":
5863 limit = limit * ironmark;
5864 break;
5865 }
5866 $('<p class="c_' + color + '"style="position:absolute;left: ' + limit + 'px; background:' + color + ';width:2px;height:100%;margin:0px"></p>').appendTo(this);
5867 }
5868 }
5869 });
5870 }
5871 }
5872 }
5873 }
5874
5875 /*******************************************************************************************************************************
5876 * â— Percentual Trade
5877 *******************************************************************************************************************************/
5878 var rest_count = 0;
5879
5880 function addPercentTrade(wndID, ww) {
5881
5882 var a = "";
5883 var content = wndID + ".content";
5884 if (ww) {
5885 a = "ww_";
5886 content = wndID + '.trade .send_res';
5887 }
5888 $('<div class="btn btn_trade"><a class="button" href="#">' +
5889 '<span class="left"><span class="right">' +
5890 '<span class="middle mid">' +
5891 '<span class="img_trade"></span></span></span></span>' +
5892 '<span style="clear:both;"></span>' +
5893 '</a></div>').prependTo(content);
5894
5895 $(wndID + '.btn_trade').tooltip(getText("labels", "per"));
5896
5897 setPercentTrade(wndID, ww);
5898
5899 // Style
5900 $(wndID + '.btn').css({width: '20px', overflow: 'visible', position: 'absolute', display: 'block'});
5901
5902 if (!ww) {
5903 $(wndID + '.content').css({height: '320px'});
5904 }
5905
5906 if (ww) {
5907 $(wndID + '.btn_trade').css({left: '678px', top: '154px'});
5908 } else {
5909 $(wndID + '.btn_trade').css({left: '336px', top: '135px'});
5910 }
5911
5912 $(wndID + '.mid').css({minWidth: '26px'});
5913
5914 $(wndID + '.img_trade').css({
5915 width: '27px',
5916 height: '27px',
5917 top: '-3px',
5918 float: 'left',
5919 position: 'relative',
5920 background: 'url("http://666kb.com/i/cjq6d72qk521ig1zz.png") no-repeat'
5921 });
5922
5923 }
5924
5925 var res = {};
5926
5927 function setPercentTrade(wndID, ww) {
5928 var a = ww ? "ww_" : "", own_town = $(wndID + '.town_info').get(0) ? true : false;
5929
5930 $(wndID + '.btn_trade').toggleClick(function () {
5931 res.wood = {};
5932 res.stone = {};
5933 res.iron = {};
5934 res.sum = {};
5935
5936 res.sum.amount = 0;
5937 // Set amount of resources to 0
5938 setAmount(true, a, wndID);
5939 // Total amount of resources // TODO: ITowns.getTown(Game.townId).getCurrentResources(); ?
5940 for (var e in res) {
5941 if (res.hasOwnProperty(e) && e != "sum") {
5942 res[e].rest = false;
5943 res[e].amount = parseInt($('.ui_resources_bar .' + e + ' .amount').get(0).innerHTML, 10);
5944 res.sum.amount += res[e].amount;
5945 }
5946 }
5947 // Percentage of total resources
5948 res.wood.percent = 100 / res.sum.amount * res.wood.amount;
5949 res.stone.percent = 100 / res.sum.amount * res.stone.amount;
5950 res.iron.percent = 100 / res.sum.amount * res.iron.amount;
5951
5952 // Total trading capacity
5953 res.sum.cur = parseInt($(wndID + '#' + a + 'big_progressbar .caption .curr').get(0).innerHTML, 10);
5954
5955 // Amount of resources on the percentage of trading capacity (%)
5956 res.wood.part = parseInt(res.sum.cur / 100 * res.wood.percent, 10);
5957 res.stone.part = parseInt(res.sum.cur / 100 * res.stone.percent, 10);
5958 res.iron.part = parseInt(res.sum.cur / 100 * res.iron.percent, 10);
5959
5960 // Get rest warehouse capacity of each resource type
5961 for (var f in res) {
5962 if (res.hasOwnProperty(f) && f != "sum") {
5963 if (!ww && own_town) { // Own town
5964 var curr = parseInt($(wndID + '#town_capacity_' + f + ' .amounts .curr').get(0).innerHTML.replace('+', '').trim(), 10) || 0,
5965 curr2 = parseInt($(wndID + '#town_capacity_' + f + ' .amounts .curr2').get(0).innerHTML.replace('+', '').trim(), 10) || 0,
5966 max = parseInt($(wndID + '#town_capacity_' + f + ' .amounts .max').get(0).innerHTML.replace('+', '').trim(), 10) || 0;
5967
5968 res[f].cur = curr + curr2;
5969 res[f].max = max - res[f].cur;
5970
5971 if (res[f].max < 0) {
5972 res[f].max = 0;
5973 }
5974
5975 } else { // World wonder or foreign town
5976 res[f].max = 30000;
5977 }
5978 }
5979 }
5980 // Rest of fraction (0-2 units) add to stone amount
5981 res.stone.part += res.sum.cur - (res.wood.part + res.stone.part + res.iron.part);
5982
5983 res.sum.rest = 0;
5984 rest_count = 0;
5985 calcRestAmount();
5986 setAmount(false, a, wndID);
5987 }, function () {
5988 setAmount(true, a, wndID);
5989 });
5990 }
5991
5992 function calcRestAmount() {
5993 // Subdivide rest
5994 if (res.sum.rest > 0) {
5995 for (var e in res) {
5996 if (res.hasOwnProperty(e) && e != "sum" && res[e].rest != true) {
5997 res[e].part += res.sum.rest / (3 - rest_count);
5998 }
5999 }
6000 res.sum.rest = 0;
6001 }
6002 // Calculate new rest
6003 for (var f in res) {
6004 if (res.hasOwnProperty(f) && f != "sum" && res[f].rest != true) {
6005 if (res[f].max <= res[f].part) {
6006 res[f].rest = true;
6007 res.sum.rest += res[f].part - res[f].max;
6008 rest_count += 1;
6009 res[f].part = res[f].max;
6010 }
6011 }
6012 }
6013 // Recursion
6014 if (res.sum.rest > 0 && rest_count < 3) {
6015 calcRestAmount();
6016 }
6017 }
6018
6019 function setAmount(clear, a, wndID) {
6020 for (var e in res) {
6021 if (res.hasOwnProperty(e) && e != "sum") {
6022 if (clear == true) {
6023 res[e].part = 0;
6024 }
6025 $(wndID + "#" + a + "trade_type_" + e + ' [type="text"]').select().val(res[e].part).blur();
6026 }
6027 }
6028 }
6029
6030 /********************************************************************************************************************************
6031 * Unit strength (blunt/sharp/distance) and Transport Capacity
6032 * ----------------------------------------------------------------------------------------------------------------------------
6033 * | â— Unit strength: Menu
6034 * | - Switching of def/off display with buttons
6035 * | - Possible Selection of certain unit types
6036 * | â— Unit strength: Conquest
6037 * | â— Unit strength: Barracks
6038 * | â— Transport capacity: Menu
6039 * | - Switching of transporter speed (+/- big transporter)
6040 * ----------------------------------------------------------------------------------------------------------------------------
6041 * ******************************************************************************************************************************/
6042
6043 var def = true, blunt = 0, sharp = 0, dist = 0, shipsize = false;
6044
6045 var UnitStrength = {
6046 // Calculate defensive strength
6047 calcDef: function (units) {
6048 var e;
6049 blunt = sharp = dist = 0;
6050 for (e in units) {
6051 if (units.hasOwnProperty(e)) {
6052 blunt += units[e] * uw.GameData.units[e].def_hack;
6053 sharp += units[e] * uw.GameData.units[e].def_pierce;
6054 dist += units[e] * uw.GameData.units[e].def_distance;
6055 }
6056 }
6057 },
6058 // Calculate offensive strength
6059 calcOff: function (units, selectedUnits) {
6060 var e;
6061 blunt = sharp = dist = 0;
6062 for (e in selectedUnits) {
6063 if (selectedUnits.hasOwnProperty(e)) {
6064 var attack = (units[e] || 0) * uw.GameData.units[e].attack;
6065 switch (uw.GameData.units[e].attack_type) {
6066 case 'hack':
6067 blunt += attack;
6068 break;
6069 case 'pierce':
6070 sharp += attack;
6071 break;
6072 case 'distance':
6073 dist += attack;
6074 break;
6075 }
6076 }
6077 }
6078 },
6079 /*******************************************************************************************************************************
6080 * â— Unit strength: Unit menu
6081 *******************************************************************************************************************************/
6082 Menu: {
6083 activate: function () {
6084 $('<div id="strength" class="cont def"><hr>' +
6085 '<span class="bold text_shadow cont_left strength_font">' +
6086 '<table style="margin:0px;">' +
6087 '<tr><td><div class="ico units_info_sprite img_hack"></td><td id="blunt">0</td></tr>' +
6088 '<tr><td><div class="ico units_info_sprite img_pierce"></td><td id="sharp">0</td></tr>' +
6089 '<tr><td><div class="ico units_info_sprite img_dist"></td><td id="dist">0</td></tr>' +
6090 '</table>' +
6091 '</span>' +
6092 '<div class="cont_right">' +
6093 '<img id="def_button" class="active img" src="https://gpall.innogamescdn.com/images/game/unit_overview/support.png">' +
6094 '<img id="off_button" class="img" src="https://gpall.innogamescdn.com/images/game/unit_overview/attack.png">' +
6095 '</div></div>').appendTo('.units_land .content');
6096
6097 // Style
6098 $('<style id="dio_strength_style">' +
6099 '#strength.def #off_button, #strength.off #def_button { filter:url(#Sepia); -webkit-filter:sepia(1); }' +
6100 '#strength.off #off_button, #strength.def #def_button { filter:none; -webkit-filter:none; } ' +
6101
6102 '#strength.off .img_hack { background-position:0% 36%;} ' +
6103 '#strength.def .img_hack { background-position:0% 0%;} ' +
6104 '#strength.off .img_pierce { background-position:0% 27%;} ' +
6105 '#strength.def .img_pierce { background-position:0% 9%;} ' +
6106 '#strength.off .img_dist { background-position:0% 45%;} ' +
6107 '#strength.def .img_dist { background-position:0% 18%;} ' +
6108
6109 '#strength .strength_font { font-size: 0.8em; } ' +
6110 '#strength.off .strength_font { color:#edb;} ' +
6111 '#strength.def .strength_font { color:#fc6;} ' +
6112
6113 '#strength .ico { height:20px; width:20px; } ' +
6114 '#strength .units_info_sprite { background:url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png); background-size:100%; } ' +
6115
6116 '#strength .img_pierce { background-position:0px -20px; } ' +
6117 '#strength .img_dist { background-position:0px -40px; } ' +
6118 '#strength hr { margin:0px; background-color:#5F5242; height:2px; border:0px solid; } ' +
6119 '#strength .cont_left { width:65%; display:table-cell; } ' +
6120
6121 '#strength.cont { background:url(https://gpall.innogamescdn.com/images/game/layout/layout_units_nav_border.png); } ' +
6122
6123 '#strength .cont_right { width:30%; display:table-cell; vertical-align:middle; } ' +
6124 '#strength .img { float:right; background:none; margin:2px 8px 2px 0px; } ' +
6125
6126 '</style>').appendTo("head");
6127
6128 // Button events
6129 $('.units_land .units_wrapper, .btn_gods_spells .checked').click(function () {
6130 setTimeout(function () {
6131 UnitStrength.Menu.update();
6132 }, 100);
6133 });
6134
6135 $('#off_button').click(function () {
6136 $('#strength').addClass('off').removeClass('def');
6137
6138 def = false;
6139 UnitStrength.Menu.update();
6140 });
6141 $('#def_button').click(function () {
6142 $('#strength').addClass('def').removeClass('off');
6143
6144 def = true;
6145 UnitStrength.Menu.update();
6146 });
6147 $('#def_button, #off_button').hover(function () {
6148 $(this).css('cursor', 'pointer');
6149 });
6150
6151 UnitStrength.Menu.update();
6152 },
6153 deactivate: function () {
6154 $('#strength').remove();
6155 $('#dio_strength_style').remove();
6156 },
6157 update: function () {
6158 var unitsIn = uw.ITowns.getTown(uw.Game.townId).units(), units = UnitStrength.Menu.getSelected();
6159
6160 // Calculation
6161 if (def === true) {
6162 UnitStrength.calcDef(units);
6163 } else {
6164 UnitStrength.calcOff(unitsIn, units);
6165 }
6166 $('#blunt').get(0).innerHTML = blunt;
6167 $('#sharp').get(0).innerHTML = sharp;
6168 $('#dist').get(0).innerHTML = dist;
6169 },
6170 getSelected: function () {
6171 var units = [];
6172 if ($(".units_land .units_wrapper .selected").length > 0) {
6173 $(".units_land .units_wrapper .selected").each(function () {
6174 units[this.className.split(" ")[1]] = this.children[0].innerHTML;
6175 });
6176 } else {
6177 $(".units_land .units_wrapper .unit").each(function () {
6178 units[this.className.split(" ")[1]] = this.children[0].innerHTML;
6179 });
6180 }
6181 return units;
6182 }
6183 },
6184 /*******************************************************************************************************************************
6185 * â— Unit strength: Conquest
6186 *******************************************************************************************************************************/
6187 Conquest: {
6188 add: function () {
6189 var units = [], str;
6190
6191 // units of the siege
6192 $('#conqueror_units_in_town .unit').each(function () {
6193 str = $(this).attr("class").split(" ")[4];
6194 if (!uw.GameData.units[str].is_naval) {
6195 units[str] = parseInt(this.children[0].innerHTML, 10);
6196 //console.log($(this).attr("class").split(" ")[4]);
6197 }
6198 });
6199 // calculation
6200 UnitStrength.calcDef(units);
6201
6202 $('<div id="strength_eo" class="game_border" style="width:90px; margin: 20px; align:center;">' +
6203 '<div class="game_border_top"></div><div class="game_border_bottom"></div>' +
6204 '<div class="game_border_left"></div><div class="game_border_right"></div>' +
6205 '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
6206 '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
6207 '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">' +
6208 '<tr><td width="1%"><div class="ico units_info_sprite img_hack"></div></td><td id="bl" align="center" width="100%">0</td></tr>' +
6209 '<tr><td><div class="ico units_info_sprite img_pierce"></div></td><td id="sh" align="center">0</td></tr>' +
6210 '<tr><td><div class="ico units_info_sprite img_dist"></div></td><td id="di" align="center">0</td></tr>' +
6211 '</table></span>' +
6212 '</div>').appendTo('#conqueror_units_in_town');
6213
6214 $('#strength_eo').tooltip('Gesamteinheitenstärke der Belagerungstruppen');
6215
6216 // Veröffentlichung-Button-Text
6217 $('#conqueror_units_in_town .publish_conquest_public_id_wrap').css({
6218 marginLeft: '130px'
6219 });
6220
6221 $('#strength_eo .ico').css({
6222 height: '20px',
6223 width: '20px'
6224 });
6225 $('#strength_eo .units_info_sprite').css({
6226 background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
6227 backgroundSize: '100%'
6228 });
6229 $('#strength_eo .img_pierce').css({backgroundPosition: '0% 9%'});
6230 $('#strength_eo .img_dist').css({backgroundPosition: '0% 18%'});
6231
6232
6233 $('#bl').get(0).innerHTML = blunt;
6234 $('#sh').get(0).innerHTML = sharp;
6235 $('#di').get(0).innerHTML = dist;
6236 }
6237 },
6238 /*******************************************************************************************************************************
6239 * â— Unit strength: Barracks
6240 *******************************************************************************************************************************/
6241 Barracks: {
6242 add: function () {
6243 if (!$('#strength_baracks').get(0)) {
6244 var units = [], pop = 0;
6245
6246 // whole units of the town
6247 $('#units .unit_order_total').each(function () {
6248 units[$(this).parent().parent().attr("id")] = this.innerHTML;
6249 });
6250 // calculation
6251 UnitStrength.calcDef(units);
6252
6253 // population space of the units
6254 for (var e in units) {
6255 if (units.hasOwnProperty(e)) {
6256 pop += units[e] * uw.GameData.units[e].population;
6257 }
6258 }
6259 $('<div id="strength_baracks" class="game_border" style="float:right; width:70px; align:center;">' +
6260 '<div class="game_border_top"></div><div class="game_border_bottom"></div>' +
6261 '<div class="game_border_left"></div><div class="game_border_right"></div>' +
6262 '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
6263 '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
6264 '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">' +
6265 '<tr><td width="1%"><div class="ico units_info_sprite img_hack"></div></td><td id="b" align="center" width="100%">0</td></tr>' +
6266 '<tr><td><div class="ico units_info_sprite img_pierce"></div></td><td id="s" align="center">0</td></tr>' +
6267 '<tr><td><div class="ico units_info_sprite img_dist"></div></td><td id="d" align="center">0</td></tr>' +
6268 '</table></span>' +
6269 '</div>').appendTo('.ui-dialog #units');
6270
6271 $('<div id="pop_baracks" class="game_border" style="float:right; width:60px; align:center;">' +
6272 '<div class="game_border_top"></div><div class="game_border_bottom"></div>' +
6273 '<div class="game_border_left"></div><div class="game_border_right"></div>' +
6274 '<div class="game_border_corner corner1"></div><div class="game_border_corner corner2"></div>' +
6275 '<div class="game_border_corner corner3"></div><div class="game_border_corner corner4"></div>' +
6276 '<span class="bold" style="color:#000;font-size: 0.8em;"><table style="margin:0px;background:#f7dca2;width:100%;align:center;">' +
6277 '<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>' +
6278 '</table></span>' +
6279 '</div>').appendTo('.ui-dialog #units');
6280
6281 $('.ui-dialog #units .ico').css({
6282 height: '20px',
6283 width: '20px'
6284 });
6285 $('.ui-dialog #units .units_info_sprite').css({
6286 background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
6287 backgroundSize: '100%'
6288 });
6289 $('.ui-dialog #units .img_pierce').css({backgroundPosition: '0% 9%'});
6290 $('.ui-dialog #units .img_dist').css({backgroundPosition: '0% 18%'});
6291
6292 //$('#pop_baracks').tooltip('Bevölkerungszahl aller Landeinheiten der Stadt');
6293 //$('#strength_baracks').tooltip('Gesamteinheitenstärke stadteigener Truppen');
6294
6295 $('#b').get(0).innerHTML = blunt;
6296 $('#s').get(0).innerHTML = sharp;
6297 $('#d').get(0).innerHTML = dist;
6298 $('#p').get(0).innerHTML = pop;
6299 }
6300 }
6301 }
6302 };
6303
6304 /*******************************************************************************************************************************
6305 * â— Transporter capacity
6306 *******************************************************************************************************************************/
6307 var TransportCapacity = {
6308 activate: function () {
6309 // transporter display
6310 $('<div id="transporter" class="cont" style="height:25px;">' +
6311 '<table style=" margin:0px;"><tr align="center" >' +
6312 '<td><img id="ship_img" class="ico" src="http://s7.directupload.net/images/140724/4pvfuch8.png"></td>' +
6313 '<td><span id="ship" class="bold text_shadow" style="color:#FFCC66;font-size: 10px;line-height: 2.1;"></span></td>' +
6314 '</tr></table>' +
6315 '</div>').appendTo('.units_naval .content');
6316
6317 $('#transporter.cont').css({
6318 background: 'url(https://gpall.innogamescdn.com/images/game/layout/layout_units_nav_border.png)'
6319 });
6320
6321 $('#transporter').hover(function () {
6322 $(this).css('cursor', 'pointer');
6323 });
6324 $('#transporter').toggleClick(
6325 function () {
6326 $('#ship_img').get(0).src = "http://s1.directupload.net/images/140724/b5xl8nmj.png";
6327 shipsize = !shipsize;
6328 TransportCapacity.update();
6329 },
6330 function () {
6331 $('#ship_img').get(0).src = "http://s7.directupload.net/images/140724/4pvfuch8.png";
6332 shipsize = !shipsize;
6333 TransportCapacity.update();
6334 }
6335 );
6336 TransportCapacity.update();
6337 },
6338 deactivate: function () {
6339 $('#transporter').remove();
6340 },
6341 update: function () {
6342 var bigTransp = 0, smallTransp = 0, pop = 0, ship = 0, unit, berth, units = [];
6343 // Ship space (available)
6344 smallTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().small_transporter, 10);
6345 if (isNaN(smallTransp)) smallTransp = 0;
6346 if (shipsize) {
6347 bigTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().big_transporter, 10);
6348 if (isNaN(bigTransp)) bigTransp = 0;
6349 }
6350
6351 // Checking: Research berth
6352 berth = 0;
6353 if (uw.ITowns.getTown(uw.Game.townId).researches().hasBerth()) {
6354 berth = GameData.research_bonus.berth;
6355 }
6356 ship = bigTransp * (GameData.units.big_transporter.capacity + berth) + smallTransp * (GameData.units.small_transporter.capacity + berth);
6357
6358 units = uw.ITowns.getTown(uw.Game.townId).units();
6359
6360 // Ship space (required)
6361 for (var e in units) {
6362 if (units.hasOwnProperty(e)) {
6363 if (uw.GameData.units[e]) { // without Heroes
6364 if (!(uw.GameData.units[e].is_naval || uw.GameData.units[e].flying)) {
6365 pop += units[e] * uw.GameData.units[e].population;
6366 }
6367 }
6368 }
6369 }
6370 $('#ship').get(0).innerHTML = pop + "/" + ship;
6371 }
6372 };
6373
6374
6375 /*******************************************************************************************************************************
6376 * Simulator
6377 * ----------------------------------------------------------------------------------------------------------------------------
6378 * | â— Layout adjustment
6379 * | â— Permanent display of the extended modifier box
6380 * | â— Unit strength for entered units (without modificator influence yet)
6381 * ----------------------------------------------------------------------------------------------------------------------------
6382 *******************************************************************************************************************************/
6383 var Simulator = {
6384 activate: function () {
6385 $('<style id="dio_simulator_style" type="text/css">' +
6386
6387 '#place_simulator { overflow: hidden !important} ' +
6388 '#place_simulator .game_body { height: 417px !important} ' +
6389
6390 '#place_simulator_form h4 { display:none; } '+
6391
6392 '#place_simulator .place_simulator_table { margin: 0px !important } '+
6393
6394 '#place_simulator_form .place_sim_wrap_mods { margin-bottom: 2px; } '+
6395
6396 // Bonus container
6397 '.place_sim_bonuses_heroes { position:absolute; right:3px; top:27px; width: 272px;} ' +
6398 '.place_sim_bonuses_heroes .place_sim_showhide { display:none; } ' + // Hide modifier box button
6399
6400
6401 //'.place_sim_wrap_mods {position: relative; right: -17px !important} '+
6402 '.place_sim_wrap_mods .place_simulator_table :eq(1) { width: 300px;} ' + ////////////// genauer!
6403 '.place_sim_wrap_mods > .place_simulator_table { width: 272px;} ' + ////////////// genauer!
6404
6405 // Wall losses
6406 '.place_sim_wrap_mods tr:last-child { display:none; } ' +
6407
6408 // Extended modifier box
6409 //'@-webkit-keyframes MODBOX { 0% { opacity: 0; } 100% { opacity: 1; } } '+
6410 //'@keyframes MODBOX { 0% { opacity: 0; } 100% { opacity: 1; } } '+
6411
6412 '.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} ' +
6413 '.place_sim_wrap_mods_extended table tr td:eq(0) { width: 18px !important } ' +
6414 '.place_sim_wrap_mods_extended td { border:0px; } ' +
6415 '.place_sim_wrap_mods_extended tr td:first-child { border-left:0px; width:19px; padding-left:0px; } ' +
6416 '.place_sim_wrap_mods_extended .place_simulator_table { margin:0px; border-collapse:separate; border:1px solid #724B08; table-layout:fixed; width:100% } ' +
6417
6418 '.place_simulator_table .place_image { display:block; width: 20px; height:20px; background-size:100%; margin:auto; } ' +
6419
6420 '.place_simulator_table .place_image.pa_commander { background: url(https://diotools.de/images/game/advisors/advisors_22.png); background-position: 0px 44px; } ' +
6421 '.place_simulator_table .place_image.pa_captain { background: url(https://diotools.de/images/game/advisors/advisors_22.png); background-position: 0px 88px; } ' +
6422 '.place_simulator_table .place_image.pa_priest { background: url(https://diotools.de/images/game/advisors/advisors_22.png); background-position: 0px 66px; } ' +
6423
6424 '.place_simulator_table .place_image.is_night { background-position: 0px -40px; } ' +
6425 '.place_simulator_table .place_image.research_ram { background-position: 0px -300px; } ' +
6426 '.place_simulator_table .place_image.research_phalanx { background-position: 0px -280px; }' +
6427 '.place_simulator_table .place_image.research_divine_selection { background-position: 0 -600px; }' +
6428
6429 '.place_sim_wrap_mods_extended .place_cross { height:16px; background:none; } ' +
6430 '.place_sim_wrap_mods_extended .place_checkbox_field { display:table-cell; width:13px; height:13px; } ' +
6431
6432 '.place_sim_wrap_mods_extended tr:last-child { display:none;} ' +
6433
6434 '.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} ' +
6435
6436 '.place_sim_wrap_mods_extended .game_border>div { display:none; } ' +
6437 '.place_sim_wrap_mods_extended .game_border { margin:0px; } ' +
6438
6439 '.place_sim_wrap_mods_extended .game_border { height: 139px; overflow-y: auto; overflow-x: hidden; }' + // Größe der Modfikatorbox begrenzen
6440
6441 '#place_simulator .window_inner_curtain { display: none !important } ' + // Hintergrund entfernen bei offener Modifikatorbox
6442
6443 // Unit container
6444 '#simulator_body .unit_container { height: 50px !important; width: 50px !important; margin: 0px 3px 0px 1px !important} ' +
6445 '.place_simulator_odd, .place_simulator_even { text-align: center !important} ' +
6446 '.place_insert_field { margin: 0px !important} ' +
6447
6448 '#place_sim_ground_units { position:absolute; bottom: 35px;} ' +
6449
6450 // Sea unit box
6451 '#place_sim_naval_units { position: absolute; } ' +
6452 '#place_sim_naval_units tbody tr:last-child { height:auto !important; }' +
6453
6454 // Land unit box
6455 '#place_sim_wrap_units { position: absolute !important; bottom: 35px !important} ' +
6456
6457 '#simulator_body>h4 { position:absolute;bottom:188px;} ' +
6458
6459 // Select boxes
6460 '.place_sim_select_gods_wrap { position:absolute; bottom:182px; } ' +
6461
6462 '.place_sim_select_gods_wrap .place_sim_select_gods { width: 150px; } ' +
6463 '.place_sim_select_gods_wrap select { max-width: 120px; } ' +
6464
6465 '.place_sim_select_gods_wrap .place_symbol, .place_sim_select_strategies .place_symbol { margin: 1px 2px 0px 5px !important} ' +
6466 '.place_sim_insert_units .place_symbol { filter: hue-rotate(330deg); -webkit-filter: hue-rotate(330deg);} ' +
6467 '.place_attack { float: left !important} ' +
6468
6469 // Hero box
6470 '.place_sim_heroes_container { position: absolute; right: 0px; z-index: 1; } ' +
6471 '.place_sim_hero_container { width: 45px !important; height: 25px !important} ' +
6472
6473 '#place_simulator .place_sim_bonuses_heroes h4:nth-of-type(2) { display:none; }' + // Heroes title
6474
6475 // - Hero container
6476 '.place_sim_hero_choose, .place_sim_hero_unit_container { height: 26px !important; width: 30px !important} ' +
6477 '#hero_defense_icon, #hero_attack_icon { height: 25px !important; width: 25px !important; margin: 0px !important} ' +
6478 '#hero_defense_dd, #hero_attack_dd { height: 25px !important; width: 25px !important; margin: 1px !important} ' +
6479 '.place_sim_hero_attack, .place_sim_hero_defense { margin-left: 3px !important} ' +
6480 '#hero_attack_text, #hero_defense_text { font-size: 11px !important; bottom: 0px !important} ' +
6481 '.place_sim_heroes_container .plus { left: 2px; top: 2px !important} ' +
6482
6483 '.place_sim_heroes_container .button_new.square { left: 2px !important; } ' +
6484
6485
6486 // - Hero spinner
6487 '.place_sim_heroes_container .spinner { height: 25px !important; width: 40px !important } ' +
6488 '.place_sim_heroes_container td:nth-child(0) { height: 30px !important} ' +
6489 '.place_sim_heroes_container .spinner { height: 24px !important; position:absolute !important; width:12px !important; left:29px !important; '+
6490 'background:url(https://gpall.innogamescdn.com/images/game/border/odd.png) repeat !important; border: 1px solid rgb(107, 107, 107) !important; } ' +
6491 '.place_sim_heroes_container .spinner .button_down, .place_sim_heroes_container .spinner .button_up { bottom: 2px !important; cursor: pointer !important} ' +
6492 '.place_sim_heroes_container .spinner .border_l, .place_sim_heroes_container .spinner .border_r, .place_sim_heroes_container .spinner .body { display:none; } '+
6493
6494 // Quack
6495 '#q_place_sim_lost_res { display: none; } ' +
6496 '</style>').appendTo('head');
6497
6498 if($('#place_simulator').get(0)) {
6499 Simulator.change();
6500 }
6501
6502 SimulatorStrength.activate();
6503
6504 },
6505 deactivate: function () {
6506 $('#dio_simulator_style').remove();
6507 if($('#simu_table').get(0)) {
6508 $('#simu_table').remove();
6509
6510 // Hero box
6511 if ($('.place_sim_heroes_container').get(0)) {
6512 $('.hero_unit').each(function () {
6513 $(this).addClass('unit_icon40x40').removeClass('unit_icon25x25');
6514 });
6515
6516 // Hero spinner
6517 $('.place_sim_heroes_container .spinner').each(function () {
6518 $(this).addClass('place_sim_hero_spinner');
6519 });
6520 }
6521 }
6522
6523 SimulatorStrength.deactivate();
6524 },
6525 change: function () {
6526 // TODO: Durch CSS ersetzen...
6527
6528 // Wall loss
6529 $('.place_sim_wrap_mods tr:eq(1) td:eq(5)').html('<span id="building_place_def_losses_wall_level" class="place_losses bold"></span>');
6530
6531 // Extended modificator box
6532 $('.place_sim_wrap_mods_extended .power').each(function () {
6533 $(this).removeClass("power_icon45x45").addClass("power_icon16x16");
6534 });
6535 $('.place_sim_wrap_mods_extended td:nth-child(even)').each(function () {
6536 $(this).addClass("left_border place_simulator_odd");
6537 });
6538 $('.place_sim_wrap_mods_extended td:nth-child(odd)').each(function () {
6539 $(this).addClass("left_border place_simulator_even");
6540 });
6541
6542 // Border entfernen
6543 $('.place_sim_wrap_mods_extend td:first-child').each(function () {
6544 $(this).removeClass("left_border");
6545 });
6546
6547 // -> Update percentage each time
6548 $('.place_checkbox_field').click(function () {
6549 FightSimulator.closeModsExtended(); //$('.place_sim_bonuses_more_confirm').get(0).click();
6550 });
6551
6552 // Hero world ?
6553 if (uw.Game.hasArtemis) {
6554 $('.place_sim_wrap_mods_extend tr').each(function () {
6555 this.children[1].style.borderLeft = "none";
6556 this.children[0].remove();
6557 });
6558 }
6559
6560 // Hero box
6561 if ($('.place_sim_heroes_container').get(0)) {
6562 $('.hero_unit').each(function () {
6563 $(this).removeClass('unit_icon40x40').addClass('unit_icon25x25');
6564 });
6565
6566 // Hero spinner
6567 $('.place_sim_heroes_container .spinner').each(function () {
6568 $(this).removeClass('place_sim_hero_spinner');
6569 });
6570 }
6571
6572 setStrengthSimulator();
6573 }
6574 };
6575
6576 function afterSimulation() {
6577 var lossArray = {att: {res: 0, fav: 0, pop: 0}, def: {res: 0, fav: 0, pop: 0}},
6578 wall_level = parseInt($('.place_sim_wrap_mods .place_insert_field[name="sim[mods][def][wall_level]"]').val(), 10),
6579 wall_damage = parseInt($('#building_place_def_losses_wall_level').get(0).innerHTML, 10),
6580 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];
6581
6582 // Calculate unit losses
6583 $('#place_sim_ground_units .place_losses, #place_sim_naval_units .place_losses').each(function () {
6584 var loss = parseInt(this.innerHTML, 10) || 0;
6585 //console.log(this.innerHTML);
6586 if (loss > 0) {
6587 var unit = this.id.substring(26);
6588 var side = this.id.split("_")[2]; // att / def
6589 lossArray[side].res += loss * (uw.GameData.units[unit].resources.wood + uw.GameData.units[unit].resources.stone + uw.GameData.units[unit].resources.iron);
6590 lossArray[side].fav += loss * uw.GameData.units[unit].favor;
6591 lossArray[side].pop += loss * uw.GameData.units[unit].population;
6592 }
6593 });
6594 // Calculate wall resource losses
6595 for (var w = wall_level; w > wall_level - wall_damage; w--) {
6596 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
6597 }
6598
6599 // Insert losses into table
6600 for (var x in lossArray) {
6601 if (lossArray.hasOwnProperty(x)) {
6602 for (var z in lossArray[x]) {
6603 if (lossArray[x].hasOwnProperty(z)) {
6604 //console.log(((z === "res") && (lossArray[x][z] > 10000)) ? (Math.round(lossArray[x][z] / 1000) + "k") : lossArray[x][z]);
6605 $("#" + x + "_" + z).get(0).innerHTML = ((z === "res") && (lossArray[x][z] > 10000)) ? (Math.round(lossArray[x][z] / 1000) + "k") : lossArray[x][z];
6606
6607 }
6608 }
6609 }
6610 }
6611 }
6612
6613 // Stärkeanzeige: Simulator
6614 var unitsGround = {att: {}, def: {}}, unitsNaval = {att: {}, def: {}}, name = "";
6615
6616 var SimulatorStrength = {
6617 unitsGround : {att: {}, def: {}},
6618 unitsNaval : {att: {}, def: {}},
6619
6620 activate : function(){
6621 $('<style id="dio_simulator_strength_style">'+
6622 '#dio_simulator_strength { position:absolute; top:192px; font-size:0.8em; width:63%; } '+
6623 '#dio_simulator_strength .ico { height:20px; width:20px; margin:auto; } '+
6624 '#dio_simulator_strength .units_info_sprite { background:url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png); background-size:100%; } ' +
6625
6626 '#dio_simulator_strength .img_hack { background-position:0% 36%; } '+
6627 '#dio_simulator_strength .img_pierce { background-position:0% 27%; } '+
6628 '#dio_simulator_strength .img_dist { background-position:0% 45% !important; } '+
6629 '#dio_simulator_strength .img_ship { background-position:0% 72%; } '+
6630
6631 '#dio_simulator_strength .img_fav { background: url(https://gpall.innogamescdn.com/images/game/res/favor.png) !important; background-size: 100%; } '+
6632 '#dio_simulator_strength .img_res { background: url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png) 0% 54%; background-size: 100%; } '+
6633 '#dio_simulator_strength .img_pop { background: url(https://gpall.innogamescdn.com/images/game/res/pop.png); background-size:100%; } '+
6634
6635 '#dio_simulator_strength .left_border { width: 54px; } '+
6636 '</style>'
6637 ).appendTo('head');
6638
6639 },
6640 deactivate : function(){
6641 $('#dio_simulator_strength_style').remove();
6642 },
6643 add : function(){
6644 $('<div id="dio_simulator_strength">' +
6645 '<div style="float:left; margin-right:12px;"><h4>' + getText("labels", "str") + '</h4>' +
6646 '<table class="place_simulator_table strength" cellpadding="0px" cellspacing="0px" style="align:center;">' +
6647 '<tr>' +
6648 '<td class="place_simulator_even"></td>' +
6649 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_hack"></div></td>' +
6650 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_pierce"></div></td>' +
6651 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_dist"></div></td>' +
6652 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_ship"></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_b">0</td>' +
6656 '<td class="left_border place_simulator_even" id="att_s">0</td>' +
6657 '<td class="left_border place_simulator_odd" id="att_d">0</td>' +
6658 '<td class="left_border place_simulator_even" id="att_ship">0</td>' +
6659 '</tr><tr>' +
6660 '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
6661 '<td class="left_border place_simulator_odd" id="def_b">0</td>' +
6662 '<td class="left_border place_simulator_even" id="def_s">0</td>' +
6663 '<td class="left_border place_simulator_odd" id="def_d">0</td>' +
6664 '<td class="left_border place_simulator_even" id="def_ship">0</td>' +
6665 '</tr>' +
6666 '</table>' +
6667 '</div><div><h4>' + getText("labels", "los") + '</h4>' +
6668 '<table class="place_simulator_table loss" cellpadding="0px" cellspacing="0px" style="align:center;">' +
6669 '<tr>' +
6670 '<td class="place_simulator_even"></td>' +
6671 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_res"></div></td>' +
6672 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_fav"></div></td>' +
6673 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_pop"></div></td>' +
6674 '</tr><tr>' +
6675 '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>' +
6676 '<td class="left_border place_simulator_odd" id="att_res">0</td>' +
6677 '<td class="left_border place_simulator_even" id="att_fav">0</td>' +
6678 '<td class="left_border place_simulator_odd" id="att_pop">0</td>' +
6679 '</tr><tr>' +
6680 '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
6681 '<td class="left_border place_simulator_odd" id="def_res">0</td>' +
6682 '<td class="left_border place_simulator_even" id="def_fav">0</td>' +
6683 '<td class="left_border place_simulator_odd" id="def_pop">0</td>' +
6684 '</tr>' +
6685 '</table>' +
6686 '</div></div>').appendTo('#simulator_body');
6687
6688
6689 $('#dio_simulator_strength .left_border').each(function () {
6690 $(this)[0].align = 'center';
6691 });
6692
6693 // Tooltips setzen
6694 $('#dio_simulator_strength .strength').tooltip(getText("labels", "str") + " (" + getText("labels", "mod") + ")");
6695 $('#dio_simulator_strength .loss').tooltip(getText("labels", "los"));
6696
6697 // Klick auf Einheitenbild
6698 $('.index_unit').click(function () {
6699 var type = $(this).attr('class').split(" ")[4];
6700 $('.place_insert_field[name="sim[units][att][' + type + ']"]').change();
6701 });
6702
6703 $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').on('input change', function () {
6704 name = $(this).attr("name").replace(/\]/g, "").split("[");
6705 var str = this;
6706
6707
6708 setTimeout(function () {
6709 var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2],
6710 val, e;
6711
6712 val = parseInt($(str).val(), 10);
6713 val = val || 0;
6714
6715 if (unit_type == "ground") {
6716 unitsGround[name[2]][name[3]] = val;
6717
6718 if (name[2] == "def") {
6719 UnitStrength.calcDef(unitsGround.def);
6720 } else {
6721 UnitStrength.calcOff(unitsGround.att, unitsGround.att);
6722 }
6723 $('#' + name[2] + '_b').get(0).innerHTML = blunt;
6724 $('#' + name[2] + '_s').get(0).innerHTML = sharp;
6725 $('#' + name[2] + '_d').get(0).innerHTML = dist;
6726
6727 } else {
6728 var att = 0, def = 0;
6729 unitsNaval[name[2]][name[3]] = val;
6730
6731 if (name[2] == "def") {
6732 for (e in unitsNaval.def) {
6733 if (unitsNaval.def.hasOwnProperty(e)) {
6734 def += unitsNaval.def[e] * uw.GameData.units[e].defense;
6735 }
6736 }
6737 $('#def_ship').get(0).innerHTML = def;
6738
6739 } else {
6740 for (e in unitsNaval.att) {
6741 if (unitsNaval.att.hasOwnProperty(e)) {
6742 att += unitsNaval.att[e] * uw.GameData.units[e].attack;
6743 }
6744 }
6745 $('#att_ship').get(0).innerHTML = att;
6746 }
6747 }
6748 }, 100);
6749 });
6750
6751 // Abfrage wegen eventueller Spionageweiterleitung
6752 getUnitInputs();
6753 setTimeout(function () {
6754 setChangeUnitInputs("def");
6755 }, 100);
6756
6757 $('#select_insert_units').change(function () {
6758 var side = $(this).find('option:selected').val();
6759
6760 setTimeout(function () {
6761 getUnitInputs();
6762 if (side === "att" || side === "def") {
6763 setChangeUnitInputs(side);
6764 }
6765 }, 200);
6766 });
6767 },
6768
6769 getUnitInputs : function(){
6770 $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').each(function () {
6771 var name = $(this).attr("name").replace(/\]/g, "").split("[");
6772
6773 var str = this;
6774
6775 var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2];
6776
6777 var val = parseInt($(str).val(), 10);
6778
6779 val = val || 0;
6780
6781 if (unit_type === "ground") {
6782 SimulatorStrength.unitsGround[name[2]][name[3]] = val;
6783 } else {
6784 SimulatorStrength.unitsNaval[name[2]][name[3]] = val;
6785 }
6786 });
6787 },
6788
6789 updateStrength : function(){
6790
6791 }
6792 }
6793 function setStrengthSimulator() {
6794 $('<div id="dio_simulator_strength">' +
6795 '<div style="float:left; margin-right:12px;"><h4>' + getText("labels", "str") + '</h4>' +
6796 '<table class="place_simulator_table strength" cellpadding="0px" cellspacing="0px" style="align:center;">' +
6797 '<tr>' +
6798 '<td class="place_simulator_even"></td>' +
6799 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_hack"></div></td>' +
6800 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_pierce"></div></td>' +
6801 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_dist"></div></td>' +
6802 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_ship"></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_b">0</td>' +
6806 '<td class="left_border place_simulator_even" id="att_s">0</td>' +
6807 '<td class="left_border place_simulator_odd" id="att_d">0</td>' +
6808 '<td class="left_border place_simulator_even" id="att_ship">0</td>' +
6809 '</tr><tr>' +
6810 '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
6811 '<td class="left_border place_simulator_odd" id="def_b">0</td>' +
6812 '<td class="left_border place_simulator_even" id="def_s">0</td>' +
6813 '<td class="left_border place_simulator_odd" id="def_d">0</td>' +
6814 '<td class="left_border place_simulator_even" id="def_ship">0</td>' +
6815 '</tr>' +
6816 '</table>' +
6817 '</div><div><h4>' + getText("labels", "los") + '</h4>' +
6818 '<table class="place_simulator_table loss" cellpadding="0px" cellspacing="0px" style="align:center;">' +
6819 '<tr>' +
6820 '<td class="place_simulator_even"></td>' +
6821 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_res"></div></td>' +
6822 '<td class="left_border place_simulator_even"><div class="ico units_info_sprite img_fav"></div></td>' +
6823 '<td class="left_border place_simulator_odd"><div class="ico units_info_sprite img_pop"></div></td>' +
6824 '</tr><tr>' +
6825 '<td class="place_simulator_even"><div class="place_symbol place_att"></div></td>' +
6826 '<td class="left_border place_simulator_odd" id="att_res">0</td>' +
6827 '<td class="left_border place_simulator_even" id="att_fav">0</td>' +
6828 '<td class="left_border place_simulator_odd" id="att_pop">0</td>' +
6829 '</tr><tr>' +
6830 '<td class="place_simulator_even"><div class="place_symbol place_def"></div></td>' +
6831 '<td class="left_border place_simulator_odd" id="def_res">0</td>' +
6832 '<td class="left_border place_simulator_even" id="def_fav">0</td>' +
6833 '<td class="left_border place_simulator_odd" id="def_pop">0</td>' +
6834 '</tr>' +
6835 '</table>' +
6836 '</div></div>').appendTo('#simulator_body');
6837
6838
6839 /*
6840 $('#dio_simulator_strength').css({
6841 position: 'absolute',
6842 top: '192px',
6843 fontSize: '0.8em',
6844 width: '63%'
6845 });
6846 $('#dio_simulator_strength .ico').css({
6847 height: '20px',
6848 width: '20px',
6849 margin: 'auto'
6850 });
6851 $('#dio_simulator_strength .units_info_sprite').css({
6852 background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png)',
6853 backgroundSize: '100%'
6854 });
6855 $('#dio_simulator_strength .img_hack').css({backgroundPosition: '0% 36%'});
6856 $('#dio_simulator_strength .img_pierce').css({backgroundPosition: '0% 27%'});
6857 $('#dio_simulator_strength .img_dist').css({backgroundPosition: '0% 45%'});
6858 $('#dio_simulator_strength .img_ship').css({backgroundPosition: '0% 72%'});
6859
6860 $('#dio_simulator_strength .img_fav').css({
6861 background: 'url(https://gpall.innogamescdn.com/images/game/res/favor.png)',
6862 backgroundSize: '100%'
6863 });
6864 $('#dio_simulator_strength .img_res').css({
6865 background: 'url(https://gpall.innogamescdn.com/images/game/units/units_info_sprite2.51.png) 0% 54%',
6866 backgroundSize: '100%'
6867 });
6868 $('#dio_simulator_strength .img_pop').css({
6869 background: 'url(https://gpall.innogamescdn.com/images/game/res/pop.png)',
6870 backgroundSize: '100%'
6871 });
6872
6873 $('#dio_simulator_strength .left_border').css({
6874 width: '54px'
6875 });
6876 */
6877
6878
6879 $('#dio_simulator_strength .left_border').each(function () {
6880 $(this)[0].align = 'center';
6881 });
6882
6883 $('#dio_simulator_strength .strength').tooltip(getText("labels", "str") + " (" + getText("labels", "mod") + ")");
6884 $('#dio_simulator_strength .loss').tooltip(getText("labels", "los"));
6885
6886 // Klick auf Einheitenbild
6887 $('.index_unit').click(function () {
6888 var type = $(this).attr('class').split(" ")[4];
6889 $('.place_insert_field[name="sim[units][att][' + type + ']"]').change();
6890 });
6891
6892 $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').on('input change', function () {
6893 name = $(this).attr("name").replace(/\]/g, "").split("[");
6894 var str = this;
6895 //console.log(str);
6896 setTimeout(function () {
6897 var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2],
6898 val, e;
6899
6900 val = parseInt($(str).val(), 10);
6901 val = val || 0;
6902
6903 if (unit_type == "ground") {
6904 unitsGround[name[2]][name[3]] = val;
6905
6906 if (name[2] == "def") {
6907 UnitStrength.calcDef(unitsGround.def);
6908 } else {
6909 UnitStrength.calcOff(unitsGround.att, unitsGround.att);
6910 }
6911 $('#' + name[2] + '_b').get(0).innerHTML = blunt;
6912 $('#' + name[2] + '_s').get(0).innerHTML = sharp;
6913 $('#' + name[2] + '_d').get(0).innerHTML = dist;
6914
6915 } else {
6916 var att = 0, def = 0;
6917 unitsNaval[name[2]][name[3]] = val;
6918
6919 if (name[2] == "def") {
6920 for (e in unitsNaval.def) {
6921 if (unitsNaval.def.hasOwnProperty(e)) {
6922 def += unitsNaval.def[e] * uw.GameData.units[e].defense;
6923 }
6924 }
6925 $('#def_ship').get(0).innerHTML = def;
6926
6927 } else {
6928 for (e in unitsNaval.att) {
6929 if (unitsNaval.att.hasOwnProperty(e)) {
6930 att += unitsNaval.att[e] * uw.GameData.units[e].attack;
6931 }
6932 }
6933 $('#att_ship').get(0).innerHTML = att;
6934 }
6935 }
6936 }, 100);
6937 });
6938
6939 // Abfrage wegen eventueller Spionageweiterleitung
6940 getUnitInputs();
6941 setTimeout(function () {
6942 setChangeUnitInputs("def");
6943 }, 100);
6944
6945 $('#select_insert_units').change(function () {
6946 var side = $(this).find('option:selected').val();
6947
6948 setTimeout(function () {
6949 getUnitInputs();
6950 if (side === "att" || side === "def") {
6951 setChangeUnitInputs(side);
6952 }
6953 }, 200);
6954 });
6955 }
6956
6957 function getUnitInputs() {
6958 $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').each(function () {
6959 name = $(this).attr("name").replace(/\]/g, "").split("[");
6960
6961 var str = this;
6962
6963 var unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2];
6964
6965 var val = parseInt($(str).val(), 10);
6966
6967 val = val || 0;
6968
6969 if (unit_type === "ground") {
6970 unitsGround[name[2]][name[3]] = val;
6971 } else {
6972 unitsNaval[name[2]][name[3]] = val;
6973 }
6974 });
6975 }
6976
6977 function setChangeUnitInputs(side) {
6978 $('.place_insert_field[name="sim[units][' + side + '][godsent]"]').change();
6979 setTimeout(function () {
6980 $('.place_insert_field[name="sim[units][' + side + '][colonize_ship]"]').change();
6981 }, 100);
6982 }
6983
6984 /*******************************************************************************************************************************
6985 * Defense form
6986 * ----------------------------------------------------------------------------------------------------------------------------
6987 * | â— Adds a defense form to the bbcode bar
6988 * ----------------------------------------------------------------------------------------------------------------------------
6989 *******************************************************************************************************************************/
6990
6991 // Funktion aufteilen...
6992 function addForm(e) {
6993 var textareaId = "", bbcodeBarId = "";
6994
6995 switch (e) {
6996 case "/alliance_forum/forum":
6997 textareaId = "#forum_post_textarea";
6998 bbcodeBarId = "#forum";
6999 break;
7000 case "/message/forward":
7001 textareaId = "#message_message";
7002 bbcodeBarId = "#message_bbcodes";
7003 break;
7004 case "/message/new":
7005 textareaId = "#message_new_message";
7006 bbcodeBarId = "#message_bbcodes";
7007 break;
7008 case "/message/view":
7009 textareaId = "#message_reply_message";
7010 bbcodeBarId = "#message_bbcodes";
7011 break;
7012 case "/player_memo/load_memo_content":
7013 textareaId = "#memo_text_area";
7014 bbcodeBarId = "#memo_edit";
7015 break;
7016 }
7017
7018 $('<a title="Verteidigungsformular" href="#" class="dio_bbcode_option def_form" name="def_form"></a>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
7019
7020 $('.def_form_button').css({
7021 cursor: 'pointer',
7022 marginTop: '3px'
7023 });
7024
7025 $(bbcodeBarId + ' .dio_bbcode_option').css({
7026 background: 'url("http://s14.directupload.net/images/140126/lt3hyb8j.png")',
7027 display: 'block',
7028 float: 'left',
7029 width: '22px',
7030 height: '23px',
7031 margin: '0 3px 0 0',
7032 position: 'relative'
7033 });
7034 $(bbcodeBarId + ' .def_form').css({
7035 backgroundPosition: '-89px 0px'
7036 });
7037 var imgArray = {
7038 wall: 'https://gpall.innogamescdn.com/images/game/main/wall.png',
7039 tower: 'https://gpall.innogamescdn.com/images/game/main/tower.png',
7040 hide: 'https://gpall.innogamescdn.com/images/game/main/hide.png',
7041
7042 spy: 'http://s7.directupload.net/images/140114/yr993xwc.png',
7043 pop: 'http://s7.directupload.net/images/140114/4d6xktxm.png',
7044
7045 rev1: 'http://s7.directupload.net/images/140115/9cv6otiu.png',
7046 rev0: 'http://s7.directupload.net/images/140115/aue4rg6i.png',
7047 eo1: 'http://s1.directupload.net/images/140115/fkzlipyh.png',
7048 eo0: 'http://s1.directupload.net/images/140115/hs2kg59c.png',
7049 att: 'http://s1.directupload.net/images/140115/3t6uy4te.png',
7050 sup: 'http://s7.directupload.net/images/140115/ty6szerx.png',
7051
7052 zeus: 'http://s1.directupload.net/images/140114/cdxecrpu.png',
7053 hera: 'http://s1.directupload.net/images/140114/mve54v2o.png',
7054 athena: 'http://s14.directupload.net/images/140114/kyqyedhe.png',
7055 poseidon: 'http://s7.directupload.net/images/140114/tusr9oyi.png',
7056 hades: 'http://s7.directupload.net/images/140114/huins2gn.png',
7057 artemis: 'http://s7.directupload.net/images/140114/kghjhko8.png',
7058 nogod: 'http://s1.directupload.net/images/140114/e7vmvfap.png',
7059
7060 captain: 'http://s14.directupload.net/images/140114/88gg75rc.png',
7061 commander: 'http://s14.directupload.net/images/140114/slbst52o.png',
7062 priest: 'http://s1.directupload.net/images/140114/glptekkx.png',
7063
7064 phalanx: 'http://s7.directupload.net/images/140114/e97wby6z.png',
7065 ram: 'http://s7.directupload.net/images/140114/s854ds3w.png',
7066
7067 militia: 'http://wiki.en.grepolis.com/images/9/9b/Militia_40x40.png',
7068 sword: 'http://wiki.en.grepolis.com/images/9/9c/Sword_40x40.png',
7069 slinger: 'http://wiki.en.grepolis.com/images/d/dc/Slinger_40x40.png',
7070 archer: 'http://wiki.en.grepolis.com/images/1/1a/Archer_40x40.png',
7071 hoplite: 'http://wiki.en.grepolis.com/images/b/bd/Hoplite_40x40.png',
7072 rider: 'http://wiki.en.grepolis.com/images/e/e9/Rider_40x40.png',
7073 chariot: 'http://wiki.en.grepolis.com/images/b/b8/Chariot_40x40.png',
7074 catapult: 'http://wiki.en.grepolis.com/images/f/f0/Catapult_40x40.png',
7075 godsent: 'http://wiki.de.grepolis.com/images/6/6e/Grepolis_Wiki_225.png',
7076
7077 def_sum: 'http://s14.directupload.net/images/140127/6cxnis9r.png',
7078
7079 minotaur: 'http://wiki.de.grepolis.com/images/7/70/Minotaur_40x40.png',
7080 manticore: 'http://wiki.de.grepolis.com/images/5/5e/Manticore_40x40.png',
7081 zyclop: 'http://wiki.de.grepolis.com/images/6/66/Zyklop_40x40.png',
7082 sea_monster: 'http://wiki.de.grepolis.com/images/7/70/Sea_monster_40x40.png',
7083 harpy: 'http://wiki.de.grepolis.com/images/8/80/Harpy_40x40.png',
7084 medusa: 'http://wiki.de.grepolis.com/images/d/db/Medusa_40x40.png',
7085 centaur: 'http://wiki.de.grepolis.com/images/5/53/Centaur_40x40.png',
7086 pegasus: 'http://wiki.de.grepolis.com/images/5/54/Pegasus_40x40.png',
7087 cerberus: 'http://wiki.de.grepolis.com/images/6/67/Zerberus_40x40.png',
7088 fury: 'http://wiki.de.grepolis.com/images/6/67/Erinys_40x40.png',
7089 griffin: 'http://wiki.de.grepolis.com/images/d/d1/Unit_greif.png',
7090 calydonian_boar: 'http://wiki.de.grepolis.com/images/9/93/Unit_eber.png',
7091
7092 big_transporter: 'http://wiki.en.grepolis.com/images/0/04/Big_transporter_40x40.png',
7093 bireme: 'http://wiki.en.grepolis.com/images/4/44/Bireme_40x40.png',
7094 attack_ship: 'http://wiki.en.grepolis.com/images/e/e6/Attack_ship_40x40.png',
7095 demolition_ship: 'http://wiki.en.grepolis.com/images/e/ec/Demolition_ship_40x40.png',
7096 small_transporter: 'http://wiki.en.grepolis.com/images/8/85/Small_transporter_40x40.png',
7097 trireme: 'http://wiki.en.grepolis.com/images/a/ad/Trireme_40x40.png',
7098 colonize_ship: 'http://wiki.en.grepolis.com/images/d/d1/Colonize_ship_40x40.png',
7099
7100 move_icon: 'https://gpall.innogamescdn.com/images/game/unit_overview/',
7101
7102 bordure: 'http://s1.directupload.net/images/140126/8y6pmetk.png'
7103 };
7104
7105 $('<div class="bb_def_chooser">' +
7106 '<div class="bbcode_box middle_center">' +
7107 '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div>' +
7108 '<div class="bbcode_box top_center"></div><div class="bbcode_box bottom_center"></div>' +
7109 '<div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>' +
7110 '<div class="bbcode_box middle_left"></div><div class="bbcode_box middle_right"></div>' +
7111 '<div class="bbcode_box content clearfix" style="padding:5px">' +
7112 '<div id="f_uni" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "det") + '</div></div><br><br>' +
7113 '<div id="f_prm" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "prm") + '</div></div><br><br>' +
7114 '<div id="f_sil" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "sil") + '</div></div><br><br>' +
7115 '<div id="f_mov" class="checkbox_new checked"><div class="cbx_icon"></div><div class="cbx_caption">' + getText("labels", "mov") + '</div></div><br><br>' +
7116 '<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>' +
7117 '</div></div></div>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
7118
7119 $('.bb_def_chooser').css({
7120 display: 'none',
7121 top: '38px',
7122 left: '510px',
7123 position: 'absolute',
7124 width: '190px',
7125 zIndex: 10000
7126 });
7127
7128 $(bbcodeBarId + " .bb_def_chooser .checkbox_new").click(function () {
7129 $(this).toggleClass("checked");
7130 });
7131
7132 $(bbcodeBarId + ' .def_form').toggleClick(function () {
7133 $(this).parent().find(".bb_def_chooser").get(0).style.display = "block";
7134 }, function () {
7135 $(this).parent().find(".bb_def_chooser").get(0).style.display = "none";
7136 });
7137
7138 $(bbcodeBarId + ' #dio_insert').click(function () {
7139 var textarea = $(textareaId).get(0), text = $(textarea).val(), troop_table = "", troop_img = "", troop_count = "", separator = "", move_table = "", landunit_sum = 0;
7140
7141 $('.def_form').click();
7142
7143 if ($('#f_uni').hasClass("checked")) {
7144 $('.units_land .unit, .units_naval .unit').each(function () {
7145 troop_img += separator + '[img]' + imgArray[this.className.split(" ")[1]] + '[/img]';
7146 troop_count += separator + '[center]' + $(this).find(".value").get(0).innerHTML + '[/center]';
7147 separator = "[||]";
7148 });
7149 } else {
7150 $('.units_land .unit').each(function () {
7151 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);
7152 if (def > 10) {
7153 landunit_sum += parseInt($(this).find(".value").get(0).innerHTML, 10) * uw.GameData.units[a].population * ((def > 20) ? 2 : 1);
7154 }
7155 });
7156 landunit_sum = (landunit_sum > 10000) ? ((Math.round(landunit_sum / 100)) / 10) + "k" : landunit_sum;
7157
7158 troop_img += '[img]' + imgArray.def_sum + '[/img]';
7159 troop_count += '[center]' + landunit_sum + '[/center]';
7160 separator = "[||]";
7161 $('.units_naval .unit').each(function () {
7162 troop_img += separator + '[img]' + imgArray[this.className.split(" ")[1]] + '[/img]';
7163 troop_count += separator + '[center]' + $(this).find(".value").get(0).innerHTML + '[/center]';
7164 });
7165 }
7166 if (troop_img !== "") {
7167 troop_table = "\n[table][**]" + troop_img + "[/**][**]" + troop_count + "[/**][/table]\n";
7168 }
7169
7170 var str = '[img]' + imgArray.bordure + '[/img]' +
7171 '\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' +
7172 //'[table][**][img]'+ imgArray.sup +'[/img][||]'+
7173 '[size=12][town]' + uw.ITowns.getTown(uw.Game.townId).getId() + '[/town] ([player]' + uw.Game.player_name + '[/player])[/size]' +
7174 //'[||][img]'+ imgArray['rev' + (uw.ITowns.getTown(uw.Game.townId).hasConqueror()?1:0)] +'[/img][/**][/table]'+
7175 '\n\n[i][b]' + getText("labels", "inf") + '[/b][/i]' + troop_table +
7176 '[table][*]' +
7177 '[img]' + imgArray.wall + '[/img][|]\n' +
7178 '[img]' + imgArray.tower + '[/img][|]\n' +
7179 '[img]' + imgArray.phalanx + '[/img][|]\n' +
7180 '[img]' + imgArray.ram + '[/img][|]\n' +
7181 ($('#f_prm').hasClass("checked") ? '[img]' + imgArray.commander + '[/img][|]\n' : ' ') +
7182 ($('#f_prm').hasClass("checked") ? '[img]' + imgArray.captain + '[/img][|]\n' : ' ') +
7183 ($('#f_prm').hasClass("checked") ? '[img]' + imgArray.priest + '[/img][|]\n' : ' ') +
7184 ($('#f_sil').hasClass("checked") ? '[center][img]' + imgArray.spy + '[/img][/center][|]\n' : ' ') +
7185 '[img]' + imgArray.pop + '[/img][|]\n' +
7186 '[img]' + imgArray[(uw.ITowns.getTown(uw.Game.townId).god() || "nogod")] + '[/img][/*]\n' +
7187 '[**][center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("wall") + '[/center][||]' +
7188 '[center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("tower") + '[/center][||]' +
7189 '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.phalanx ? '+' : '-') + '[/center][||]' +
7190 '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.ram ? '+' : '-') + '[/center][||]' +
7191 ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.commander >= uw.Timestamp.now()) ? '+' : '-') + '[/center][||]' : ' ') +
7192 ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.captain >= uw.Timestamp.now()) ? '+' : '-') + '[/center][||]' : ' ') +
7193 ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.priest >= uw.Timestamp.now()) ? '+' : '-') + '[/center][||]' : ' ') +
7194 ($('#f_sil').hasClass("checked") ? '[center]' + Math.round(uw.ITowns.getTown(uw.Game.townId).getEspionageStorage() / 1000) + 'k[/center][||]' : ' ') +
7195 '[center]' + uw.ITowns.getTown(uw.Game.townId).getAvailablePopulation() + '[/center][||]' +
7196 '[center]' + $('.gods_favor_amount').get(0).innerHTML + '[/center]' +
7197 '[/**][/table]';
7198
7199 var bb_count_str = parseInt(str.match(/\[/g).length, 10), bb_count_move = 0;
7200
7201 var i = 0;
7202 if ($('#f_mov').hasClass("checked")) {
7203 move_table += '\n[i][b]' + getText("labels", "mov") + '[/b][/i]\n[table]';
7204
7205 $('#toolbar_activity_commands').mouseover();
7206
7207 $('#toolbar_activity_commands_list .content .command').each(function () {
7208 var cl = $(this).children()[0].className.split(" ");
7209 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)) {
7210 move_table += (i % 1) ? "" : "[**]";
7211 i++;
7212 move_table += "[img]" + imgArray.move_icon + cl[2] + ".png[/img][||]";
7213 move_table += getArrivalTime($(this).children()[1].innerHTML) + (uw.Game.market_id === "de" ? " Uhr[||]" : " [||]");
7214 move_table += "[town]" + JSON.parse(atob($(this).children()[2].firstChild.href.split("#")[1])).id + "[/town]";
7215 move_table += (i % 1) ? "[||]" : "[/**]";
7216 }
7217 bb_count_move = parseInt(move_table.match(/\[/g).length, 10);
7218 });
7219 if ((bb_count_str + bb_count_move) > 480) {
7220 move_table += '[**]...[/**]';
7221 }
7222
7223 $('#toolbar_activity_commands').mouseout();
7224
7225 //console.log((bb_count_str + bb_count_move));
7226 move_table += (i % 1) ? "[/**]" : "";
7227 move_table += "[*][|][color=#800000][size=6][i] (" + getText("labels", "dev") + ": ±1s)[/i][/size][/color][/*][/table]\n";
7228 }
7229
7230 str += move_table + '[img]' + imgArray.bordure + '[/img]';
7231
7232
7233 $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + str + text.substring($(textarea).get(0).selectionEnd));
7234 });
7235 }
7236
7237 function getArrivalTime(duration_time) {
7238 /*
7239 var server_time = new Date((uw.Timestamp.server() + 7200) * 1000);
7240
7241 duration_time = duration_time.split(":");
7242
7243 s = server_time.getUTCSeconds() + parseInt(duration_time[2], 10);
7244 m = server_time.getUTCMinutes() + parseInt(duration_time[1], 10) + ((s>=60)? 1 : 0);
7245 h = server_time.getUTCHours() + parseInt(duration_time[0], 10) + ((m>=60)? 1 : 0);
7246 */
7247
7248 var server_time = $('.server_time_area').get(0).innerHTML.split(" ")[0].split(":"), arrival_time, s, m, h;
7249 duration_time = duration_time.split(":");
7250
7251 s = parseInt(server_time[2], 10) + parseInt(duration_time[2], 10);
7252 m = parseInt(server_time[1], 10) + parseInt(duration_time[1], 10) + ((s >= 60) ? 1 : 0);
7253 h = parseInt(server_time[0], 10) + parseInt(duration_time[0], 10) + ((m >= 60) ? 1 : 0);
7254
7255 s = s % 60;
7256 m = m % 60;
7257 h = h % 24;
7258
7259 s = ((s < 10) ? "0" : "") + s;
7260 m = ((m < 10) ? "0" : "") + m;
7261 h = ((h < 10) ? "0" : "") + h;
7262
7263 arrival_time = h + ":" + m + ":" + s;
7264
7265 return arrival_time;
7266 }
7267
7268
7269 /*******************************************************************************************************************************
7270 * Smiley box
7271 * ----------------------------------------------------------------------------------------------------------------------------
7272 * | â— Display of a smiley selection box for text input fields (forum, messages, notes):
7273 * | â— Used smileys: http://www.greensmilies.com/smilie-album/
7274 * | + Own Grepolis smileys
7275 * ----------------------------------------------------------------------------------------------------------------------------
7276 *******************************************************************************************************************************/
7277
7278 var smileyArray = {};
7279
7280 var SmileyBox = {
7281 loading_error: false, isHalloween: false, isXmas: false, isForum: $(".editor_textbox_container").get(0),
7282
7283 activate: function () {
7284 $('<style id="dio_smiley">' +
7285 '.smiley_button { cursor:pointer; margin:3px 2px 2px 2px; } ' +
7286
7287 '.smiley_box.game { z-index:5000; position:absolute; top:27px; left:430px; min-width:300px; display:none; } ' +
7288
7289 // Smiley categories
7290 '.smiley_box .box_header { display: table; width: 100%; text-align:center; } ' +
7291 '.smiley_box .group { display:table-cell; color: #0c450c; cursor: pointer; font-weight:bold; padding: 0px 2px 0px 2px; } ' +
7292 '.smiley_box .group.active { color: #089421; text-decoration:underline;} ' +
7293 '.smiley_box .group:hover { color: #14999E; } ' + // #11AD6C
7294
7295 // Special smiley categories
7296 '.smiley_box .halloween { color: #E25E00; } ' +
7297 '.smiley_box .xmas { color: darkred; } ' +
7298
7299 '.smiley_box hr { margin:3px 0px 0px 0px; color:#086b18; border:1px solid; } ' +
7300
7301 // Smilies
7302 '.smiley_box .box_content { overflow: hidden; } ' +
7303 '.smiley_box .box_content .smiley { border: 1px solid rgba(0,0,0,0); border-radius: 5px;} ' +
7304 '.smiley_box .box_content .smiley:hover { background: rgba(8, 148, 77, 0.2); border: 1px solid rgba(0, 128, 0, 0.5); } ' +
7305
7306 // Smiley page link
7307 '.smiley_box .box_footer { text-align:center; margin-top:4px; } ' +
7308 '.smiley_box a:link, .smiley_box a:visited { color: #086b18; font-size: 0.7em; } ' +
7309 '.smiley_box a:hover { color: #14999E; } ' +
7310
7311 // TODO Forum ...
7312 '.smiley_box.forum .box_header_left { float:left; } ' +
7313 //'.smiley_box.forum .group { padding-right: 10px; } '+
7314 '.smiley_box.forum .box_header_right { text-align:right; margin-top:2px; } ' +
7315
7316 '.smiley_box.forum { max-height:90px; margin-left:5px; width:99%; min-height:10px; } ' +
7317 '.smiley_box.forum .box_content { overflow:overlay; min-height:70px; margin-bottom:10px; } ' +
7318
7319 '.smiley_box.forum a:link, .smiley_box.forum a:visited { font-size: 1em; } ' +
7320
7321 '</style>').appendTo('head');
7322
7323
7324 // Smiley categories
7325 smileyArray.button = ["rollsmiliey", "smile"];
7326
7327 smileyArray.standard = [
7328 "smilenew", "grin", "lol", "neutral_new", "afraid", "freddus_pacman", "auslachen2", "kolobok-sanduhr", "bussi2", "winken4", "flucht2", "panik4", "ins-auge-stechen",
7329 "seb_zunge", "fluch4_GREEN", "baby_junge2", "blush-reloaded6", "frown", "verlegen", "blush-pfeif", "stevieh_rolleyes", "daumendreh2", "baby_taptap",
7330 "sadnew", "hust", "confusednew", "idea2", "irre", "irre4", "sleep", "candle", "nicken", "no_sad",
7331 "thumbs-up_new", "thumbs-down_new", "bravo2", "oh-no2", "kaffee2", "drunk", "saufen", "freu-dance", "hecheln", "headstand", "rollsmiliey", "eazy_cool01", "motz", "cuinlove", "biggrin"
7332 ];
7333 smileyArray.nature = [
7334 "dinosaurier07", "flu-super-gau", "ben_cat", "schwein", "hundeleine01", "blume", "ben_sharky", "ben_cow", "charly_bissig", "gehirnschnecke_confused", "mttao_fische", "mttao_angler",
7335 "insel", "fliegeschnappen", "spider", /* Spinne */ "shipwrecked", /* Schiffbrüchiger */ "plapperhase", "ben_dumbo"
7336 ];
7337 smileyArray.grepolis = [
7338 "mttao_wassermann", "hera", /* Hera */ "medusa", /* Medusa */ "manticore", /* Mantikor */ "cyclops", /* Zyklop */
7339 "minotaur", /* Minotaurus */ "pegasus", /* Pegasus */ "hydra", /* Hydra */
7340 "silvester_cuinlove", "mttao_schuetze", "kleeblatt2", "wallbash", /* "glaskugel4", */ "musketiere_fechtend", /* "krone-hoch",*/ "viking", // Wikinger
7341 "mttao_waage2", "steckenpferd", /* "kinggrin_anbeten2", */ "grepolove", /* Grepo Love */ "skullhaufen", "pferdehaufen" // "i/ckajscggscw4s2u60"
7342 ];
7343 smileyArray.people = [
7344 "seb_hut5", "opa_boese2", "star-wars-yoda1-gruen", "hexefliegend", "snob", "seb_detektiv_ani", "seb_cowboy", "devil", "segen", "pirat5", "borg", "hexe3b",
7345 "pharaoh", "hippie", "eazy_polizei", "stars_elvis", "mttao_chefkoch", "nikolaus", "pirate3_biggrin", "batman_skeptisch", "tubbie1", "tubbie2", "tubbie3", "tubbie4"
7346 ];
7347 smileyArray.other = [
7348 "steinwerfen", "herzen02", "scream-if-you-can", "kolobok", "headbash", "liebeskummer", "bussi", "brautpaar-reis", "grab-schaufler2", "boxen2", "aufsmaul",
7349 "sauf", "mttao_kehren", "sm", "weckruf", "klugscheisser2", "karte2_rot", "dagegen", "party", "dafuer", "outofthebox", "pokal_gold", "koepfler", "transformer"
7350 ];
7351
7352 // TODO: HolidayChecker benutzen!
7353 SmileyBox.checkHolidaySeason();
7354
7355 if (SmileyBox.isHalloween) {
7356 smileyArray.halloween = [
7357 "zombies_alien", "zombies_lol", "zombies_rolleyes", "zombie01", "zombies_smile", "zombie02", "zombies_skeptisch", "zombies_eek", "zombies_frown",
7358 "scream-if-you-can", "geistani", "pfeildurchkopf01", "grab-schaufler", "kuerbisleuchten", "mummy3",
7359 "kuerbishaufen", "halloweenskulljongleur", "fledermausvampir", "frankenstein_lol", "halloween_confused", "zombies_razz",
7360 "halloweenstars_freddykrueger", "zombies_cool", "geist2", "fledermaus2", "halloweenstars_dracula"
7361 // "batman" "halloweenstars_lastsummer"
7362 ];
7363 }
7364 if (SmileyBox.isXmas) {
7365 smileyArray.xmas = [
7366 "schneeballwerfen", "schneeball", "xmas4_advent4", "nikolaus", "weihnachtsmann_junge", "schneewerfen_wald", "weihnachtsmann_nordpol", "xmas_kilroy_kamin",
7367 "xmas4_laola", "xmas4_aufsmaul", "xmas3_smile", "xmas4_paketliebe", "mttao_ruprecht_peitsche", "3hlkoenige", "santa", "xmas4_hurra2", "weihnachtsgeschenk2", "fred_weihnachten-ostern"
7368 //"dafuer", "outofthebox", "pokal_gold", "koepfler", "transformer"
7369 ];
7370 }
7371
7372 //smileyArray.other = smileyArray.halloween.slice();
7373
7374 // Forum: Extra smiley
7375 if (SmileyBox.isForum) {
7376 smileyArray.grepolis.push("i/ckajscggscw4s2u60"); // Pacman
7377 smileyArray.grepolis.push("i/cowqyl57t5o255zli"); // Bugpolis
7378 smileyArray.grepolis.push("i/cowquq2foog1qrbee"); // Inno
7379 }
7380
7381 SmileyBox.loadSmileys();
7382 },
7383 deactivate: function () {
7384 $('#dio_smiley').remove();
7385 },
7386 checkHolidaySeason: function () {
7387 // TODO: HolidaySpecial-Klasse stattdessen benutzen
7388 var daystamp = 1000 * 60 * 60 * 24, today = new Date((new Date()) % (daystamp * (365 + 1 / 4))), // without year
7389
7390 // Halloween-Smileys ->15 days
7391 halloween_start = daystamp * 297, // 25. Oktober
7392 halloween_end = daystamp * 321, // 8. November
7393 // Xmas-Smileys -> 28 Tage
7394 xmas_start = daystamp * 334, // 1. Dezember
7395 xmas_end = daystamp * 361; // 28. Dezember
7396
7397 SmileyBox.isHalloween = (today >= halloween_start) ? (today <= halloween_end) : false;
7398
7399 SmileyBox.isXmas = (today >= xmas_start) ? (today <= xmas_end) : false;
7400 },
7401 // preload images
7402 loadSmileys: function () {
7403 // Replace german sign smilies
7404 if (LID !== "de") {
7405 smileyArray.other[17] = "dagegen2";
7406 smileyArray.other[19] = "dafuer2";
7407 }
7408
7409 for (var e in smileyArray) {
7410 if (smileyArray.hasOwnProperty(e)) {
7411 for (var f in smileyArray[e]) {
7412 if (smileyArray[e].hasOwnProperty(f)) {
7413 var src = smileyArray[e][f];
7414
7415 smileyArray[e][f] = new Image();
7416 smileyArray[e][f].className = "smiley";
7417
7418 if (src.substring(0, 2) == "i/") {
7419 smileyArray[e][f].src = "http://666kb.com/" + src + ".gif";
7420 } else {
7421 if (SmileyBox.loading_error == false) {
7422 smileyArray[e][f].src = "https://diotools.de/images/smileys/"+ e +"/smiley_emoticons_" + src + ".gif";
7423 //console.debug("Smiley", e);
7424 } else {
7425 smileyArray[e][f].src = 'http://s1.directupload.net/images/140128/93x3p4co.gif';
7426 }
7427 }
7428 smileyArray[e][f].onerror = function () {
7429 this.src = 'http://s1.directupload.net/images/140128/93x3p4co.gif';
7430 };
7431 }
7432 }
7433 }
7434 }
7435 },
7436
7437 // Forum smilies
7438 changeForumEditorLayout: function () {
7439 $('.blockrow').css({border: "none"});
7440
7441 // Subject/Title
7442 $($('.section div label[for="title"]').parent()).css({float: "left", width: "36%", marginRight: "20px"});
7443 $($('.section div label[for="subject"]').parent()).css({float: "left", width: "36%", marginRight: "20px"});
7444
7445 $('.section div input').eq(0).css({marginBottom: "-10px", marginTop: "10px"});
7446 $('#display_posticon').remove();
7447
7448 // Posticons
7449 $('.posticons table').css({width: "50%" /* marginTop: "-16px"*/});
7450 $('.posticons').css({marginBottom: "-16px"});
7451 $('.posticons').insertAfter($('.section div label[for="title"]').parent());
7452 $('.posticons').insertAfter($('.section div label[for="subject"]').parent());
7453 // Posticons hint
7454 $('.posticons p').remove();
7455 // Posticons: No Icon - radio button
7456 $(".posticons [colspan='14']").parent().replaceWith($(".posticons [colspan='14']"));
7457 $(".posticons [colspan='14']").children().wrap("<nobr></nobr>");
7458 $(".posticons [colspan='14']").appendTo('.posticons tr:eq(0)');
7459 $(".posticons [colspan='4']").remove();
7460 },
7461
7462 addForum: function () {
7463 $('<div class="smiley_box forum"><div>' +
7464 '<div class="box_header_left">' +
7465 '<span class="group standard active">' + getText("labels", "std") + '</span>' +
7466 '<span class="group grepolis">' + getText("labels", "gre") + '</span>' +
7467 '<span class="group nature">' + getText("labels", "nat") + '</span>' +
7468 '<span class="group people">' + getText("labels", "ppl") + '</span>' +
7469 '<span class="group other">' + getText("labels", "oth") + '</span>' +
7470 (SmileyBox.isHalloween ? '<span class="group halloween">' + getText("labels", "hal") + '</span>' : '') +
7471 (SmileyBox.isXmas ? '<span class="group xmas">' + getText("labels", "xma") + '</span>' : '') +
7472 '</div>' +
7473 '<div class="box_header_right"><a class="smiley_link" href="http://www.greensmilies.com/smilie-album/" target="_blank">WWW.GREENSMILIES.COM</a></div>' +
7474 '<hr>' +
7475 '<div class="box_content" style="overflow: hidden;"><hr></div>' +
7476 '</div></div><br>').insertAfter(".texteditor");
7477
7478 SmileyBox.addSmileys("standard", "");
7479
7480 $('.group').click(function () {
7481 $('.group.active').removeClass("active");
7482 $(this).addClass("active");
7483 // Change smiley group
7484 SmileyBox.addSmileys(this.className.split(" ")[1], "");
7485 });
7486 },
7487
7488 // add smiley box
7489 add: function (e) {
7490 var bbcodeBarId = "";
7491 switch (e) {
7492 case "/alliance_forum/forum":
7493 bbcodeBarId = "#forum";
7494 break;
7495 case "/message/forward":
7496 bbcodeBarId = "#message_bbcodes";
7497 break;
7498 case "/message/new":
7499 bbcodeBarId = "#message_bbcodes";
7500 break;
7501 case "/message/view":
7502 bbcodeBarId = "#message_bbcodes";//setWonderIconsOnMap
7503 break;
7504 case "/player_memo/load_memo_content":
7505 bbcodeBarId = "#memo_edit"; // old notes
7506 break;
7507 case "/frontend_bridge/fetch":
7508 bbcodeBarId = ".notes_container"; // TODO: new notes
7509 break;
7510 }
7511 if (($(bbcodeBarId + ' #emots_popup_7').get(0) || $(bbcodeBarId + ' #emots_popup_15').get(0)) && PID == 84367) {
7512 $(bbcodeBarId + " .bb_button_wrapper").get(0).lastChild.remove();
7513 }
7514 $('<img class="smiley_button" src="http://www.greensmilies.com/smile/smiley_emoticons_smile.gif">').appendTo(bbcodeBarId + ' .bb_button_wrapper');
7515
7516 $('<div class="smiley_box game">' +
7517 '<div class="bbcode_box middle_center"><div class="bbcode_box middle_right"></div><div class="bbcode_box middle_left"></div>' +
7518 '<div class="bbcode_box top_left"></div><div class="bbcode_box top_right"></div><div class="bbcode_box top_center"></div>' +
7519 '<div class="bbcode_box bottom_center"></div><div class="bbcode_box bottom_right"></div><div class="bbcode_box bottom_left"></div>' +
7520 '<div class="box_header">' +
7521 '<span class="group standard active">' + getText("labels", "std") + '</span>' +
7522 '<span class="group grepolis">' + getText("labels", "gre") + '</span>' +
7523 '<span class="group nature">' + getText("labels", "nat") + '</span>' +
7524 '<span class="group people">' + getText("labels", "ppl") + '</span>' +
7525 '<span class="group ' + (SmileyBox.isHalloween ? 'halloween' : (SmileyBox.isXmas ? 'xmas' : 'other')) + '">' + getText("labels", (SmileyBox.isHalloween ? 'hal' : (SmileyBox.isXmas ? 'xma' : 'oth'))) + '</span>' +
7526 '</div>' +
7527 '<hr>' +
7528 '<div class="box_content"></div>' +
7529 '<hr>' +
7530 '<div class="box_footer"><a href="http://www.greensmilies.com/smilie-album/" target="_blank">WWW.GREENSMILIES.COM</a></div>' +
7531 '</div>').appendTo(bbcodeBarId + ' .bb_button_wrapper');
7532
7533
7534 $(bbcodeBarId + ' .group').click(function () {
7535 $('.group.active').removeClass("active");
7536 $(this).addClass("active");
7537 // Change smiley group
7538 SmileyBox.addSmileys(this.className.split(" ")[1], "#" + $(this).closest('.bb_button_wrapper').parent().get(0).id);
7539 });
7540
7541 SmileyBox.addSmileys("standard", bbcodeBarId);
7542
7543 // smiley box toggle
7544 $(bbcodeBarId + " .smiley_button").toggleClick(
7545 function () {
7546 this.src = smileyArray.button[0].src;
7547 $(this).closest('.bb_button_wrapper').find(".smiley_box").get(0).style.display = "block";
7548 },
7549 function () {
7550 this.src = smileyArray.button[1].src;
7551 $(this).closest('.bb_button_wrapper').find(".smiley_box").get(0).style.display = "none";
7552 }
7553 );
7554 },
7555
7556 // insert smileys from arrays into smiley box
7557 addSmileys: function (type, bbcodeBarId) {
7558 // reset smilies
7559 if ($(bbcodeBarId + " .box_content").get(0)) {
7560 $(bbcodeBarId + " .box_content").get(0).innerHTML = '';
7561 }
7562 // add smilies
7563 for (var e in smileyArray[type]) {
7564 if (smileyArray[type].hasOwnProperty(e)) {
7565 $(smileyArray[type][e]).clone().appendTo(bbcodeBarId + " .box_content");
7566 //$('<img class="smiley" src="' + smileyArray[type][e].src + '" alt="" />').appendTo(bbcodeBarId + " .box_content");
7567 }
7568 }
7569 $('.smiley').css({margin: '0px', padding: '2px', maxHeight: '35px', cursor: 'pointer'});
7570
7571 $(bbcodeBarId + " .box_content .smiley").click(function () {
7572 var textarea;
7573 if (uw.location.pathname.indexOf("game") >= 0) {
7574 // hide smiley box
7575 $(this).closest('.bb_button_wrapper').find(".smiley_button").click();
7576 // find textarea
7577 textarea = $(this).closest('.gpwindow_content').find("textarea").get(0);
7578 } else {
7579
7580 if ($('.editor_textbox_container').get(0)) {
7581 textarea = $('.editor_textbox_container .cke_contents textarea').get(0);
7582 } else {
7583 $(this).appendTo('iframe .forum');
7584 }
7585 }
7586 var text = $(textarea).val();
7587 $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + "[img]" + this.src + "[/img]" + text.substring($(textarea).get(0).selectionEnd));
7588 });
7589 }
7590 };
7591
7592
7593 /*******************************************************************************************************************************
7594 * Biremes counter
7595 * ----------------------------------------------------------------------------------------------------------------------------
7596 * | â— Incremental update when calling a city (experimental, especially intended for siege worlds)
7597 * ----------------------------------------------------------------------------------------------------------------------------
7598 * @deprecated
7599 * *****************************************************************************************************************************/
7600
7601 // TODO: Altes Feature entfernen
7602 var BiremeCounter = {
7603 activate: function () {
7604 $(".picomap_container").prepend("<div id='available_units'><div id='bi_count'></div></div>");
7605
7606 $('.picomap_overlayer').tooltip(getText("options", "bir")[0]);
7607 BiremeCounter.update();
7608
7609 // Style
7610 $('<style id="dio_bireme_counter">' +
7611 '#available_units { background: url(https://gpall.innogamescdn.com/images/game/units/units_sprite_90x90_compressed.jpg); height:90px;' +
7612 'width:90px; position: relative; margin: 5px 28px 0px 28px; background-position: -270px 0px; } ' +
7613 '#bi_count { color:#826021; position:relative; top:28px; font-style:italic; width:79px; } ' +
7614 '#sea_id { background: none; font-size:25px; cursor:default; height:50px; width:50px; position:absolute; top:70px; left:157px; z-index: 30; } ' +
7615 '</style>').appendTo('head');
7616
7617 // fs_count: color: #FFC374;position: relative;top: 30px;font-style: italic;width: 101px;text-shadow: 1px 1px 0px rgb(69, 0, 0);
7618 // manti: background-position: -1350px 180px;
7619 // manti-count: color: #ECD181;position: relative;top: 48px;font-style: italic;width: 52px;text-shadow: 2px 2px 0px rgb(0, 0, 0);
7620 // medusa:-1440px 182px;
7621 // med-count: color: #DEECA4;position: relative;top: 50px;font-style: italic;width: 55px;text-shadow: 2px 2px 0px rgb(0, 0, 0);
7622
7623 // Set Sea-ID beside the bull eye
7624 $('#sea_id').prependTo('#ui_box');
7625 },
7626 deactivate: function () {
7627 $('#available_units').remove();
7628 $('#dio_bireme_counter').remove();
7629 $('#sea_id').appendTo('.picomap_container');
7630 },
7631 save: function () {
7632 saveValue(WID + "_biremes", JSON.stringify(biriArray));
7633 },
7634 update: function () {
7635 var sum = 0, e;
7636 if ($('#bi_count').get(0)) {
7637 for (e in biriArray) {
7638 if (biriArray.hasOwnProperty(e)) {
7639 if (!uw.ITowns.getTown(e)) { // town is no longer in possession of user
7640 delete biriArray[e];
7641 BiremeCounter.save();
7642 } else {
7643 sum += parseInt(biriArray[e], 10);
7644 }
7645 }
7646 }
7647
7648 sum = sum.toString();
7649 var str = "", fsize = ['1.4em', '1.2em', '1.15em', '1.1em', '1.0em'], i;
7650
7651 for (i = 0; i < sum.length; i++) {
7652 str += "<span style='font-size:" + fsize[i] + "'>" + sum[i] + "</span>";
7653 }
7654 $('#bi_count').get(0).innerHTML = "<b>" + str + "</b>";
7655 }
7656 },
7657 get: function () {
7658 var biremeIn = parseInt(uw.ITowns.getTown(uw.Game.townId).units().bireme, 10),
7659 biremeOut = parseInt(uw.ITowns.getTown(uw.Game.townId).unitsOuter().bireme, 10);
7660 if (isNaN(biremeIn)) biremeIn = 0;
7661 if (isNaN(biremeOut)) biremeOut = 0;
7662 if (!biriArray[uw.Game.townId] || biriArray[uw.Game.townId] < (biremeIn + biremeOut)) {
7663 biriArray[uw.Game.townId] = biremeIn;
7664 }
7665 BiremeCounter.update();
7666 BiremeCounter.save();
7667 },
7668 getDocks: function () {
7669 var windowID = uw.BuildingWindowFactory.getWnd().getID(),
7670 biremeTotal = parseInt($('#gpwnd_' + windowID + ' #unit_order_tab_bireme .unit_order_total').get(0).innerHTML, 10);
7671
7672 if (!isNaN(biremeTotal)) biriArray[uw.Game.townId] = biremeTotal;
7673 BiremeCounter.update();
7674 BiremeCounter.save();
7675 },
7676 getAgora: function () {
7677 var biremeTotal = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().bireme, 10);
7678 if (isNaN(biremeTotal)) biremeTotal = 0;
7679
7680 $('#units_beyond_list .bireme').each(function () {
7681 biremeTotal += parseInt(this.children[0].innerHTML, 10);
7682 });
7683 biriArray[uw.Game.townId] = biremeTotal;
7684 BiremeCounter.update();
7685 BiremeCounter.save();
7686 }
7687 };
7688
7689 /*******************************************************************************************************************************
7690 * Favor Popup
7691 * ----------------------------------------------------------------------------------------------------------------------------
7692 * | â— Improved favor popup
7693 * ----------------------------------------------------------------------------------------------------------------------------
7694 *******************************************************************************************************************************/
7695 var FavorPopup = {
7696 godArray: {
7697 zeus: '0px',
7698 hera: '-152px',
7699 poseidon: '-101px',
7700 athena: '-50px',
7701 hades: '-203px',
7702 artemis: '-305px'
7703 }, godImg: (new Image()).src = "https://diotools.de/images/game/gods.png",
7704
7705 activate: function () {
7706 $('.gods_favor_button_area, #favor_circular_progress').bind('mouseover mouseout', function () {
7707 return false;
7708 });
7709 $('.gods_area').bind('mouseover', function () {
7710 FavorPopup.setFavorPopup();
7711 });
7712 },
7713
7714 deactivate: function () {
7715 $('.gods_favor_button_area, #favor_circular_progress').unbind('mouseover mouseout');
7716 $('.gods_area').unbind('mouseover');
7717 },
7718
7719 setFavorPopup: function () {
7720 var pic_row = "", fav_row = "", prod_row = "", tooltip_str;
7721
7722 for (var g in FavorPopup.godArray) {
7723 if (FavorPopup.godArray.hasOwnProperty(g)) {
7724 if (uw.ITowns.player_gods.attributes.temples_for_gods[g]) {
7725 pic_row += '<td><div style="width:50px;height:51px;background:url(' + FavorPopup.godImg + ');background-position: 0px ' + FavorPopup.godArray[g] + ';"></td>';
7726 fav_row += '<td class="bold" style="color:blue">' + uw.ITowns.player_gods.attributes[g + "_favor"] + '</td>';
7727 prod_row += '<td class="bold">' + uw.ITowns.player_gods.attributes.production_overview[g].production + '</td>';
7728 }
7729 }
7730 }
7731 tooltip_str = $('<table><tr><td></td>' + pic_row + '</tr>' +
7732 '<tr align="center"><td><img src="https://gpall.innogamescdn.com/images/game/res/favor.png"></td>' + fav_row + '</tr>' +
7733 '<tr align="center"><td>+</td>' + prod_row + '</tr>' +
7734 '</table>');
7735
7736 $('.gods_favor_button_area, #favor_circular_progress').tooltip(tooltip_str);
7737 }
7738 };
7739
7740 /*******************************************************************************************************************************
7741 * GUI Optimization
7742 * ----------------------------------------------------------------------------------------------------------------------------
7743 * | â— Modified spell box (smaller, moveable & position memory)
7744 * | â— Larger taskbar and minimize daily reward-window on startup
7745 * | â— Modify chat
7746 * | â— Improved display of troops and trade activity boxes (movable with position memory on startup)
7747 * ----------------------------------------------------------------------------------------------------------------------------
7748 *******************************************************************************************************************************/
7749
7750 var Spellbox = {
7751 observe: function () {
7752 $.Observer(uw.GameEvents.ui.layout_gods_spells.rendered).subscribe('DIO_SPELLBOX_CHANGE_OPEN', function () {
7753 if (spellbox.show == false) {
7754 spellbox.show = true;
7755 saveValue("spellbox", JSON.stringify(spellbox));
7756 }
7757 Spellbox.change();
7758 });
7759 $.Observer(uw.GameEvents.ui.layout_gods_spells.state_changed).subscribe('DIO_SPELLBOX_CLOSE', function () {
7760 spellbox.show = false;
7761 saveValue("spellbox", JSON.stringify(spellbox));
7762 });
7763
7764 // GRCRT Bug-Fix
7765 if(typeof(RepConv) !== "undefined") {
7766 $.Observer(uw.GameEvents.ui.layout_gods_spells.rendered).unsubscribe('GRCRT_GRC_ui_layout_gods_spells_rendered');
7767
7768 $.Observer(uw.GameEvents.ui.layout_gods_spells.rendered).subscribe('GRCRT_GRC_ui_layout_gods_spells_rendered', function () {
7769 // PlayerGods doesn't exists at game start and the function would call an error
7770 if (typeof(RepConv.models.PlayerGods) !== "undefined") {
7771 RepConvTool.loadPower();
7772 }
7773 });
7774 }
7775 },
7776
7777 activate: function () {
7778 Spellbox.observe();
7779 Spellbox.change();
7780
7781 $('<style id="dio_spellbox_style" type="text/css">' +
7782 // Don't hide hero box, unit time box and hero coin box from GRC
7783 '#ui_box .nui_right_box { overflow: visible; } ' +
7784 // Hide negative spells
7785 '#ui_box .bolt, #ui_box .earthquake, #ui_box .pest { display: none } ' +
7786 // Change spell order
7787 '#ui_box .god_container { float: left } ' +
7788 '#ui_box .god_container[data-god_id="zeus"], #ui_box .god_container[data-god_id="athena"] { float: none } ' +
7789 // Remove background
7790 '#ui_box .powers_container { background: none !important } ' +
7791 // Hide god titles
7792 '#ui_box .content .title { display: none !important } ' +
7793 // Hide border elements
7794 '#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 } ' +
7795 // Layout
7796 '#ui_box .gods_area { height:150px } ' +
7797
7798 '#ui_box .gods_spells_menu { width: 134px; position:absolute; z-index:5000; padding:30px 0px 0px -4px } ' +
7799 '#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 } ' +
7800
7801 '#ui_box .nui_units_box { display:block; margin-top:-8px; position:relative } ' +
7802 '#ui_box .nui_units_box .bottom_ornament { margin-top:-28px; position: relative } ' +
7803 '</style>').appendTo('head');
7804
7805 // Draggable Box
7806 $("#ui_box .gods_spells_menu").draggable({
7807 containment: "body",
7808 distance: 10,
7809 snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, #island_quests_overview",
7810 opacity: 0.7,
7811 stop: function () {
7812 spellbox.top = this.style.top;
7813 spellbox.left = this.style.left;
7814
7815 saveValue("spellbox", JSON.stringify(spellbox));
7816 }
7817 });
7818 $("#ui_box .gods_spells_menu").before($('#ui_box .nui_units_box'));
7819
7820 // Position
7821 $('#ui_box .gods_spells_menu').css({
7822 left: spellbox.left,
7823 top: spellbox.top
7824 });
7825
7826 // Active at game start?
7827 if (spellbox.show && !$('#ui_box .btn_gods_spells').hasClass('active')) {
7828 $('#ui_box .btn_gods_spells').click();
7829 }
7830 },
7831 deactivate: function () {
7832 $('#ui_box .gods_spells_menu').draggable('destroy');
7833
7834 // Position
7835 $('#ui_box .gods_spells_menu').css({
7836 left: "auto",
7837 top: "150px"
7838 });
7839
7840 //$("#ui_box .gods_spells_menu").appendTo('gods_area'); // ?
7841
7842 $('#dio_spellbox_style').remove();
7843
7844 $.Observer(GameEvents.ui.layout_gods_spells.rendered).unsubscribe('DIO_SPELLBOX_CHANGE_OPEN');
7845 $.Observer(GameEvents.ui.layout_gods_spells.state_changed).unsubscribe('DIO_SPELLBOX_CLOSE');
7846 },
7847
7848 change: function () {
7849 //console.log("Unitsbox: "+ $(".nui_units_box").height());
7850 //console.log("Spellbox: "+ $(".gods_spells_menu").height());
7851
7852 // Change spell order
7853 $('#ui_box .god_container[data-god_id="poseidon"]').prependTo('#ui_box .gods_spells_menu .content');
7854 $('#ui_box .god_container[data-god_id="athena"]').appendTo('#ui_box .gods_spells_menu .content');
7855 $('#ui_box .god_container[data-god_id="artemis"]').appendTo('#ui_box .gods_spells_menu .content');
7856 }
7857
7858 };
7859
7860
7861 // Minimize Daily reward window on startup
7862 function minimizeDailyReward() {
7863 /*
7864 $.Observer(uw.GameEvents.window.open).subscribe('DIO_WINDOW', function(u,dato){});
7865 $.Observer(uw.GameEvents.window.reload).subscribe('DIO_WINDOW2', function(f){});
7866 */
7867 if (MutationObserver) {
7868 var startup = new MutationObserver(function (mutations) {
7869 mutations.forEach(function (mutation) {
7870 if (mutation.addedNodes[0]) {
7871 if ($('.daily_login').get(0)) { // && !uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).isMinimized()
7872 $('.daily_login').find(".minimize").click();
7873 //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).minimize();
7874 }
7875 }
7876 });
7877 });
7878 startup.observe($('body').get(0), {attributes: false, childList: true, characterData: false});
7879
7880 setTimeout(function () {
7881 startup.disconnect();
7882 }, 3000);
7883 }
7884 }
7885
7886 // Larger taskbar
7887 var Taskbar = {
7888 activate: function () {
7889 $('.minimized_windows_area').get(0).style.width = "150%";
7890 $('.minimized_windows_area').get(0).style.left = "-25%";
7891 },
7892 deactivate: function () {
7893 $('.minimized_windows_area').get(0).style.width = "100%";
7894 $('.minimized_windows_area').get(0).style.left = "0%";
7895 }
7896 };
7897
7898 // Hide fade out buttons
7899 function hideNavElements() {
7900 if (Game.premium_features.curator <= Timestamp.now()) {
7901 $('.nav').each(function () {
7902 this.style.display = "none";
7903 });
7904 }
7905 }
7906
7907 /*******************************************************************************************************************************
7908 * Chat
7909 *******************************************************************************************************************************/
7910
7911 var Chat = {
7912 user_colors : {},
7913
7914 delay : 10000,
7915
7916 timestamp : 0,
7917
7918 isWindowFocused : true,
7919
7920 isActivated : false,
7921
7922 isOpened : false,
7923
7924 activate : function(){
7925
7926 Chat.isActivated = true;
7927
7928 Chat.isOpened = true;
7929
7930 $('<style id="dio_chat_style">'+
7931 '#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; }'+
7932 '#dio_chat.resize { transition: left 0s; }'+
7933
7934 '#dio_chat .slider { width:100%; height: 6px; top:0; right:1px; position:absolute; margin-left:-8px; cursor: row-resize; }'+
7935
7936 '#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; }'+
7937 '#dio_chat .messagebox .time { float:left; color: #686; }'+
7938 '#dio_chat .messagebox .user { float:left; }'+
7939 '#dio_chat .messagebox .text { word-break: break-word; color: #797; }'+
7940
7941 '#dio_chat .messagebox .welcome .text { color: rgb(200,220,200); }'+
7942
7943 '#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; }'+
7944 '#dio_chat .togglebutton .top { height:4px; width:24px; background: url(https://diotools.de/images/game/button_sprite_vertical.png) 0px -1px; position:absolute;}'+
7945 '#dio_chat .togglebutton:hover .top { background-position: -25px -1px; }'+
7946 '#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; }'+
7947 '#dio_chat .togglebutton:hover .bottom { background-position: -25px 4px; }'+
7948 '#dio_chat .togglebutton .middle { height:100%; width:24px; background: url(https://diotools.de/images/game/button_sprite_vertical.png) -50px 0px; }'+
7949 '#dio_chat .togglebutton:hover .middle { background-position: -75px 0px; }'+
7950 '#dio_chat .togglebutton .arrow { position:absolute; left:6px; top:42.5%; }'+
7951
7952 '#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; }'+
7953
7954 '#dio_chat input { background: rgba(0, 0, 0, 0.5); color: white; border: 0px none; padding: 8px; width: 100%; border-right: 1px solid darkgreen; }'+
7955 '#dio_chat input:hover { background: rgba(0, 0, 10, 0.4); }'+
7956 '#dio_chat input:focus { background: rgba(0, 0, 10, 0.4); }'+
7957 '#dio_chat input::placeholder, '+
7958 '#dio_chat input::-webkit-input-placeholder, '+
7959 '#dio_chat input::-moz-placeholder, ' +
7960 '#dio_chat input:-ms-input-placeholder, '+
7961 '#dio_chat input:-moz-placeholder { color: black; }'+
7962
7963 // Chat im Menü ausblenden
7964 '.nui_main_menu ul { height:auto !important; }'+
7965 '.nui_main_menu li.chat { display:none !important; }'+
7966
7967 '#grcgrc { display:none }'+
7968
7969 '</style>').appendTo('head');
7970
7971 $('<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");
7972
7973 $('<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");
7974
7975 $('<div class="togglebutton"><div class="top"></div><div class="middle"><div class="arrow">â—„</div></div><div class="bottom"></div></div>').appendTo("#dio_chat");
7976
7977 // Texteingabe
7978 $('#dio_chat input').keypress(function(e) {
7979
7980 if (e.keyCode === 13) {
7981
7982 var _time = $('.server_time_area').get(0).innerHTML.split(" ")[0];
7983
7984 var _message = $(this).val();
7985
7986 if(_message.length > 0) {
7987
7988 Chat.sendMessage(_message);
7989
7990 $(this).val('');
7991 }
7992
7993 }
7994 });
7995
7996 /*
7997 $('#dio_chat').draggable({
7998 containment: "body",
7999 distance: 10,
8000 snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, #island_quests_overview",
8001 opacity: 0.7,
8002 stop: function () {}
8003 });
8004 */
8005
8006 // Ein-/Ausblenden der Chatbox
8007 $('#dio_chat .togglebutton').toggleClick(
8008 function () {
8009
8010 var x = -($(window).width() * 0.25 + 16);
8011
8012 $('#dio_chat').css("left", x);
8013
8014 setTimeout(function(){
8015 $('#dio_chat .togglebutton .arrow').get(0).innerHTML = "â–º";
8016 },1300);
8017
8018 // Tooltip
8019 $('#dio_chat .togglebutton').tooltip("Chat öffnen");
8020
8021 },
8022 function (){
8023
8024 $('#dio_chat').css("left", 0);
8025
8026 setTimeout(function(){
8027 $('#dio_chat .togglebutton .arrow').get(0).innerHTML = "â—„";
8028 },1300);
8029
8030 // Tooltip
8031 $('#dio_chat .togglebutton').tooltip("Chat schließen");
8032 }
8033 );
8034 // Wenn sich die Fenstergröße ändert
8035
8036 $(window).on("resize.dio", function(){
8037
8038 if($('#dio_chat').css("left") !== "0px"){
8039
8040 var x = -($(window).width() * 0.25 + 16);
8041
8042 $('#dio_chat').addClass("resize");
8043 $('#dio_chat').css("left", x);
8044
8045 setTimeout(function(){
8046 $('#dio_chat').removeClass("resize");
8047 },0);
8048 }
8049 });
8050
8051 // Tooltip
8052 $('#dio_chat .togglebutton').tooltip("Chat schließen");
8053
8054 // Skalierung der Höhe
8055 $('#dio_chat .slider').mousedown(function (e) {
8056 e.preventDefault();
8057
8058 $('#dio_chat .messagebox').css("max-height", "none");
8059
8060 $(document).on("mousemove.dio", function (e) {
8061 e.preventDefault();
8062
8063 var x = $(window).height() - e.pageY - 49;
8064
8065 if (x > 30 && x < $(window).height() - 400) {
8066 $('#dio_chat .messagebox').css("height", x );
8067 }
8068 });
8069 });
8070
8071 $(document).on("mouseup.dio", function (e) {
8072 $(document).off("mousemove.dio");
8073
8074 //$('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollTopMax;
8075 $('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollHeight
8076 });
8077
8078
8079
8080 Chat.timestamp = Timestamp.server();
8081
8082 // Initialer Start
8083 Chat.getMessages();
8084
8085
8086 // Öfter anfragen, wenn man chatten will
8087 $('#dio_chat').hover(function(){
8088
8089 if(Chat.isOpened === true) {
8090 Chat.delay = 3000; // 3s
8091
8092 clearTimeout(Chat.timeout_A);
8093 clearTimeout(Chat.timeout_B);
8094 }
8095
8096 }, function(){
8097
8098 if(Chat.isOpened === true) {
8099
8100 Chat.delay = 10000; // 10s
8101
8102 // Nach 5min nur noch alle 30s
8103 Chat.timeout_A = setTimeout(function () {
8104 Chat.delay = 30000;
8105 }, 300000);
8106
8107 // Nach 15min nur noch alle 60s
8108 Chat.timeout_B = setTimeout(function () {
8109 Chat.delay = 60000;
8110 }, 900000);
8111 }
8112 });
8113
8114 // Nur wenn Grepolis offen ist aktualisieren
8115 $(window).on("focus.dio", function() {
8116 Chat.isWindowFocused = true;
8117
8118 if(Chat.isOpened === true) {
8119
8120 Chat.getMessages();
8121
8122 Chat.delay = 10000; // 10s
8123
8124 clearTimeout(Chat.timeout_A);
8125 clearTimeout(Chat.timeout_B);
8126
8127 // Nach 5min nur noch alle 30s
8128 Chat.timeout_A = setTimeout(function () {
8129 Chat.delay = 30000;
8130 }, 300000);
8131
8132 // Nach 15min nur noch alle 60s
8133 Chat.timeout_B = setTimeout(function () {
8134 Chat.delay = 60000;
8135 }, 900000);
8136 }
8137
8138 }).on("blur.dio", function() {
8139 Chat.isWindowFocused = false;
8140 });
8141 },
8142 deactivate : function(){
8143 Chat.isActivated = false;
8144
8145 $('#dio_chat_style').remove();
8146 $('#dio_chat').remove();
8147
8148 // Events disconnecten
8149 $(document).off('mouseup.dio');
8150 $(window).off('focus.dio');
8151 $(window).off('blur.dio');
8152 $(window).off('resize.dio');
8153 },
8154 sendMessage : function(_message){
8155
8156 _message = encodeURIComponent(_message.replace(/'/g, "'").replace(/ /g, " "));
8157
8158 $.ajax({
8159 type: "GET",
8160 url: "https://diotools.de/php/sendMessage.php?world=" + Game.world_id + "&time=" + Timestamp.server() + "&player="+ Game.player_name +"&message="+ _message,
8161 dataType: 'text',
8162 success: function (response) {
8163 console.debug("Nachricht wurde erfolgreich gesendet");
8164
8165 //$('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollTopMax;
8166 $('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollHeight
8167
8168 Chat.getMessages();
8169 },
8170 error: function (e) {
8171 console.debug("Nachricht konnte nicht gesendet werden", e);
8172 }
8173 });
8174 },
8175 getMessages : function(){
8176
8177 if(Chat.isActivated === true) {
8178
8179 var _currentTimestamp = Timestamp.server();
8180
8181 var _url = "https://diotools.de/php/getMessages.php?world=" + Game.world_id;
8182
8183 if (typeof(Chat.lastID) !== "undefined") {
8184 _url += "&id=" + Chat.lastID;
8185 }
8186 else {
8187 _url += "&time=" + Chat.timestamp;
8188 }
8189
8190 // Eventuell noch nicht gefeuertes Timeout entfernen
8191 clearTimeout(Chat.timeout);
8192
8193 if (Chat.isWindowFocused) {
8194 $.ajax({
8195 type: "GET",
8196 url: _url,
8197 dataType: 'json',
8198 success: function (_messages) {
8199 if(Chat.isActivated === true) {
8200
8201 // Letzte Abfragezeit speichern
8202 Chat.timestamp = _currentTimestamp;
8203
8204 // console.debug("GET MESSAGES", _messages);
8205
8206 /*
8207 var _scrollDown = false;
8208 if ($('#dio_chat .messagebox')[0].scrollTop === $('#dio_chat .messagebox')[0].scrollTopMax) {
8209 _scrollDown = true;
8210 }
8211 */
8212
8213 for (var m in _messages) {
8214 if (_messages.hasOwnProperty(m)) {
8215
8216 if (typeof(_messages[m].last_id) === "undefined") {
8217
8218 // HTML-Tags ersetzen
8219 var _message = _messages[m].message.replace(/</g, '<').replace(/>/g, '>').replace(/'/g, "\'");
8220
8221 $('#dio_chat .messagebox').append(
8222 '<div class="time">' + Chat.formatTime(_messages[m].time) + ': </div>' +
8223 '<div class="user" style="color:' + Chat.getUserColor(_messages[m].player) + '">' + _messages[m].player + ': </div>' +
8224 '<div class="text"> ' + _message + ' </div>'
8225 );
8226 }
8227 else {
8228 Chat.lastID = _messages[m].last_id;
8229 }
8230 }
8231 }
8232
8233 clearTimeout(Chat.timeout);
8234
8235 Chat.timeout = setTimeout(function () {
8236
8237 if (Chat.isWindowFocused) {
8238 Chat.getMessages();
8239 }
8240
8241 }, Chat.delay);
8242
8243 //if(_scrollDown) {
8244 // $('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollTopMax;
8245 $('#dio_chat .messagebox')[0].scrollTop = $('#dio_chat .messagebox')[0].scrollHeight
8246 //}
8247 }
8248 },
8249 error: function (xhr) {
8250 console.debug("Nachrichten konnten nicht geladen werden", xhr);
8251
8252 clearTimeout(Chat.timeout);
8253
8254 Chat.timeout = setTimeout(function () {
8255
8256 Chat.getMessages();
8257
8258 }, Chat.delay);
8259
8260 }
8261 });
8262
8263 }
8264 }
8265 },
8266 getUserColor : function(_user){
8267
8268 if(typeof(Chat.user_colors[_user]) === "undefined") {
8269
8270 var r = Math.floor(Math.random() * 255);
8271 var g = Math.floor(Math.random() * 255);
8272 var b = Math.floor(Math.random() * 255);
8273
8274 // Bei zu dunkler Farbe neue Farbe ermitteln
8275 if (r + g < 200 && r < 130 && g < 130) {
8276
8277 return Chat.getUserColor(_user);
8278 }
8279
8280 Chat.user_colors[_user] = 'rgb(' + r + ',' + g + ',' + b + ')';
8281 }
8282
8283 return Chat.user_colors[_user];
8284 },
8285 formatTime : function(_timestamp){
8286
8287 var date = new Date(_timestamp*1000);
8288
8289 // Hours part from the timestamp
8290 var hours = "0" + date.getHours();
8291 // Minutes part from the timestamp
8292 var minutes = "0" + date.getMinutes();
8293 // Seconds part from the timestamp
8294 var seconds = "0" + date.getSeconds();
8295
8296 // Will display time in 10:30:23 format
8297 return hours.substr(-2) + ':' + minutes.substr(-2) + ':' + seconds.substr(-2);
8298 }
8299 };
8300
8301 /*******************************************************************************************************************************
8302 * Activity boxes
8303 * ----------------------------------------------------------------------------------------------------------------------------
8304 * | â— Show troops and trade activity boxes
8305 * | â— Boxes are magnetic & movable (position memory)
8306 * ----------------------------------------------------------------------------------------------------------------------------
8307 *******************************************************************************************************************************/
8308 var mut_toolbar, mut_command, mut_trade;
8309
8310 var save_command_mouseout,
8311 save_commandlist_mouseout,
8312 save_trade_mouseout,
8313 save_tradelist_mouseout,
8314
8315 save_command_mouseover,
8316 save_trade_mouseover;
8317
8318
8319 var ActivityBoxes = {
8320 activate: function () {
8321 ActivityBoxes.checkToolbarAtStart();
8322
8323 $('#toolbar_activity_commands_list').css({
8324 left: commandbox.left + "px",
8325 top: commandbox.top + "px"
8326 });
8327
8328 $('<style id="fix_lists" type="text/css">' +
8329 '#toolbar_activity_commands_list, #toolbar_activity_trades_list { width: 160px}' +
8330 '.dropdown-list .content { max-height: 329px}' +
8331 '</style>' +
8332 '<style id="dio_fix_trade" type="text/css">' +
8333 '#toolbar_activity_trades_list {' +
8334 'left:' + tradebox.left + 'px !important;' +
8335 'top: ' + tradebox.top + 'px !important}' +
8336 '</style>').appendTo('head');
8337
8338
8339 ActivityBoxes.draggableTradeBox();
8340 ActivityBoxes.draggableCommandBox();
8341
8342 ActivityBoxes.catchToolbarEvents();
8343 },
8344 deactivate: function () {
8345 ActivityBoxes.hideTradeList();
8346 ActivityBoxes.hideCommandList();
8347
8348 mut_toolbar.disconnect();
8349 mut_command.disconnect();
8350 mut_trade.disconnect();
8351 },
8352 showTradeList: function () {
8353 if (!$('#dio_trades_activity_style').get(0)) {
8354 $('#toolbar_activity_trades').mouseover();
8355 $('<style id="dio_trades_activity_style"> #toolbar_activity_trades_list { display: block !important; } </style>').appendTo("head");
8356 }
8357 },
8358 showCommandList: function () {
8359 if (!$('#dio_commands_activity_style').get(0)) {
8360 $('#toolbar_activity_commands').mouseover();
8361 $('<style id="dio_commands_activity_style"> #toolbar_activity_commands_list { ' +
8362 'display:block !important; left:' + commandbox.left + 'px; top:' + commandbox.top + 'px; }' +
8363 '</style>').appendTo("head");
8364 }
8365 },
8366 hideTradeList: function () {
8367 if ($('#dio_trades_activity_style').get(0)) {
8368 $('#dio_trades_activity_style').remove();
8369 $('#toolbar_activity_trades').mouseout();
8370 }
8371 },
8372 hideCommandList: function () {
8373 if ($('#dio_commands_activity_style').get(0)) {
8374 $('#dio_commands_activity_style').remove();
8375 $('#toolbar_activity_commands').mouseout();
8376 }
8377 },
8378 activate2: function () {
8379 var observe_options = {attributes: false, childList: true, characterData: false};
8380
8381 ActivityBoxes.catchToolbarEvents();
8382
8383 mut_command.observe($('.toolbar_activities .commands .count').get(0), observe_options);
8384 mut_trade.observe($('.toolbar_activities .trades .count').get(0), observe_options);
8385
8386 $('<style id="dio_activity_style"> ' +
8387 '#toolbar_activity_commands_list.active { display: block !important; } ' +
8388 '#toolbar_activity_trades_list.active { display: block !important; } ' +
8389 '</style>').appendTo("head");
8390
8391
8392 $('#toolbar_activity_commands').mouseover();
8393 $('#toolbar_activity_trades').mouseover();
8394
8395 $('#toolbar_activity_commands, #toolbar_activity_trades').off("mouseover");
8396
8397 $('#toolbar_activity_commands, #toolbar_activity_commands_list, #toolbar_activity_trades, #toolbar_activity_trades_list').off("mouseout");
8398
8399 $('#toolbar_activity_trades_list').unbind("click");
8400 //console.log($('#toolbar_activity_commands').data('events')["dd:list:show"][0].handler());
8401
8402 ActivityBoxes.checkToolbarAtStart();
8403
8404 $('#toolbar_activity_commands_list').css({
8405 left: commandbox.left + "px",
8406 top: commandbox.top + "px"
8407 });
8408
8409 $('<style id="fix_lists" type="text/css">' +
8410 '#toolbar_activity_commands_list, #toolbar_activity_trades_list { width: 160px}' +
8411 '.dropdown-list .content { max-height: 329px}' +
8412 '</style>' +
8413 '<style id="dio_fix_trade" type="text/css">' +
8414 '#toolbar_activity_trades_list {' +
8415 'left:' + tradebox.left + 'px !important;' +
8416 'top: ' + tradebox.top + 'px !important}' +
8417 '</style>').appendTo('head');
8418
8419 ActivityBoxes.draggableCommandBox();
8420 ActivityBoxes.draggableTradeBox();
8421
8422
8423 /*
8424 $('.toolbar_activities .commands').on("mouseover.bla", function(){
8425 $('#toolbar_activity_commands_list').addClass("active");
8426 });
8427
8428 $('.toolbar_activities .trades').mouseover(function(){
8429 $('#toolbar_activity_trades_list').addClass("active");
8430 });
8431 */
8432 },
8433 deactivate2: function () {
8434 mut_toolbar.disconnect();
8435 mut_command.disconnect();
8436 mut_trade.disconnect();
8437 /*
8438 $('#toolbar_activity_commands').on("mouseover", save_command_mouseover);
8439 $('#toolbar_activity_trades').on("mouseover", save_trade_mouseover);
8440
8441 $('#toolbar_activity_commands').on("mouseout", save_command_mouseout);
8442 $('#toolbar_activity_commands_list').on("mouseout", save_commandlist_mouseout);
8443 $('#toolbar_activity_trades').on("mouseout", save_trade_mouseout);
8444 $('#toolbar_activity_trades_list').on("mouseout", save_tradelist_mouseout);
8445 */
8446
8447 $('#toolbar_activity_commands').mouseover = save_command_mouseover;
8448 $('#toolbar_activity_trades').mouseover = save_trade_mouseover;
8449
8450 $('#toolbar_activity_commands').mouseout = save_command_mouseout;
8451 $('#toolbar_activity_commands_list').mouseout = save_commandlist_mouseout;
8452 $('#toolbar_activity_trades').mouseout = save_trade_mouseout;
8453 $('#toolbar_activity_trades_list').mouseout = save_tradelist_mouseout;
8454
8455
8456 $('#toolbar_activity_trades_list').removeClass("active");
8457 $('#toolbar_activity_commands_list').removeClass("active");
8458 /*
8459 $('.toolbar_activities .commands').off("mouseover.bla");
8460 */
8461 $('#dio_activity_style').remove();
8462
8463
8464 },
8465 checkToolbarAtStart: function () {
8466 if (parseInt($('.toolbar_activities .commands .count').get(0).innerHTML, 10) > 0) {
8467 ActivityBoxes.showCommandList();
8468 } else {
8469 ActivityBoxes.hideCommandList();
8470 }
8471 if (parseInt($('.toolbar_activities .trades .count').get(0).innerHTML, 10) > 0) {
8472 ActivityBoxes.showTradeList();
8473 } else {
8474 ActivityBoxes.hideTradeList();
8475 }
8476 },
8477 catchToolbarEvents: function () {
8478 var observe_options = {attributes: false, childList: true, characterData: false};
8479
8480 mut_toolbar = new MutationObserver(function (mutations) {
8481 mutations.forEach(function (mutation) {
8482 if (mutation.addedNodes[0]) {
8483 //console.debug(mutation.target.id);
8484 if (mutation.target.id === "toolbar_activity_trades_list") {
8485 ActivityBoxes.draggableTradeBox();
8486 } else {
8487 ActivityBoxes.draggableCommandBox();
8488 }
8489 mutation.addedNodes[0].remove();
8490 }
8491 });
8492 });
8493 //mut_toolbar.observe($('#toolbar_activity_commands_list').get(0), observe_options );
8494 //mut_toolbar.observe($('#toolbar_activity_trades_list').get(0), observe_options );
8495
8496 mut_command = new MutationObserver(function (mutations) {
8497 mutations.forEach(function (mutation) {
8498 if (mutation.addedNodes[0]) {
8499 //console.debug(mutation.addedNodes[0].nodeValue);
8500 if (mutation.addedNodes[0].nodeValue > 0) {
8501 ActivityBoxes.showCommandList();
8502 } else {
8503 //console.debug("hide commands");
8504 ActivityBoxes.hideCommandList();
8505 }
8506 }
8507 });
8508 });
8509 mut_trade = new MutationObserver(function (mutations) {
8510 mutations.forEach(function (mutation) {
8511 if (mutation.addedNodes[0]) {
8512 if (mutation.addedNodes[0].nodeValue > 0) {
8513 ActivityBoxes.showTradeList();
8514 } else {
8515 ActivityBoxes.hideTradeList();
8516 }
8517 }
8518 });
8519 });
8520 mut_command.observe($('.toolbar_activities .commands .count').get(0), observe_options);
8521 mut_trade.observe($('.toolbar_activities .trades .count').get(0), observe_options);
8522 },
8523 // Moveable boxes
8524 draggableTradeBox: function () {
8525 $("#toolbar_activity_trades_list").draggable({
8526 containment: "body",
8527 distance: 20,
8528 snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, .nui_left_box",
8529 opacity: 0.7,
8530 start: function () {
8531 $("#dio_fix_trade").remove();
8532 },
8533 stop: function () {
8534 var pos = $('#toolbar_activity_trades_list').position();
8535
8536 tradebox.left = pos.left;
8537 tradebox.top = pos.top;
8538
8539 saveValue("tradebox", JSON.stringify(tradebox));
8540
8541 $('<style id="dio_fix_trade" type="text/css">' +
8542 '#toolbar_activity_trades_list { left:' + tradebox.left + 'px !important; top:' + tradebox.top + 'px !important; } ' +
8543 '</style>').appendTo('head');
8544 }
8545 });
8546 },
8547 draggableCommandBox: function () {
8548 $("#toolbar_activity_commands_list").draggable({
8549 containment: "body",
8550 distance: 20,
8551 snap: "body, .gods_area, .nui_units_box, .ui_quickbar, .nui_main_menu, .minimized_windows_area, .nui_left_box",
8552 opacity: 0.7,
8553 stop: function () {
8554 var pos = $('#toolbar_activity_commands_list').position();
8555 commandbox.left = pos.left;
8556 commandbox.top = pos.top;
8557
8558 saveValue("commandbox", JSON.stringify(commandbox));
8559 }
8560 });
8561 }
8562 };
8563
8564 /*******************************************************************************************************************************
8565 * Counter
8566 *******************************************************************************************************************************/
8567
8568 function counter(time) {
8569 var type = "", today, counted, year, month, day;
8570 if (uw.Game.market_id !== "zz") {
8571 counted = DATA.count;
8572 today = new Date((time + 7200) * 1000);
8573 year = today.getUTCFullYear();
8574 month = ((today.getUTCMonth() + 1) < 10 ? "0" : "") + (today.getUTCMonth() + 1);
8575 day = (today.getUTCDate() < 10 ? "0" : "") + today.getUTCDate();
8576 today = year + month + day;
8577 //console.log(today);
8578 if (counted[0] !== today) {
8579 type += "d";
8580 }
8581 if (counted[1] == false) {
8582 type += "t";
8583 }
8584 if ((counted[2] == undefined) || (counted[2] == false)) {
8585 type += "b";
8586 }
8587 if (type !== "") {
8588 $.ajax({
8589 type: "GET",
8590 url: "https://diotools.de/game/count.php?type=" + type + "&market=" + uw.Game.market_id + "&date=" + today + "&browser=" + getBrowser(),
8591 dataType: 'text',
8592 success: function (text) {
8593 if (text.indexOf("dly") > -1) {
8594 counted[0] = today;
8595 }
8596 if (text.indexOf("tot") > -1) {
8597 counted[1] = true;
8598 }
8599 if (text.indexOf("bro") > -1) {
8600 counted[2] = true;
8601 }
8602 saveValue("dio_count", JSON.stringify(counted));
8603 }
8604 });
8605 }
8606 }
8607 }
8608
8609
8610 /*******************************************************************************************************************************
8611 * Political Map
8612 *******************************************************************************************************************************/
8613
8614 var PoliticalMap = {
8615 data: null,
8616 activate: function () {
8617 $('<div id="dio_political_map">' +
8618 '<div class="canvas_wrapper"></div>' +
8619 '<select class="zoom_select">' +
8620 '<option value="0.50">1 : 0.50</option>' +
8621 '<option value="0.75">1 : 0.75</option>' +
8622 '<option value="1.00" selected>1 : 1.00</option>' +
8623 '<option value="1.25">1 : 1.25</option>' +
8624 '<option value="1.50">1 : 1.50</option>' +
8625 '<option value="2.00">1 : 2.00</option>' +
8626 '<option value="3.00">1 : 3.00</option>' +
8627 '</select>' +
8628 '<div class="legend sandy-box">' +
8629 '<div class="corner_tl"></div>' +
8630 '<div class="corner_tr"></div>' +
8631 '<div class="corner_bl"></div>' +
8632 '<div class="corner_br"></div>' +
8633 '<div class="border_t"></div>' +
8634 '<div class="border_b"></div>' +
8635 '<div class="border_l"></div>' +
8636 '<div class="border_r"></div>' +
8637 '<div class="middle"></div>' +
8638 '<div class="content"><div class="item"></div></div>' +
8639 '</div></div>').appendTo('#ui_box');
8640
8641 // Style
8642 $('<style id="dio_political_map_style">' +
8643 '#dio_political_map { width:100%; height:100%; z-index:3; background:#123d70; display:none; position:absolute; top:0; } ' +
8644 '#dio_political_map.active { display: block; } ' +
8645 '#dio_political_map .canvas_wrapper { } ' +
8646 '#dio_political_map canvas { position: absolute; cursor:move; top:0; left:0; } ' +
8647 '#dio_political_map .zoom_select { position:absolute; top:70px; left:300px; font-size: 2em; opacity:0.5; } ' +
8648 '#dio_political_map .zoom_select:hover { opacity:1; } ' +
8649 '#dio_political_map .legend { position:absolute; right:200px; top:50px; width:200px; height:auto; text-align:left; } ' +
8650 '#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; } ' +
8651 '#dio_political_map .legend .wonder_icon { float: left; margin: 4px; } ' +
8652
8653 '.btn_political_map { top:56px; left:-4px; z-index:10; position:absolute; } ' +
8654
8655 '.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%; } ' +
8656 // http://s14.directupload.net/images/140408/k4wikrlq.png // http://s7.directupload.net/images/140408/ahfr8227.png
8657 '.btn_political_map .ico_political_map.checked { margin-top:8px; } ' +
8658 '</style>').appendTo('head');
8659
8660 PoliticalMap.addButton();
8661
8662 var zoomSelect = $('.zoom_select');
8663
8664 zoomSelect.change(function () {
8665 //PoliticalMap.zoomToCenter();
8666 });
8667 zoomSelect.on("change", function () {
8668 PoliticalMap.zoomToCenter();
8669 });
8670
8671 ColorPicker.init();
8672 },
8673 deactivate: function () {
8674 $('.btn_political_map').remove();
8675 $('#dio_political_map_style').remove();
8676 },
8677 addButton: function () {
8678 var m_ZoomFactor = 1.0;
8679 $('<div class="btn_political_map circle_button" name="political_map"><div class="ico_political_map js-caption"></div></div>').appendTo(".bull_eye_buttons");
8680
8681 var politicalMapButton = $('.btn_political_map');
8682
8683 // Tooltip
8684 politicalMapButton.tooltip("Political Map"); // TODO: Language
8685
8686 // Events
8687 politicalMapButton.on('mousedown', function () {
8688 //$('.btn_political_map, .ico_political_map').addClass("checked");
8689 }).on('mouseup', function () {
8690 //$('.btn_political_map, .ico_political_map').removeClass("checked");
8691 });
8692
8693 $('.rb_map .option').click(function () {
8694 $('.btn_political_map, .ico_political_map').removeClass("checked");
8695 $('#dio_political_map').removeClass("active");
8696 $(this).addClass("checked");
8697 });
8698
8699 politicalMapButton.click(function () {
8700 $('.rb_map .checked').removeClass("checked");
8701 $('.btn_political_map, .ico_political_map').addClass("checked");
8702 $('#dio_political_map').addClass("active");
8703
8704 if ($('#dio_political_map').hasClass("active")) {
8705 if (PoliticalMap.data == null) {
8706 $('#ajax_loader').css({visibility: "visible"});
8707 // Map-Daten aus DB auslesen
8708 PoliticalMap.loadMapData();
8709 } else {
8710 //PoliticalMap.drawMap(PoliticalMap.data);
8711 }
8712 }
8713 });
8714 },
8715 /**
8716 * Läd die Allianzen und Inseln aus der Datenbank
8717 * @since 3.0
8718 */
8719 loadMapData: function () {
8720 $.ajax({
8721 type: "GET",
8722 url: "https://diotools.de/php/map.php?world_id=" + WID + "&callback=jsonCallback",
8723 //dataType: 'jsonp',
8724 //async: false,
8725 //jsonpCallback: 'jsonCallback',
8726 //contentType: "application/json",
8727 success: function (response) {
8728 if (response !== "") {
8729 PoliticalMap.data = response;
8730
8731 var m_ZoomFactor = $('.zoom_select').get(0)[$('.zoom_select').get(0).selectedIndex].selected;
8732
8733 PoliticalMap.drawMap(PoliticalMap.data, m_ZoomFactor);
8734 PoliticalMap.drawWonders(PoliticalMap.data, m_ZoomFactor);
8735
8736 $('#ajax_loader').css({visibility: "hidden"});
8737
8738 // Überprüfen, ob die Weltdaten geupdatet werden müssen
8739 $.ajax({
8740 type: "GET",
8741 url: "https://diotools.de/php/update_db.php?world_id=" + WID
8742 });
8743 } else {
8744 // Welt existiert noch nicht in DB
8745 $.ajax({
8746 type: "GET", url: "https://diotools.de/php/update_db.php?world_id=" + WID,
8747 success: function () {
8748 // Map-Daten aus DB auslesen, wenn die Weltdaten erfolgreich in die DB geladen wurden
8749 $.ajax({
8750 type: "GET",
8751 url: "https://diotools.de/php/map.php?world_id=" + WID,
8752 success: function (response) {
8753 PoliticalMap.data = response;
8754
8755 var m_ZoomFactor = $('.zoom_select').get(0)[$('.zoom_select').get(0).selectedIndex].selected;
8756
8757 PoliticalMap.drawMap(PoliticalMap.data, m_ZoomFactor);
8758 PoliticalMap.drawWonders(PoliticalMap.data, m_ZoomFactor);
8759
8760 $('#ajax_loader').css({visibility: "hidden"});
8761 }
8762 });
8763 }
8764 });
8765 }
8766 }
8767 });
8768 },
8769 /**
8770 * Ändert die Zoomstufe der Karte zum Zentrum hin
8771 *
8772 * @param _zoom
8773 * @since 3.0
8774 */
8775 zoomToCenter: function () {
8776 var _zoom = $('.zoom_select').get(0)[$('.zoom_select').get(0).selectedIndex].value;
8777
8778 var canvas = $('#dio_political_map canvas'),
8779
8780 canvas_size = parseInt($('#dio_political_map canvas').width(), 10); // Breite und Höhe sind immer gleich
8781
8782 var canvas_style = $('#dio_political_map .canvas_wrapper').get(0).style;
8783
8784 // Berechnung: Alter Abstand + (1000 * Zoomänderung / 2)
8785 canvas_style.top = parseInt(canvas_style.top, 10) + (1000 * (canvas_size / 1000 - _zoom)) / 2 + "px";
8786 canvas_style.left = parseInt(canvas_style.left, 10) + (1000 * (canvas_size / 1000 - _zoom)) / 2 + "px";
8787
8788 PoliticalMap.clearMap();
8789 PoliticalMap.drawMap(PoliticalMap.data, _zoom);
8790 PoliticalMap.drawWonders(PoliticalMap.data, _zoom);
8791
8792 },
8793 /**
8794 * Ändert die Zoomstufe der Karte zur Cursorposition hin
8795 *
8796 * @param _zoom
8797 * @param _pos
8798 *
8799 * @since 3.0
8800 */
8801 zoomToCursorPosition: function (_zoom, _pos) {
8802
8803 },
8804 /**
8805 * Zeichnet die Karte in ein Canvas
8806 *
8807 * @param _islandArray {Array}
8808 * @param _zoom {int}
8809 *
8810 * @since 3.0
8811 */
8812 drawMap: function (_islandArray, _zoom) {
8813
8814 $('<canvas class="canv_map" height="' + (1000 * _zoom) + 'px" width="' + (1000 * _zoom) + "px\"></canvas>").prependTo('.canvas_wrapper')
8815
8816 // TODO: Weite und Höhe vom Fenster ermitteln, Update Containment bei onResizeWindow
8817 $('#dio_political_map .canvas_wrapper').draggable({
8818 // left, top, right, bottom
8819 //containment: [-500 * _zoom, -300 * _zoom, 500 * _zoom, 300 * _zoom],
8820 distance: 10,
8821 grid: [100 * _zoom, 100 * _zoom],
8822 //limit: 500,
8823 cursor: 'pointer'
8824 });
8825
8826 var ally_ranking = JSON.parse(_islandArray)['ally_ranking'];
8827 var island_array = JSON.parse(_islandArray)['ally_island_array'];
8828
8829
8830 var c = $('#dio_political_map .canv_map')[0].getContext('2d');
8831
8832 // Grid
8833 c.strokeStyle = 'rgb(0,100,0)';
8834
8835 for (var l = 0; l <= 10; l++) {
8836 // Horizontal Line
8837 c.moveTo(0, l * 100 * _zoom);
8838 c.lineTo(1000 * _zoom, l * 100 * _zoom);
8839 c.stroke();
8840
8841 // Vertical Line
8842 c.moveTo(l * 100 * _zoom, 0);
8843 c.lineTo(l * 100 * _zoom, 1000 * _zoom);
8844 c.stroke();
8845 }
8846
8847 // Center Circle
8848 c.beginPath();
8849 c.arc(500 * _zoom, 500 * _zoom, 100 * _zoom, 0, Math.PI * 2, true);
8850 c.fillStyle = 'rgba(0,100,0,0.2)';
8851 c.fill();
8852 c.stroke();
8853
8854 // Sea numbers
8855 c.fillStyle = 'rgb(0,100,0)';
8856
8857 for (var y = 0; y <= 10; y++) {
8858 for (var x = 0; x <= 10; x++) {
8859 c.fillText(y + "" + x, y * 100 * _zoom + 2, x * 100 * _zoom + 10);
8860 }
8861 }
8862
8863 // Alliance Colors
8864 var colorArray = ["#00A000", "yellow", "red", "rgb(255, 116, 0)", "cyan", "#784D00", "white", "purple", "#0078FF", "deeppink", "darkslategrey"];
8865
8866 // Islands
8867 for (var t in island_array) {
8868 if (island_array.hasOwnProperty(t)) {
8869 var tmp_points = 0, dom_ally = "";
8870 for (var ally in island_array[t]) {
8871 if (island_array[t].hasOwnProperty(ally)) {
8872 if (tmp_points < island_array[t][ally] && (ally !== "X") && (ally !== "")) {
8873 tmp_points = island_array[t][ally];
8874 dom_ally = ally;
8875 }
8876 }
8877 }
8878
8879 c.fillStyle = colorArray[parseInt(ally_ranking[dom_ally], 10) - 1] || "darkslategrey";
8880 //c.fillRect(t.split("x")[0] * _zoom, t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
8881
8882 //c.beginPath();
8883 //console.info(island_array[t]);
8884 //c.arc(t.split("x")[0], t.split("x")[1], 2, 0, Math.PI * 2, true);
8885 //c.fillRect(t.split("x")[0] * _zoom,t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
8886 //c.fill();
8887
8888 // TEST HEATMAP
8889 //console.debug("Blaaa", c.fillStyle);
8890 if (c.fillStyle !== "#2f4f4f") {
8891 var color = c.fillStyle;
8892
8893 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);
8894 radgrad.addColorStop(0, PoliticalMap.convertHexToRgba(color, 0.2));
8895 radgrad.addColorStop(0.6, PoliticalMap.convertHexToRgba(color, 0.2));
8896 radgrad.addColorStop(1, PoliticalMap.convertHexToRgba(color, 0.0));
8897
8898 // draw shape
8899 c.fillStyle = radgrad;
8900
8901 c.fillRect(t.split("x")[0] * _zoom - 10, t.split("x")[1] * _zoom - 10, 22, 22);
8902
8903 c.fillStyle = PoliticalMap.convertHexToRgba(color, 0.7);
8904 c.fillRect(t.split("x")[0] * _zoom, t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
8905 }
8906 else {
8907 c.fillRect(t.split("x")[0] * _zoom, t.split("x")[1] * _zoom, 3 * _zoom, 3 * _zoom);
8908 }
8909 }
8910 }
8911
8912
8913
8914 // Legende
8915 var legend = $('#dio_political_map .legend .content');
8916
8917 legend.get(0).innerHTML = "";
8918
8919 for (var ally in ally_ranking) {
8920 if (ally_ranking.hasOwnProperty(ally)) {
8921 //legend.append("<div class='item' style='color:"+ colorAllyArray[ally] +"'><div class='color_checker' style='background-color:"+ colorAllyArray[ally] +"'></div>...</div>");
8922
8923 if (ally_ranking[ally] > 10) {
8924 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>");
8925
8926 break;
8927 } else {
8928 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>");
8929
8930 }
8931 }
8932 }
8933
8934 $('#dio_political_map .legend .color_checker').click(function (event) {
8935 // getting user coordinates
8936 var x = event.pageX - this.offsetLeft;
8937 var y = event.pageY - this.offsetTop;
8938
8939 console.debug("Color Checker", event.pageX, this.offsetLeft);
8940
8941 ColorPicker.open(x,y);
8942 });
8943
8944
8945 // TODO: Wenn eine Farbe ausgewählt wurde, soll [...]
8946 $(ColorPicker).on("onColorChanged", function(event, color){
8947 console.debug("Farbe setzen", event, color);
8948
8949 $.ajax({
8950 type: "POST",
8951 url: "https://" + Game.world_id + ".grepolis.com/game/alliance?town_id=" + Game.townId + "&action=assign_map_color&h=" + Game.csrfToken,
8952 data: {
8953 "json": "{\"alliance_id\":\"217\",\"color\":"+ color +",\"player_id\":\"8512878\",\"town_id\":\"71047\",\"nl_init\":true}"
8954 },
8955 success: function (response) {
8956 console.debug("Erfolgreich übertragen", response);
8957 }
8958 });
8959 });
8960
8961 },
8962 convertHexToRgba: function (hex, opacity) {
8963 console.debug("hex", hex);
8964 hex = hex.replace('#', '');
8965 r = parseInt(hex.substring(0, 2), 16);
8966 g = parseInt(hex.substring(2, 4), 16);
8967 b = parseInt(hex.substring(4, 6), 16);
8968
8969 result = 'rgba(' + r + ',' + g + ',' + b + ',' + opacity + ')';
8970 return result;
8971 },
8972 /**
8973 * Zeichnet die Weltwunder auf der Karte
8974 *
8975 * @param _islandArray {Array}
8976 * @param _zoom {int}
8977 *
8978 * @since 3.0
8979 */
8980 drawWonders: function (_islandArray, _zoom) {
8981
8982 $('<canvas class="canv_ww" height="' + (1000 * _zoom) + 'px" width="' + (1000 * _zoom) + 'px"></canvas>').appendTo('.canvas_wrapper')
8983
8984 var c = $('#dio_political_map .canv_ww')[0].getContext('2d');
8985
8986 c.strokeStyle = 'rgb(0,100,0)';
8987
8988 // World Wonders
8989 var wonders = {}, wonderImages = {};
8990 //console.debug(JSON.stringify(wonder.map));
8991
8992 for (var wonderType in wonder.map) {
8993 if (wonder.map.hasOwnProperty(wonderType)) {
8994 var tmp = 0;
8995 for (var wonderCoords in wonder.map[wonderType]) {
8996 if (parseInt(wonder.map[wonderType][wonderCoords], 10) > tmp) {
8997 wonders[wonderType] = wonderCoords;
8998 tmp = parseInt(wonder.map[wonderType][wonderCoords], 10)
8999 }
9000 }
9001 }
9002 }
9003
9004 // Legende
9005 var legend = $('#dio_political_map .legend .content');
9006
9007 legend.append("<div class=\"item no_results\"></div>");
9008
9009 for (var w in wonders) {
9010 if (wonders.hasOwnProperty(w)) {
9011 var _w = w;
9012
9013 wonderImages[_w] = new Image();
9014
9015 wonderImages[_w].onload = function () {
9016 c.drawImage(this, this.pos.split("_")[0] * _zoom - 9, this.pos.split("_")[1] * _zoom - 9);
9017 };
9018
9019 wonderImages[_w].pos = wonders[_w];
9020 wonderImages[_w].src = "https://diotools.de/images/icons/ww/" + _w + ".png";
9021
9022 var wonder_string = _w.split("_of")[0].split("_");
9023 wonder_string = wonder_string[wonder_string.length - 1];
9024 wonder_string = wonder_string.substring(0, 1).toUpperCase() + wonder_string.substring(1);
9025
9026 legend.append("<img class='wonder_icon' src='" + wonderImages[_w].src + "'><div class='item'>" + wonder_string + "</div>");
9027 }
9028 }
9029 },
9030 clearMap: function () {
9031 $('#dio_political_map .canv_map').remove();
9032 $('#dio_political_map .canv_ww').remove();
9033 },
9034 getAllianceColors: function () {
9035 $.ajax({
9036 type: "GET",
9037 url: "https://" + Game.world_id + ".grepolis.com/game/map_data?town_id=" + Game.townId + "&action=get_custom_colors&h=" + Game.csrfToken,
9038 dataType: 'json',
9039 success: function (response) {
9040 // Allianzbox herausfiltern
9041 var html_string = $('#alliance_box', $(response.json.list_html));
9042
9043 var flagArray = $('.flag', html_string);
9044 var linkArray = $('a', html_string);
9045
9046 var allianceColorArray = [];
9047
9048 for (var i = 0; i < flagArray.length; i++) {
9049 allianceColorArray[i] = {
9050 "id": parseInt(linkArray[i].attributes.onclick.value.split(",")[1].split(")")[0], 10),
9051 "color": flagArray[i].style.backgroundColor
9052 };
9053 }
9054
9055 // console.debug("ANTWORT", allianceColorArray);
9056 }
9057 });
9058 }
9059 };
9060
9061 var ColorPicker = {
9062 open: function(pos_left, pos_top){
9063 $('#dio_color_picker').removeClass("hidden");
9064 $('#dio_color_picker').css({
9065 left: pos_left,
9066 top: pos_top
9067 });
9068 },
9069 close: function(){
9070 $('#dio_color_picker').addClass("hidden");
9071 },
9072 init: function () {
9073 // Style
9074 $('<style id="dio_color_picker_style">' +
9075 '#dio_color_picker { left:200px;top:300px;position:absolute;z-index:1000;} ' +
9076 '#dio_color_picker.hidden { display:none;} ' +
9077 '#dio_color_picker span.grepo_input, ' +
9078 '#dio_color_picker a.color_table, ' +
9079 '#dio_color_picker a.confirm, ' +
9080 '#dio_color_picker a.cancel' +
9081 ' { float:left; } ' +
9082 '</style>').appendTo('head');
9083
9084 $(
9085 '<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>' +
9086 '<div id="hex">HEX: <input type="text"></input></div>' +
9087 '<div id="rgb">RGB: <input type="text"></input></div>'
9088 ).prependTo('#dio_political_map')
9089
9090 $(
9091 '<div id="dio_color_picker" class="hidden"><table class="bb_popup" cellpadding="0" cellspacing="0"><tbody>' +
9092 '<tr class="bb_popup_top">' +
9093 '<td class="bb_popup_top_left"></td>' +
9094 '<td class="bb_popup_top_middle"></td>' +
9095 '<td class="bb_popup_top_right"></td>' +
9096 '</tr>' +
9097 '<tr>' +
9098 '<td class="bb_popup_middle_left"></td>' +
9099 '<td class="bb_popup_middle_middle">' +
9100 '<div class="bb_color_picker_colors">' +
9101 '<div style="background-color: rgb(255, 0, 0);"></div>' +
9102 '<div style="background-color: rgb(0, 255, 0);"></div>' +
9103 '<div style="background-color: rgb(0, 0, 255);"></div>' +
9104 '</div>' +
9105 '<a href="#" class="cancel"></a>' +
9106 '<span class="grepo_input">' +
9107 '<span class="left">' +
9108 '<span class="right">' +
9109 '<input class="color_string" style="width:50px;" maxlength="6" type="text">' +
9110 '</span>' +
9111 '</span>' +
9112 '</span>' +
9113 '<a href="#" class="color_table"><input type="color" id="c" tabindex=-1 class="hidden"></a>' +
9114 '<a href="#" class="confirm"></a>' +
9115 '</td>' +
9116 '<td class="bb_popup_middle_right"></td>' +
9117 '</tr>' +
9118 '<tr class="bb_popup_bottom">' +
9119 '<td class="bb_popup_bottom_left"></td>' +
9120 '<td class="bb_popup_bottom_middle"></td>' +
9121 '<td class="bb_popup_bottom_right"></td>' +
9122 '</tr>' +
9123 '</tbody></table></div>'
9124 ).prependTo('#dio_political_map');
9125
9126 var canvas = document.getElementById('canvas_picker').getContext('2d');
9127
9128 var count = 5, line = 0, width = 16, height = 12, sep = 1;
9129
9130 var offset = (count - 2) * width;
9131
9132 for (var i = 2, j = 0; i < count; i++, j++) {
9133
9134 line = 0;
9135
9136 // Pinktöne (255,0,255)
9137 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", 0, " + ((i / count * 255) | 0) + ")";
9138 canvas.fillRect(i * width, line, width - sep, height - sep);
9139
9140 canvas.fillStyle = "rgb(255," + ((j / (count - 1) * 255) | 0) + ", 255)";
9141 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9142
9143 line = line + height;
9144
9145 // Rosatöne (255,0,127)
9146 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", 0, " + ((i / count * 127) | 0) + ")";
9147 canvas.fillRect(i * width, line, width - sep, height - sep);
9148
9149 canvas.fillStyle = "rgb(255," + ((j / (count - 1) * 255) | 0) + "," + (127 + ((j / (count - 1) * 127) | 0)) + ")";
9150 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9151
9152 line = line + height;
9153
9154 // Rottöne (255,0,0)
9155 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", 0, 0)";
9156 canvas.fillRect(i * width, line, width - sep, height - sep);
9157
9158 canvas.fillStyle = "rgb(255," + ((j / (count - 1) * 255) | 0) + "," + ((j / (count - 1) * 255) | 0) + ")";
9159 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9160
9161 line = line + height;
9162
9163 // Orangetöne (255, 127, 0)
9164 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", " + ((i / count * 127) | 0) + ", 0)";
9165 canvas.fillRect(i * width, line, width - sep, height - sep);
9166
9167 canvas.fillStyle = "rgb(255, " + (127 + ((j / (count - 1) * 127) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ")";
9168 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9169
9170 line = line + height;
9171
9172 // Dunkelbrauntöne (170, 85, 0)
9173 canvas.fillStyle = "rgb(" + ((i / count * 170) | 0) + ", " + ((i / count * 85) | 0) + ", 0)";
9174 canvas.fillRect(i * width, line, width - sep, height - sep);
9175
9176 canvas.fillStyle = "rgb(" + (170 + (j / (count - 1) * 85) | 0) + ", " + (85 + ((j / (count - 1) * 170) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ")";
9177 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9178
9179 line = line + height;
9180
9181 // Brauntöne (191, 127, 0)
9182 canvas.fillStyle = "rgb(" + ((i / count * 191) | 0) + ", " + ((i / count * 127) | 0) + ", 0)";
9183 canvas.fillRect(i * width, line, width - sep, height - sep);
9184
9185 canvas.fillStyle = "rgb(" + (191 + (j / (count - 1) * 64) | 0) + ", " + (127 + ((j / (count - 1) * 127) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ")";
9186 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9187
9188 line = line + height;
9189
9190 // Gelbtöne (255,255,0)
9191 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ", 0)";
9192 canvas.fillRect(i * width, line, width - sep, height - sep);
9193
9194 canvas.fillStyle = "rgb(255, 255," + ((j / (count - 1) * 255) | 0) + ")";
9195 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9196
9197 line = line + height;
9198
9199 // Gelbgrüntöne (127,255,0)
9200 canvas.fillStyle = "rgb(" + ((i / count * 127) | 0) + "," + ((i / count * 191) | 0) + ", 0)";
9201 canvas.fillRect(i * width, line, width - sep, height - sep);
9202
9203 canvas.fillStyle = "rgb(" + (127 + (j / (count - 1) * 127) | 0) + "," + (191 + (j / (count - 1) * 64) | 0) + "," + ((j / (count - 1) * 255) | 0) + ")";
9204 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9205
9206 line = line + height;
9207
9208 // Dunkelgrasgrüntöne (85, 170, 0)
9209 /*
9210 canvas.fillStyle = "rgb("+ ((i/count*85)|0) +", "+ ((i/count*170)|0) +", 0)";
9211 canvas.fillRect(i * width, line, width-sep, height-sep);
9212
9213 canvas.fillStyle = "rgb("+ (85 + (j/(count-1)*170)|0) +", "+ (170 + ((j/(count-1)*85)|0)) +","+ ((j/(count-1)*255)|0) +")";
9214 canvas.fillRect(i * width + offset, line, width-sep, height-sep);
9215
9216 line = line + height;
9217 */
9218
9219 // Grüntöne (0,255,0)
9220 canvas.fillStyle = "rgb(0," + ((i / count * 255) | 0) + ", 0)";
9221 canvas.fillRect(i * width, line, width - sep, height - sep);
9222
9223 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + ", 255," + ((j / (count - 1) * 255) | 0) + ")";
9224 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9225
9226 line = line + height;
9227
9228 // Türkistöne (0,255,127)
9229 /*
9230 canvas.fillStyle = "rgb(0,"+ ((i/count*255)|0) +","+ ((i/count*127)|0) + ")";
9231 canvas.fillRect(i * width, line, width-sep, height-sep);
9232
9233 canvas.fillStyle = "rgb("+ ((j/(count-1)*255)|0) +", 255,"+ (127 + ((j/(count-1)*127)|0)) +")";
9234 canvas.fillRect(i * width + offset, line, width-sep, height-sep);
9235
9236 line = line + height;
9237 */
9238
9239 // Dunkel-Türkistöne (0,191,127)
9240 canvas.fillStyle = "rgb(0, " + ((i / count * 191) | 0) + "," + ((i / count * 127) | 0) + ")";
9241 canvas.fillRect(i * width, line, width - sep, height - sep);
9242
9243 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + "," + (191 + (j / (count - 1) * 64) | 0) + ", " + (127 + ((j / (count - 1) * 127) | 0)) + ")";
9244 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9245
9246 line = line + height;
9247
9248
9249 // Cyantöne (0,255,255)
9250 canvas.fillStyle = "rgb(0, " + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ")";
9251 canvas.fillRect(i * width, line, width - sep, height - sep);
9252
9253 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + ",255, 255)";
9254 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9255
9256 line = line + height;
9257
9258 // Hellblautöne (0,127,255)
9259 canvas.fillStyle = "rgb(0, " + ((i / count * 127) | 0) + "," + ((i / count * 255) | 0) + ")";
9260 canvas.fillRect(i * width, line, width - sep, height - sep);
9261
9262 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + "," + (127 + ((j / (count - 1) * 127) | 0)) + ", 255)";
9263 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9264
9265 line = line + height;
9266
9267 // Blautöne (0,0,255)
9268 canvas.fillStyle = "rgb(0, 0, " + ((i / count * 255) | 0) + ")";
9269 canvas.fillRect(i * width, line, width - sep, height - sep);
9270
9271 canvas.fillStyle = "rgb(" + ((j / (count - 1) * 255) | 0) + "," + ((j / (count - 1) * 255) | 0) + ", 255)";
9272 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9273
9274 line = line + height;
9275
9276 // Lilatöne (127,0,255)
9277 canvas.fillStyle = "rgb(" + ((i / count * 127) | 0) + ", 0, " + ((i / count * 255) | 0) + ")";
9278 canvas.fillRect(i * width, line, width - sep, height - sep);
9279
9280 canvas.fillStyle = "rgb(" + (127 + ((j / (count - 1) * 127) | 0)) + "," + ((j / (count - 1) * 255) | 0) + ", 255)";
9281 canvas.fillRect(i * width + offset, line, width - sep, height - sep);
9282
9283 line = line + height;
9284
9285 // Grautöne
9286 /*
9287 canvas.fillStyle = "rgb("+ ((i/count*127)|0) +", "+ ((i/count*127)|0) +", "+ ((i/count*127)|0) +")";
9288 canvas.fillRect(i * width, line, width-sep, height-sep);
9289
9290 canvas.fillStyle = "rgb("+ (127 + ((j/(count-1)*127)|0)) +","+ (127 + ((j/(count-1)*127)|0)) +","+ (127 + ((j/(count-1)*127)|0)) +")";
9291 canvas.fillRect(i * width + offset, line, width-sep, height-sep);
9292
9293 line = line + height;
9294 */
9295
9296 }
9297
9298 line = line + height;
9299
9300 for (var i = 0; i <= count; i++) {
9301 // Grautöne
9302 canvas.fillStyle = "rgb(" + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ", " + ((i / count * 255) | 0) + ")";
9303 canvas.fillRect(i * width + width * 2, line, width - sep, height - sep);
9304 }
9305
9306
9307 // http://www.javascripter.net/faq/rgbtohex.htm
9308 function rgbToHex(R, G, B) {
9309 return toHex(R) + toHex(G) + toHex(B)
9310 }
9311
9312 function toHex(n) {
9313 n = parseInt(n, 10);
9314 if (isNaN(n)) return "00";
9315 n = Math.max(0, Math.min(n, 255));
9316 return "0123456789ABCDEF".charAt((n - n % 16) / 16) + "0123456789ABCDEF".charAt(n % 16);
9317 }
9318
9319 $('#dio_color_picker a.cancel').click(function () {
9320 ColorPicker.close();
9321 });
9322
9323
9324 $('#dio_color_picker a.confirm').click(function () {
9325 // Custom-Event auslösen
9326 $(ColorPicker).trigger("onColorChanged", [$('#dio_color_picker .color_string')[0].value]);
9327 ColorPicker.close();
9328 });
9329
9330 $('#dio_color_picker a.color_table').click(function () {
9331 document.getElementById("c").click();
9332 });
9333
9334 $('#dio_color_picker a.color_table #c').change(function () {
9335 $('#dio_color_picker input.color_string')[0].value = this.value;
9336 $('#dio_color_picker input.color_string')[0].style.color = this.value;
9337 });
9338 }
9339 };
9340
9341 var UnitImages = {
9342 activate : function(){
9343 $('<style id="dio_unit_images">' +
9344
9345 '.unit_icon25x25 { background-image: url(https://diotools.de/images/game/units/unit_icons_25x25_2.91.png);} ' +
9346 '.unit_icon40x40 { background-image: url(https://diotools.de/images/game/units/unit_icons_40x40_2.91.png);} ' +
9347 '.unit_icon50x50 { background-image: url(https://diotools.de/images/game/units/unit_icons_50x50_2.91.png);} ' +
9348 '.unit_icon90x90 { background-image: url(https://diotools.de/images/game/units/unit_icons_90x90_2.91.png);} ' +
9349
9350 '.unit_icon228x165 { background-image: none; height:0px;} ' +
9351 '.unit_card .deco_statue { background-image: none !important;} ' +
9352 '.grepo_box_silver .border_l, .grepo_box_silver .border_r { background-image: none;} ' +
9353 '.box_corner .box_corner_tl, .grepo_box_silver .box_corner_tr { height:31px; } ' +
9354 '.grepo_box_silver .grepo_box_content { padding: 21px 10px 0px; } ' +
9355
9356 '</style>').appendTo('head');
9357 },
9358 deactivate : function(){
9359 $('#dio_unit_images').remove();
9360
9361 }
9362 };
9363
9364 /*******************************************************************************************************************************
9365 * Holiday Special
9366 *******************************************************************************************************************************/
9367
9368 var HolidaySpecial = {
9369 isHalloween : false, isXmas : false, isNewYear : false, isEaster : false,
9370
9371 activate : function(){
9372 var daystamp = 1000*60*60*24, today = new Date((new Date())%(daystamp*(365+1/4))), // without year
9373
9374 // Halloween -> 15 days
9375 halloween_start = daystamp * 297, // 25. Oktober
9376 halloween_end = daystamp * 321, // 8. November
9377 // Xmas -> 28 days
9378 xmas_start = daystamp * 334, // 1. Dezember
9379 xmas_end = daystamp * 361, // 28. Dezember
9380 // NewYear -> 7 days
9381 newYear_start = daystamp * 0, // 1. Januar
9382 newYear_end = daystamp * 7; // 7. Januar
9383
9384 HolidaySpecial.isHalloween = (today >= halloween_start) ? (today <= halloween_end) : false;
9385
9386 HolidaySpecial.isXmas = (today >= xmas_start) ? (today <= xmas_end) : false;
9387
9388 HolidaySpecial.isNewYear = (today >= newYear_start) ? (today <= newYear_end) : false;
9389
9390 if(HolidaySpecial.isXmas){ HolidaySpecial.XMas.add(); }
9391 if(HolidaySpecial.isNewYear){ HolidaySpecial.NewYear.add(); }
9392
9393 // Calculation Easter
9394
9395 // Jahreszahl
9396 var X = 2016;
9397
9398 // Säkularzahl
9399 var K = parseInt(X / 100, 10);
9400 // Mondparameter
9401 var A = X % 19;
9402
9403 // säkulare Mondschaltung
9404 var M = 15 + parseInt((3 * K + 3)/4, 10) - parseInt((8 * K + 13)/25, 10);
9405
9406 // säkulare Sonnenschaltung
9407 var S = 2 - parseInt((3 * K + 3)/4, 10);
9408
9409 // Erster Vollmond im Frühling
9410 var D = (19 * A + M) % 30;
9411
9412 // Kalendarische Korrekturgröße
9413 var R = parseInt((D + parseInt(A / 11, 10)) / 29, 10);
9414
9415 // Ostergrenze
9416 var OG = 21 + D - R;
9417
9418 // Erster Sonntag im März
9419 var SZ = 7 - ((2016 + parseInt(2016/4, 10) + S) % 7);
9420
9421 // Entfernung des Ostersonntags von der Ostergrenze
9422 var OE = 7 - ((OG - SZ) % 7);
9423
9424 // Ostersonntag als Märzdatum
9425 var OS = OG + OE;
9426
9427 // console.debug("DIO-TOOLS | Ostersonntag: " + OS);
9428
9429 },
9430 XMas : {
9431 add : function(){
9432 $('<a href="http://www.greensmilies.com/smilie-album/weihnachten-smilies/" target="_blank"><div id="dio_xmas"></div></a>').appendTo('#ui_box');
9433
9434 var dioXMAS = $('#dio_xmas');
9435
9436 dioXMAS.css({
9437 background: 'url("http://www.greensmilies.com/smile/smiley_emoticons_weihnachtsmann_nordpol.gif") no-repeat',
9438 height: '51px',
9439 width: '61px',
9440 position:'absolute',
9441 bottom:'10px',
9442 left:'60px',
9443 zIndex:'2000'
9444 });
9445 dioXMAS.tooltip("Ho Ho Ho, Merry Christmas!");
9446 }
9447 },
9448 NewYear : {
9449 add : function(){
9450 // TODO: Jahreszahl dynamisch setzen
9451 $('<a href="http://www.greensmilies.com/smilie-album/" target="_blank"><div id="dio_newYear">'+
9452 '<img src="http://www.greensmilies.com/smile/sign2_2.gif">'+
9453 '<img src="http://www.greensmilies.com/smile/sign2_0.gif">'+
9454 '<img src="http://www.greensmilies.com/smile/sign2_1.gif">'+
9455 '<img src="http://www.greensmilies.com/smile/sign2_9.gif">'+
9456 '</div></a>').appendTo('#ui_box');
9457
9458 var dioNewYear = $('#dio_newYear');
9459
9460 dioNewYear.css({
9461 position:'absolute',
9462 bottom:'10px',
9463 left:'70px',
9464 zIndex:'10'
9465 });
9466 dioNewYear.tooltip("Happy new year!");
9467 }
9468 }
9469 };
9470
9471}