// ==UserScript== // @name DIO-TOOLS-David1327 // @name:fr DIO-TOOLS-David1327 // @namespace https://www.tuto-de-david1327.com/pages/info/dio-tools-david1327.html // @version 4.35 // @author DIONY (changes and bug fixes by David1327) // @description Version 2024. DIO-Tools + Quack is a small extension for the browser game Grepolis. (counter, displays, smilies, trade options, changes to the layout) // @description:FR Version 2024. DIO-Tools + Quack est une petite extension du jeu par navigateur Grepolis. (compteur, affichages, smileys, options commerciales, modifications de la mise en page) // @match https://*.grepolis.com/game/* // @match https://*.forum.grepolis.com/* // @match https://dio-david1327.github.io/* // @updateURL https://dio-david1327.github.io/DIO-TOOLS-David1327/code.user.js // @downloadURL https://dio-david1327.github.io/DIO-TOOLS-David1327/code.user.js // @require https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js // @resource clipboard https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js // @icon https://dio-david1327.github.io/img/smileys/bussi2.gif // @icon64 https://www.tuto-de-david1327.com/medias/images/dio-tools-david1327.jpg // @copyright 2013+, DIONY and 2019+, David1327 // @grant GM_setValue // @grant GM_getValue // @grant GM_deleteValue // @grant GM_xmlhttpRequest // @grant GM_getResourceText // @license GPL-3.0-only // ==/UserScript== let dio_version = GM.info.script.version; /******************************************************************************************************************************* * Global stuff *******************************************************************************************************************************/ var uw = unsafeWindow || window, $ = uw.jQuery, DATA, GMM, url_dev; // GM-API? if (GM.info.scriptHandler == "Greasemonkey") GMM = false else GMM = (typeof GM_info === 'object'); //GMM = true; //GMM = false; //url_dev = true; console.log('%c|= ' + GM.info.script.name + ' is active v' + dio_version + ' (' + GM.info.scriptHandler + ' v' + GM.info.version + ') [GMM ' + GMM + '] =|', 'color: green; font-size: 1em; font-weight: bolder; '); function loadValue(name, default_val) { var value; if (GMM) { value = GM_getValue(name, default_val); } else { value = localStorage.getItem(name) || default_val; } if (typeof (value) === "string") { value = JSON.parse(value) } return value; } // LOAD DATA if ((uw.location.pathname.indexOf("game") >= 0)) { var WID = uw.Game.world_id, MID = uw.Game.market_id, AID = uw.Game.alliance_id; DATA = { // GLOBAL options: loadValue("options", "{}"), test: loadValue("test", "{}"), user: loadValue("dio_user", "{}"), notification: loadValue('notif', '0'), update: loadValue('update', '0'), notiff: loadValue('notiff', '0'), error: loadValue('error', '{}'), // WORLD townTypes: loadValue(WID + "_townTypes", "{}"), townAuto: loadValue(WID + "_townAuto", "{}"), sentUnits: loadValue(WID + "_sentUnits", '{ "attack": {}, "support": {} }'), biremes: loadValue(WID + "_biremes", "{}"), //old bullseyeUnit: loadValue(WID + "_bullseyeUnit", '{ "current_group" : -1 }'), // new worldWonder: loadValue(WID + "_wonder", '{ "ratio": {}, "storage": {}, "map": {} }'), Overviews: loadValue("Overviews", '{ "Buildings": "", "Culture": "", "Gods": "" }'), wall: loadValue(WID + '_wall', '[]'), volumeControl: loadValue('volumeControl', '0.5'), URLAlarm: loadValue('URLAlarm', JSON.stringify("https://dio-david1327.github.io/audio/alarm.mp3")), // MARKET worldWonderTypes: loadValue(MID + "_wonderTypes", '{}') }; if (!DATA.worldWonder.map) { DATA.worldWonder.map = {}; } // Temporary: if (typeof DATA.options.dio_trd == 'boolean') { DATA.options.dio_per = DATA.options.dio_rec = DATA.options.dio_trd; delete DATA.options.dio_trd; } if (typeof DATA.options.dio_mov == 'boolean') { DATA.options.dio_act = DATA.options.dio_mov; delete DATA.options.dio_mov; } if (typeof DATA.options.dio_twn == 'boolean') { DATA.options.dio_tic = DATA.options.dio_til = DATA.options.dio_tim = DATA.options.dio_twn; delete DATA.options.dio_twn; } if (GMM) GM_deleteValue("notification"); } // GM: EXPORT FUNCTIONS uw.saveValueGM = function (name, val) { setTimeout(() => { GM_setValue(name, val); }, 0); }; uw.deleteValueGM = function (name) { setTimeout(() => { GM_deleteValue(name); }, 0); }; var time_a, time_b; // APPEND SCRIPT function appendScript() { //console.log("GM-API: " + gm_bool); if (document.getElementsByTagName('body')[0]) { if (GMM) { const scriptclipboard = document.createElement("script"); scriptclipboard.textContent = GM_getResourceText("clipboard"); document.body.appendChild(scriptclipboard); } var dioscript = document.createElement('script'); dioscript.type = 'text/javascript'; dioscript.id = 'diotools'; time_a = uw.Timestamp.client(); dioscript.textContent = DIO_GAME.toString().replace(/uw\./g, "") + "\n DIO_GAME('" + dio_version + "', " + GMM + ", '" + JSON.stringify(DATA).replace(/'/g, "##") + "', " + time_a + ", " + url_dev + ");"; document.body.appendChild(dioscript); } else setTimeout(() => { appendScript(); }, 500); } if (location.host === "dio-david1327.github.io") { DIO_PAGE(); } // PAGE else if ((uw.location.pathname.indexOf("game") >= 0)) { try { $('').appendTo("head"); if (!GMM) $('').appendTo("head"); //$('').appendTo("head"); } catch (error) { console.log(error, '').appendTo("head"); */ console.debug("SPRACHE", MID); // Translation GET function getTexts(category, name, data) { var txt = "???", lang = MID; if (DATA.test.lang && !data) { lang = DATA.test.lang } if (LANG[lang]) { if (LANG[lang][category]) { if (LANG[lang][category][name]) { txt = LANG[lang][category][name]; } else { if (LANG.en[category]) { if (LANG.AUTO[category][name]) { txt = LANG.AUTO[category][name]; } else if (LANG.en[category][name]) { txt = LANG.en[category][name]; } } } } else { if (LANG.en[category]) { if (LANG.AUTO[category][name]) { txt = LANG.AUTO[category][name]; } else if (LANG.en[category][name]) { txt = LANG.en[category][name]; } } } } else { if (LANG.en[category]) { if (LANG.AUTO[category][name]) { txt = LANG.AUTO[category][name]; } else if (LANG.en[category][name]) { txt = LANG.en[category][name]; } } } return txt; } /******************************************************************************************************************************* * Settings *******************************************************************************************************************************/ // (De)activation of the features var Options_def = { dio_bir: true, // Biremes counter dio_ava: true, // Available units dio_ava2: true, // Available units dio_sml: true, // Smileys dio_str: true, // Unit strength dio_tra: true, // Transport capacity dio_per: true, // Percentual Trade dio_rec: true, // Recruiting Trade dio_way: true, // Troop speed dio_cnt: true, // Attack/support counter dio_sim: true, // Simulator dio_act: true, // Activity boxes dio_tsk: true, // Task bar dio_pop: true, // Favor popup dio_bbc: true, // BBCode bar dio_com: true, // Unit comparison dio_TEST: false,// Unit comparison dio_tic: true, // Town icons dio_tic2: true, // Town icons dio_til: true, // Town icons: Town list dio_tim: true, // Town icons: Map dio_tiw: true, // Town Popup dio_tpt: true, // Town Popup troop dio_tis: true, // Town Popup support dio_tih: true, // Town Popup Hero dio_tir: true, // Town Popup Resource dio_wwc: true, // World wonder counter dio_wwr: false, // World wonder ranking dio_wwi: false, // World wonder icons dio_con: true, // Context menu dio_sen: true, // Sent units dio_tov: false, // Town overview dio_scr: true, // Mausrad, dio_Scr: true, // Scrollbar Style dio_Tow: true, // town bb dio_Rew: true, // minimize Daily Reward dio_Fdm: true, // ForumDeleteMultiple dio_Sel: true, // selectunitshelper dio_Cul: true, // cultureOverview dio_Cup: true, // cultureProgress dio_Cuo: true, // culturePoints dio_Hot: true, // hotkeys dio_Isl: true, // islandFarmingVillages dio_Ish: true, // farmingvillageshelper dio_Hio: true, // hidesOverview dio_Hid: true, // hidesIndexIron dio_Tol: true, // townslist dio_Cib: true, // city_view_btn dio_Ciw: false, // city_view_window dio_Cic: false, // city_btn_construction dio_Tti: true, // townTradeImprovement dio_Mse: true, // MessageExport dio_Rep: true, // reports dio_Rct: true, // resCounter dio_BBt: true, // BBtowninfo dio_Rtt: false, // removeTooltipps dio_Buc: true, // buildingControl dio_Cuc: true, // cultureControl dio_BBl: true, // BBcodeList dio_Onb: true, // OceanNumbers dio_Amm: true, // ally_mass_mail dio_Idl: true, // idle dio_Saw: true, // Save_wall dio_Att: true, // AttacksAlarms dio_err: false, // Error Reports dio_her: true, // Thrakische Eroberung //color dio_aaa: true, dio_bbb: false, dio_ccc: false, dio_ddd: false, dio_eee: false, }; DATA.options.dio_Sav = false saveValue("options", JSON.stringify(DATA.options)); if (!uw.Game.features.end_game_type == "end_game_type_world_wonder") { delete Options_def.dio_wwc; delete Options_def.dio_wwr; delete Options_def.dio_wwi; } if (!typeof (uw.MoleHoleOnBoard) == "undefined") { delete Options_def.dio_Ciw; } if (!typeof (uw.FLASK_GAME) == "undefined") { delete Options_def.dio_til; delete Options_def.dio_Sel; } if (uw.location.pathname.indexOf("game") >= 0) { for (var opt in Options_def) { if (Options_def.hasOwnProperty(opt)) { if (DATA.options[opt] === undefined) { DATA.options[opt] = Options_def[opt]; } } } } var version_text = '', version_color = 'black'; $('').appendTo("head"); function getLatestVersion() { var version_latest = "??"; try { version_latest = uw.dio_latest_version; } catch (error) { errorHandling(error, "dio_latest_version (getLatestVersion)"); } var v_info = $('#dio_version_info'); try { if (version_text === '') { if (dio_version > version_latest) { version_text = "
" + getTexts("Settings", 'version_dev') + "
"; version_color = 'darkblue'; $('.dio_settings .dio_icon').css({ filter: "hue-rotate(100deg)" }); tooltip_settings(); } else if (dio_version == version_latest) { version_text = "
" + getTexts("Settings", 'version_new') + "
"; } else { version_text = "
" + getTexts("Settings", 'version_old') + "
" + "--> " + getTexts("Settings", 'version_update') + ""; version_color = 'crimson'; $('.dio_settings .dio_icon').css({ filter: "hue-rotate(260deg)" }); tooltip_settings(); } v_info.html(version_text).css({ color: version_color }); } else { v_info.html(version_text).css({ color: version_color }); } } catch (error) { errorHandling(error, "getLatestVersion"); if (version_text === '') { version_text = "
" + getTexts("Settings", 'version_old') + "
" + "--> " + getTexts("Settings", 'version_update') + ""; version_color = 'crimson'; $('.dio_settings .dio_icon').css({ filter: "hue-rotate(260deg)" }); v_info.html(version_text).css({ color: version_color }); } else { v_info.html(version_text).css({ color: version_color }); } } } /******************************************************************************************************************************* * Add DIO-Tools to grepo settings *******************************************************************************************************************************/ // Styles $('').appendTo('head'); function settings() { var wid = $(".settings-menu").get(0).parentNode.id; if (!$("#dio_tools").get(0)) { $(".settings-menu ul:last").append('
  • DIO-Tools-David1327
  • '); } $(".settings-link").click(function () { $('.section').each(function () { this.style.display = "block"; }); $('.settings-container').removeClass("dio_overflow"); $('#dio_bg_medusa').css({ display: "none" }); if ($('#dio_settings').get(0)) { $('#dio_settings').get(0).style.display = "none"; } }); $("#dio_tools").click(function () { if ($('.email').get(0)) $('.settings-container').removeClass("email"); $('.settings-container').addClass("dio_overflow"); $('#dio_bg_medusa').css({ display: "block" }); if (!$('#dio_settings').get(0)) { var Browser = getBrowser().replace(/(1|2|3|4|5|6|7|8|9|\ )/gm, ""); var Navigator = navigator.language[0] + navigator.language[1]; var trans = [(DATA.test.lang ? "Actuel " + (DATA.test.lang).toUpperCase() : getTexts("translations", "translations")), getTexts("buttons", "res") + " (" + (MID).toUpperCase() + ")"]; (typeof (navigator) ? (LANG[Navigator] ? trans.push(getTexts("labels", "loc") + " " + Navigator.toUpperCase()) : "") : ""); var dio_supported_lang = [getTexts("translations", "add_edit")]; $.each(LANG, function (a, b) { if (a != "AUTO") dio_supported_lang.push(a); }); dio_supported_lang.sort() $('.settings-container').append( '
    ' + '
    DIO-TOOLS-David1327 (v' + dio_version + ')' + '
    ' + dio.grepo_dropdown_flag("dio_langdiv", dio_supported_lang, trans, null, getTexts("translations", "language"))[0].outerHTML + '
    ' + '
    ' + // Check latest version '
    ' + // Donate button '
    ' + dio.createBtnDonate(getTexts("Settings", "Donate"), null, null, 0, getTexts("link", "Donate")) + '
    ' + // '
    ' + // Settings navigation '' + // Settings content '
    ' + // Units tab '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + // Icons tab '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + // Forum tab '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + // Trade tab '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + // Layout tab '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + ((Browser !== 'Firefox') ? ('' + '' + '' + '') : "") + '' + '' + '' + '' + '' + '' + '' + //reports '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + // Other Stuff tab '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + /*'' + '' +*/ //((Game.features.is_domination_active = false) ? ( ((uw.Game.features.end_game_type == "end_game_type_world_wonder") ? ( '' + '' + '') : "") + '' + // Premium '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + // Quack '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + ((MID == 'fr' || MID == 'de' || MID == 'en' || MID == 'zz') ? ( '' + '') : "") + '' + // GRCT '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + /*'' + '' + '' +*/ '' + '
    ' + // Links (Forum, PM, ...) '
    ' + '' + '' + getTexts("tutoriel", "tuto") + '' + '' + getTexts("Settings", "cat_forum") + ': ' + 'DIO-TOOLS-David1327' + '' + '' + getTexts("Settings", "forum") + '' + '
    ' + '
    '); getLatestVersion(); $("#dio_langdiv").change(function () { let lang = $(this).val().toLowerCase(); //console.log($(this)); if ($(this).val() === (DATA.test.lang ? (DATA.test.lang).toUpperCase() : getTexts("translations", "translations"))) { return; } else if ($(this).val() === getTexts("translations", "add_edit")) { dio.add_lang = true; Notification.activate(); uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_PLAYER_SETTINGS).close(); return; } else if ($(this).val() === getTexts("labels", "loc") + " " + Navigator.toUpperCase()) { DATA.test.lang = Navigator; saveValue("test", JSON.stringify(DATA.test)); uw.HumanMessage.success(getTexts("translations", "translations") + " " + getTexts("labels", "loc") + " " + Navigator.toUpperCase()); } else if ($(this).val() === getTexts("buttons", "res") + " (" + (MID).toUpperCase() + ")") { DATA.test.lang = ""; deleteValue("test", JSON.stringify(DATA.test)); uw.HumanMessage.success(getTexts("translations", "translations") + " " + getTexts("buttons", "res") + " (" + MID + ")"); } else { DATA.test.lang = lang; saveValue("test", JSON.stringify(DATA.test)); uw.HumanMessage.success(getTexts("translations", "translations") + " " + lang); } uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_PLAYER_SETTINGS).close(); openSettings(); //var tooltip_str = "DIO-Tools-David1327: " + (uw.DM.getl10n("layout", "config_buttons").settings || "Settings") + "
    v" + dio_version + " [" + (DATA.test.lang ? (DATA.test.lang === "zz" ? "EN" : (DATA.test.lang).toUpperCase()) : (MID === "zz" ? "EN" : MID)) + "]"; tooltip_settings(); return; }); // Tab event handler $('#dio_settings .dio_settings_tabs .submenu_link').click(function () { if (!$(this).hasClass("active")) { $('#dio_settings .dio_settings_tabs .submenu_link.active').removeClass("active"); $(this).addClass("active"); $("#dio_settings .visible").removeClass("visible"); $("#" + this.id + "_table").addClass("visible"); } }); // $('#tuto').tooltip(getTexts("Settings", "Update") + " " + dio_version + " / " + getTexts("labels", "donat") + " / " + getTexts("translations", "translations") + " / BUG"); $('#tuto').click(() => { Notification.activate(); }); $('#dio_settings .défaut_s').tooltip(dio_icon + getTexts("buttons", "res")); $("#dio_settings .défaut_s").click(() => { uw.hOpenWindow.showConfirmDialog(getTexts("buttons", "res"), getTexts("labels", "raf"), function () { deleteValue("options"); location.reload(); }); }); $('#tuto2').click(() => { dio.bug = true; Notification.activate(); }); $("#dio_settings .checkbox_new").click(function () { $(this).toggleClass("checked").toggleClass("green"); toggleActivation(this.id); if (Options_def[this.id] === undefined) $(this).toggleClass("disabled") DATA.options[this.id] = $(this).hasClass("checked"); saveValue("options", JSON.stringify(DATA.options)); }); $('#dio_settings .radiobutton .option').click(function () { $('#dio_settings .radiobutton .option').removeClass("checked").removeClass("green"); DATA.options.dio_aaa = false; DATA.options.dio_bbb = false; DATA.options.dio_ccc = false; DATA.options.dio_ddd = false; DATA.options.dio_eee = false; $(this).toggleClass("checked").toggleClass("green"); toggleActivation(this.id); DATA.options[this.id] = $(this).hasClass("checked"); saveValue("options", JSON.stringify(DATA.options)); if (DATA.options.dio_Scr) { Scrollbar.add(); }; }); for (var e in DATA.options) { if (DATA.options.hasOwnProperty(e)) { if (DATA.options[e] === true) { $("#" + e).addClass("checked").addClass("green"); } } } $('#dio_save').click(function () { $('#dio_settings .checkbox_new').each(function () { var act = false; if ($("#" + this.id).hasClass("checked")) { act = true; } DATA.options[this.id] = act; }); $('#dio_settings .radiobutton .option').each(function () { var act = false; if ($(this.id).hasClass("checked")) { act = true; } DATA.options[this.id] = act; }); saveValue("options", JSON.stringify(DATA.options)); }); //$('#dio_volumeControl').val(DATA.volumeControl); // Récupérez la valeur du contrôle de volume et mettez à jour le volume audio $('#dio_volumeControl').on('input', function () { var volume = $(this).val(); AttacksAlarms.audioElement[0].volume = volume; AttacksAlarms.audio.volume = (volume > 0.3 ? volume : 0.3) // Contrôle de volume //$(this).val(volume); saveValue("volumeControl", JSON.stringify(volume)); }); // Gérez l'événement du clic sur le bouton $("#setCustomUrlBtn").on("click", function () { var customUrl = $("#customUrlInput").val(); // Vérifiez si l'URL est non vide avant de la définir if (customUrl.trim() !== "") { AttacksAlarms.setMusicURL(customUrl); } else { uw.HumanMessage.error(dio_icon + "Veuillez entrer une URL.") //uw.HumanMessage.error(dio_icon + getTexts("wall", "erreur")) } }); } $('.section').each(function () { this.style.display = "none"; }); $('#dio_settings').get(0).style.display = "block"; }); } function toggleActivation(opt) { var FEATURE, activation = true; switch (opt) { case "dio_sml": FEATURE = SmileyBox; break; case "dio_str": FEATURE = UnitStrength.Menu; break; case "dio_tra": FEATURE = TransportCapacity; break; case "dio_ava": FEATURE = AvailableUnits; break; case "dio_ava2": FEATURE = AvailableUnits.ocean; break; case "dio_sim": FEATURE = Simulator; break; case "dio_tsk": FEATURE = Taskbar; break; case "dio_scr": FEATURE = MouseWheelZoom; break; case "dio_com": FEATURE = UnitComparison; break; case "dio_pop": FEATURE = FavorPopup; break; case "dio_con": FEATURE = ContextMenu; break; case "dio_tic": FEATURE = TownIcons; break; case "dio_tic2": FEATURE = TownIcons.auto; break; case "dio_tiw": FEATURE = TownPopup; break; case "dio_tim": FEATURE = Map; break; case "dio_til": if (typeof (uw.FLASK_GAME) == "undefined") { FEATURE = TownList; } break; case "dio_sen": FEATURE = SentUnits; break; case "dio_act": FEATURE = ActivityBoxes; break; case "dio_wwc": FEATURE = WorldWonderCalculator; break; /*case "dio_wwr": FEATURE = WorldWonderRanking; break;*/ case "dio_wwi": FEATURE = WorldWonderIcons; break; case "dio_rec": FEATURE = RecruitingTrade; break; case "dio_way": FEATURE = ShortDuration; break; case "dio_Scr": FEATURE = Scrollbar; break; case "dio_Tow": FEATURE = Townbb; break; case "dio_Rew": FEATURE = Reward; break; case "dio_Fdm": FEATURE = ForumDeleteMultiple; break; case "dio_Sel": if (typeof (uw.FLASK_GAME) == "undefined") { FEATURE = selectunitshelper; } break; case "dio_Cul": FEATURE = cultureOverview; break; case "dio_Cup": FEATURE = cultureProgress; break; case "dio_Cuo": FEATURE = culturePoints; break; case "dio_Hot": FEATURE = hotkeys; break; case "dio_Isl": FEATURE = islandFarmingVillages; break; case "dio_Ish": FEATURE = farmingvillageshelper; break; case "dio_Hio": FEATURE = hidesOverview; break; case "dio_Hid": FEATURE = hidesIndexIron; break; case "dio_Tol": FEATURE = townslist; break; case "dio_Cib": FEATURE = city_view_btn; break; case "dio_Ciw": if (typeof (uw.MoleHoleOnBoard) == "undefined") { FEATURE = city_view_window; } break; case "dio_Cic": FEATURE = city_btn_construction; break; case "dio_Tti": FEATURE = townTradeImprovement; break; case "dio_Mse": FEATURE = MessageExport; break; case "dio_Rep": FEATURE = reports; break; case "dio_Rct": FEATURE = resCounter; break; case "dio_BBt": FEATURE = BBtowninfo; break; case "dio_Rtt": FEATURE = removetooltipps; break; case "dio_Buc": FEATURE = buildingControl; break; case "dio_Cuc": FEATURE = cultureControl; break; case "dio_BBl": FEATURE = BBcodeList; break; case "dio_Onb": FEATURE = OceanNumbers; break; case "dio_Amm": FEATURE = ally_mass_mail; break; case "dio_Idl": FEATURE = idle; break; case "dio_Saw": FEATURE = Save_wall; break; case "dio_Att": FEATURE = AttacksAlarms; break; default: activation = false; break; } if (activation) { if (DATA.options[opt]) { FEATURE.deactivate(); } else { FEATURE.activate(); } } } function tooltip_settings() { var tooltip_str = "DIO-Tools-David1327: " + getTexts("hotkeys", "settings") + "
    v" + dio_version + " [" + (DATA.test.lang ? (DATA.test.lang === "zz" ? "EN" : (DATA.test.lang).toUpperCase()) : (MID === "zz" ? "EN" : MID)) + "]"; var version_latest = "??"; try { version_latest = uw.dio_latest_version; } catch (error) { } if (version_latest !== "??") { if (dio_version < version_latest) { tooltip_str += "
    " + getTexts("Settings", 'version_old'); } else if (dio_version > version_latest) { tooltip_str += "
    " + getTexts("Settings", 'version_dev') } } return $('.dio_settings').tooltip(tooltip_str); } function addSettingsButton() { $('
    ').appendTo(".gods_area"); // Style $('').appendTo('head'); // Tooltip tooltip_settings(); // Mouse Events $('.dio_settings').on('mousedown', function () { $('.dio_icon').addClass('click'); }); $('.dio_settings').on('mouseup', function () { $('.dio_icon').removeClass('click'); }); $('.dio_settings').click(openSettings); } var diosettings = false; function openSettings() { if (!uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_PLAYER_SETTINGS)) { diosettings = true; } else { $('#dio_tools').click(); } uw.Layout.wnd.Create(uw.GPWindowMgr.TYPE_PLAYER_SETTINGS, getTexts("hotkeys", "settings")); } var exc = false, sum = 0, ch = ["IGCCJB"], alpha = 'ABCDEFGHIJ'; function a() { var pA = PID.toString(), pB = ""; for (var c in pA) { if (pA.hasOwnProperty(c)) { pB += alpha[pA[parseInt(c, 10)]]; } } sum = 0; for (var b in ch) { if (ch.hasOwnProperty(b)) { if (pB !== ch[b]) { exc = true; } else { exc = false; return; } for (var s in ch[b]) { if (ch[b].hasOwnProperty(s)) { sum += alpha.indexOf(ch[b][s]); } } } } } var autoTownTypes, manuTownTypes, manuTownAuto, population, sentUnitsArray, biriArray, wonder, wonderTypes, Overviews; function setStyle() { // Settings $('').appendTo('head'); // Town Icons $('').appendTo('head'); // Tutorial-Quest Container $('').appendTo('head'); // Velerios //$('').appendTo('head'); // Specific player wishes if (PID == 1212083) { $('').appendTo('head'); } } function loadFeatures() { if (typeof (ITowns) !== "undefined") { autoTownTypes = {}; manuTownTypes = DATA.townTypes; manuTownAuto = DATA.townAuto; population = {}; sentUnitsArray = DATA.sentUnits; biriArray = DATA.biremes; wonder = DATA.worldWonder; wonderTypes = DATA.worldWonderTypes; Overviews = DATA.Overviews var DIO_USER = { 'name': uw.Game.player_name, 'market': MID }; saveValue("dio_user", JSON.stringify(DIO_USER)); if (Overviews.Culture == "") { Overviews.Culture = uw.DM.getl10n("mass_recruit").sort_by.name; Overviews.Culture_Dif = ">"; Overviews.Buildings = uw.DM.getl10n("mass_recruit").sort_by.name; Overviews.Buildings_Dif = ">"; Overviews.Gods = uw.DM.getl10n("mass_recruit").sort_by.name; //Overviews.hour = 0; //Overviews.minute = 0; saveValue("Overviews", JSON.stringify(Overviews)); } $.Observer(uw.GameEvents.game.load).subscribe('DIO_START', function (e, data) { a(); // English => default language if (!LANG[LID]) { LID = "en"; } if ((ch.length == 1) && exc && (sum == 28)) { // AJAX-EVENTS setTimeout(() => { ajaxObserver(); }, 0); addSettingsButton(); addFunctionToITowns(); if (DATA.options.dio_tsk) { setTimeout(() => { Taskbar.activate(); }, 0); } //addStatsButton(); fixUnitValues(); setTimeout(() => { var waitCount = 0; // No comment... it's Grepolis... i don't know... *rolleyes* function waitForGrepoLazyLoading() { if (typeof (uw.ITowns.townGroups.getGroupsDIO()[-1]) !== "undefined" && typeof (uw.ITowns.getTown(uw.Game.townId).getBuildings) !== "undefined") { try { // Funktion wird manchmal nicht ausgeführt: var units = uw.ITowns.getTown(uw.Game.townId).units(); getAllUnits(); setInterval(() => { getAllUnits(); }, 5000); // 15min setTimeout(() => { getLatestVersion(); }, 2000); if (DATA.options.dio_ava) setTimeout(() => { AvailableUnits.activate(); }, 0); if (DATA.options.dio_ava2) setTimeout(() => { AvailableUnits.ocean.activate(); }, 0); if (DATA.options.dio_tic) setTimeout(() => { TownIcons.activate(); }, 0); if (DATA.options.dio_tic) setTimeout(() => { TownIcons.auto.activate(); }, 0); if (DATA.options.dio_tiw) setTimeout(() => { TownPopup.activate(); }, 0); if (DATA.options.dio_tim) setTimeout(() => { Map.activate(); }, 100); if (DATA.options.dio_til & (typeof (uw.FLASK_GAME) == "undefined")) setTimeout(() => { TownList.activate(); }, 0); } catch (e) { if (waitCount < 12) { waitCount++; console.warn("DIO-Tools | Fehler | getAllUnits | units() fehlerhaft ausgeführt?", e); // Ausführung wiederholen setTimeout(() => { waitForGrepoLazyLoading(); }, 5000); // 5s } else { errorHandling(e, "waitForGrepoLazyLoading2"); } } } else { var e = { "stack": "getGroups() = " + typeof (uw.ITowns.townGroups.getGroupsDIO()[-1]) + ", getBuildings() = " + typeof (uw.ITowns.getTown(uw.Game.townId).getBuildings) }; if (waitCount < 12) { waitCount++; console.warn("DIO-Tools | Fehler | getAllUnits | " + e.stack); // Ausführung wiederholen setTimeout(() => { waitForGrepoLazyLoading(); }, 5000); // 5s } else { errorHandling(e, "waitForGrepoLazyLoading2"); } } } waitForGrepoLazyLoading(); }, 0); imageSelectionProtection(); if (DATA.options.dio_pop) setTimeout(() => { FavorPopup.activate(); }, 0); if (DATA.options.dio_con) setTimeout(() => { ContextMenu.activate(); }, 0); if (DATA.options.dio_act) setTimeout(() => { ActivityBoxes.activate(); }, 0); if (DATA.options.dio_str) setTimeout(() => { UnitStrength.Menu.activate(); }, 0); if (DATA.options.dio_tra) setTimeout(() => { TransportCapacity.activate(); }, 0); if (DATA.options.dio_com) setTimeout(() => { UnitComparison.activate(); }, 0); if (DATA.options.dio_sml) setTimeout(() => { SmileyBox.activate(); }, 0); if (DATA.options.dio_scr) setTimeout(() => { MouseWheelZoom.activate(); }, 0); if (DATA.options.dio_sim) setTimeout(() => { Simulator.activate(); }, 0); if (DATA.options.dio_sen) setTimeout(() => { SentUnits.activate(); }, 0); if (uw.Game.features.end_game_type == "end_game_type_world_wonder") { if (DATA.options.dio_wwc) setTimeout(() => { WorldWonderCalculator.activate(); }, 0); } if (DATA.options.dio_rec) setTimeout(() => { RecruitingTrade.activate(); }, 0); if (DATA.options.dio_way) setTimeout(() => { ShortDuration.activate(); }, 0); if (DATA.options.dio_Scr) setTimeout(() => { Scrollbar.activate(); }, 0); if (DATA.options.dio_Tow) setTimeout(() => { Townbb.activate(); }, 100); if (DATA.options.dio_Hot) setTimeout(() => { hotkeys.activate(); }, 3000); if (DATA.options.dio_Isl) setTimeout(() => { islandFarmingVillages.activate(); }, 500); if (DATA.options.dio_Rew) setTimeout(() => { Reward.activate(); }, 100); if (DATA.options.dio_Cib) setTimeout(() => { city_view_btn.activate(); }, 1000); if (DATA.options.dio_Ciw & (typeof (uw.MoleHoleOnBoard) == "undefined")) setTimeout(() => { city_view_window.activate(); }, 1000); if (DATA.options.dio_Cic) setTimeout(() => { city_btn_construction.activate(); }, 1000); if (DATA.options.dio_Tti) setTimeout(() => { townTradeImprovement.activate(); }, 0); if (DATA.options.dio_Hio) setTimeout(() => { hidesOverview.activate(); }, 1000); if (DATA.options.dio_Rtt) setTimeout(() => { removetooltipps.activate(); }, 100); if (DATA.options.dio_Rct) setTimeout(() => { resCounter.activate(); }, 0); if (DATA.options.dio_Hid) setTimeout(() => { hidesIndexIron.activate(); }, 0); if (DATA.options.dio_Tol) setTimeout(() => { townslist.activate(); }, 100); if (DATA.options.dio_BBt) setTimeout(() => { BBtowninfo.activate(); }, 100); if (DATA.options.dio_Cul) setTimeout(() => { cultureOverview.activate(); }, 100); if (DATA.options.dio_Cuc) setTimeout(() => { cultureControl.activate(); }, 100); if (DATA.options.dio_Buc) setTimeout(() => { buildingControl.activate(); }, 100); if (DATA.options.dio_Cup) setTimeout(() => { cultureProgress.activate(); }, 0); if (DATA.options.dio_BBl) setTimeout(() => { BBcodeList.activate(); }, 0); if (DATA.options.dio_Onb) setTimeout(() => { OceanNumbers.activate(); }, 0); if (DATA.options.dio_Amm) setTimeout(() => { ally_mass_mail.activate(); }, 0); if (DATA.options.dio_Idl) setTimeout(() => { idle.activate(); }, 0); if (DATA.options.dio_Saw) setTimeout(() => { Save_wall.activate(); }, 0); if (DATA.options.dio_Att) setTimeout(() => { AttacksAlarms.activate(); }, 0); // compatibility flask-tools ? if (typeof (uw.FLASK_GAME) !== "undefined") setTimeout(() => { compatibility.flask_tools(); }, 2000); // Notifications setTimeout(() => { Notification.init(); }, 0); setTimeout(() => { HolidaySpecial.activate(); }, 0); setTimeout(() => { dio.style(); }, 0); cache(); player_idle(); setInterval(() => { player_idle(); console.log("actualisé") }, 1860000); setInterval(() => { cache(); }, 4000000); // Execute once to get alliance ratio if (uw.Game.features.end_game_type == "end_game_type_world_wonder") { setTimeout(() => { uw.getPointRatioFromCache() }, 10000); } } time_b = uw.Timestamp.client(); }); } else { setTimeout(() => { loadFeatures(); }, 100); } } if (uw.location.pathname.indexOf("game") >= 0) { setStyle(); loadFeatures(); } /******************************************************************************************************************************* * HTTP-Requests * *****************************************************************************************************************************/ function ajaxObserver() { $(document).ajaxComplete(function (e, xhr, opt) { var url = opt.url.split("?"), action = ""; //console.log("0: ", url[0]); //console.log("1: ", url[1]); if (typeof (url[1]) !== "undefined" && typeof (url[1].split(/&/)[1]) !== "undefined") { action = url[0].substr(5) + "/" + url[1].split(/&/)[1].substr(7); } if (PID == 84367 || PID == 104769 || PID == 1577066 || PID == 100144 || david1327) { console.log("action=>", action); } var wnd = uw.GPWindowMgr.getFocusedWindow() || false; if (wnd) { dio.wndId = wnd.getID(); dio.wnd = wnd.getJQElement().find(".gpwindow_content"); } /* eslint-disable no-fallthrough */ switch (action) { case "/map_data/get_chunks": if (DATA.options.dio_tim) Map.add(); if (DATA.options.dio_Onb) OceanNumbers.add(); break; case "/notify/fetch": if (uw.WM.isOpened("notes")) { if (!$('.notes_container .bb_button_wrapper .dio_smiley_button').get(0) & $(".notes_container .bb_button_wrapper").length) { if (DATA.options.dio_sml) SmileyBox.add("/frontend_bridge/execute"); if (DATA.options.dio_bbc) addForm("/frontend_bridge/execute"); } } break; case "/frontend_bridge/fetch": // Daily Reward if (DATA.options.dio_tim) Map.add(); if (DATA.options.dio_Rew) Reward.activate(); if (DATA.options.dio_Rtt) dio.removeTooltipps(); ///if (DATA.options.dio_Hid) hidesIndexIron.add(); case "/frontend_bridge/execute": if (DATA.options.dio_sml) SmileyBox.add(action); if (DATA.options.dio_bbc) addForm(action); break; case "/player/index": settings(); if (diosettings) { $('#dio_tools').click(); diosettings = false; } break; case "/building_hide/index": break; case "/building_barracks/index": case "/building_barracks/build": case "/building_barracks/cancel": case "/building_barracks/units": if (DATA.options.dio_str) UnitStrength.Barracks.add(); if (DATA.options.dio_Rtt) dio.removeTooltipps(); if (DATA.options.dio_Rtt) dio.removeTooltipps("barracks"); reload.add(action) break; case "/building_docks/index": case "/building_docks/build": case "/building_docks/cancel": if (DATA.options.dio_Rtt) dio.removeTooltipps(); if (DATA.options.dio_Rtt) dio.removeTooltipps("docks"); reload.add(action) break; case "/building_place/index": case "/building_place/units_beyond": if (DATA.options.dio_Rtt) dio.removeTooltipps(); //addTransporterBackButtons(); break; case "/building_place/simulator": if (DATA.options.dio_sim) setStrengthSimulator(); if (DATA.options.dio_Rtt) dio.removeTooltipps(); break; case "/building_place/simulate": case "/building_place/insertSurvivesDefUnitsAsNewDefender": if (DATA.options.dio_sim) afterSimulation(); break; case "/town_overviews/building_overview": if (DATA.options.dio_Buc) buildingControl.init(); break; case "/town_overviews/culture_overview": case "/town_overviews/start_celebration": case "/town_overviews/start_all_celebrations": if (DATA.options.dio_Cul) cultureOverview.add(); if (DATA.options.dio_Cuc) cultureControl.init(); case "/building_place/culture": if (DATA.options.dio_Cup) cultureProgress.add(); if (DATA.options.dio_Cuo) culturePoints.activate(); break; case "/farm_town_overviews/index": if (DATA.options.dio_Ish) farmingvillageshelper.islandHeader(); break; case "/farm_town_overviews/claim_loads": if (DATA.options.dio_Ish) { farmingvillageshelper.rememberloot(); farmingvillageshelper.indicateLoot(); } break; case "/island_info/index": if (DATA.options.dio_Isl) islandFarmingVillages.activate(); if (DATA.options.dio_Idl) idle.add(action.split("/")[1], uw.Layout.wnd.GetByID(wnd.getID())); if (DATA.options.dio_BBl) BBcodeList.island_info(); break; case "/alliance_forum/forum": if (DATA.options.dio_Fdm) ForumDeleteMultiple.activate(); if (DATA.options.dio_sml) SmileyBox.add(action); if (DATA.options.dio_bbc) addForm(action); break; case "/message/view": //markMessage(); case "/message/new": case "/message/forward": if (DATA.options.dio_Idl) idle.add(action.split("/")[1]) if (DATA.options.dio_Mse) MessageExport.add(); case '/message/default': case '/message/index': case '/message/create': case '/message/reply': //markMessages(); case "/player_memo/load_memo_content": if (DATA.options.dio_sml) SmileyBox.add(action); if (DATA.options.dio_bbc) addForm(action); break; case "/wonders/index": if (DATA.options.dio_per & (uw.Game.features.end_game_type == "end_game_type_world_wonder")) { WWTradeHandler(); } if (DATA.options.dio_wwc) getResWW(); /*global getResWW*/ break; case "/wonders/send_resources": if (DATA.options.dio_wwc & (uw.Game.features.end_game_type == "end_game_type_world_wonder")) { getResWW(); } break; case "/ranking/alliance": if (uw.Game.features.end_game_type == "end_game_type_world_wonder") { getPointRatioFromAllianceRanking(); /*global getPointRatioFromAllianceRanking*/ } break; case "/ranking/wonder_alliance": if (uw.Game.features.end_game_type == "end_game_type_world_wonder") { getPointRatioFromAllianceRanking(); } /*if (DATA.options.dio_wwr & (uw.Game.features.end_game_type == "end_game_type_world_wonder")) { WorldWonderRanking.change(JSON.parse(xhr.responseText).plain.html); }*/ if (DATA.options.dio_wwi & (uw.Game.features.end_game_type == "end_game_type_world_wonder")) { WorldWonderIcons.activate(); } break; case "/alliance/members_show": if (uw.Game.features.end_game_type == "end_game_type_world_wonder") { getPointRatioFromAllianceMembers(); /*global getPointRatioFromAllianceMembers*/ } break; case "/town_overviews/trade_overview": if (DATA.options.dio_Rct) resCounter.init(); addPercentTrade(1234, false); // TODO break; case "/farm_town_overviews/get_farm_towns_for_town": if (DATA.options.dio_Ish && typeof activeFarm != 'undefined') { farmingvillageshelper.setloot(); } changeResColor(); break; case "/command_info/conquest_info": if (DATA.options.dio_str) UnitStrength.Conquest.add(); break; case "/command_info/conquest_movements": case "/conquest_info/getinfo": if (DATA.options.dio_cnt) countMovements(); break; case "/player/get_profile_html": //if (DATA.options.dio_BBt) BBtowninfo.profile(); if (DATA.options.dio_BBt) BBtowninfo.add(action.split("/")[1]); //if (DATA.options.dio_BBt) if (DATA.options.dio_BBl) BBcodeList.player_towns(); if (DATA.options.dio_Idl) idle.add(action.split("/")[1]); break; case "/alliance/profile": //if (DATA.options.dio_BBt) BBtowninfo.profile_alliance(); if (DATA.options.dio_BBt) BBtowninfo.add(action.split("/")[1]); //if (DATA.options.dio_BBt) if (DATA.options.dio_BBl) BBcodeList.alliance_player(); if (DATA.options.dio_Amm) ally_mass_mail.add(); if (DATA.options.dio_Idl) idle.add(action.split("/")[1]); break; case "/town_info/trading": addTradeMarks(15, 18, 15, "red"); TownTabHandler(action.split("/")[2]); break; case "/town_info/info": case "/town_info/attack": case "/town_info/support": //console.debug(JSON.parse(xhr.responseText)); TownTabHandler(action.split("/")[2]); if (DATA.options.dio_Sel & typeof (uw.FLASK_GAME) == "undefined") { selectunitshelper.activate(); } if (DATA.options.dio_Rtt) dio.removeTooltipps("attack"); break; case "/report/index": case "/report/default": case "/report/move": case "/report/delete_many": changeDropDownButton(); if (DATA.options.dio_Rep) { //reports.reportFoldersort(); reports.reportsColor(); //reports.reportsMove(); reports.reportsFilter(); } break; case "/report/view": $("#mhUnRes").remove(); break; case "/message/default": case "/message/index": break; case "/town_info/go_to_town": break; case "/town_overviews/store_iron": if (DATA.options.dio_Hio) hidesOverview.refresh_silver_total(xhr); break; case "/town_overviews/hides_overview": if (DATA.options.dio_Hio) hidesOverview.init(); if (DATA.options.dio_Hid) setTimeout(() => { hidesIndexIron.add(); }, 100); break; case "/farm_town_info/attack": if (DATA.options.dio_Rtt) dio.removeTooltipps(); break; case "/building_wall/index": if (DATA.options.dio_Rtt) dio.removeTooltipps("wall"); if (DATA.options.dio_Saw) Save_wall.add(); //test break; case "/ranking/index": case "/ranking/global": break; } }); } function test() { console.debug("STADTGRUPPEN", uw.Game.constants.ui.town_group); } /******************************************************************************************************************************* * Helping functions * ---------------------------------------------------------------------------------------------------------------------------- * | ● fixUnitValues: Get unit values and overwrite some wrong values * | ● getMaxZIndex: Get the highest z-index of "ui-dialog"-class elements * ---------------------------------------------------------------------------------------------------------------------------- *******************************************************************************************************************************/ var dio = { style: () => { $('').appendTo('head'); // Xmas -> 28 days dio.img_Xmas = dio.daystamp(334, 361); // 1. Dezember (334) / 28. Dezember (361) // Easter-Smileys -> 23 days dio.img_Easter = dio.daystamp(88, 110); // 30. march (88) / 21. april (110) // Halloween -> 15 days dio.img_Halloween = dio.daystamp(295, 321); // 23. Oktober / 8. November if (dio.img_Xmas) { dio_img = Home_url + "/img/dio/icon-xmas.gif"; } if (dio.img_Easter) { dio_img = Home_url + "/img/dio/icon-paques.png"; } //if (dio.img_Halloween) { dio_img = Home_url + ""; } $('').appendTo("head"); }, createButton: (Text, ID, Class, i) => { //dio.createButton(getTexts("messages", "copy"), "dio-copy-message-quote", null, 'data-clipboard-target="#expTextarea"') return "' + dio_icon + '' + Text + '' }, createBtnDonate: (Text, ID, Class, i, h) => { //dio.createBtnDonate(getTexts("Settings", "Donate"), null, null, 0, getTexts("link", "Donate")) return "' + Text + '' }, grepo_btn: (ID, Text) => { return $('' + Text + ''); }, grepo_dropdown_flag: (ID, Options, label, group, group2) => { var str = ''; return $(str); }, grepo_dropdown: (ID, Class, Options, sel) => { var str = ''; return str; }, drop_menu(This, Class, onglet) { $(This).parent().find(".sel").toggleClass("sel"); $(This).toggleClass("sel"); Overviews[onglet] = $(This).attr("name"); var buil = Overviews[onglet]; $(Class + ' .caption').attr("name", buil); $(Class + ' .caption').each(function () { this.innerHTML = buil; }); $($(This).parent().parent().get(0)).removeClass("open"); $(Class + ' .caption').change(); saveValue("Overviews", JSON.stringify(Overviews)); }, drop_menus_open(open, remove) { if (!$($(open)).hasClass("open")) { $($(open)).addClass("open"); $($(remove)).removeClass("open"); } else { $($(open)).removeClass("open"); } }, grepo_submenu: (ID, Title) => { return $('
  • ' + Title + '
  • '); }, daystamp: (start, end) => { //dio.daystamp(start, end) var daystamp = 1000 * 60 * 60 * 24, today = new Date((new Date()) % (daystamp * (365 + 1 / 4))), // without year // Xmas -> 28 days Start = daystamp * start, End = daystamp * end, ID = (today >= Start) ? (today <= End) : false; return ID; }, removeTooltipps: (type) => { setTimeout(() => { var a; switch (type) { case "attack": a = $(".unit_icon40x40"); break; case "wall": a = $(".unit_icon50x50"); break; case "barracks": case "docks": a = $(".thin_frame"); break; default: a = $(".unit") } $(a).off('mouseenter mouseleave'); }, 50); }, clipboard: (IDbutton, input, error, Text) => { try { var clipboard = new uw.ClipboardJS(IDbutton); clipboard.on("success", () => { setTimeout(() => { uw.HumanMessage.success(dio_icon + getTexts("messages", "copybb")) if (input !== null) { $(IDbutton).css({ "display": "none" }) $(input).css({ "display": "none" }) } if (Text !== null) { if (uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_BBCODEE)) { uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_BBCODEE).close(); } } }, 50) }); clipboard.on('error', (e) => { return uw.HumanMessage.error(dio_icon + getTexts("messages", "cli")); errorHandling(e, "clipboard error"); }); } catch (error) { return errorHandling(error, "clipboard"); } }, dateDiff(date1, date2) { var diff = {} var tmp = date2 - date1; tmp = Math.floor(tmp / 1000); diff.sec = tmp % 60; tmp = Math.floor((tmp - diff.sec) / 60); diff.min = tmp % 60; tmp = Math.floor((tmp - diff.min) / 60); diff.hour = tmp % 24; tmp = Math.floor((tmp - diff.hour) / 24); diff.day = tmp; return diff; }, lang() { let lang; if (DATA.test.lang) lang = DATA.test.lang else lang = MID if (lang == "zz") lang = "en" return lang; }, Extract_alliance(element) { let onclickAttributeValue = element.attr('onclick'); // Sélectionnez l'élément contenant le nom de l'alliance dans l'attribut onclick let alliance = onclickAttributeValue.match(/\('(.*?)',/)[1].replace(/\\/g, ''); // Utilisez une expression régulière pour extraire le nom du joueur return alliance; }, getTooltip(a, level) { if (uw.GameData.researches[a]) return "" + uw.GameData.researches[a].name + "

    " + uw.GameData.researches[a].description; else if (uw.GameData.buildings[a]) return "" + uw.GameData.buildings[a].name + "

    " + uw.GameData.buildings[a].description; else if (uw.GameData.powers[a]) return uw.us.template(uw.DM.getTemplate("COMMON", "casted_power_tooltip"), $.extend({}, uw.GameDataPowers.getTooltipPowerData(uw.GameData.powers[a], { percent: 30, lifetime: 1800, level: (level ? level : 1) }, (level ? level : "")), null)); return "??? " + a }, getName(a) { if (uw.GameData.researches[a]) return uw.GameData.researches[a].name; else if (uw.GameData.buildings[a]) return uw.GameData.buildings[a].name; else if (uw.GameData.powers[a]) return uw.GameData.powers[a].name; return "??? " + a }, spinner(ID, Class, placeholder, type, style, name) { return '
    ' + '
    ' + '
    ' + '
    ' + '' + '
    ' + '
    ' + '
    ' + '
    ' }, }; // Fix buggy grepolis values function fixUnitValues() { //uw.GameData.units.small_transporter.attack = uw.GameData.units.big_transporter.attack = uw.GameData.units.demolition_ship.attack = uw.GameData.units.militia.attack = 0; //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; uw.GameData.units.militia.resources = { wood: 0, stone: 0, iron: 0 }; } function getMaxZIndex() { var maxZ = Math.max.apply(null, $.map($("div[class^='ui-dialog']"), function (e, n) { if ($(e).css('position') == 'absolute') { return parseInt($(e).css('z-index'), 10) || 1000; } })); return (maxZ !== -Infinity) ? maxZ + 1 : 1000; } function getBrowser() { var ua = navigator.userAgent, tem, M = ua.match(/(opera|maxthon|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; if (/trident/i.test(M[1])) { tem = /\brv[ :]+(\d+)/g.exec(ua) || []; M[1] = 'IE'; M[2] = tem[1] || ''; } if (M[1] === 'Chrome') { tem = ua.match(/\bOPR\/(\d+)/); if (tem !== null) { M[1] = 'Opera'; M[2] = tem[1]; } } M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?']; if ((tem = ua.match(/version\/(\d+)/i)) !== null) M.splice(1, 1, tem[1]); return M.join(' '); } function system() { let isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0, isMacLike = navigator.platform.match(/(Mac|iPhone|iPod|iPad)/i) ? true : false, system = false; if (isMacLike || isMac) { system = true } return system; }; function cache() { var c, h = {}, k = {}; if ("object" != typeof uw.MM.DIO) { setTimeout(() => { cache(); }, 1E4); } else { try { $.ajax({ method: "get", url: "/data/players.txt" }).done(function (m) { try { $.each(m.split(/\r\n|\n/), function (C, K) { c = K.split(/,/); h[decodeURIComponent(c[1] + "")] = { id: c[0], name: decodeURIComponent(c[1] + ""), Points: c[3], alliance_id: c[2], Rank: c[4], Cities: c[5] }; }); uw.MM.DIO.cachePlayers = h; } catch (error) { errorHandling(error, "cache players done"); } }); } catch (error) { errorHandling(error, "cache players"); } try { $.ajax({ method: "get", url: "/data/alliances.txt", }).done(function (m) { try { $.each(m.split(/\r\n|\n/), function (C, K) { c = K.split(/,/); k[c[0]] = { id: c[0], name: decodeURIComponent(c[1] + ""), Points: c[2], Players: c[4], Rank: c[5], Cities: c[3] }; }); uw.MM.DIO.cacheAlliances = k; } catch (error) { errorHandling(error, "cache alliances done"); } }); } catch (error) { errorHandling(error, "cache alliances"); } } } function player_idle() { if ("object" != typeof uw.MM.DIO) { setTimeout(() => { player_idle(); }, 1E4); } else { try { $.ajax({ method: "get", url: "https://api.grepodata.com/data/" + WID + "/player_idle.json" }).done(function (data) { try { // Parcours de l'objet JSON pour construire le tableau souhaité $.each(data, function (key, value) { // Création d'un objet avec les propriétés id et idle var objet = { id: key, idle: value }; // Ajout de l'objet au tableau résultat uw.MM.DIO.player_idle[key] = objet; }); } catch (error) { errorHandling(error, "player_idle done"); } }).fail(function (jqXHR, textStatus, errorThrown) { // Gérer les erreurs de la requête AJAX ici console.error("DIO-TOOLS | player_idle | " + textStatus + " AJAX " + errorThrown); }); } catch (error) { errorHandling(error, "player_idle"); } } } if ("object" == typeof uw.MM.DIO) console.log(uw.MM.DIO.player_idle[uw.MM.DIO.cachePlayers.david1327.id].idle) // Error Handling / Remote diagnosis / Automatic bug reports function errorHandling(e, fn) { var error = 1; if (PID === 1538932 || PID === 100144) { uw.HumanMessage.error(dio_icon + "DIO-TOOLS(" + dio_version + ")-ERROR: " + e.message); console.log("DIO-TOOLS | Error-Stack | " + [fn] + " | ", e.stack); //console.log("DIO-TOOLS | Error-Stack | "+[fn]+" | ", e.name + ": " + e.toString()); //DATA.error[version][fn] = true; //saveValue("error", JSON.stringify(uw.MM.DIO.error)); } else { //if (!DATA.error[dio_version]) { // DATA.error[dio_version] = {}; //} console.log("DIO-TOOLS | Error-Stack | " + [fn] + " | ", e.toString()); //saveValue("error", JSON.stringify(DATA.error)); /*if (DATA.options.dio_err && !DATA.error[dio_version][fn]) { $.ajax({ type: "POST", url: "https://diotools.de/game/error.php", data: {error: e.stack.replace(/'/g, '"'), "function": fn, browser: getBrowser(), version: dio_version}, success: function (text) { DATA.error[version][fn] = true; saveValue("error", JSON.stringify(DATA.error)); } }); }*/ } try { let nb = 1; var errordio = uw.MM.DIO.errorDio, nb2 = 0, nb_error = 1; if (typeof (errordio[fn]) !== "undefined") { nb = nb + errordio[fn].nb; } var date = new Date(); errordio[fn] = { "function": fn, message: e.toString().replace(/'|\"/g, ''), error: e.stack.replace(/'/g, '"'), version: dio_version, browser: getBrowser(), system: ((system()) ? "Mac" : "Windows"), nb: nb, date: date.toLocaleString("fr-FR", { timeZone: 'UTC' }), }; $.each(errordio, function (name) { if (name !== "nb") { nb2++; } errordio.nb = nb2; }); if (!DATA.error[dio_version]) { DATA.error[dio_version] = {}; } if (typeof (DATA.error[dio_version][fn]) !== "undefined") { DATA.error[dio_version][fn].nb = DATA.error[dio_version][fn].nb + 1; DATA.error[dio_version][fn].date_fin = date.toLocaleString("fr-FR", { timeZone: 'UTC' }); } if (!DATA.error[dio_version][fn]) { DATA.error[dio_version][fn] = { "function": fn, message: e.toString().replace(/"/g, '\''), //error: JSON.stringify(e.stack.replace(/'|\"/g, ''),), version: dio_version, browser: getBrowser(), system: ((system()) ? "Mac" : "Windows"), nb: 1, date: date.toLocaleString("fr-FR", { timeZone: 'UTC' }), date_fin: "", }; }; nb = 0; $.each(DATA.error[dio_version], function (name) { if (name !== "nb") { nb++; } DATA.error[dio_version].nb = nb; }); saveValue("error", JSON.stringify(DATA.error)); } catch (e) { } } var dio_bug = true; $('').appendTo('head'); function createWindowType(name, title, width, height, minimizable, position) { // Create Window Type function WndHandler(wndhandle) { this.wnd = wndhandle; } Function.prototype.inherits.call(WndHandler, uw.WndHandlerDefault); WndHandler.prototype.getDefaultWindowOptions = function () { if (MID == 'zz' || dio_bug) { return { //position: "10px", hidden: !1, left: 297, top: 101, width: width, height: height, minimizable: minimizable, title: title, }; } else { return { position: position, width: width, height: height, minimizable: minimizable, title: "
    " + title + "
    " }; } }; uw.GPWindowMgr.addWndType(name, "75623", WndHandler, 1); } // Adds points to numbers function pointNumber(number, space) { var sep; if (LID === "de") sep = "."; else sep = ","; if (space) sep = " "; number = number.toString(); if (number.length > 3) { var mod = number.length % 3; var output = (mod > 0 ? (number.substring(0, mod)) : ''); for (var i = 0; i < Math.floor(number.length / 3); i++) { if ((mod == 0) && (i == 0)) { output += number.substring(mod + 3 * i, mod + 3 * i + 3); } else { output += sep + number.substring(mod + 3 * i, mod + 3 * i + 3); } } number = output; } return number; } /* TEST*/ var friendly_allies = []; var enemy_allies = []; function encodeString(input) { var output; output = input.replace(/ /g, '+'); output = output.replace(/\*/g, '%2A'); output = output.replace(/\=/g, '%3D'); output = output.replace(/Ł/g, '%C5%81'); output = output.replace(/ł/g, '%C5%82'); output = output.replace(/Ą/g, '%C4%84'); output = output.replace(/ą/g, '%C4%85'); output = output.replace(/Ę/g, '%C4%98'); output = output.replace(/ę/g, '%C4%99'); output = output.replace(/Ć/g, '%C4%86'); output = output.replace(/ć/g, '%C4%87'); output = output.replace(/Ó/g, '%C3%93'); output = output.replace(/ó/g, '%C3%B3'); output = output.replace(/Ń/g, '%C5%83'); output = output.replace(/ń/g, '%C5%84'); output = output.replace(/Ś/g, '%C5%9A'); output = output.replace(/ś/g, '%C5%9B'); output = output.replace(/Ź/g, '%C5%B9'); output = output.replace(/ź/g, '%C5%BA'); output = output.replace(/Ż/g, '%C5%BB'); output = output.replace(/ż/g, '%C5%BC'); return output; } function getAllianceName(allianceNumber) { if (allianceNumber == - 1) return getTexts('labels', 'no_ally'); if (allianceNumber == 0) return getTexts('labels', 'no_ally'); return uw.MM.DIO.cacheAlliances[allianceNumber].name; } function getAllianceNumber(player) { player = encodeString(player); if (player == "") return - 1; if (uw.MM.DIO.cachePlayers[player] == undefined) return - 1; if (uw.MM.DIO.cachePlayers[player].alliance_id == "") return 0; return uw.MM.DIO.cachePlayers[player].alliance_id; } function markMessage() { cache(); $('').appendTo('head'); var sender = $('#message_partner .gp_player_link').text(); var sender_ally = getAllianceNumber(sender); if (sender_ally == 0 || sender_ally == - 1) return if (sender_ally == AID) { $('#message_partner .gp_player_link').after('
    ' + getAllianceName(sender_ally) + ''); } else if (uw.MM.DIO.AlliancePact().ENEMY[sender_ally]) { $('#message_partner .gp_player_link').after('
    ' + getAllianceName(sender_ally) + '
    '); } else if (uw.MM.DIO.AlliancePact().PACT[sender_ally]) { $('#message_partner .gp_player_link').after('
    ' + getAllianceName(sender_ally) + '
    '); } else { $('#message_partner .gp_player_link').after('
    ' + getAllianceName(sender_ally) + '
    '); } if ($('.MHbbcADD').length) $('#dio-alliance_link').css('display', 'none'); $('#dio-alliance_link').tooltip(dio_icon) } function markMessages() { cache(); $('').appendTo('head'); $('.message_item').each(function () { var sender = $(this).find('.gp_player_link').text(); var sender_ally = getAllianceNumber(sender); if (sender_ally == 0 || sender_ally == - 1) return if ($(this).find('#dio-alliance_link').length < 1 && !$('.MHbbcADD').length) { if (sender_ally == AID) { $(this).find('.gp_player_link').after('
    ' + getAllianceName(sender_ally) + '
    '); $(this).find('#dio-alliance_link').tooltip(dio_icon) } else if (uw.MM.DIO.AlliancePact().ENEMY[sender_ally]) { $(this).find('.gp_player_link').after('
    ' + getAllianceName(sender_ally) + '
    '); $(this).find('#dio-alliance_link').tooltip(dio_icon) } else if (uw.MM.DIO.AlliancePact().PACT[sender_ally]) { $(this).find('.gp_player_link').after('
    ' + getAllianceName(sender_ally) + '
    '); $(this).find('#dio-alliance_link').tooltip(dio_icon) } else { $(this).find('.gp_player_link').after('
    ' + getAllianceName(sender_ally) + '
    '); $(this).find('#dio-alliance_link').tooltip(dio_icon) } } }); } // Notification var Notification = { REMINDER: false, init: () => { // Window createWindowType("DIO_Notification", getTexts("tutoriel", "tuto"), 830, 550, true, ["center", "center", 100, 100]); createWindowType("DIO_Notification_v", getTexts("Settings", "version_old"), 450, 150, true); // Style $('').appendTo('head'); // NotificationType uw.NotificationType.DIO_TOOLS = "diotools"; uw.NotificationType.DIO_TOOLS_V = "diotools_v"; var notifN = dio_version.split(".")[1] + 1; var titreN = // 0; // nouvelles fonctionnalités 1; // Nouvelle version // 2; // "" var featureN = // 0; // nouvelles fonctionnalités // 1; // nouvelles fonctionnalités + titre 2; // "" var titre = [getTexts("Settings", "Feature"), getTexts("Settings", "Feature2"), ""]; var feature = [getTexts("Settings", "Feature"), getTexts("Settings", "Feature") + ' (' + getTexts("Options", "Buc")[0] + ')', ""]; var notif = DATA.notification, notiff = DATA.notiff; //console.log(DATA.notification) if (notiff !== 0 && dio_version === version_latest) { saveValue('notiff', 0); } if (notif <= notifN || david1327 && notiff <= 7) { Notification.create(titre[titreN], feature[featureN], "DIO_TOOLS", "#3f0"); //; // Click Event $('.diotools .icon').click(function () { Notification.activate(); $(this).parent().find(".close").click(); saveValue('notif', notifN + 1); }); saveValue('notiff', notiff + 1); setTimeout(() => { $('#notification_area .diotools .icon').parent().find(".close").click() }, 1800000); } var version_latest = dio_version; var update = DATA.update; setTimeout(() => { try { version_latest = uw.dio_latest_version; } catch (error) { errorHandling(error, "dio_latest_version (Notification.update)"); } if (update !== 0 && dio_version === version_latest) { saveValue('update', 0); } if (dio_version < version_latest && update <= 7) { Notification.create(getTexts("Settings", "version_old"), getTexts("Settings", "Available"), "DIO_TOOLS_V", "#f22"); // Click Event $('.diotools_v .icon').click(function () { Notification.update(); $(this).parent().find(".close").click(); }); saveValue('update', update + 1); } }, 1000); }, update: () => { if (Notification.REMINDER == false) { var expRahmen_a = '
    ' + '

    ' + getTexts("Settings", "Available") + '

    ' + '' + getTexts("Settings", "install") + '' + '' + getTexts("Settings", "reminder") + '' + '
    '; var BBwnd = uw.GPWindowMgr.Create(uw.GPWindowMgr.TYPE_DIO_Notification_v) || uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_Notification_v).close(); BBwnd.setContent(expRahmen_a); } else { confirmm(); } var update = DATA.update; // Click Event $('#dio_notif .confirmm').click(function () { setTimeout(() => { confirmm(); }, 2000); }); function confirmm() { if (uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_Notification_v)) { uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_Notification_v).close(); } var expRahmen_a = '
    ' + '

    ' + getTexts("Settings", "reqreload") + '

    ' + '' + getTexts("Settings", "reload") + '' + '' + getTexts("Settings", "reminder") + '' + '
    '; var BBwnd = uw.GPWindowMgr.Create(uw.GPWindowMgr.TYPE_DIO_Notification_v) || uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_Notification_v).close(); BBwnd.setContent(expRahmen_a); $("#dio_notif .reloadd").click(() => { if (uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_Notification_v)) { uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_Notification_v).close(); } uw.hOpenWindow.showConfirmDialog(getTexts("buttons", "res"), getTexts("labels", "raf"), function () { location.reload(); }); }); $("#dio_notif .reminder").click(() => { if (uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_Notification_v)) { uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_Notification_v).close(); }; Notification.REMINDER = true; setTimeout(() => { Notification.update(); }, 180000); }); } $('#dio_notif .cancell').click(function () { if (uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_Notification_v)) { uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_Notification_v).close(); } setTimeout(() => { Notification.create(getTexts("Settings", "version_old"), getTexts("Settings", "Feature2"), "DIO_TOOLS_V", "#f22"); // Click Event $('.diotools_v .icon').click(function () { Notification.update(); $(this).parent().find(".close").click(); }); saveValue('update', update + 1); }, 18000000); saveValue('update', update - 1); }); }, activate: () => { var grepoGameBorder = '
    ' + '
    ' + '
    ' + '
    '; var inhalte = { dioset_tab1: tab1(), dioset_tab2: tab2(), dioset_tab3: tab3(), dioset_tab4: tab4() }; //Mise à jour function tab1() { var HTML_tab1 = '
    ' + '
    ' + '
    ' + '' + getTexts("Settings", "cat_forum") + ': ' + 'DIO-TOOLS-David1327'; if (MID == "fr" || dio.lang() == "fr") { HTML_tab1 += '' + 'DIO-TOOLS-David132' + '' + '' + getTexts("Settings", "Update") + " " + dio_version + ''; } else { HTML_tab1 += '' + 'DIO-TOOLS-David132' + '' + '' + getTexts("Settings", "Update") + " " + dio_version + ''; } HTML_tab1 += '
    ' + '
    ' + '' + '
    ' + dio.createBtnDonate(getTexts("Settings", "Donate"), null, null, 0, getTexts("link", "Donate")) + '
    ' + '
    '; HTML_tab1 += grepoGameBorder + /*getTexts("Settings", "Update") + " " + dio_version +*/ 'News
    '; // var version = dio_version[2] += dio_version[3] var beforeversion = dio_version.replace(version, version - 1); beforeversion = beforeversion.split(".")[0] + "." + beforeversion.split(".")[1] if (DATA.error[beforeversion]) { deleteValue("error"); } if (dio.lang() == "fr") HTML_tab1 += ''; else HTML_tab1 += ''; return HTML_tab1; } //Contribution function tab2() { var HTML_tab2 = '
    ' + '' + '
    ' + '' + getTexts("Settings", "cat_forum") + ': ' + 'DIO-TOOLS-David1327'; if (MID == "fr" || dio.lang() == "fr") { HTML_tab2 += '' + 'DIO-TOOLS-David132' + '' + '' + getTexts("Settings", "Update") + " " + dio_version + ''; } else { HTML_tab2 += '' + 'DIO-TOOLS-David132' + '' + '' + getTexts("Settings", "Update") + " " + dio_version + ''; } HTML_tab2 += '
    ' + '
    ' + '' + '
    ' + dio.createBtnDonate(getTexts("Settings", "Donate"), null, null, 0, getTexts("link", "Donate")) + '
    ' + '
    '; HTML_tab2 += grepoGameBorder + getTexts("labels", "donat") + ''; var don, donNb = 0, reste, donationsListe = [ [1, 4, 101.26, 94.9, 'Ines L'], [2, 5, 60, 56.51, 'Christiane G'], [3, 19, 50.35, 42.18, 'adriano g'], [4, 1, 50, 47.2, 'Nepomuk P'], [4, 2, 50, 47.85, 'Artur Z'], [5, 15, 43, 36, 'Davryll'], [6, 1, 31.26, 29.6, 'Nigel T'], [7, 1, 30, 28.78, 'glaglatoulle'], [7, 3, 30, 27.48, 'elifoxo'], [8, 2, 22, 20.66, 'Ulla R'], [9, 2, 21.32, 20, 'Heinz E'], [10, 3, 20.51, 18.86, 'etienne1306'], [11, 1, 20, 19.07, 'Uwe S'], [11, 1, 20, 19.07, 'kanokwan s'], [11, 1, 20, 19.07, 'lydie c'], [11, 1, 20, 19.07, 'Elwira G'], [11, 1, 20, 19.07, 'Sven K'], [12, 1, 15, 14.21, 'Walther M'], [12, 1, 15, 14.21, 'Attila'], [13, 1, 10.66, 10, 'Arkadiusz W'], [14, 2, 10.51, 9.5, 'Kornelia M'], [15, 1, 10, 9.36, 'Ocaso'], [15, 1, 10, 9.36, 'Uwe J'], [15, 1, 10, 9.36, 'SABINE B'], [15, 1, 10, 9.36, 'Jean-Paul B'], [15, 1, 10, 9.16, 'Eric A'], [15, 1, 10, 9.36, 'benoit A'], [15, 1, 10, 9.36, 'Doris H'], [15, 1, 10, 9.36, 'Andreas A'], [15, 1, 10, 9.36, 'Christian P'], [15, 1, 10, 9.36, 'filippo v'], [15, 1, 10, 9.36, 'Gabory A'], [15, 1, 10, 9.36, 'Andreas S'], [15, 1, 10, 9.36, 'Herbert L'], [16, 1, 7, 6.45, 'thomas c'], [17, 1, 5.55, 5.04, 'Matthias H'], [17, 1, 5.55, 5.04, 'Susi K'], [17, 1, 5.55, 5.04, 'Annette H'], [18, 1, 5.51, 5, 'thomas s'], [18, 1, 5.51, 5, 'Laurent R'], [18, 1, 5.51, 5, 'Arphox'], [19, 1, 5, 4.5, 'Detlef Z'], [19, 1, 5, 4.5, 'florian p'], [19, 1, 5, 4.5, 'Denai'], [19, 1, 5, 4.5, 'Swen A'], [19, 1, 5, 4.5, 'Kallerberg'], [19, 1, 5, 4.5, 'Thomas C'], [19, 1, 5, 4.5, 'Mateusz O'], [19, 1, 5, 4.5, 'Dorthe D'], [19, 1, 5, 4.5, 'Sven O'], [19, 1, 5, 4.5, 'Societatea-d-S B'], [19, 1, 5, 4.5, 'Ulrich S'], [19, 1, 5, 4.5, 'Antonio-Acuña B'], [19, 1, 5, 4.5, 'Petr M'], [19, 1, 5, 5.5, 'Max P'], [19, 1, 5, 4.4, 'Therese S'], [19, 1, 5, 4.5, 'Comte M'], [19, 1, 5, 4.5, 'Yvonne H'], [19, 1, 5, 4.5, 'Diana S'], [19, 1, 5, 4.5, 'José-Miguel A'], [19, 1, 5, 4.5, 'Raul-Garcia C'], [19, 1, 5, 4.5, 'Dylan D'], [20, 3, 3.39, 2.24, 'Gyorgy C'], [21, 1, 2.5, 2.08, 'Martin G'], [22, 2, 2.39, 1.62, 'Eduard B'], [23, 1, 2, 1.59, 'Marie-Laure D'], [23, 1, 2, 1.59, 'Ute N'], [24, 1, 1.39, 1, 'Puiu D'], [24, 1, 1.39, 1, 'laurent k'], [25, 1, 1, 0.38, 'Francesco L'], ]; $.each(donationsListe, function () { donNb++; }); don = Math.round(donNb / 4) reste = (donNb - 4 * don) if (reste < 0) reste = 0 HTML_tab2 += '
    '; if (dio.lang() == "fr") HTML_tab2 += ''; //scrolling="no" else HTML_tab2 += ''; //scrolling="no"; HTML_tab2 += '

    ' + getTexts("labels", "ingame_name")[0] + '

    ' + '

    ' + getTexts("labels", "ingame_name")[1] + '

    ' + '' + '' + (function () { var donNb2 = -1, donations = [], donations2 = [], donations3 = [], donations4 = [], donation_table = "", donation_table2 = "", donation_table3 = "", donation_table4 = ""; $.each(donationsListe, function (a) { donNb2++; if (donNb2 < (don + (reste > 0 ? 1 : 0))) { donations.push(donationsListe[donNb2]) } else if (donNb2 < (don + don + (reste > 1 ? 2 : reste))) { donations2.push(donationsListe[donNb2]) } else if (donNb2 < (don + don + don + (reste > 2 ? 3 : reste))) { donations3.push(donationsListe[donNb2]) } else { donations4.push(donationsListe[donNb2]) } }) var d = 0; for (d = 0; d < donations.length; d++) { var donation_class = ""; switch (donations[d][0]) { case 1: donation_class = "gold"; break; case 2: donation_class = "silver"; break; case 3: donation_class = "bronze"; break; default: donation_class = "green2"; break; } donation_table += ''; } for (d = 0; d < donations2.length; d++) { donation_table2 += ''; } for (d = 0; d < donations3.length; d++) { donation_table3 += ''; } for (d = 0; d < donations4.length; d++) { donation_table4 += ''; } return donation_table + '
    ' + getTexts("labels", "donat") + '
    ' + donations[d][4] + '' + donations[d][2] + '€
    ' + donations2[d][4] + '' + donations2[d][2] + '€
    ' + donations3[d][4] + '' + donations3[d][2] + '€
    ' + donations4[d][4] + '' + donations4[d][2] + '€
    ' + donation_table2 + '
    ' + donation_table3 + '
    ' + donation_table4; })() + '
    ' + '
    '; return HTML_tab2; } //Traductions function tab3() { var HTML_tab3 = ""; var supported_lang = [getTexts("translations", "info"), getTexts("translations", "add_lang")]; var languages = []; $.each(LANG, function (a) { if (a != "AUTO") languages.push(a); }); // Parcourez les langues et ajoutez-les au tableau languages.sort(); // Triez le tableau alphabétiquement $.each(languages, function (index, language) { supported_lang.push(language); }); HTML_tab3 += '
    ' + '' + '
    ' + '
    ' + dio.createButton(getTexts("translations", "send")) + '
    '; if (MID == "fr" || dio.lang() == "fr") { HTML_tab3 += '' + 'DIO-TOOLS-David132' + '' + '' + getTexts("Settings", "Update") + " " + dio_version + ''; } else { HTML_tab3 += '' + 'DIO-TOOLS-David132' + '' + '' + getTexts("Settings", "Update") + " " + dio_version + ''; } HTML_tab3 += '
    ' + '
    ' + '' + '
    ' + dio.createBtnDonate(getTexts("Settings", "Donate"), null, null, 0, getTexts("link", "Donate")) + '
    ' + '
    '; HTML_tab3 += grepoGameBorder + getTexts("labels", "Tran") + '
    ' + dio.grepo_dropdown_flag("langdiv", supported_lang, null, null, null)[0].outerHTML + '
    '; //var lngFlags = ""; HTML_tab3 += '
    ' + getTexts("translations", "please_note") + ':' + '
    ' + getTexts("translations", "credits") + ':
    '; HTML_tab3 += '
    '; //HTML_tab3 += dio.grepo_btn("diomenu_einstellungen_sendmail", getTexts("Settings", "send"))[0].outerHTML; return HTML_tab3; } //BUG function tab4() { var HTML_tab4 = '
    ' + '' + '
    ' + dio.createButton(getTexts("buttons", "res")) + '
    ' + '
    ' + '
    ' + dio.createButton(getTexts("translations", "send")) + '
    ' + '' + getTexts("Settings", "cat_forum") + ': ' + 'DIO-TOOLS-David1327'; if (MID == "fr" || dio.lang() == "fr") { HTML_tab4 += '' + 'DIO-TOOLS-David132'; } else { HTML_tab4 += '' + 'DIO-TOOLS-David132'; } HTML_tab4 += '
    ' + '
    ' + '' + '
    ' + dio.createBtnDonate(getTexts("Settings", "Donate"), null, null, 0, getTexts("link", "Donate")) + '
    ' + '
    '; HTML_tab4 += grepoGameBorder + 'BUG'; var name_a = "", errordio = DATA.error[dio_version], script = uw.MM.DIO.info_dio.script, errorr = uw.MM.DIO.errorDio; HTML_tab4 += '

    ' + (script.grcrt ? 'Grcrt: true; ' : "") + (script.HMole ? 'HMole: true; ' : "") + (script.Gt ? 'Gt: true; ' : "") + (script.FLASK ? 'FLASK: true; ' : "") + (script.Quack ? 'Quack: true; ' : "") + (script.GrepoData ? 'GrepoData: true; ' : "") + '

    '; $.each(errordio, function (name) { if (name !== "nb") { name_a += '

    Function: ' + errordio[name].function + '
    ' + 'Message: ' + errordio[name].message + '
    ' + (typeof (errorr[name]) !== "undefined" ? ('Error: ' + errorr[name].error + '
    ') : "") + 'Version: ' + errordio[name].version + '
    ' + 'latest_version: ' + uw.MM.DIO.info_dio.latest_version + '
    ' + 'Browser: ' + errordio[name].browser + '
    ' + 'System: ' + errordio[name].system + '
    ' + 'Nb: ' + errordio[name].nb + '
    ' + 'Date: ' + errordio[name].date + '
    ' + 'Date fin: ' + errordio[name].date_fin + '

    '; } }); HTML_tab4 += name_a; if (name_a === "") { HTML_tab4 += "no bug"; } HTML_tab4 += '
    '; return HTML_tab4; } function handle_and_style() { dio.clipboard("#dio-copy-Traductions-quote", null, "handle_and_style", true) $("#dioerrordio").click(() => { var name_a = "", errordio = DATA.error[dio_version], script = uw.MM.DIO.info_dio.script, errorr = uw.MM.DIO.errorDio; var name_b = '' + 'Grcrt: ' + (script.grcrt ? true : false) + "; " + 'HMole: ' + (script.HMole ? true : false) + "; " + 'Gt: ' + (script.Gt ? true : false) + "; " + 'FLASK: ' + (script.FLASK ? true : false) + "; " + 'Quack: ' + (script.Quack ? true : false) + "; " + 'GrepoData: ' + (script.GrepoData ? true : false); $.each(errordio, function (name) { if (name !== "nb") { name_a += 'Function: ' + errordio[name].function + "\n" + 'Message: ' + errordio[name].message + "\n" + (typeof (errorr[name]) !== "undefined" ? ('Error: ' + errorr[name].error + "\n") : "") + 'Version: ' + errordio[name].version + "\n" + 'latest_version ' + uw.MM.DIO.info_dio.latest_version + "\n" + 'Browser: ' + errordio[name].browser + "\n" + 'System: ' + errordio[name].system + "\n" + 'Nb: ' + errordio[name].nb + "\n" + 'Date: ' + errordio[name].date + "\n" + 'Date fin: ' + errordio[name].date_fin + "\n\n"; } }); if (name_a === "") { uw.HumanMessage.error(dio_icon + "no bug"); return; } uw.hOpenWindow.showConfirmDialog('', getTexts("translations", "send"), function () { var trans_HTML_send = pName + '
    ' + PID + '
    ' + WID + '

    '; var trans_BBcode_send = pName + "\n" + WID + "\n\n"; trans_BBcode_send += "`" + name_b + "\n" + name_a + "`\n"; createWindowType("DIO_BBCODEE", getTexts("messages", "bbmessages"), 700, 350, true, ["center", "center", 100, 100]); var expRahmen_a = "

    " + "
    " + "
    " + "
    "; //var expRahmen_b = "
    " + trans_HTML_send + "
    "; var expRahmen_c = "
    " + dio.createButton(getTexts("messages", "copy"), "dio-copy-Traductions-quote", null, 'data-clipboard-target="#expTextarea"') + "
    "; var expRahmen_e = "
    "; var expTitel = getTexts("messages", "Tol"); var BBwnd = uw.GPWindowMgr.Create(uw.GPWindowMgr.TYPE_DIO_BBCODEE) || uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_BBCODEE).close(); //BBwnd.setTitle(getTexts("qtoolbox", "bb_codes") + " - " + getTexts("bbcode", "messages")); BBwnd.setContent(expRahmen_a + expTitel + expRahmen_c + trans_BBcode_send + expRahmen_d + expRahmen_e); }); }); $("#dio_res").click(() => { uw.hOpenWindow.showConfirmDialog('', getTexts("labels", "raf"), function () { deleteValue("error"); location.reload(); }); }); $("#diomenu_einstellungen_sendmail").css({ "margin-left": "1px" }); $("#diomenu_einstellungen_sendmail").click(function () { if ($("#trans_lang").length && !$.trim($("#trans_lang").val())) { uw.HumanMessage.error(dio_icon + getTexts("translations", "enter_lang_name")); return; } else if ($("#langdiv").val() === getTexts("Settings", "info")) { uw.HumanMessage.error(dio_icon + getTexts("translations", "choose_lang")); return; } else if ($("#trans_content .toSend").length === 0) { uw.HumanMessage.error(dio_icon + getTexts("translations", "no_translation")); return; } uw.hOpenWindow.showConfirmDialog('', getTexts("translations", "trans_sure"), function () { //$("#ajax_loader").css({"visibility":"visible"}); var trans_HTML_send = pName + '
    ' + PID + '
    ' + WID + '

    '; $('#trans_content > DIV').each(function (i) { if ($('.toSend', this).length != 0) { trans_HTML_send += '' + $('SPAN', this).text() + ': {
    '; $('.toSend', this).each(function (index) { trans_HTML_send += $(this).data('name') + ': "' + $('td:last textarea', this).val() + '",
    '; }); trans_HTML_send += '},
    '; } }); /*var trans_BBcode_send = pName + '\n'; trans_BBcode_send += '\n' + $("#diolang").text().toLowerCase() + ' : {\n'; $('#trans_content > DIV').each(function (i) { if ($('.toSend', this).length != 0) { trans_BBcode_send += '\n' + $('SPAN', this).text() + ' : {\n'; $('.toSend', this).each(function (index) { trans_BBcode_send += $(this).data('name') + ' : "' + $("td:last textarea", this).val() + '",\n'; }); trans_BBcode_send += '},\n'; } }); trans_BBcode_send += "\n},\n";*/ var trans_BBcode_send = pName + '\n'; trans_BBcode_send += '\n' + $("#diolang").text().toLowerCase() + ' : {\n'; $('#trans_content > DIV').each(function (i) { if ($('.toSend', this).length != 0) { trans_BBcode_send += '\n' + $('SPAN', this).text() + ' : {\n'; if ($('SPAN', this).text() != "Options") { $('.toSend', this).each(function (index) { trans_BBcode_send += $(this).data('name') + ' : "' + $("td:last textarea", this).val() + '",\n'; }); } else { $('.toSend', this).each(function (index) { trans_BBcode_send += $(this).data('name') + ' : ["' + $("#diobb1 textarea", this).val() + '","' + $("#diobb2 textarea", this).val() + '"],\n'; }); } trans_BBcode_send += '},\n'; } }); trans_BBcode_send += "\n},\n"; createWindowType("DIO_BBCODEE", getTexts("messages", "bbmessages"), 700, 350, true, ["center", "center", 100, 100]); var expRahmen_a = "

    " + "
    " + "
    " + "
    "; //var expRahmen_b = "
    " + trans_HTML_send + "
    "; var expRahmen_c = "
    " + dio.createButton(getTexts("messages", "copy"), "dio-copy-Traductions-quote", null, 'data-clipboard-target="#expTextarea"') + "
    "; var expRahmen_e = "
    "; var expTitel = getTexts("messages", "Tol"); var BBwnd = uw.GPWindowMgr.Create(uw.GPWindowMgr.TYPE_DIO_BBCODEE) || uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_BBCODEE).close(); //BBwnd.setTitle(getTexts("qtoolbox", "bb_codes") + " - " + getTexts("bbcode", "messages")); BBwnd.setContent(expRahmen_a + expTitel + expRahmen_c + trans_BBcode_send + expRahmen_d + expRahmen_e); }); }); /*$("#diomenu_einstellungen_sendmail").click(function () { if ($("#trans_lang").length && !$.trim($("#trans_lang").val())) { uw.HumanMessage.error(dio_icon + getTexts("Settings", "enter_lang_name")); return; } else if ($("#langdiv").val() === getTexts("Settings", "info")) { uw.HumanMessage.error(dio_icon + getTexts("Settings", "choose_lang")); return; } else if ($("#trans_content .toSend").length === 0) { uw.HumanMessage.error(dio_icon + getTexts("Settings", "no_translation")); return; } hOpenWindow.showConfirmDialog('', getTexts("Settings", "trans_sure"), function () { $("#ajax_loader").css({"visibility":"visible"}); var trans_HTML_send = pName + "
    " + PID + "
    " + WID + "

    "; $("#trans_content > DIV").each(function (i) { if ($(".toSend", this).length != 0) { trans_HTML_send += "" + $("SPAN", this).text() + " : {
    "; $(".toSend", this).each(function (index) { trans_HTML_send += $(this).data("name") + " : '" + $("td:last textarea", this).val() + "',
    "; }); trans_HTML_send += "},
    "; } }); var xhr = $.ajax({ type : 'POST', url : "smtp-relay.sendinblue.com", dataType : 'json', data : { key : 'QfLaN1Yh4ctSUApK', message : { html : trans_HTML_send, subject : 'Quack Toolsammlung Translation ' + $("#langdiv").val(), from_email : "123@cuvox.de", to : [{ "email" : "124@cuvox.de", } ] } } }); xhr.done(function (data) { $("#ajax_loader").css({"visibility":"hidden"}); uw.HumanMessage.success(dio_icon + getTexts("Settings", "trans_success")); }); xhr.fail(function (jqXHR, textStatus, errorThrown) { $("#dioajaxloader").css({ "display" : "none" }); uw.HumanMessage.error(dio_icon + getTexts("Settings", "trans_fail")); }); }); });*/ $(".contentDiv > DIV:last-child").css({ "margin-bottom": "5px" }); $("#langdiv").change(function () { var lang_tab3 = $(this).val().toLowerCase(); var langHTML_tab3 = ""; langHTML_tab3 += '

    ' + getTexts("translations", "trans") + ': ' + lang_tab3.toUpperCase() + ''; if ($(this).val() === getTexts("translations", "add_lang")) { langHTML_tab3 += '
    '; } else langHTML_tab3 += ''; if ($(this).val() === getTexts("translations", "info")) { BBwnd.setContent(inhalte.dioset_tab3); handle_and_style(); return; } else if ($(this).val() === getTexts("translations", "add_lang")) { langHTML_tab3 += '
    ' + getTexts("translations", "language") + '
    '; langHTML_tab3 += ''; langHTML_tab3 += ''; langHTML_tab3 += '
    ' + getTexts("translations", "name") + '
    '; } $.each(LANG.en, function (a, b) { if (a != "Notification" && a != "link") { langHTML_tab3 += '
    ' + a + '
    '; $.each(b, function (c, d) { var text = (LANG[lang_tab3] != undefined && LANG[lang_tab3][a] != undefined && LANG[lang_tab3][a][c] != undefined) ? (LANG[lang_tab3][a][c] === "" ? "salmon" : "#fff0cf") : "salmon"; langHTML_tab3 += ''; if (a != "Options") { langHTML_tab3 += ''; langHTML_tab3 += (LANG[lang_tab3] != undefined && LANG[lang_tab3][a] != undefined && LANG[lang_tab3][a][c] != undefined) ? '' : ''; langHTML_tab3 += ''; } else { langHTML_tab3 += ''; langHTML_tab3 += (LANG[lang_tab3] != undefined && LANG[lang_tab3][a] != undefined && LANG[lang_tab3][a][c] != undefined) ? '' : ''; langHTML_tab3 += (LANG[lang_tab3] != undefined && LANG[lang_tab3][a] != undefined && LANG[lang_tab3][a][c] != undefined) ? '' : ''; langHTML_tab3 += ''; } }); langHTML_tab3 += '
    ' + d + '
    ' + d[0] + '\n
    ' + d[1] + '
    '; } }); $("#trans_content").html(langHTML_tab3); $("#trans_content td").css({ "border-top": "1px solid grey" }); $("#trans_content textarea").css({ //"height" : "18px", "width": "99%", "resize": "vertical", "margin": "0", "padding": "0" }); $("#trans_content textarea").on("change", function () { $(this).parent().css({ "border": "1px solid green" }); $(this).parent().parent().addClass("toSend"); $(this).val($(this).val()); }); $(".contentDiv div:last-child").css({ "margin-bottom": "5px" }); }); } var BBwnd = uw.GPWindowMgr.Create(uw.GPWindowMgr.TYPE_DIO_Notification) || uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_Notification); //BBwnd.setTitle(getTexts("qtoolbox", "settings")); if (dio.bug) { BBwnd.setContent(inhalte.dioset_tab4); } else if (dio.add_lang) { BBwnd.setContent(inhalte.dioset_tab3); } else { BBwnd.setContent(inhalte.dioset_tab1); } if ($("#diomenu_settings_tabs").length === 0) { BBwnd.getJQElement().append(''); } $("#diomenu_settings_tabs li a").removeClass("active"); if (dio.bug) { $("#dioset_tab4").addClass("active"); dio.bug = false } else if (dio.add_lang) { $("#dioset_tab3").addClass("active"); dio.add_lang = false } else { $("#dioset_tab1").addClass("active"); } handle_and_style(); $("#diomenu_settings_tabs li a").click(function () { $("#diomenu_settings_tabs li a").removeClass("active"); $(this).addClass("active"); BBwnd.setContent(inhalte[this.id]); handle_and_style(); }); }, create: (titre, feature, DIO, color) => { var Notification = new uw.NotificationHandler(); Notification.notify($('#notification_area>.notification').length + 1, uw.NotificationType[DIO], "" + titre + "!" + feature + "DIO-Tools-david1327: v" + dio_version + ""); }, addCopyListener: () => { dio.clipboard("#dio-copy-Traductions-quote", null, "handle_and_style", true) }, }; /******************************************************************************************************************************* * compatibility Script *******************************************************************************************************************************/ var compatibility = { flask_tools: () => { // compatibility flask-tools if (typeof (uw.FLASK_GAME) !== "undefined") { uw.HumanMessage.error(dio_icon + "flask"); //Units overview $('#available_units_bullseye').remove(); $('#available_units_bullseye_addition').remove(); $('#flask_available_units_style').remove(); $('#flask_available_units_style_addition').remove(); //Unit Comparison $('#btn_available_units').remove(); if (uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_FLASK_UNITS)) { uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_FLASK_UNITS).close(); } //Unit strength $('#strength').remove(); $('#flask_strength_style').remove(); //Simulator $('#flask_simulator_strength_style').remove(); $('#flask_simulator_strength').remove(); //Recruiting trade $('#flask_style_recruiting_trade').remove(); //Transport capacity $('#transporter').remove(); //Map $("#flask_game_list_header_style").remove(); $("#flask_town_popup_style").remove(); //style $('').appendTo('head'); }; }, }; /******************************************************************************************************************************* * Mousewheel Zoom *******************************************************************************************************************************/ var MouseWheelZoom = { activate: () => { // Agora $('').appendTo('head'); $('').appendTo('.nui_battlepoints_container'); $("#dio_Agora").click(() => { uw.PlaceWindowFactory.openPlaceWindow(); }); // Scroll trough the views $('#main_area, #dio_political_map, .viewport, .sjs-city-overview-viewport').bind('mousewheel', function (e) { e.stopPropagation(); var current = $('.bull_eye_buttons .checked').get(0).getAttribute("name"), delta = 0, scroll, sub_scroll = 6; switch (current) { case 'strategic_map': scroll = 3; break; case 'island_view': scroll = 2; break; case 'city_overview': scroll = 1; break; } delta = -e.originalEvent.detail || e.originalEvent.wheelDelta; // Firefox || Chrome & Opera //console.debug("cursor_pos", e.pageX, e.pageY); if (scroll !== 4) { if (delta < 0) { scroll += 1; } else { scroll -= 1; } } else { // Zoomstufen bei der Politischen Karte sub_scroll = $('.zoom_select').get(0).selectedIndex; if (delta < 0) { sub_scroll -= 1; } else { sub_scroll += 1; } if (sub_scroll === -1) { sub_scroll = 0; } if (sub_scroll === 7) { scroll = 3; } } switch (scroll) { case 3: $('.bull_eye_buttons .strategic_map').click(); $('#popup_div').css('display', 'none'); break; case 2: $('.bull_eye_buttons .island_view').click(); TownPopup.remove(); break; case 1: $('.bull_eye_buttons .city_overview').click(); break; } // Prevent page from scrolling return false; }); }, deactivate: () => { $('#main_area, .ui_city_overview').unbind('mousewheel'); $('#dio_Agora').remove(); $('#dio_Agora_style').remove(); } }; /******************************************************************************************************************************* * Body Handler * ---------------------------------------------------------------------------------------------------------------------------- * | ● Town icon * | ● Town icon (Map) * | ● Town Popup * | ● Town list: Adds town type to the town list * | ● Swap Context Icons * ---------------------------------------------------------------------------------------------------------------------------- *******************************************************************************************************************************/ // Fix icon update when switching cities function updateIcon() { setTimeout(() => { var townType = (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no"))); $('#town_icon .icon_big').removeClass().addClass('icon_big townicon_' + townType + " auto"); $('#town_icon .icon_big').css({ backgroundPosition: TownIcons.types[townType] * -25 + 'px 0px' }); }, 0); }; /******************************************************************************************************************************* * Town icon *******************************************************************************************************************************/ let dio_icon_small = Home_url + "/img/dio/btn/town-icons.png"; var TownIcons = { types: { // Automatic Icons lo: 0, ld: 3, so: 6, sd: 7, fo: 10, fd: 9, bu: 14, /* Building */ po: 22, no: 12, // Manual Icons fa: 20, /* Favor */ re: 15, /* Resources */ di: 2, /* Distance */ sh: 1, /* Pierce */ lu: 13, /* ?? */ dp: 11, /* Diplomacy */ ha: 15, /* ? */ si: 18, /* Silber */ ra: 17, ch: 19, /* Research */ ti: 23, /* Time */ un: 5, wd: 16, /* Wood */ wo: 24, /* World */ bo: 13, /* Booty */ gr: 21, /* Lorbeer */ st: 17, /* Stone */ is: 26, /* ?? */ he: 4, /* Helmet */ ko: 8, /* Kolo */ O1: 58, O2: 59, O3: 60, O4: 61, O5: 62, O6: 63, OO: 25, /* Kolo */ SL: 26, // Slinger CB: 27, // Cerberus SW: 28, // Chariot CE: 29, // Colony ship CY: 30, // Calydonian boar DS: 31, // Fire ship FS: 32, // Light ship BI: 33, // Bireme TR: 34, // Trireme GF: 35, // Griffin MN: 36, // Manticore MD: 37, // Medusa EY: 38, // Erinys HP: 39, // Harpy HD: 40, // Hydra CT: 41, // Centaur PG: 42, // Pegasus RE: 43, // Horseman HO: 44, // Hoplite CA: 45, // Catapult ee: 46, // SK: 47, // Swordsman BS: 48, // Archer MT: 49, // Minotaur CL: 50, // Cyclop SE: 51, // Siren ST: 52, // Satyr LD: 53, // Ladon SR: 54, // Spartoi BT: 55, BE: 56, Bo: 57, a1: 64, a2: 65, a3: 66, a4: 67, a5: 68, a6: 69, a7: 70, a8: 71, }, deactivate: () => { $('#town_icon').remove(); $('#dio_townicons_field').remove(); }, activate: () => { try { $('
    ').appendTo('.town_name_area'); // Town Icon Style $('#town_icon .icon_big').css({ backgroundPosition: TownIcons.types[(manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no")))] * -25 + 'px 0px' }); //console.debug(dio_sprite); $('').appendTo('head'); var icoArray = [ 'lo', 'ld', 'fo', 'fd', 'so', 'sd', 'no', 'po', 'sh', 'di', 'un', 'ko', 'ti', 'gr', 'dp', 're', 'wd', 'st', 'si', 'bu', 'he', 'ch', 'bo', 'fa', 'wo', 'OO', 'O1', 'O2', 'O3', 'O4', 'O5', 'O6', 'hr', 'FS', 'BI', 'TR', 'BT', 'BE', 'CE', 'DS', 'SK', 'SL', 'BS', 'HO', 'RE', 'SW', 'CA', 'CT', 'CB', 'CL', 'EY', 'MD', 'MT', 'HD', 'HP', 'MN', 'PG', 'GF', 'CY', 'SE', 'ST', 'LD', 'SR', 'ee', 'Bo', 'hr', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', ]; // Fill select box with town icons $('').appendTo("#town_icon"); for (var i in icoArray) { if (icoArray.hasOwnProperty(i)) { if (icoArray[i] === 'hr') { $('.select_town_icon .item-list').append('
    '); } else { $('.select_town_icon .item-list').append('
    '); } } } $('
    Auto
    ' + '
    ' + '
    ').appendTo('.select_town_icon .item-list'); $('#town_icon .auto_s').tooltip('' + '' + '' + '' + '' + '' + '' + '' + '
    ' + getTexts("Town_icons", "LandOff") + '
    ' + getTexts("Town_icons", "FlyOff") + '
    ' + getTexts("Town_icons", "NavyOff") + '
    ' + getTexts("Town_icons", "Out") + '
    ' + getTexts("Town_icons", "LandDef") + '
    ' + getTexts("Town_icons", "FlyDef") + '
    ' + getTexts("Town_icons", "NavyDef") + '
    ' + getTexts("Town_icons", "Emp") + '
    '); $('#town_icon .défaut_s').tooltip(dio_icon + getTexts("buttons", "res")); $('#town_icon .option_s').click(function () { $("#town_icon .sel").removeClass("sel"); $(this).addClass("sel"); if ($(this).attr("name") === "auto") { delete manuTownTypes[uw.Game.townId]; manuTownAuto[uw.Game.townId] = true; //getAllUnits(); } else if ($(this).attr("name") === "défaut") { delete manuTownTypes[uw.Game.townId]; delete manuTownAuto[uw.Game.townId]; //getAllUnits(); } else { manuTownTypes[uw.Game.townId] = $(this).attr("name"); } TownIcons.changeTownIcon(); getAllUnits(); TownList.change(); // Update town icons on the map if (DATA.options.dio_tim) { Map.add(); } //setOnMap(); saveValue(WID + "_townTypes", JSON.stringify(manuTownTypes)); saveValue(WID + "_townAuto", JSON.stringify(manuTownAuto)); }); // Show & hide drop menus on click $('#town_icon .town_icon_bg').click(() => { var el = $('#town_icon .select_town_icon').get(0); if (el.style.display === "none") { el.style.display = "block"; } else { el.style.display = "none"; } }); $('#town_icon .select_town_icon [name="' + (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" : "")) + '"]').addClass("sel"); } catch (error) { errorHandling(error, "addTownIcon"); } }, changeTownIcon: () => { var townType = (manuTownTypes[uw.Game.townId] || ((autoTownTypes[uw.Game.townId] || "no"))); $('#town_icon .icon_big').removeClass().addClass('icon_big townicon_' + townType + " auto"); $('#town_icon .sel').removeClass("sel"); $('#town_icon .select_town_icon [name="' + (manuTownTypes[uw.Game.townId] || (autoTownTypes[uw.Game.townId] ? "auto" : "")) + '"]').addClass("sel"); $('#town_icon .icon_big').css({ backgroundPosition: TownIcons.types[townType] * -25 + 'px 0px' }); $('#town_icon .select_town_icon').get(0).style.display = "none"; }, auto: { activate: () => { setTimeout(() => { getAllUnits(); TownIcons.changeTownIcon(); }, 100); }, deactivate: () => { setTimeout(() => { getAllUnits(); TownIcons.changeTownIcon(); }, 100); }, }, }; // Style for town icons var style_str = ''; $(style_str).appendTo('head'); /******************************************************************************************************************************* * Town icon (Map) *******************************************************************************************************************************/ var Map = { // TODO: activate aufspliten in activate und add activate: () => { //style $("").appendTo("head"); Map.add(); $("#ui_box > div.topleft_navigation_area > div.coords_box > div.btn_jump_to_coordination.circle_button.jump_to_coordination > div, #ui_box > div.topleft_navigation_area > div.bull_eye_buttons > div.btn_jump_to_town.circle_button.jump_to_town > div, #minimap_canvas, #map").click(() => { if (DATA.options.dio_tim) setTimeout(() => { Map.add(); }, 500); }); $("#minimap_canvas").dblclick(() => { if (DATA.options.dio_tim) setTimeout(() => { Map.add(); }, 500); }); }, add: () => { try { // Style for own towns (town icons) for (var e in autoTownTypes) { if (autoTownTypes.hasOwnProperty(e)) { $("#mini_t" + e + ", #town_flag_" + e + " .flagpole").css({ "background": "rgb(255, 187, 0) url(" + dio_icon_small + ") repeat", "background-position": (TownIcons.types[(manuTownTypes[e] || autoTownTypes[e])] * -25) + "px -27px", }); } $('#minimap_islands_layer').off("mousedown"); $('#minimap_islands_layer').on("mousedown", function () { if (typeof ($('#context_menu').get(0)) !== "undefined") { $('#context_menu').get(0).remove(); } }); } } catch (error) { errorHandling(error, "Map.add"); } }, deactivate: () => { $('#dio_townicons_map').remove(); $(".own_town .flagpole, #main_area .m_town").css({ "background": "" }); } }; /******************************************************************************************************************************* * Town Popup *******************************************************************************************************************************/ var TownPopup = { activate: () => { $('').appendTo('head'); // Town Popups on Strategic map $('#minimap_islands_layer').off('mouseout', '.m_town'); $('#minimap_islands_layer').on('mouseout', '.m_town', function () { TownPopup.remove(); }); $('#minimap_islands_layer').off('mouseover', '.m_town'); $('#minimap_islands_layer').on('mouseover', '.m_town', function () { TownPopup.add(this); }); // Town Popups on island view $('#map_towns').off('mouseout', '.own_town .flagpole'); $('#map_towns').on('mouseout', '.own_town .flagpole', function () { TownPopup.remove(); }); $('#map_towns').off('mouseover', '.own_town .flagpole'); $('#map_towns').on('mouseover', '.own_town .flagpole', function () { TownPopup.add(this); }); }, deactivate: () => { $("#dio_town_popup_style").remove(); // Events entfernen $('#minimap_islands_layer').off('click', '.m_town'); $('#minimap_islands_layer').off("mousedown"); $('#minimap_islands_layer').off('mouseout', '.m_town'); $('#minimap_islands_layer').off('mouseover', '.m_town'); }, add: (that) => { var townID = 0; var popup_left = 0, popup_top = 0, classSize = ""; //console.debug("TOWN", $(that).offset(), that.id); if (that.classList.contains('town_name')) { townID = parseInt(that.parentNode.dataset.townid); popup_left = ($(that).offset().left - 150); popup_top = ($(that).offset().top + 20); } else if (that.id === "") { // Island view townID = parseInt($(that).parent()[0].id.substring(10), 10); if (DATA.options.dio_tim) { popup_left = ($(that).offset().left + 20); popup_top = ($(that).offset().top + 20); } else { popup_left = ($(that).offset().left + 15); popup_top = ($(that).offset().top + 15); } } else { // Strategic map townID = parseInt(that.id.substring(6), 10); if (DATA.options.dio_tim) { popup_left = ($(that).offset().left - 150); popup_top = ($(that).offset().top + 20); } else { popup_left = ($(that).offset().left - 145); popup_top = ($(that).offset().top + 15); } } // Own town? if (typeof (uw.ITowns.getTown(townID)) !== "undefined") { var units = uw.ITowns.getTowns()[townID].units(); var unitsSupport = uw.ITowns.getTowns()[townID].unitsSupport(); var error = false; TownPopup.remove(); // var popup = "
    "; var popup = ""; popup += ""; popup += ""; popup += ""; popup += ""; $(popup).appendTo("#popup_div_curtain"); } }, remove: () => { $('#dio_town_popup').remove(); } }; /******************************************************************************************************************************* * Town list: Adds town type to the town list *******************************************************************************************************************************/ var TownList = { activate: () => { // Style town list $('').appendTo('head'); // Open town list: hook to grepolis function render() var i = 0; while (uw.layout_main_controller.sub_controllers[i].name != 'town_name_area') { i++; } 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; uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render = function () { uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render_old(); TownList.change(); }; // Town List open? if ($('#town_groups_list').get(0)) { TownList.change(); } }, deactivate: () => { var i = 0; while (uw.layout_main_controller.sub_controllers[i].name != 'town_name_area') { i++; } uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render = uw.layout_main_controller.sub_controllers[i].controller.town_groups_list_view.render_old; $('#dio_town_list').remove(); $('#town_groups_list .dio_icon_small, #town_groups_list .pop_percent').css({ display: 'none' }); $("#town_groups_list .town_group_town").unbind('mouseenter mouseleave'); }, change: () => { if (!$('#town_groups_list .dio_icon_small').get(0)) { $("#town_groups_list .town_group_town").each(function () { try { var town_item = $(this), town_id = town_item.attr('name'), townicon_div, percent_div = "", percent = -1, pop_space = "full"; if (population[town_id]) { percent = population[town_id].percent; } if (percent < 75) { pop_space = "threequarter"; } if (percent < 50) { pop_space = "half"; } if (percent < 25) { pop_space = "quarter"; } if (!town_item.find('dio_icon_small').length) { townicon_div = '
    '; // TODO: Notlösung... if (percent != -1) { percent_div = '
    ' + percent + '%
    '; } town_item.prepend(townicon_div + percent_div); } } catch (error) { errorHandling(error, "TownList.change"); } }); } // Hover Effect for Quacks Tool: $("#town_groups_list .town_group_town").hover( function () { $(this).find('.island_quest_icon').addClass("hidden_icon"); }, function () { $(this).find('.island_quest_icon').removeClass("hidden_icon"); } ); } }; /******************************************************************************************************************************* * Swap Context Icons *******************************************************************************************************************************/ var ContextMenu = { activate: () => { // Set context menu event handler $.Observer(uw.GameEvents.map.context_menu.click).subscribe('DIO_CONTEXT', function (e, data) { if (DATA.options.dio_con && $('#context_menu').children().length == 4) { // Clear animation $('#context_menu div#goToTown').css({ left: '0px', top: '0px', WebkitAnimation: 'none', //'A 0s linear', animation: 'none' //'B 0s linear' }); } // Replace german label of 'select town' button if (LID === "de" && $('#select_town').get(0)) { $("#select_town .caption").get(0).innerHTML = "Selektieren"; } $("#select_town").click(updateIcon); }); // Set context menu animation $('').appendTo('head'); updateIcon(); }, deactivate: () => { $.Observer(uw.GameEvents.map.context_menu.click).unsubscribe('DIO_CONTEXT'); $('#dio_context_menu').remove(); } }; /******************************************************************************************************************************* * Temporary replacement grcrt "City Command Overview" *******************************************************************************************************************************/ $('').appendTo('head'); /******************************************************************************************************************************* * Available units * ---------------------------------------------------------------------------------------------------------------------------- * | ● GetAllUnits * | ● Shows all available units * ---------------------------------------------------------------------------------------------------------------------------- *******************************************************************************************************************************/ var groupUnitArray = {}; // TODO: split Function (getUnits, calcUnitsSum, availableUnits, countBiremes, getTownTypes)? // Alter Einheitenzähler function getAllUnits() { try { var townArray = uw.ITowns.getTowns(), groupArray = uw.ITowns.townGroups.getGroupsDIO(), unitArray = { "sword": 0, "archer": 0, "hoplite": 0, "chariot": 0, "godsent": 0, "rider": 0, "slinger": 0, "catapult": 0, "small_transporter": 0, "big_transporter": 0, "manticore": 0, "harpy": 0, "pegasus": 0, "cerberus": 0, "minotaur": 0, "medusa": 0, "zyklop": 0, "centaur": 0, "fury": 0, "sea_monster": 0 }, unitArraySea = { "bireme": 0, "trireme": 0, "attack_ship": 0, "demolition_ship": 0, "colonize_ship": 0 }; if (uw.Game.hasArtemis) { unitArray = $.extend(unitArray, { "griffin": 0, "calydonian_boar": 0 }); } if (uw.Game.gods_active.aphrodite) { unitArray = $.extend(unitArray, { "siren": 0, "satyr": 0 }); } if (uw.Game.gods_active.ares) { unitArray = $.extend(unitArray, { "spartoi": 0, "ladon": 0 }); } unitArray = $.extend(unitArray, unitArraySea); for (var group in groupArray) { if (groupArray.hasOwnProperty(group)) { groupUnitArray[group] = Object.create(unitArray); for (var town in groupArray[group].towns) { if (groupArray[group].towns.hasOwnProperty(town)) { var type = { lo: 0, ld: 0, so: 0, sd: 0, fo: 0, fd: 0 }; // Type for TownList for (var unit in unitArray) { if (unitArray.hasOwnProperty(unit)) { // All Groups: Available units var tmp = parseInt(uw.ITowns.getTown(town).units()[unit], 10); groupUnitArray[group][unit] += tmp || 0; // Only for group "All" if (group == -1) { // Bireme counter // old if (unit === "bireme" && ((biriArray[townArray[town].id] || 0) < (tmp || 0))) { biriArray[townArray[town].id] = tmp; } //TownTypes if (!uw.GameData.units[unit].is_naval) { if (uw.GameData.units[unit].flying) { type.fd += ((uw.GameData.units[unit].def_hack + uw.GameData.units[unit].def_pierce + uw.GameData.units[unit].def_distance) / 3 * (tmp || 0)); type.fo += (uw.GameData.units[unit].attack * (tmp || 0)); } else { type.ld += ((uw.GameData.units[unit].def_hack + uw.GameData.units[unit].def_pierce + uw.GameData.units[unit].def_distance) / 3 * (tmp || 0)); type.lo += (uw.GameData.units[unit].attack * (tmp || 0)); } } else { type.sd += (uw.GameData.units[unit].defense * (tmp || 0)); type.so += (uw.GameData.units[unit].attack * (tmp || 0)); } } } } // Only for group "All" if (group == -1) { // Icon: DEF or OFF? var z = ((type.sd + type.ld + type.fd) <= (type.so + type.lo + type.fo)) ? "o" : "d", temp = 0; for (var t in type) { if (type.hasOwnProperty(t)) { // Icon: Land/Sea/Fly (t[0]) + OFF/DEF (z) if (temp < type[t]) { autoTownTypes[townArray[town].id] = t[0] + z; temp = type[t]; } // Icon: Troops Outside (overwrite) if (temp < 1000) { autoTownTypes[townArray[town].id] = "no"; } } } // Icon: Empty Town (overwrite) var popBuilding = 0, buildVal = uw.GameData.buildings, levelArray = townArray[town].buildings().getLevels(), popMax = Math.floor(buildVal.farm.farm_factor * Math.pow(townArray[town].buildings().getBuildingLevel("farm"), buildVal.farm.farm_pow)), // Population from farm level popPlow = townArray[town].getResearches().attributes.plow ? 200 : 0, popFactor = townArray[town].getBuildings().getBuildingLevel("thermal") ? 1.1 : 1.0, // Thermal popExtra = townArray[town].getPopulationExtra(); for (var b in levelArray) { if (levelArray.hasOwnProperty(b)) { popBuilding += Math.round(buildVal[b].pop * Math.pow(levelArray[b], buildVal[b].pop_factor)); } } population[town] = {}; population[town].max = popMax * popFactor + popPlow + popExtra; population[town].buildings = popBuilding; population[town].units = parseInt((population[town].max - (popBuilding + townArray[town].getAvailablePopulation())), 10); if (population[town].units < 300) { autoTownTypes[townArray[town].id] = "po"; } population[town].percent = Math.round(100 / (population[town].max - popBuilding) * population[town].units); if (!manuTownAuto[townArray[town].id] && DATA.options.dio_tic && !DATA.options.dio_tic2) { autoTownTypes[townArray[town].id] = "OO"; } } } } } } // Update Available Units AvailableUnits.updateBullseye(); if (uw.GPWindowMgr.TYPE_DIO_UNITS) { if (uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_UNITS)) { AvailableUnits.updateWindow(); } } } catch (error) { errorHandling(error, "getAllUnits"); } // TODO: Eventueller Fehler in Funktion } function addFunctionToITowns() { try { var version_latest = "??"; setTimeout(() => { try { uw.MM.DIO.info_dio.latest_version = uw.dio_latest_version; } catch (error) { errorHandling(error, "dio_latest_version (addFunctionToITowns)"); } }, 1000); // Copy function and prevent an error uw.MM.DIO = { player_idle: {}, getPlayer: {}, info_dio: { name: "DIO-TOOLS-David1327", version: dio_version, latest_version: version_latest, script: { grcrt: "", HMole: "", Gt: "", FLASK: "", Quack: "", GrepoData: "", }, }, errorDio: { nb: 0 }, lang: uw.Game.market_id, land: uw.Game.world_id.substring(0, 2), }; var script = uw.MM.DIO.info_dio.script; setTimeout(() => { script.grcrt = (typeof (uw.GRCRT_Notifications) !== "undefined" ? true : false); script.HMole = (typeof (uw.MH) !== "undefined" ? true : false); script.Gt = (typeof (uw.GtkAbout) !== "undefined" ? true : false); script.FLASK = (typeof (uw.FLASK_GAME) !== "undefined" ? true : false); script.Quack = (typeof (uw.main_script) !== "undefined" ? true : false); script.GrepoData = (typeof (uw.gd_version) !== "undefined" ? true : false); }, 10000); uw.MM.DIO.getPlayer.Groups = function () { var town_groups_towns, town_groups, groups = {}; // #Grepolis Fix: 2.75 -> 2.76 if (uw.MM.collections) { town_groups_towns = uw.MM.collections.TownGroupTown[0]; town_groups = uw.MM.collections.TownGroup[0]; } else { town_groups_towns = uw.MM.getCollections().TownGroupTown[0]; town_groups = uw.MM.getCollections().TownGroup[0]; } town_groups_towns.each(function (town_group_town) { var gid = town_group_town.getGroupId(), group = groups[gid], town_id = town_group_town.getTownId(); if (!group) { groups[gid] = group = { id: gid, //name: town_groups.get(gid).getName(), // hier tritt manchmal ein Fehler auf: TypeError: Cannot read property "getName" of undefined at https://_.grepolis.com/cache/js/merged/game.js?1407322916:8298:525 towns: {} }; } group.towns[town_id] = { id: town_id }; //groups[gid].towns[town_id]={id:town_id}; }); //console.log(groups); return groups; }; uw.MM.DIO.getPlayer.Groups_town = function () { var town_groups_towns, town_groups, groups = {}; // #Grepolis Fix: 2.75 -> 2.76 if (uw.MM.collections) { town_groups_towns = uw.MM.collections.TownGroupTown[0]; town_groups = uw.MM.collections.TownGroup[0]; } else { town_groups_towns = uw.MM.getCollections().TownGroupTown[0]; town_groups = uw.MM.getCollections().TownGroup[0]; } town_groups_towns.each(function (town_group_town) { var gid = town_group_town.getGroupId(), town_id = town_group_town.getTownId(), group = groups[town_id]; if (!group) { groups[town_id] = group = { id: town_id, //name: town_groups.get(gid).getName(), // hier tritt manchmal ein Fehler auf: TypeError: Cannot read property "getName" of undefined at https://_.grepolis.com/cache/js/merged/game.js?1407322916:8298:525 groups: {} }; } if (town_id !== 0 || town_id !== -1) { group.groups[gid] = { id: gid, name: uw.ITowns.town_groups._byId[gid].attributes.name } }; //groups[gid].towns[town_id]={id:town_id}; }); //console.log(groups); return groups; }; uw.MM.DIO.getPlayer.Hero = function () { var PlayerHero, heros = {}; // #Grepolis Fix: 2.75 -> 2.76 if (uw.MM.collections) { PlayerHero = uw.MM.collections.PlayerHero[0]; } else { PlayerHero = uw.MM.getCollections().PlayerHero[0]; } PlayerHero.each(function (PlayerHero) { var hero_name = PlayerHero.getId(), hero_level = PlayerHero.getLevel(), town_id = PlayerHero.getHomeTownId(), town_name = PlayerHero.getOriginTownName(), hero = heros[town_id]; if (!hero) { heros[town_id] = hero = { town_id: town_id, town: town_name, hero_name, hero_level: hero_level }; } }); return heros; }; uw.MM.DIO.AlliancePact = function () { var ENEMY = {}, PACT = {}, AlliancePact = {}; function attributes(Relation, a) { if (a.attributes.alliance_1_id == AID) { Relation[a.attributes.alliance_2_id] = { id: a.attributes.alliance_2_id, town: a.attributes.alliance_2_name, } } else { Relation[a.attributes.alliance_1_id] = { id: a.attributes.alliance_1_id, town: a.attributes.alliance_1_name, } } } $.each(uw.MM.getOnlyCollectionByName("AlliancePact").models, function (h, a) { if (!a.getInvitationPending()) { switch (a.getRelation()) { case "war": attributes(ENEMY, a); break; case "peace": attributes(PACT, a); break; } }; }); AlliancePact.ENEMY = ENEMY; AlliancePact.PACT = PACT; return AlliancePact; }; uw.ITowns.townGroups.getGroupsDIO = function () { var town_groups_towns, town_groups, groups = {}; // #Grepolis Fix: 2.75 -> 2.76 if (uw.MM.collections) { town_groups_towns = uw.MM.collections.TownGroupTown[0]; town_groups = uw.MM.collections.TownGroup[0]; } else { town_groups_towns = uw.MM.getCollections().TownGroupTown[0]; town_groups = uw.MM.getCollections().TownGroup[0]; } town_groups_towns.each(function (town_group_town) { var gid = town_group_town.getGroupId(), group = groups[gid], town_id = town_group_town.getTownId(); if (!group) { groups[gid] = group = { id: gid, //name: town_groups.get(gid).getName(), // hier tritt manchmal ein Fehler auf: TypeError: Cannot read property "getName" of undefined at https://_.grepolis.com/cache/js/merged/game.js?1407322916:8298:525 towns: {} }; } group.towns[town_id] = { id: town_id }; //groups[gid].towns[town_id]={id:town_id}; }); //console.log(groups); return groups; }; uw.ITowns.getHeroDIO = function () { var town_groups_towns, town_groups, groups = {}; // #Grepolis Fix: 2.75 -> 2.76 var PlayerHero; if (uw.MM.collections) { PlayerHero = uw.MM.collections.PlayerHero[0]; } else { PlayerHero = uw.MM.getCollections().PlayerHero[0]; } PlayerHero.each(function (PlayerHero) { var hero_name = PlayerHero.getId(), hero_level = PlayerHero.getLevel(), town_id = PlayerHero.getHomeTownId(), town_name = PlayerHero.getOriginTownName(), group = groups[town_id]; if (!group) { groups[town_id] = group = { town_id: town_id, town: town_name, hero_name, hero_level: hero_level }; } }); return groups; }; } catch (error) { errorHandling(error, "addFunctionToITowns"); } } // Neuer Einheitenzähler var UnitCounter = { units: { "total": {}, "available": {}, "outer": {}, "foreign": {}, "support": {} }, count: () => { var tooltipHelper = uw.require("helpers/units_tooltip_helper"); var groups = uw.ITowns.townGroups.getGroupsDIO(); for (var groupId in groups) { if (groups.hasOwnProperty(groupId)) { UnitCounter.units.total[groupId] = {}; UnitCounter.units.available[groupId] = {}; UnitCounter.units.outer[groupId] = {}; UnitCounter.units.support[groupId] = {}; for (var townId in groups[groupId].towns) { if (groups[groupId].towns.hasOwnProperty(townId)) { // Einheiten gesamt UnitCounter.units.total[groupId][townId] = uw.ITowns.towns[townId].units(); // Einheiten verfügbar UnitCounter.units.available[groupId][townId] = uw.ITowns.towns[townId].units(); // Einheiten außerhalb UnitCounter.units.outer[groupId][townId] = {}; // Einheiten außerhalb UnitCounter.units.support[groupId][townId] = uw.ITowns.towns[townId].unitsSupport(); var supports = tooltipHelper.getDataForSupportingUnitsInOtherTownFromCollection(uw.MM.getTownAgnosticCollectionsByName("Units")[1].fragments[townId], uw.MM.getOnlyCollectionByName("Town")); for (var supportId in supports) { if (supports.hasOwnProperty(supportId)) { for (var attributeId in supports[supportId].attributes) { if (supports[supportId].attributes.hasOwnProperty(attributeId)) { // Attribut ist eine Einheit? if (typeof (uw.GameData.units[attributeId]) !== "undefined" && supports[supportId].attributes[attributeId] > 0) { UnitCounter.units.outer[groupId][townId][attributeId] = (UnitCounter.units.outer[groupId][townId][attributeId] || 0) + supports[supportId].attributes[attributeId]; UnitCounter.units.total[groupId][townId][attributeId] = (UnitCounter.units.total[groupId][townId][attributeId] || 0) + supports[supportId].attributes[attributeId]; } } } } } } } // Summen aller Städte berechnen UnitCounter.summarize(groupId); } } return UnitCounter.units; }, summarize: (groupId) => { var tooltipHelper = uw.require("helpers/units_tooltip_helper"); UnitCounter.units.total[groupId].all = {}; UnitCounter.units.available[groupId].all = {}; UnitCounter.units.outer[groupId].all = {}; UnitCounter.units.support[groupId].all = {}; for (var townId in UnitCounter.units.total[groupId]) { if (UnitCounter.units.total[groupId].hasOwnProperty(townId) && townId !== "all") { var unitId; // Einheiten gesamt for (unitId in UnitCounter.units.total[groupId][townId]) { if (UnitCounter.units.total[groupId][townId].hasOwnProperty(unitId)) { UnitCounter.units.total[groupId].all[unitId] = (UnitCounter.units.total[groupId].all[unitId] || 0) + UnitCounter.units.total[groupId][townId][unitId]; } } // Einheiten verfügbar for (unitId in UnitCounter.units.available[groupId][townId]) { if (UnitCounter.units.available[groupId][townId].hasOwnProperty(unitId)) { UnitCounter.units.available[groupId].all[unitId] = (UnitCounter.units.available[groupId].all[unitId] || 0) + UnitCounter.units.available[groupId][townId][unitId]; } } // Einheiten außerhalb for (unitId in UnitCounter.units.outer[groupId][townId]) { if (UnitCounter.units.outer[groupId][townId].hasOwnProperty(unitId)) { UnitCounter.units.outer[groupId].all[unitId] = (UnitCounter.units.outer[groupId].all[unitId] || 0) + UnitCounter.units.outer[groupId][townId][unitId]; } } // Einheiten außerhalb for (unitId in UnitCounter.units.support[groupId][townId]) { if (UnitCounter.units.support[groupId][townId].hasOwnProperty(unitId)) { UnitCounter.units.support[groupId].all[unitId] = (UnitCounter.units.support[groupId].all[unitId] || 0) + UnitCounter.units.support[groupId][townId][unitId]; } } } } } }; var AvailableUnits = { timeout: null, activate: () => { AvailableUnits.timeout = setInterval(() => { UnitCounter.count(); }, 1000); var DioMenuFix = !1; $("#dio_available_units_bullseye").length && 0 == DioMenuFix && ( DioMenuFix = !0, $("#HMoleM").css({ top: $("#ui_box .nui_left_box:first").offset().top + $("#ui_box .nui_left_box:first")[0].scrollHeight - 6 }), uw.MH.nui_main_menu() ); $('').appendTo('head'); var default_title = uw.DM.getl10n("place", "support_overview").options.troop_count + " (" + getTexts("labels", "available") + ")"; $(".dio_picomap_container").prepend("
    "); // Ab version 2.115 if ($(".topleft_navigation_area").get(0)) { $(".topleft_navigation_area").prepend("
    "); $('').appendTo('head'); AvailableUnits.autre(); } // Style $('').appendTo('head'); if (uw.Game.gods_active.aphrodite || uw.Game.gods_active.ares) { createWindowType("DIO_UNITS", (LANG.hasOwnProperty(LID) ? getTexts("Options", "ava")[0] : default_title), 430, 315, true, [240, 70]); } else { createWindowType("DIO_UNITS", (LANG.hasOwnProperty(LID) ? getTexts("Options", "ava")[0] : default_title), 378, 315, true, [240, 70]); } // Set Sea-ID beside the bull eye $('#sea_id').prependTo('#ui_box'); AvailableUnits.addButton(); UnitCounter.count(); AvailableUnits.updateBullseye(); $('.dio_picomap_overlayer').tooltip(dio_icon + getTexts("Options", "ava")[0]); }, autre: () => { if ($(".topleft_navigation_area").get(0)) { $('#dio_available_units_style_oceanautre').remove() $('#dio_available_units_style_oceanaut').remove(); if (DATA.options.dio_ava2) { $('').appendTo('head'); } else if (!DATA.options.dio_ava2) { $('').appendTo('head'); }; } }, ocean: { activate: () => { if (DATA.options.dio_ava) setTimeout(() => { AvailableUnits.autre(); }, 10); }, deactivate: () => { if (DATA.options.dio_ava) setTimeout(() => { AvailableUnits.autre(); }, 10); }, }, deactivate: () => { $('#dio_available_units_bullseye').remove(); $('#dio_available_units_bullseye_addition').remove(); $('#dio_available_units_style_addition_main_menu').remove(); $('#dio_available_units_style_oceanautre').remove(); $('#dio_available_units_style_oceanaut').remove(); $('').appendTo('head'); $('#dio_available_units_style').remove(); $('#dio_available_units_style_addition').remove(); $('#dio_btn_available_units').remove(); if (uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_UNITS)) { uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_UNITS).close(); } $('.dio_picomap_overlayer').unbind(); $('#sea_id').appendTo('.dio_picomap_container') $('#dio_available_units_style_ocean').remove() clearTimeout(AvailableUnits.timeout); AvailableUnits.timeout = null; }, addButton: () => { var default_title = uw.DM.getl10n("place", "support_overview").options.troop_count + " (" + getTexts("labels", "available") + ")"; $('
    ').appendTo(".bull_eye_buttons"); // Events $('#dio_btn_available_units').on('mousedown', function () { $('#dio_btn_available_units, .ico_available_units').addClass("checked"); }).on('mouseup', function () { $('#dio_btn_available_units, .ico_available_units').removeClass("checked"); }); $('#dio_btn_available_units, .dio_picomap_overlayer').click(() => { if (!uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_UNITS)) { AvailableUnits.openWindow(); $('#dio_btn_available_units, .ico_available_units').addClass("checked"); } else { AvailableUnits.closeWindow(); $('#dio_btn_available_units, .ico_available_units').removeClass("checked"); } }); $('.close_all').click(() => { $('#dio_btn_available_units, .ico_available_units').removeClass("checked"); }); // Tooltip $('#dio_btn_available_units').tooltip(LANG.hasOwnProperty(LID) ? dio_icon + getTexts("labels", "uni") : default_title); }, openWindow: () => { var groupArray = uw.ITowns.townGroups.getGroupsDIO(), unitArray = { "sword": 0, "archer": 0, "hoplite": 0, "slinger": 0, "rider": 0, "chariot": 0, "catapult": 0, "godsent": 0, "manticore": 0, "harpy": 0, "pegasus": 0, "griffin": 0, "cerberus": 0, "minotaur": 0, "medusa": 0, "zyklop": 0, "centaur": 0, "calydonian_boar": 0, "fury": 0, "sea_monster": 0, "spartoi": 0, "ladon": 0, "satyr": 0, "siren": 0, "small_transporter": 0, "big_transporter": 0, "bireme": 0, "attack_ship": 0, "trireme": 0, "demolition_ship": 0, "colonize_ship": 0 }; if (!groupArray[DATA.bullseyeUnit.current_group]) { DATA.bullseyeUnit.current_group = -1; } if (!uw.Game.hasArtemis) { delete unitArray.calydonian_boar; delete unitArray.griffin; } if (!uw.Game.gods_active.aphrodite) { delete unitArray.siren; delete unitArray.satyr; } if (!uw.Game.gods_active.ares) { delete unitArray.spartoi; delete unitArray.ladon; } var land_units_str = "", content = '
    ' + // Dropdown menu '
    ' + '' + '' + '
    ' + '' + '' + '' + '' + '' + '
    ' + getTexts("labels", "total") + '
    ' + getTexts("labels", "available") + '
    ' + getTexts("labels", "outer") + '
    ' + getTexts("labels", "sup") + '
    ' + '
    ' + '
    ' + '' + '
    ' + '' + // Content '
    '; for (var unit in unitArray) { if (unitArray.hasOwnProperty(unit)) { land_units_str += '
    '; if (uw.Game.gods_active.aphrodite) { if (unit == "siren") { land_units_str += '
    '; } // break } else if (uw.Game.gods_active.ares) { if (unit == "ladon") { land_units_str += '
    '; } } else if (unit == "sea_monster") { land_units_str += '
    '; } } } content += land_units_str + '
    '; AvailableUnits.wnd = uw.Layout.wnd.Create(uw.GPWindowMgr.TYPE_DIO_UNITS); AvailableUnits.wnd.setContent(content); /*global Timestamp*/ if (uw.Game.premium_features.curator <= Timestamp.now()) { $('#dio_available_units .drop_box').css({ display: 'none' }); DATA.bullseyeUnit.current_group = -1; } // Add groups to dropdown menu for (var group in groupArray) { if (groupArray.hasOwnProperty(group)) { if (uw.ITowns.town_groups._byId[group]) { var group_name = uw.ITowns.town_groups._byId[group].attributes.name; $('
    ' + group_name + '
    ').appendTo('#dio_available_units .item-list'); } } } // Set active mode if (typeof (DATA.bullseyeUnit.mode) !== "undefined") { $('#dio_available_units .radiobutton .option[name="' + DATA.bullseyeUnit.mode + '"]').addClass("checked"); } else { $('#dio_available_units .radiobutton .option[name="available"]').addClass("checked"); } // Update AvailableUnits.updateWindow(); // Dropdown menu Handler $('#dio_available_units .drop_group').click(() => { $('#dio_available_units .select_group').toggleClass('open'); }); // Change group $('#dio_available_units .select_group .option').click(function () { DATA.bullseyeUnit.current_group = $(this).attr("name"); $('#dio_available_units .select_group').removeClass('open'); $('#dio_available_units .select_group .option.sel').removeClass("sel"); $(this).addClass("sel"); $('#dio_available_units .drop_group .caption').attr("name", DATA.bullseyeUnit.current_group); $('#dio_available_units .drop_group .caption').get(0).innerHTML = this.innerHTML; $('#dio_available_units .unit.active').removeClass("active"); $('#dio_available_units .unit.' + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme")).addClass("active"); UnitCounter.count(); AvailableUnits.updateWindow(); AvailableUnits.updateBullseye(); AvailableUnits.save(); }); // Change mode (total, available, outer) $('#dio_available_units .radiobutton .option').click(function () { DATA.bullseyeUnit.mode = $(this).attr("name"); $('#dio_available_units .radiobutton .option.checked').removeClass("checked"); $(this).addClass("checked"); UnitCounter.count(); AvailableUnits.updateWindow(); AvailableUnits.updateBullseye(); AvailableUnits.save(); }); // Set active bullseye unit $('#dio_available_units .unit.' + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme")).addClass("active"); // Change bullseye unit $('#dio_available_units .unit').click(function () { DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] = this.className.split(" ")[4].trim(); $('#dio_available_units .unit.active').removeClass("active"); $(this).addClass("active"); AvailableUnits.updateBullseye(); AvailableUnits.save(); }); //tooltip $('#dio_help_available_units').tooltip('Wiki (' + dio_icon + getTexts("Options", "ava")[0] + ')'); /* for (unit in unitArray) { if (unitArray.hasOwnProperty(unit)) { $('#dio' + unit).tooltip(uw.GameData.units[unit].name); } } */ $('#dio_close_available_units').click(() => { if (!uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_UNITS)) { AvailableUnits.openWindow(); $('#dio_btn_available_units, .ico_available_units').addClass("checked"); } else { AvailableUnits.closeWindow(); $('#dio_btn_available_units, .ico_available_units').removeClass("checked"); } }); }, closeWindow: () => { uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_UNITS).close(); }, save: () => { // console.debug("BULLSEYE SAVE", DATA.bullseyeUnit); saveValue(WID + "_bullseyeUnit", JSON.stringify(DATA.bullseyeUnit)); }, updateBullseye: () => { var sum = 0, str = "", fsize = ['1.4em', '1.2em', '1.15em', '1.1em', '1.0em', '0.95em'], i; if ($('#dio_available_units_bullseye').get(0)) { $('#dio_available_units_bullseye').get(0).className = "unit_icon90x90 " + (DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme"); if (UnitCounter.units[DATA.bullseyeUnit.mode || "available"][DATA.bullseyeUnit.current_group]) { sum = UnitCounter.units[DATA.bullseyeUnit.mode || "available"][DATA.bullseyeUnit.current_group].all[(DATA.bullseyeUnit[DATA.bullseyeUnit.current_group] || "bireme")] || 0; } sum = sum.toString(); for (i = 0; i < sum.length; i++) { str += "" + sum[i] + ""; } $('#dio_available_units_bullseye .amount').get(0).innerHTML = str; if (sum >= 100000) { $('#dio_available_units_bullseye').addClass("big_number"); } else { $('#dio_available_units_bullseye').removeClass("big_number"); } } }, updateWindow: () => { $('#dio_available_units .box_content .unit').each(function () { var unit = this.className.split(" ")[4]; // TODO: Alte Variante entfernen // Alte Variante: //this.innerHTML = '' + groupUnitArray[DATA.bullseyeUnit.current_group][unit] + ''; // Neue Variante this.innerHTML = '' + (UnitCounter.units[DATA.bullseyeUnit.mode || "available"][DATA.bullseyeUnit.current_group].all[unit] || 0) + ''; $('#dio' + unit).tooltip(uw.GameData.units[unit].name + " (" + (UnitCounter.units[DATA.bullseyeUnit.mode || "available"][DATA.bullseyeUnit.current_group].all[unit] || 0) + ")"); }); } }; /******************************************************************************************************************************* * Comparison box * ---------------------------------------------------------------------------------------------------------------------------- * | ● Compares the units of each unit type * ---------------------------------------------------------------------------------------------------------------------------- *******************************************************************************************************************************/ var UnitComparison = { activate: () => { //UnitComparison.addBox(); UnitComparison.addButton(); // Create Window Type createWindowType("DIO_COMPARISON", getTexts("labels", "dsc"), 500, 405, true, ["center", "center", 100, 100]); //Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_COMPARISON).setHeight('800'); // Style $('').appendTo("head"); }, deactivate: () => { $('#dio_comparison_button').remove(); $('#dio_comparison_style').remove(); if (uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_COMPARISON)) { uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_COMPARISON).close(); } }, addButton: () => { $('
    ').appendTo(".bull_eye_buttons"); // Events $('#dio_comparison_button').click(() => { if (!uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_COMPARISON)) { UnitComparison.openWindow(); $('#dio_comparison_button').addClass("checked"); } else { UnitComparison.closeWindow(); $('#dio_comparison_button').removeClass("checked"); } }); $('.close_all').click(() => { $('#dio_comparison_button').removeClass("checked"); }); // Tooltip $('#dio_comparison_button').tooltip(dio_icon + getTexts("labels", "dsc")); }, openWindow: () => { var content = // Title tabs '' + '
    ' + '' + '
    ' + '' + // Content '
    '; uw.Layout.wnd.Create(uw.GPWindowMgr.TYPE_DIO_COMPARISON).setContent(content); UnitComparison.addComparisonTable("hack"); UnitComparison.addComparisonTable("pierce"); UnitComparison.addComparisonTable("distance"); UnitComparison.addComparisonTable("sea"); // Tooltips var labelArray = uw.DM.getl10n("barracks"), labelAttack = uw.DM.getl10n("context_menu", "titles").attack, labelDefense = uw.DM.getl10n("place", "tabs")[0]; $('.tr_att').tooltip(labelAttack); $('.tr_def').tooltip(labelDefense + " (Ø)"); $('.tr_def_sea').tooltip(labelDefense); $('.tr_spd').tooltip(labelArray.tooltips.speed); $('.tr_bty').tooltip(labelArray.tooltips.booty.title); $('.tr_bty_sea').tooltip(labelArray.tooltips.ship_transport.title); $('.tr_res').tooltip(labelArray.costs + " (" + labelArray.cost_details.wood + " + " + labelArray.cost_details.stone + " + " + labelArray.cost_details.iron + ")"); $('.tr_woo').tooltip(labelArray.costs + " (" + labelArray.cost_details.wood + ")"); $('.tr_sto').tooltip(labelArray.costs + " (" + labelArray.cost_details.stone + ")"); $('.tr_iro').tooltip(labelArray.costs + " (" + labelArray.cost_details.iron + ")"); $('.tr_fav').tooltip(labelArray.costs + " (" + labelArray.cost_details.favor + ")"); $('.tr_tim').tooltip(labelArray.cost_details.buildtime_barracks + " (s)"); $('.tr_tim_sea').tooltip(labelArray.cost_details.buildtime_docks + " (s)"); UnitComparison.switchComparisonTables(); // Close button event - uncheck available units button /*if (typeof uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_COMPARISON).getJQCloseButton() != 'undefined') { uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_COMPARISON).getJQCloseButton().get(0).onclick = function () { $('#dio_comparison_button').removeClass("checked"); $('.ico_comparison').get(0).style.marginTop = "5px"; }; };*/ $('#dio_close_UnitComparison').click(() => { if (uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_COMPARISON)) { UnitComparison.closeWindow(); $('#dio_comparison_button').removeClass("checked"); } }); }, closeWindow: function () { uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_COMPARISON).close(); }, switchComparisonTables: function () { $('#dio_comparison_menu .hack, #dio_comparison_menu .pierce, #dio_comparison_menu .distance, #dio_comparison_menu .sea').click(function () { $('#dio_comparison .box_content').removeClass($('#dio_comparison .box_content').get(0).className.split(" ")[1]); //console.debug(this.className.split(" ")[1]); $('#dio_comparison .box_content').addClass(this.className.split(" ")[1]); $('#dio_comparison_menu .active').removeClass("active"); $(this).addClass("active"); }); }, tooltips: [], t: 0, addComparisonTable: (type) => { var pos = { att: { hack: "36%", pierce: "27%", distance: "45.5%", sea: "72.5%" }, def: { hack: "18%", pierce: "18%", distance: "18%", sea: "81.5%" } }; var unitIMG = "https://gp" + LID + ".innogamescdn.com/images/game/units/units_info_sprite2.51.png"; var strArray = [ "", '
    ', '
    ', '
    ', (type !== "sea") ? '
    ' : '
    ', '
    ', '
    ', '
    ', '
    ', '
    ', '
    ' ]; for (var e in uw.GameData.units) { if (uw.GameData.units.hasOwnProperty(e)) { var valArray = []; if (type === (uw.GameData.units[e].attack_type || "sea") && (e !== "militia")) { valArray.att = Math.round(uw.GameData.units[e].attack * 10 / uw.GameData.units[e].population) / 10; 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; valArray.def = valArray.def || Math.round(uw.GameData.units[e].defense * 10 / uw.GameData.units[e].population) / 10; valArray.speed = uw.GameData.units[e].speed; valArray.booty = Math.round(((uw.GameData.units[e].booty) * 10) / uw.GameData.units[e].population) / 10; 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; 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)); valArray.wood = Math.round((uw.GameData.units[e].resources.wood) / (uw.GameData.units[e].population)); valArray.stone = Math.round((uw.GameData.units[e].resources.stone) / (uw.GameData.units[e].population)); valArray.iron = Math.round((uw.GameData.units[e].resources.iron) / (uw.GameData.units[e].population)); valArray.favor = Math.round((uw.GameData.units[e].favor * 10) / uw.GameData.units[e].population) / 10; valArray.time = Math.round(uw.GameData.units[e].build_time / uw.GameData.units[e].population); // World without Artemis? -> grey griffin and boar valArray.heroStyle = ""; valArray.heroStyleIMG = ""; if (!uw.Game.hasArtemis && ((e === "griffin") || (e === "calydonian_boar"))) { valArray.heroStyle = "color:black;opacity: 0.4;"; valArray.heroStyleIMG = "filter: url(#GrayScale); -webkit-filter:grayscale(100%);"; } if (!uw.Game.gods_active.aphrodite && ((e === "siren") || (e === "satyr"))) { valArray.heroStyle = "display: none;"; } if (!uw.Game.gods_active.ares && ((e === "spartoi") || (e === "ladon"))) { valArray.heroStyle = "display: none;"; } strArray[0] += ''; strArray[1] += '' + valArray.att + ''; strArray[2] += '' + valArray.def + ''; strArray[3] += '' + valArray.speed + ''; strArray[4] += '' + valArray.booty + ''; strArray[5] += '' + valArray.res + ''; strArray[8] += '' + valArray.wood + ''; strArray[9] += '' + valArray.stone + ''; strArray[10] += '' + valArray.iron + ''; strArray[6] += '' + valArray.favor + ''; strArray[7] += '' + valArray.time + ''; UnitComparison.tooltips[UnitComparison.t] = uw.GameData.units[e].name; UnitComparison.t++; $('#dio_help_UnitComparison').tooltip('Wiki (' + dio_icon + getTexts("Options", "com")[0] + ')'); } } } $('' + '' + strArray[0] + '' + '' + strArray[1] + '' + strArray[2] + '' + '' + strArray[3] + '' + strArray[4] + '' + '' + strArray[5] + '' + strArray[8] + '' + '' + strArray[9] + '' + strArray[10] + '' + '' + strArray[6] + '' + strArray[7] + '' + '').appendTo('#dio_comparison .box_content'); for (var i = 0; i <= UnitComparison.t; i++) { $('.un' + i).tooltip(UnitComparison.tooltips[i]); } } }; /******************************************************************************************************************************* * Reports * ---------------------------------------------------------------------------------------------------------------------------- * | ● Adding a color filter. Quack function * ---------------------------------------------------------------------------------------------------------------------------- *******************************************************************************************************************************/ var reports = { activate: () => { }, reportsColor: () => { var b = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_REPORT); if (b.length == 0) return; var wnd = b[b.length - 1]; var c = wnd.getID(); $("DIV#gpwnd_" + c + " #report_list li").each(function () { $(this).css({ "border-left": "5px solid rgb(128, 64, 0)" }).addClass("farm"); }); // attaques $("DIV#gpwnd_" + c + " #report_list .color_highlight ").each(function () { $(this).css({ "border-left": "5px solid red" }).removeClass("farm").addClass("angriffe"); }); // troupes stationnées $("DIV#gpwnd_" + c + " #report_list li:contains('" + getTexts("reports", "supporting", true) + "')").each(function () { $(this).css({ "border-left": "5px solid green" }).removeClass("farm").addClass("unterstützungen"); }); // soutient $("DIV#gpwnd_" + c + " #report_list li:contains('" + getTexts("reports", "support", true) + "')").each(function () { $(this).css({ "border-left": "5px solid green" }).removeClass("farm").addClass("unterstützungen"); }); // ne peut pas soutenir $("DIV#gpwnd_" + c + " #report_list li:contains('" + uw.DM.getl10n("report", true).inbox.filter_types.support.toLowerCase() + "')").each(function () { $(this).css({ "border-left": "5px solid green" }).removeClass("farm").addClass("unterstützungen"); }); // Espion provenant $("DIV#gpwnd_" + c + " #report_list li:contains('" + getTexts("reports", "spy", true) + "')").each(function () { $(this).css({ "border-left": "5px solid blue" }).removeClass("farm").addClass("spios"); }); // espionne $("DIV#gpwnd_" + c + " #report_list li:contains('" + getTexts("reports", "spying", true) + "')").each(function () { $(this).css({ "border-left": "5px solid blue" }).removeClass("farm").addClass("spios"); }); // conquered $("DIV#gpwnd_" + c + " #report_list li:contains('" + getTexts("reports", "conquered", true) + "')").each(function () { $(this).css({ "border-left": "5px solid black" }).removeClass("farm"); }); // (lancé) $("DIV#gpwnd_" + c + " #report_list li:contains('" + getTexts("reports", "enacted", true) + "')").each(function () { $(this).css({ "border-left": "5px solid purple" }).removeClass("farm").addClass("zauber"); }); // (Vous avez reçu) gold $("DIV#gpwnd_" + c + " #report_list li:contains('" + getTexts("reports", "gold", true) + "')").each(function () { $(this).css({ "border-left": "5px solid rgba(123, 128, 0, 0.89)" }).addClass("farm"); }); //réservation (Votre réservation pour) $("DIV#gpwnd_" + c + " #report_list li:contains('" + getTexts("reports", "Reservations", true) + "')").each(function () { $(this).css({ "border-left": "5px solid yellow" }).addClass("farm"); }); //Alliance (parrainé) $("DIV#gpwnd_" + c + " #report_list li:contains('" + getTexts("reports", "parrainé", true) + "')").each(function () { $(this).css({ "border-left": "5px solid yellow" }).addClass("farm"); }); }, reportsFilter: () => { if (MID == 'fr' || MID == 'de' || MID == 'en' || MID == 'zz') { var b = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_REPORT); if (b.length != 0) { var wnd = b[b.length - 1]; var c = wnd.getID(); if (!$("#dio_menu_berichte_icon_wrapper").is(":visible")) { $('
    ').appendTo("DIV#gpwnd_" + c + " #es_page_reports"); $('').appendTo('#dio_menu_berichte_icon_wrapper'); $('').appendTo('#dio_menu_berichte_icon_wrapper'); $('').appendTo('#dio_menu_berichte_icon_wrapper'); $('').appendTo('#dio_menu_berichte_icon_wrapper'); $('').appendTo('#dio_menu_berichte_icon_wrapper'); $(".dio_menu_berichte_Icon").css({ 'display': 'inline-block', 'background-image': 'url(' + Home_url + '/img/dio/btn/reportsfilter.gif)', 'background-repeat': 'repeat scroll', 'width': '22px', 'height': '22px', 'position': 'relative', 'float': 'left', 'margin-left': '22px' }); $(".dio_menu_berichte_checkbox").css({ 'margin-top': '5px', 'margin-left': '31px' }); $(".dio_menu_berichte_checkbox").click(function () { var classid = this.id; var checkBoxes = $("li." + classid + " INPUT[type='checkbox']"); checkBoxes.attr("checked", !checkBoxes.attr("checked")); }); } var ReportTooltip = uw.DM.getl10n("report").inbox.filter_types; //tooltip $('#angriffe').tooltip(dio_icon + ReportTooltip.attacks); $('#unterstützungen').tooltip(dio_icon + ReportTooltip.support); $('#zauber').tooltip(dio_icon + ReportTooltip.divine_powers); $('#spios').tooltip(dio_icon + ReportTooltip.espionage); $('#farm').tooltip(dio_icon + ReportTooltip.misc); } } }, deactivate: () => { $('dio_menu_berichte_icon_wrapper').remove(); }, }; /******************************************************************************************************************************* * World Wonder * ---------------------------------------------------------------------------------------------------------------------------- * | ● worldWonderIcon * | ● WorldWonderIcons * | ● World Wonder Ranking - Change * | ● click adjustment * | ● Share calculation (= ratio of player points to alliance points) * | ● Resources calculation & counter (stores amount) * | ● Adds missing previous & next buttons on finished world wonders (better browsing through world wonders) * ---------------------------------------------------------------------------------------------------------------------------- *******************************************************************************************************************************/ function imageSelectionProtection() { $('').appendTo('head'); } var worldWonderIcon = { colossus_of_rhodes: "url(https://gp" + LID + ".innogamescdn.com/images/game/map/wonder_colossus_of_rhodes.png) 38px -1px;", great_pyramid_of_giza: "url(https://gp" + LID + ".innogamescdn.com/images/game/map/wonder_great_pyramid_of_giza.png) 34px -6px;", hanging_gardens_of_babylon: "url(https://gp" + LID + ".innogamescdn.com/images/game/map/wonder_hanging_gardens_of_babylon.png) 34px -5px;", lighthouse_of_alexandria: "url(https://gp" + LID + ".innogamescdn.com/images/game/map/wonder_lighthouse_of_alexandria.png) 37px -1px;", mausoleum_of_halicarnassus: "url(https://gp" + LID + ".innogamescdn.com/images/game/map/wonder_mausoleum_of_halicarnassus.png) 37px -4px;", statue_of_zeus_at_olympia: "url(https://gp" + LID + ".innogamescdn.com/images/game/map/wonder_statue_of_zeus_at_olympia.png) 36px -3px;", temple_of_artemis_at_ephesus: "url(https://gp" + LID + ".innogamescdn.com/images/game/map/wonder_temple_of_artemis_at_ephesus.png) 34px -5px;" }; var WorldWonderIcons = { activate: () => { try { if (!$('#dio_wondericons').get(0)) { var color = "orange"; // style for world wonder icons var style_str = "").appendTo('head'); // Context menu on mouseclick $('#minimap_islands_layer').on('click', '.m_island', function (e) { var ww_coords = this.id.split("i")[3].split("_"); uw.Layout.contextMenu(e, 'wonder', { ix: ww_coords[0], iy: ww_coords[1] }); }); } } catch (error) { errorHandling(error, "setWonderIconsOnMap"); } }, deactivate: () => { $('#dio_wondericons').remove(); } }; /******************************************************************************************************************************* * getPointRatio: Default *******************************************************************************************************************************/ if (uw.Game.features.end_game_type == "end_game_type_world_wonder") { function getPointRatioFromCache() { if (AID) { if ("object" != typeof uw.MM.DIO) { setTimeout(() => { getPointRatioFromCache(); }, 1E4); } else { try { var AP = uw.MM.DIO.cacheAlliances[uw.Game.alliance_id].Points; wonder.ratio[AID] = 100 / AP * uw.Game.player_points; saveValue(WID + "_wonder", JSON.stringify(wonder)); } catch (error) { errorHandling(error, "getPointRatioFromCache"); } } } else { wonder.ratio[AID] = -1; saveValue(WID + "_wonder", JSON.stringify(wonder)); } } function getPointRatioFromAllianceRanking() { try { if (AID && $('.current_player .r_points').get(0)) { wonder.ratio[AID] = 100 / parseInt($('.current_player .r_points').get(0).innerHTML, 10) * uw.Game.player_points; saveValue(WID + "_wonder", JSON.stringify(wonder)); } } catch (error) { errorHandling(error, "getPointRatioFromAllianceRaking"); } } function getPointRatioFromAllianceMembers() { try { var ally_points = 0; $('#ally_members_body tr').each(function () { ally_points += parseInt($(this).children().eq(2).text(), 10) || 0; }); wonder.ratio[AID] = 100 / ally_points * uw.Game.player_points; saveValue(WID + "_wonder", JSON.stringify(wonder)); } catch (error) { errorHandling(error, "getPointRatioFromAllianceMembers"); } } var WorldWonderCalculator = { activate: () => { // Style $('').appendTo('head'); }, deactivate: () => { $('#dio_wonder_calculator').remove(); }, }; // TODO: Split function... function getResWW() { try { var wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_WONDERS); for (var e in wndArray) { if (wndArray.hasOwnProperty(e)) { var wndID = "#gpwnd_" + wndArray[e].getID() + " "; if ($(wndID + '.wonder_progress').get(0)) { var res = 0, ww_share = { total: { share: 0, sum: 0 }, stage: { share: 0, sum: 0 } }, ww_type = $(wndID + '.finished_image_small').attr('src').split("/")[6].split("_")[0], // Which world wonder? res_stages = [2, 4, 6, 10, 16, 28, 48, 82, 140, 238], // Rohstoffmenge pro Rohstofftyp in 100.000 Einheiten stage = parseInt($(wndID + '.wonder_expansion_stage span').get(0).innerHTML.split("/")[0], 10) + 1, // Derzeitige Füllstufe speed = uw.Game.game_speed; wonder.storage[AID] = wonder.storage[AID] || {}; wonder.storage[AID][ww_type] = wonder.storage[AID][ww_type] || {}; wonder.storage[AID][ww_type][stage] = wonder.storage[AID][ww_type][stage] || 0; if (!$(wndID + '.ww_ratio').get(0)) { $('
    ').appendTo(wndID + '.wonder_res_container .trade'); $(wndID + '.wonder_header').prependTo(wndID + '.wonder_progress'); $(wndID + '.wonder_res_container .send_res').insertBefore(wndID + '.wonder_res_container .next_level_res'); } for (var d in res_stages) { if (res_stages.hasOwnProperty(d)) { ww_share.total.sum += res_stages[d]; } } ww_share.total.sum *= speed * 300000; ww_share.total.share = parseInt(wonder.ratio[AID] * (ww_share.total.sum / 100), 10); ww_share.stage.sum = speed * res_stages[stage - 1] * 300000; ww_share.stage.share = parseInt(wonder.ratio[AID] * (ww_share.stage.sum / 100), 10); // ( 3000 = 3 Rohstofftypen * 100000 Rohstoffe / 100 Prozent) setResWW(stage, ww_type, ww_share, wndID); $(wndID + '.wonder_res_container .send_resources_btn').click(() => { try { wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_wood input:text').get(0).value, 10); wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_stone input:text').get(0).value, 10); wonder.storage[AID][ww_type][stage] += parseInt($(wndID + '#ww_trade_type_iron input:text').get(0).value, 10); setResWW(stage, ww_type, ww_share, wndID); saveValue(WID + "_wonder", JSON.stringify(wonder)); } catch (error) { errorHandling(error, "getResWW_Click"); } }); } else { $('
    ').appendTo(wndID + '.wonder_controls'); $(wndID + '.wonder_finished').css({ width: '100%' }); $(wndID + '.pos_Y').css({ top: '-266px' }); } } } } catch (error) { errorHandling(error, "getResWW"); } } function setResWW(stage, ww_type, ww_share, wndID) { try { var stage_width, total_width, res_total = 0, stage_color = "red", total_color = "red"; for (var z in wonder.storage[AID][ww_type]) { if (wonder.storage[AID][ww_type].hasOwnProperty(z)) { res_total += wonder.storage[AID][ww_type][z]; } } // Progressbar if (ww_share.stage.share > wonder.storage[AID][ww_type][stage]) { stage_width = (242 / ww_share.stage.share) * wonder.storage[AID][ww_type][stage]; stage_color = "red"; } else { stage_width = 242; stage_color = "green" } if (ww_share.total.share > res_total) { total_color = "red"; total_width = (242 / ww_share.total.share) * res_total; } else { total_width = 242; total_color = "green" } $(wndID + '.ww_ratio').get(0).innerHTML = ""; $(wndID + '.ww_ratio').append( '' + getTexts("labels", "leg") + ' (' + (Math.round(wonder.ratio[AID] * 100) / 100) + '%):' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '' + Math.round(wonder.storage[AID][ww_type][stage] / ww_share.stage.share * 100) + '%' + '
    ' + '
    ' + getTexts("labels", "stg") + ': ' + pointNumber(wonder.storage[AID][ww_type][stage]) + ' / ' + '' + pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '' + Math.round(res_total / ww_share.total.share * 100) + '%' + '
    ' + '
    ' + getTexts("labels", "tot") + ': ' + pointNumber(res_total) + ' / ' + '' + pointNumber((Math.round(ww_share.total.share / 1000) * 1000)) + '
    ' + '
    '); $(wndID + '.ww_ratio').tooltip( "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "
    (" + (Math.round((wonder.ratio[AID]) * 100) / 100) + "%)(100%)
    " + getTexts("labels", "stg") + " " + stage + "" + pointNumber(Math.round(ww_share.stage.share / 1000) * 1000) + "" + pointNumber(Math.round(ww_share.stage.sum / 1000) * 1000) + "
    " + getTexts("labels", "tot") + "" + pointNumber(Math.round(ww_share.total.share / 1000) * 1000) + "" + pointNumber(Math.round(ww_share.total.sum / 1000) * 1000) + "
    "); } catch (error) { errorHandling(error, "setResWW"); } } } /******************************************************************************************************************************* * Farming Village Overview * ---------------------------------------------------------------------------------------------------------------------------- * | ● Color change on possibility of city festivals * | ● farmingvillageshelper : Automatically hide the city. Quack function * ---------------------------------------------------------------------------------------------------------------------------- * *****************************************************************************************************************************/ /******************************************************************************************************************************* * Color change on possibility of city festivals *******************************************************************************************************************************/ function changeResColor() { var res, res_min, i = 0; $('#fto_town_list .fto_resource_count :last-child').reverseList().each(function () { if ($(this).parent().hasClass("stone")) res_min = 18000; else res_min = 15000; res = parseInt(this.innerHTML, 10); if ((res >= res_min) && !($(this).hasClass("town_storage_full"))) this.style.color = '#0A0'; if (res < res_min) this.style.color = '#000'; }); } /******************************************************************************************************************************* * ● farming villages helper *******************************************************************************************************************************/ var farmingvillageshelper = { activate: () => { }, rememberloot: () => { var activeFarmClass = $('#time_options_wrapper .active').attr('class').split(' '); var activeFarm = activeFarmClass[1]; }, setloot: () => { setTimeout(() => { $('#time_options_wrapper .' + activeFarm).click(); /*global activeFarm*/ }, 500); }, islandHeader: () => { $('#fto_town_list li').each(function (index) { if (this.classList.length == 2) { $(this).addClass("dio_li_island"); $(this).append( '
    ' + '' ); $(this).find("span").css({ "margin-left": "2px" }); $(this).find("a").css({ "color": "rgb(238, 221, 187)" }); } }); $('.dio_colordivider').click(function () { var el = $(this).parent().nextUntil(".dio_li_island"); if ($('#fto_town_list li:first[style*="border-right"]').length == 0) { el.slideToggle(); } else { el.toggleClass("hidden"); } }); $('').appendTo('head'); }, indicateLoot: () => { var activeIsland = $('#fto_town_list li.active').prevAll(".dio_li_island").first(); activeIsland.find("div.checkbox_new").removeClass("disabled"); activeIsland.find("div.dio_colordivider").trigger("click"); }, switchTown: (direction) => { var el; if (direction === "up") { el = $('#fto_town_list li.active').prevAll("li:not(.dio_li_island):visible").first(); } else { el = $('#fto_town_list li.active').nextAll("li:not(.dio_li_island):visible").first(); } el.click(); if (el.get(0)) { el.get(0).scrollIntoView(); var scrollPosition = el.get(0).parentNode.scrollTop; var scrollMax = scrollPosition += 405; var scrollContainer = el.get(0).parentNode.scrollHeight; if (scrollMax != scrollContainer) { el.get(0).parentNode.scrollTop -= 160; } } }, deactivate: () => { $("#dio_toggleAutohide").addClass('dio_autoHideCitiesOff'); }, }; /******************************************************************************************************************************** * Conquest Info * ----------------------------------------------------------------------------------------------------------------------------- * | ● Amount of supports und attacks in the conquest window * | ● Layout adjustment (for reasons of clarity) * | - TODO: conquest window of own cities * ----------------------------------------------------------------------------------------------------------------------------- * ******************************************************************************************************************************/ function countMovements() { var sup = 0, att = 0; $('.tab_content #unit_movements .support').each(function () { sup++; }); $('.tab_content #unit_movements .attack_land, .tab_content #unit_movements .attack_sea, .tab_content #unit_movements .attack_takeover').each(function () { att++; }); var str = "
    " + "
    " + "
    " + sup + "
    " + "
    " + "
    " + att + "
    " + "
    "; if ($('.gpwindow_content .tab_content .bold').get(0)) { $('.gpwindow_content .tab_content .bold').append(str); } else { $('.gpwindow_content h4:eq(1)').append(str); } $('').appendTo("head"); } /******************************************************************************************************************************* * Town window * ---------------------------------------------------------------------------------------------------------------------------- * | ● TownTabHandler (trade, attack, support,...) * | ● Sent units box * | ● Short duration: Display of 30% troop speed improvement in attack/support tab * | ● Trade options: * | - Ressource marks on possibility of city festivals * | - Percentual Trade: Trade button * | - Recruiting Trade: Selection boxes (ressource ratio of unit type + share of the warehouse capacity of the target town) * | ● Town Trade Improvement : Click on it and it is only exchanged towards a festival. Quack function * ---------------------------------------------------------------------------------------------------------------------------- *******************************************************************************************************************************/ var arrival_interval = {}; var hades_interval = {}; // TODO: Change both functions in MultipleWindowHandler() function TownTabHandler(action) { try { var wndArray, wndID, wndA, wnd; wndArray = uw.Layout.wnd.getOpen(uw.Layout.wnd.TYPE_TOWN); for (var e in wndArray) { if (wndArray.hasOwnProperty(e)) { wndID = "#gpwnd_" + wndArray[e].getID() + " "; wnd = wndArray[e].getID(); if (!$(wndID).get(0)) { wndID = "#gpwnd_" + (wndArray[e].getID() + 1) + " "; wnd = wndArray[e].getID() + 1; } switch (action) { case "trading": if ($(wndID + '#trade_tab').get(0)) { if (!$(wndID + '.dio_rec_trade').get(0) && DATA.options.dio_rec) { RecruitingTrade.add(wndID); } if (!$(wndID + '.dio_btn_trade').get(0) && DATA.options.dio_per) { addPercentTrade(wndID, false); } if (!$(wndID + '.dio_send_cult').get(0) && $(wndID + '.town-capacity-indicator').get(0) && DATA.options.dio_Tti) { townTradeImprovement.add(wndID, wnd); } } break; case "info": if (DATA.options.dio_BBt) BBtowninfo.towninfo(wnd); if (DATA.options.dio_BBt) BBtowninfo.add(action); if (DATA.options.dio_Idl) idle.add(action); break; case "support": case "attack": if (DATA.options.dio_way && !($('.js-casted-powers-viewport .unit_movement_boost').get(0) || $(wndID + '.short_duration').get(0))) { ShortDuration.add(wndID, action); } else $("#dio_short_duration_stylee").remove(); if (DATA.options.dio_sen) SentUnits.add(wndID, action); break; case "rec_mark": break; } } } } catch (error) { errorHandling(error, "TownTabHandler"); } } function WWTradeHandler() { var wndArray, wndID, wndA; wndArray = uw.GPWindowMgr.getOpen(uw.GPWindowMgr.TYPE_WONDERS); for (var e in wndArray) { if (wndArray.hasOwnProperty(e)) { wndID = "#gpwnd_" + wndArray[e].getID() + " "; if (DATA.options.dio_per && !($(wndID + '.dio_btn_trade').get(0) || $(wndID + '.next_building_phase').get(0) || $(wndID + '#ww_time_progressbar').get(0))) { addPercentTrade(wndID, true); } } } } /******************************************************************************************************************************* * ● Sent units box *******************************************************************************************************************************/ var SentUnits = { activate: () => { $('').appendTo("head"); $.Observer(uw.GameEvents.command.send_unit).subscribe('DIO_SEND_UNITS', function (e, data) { if (DATA.options.dio_sen) { // We handle revolt in the same pool as a regular attack & portal olympus if (data.sending_type === "revolt" || data.sending_type === "portal_attack_olympus") data.sending_type = "attack"; if (data.sending_type === "portal_support_olympus") data.sending_type = "support"; for (var z in data.params) { if (data.params.hasOwnProperty(z) && (data.sending_type !== "")) { if (uw.GameData.units[z]) { sentUnitsArray[data.sending_type][z] = (sentUnitsArray[data.sending_type][z] == undefined ? 0 : sentUnitsArray[data.sending_type][z]); sentUnitsArray[data.sending_type][z] += data.params[z]; } } } SentUnits.update(data.sending_type); } }); }, deactivate: () => { $.Observer(uw.GameEvents.command.send_unit).unsubscribe('DIO_SEND_UNITS'); $('#dio_table_box').remove(); $('#dio_SentUnits_style').remove(); $('#dio_SentUnits_modif_style').remove(); $('#dio_SentUnits_breach_style').remove(); }, add: (wndID, action) => { $('').appendTo(wndID + ' .attack_support_window'); if ((uw.ITowns.getTown(uw.Game.townId).researches().attributes.breach == true || uw.ITowns.getTown(uw.Game.townId).researches().attributes.stone_storm == true) & DATA.options.dio_sen) { $('').appendTo(wndID + ' .attack_support_window'); } else { $('').appendTo(wndID + ' .attack_support_window'); }; if (!$(wndID + '.sent_units_box').get(0)) { $('
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + getTexts("labels", "lab") + ' (' + (action == "attack" ? "OFF" : "DEF") + ')' + '
    ' + '

    ' + '
    ' + '
    ' + '
    ' + '
    ' + getTexts("buttons", "res") + '
    ' + '
    ' + '
    ').appendTo(wndID + ' .attack_support_window'); SentUnits.update(action); $(wndID + ' #btn_sent_units_reset').click(() => { // Overwrite old array sentUnitsArray[action] = {}; SentUnits.update(action); }); } }, update: (action) => { try { // Remove old unit list $('.sent_units_box.' + action + ' .units_list').each(function () { this.innerHTML = ""; }); function appendUnitIcon(unit, count) { $('.sent_units_box.' + action + ' .units_list').each(function () { $(this).append('
    ' + '' + count + '' + '
    '); }); } // Add new unit list for (var x in sentUnitsArray[action]) { if (sentUnitsArray[action].hasOwnProperty(x)) { if ((sentUnitsArray[action][x] || 0) > 0) { appendUnitIcon(x, sentUnitsArray[action][x]); } } } saveValue(WID + "_sentUnits", JSON.stringify(sentUnitsArray)); } catch (error) { errorHandling(error, "updateSentUnitsBox"); } } }; /******************************************************************************************************************************* * ● Short duration *******************************************************************************************************************************/ var ShortDuration = { activate: () => { $('').appendTo('head'); }, deactivate: () => { $("#dio_short_duration_style").remove(); $("#dio_short_duration_stylee").remove(); $("#dio_duration").remove(); }, add: (wndID, action) => { try { $('').appendTo(wndID + '.attack_support_window'); $('' + '' + '' + '' + '' + '' + (action == "attack" ? '' + '' + '' + '' : "") + '
     ╚> ~0:00:00   ╚>~00:00:00
     ╚> ~0:00:00   ╚>~00:00:00
    ').prependTo(wndID + ".duration_container"); //} $(wndID + ".nightbonus").appendTo(wndID + ".dio_night"); $(wndID + '.way_duration').appendTo(wndID + ".dio_way"); $(wndID + ".arrival_time").appendTo(wndID + ".dio_arrival"); // Tooltip $(wndID + ' .short_duration_row .short_icon').tooltip(dio.getTooltip("unit_movement_boost") + '
    '); $(wndID + ' .hades_duration_row .cap_of_invisibility').tooltip(dio.getTooltip("cap_of_invisibility") + '
    '); // Detection of changes ShortDuration.change(wndID, action); ShortDuration.calculate(wndID, action); } catch (error) { errorHandling(error, "addShortDuration"); } }, change: (wndID, action) => { var duration = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { if (mutation.addedNodes[0]) ShortDuration.calculate(wndID, action); }); }); if ($(wndID + '.way_duration').get(0)) { duration.observe($(wndID + '.way_duration').get(0), { attributes: false, childList: true, characterData: false }); } }, calculate: (wndID, action) => { try { var setup_time = 900 / uw.Game.game_speed, duration_time = $(wndID + '.duration_container .way_duration').get(0).innerHTML.replace("~", "").split(":"), // TODO: hier tritt manchmal Fehler auf TypeError: Cannot read property "innerHTML" of undefined at calcShortDuration (:3073:86) duration_time_short, duration_time_hades, arrival_time_short, arrival_time_hades, h, m, s, atalanta_factor = 0; //console.log(setup_time) var hasCartography = uw.ITowns.getTown(uw.Game.townId).getResearches().get("cartography"); var hasMeteorology = uw.ITowns.getTown(uw.Game.townId).getResearches().get("meteorology"); var hasSetSail = uw.ITowns.getTown(uw.Game.townId).getResearches().get("set_sail"); var hasLighthouse = uw.ITowns.getTown(uw.Game.townId).buildings().get("lighthouse"); // Atalanta aktiviert? if ($(wndID + '.unit_container.heroes_pickup .atalanta').get(0)) { if ($(wndID + '.cbx_include_hero').hasClass("checked")) { // Beschleunigung hängt vom Level ab, Level 1 = 11%, Level 20 = 30% var atalanta_level = uw.MM.getCollections().PlayerHero[0].models[1].get("level"); atalanta_factor = (atalanta_level + 10) / 100; } } // Sekunden, Minuten und Stunden zusammenrechnen (-> in Sekunden) duration_time = ((parseInt(duration_time[0], 10) * 60 + parseInt(duration_time[1], 10)) * 60 + parseInt(duration_time[2], 10)); // Verkürzte Laufzeit berechnen duration_time_short = ((duration_time - setup_time) * (1 + atalanta_factor)) / (1 + 0.3 + atalanta_factor) + setup_time; duration_time_hades = (duration_time) / 10; h = Math.floor(duration_time_short / 3600); m = Math.floor((duration_time_short - h * 3600) / 60); s = Math.floor(duration_time_short - h * 3600 - m * 60); if (h < 10) { h = "0" + h; } if (m < 10) { m = "0" + m; } if (s < 10) { s = "0" + s; } $(wndID + '.short_duration').get(0).innerHTML = "~" + h + ":" + m + ":" + s; // Ankunftszeit errechnen arrival_time_short = Math.round((Timestamp.server() + uw.Game.server_gmt_offset)) + duration_time_short; h = Math.floor(arrival_time_short / 3600); m = Math.floor((arrival_time_short - h * 3600) / 60); s = Math.floor(arrival_time_short - h * 3600 - m * 60); h %= 24; if (h < 10) { h = "0" + h; } if (m < 10) { m = "0" + m; } if (s < 10) { s = "0" + s; } $(wndID + '.short_arrival').get(0).innerHTML = "~" + h + ":" + m + ":" + s; clearInterval(arrival_interval[wndID]); arrival_interval[wndID] = setInterval(function () { arrival_time_short += 1; h = Math.floor(arrival_time_short / 3600); m = Math.floor((arrival_time_short - h * 3600) / 60); s = Math.floor(arrival_time_short - h * 3600 - m * 60); h %= 24; if (h < 10) { h = "0" + h; } if (m < 10) { m = "0" + m; } if (s < 10) { s = "0" + s; } if ($(wndID + '.short_arrival').get(0)) { $(wndID + '.short_arrival').get(0).innerHTML = "~" + h + ":" + m + ":" + s; } else { clearInterval(arrival_interval[wndID]); } }, 1000); if (action == "attack") { h = Math.floor(duration_time_hades / 3600); m = Math.floor((duration_time_hades - h * 3600) / 60); s = Math.floor(duration_time_hades - h * 3600 - m * 60); if (h < 10) { h = "0" + h; } if (m < 10) { m = "0" + m; } if (s < 10) { s = "0" + s; } $(wndID + '.hades_duration').get(0).innerHTML = "~" + h + ":" + m + ":" + s; // Ankunftszeit errechnen arrival_time_hades = Math.round((Timestamp.server() + uw.Game.server_gmt_offset)) + duration_time_hades; h = Math.floor(arrival_time_hades / 3600); m = Math.floor((arrival_time_hades - h * 3600) / 60); s = Math.floor(arrival_time_hades - h * 3600 - m * 60); h %= 24; if (h < 10) { h = "0" + h; } if (m < 10) { m = "0" + m; } if (s < 10) { s = "0" + s; } $(wndID + '.hades_visibility').get(0).innerHTML = "~" + h + ":" + m + ":" + s; clearInterval(hades_interval[wndID]); hades_interval[wndID] = setInterval(function () { arrival_time_hades += 1; h = Math.floor(arrival_time_hades / 3600); m = Math.floor((arrival_time_hades - h * 3600) / 60); s = Math.floor(arrival_time_hades - h * 3600 - m * 60); h %= 24; if (h < 10) { h = "0" + h; } if (m < 10) { m = "0" + m; } if (s < 10) { s = "0" + s; } if ($(wndID + '.hades_visibility').get(0)) { $(wndID + '.hades_visibility').get(0).innerHTML = "~" + h + ":" + m + ":" + s; } else { clearInterval(hades_interval[wndID]); } }, 1000); } } catch (error) { errorHandling(error, "ShortDuration.calculate"); } } }; /******************************************************************************************************************************* * ● Dropdown menu *******************************************************************************************************************************/ // TODO: Umstellen! // Preload images for drop down arrow buttons var drop_over = new Image(); drop_over.src = Home_url + "/img/dio/btn/drop-over.png"; var drop_out = new Image(); drop_out.src = Home_url + "/img/dio/btn/drop-out.png"; function changeDropDownButton() { $('').appendTo('head'); } /******************************************************************************************************************************* * ● Recruiting Trade * *****************************************************************************************************************************/ try { var trade_count = 0, unit = "FS", unit2 = "", percent = "0.0"; // Recruiting Trade if (typeof (uw.GameData.units.attack_ship) == "undefined") { unit2 = "Attack ship"; setTimeout(() => { unit2 = uw.GameData.units.attack_ship.name }, 200); } else unit2 = uw.GameData.units.attack_ship.name; } catch (error) { errorHandling(error, "RecruitingTrade 1"); } // TODO: Funktion umformen, Style anpassen! var RecruitingTrade = { activate: () => { $('').appendTo('head'); }, deactivate: () => { $('#dio_style_recruiting_trade').remove(); $('#dio_recruiting_trade').remove(); }, add: (wndID) => { try { var max_amount, percent_input; $(wndID + "#duration_container").before('
    ' + dio.spinner("", "dio_drop_rec_perc spinner_horizontal", "0", "text") + // DropDown-Button for unit '(' + trade_count + ')
    '); //(' + trade_count + ')
    let options = [], ratio = {} let units_html = ''; $(units_html).appendTo(wndID + ".dio_rec_trade") ratio.CitywallLv5 = { w: 0.2286, s: 1, i: 0.6714, name: uw.GameData.buildings.wall.name + " Lv 5" }; // City wall Lv 5 ratio.CitywallLv15 = { w: 0.0762, s: 1, i: 0.7491, name: uw.GameData.buildings.wall.name + " Lv 15" }; // City wall Lv 15 ratio.hideLv5 = RecruitingTrade.resources(false, 1621, 2000, 2980, uw.DM.getl10n("hide").index.hide + " Lv 5"); // City hide Lv 5 ratio.hideLv10 = RecruitingTrade.resources(false, 3991, 4000, 5560, uw.DM.getl10n("hide").index.hide + " Lv 10"); // City hide Lv 10 ratio.festival = { w: 0.8333, s: 1, i: 0.8333, name: getTexts("Quack", "cityfestivals") }; // City festival $(wndID + ".dio_rec_trade [name='" + unit + "']").toggleClass("sel"); // cliquez sur les événements du menu déroulant $(wndID + ' .select_rec_unit .option_s').each(function () { $(this).click(function (e) { $(wndID + ".select_rec_unit .sel").toggleClass("sel"); $(wndID + "." + this.className.split(" ")[4]).toggleClass("sel"); unit = $(this).attr("name"); unit2 = ratio[unit].name; $(wndID + '.dio_drop_rec_unit .caption').attr("name", unit); $(wndID + '.dio_drop_rec_unit .caption').each(function () { this.innerHTML = unit2; }); $($(this).parent().parent().get(0)).removeClass("open"); $(wndID + '.dio_drop_rec_unit .caption').change(); }); }); $(wndID + ' .select_rec_perc .option').each(function () { $(this).click(function (e) { $(this).parent().find(".sel").toggleClass("sel"); $(this).toggleClass("sel"); percent = $(this).attr("name"); $(wndID + '.dio_drop_rec_perc .caption').attr("name", percent); $(wndID + '.dio_drop_rec_perc .caption').each(function () { this.innerHTML = Math.round(percent * 100) + "%"; }); $($(this).parent().parent().get(0)).removeClass("open") $(wndID + '.dio_drop_rec_perc .caption').change(); }); }); // show & hide drop menus on click //$(wndID + '.dio_drop_rec_perc').click(function (e) { dio.drop_menus_open(wndID + '.select_rec_perc', wndID + '.select_rec_unit') }); $(wndID + '.dio_drop_rec_unit').click(function (e) { dio.drop_menus_open(wndID + '.select_rec_unit', wndID + '.select_rec_perc') }); $(wndID).click(function (e) { var clicked = $(e.target), element = $('#' + this.id + ' .dropdown-list.open').get(0); if ((clicked[0].parentNode.className.split(" ")[1] !== "dropdown") && element) { $(element).removeClass("open"); } }); $(wndID + " .dio_drop_rec_perc").spinnerHorizontal({ value: percent * 100, step: 10, max: 100, min: 0, }); // hover arrow change $(wndID + '.dropdown').hover(function (e) { $(e.target)[0].parentNode.childNodes[3].style.background = "url('" + drop_over.src + "') no-repeat -1px -1px"; }, function (e) { $(e.target)[0].parentNode.childNodes[3].style.background = "url('" + drop_out.src + "') no-repeat -1px -1px"; }); $(wndID + ".dio_drop_rec_unit .caption").attr("name", unit); $(wndID + ".dio_drop_rec_perc .caption").attr("name", percent); $(wndID + '.dio_drop_rec_unit').tooltip(dio_icon + getTexts("labels", "rat")); $(wndID + '.dio_drop_rec_perc').tooltip(dio_icon + getTexts("labels", "shr")); if ($(wndID + '#town_capacity_wood .max').get(0)) { max_amount = parseInt($(wndID + '#town_capacity_wood .max').get(0).innerHTML, 10); } else { max_amount = 25500; } $(wndID + ".dio_drop_rec_perc").on("click", function () { test(this) }); $(wndID + '.caption, ' + wndID + '.dio_drop_rec_perc').on("change", function (e) { test(this) }); test($(wndID + ".dio_drop_rec_perc")); function test(This) { //if (!(($(This).attr('name') === unit) || ($(This).attr('name') === percent))) { $(wndID + '.dio_rec_count').get(0).innerHTML = "(" + trade_count + ")"; } percent_input = $(This).parent().parent().find(".dio_drop_rec_perc input") if (!percent_input.is(":visible")) return unit = $(This).parent().parent().parent().find(".dio_drop_rec_unit .caption").attr('name'); percent = percent_input.val() / 100 var max = (max_amount - 100) / 1000; //console.log(88, wndID, max * ratio[unit].w) addTradeMarks(max * ratio[unit].w, max * ratio[unit].s, max * ratio[unit].i, "lime", wndID); 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) var rArray = uw.ITowns.getTown(uw.Game.townId).getCurrentResources(); var tradeCapacity = uw.ITowns.getTown(uw.Game.townId).getAvailableTradeCapacity(); var wood = ratio[unit].w * part; var stone = ratio[unit].s * part; var iron = ratio[unit].i * part; // added by maro // wenn der 'tmp' == 1 dann wurde 100% ausgewählt //if(tmp == 1) { //alert('100% wurde ausgewählt'); var tmpgratio = ratio[unit].w + ratio[unit].s + ratio[unit].i wood = tradeCapacity / tmpgratio * ratio[unit].w; stone = tradeCapacity / tmpgratio * ratio[unit].s; iron = tradeCapacity / tmpgratio * ratio[unit].i; /*alert('folgende Daten sind vorhanden \n' + 'transportkapacität: ' + tradeCapacity + '\n' + 'name: ' + tmp + '\n' + 'ratio Holz ??: ' + ratio[unit].w + '\n' + 'ratio Stein: ' + ratio[unit].s + '\n' + 'ratio Silber: ' + ratio[unit].i + '\n' + 'rArray (Holz?): ' + rArray.wood);*/ //added by vookus - traded immer prozentual zur gewünschten einheit auch wenn nicht genügen resi für ein volles lager vorhanden sind function addTEST(a, b, c) { let A, B, C, tmps = percent * 100; A = rArray[a] * percent; B = A / (ratio[unit][a.substring(0, 1)] * tmps) * tmps * ratio[unit][b.substring(0, 1)]; C = A / (ratio[unit][a.substring(0, 1)] * tmps) * tmps * ratio[unit][c.substring(0, 1)]; if (A > getRess(a) || B > getRess(b) || C > getRess(c)) { percent_input.css({ color: '#610fe5' }); //A = B = C = 0 } $(wndID + "#trade_type_" + a + " [type='text']").select().val(A).blur(); $(wndID + "#trade_type_" + b + " [type='text']").select().val(B).blur(); $(wndID + "#trade_type_" + c + " [type='text']").select().val(C).blur(); } function getRess(res_type) { if (!$(wndID + "#town_capacity_" + res_type).get(0)) return var res = {}; res.selector = $(wndID + "#town_capacity_" + res_type); res.amounts = { curr: parseInt(res.selector.find(".curr").html()) || 0, curr2: parseInt(res.selector.find(".curr2").html().substring(3)) || 0, curr3: parseInt(res.selector.find(".curr3").html().substring(3)) || 0, max: parseInt(res.selector.find(".max").html()) || 0 } res.needed = res.amounts.max - res.amounts.curr - res.amounts.curr2; return res.needed; } percent_input.css({ color: '#000' }); if ((wood > rArray.wood) && (stone < rArray.stone) && (iron < rArray.iron)) { addTEST("wood", "stone", "iron") } else if ((wood < rArray.wood) && (stone > rArray.stone) && (iron < rArray.iron)) { addTEST("stone", "wood", "iron") } else if ((wood < rArray.wood) && (stone < rArray.stone) && (iron > rArray.iron)) { addTEST("iron", "stone", "wood") } else if ((wood > rArray.wood) && (stone < rArray.stone) && (iron > rArray.iron) && ((rArray.wood) * ratio[unit].w) < ((rArray.iron) * ratio[unit].i)) { addTEST("wood", "stone", "iron") } else if ((wood > rArray.wood) && (stone < rArray.stone) && (iron > rArray.iron) && ((rArray.wood) * ratio[unit].w) > ((rArray.iron) * ratio[unit].i)) { addTEST("iron", "stone", "wood") } else if ((wood < rArray.wood) && (stone > rArray.stone) && (iron > rArray.iron) && ((rArray.iron) * ratio[unit].i) < ((rArray.stone) * ratio[unit].s)) { addTEST("iron", "stone", "wood") } else if ((wood < rArray.wood) && (stone > rArray.stone) && (iron > rArray.iron) && ((rArray.iron) * ratio[unit].i) > ((rArray.stone) * ratio[unit].s)) { addTEST("stone", "wood", "iron") } else if ((wood > rArray.wood) && (stone > rArray.stone) && (iron < rArray.iron) && ((rArray.wood) * ratio[unit].w) > ((rArray.stone) * ratio[unit].s)) { addTEST("stone", "wood", "iron") } else if ((wood > rArray.wood) && (stone > rArray.stone) && (iron < rArray.iron) && ((rArray.wood) * ratio[unit].w) < ((rArray.stone) * ratio[unit].s)) { addTEST("wood", "stone", "iron") } else if ((wood > rArray.wood) && (stone > rArray.stone) && (iron > rArray.iron)) { wood = stone = iron = 0; percent_input.css({ color: '#f00' }); } else if ((wood < rArray.wood) && (stone < rArray.stone) && (iron < rArray.iron)) { if (wood * percent > getRess("wood") || stone * percent > getRess("stone") || iron * percent > getRess("iron")) { percent_input.css({ color: '#610fe5' }); //wood = stone = iron = 0; } $(wndID + "#trade_type_wood [type='text']").select().val(wood * percent).blur(); $(wndID + "#trade_type_stone [type='text']").select().val(stone * percent).blur(); $(wndID + "#trade_type_iron [type='text']").select().val(iron * percent).blur(); } else { percent_input.css({ color: '#000' }); wood = stone = iron = 0; $(wndID + "#trade_type_wood [type='text']").select().val(wood).blur(); $(wndID + "#trade_type_stone [type='text']").select().val(stone).blur(); $(wndID + "#trade_type_iron [type='text']").select().val(iron).blur(); } } $(wndID + '#trade_button').click(() => { trade_count++; $(wndID + '.dio_rec_count').get(0).innerHTML = "(" + trade_count + ")"; }); $(wndID + '.dio_drop_rec_perc .caption').change(); // Tooltip $.each(options, function (i, o) { $('.option_s.unit.index_unit.unit_icon40x40.' + o).tooltip(uw.GameData.units[o].name) }) //Other $('#diowall').tooltip(uw.GameData.buildings.wall.name + " Lv 5"); $('#diowall2').tooltip(uw.GameData.buildings.wall.name + " Lv 15"); $('#diohide').tooltip(uw.DM.getl10n("hide").index.hide + " Lv 5"); $('#diohide2').tooltip(uw.DM.getl10n("hide").index.hide + " Lv 10"); $('#diofestivals').tooltip(getTexts("Quack", "cityfestivals")); } catch (error) { errorHandling(error, "RecruitingTrade"); } }, resources: (res, W, S, I, name) => { let w, s, i, a; if (res) { a = uw.GameData.units[res].resources; w = a.wood; s = a.stone; i = a.iron; a = Math.max(w, s, i); name = uw.GameData.units[res].name; } else { w = W; s = S; i = I; a = w + s + i; } w = w / a; s = s / a; i = i / a; return ({ w: w, s: s, i: i, name: name }); }, }; /******************************************************************************************************************************* * ● Ressources marks *******************************************************************************************************************************/ function addTradeMarks(woodmark, stonemark, ironmark, color) { var max_amount, limit, wndArray = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_TOWN), wndID; for (var e in wndArray) { if (wndArray.hasOwnProperty(e)) { wndID = "#gpwnd_" + wndArray[e].getID() + " "; if ($(wndID + '.town-capacity-indicator').get(0)) { max_amount = $(wndID + '.amounts .max').get(0).innerHTML; $('#trade_tab .c_' + color).each(function () { this.remove(); }); var progressBarList = $('#trade_tab .progress'); for (var i = 0; i < progressBarList.length; i++) { var progressBar = progressBarList[i]; if ($("p", progressBar).length < 3) { if ($(progressBar).parent().get(0).id != "big_progressbar") { limit = 1000 * (242 / parseInt(max_amount, 10)); switch ($(progressBar).parent().get(0).id.split("_")[2]) { case "wood": limit = limit * woodmark; break; case "stone": limit = limit * stonemark; break; case "iron": limit = limit * ironmark; break; } $('

    ').appendTo(progressBar); } } } } } } } /******************************************************************************************************************************* * ● Percentual Trade *******************************************************************************************************************************/ var rest_count = 0; function addPercentTrade(wndID, ww) { var a, b = ""; var content = wndID + ".content .btn_trade_button.button_new"; if (ww) { a = "ww_"; b = "_ww"; content = wndID + '.trade .send_res .button.send_resources_btn'; } $(content).after('
    ' + '' + '' + '' + '' + '
    '); $(wndID + '.dio_btn_trade').tooltip(dio_icon + getTexts("labels", "per")); setPercentTrade(wndID, ww); // Style $('div.wonder_res_container fieldset.send_res .button').css({ "margin-top": "0px" }); $('#trade_tab #duration_container').css({ "margin-bottom": "-15px" }); $(wndID + '.dio_btn_trade').css({ "position": "relative", "top": "13px", "display": "inline", "margin-left": "10px" }); $(wndID + '.mid').css({ minWidth: '26px' }); $(wndID + '.img_trade').css({ width: '27px', height: '27px', top: '-3px', float: 'left', position: 'relative', background: 'url("' + Home_url + '/img/dio/btn/echange.png") no-repeat' }); } var res = {}; function setPercentTrade(wndID, ww) { try { var a = ww ? "ww_" : "", own_town = $(wndID + '.town_info').get(0) ? true : false; $(wndID + '.dio_btn_trade').toggleClick(function () { res.wood = {}; res.stone = {}; res.iron = {}; res.sum = {}; res.sum.amount = 0; // Set amount of resources to 0 setAmount(true, a, wndID); // Total amount of resources // TODO: ITowns.getTown(Game.townId).getCurrentResources(); ? for (var e in res) { if (res.hasOwnProperty(e) && e != "sum") { res[e].rest = false; res[e].amount = parseInt($('.ui_resources_bar .' + e + ' .amount').get(0).innerHTML, 10); res.sum.amount += res[e].amount; } } // Percentage of total resources res.wood.percent = 100 / res.sum.amount * res.wood.amount; res.stone.percent = 100 / res.sum.amount * res.stone.amount; res.iron.percent = 100 / res.sum.amount * res.iron.amount; // Total trading capacity res.sum.cur = parseInt($(wndID + '#' + a + 'big_progressbar .caption .curr').get(0).innerHTML, 10); // Amount of resources on the percentage of trading capacity (%) res.wood.part = parseInt(res.sum.cur / 100 * res.wood.percent, 10); res.stone.part = parseInt(res.sum.cur / 100 * res.stone.percent, 10); res.iron.part = parseInt(res.sum.cur / 100 * res.iron.percent, 10); // Get rest warehouse capacity of each resource type for (var f in res) { if (res.hasOwnProperty(f) && f != "sum") { if (!ww && own_town) { // Own town var curr = parseInt($(wndID + '#town_capacity_' + f + ' .amounts .curr').get(0).innerHTML.replace('+', '').trim(), 10) || 0, curr2 = parseInt($(wndID + '#town_capacity_' + f + ' .amounts .curr2').get(0).innerHTML.replace('+', '').trim(), 10) || 0, max = parseInt($(wndID + '#town_capacity_' + f + ' .amounts .max').get(0).innerHTML.replace('+', '').trim(), 10) || 0; res[f].cur = curr + curr2; res[f].max = max - res[f].cur; if (res[f].max < 0) { res[f].max = 0; } } else { // World wonder or foreign town res[f].max = 30000; } } } // Rest of fraction (0-2 units) add to stone amount res.stone.part += res.sum.cur - (res.wood.part + res.stone.part + res.iron.part); res.sum.rest = 0; rest_count = 0; calcRestAmount(); setAmount(false, a, wndID); }, function () { setAmount(true, a, wndID); }); } catch (error) { errorHandling(error, "setPercentTrade"); } } function calcRestAmount() { // Subdivide rest if (res.sum.rest > 0) { for (var e in res) { if (res.hasOwnProperty(e) && e != "sum" && res[e].rest != true) { res[e].part += res.sum.rest / (3 - rest_count); } } res.sum.rest = 0; } // Calculate new rest for (var f in res) { if (res.hasOwnProperty(f) && f != "sum" && res[f].rest != true) { if (res[f].max <= res[f].part) { res[f].rest = true; res.sum.rest += res[f].part - res[f].max; rest_count += 1; res[f].part = res[f].max; } } } // Recursion if (res.sum.rest > 0 && rest_count < 3) calcRestAmount(); } function setAmount(clear, a, wndID) { for (var e in res) { if (res.hasOwnProperty(e) && e != "sum") { if (clear == true) { res[e].part = 0; } $(wndID + "#" + a + "trade_type_" + e + ' [type="text"]').select().val(res[e].part).blur(); } } } /******************************************************************************************************************************* * ● Town Trade Improvement : Click on it and it is only exchanged towards a festival. Quack function *******************************************************************************************************************************/ var townTradeImprovement = { activate: () => { $('').appendTo('head'); }, add: (wndID, wnd) => { try { function getRes(res_type, wnd_id, mode) { var res = {}; res.wnd = $("DIV#gpwnd_" + wnd_id); res.selector = res.wnd.find("#town_capacity_" + res_type); res.caption = { curr: parseInt(res.wnd.find("#big_progressbar .caption .curr").html()), max: parseInt(res.wnd.find("#big_progressbar .caption .max").html()), now: parseInt(res.wnd.find("#trade_type_" + res_type + " input").val()) } res.amounts = { curr: parseInt(res.selector.find(".curr").html()) || 0, curr2: parseInt(res.selector.find(".curr2").html().substring(3)) || 0, curr3: parseInt(res.selector.find(".curr3").html().substring(3)) || 0, max: parseInt(res.selector.find(".max").html()) || 0 } if (mode === "cult" || mode === "cultreverse") { res.amounts.max = (res_type === "stone") ? 18000 : 15000; } if (mode === "cultreverse") { var townrescurrent = $("div#ui_box div.ui_resources_bar div.indicator[data-type='" + res_type + "'] div.amount").text(); res.needed = townrescurrent - res.amounts.max; } else { res.needed = res.amounts.max - res.amounts.curr - res.amounts.curr2; } return res; } $(wndID + " .tripple-progress-progressbar").each(function () { var res_type = this.id.split("_")[2]; var res = getRes(res_type, wnd); $(this).find(".amounts").append(' ► ' + res.needed + ''); }); $($(wndID + "#trade > div > div.content > .town-capacity-indicator")[2]).before( '
    ' + '' + '' + '' + '' + '' + '' + /*'' + '' + ''*/'
    ' ); $(wndID + " .dio_trade").click(function () { var id = this.id.split("_"); var res = getRes(id[1], id[2], id[3]); if (res.needed - res.amounts.curr3 <= 0 || res.caption.curr <= 0 || res.amounts.curr3 > 0) { res.send = 0; } else if (res.needed - res.amounts.curr3 > res.caption.curr) { res.send = res.caption.curr + res.amounts.curr3 } else { res.send = res.needed; } res.wnd.find("#trade_type_" + id[1] + " input").val(res.send).select().blur(); }); // Tooltip $('.dio_max').tooltip(dio_icon + "max"); $('.dio_send_cult').tooltip(dio_icon + getTexts("Quack", "cityfestivals")); } catch (error) { errorHandling(error, "townTradeImprovement"); } }, deactivate: () => { $('.tripple-progress-progressbar #dio_needed').remove(); $('#dio_Improvement_trade').remove(); $('#dio_style_Improvement_trade').remove(); }, }; /******************************************************************************************************************************** * Unit strength (blunt/sharp/distance) and Transport Capacity * ---------------------------------------------------------------------------------------------------------------------------- * | ● Unit strength: Menu * | - Switching of def/off display with buttons * | - Possible Selection of certain unit types * | ● Unit strength: Conquest * | ● Unit strength: Barracks * | ● Transport capacity: Menu * | - Switching of transporter speed (+/- big transporter) * ---------------------------------------------------------------------------------------------------------------------------- * ******************************************************************************************************************************/ var def = true, blunt = 0, sharp = 0, dist = 0, shipsize = false; var UnitStrength = { // Calculate defensive strength calcDef: (units) => { var e; blunt = sharp = dist = 0; for (e in units) { if (units.hasOwnProperty(e)) { blunt += units[e] * (uw.GameData.units[e].def_hack || 0); sharp += units[e] * (uw.GameData.units[e].def_pierce || 0); dist += units[e] * (uw.GameData.units[e].def_distance || 0); } } }, // Calculate offensive strength calcOff: (units, selectedUnits) => { var e; blunt = sharp = dist = 0; for (e in selectedUnits) { if (selectedUnits.hasOwnProperty(e)) { var attack = (units[e] || 0) * uw.GameData.units[e].attack; switch (uw.GameData.units[e].attack_type) { case 'hack': blunt += attack; break; case 'pierce': sharp += attack; break; case 'distance': dist += attack; break; } } } }, /******************************************************************************************************************************* * ● Unit strength: Unit menu *******************************************************************************************************************************/ Menu: { timeout: null, activate: () => { UnitStrength.Menu.timeout = setInterval(() => { if ($("#dio_strength").css('display') != 'none') { UnitStrength.Menu.update() } }, 500); $('' + '
    ' + getTexts("Options", "str")[0] + '
    ').appendTo('.units_land .content'); $(".units_land .nav .border_top").click(() => { uw.BarracksWindowFactory.openBarracksWindow(); }); $("#dio_tr_btn").click(() => { if ($("#dio_strength").css('display') == 'none') UnitStrength.Menu.update(); $("#dio_strength").slideToggle(); }); $("#dio_strength").click(() => { UnitStrength.Menu.update(); }); // Style $('').appendTo("head"); // Button events $('.units_land .units_wrapper, .btn_gods_spells .checked').click(() => { setTimeout(() => { UnitStrength.Menu.update(); }, 100); }); $('#dio_off_button').click(() => { $('#dio_strength').addClass('off').removeClass('def'); def = false; UnitStrength.Menu.update(); }); $('#dio_def_button').click(() => { $('#dio_strength').addClass('def').removeClass('off'); def = true; UnitStrength.Menu.update(); }); UnitStrength.Menu.update(); }, deactivate: () => { $('#dio_strength').remove(); $('#dio_strength_style').remove(); $('#dio_Caserne').remove(); $('#dio_tr_btn').remove(); clearTimeout(UnitStrength.Menu.timeout); UnitStrength.Menu.timeout = null; }, update: () => { var unitsIn = uw.ITowns.getTown(uw.Game.townId).units(), units = UnitStrength.Menu.getSelected(); // Calculation if (def === true) { UnitStrength.calcDef(units); } else { UnitStrength.calcOff(unitsIn, units); } $('#dio_blunt').get(0).innerHTML = blunt; $('#dio_sharp').get(0).innerHTML = sharp; $('#dio_dist').get(0).innerHTML = dist; }, getSelected: () => { var units = []; if ($(".units_land .units_wrapper .selected").length > 0) { $(".units_land .units_wrapper .selected").each(function () { units[this.className.split(" ")[1]] = this.children[0].innerHTML; }); } else { $(".units_land .units_wrapper .unit").each(function () { units[this.className.split(" ")[1]] = this.children[0].innerHTML; }); } return units; } }, /******************************************************************************************************************************* * ● Unit strength: Conquest *******************************************************************************************************************************/ Conquest: { add: () => { var units = [], str; // units of the siege $('#conqueror_units_in_town .unit').each(function () { str = $(this).attr("class").split(" ")[4]; if (!uw.GameData.units[str].is_naval) { units[str] = parseInt(this.children[0].innerHTML, 10); } }); // calculation UnitStrength.calcDef(units); $('
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '' + '' + '' + '' + '
    0
    0
    0
    ' + '
    ').appendTo('#conqueror_units_in_town'); $('#dio_strength_eo').tooltip('Gesamteinheitenstärke der Belagerungstruppen'); // Veröffentlichung-Button-Text $('#conqueror_units_in_town .publish_conquest_public_id_wrap').css({ marginLeft: '130px' }); $('#dio_strength_eo .ico').css({ height: '20px', width: '20px' }); $('#dio_strength_eo .units_info_sprite').css({ background: 'url(https://gp' + LID + '.innogamescdn.com/images/game/units/units_info_sprite2.51.png)', backgroundSize: '100%' }); $('#dio_strength_eo .img_pierce').css({ backgroundPosition: '0% 9%' }); $('#dio_strength_eo .img_dist').css({ backgroundPosition: '0% 18%' }); $('#dio_bl').get(0).innerHTML = blunt; $('#dio_sh').get(0).innerHTML = sharp; $('#dio_di').get(0).innerHTML = dist; } }, /******************************************************************************************************************************* * ● Unit strength: Barracks *******************************************************************************************************************************/ Barracks: { add: () => { if (!$('#dio_strength_baracks').get(0)) { var units = [], pop = 0; // whole units of the town $('#units .unit_order_total').each(function () { units[$(this).parent().parent().attr("id")] = this.innerHTML; }); // calculation UnitStrength.calcDef(units); // population space of the units for (var e in units) { if (units.hasOwnProperty(e)) { pop += units[e] * uw.GameData.units[e].population; } } $('
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '' + '' + '' + '' + '
    0
    0
    0
    ' + '
    ').appendTo('.ui-dialog #units'); $('
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '' + '' + '
    0
    ' + '
    ').appendTo('.ui-dialog #units'); $('.ui-dialog #units .ico').css({ height: '20px', width: '20px' }); $('.ui-dialog #units .units_info_sprite').css({ background: 'url(https://gp' + LID + '.innogamescdn.com/images/game/units/units_info_sprite2.51.png)', backgroundSize: '100%' }); $('.ui-dialog #units .img_pierce').css({ backgroundPosition: '0% 9%' }); $('.ui-dialog #units .img_dist').css({ backgroundPosition: '0% 18%' }); $('#dio_b').get(0).innerHTML = blunt; $('#dio_s').get(0).innerHTML = sharp; $('#dio_d').get(0).innerHTML = dist; $('#dio_p').get(0).innerHTML = pop; } } } }; /******************************************************************************************************************************* * ● Transporter capacity *******************************************************************************************************************************/ var TransportCapacity = { timeout: null, activate: () => { try { // transporter display $('
    ' + //'' + '
    ' + '' + '' + '' + '' + '' + //'
    ' + "").appendTo(".units_naval .content"); $(".units_naval .nav .border_top").click(() => { uw.DocksWindowFactory.openDocksWindow(); }); $('').appendTo('head'); $("#dio_tr_recruit.checkbox_new").click(function () { if ($(this).find("DIV.tr_deactivated").length === 0) { $(this).toggleClass("checked"); } }); TransportCapacity.timeout = setInterval(() => { TransportCapacity.update(); }, 800); $("#dio_tr_recruit").click(() => { TransportCapacity.update(); }); $("#dio_transporter").toggleClick( function () { $("#dio_ship_img").get(0).src = Home_url + "/img/dio/logo/mini-bateau-red.png"; shipsize = true TransportCapacity.update(); }, function () { $("#dio_ship_img").get(0).src = Home_url + "/img/dio/logo/mini-bateau.png"; shipsize = false TransportCapacity.update(); } ); TransportCapacity.update(); $("#dio_tr_recruit").tooltip(dio_icon + getTexts("transport_calc", "recruits")); } catch (error) { errorHandling(error, "TransportCapacity (activate)"); } }, deactivate: () => { $("#dio_TransportCapacity_style").remove(); $("#dio_transporter").remove(); $("#dio_Port").remove(); $("#dio_tr_recruit").remove(); clearTimeout(TransportCapacity.timeout); TransportCapacity.timeout = null; }, update: () => { try { const selected_town = uw.ITowns.getTown(uw.Game.townId), GD_units = uw.GameData.units, GD_heroes = uw.GameData.heroes, trans_small = GD_units.small_transporter, trans_big = GD_units.big_transporter; let bigTransp = 0, smallTransp = 0, pop = 0, pop_def = 0, ship = 0, unit, berth, units = []; // Ship space (available) smallTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().small_transporter, 10); if (isNaN(smallTransp)) smallTransp = 0; if (shipsize) { bigTransp = parseInt(uw.ITowns.getTown(parseInt(uw.Game.townId, 10)).units().big_transporter, 10); if (isNaN(bigTransp)) bigTransp = 0; } // Checking: Research berth berth = 0; if (uw.ITowns.getTown(uw.Game.townId).researches().hasBerth()) { berth = uw.GameData.research_bonus.berth; } ship = bigTransp * (trans_big.capacity + berth) + smallTransp * (trans_small.capacity + berth); units = uw.ITowns.getTown(uw.Game.townId).units(); function isOff(name) { return GD_units[name].unit_function === "function_off" || GD_units[name].unit_function === "function_both" } function isDef(name) { return GD_units[name].unit_function === "function_def" || GD_units[name].unit_function === "function_both" } // Ship space (required) for (var e in units) { if (units.hasOwnProperty(e)) { if (GD_units[e]) { if (isOff(e)) { if (e === "spartoi") { pop += units[e]; } else if ( !(GD_units[e].is_naval || GD_units[e].flying) ) { pop += units[e] * GD_units[e].population; } } if (isDef(e)) { if (!(GD_units[e].is_naval || GD_units[e].flying)) { pop_def += units[e] * GD_units[e].population; } } } } } if ($(".dio_tr_recruit").parent().hasClass("checked")) { const recruits = selected_town.getUnitOrdersCollection().models; for (let i = 0; i < recruits.length; ++i) { const unitt = recruits[i].attributes.unit_type, number = recruits[i].attributes.units_left; // Landtruppen if (!(unitt in GD_heroes) && units[unitt] != 0 && !GD_units[unitt].flying && GD_units[unitt].capacity == undefined) { if (isOff(unitt)) { if (unitt === "spartoi") { pop += number; } else { pop += number * GD_units[unitt].population; } } if (isDef(unitt)) { if (unitt === "spartoi") { pop_def += number; } else { pop_def += number * GD_units[unitt].population; } } } // Transportschiffe else if (!(unitt in GD_heroes) && units[unitt] != 0 && !GD_units[unitt].flying && GD_units[unitt].capacity != 0) { if (!shipsize) { if (unitt === "small_transporter") { ship += number * (GD_units[unitt].capacity + berth); } else return } if (shipsize) { ship += number * (GD_units[unitt].capacity + berth); } } } } $(".dio_tr_recruit").css({ "background-position-y": pop_def > pop ? "-36px" : "0px" }); if (pop_def > pop) { pop = pop_def; } let newHTML = ` ship ? "#ffb4b4" : "#6eff5c") }">${pop}/${ship}`; if ($("#dio_ship").get(0).innerHTML !== newHTML) { $("#dio_ship").get(0).innerHTML = newHTML; } const popDiff = Math.abs(pop - ship); if (pop > ship) { let missing = Math.ceil(popDiff / (trans_small.capacity + berth)); name = missing === 1 ? trans_small.name : trans_small.name_plural; if (shipsize) { missing = Math.ceil(popDiff / (trans_big.capacity + berth)); name = missing === 1 ? trans_big.name : trans_big.name_plural; } $("#dio_transporter").tooltip(dio_icon + getTexts("transport_calc", "Lack") + " " + missing + " " + name); } else { name = trans_small.name_plural; if (shipsize) { name = trans_big.name_plural }; $("#dio_transporter").tooltip(dio_icon + getTexts("transport_calc", "Still") + " " + popDiff + " " + getTexts("transport_calc", "pop") + " " + name + "."); if (pop === 0 & ship === 0) { $("#dio_transporter").tooltip(dio_icon + getTexts("transport_calc", "army")); } else if (popDiff === 0) { $("#dio_transporter").tooltip(dio_icon + getTexts("transport_calc", "Optipop") + " " + name + "."); } } } catch (error) { errorHandling(error, "TransportCapacity (update)"); } }, }; /******************************************************************************************************************************* * Simulator * ---------------------------------------------------------------------------------------------------------------------------- * | ● Layout adjustment * | ● Unit strength for entered units (without modificator influence yet) * ---------------------------------------------------------------------------------------------------------------------------- *******************************************************************************************************************************/ var Simulator = { activate: () => { $('').appendTo('head'); if ($('#place_simulator').get(0)) { setStrengthSimulator(); } SimulatorStrength.activate(); }, deactivate: () => { $('#dio_simulator_style').remove(); if ($('#simu_table').get(0)) { $('#simu_table').remove(); } SimulatorStrength.deactivate(); } }; function afterSimulation() { try { let lossArray = { att: { res: 0, fav: 0, pop: 0 }, def: { res: 0, fav: 0, pop: 0 } }, wall_level = parseInt($('.place_sim_wrap_mods .place_insert_field[name="sim[mods][def][wall_level]"]').val(), 10), wall_damage = parseInt($('#building_place_def_losses_wall_level').get(0).innerHTML, 10), 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]; // Calculate unit losses $('#place_sim_ground_units .place_losses, #place_sim_naval_units .place_losses').each(function () { const loss = parseInt(this.innerHTML, 10) || 0; //console.log(this.innerHTML); if (loss > 0) { const unit = this.id.substring(26); const side = this.id.split("_")[2]; // att / def lossArray[side].res += loss * (uw.GameData.units[unit].resources.wood + uw.GameData.units[unit].resources.stone + uw.GameData.units[unit].resources.iron); lossArray[side].fav += loss * uw.GameData.units[unit].favor; lossArray[side].pop += loss * uw.GameData.units[unit].population; } }); // Calculate wall resource losses for (let w = wall_level; w > wall_level - wall_damage; w--) { 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 } // Insert losses into table for (let x in lossArray) { if (lossArray.hasOwnProperty(x)) { for (var z in lossArray[x]) { if (lossArray[x].hasOwnProperty(z)) { //console.log(((z === "res") && (lossArray[x][z] > 10000)) ? (Math.round(lossArray[x][z] / 1000) + "k") : lossArray[x][z]); $("#dio_" + x + "_" + z).get(0).innerHTML = ((z === "res") && (lossArray[x][z] > 10000)) ? (Math.round(lossArray[x][z] / 1000) + "k") : lossArray[x][z]; } } } } } catch (error) { errorHandling(error, "afterSimulation"); } } // Stärkeanzeige: Simulator let unitsGround = { att: {}, def: {} }, unitsNaval = { att: {}, def: {} }, name = ""; var SimulatorStrength = { timeout: null, unitsGround: { att: {}, def: {} }, unitsNaval: { att: {}, def: {} }, activate: () => { $('' ).appendTo('head'); SimulatorStrength.timeout = setInterval(() => { if ($('#dio_simulator_strength').length) { afterSimulation(); } }, 900); }, deactivate: () => { $('#dio_simulator_strength_style').remove(); $('#dio_simulator_strength').remove(); clearTimeout(SimulatorStrength.timeout); SimulatorStrength.timeout = null; } } function setStrengthSimulator() { try { $('
    ' + '

    ' + getTexts("labels", "str") + '

    ' + '
    ' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
    0000
    0000
    ' + '

    ' + getTexts("labels", "los") + '

    ' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
    000
    000
    ' + '
    ').appendTo('#simulator_body'); $('#dio_simulator_strength .left_border').each(function () { $(this)[0].align = 'center'; }); $('#dio_simulator_strength .strength').tooltip(dio_icon + getTexts("labels", "str") + " (" + getTexts("labels", "mod") + ")"); $('#dio_simulator_strength .loss').tooltip(dio_icon + getTexts("labels", "los")); // Klick auf Einheitenbild $('.index_unit').click(function () { const type = $(this).attr('class').split(" ")[4]; $('.place_insert_field[name="sim[units][att][' + type + ']"]').change(); }); $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').on('input change', function () { name = $(this).attr("name").replace(/\]/g, "").split("["); const str = this; setTimeout(() => { const unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2]; let val, e; val = parseInt($(str).val(), 10); val = val || 0; if (unit_type == "ground") { unitsGround[name[2]][name[3]] = val; if (name[2] == "def") { UnitStrength.calcDef(unitsGround.def); } else { UnitStrength.calcOff(unitsGround.att, unitsGround.att); } $('#dio_' + name[2] + '_b').get(0).innerHTML = blunt; $('#dio_' + name[2] + '_s').get(0).innerHTML = sharp; $('#dio_' + name[2] + '_d').get(0).innerHTML = dist; } else { let att = 0, def = 0; unitsNaval[name[2]][name[3]] = val; if (name[2] == "def") { for (e in unitsNaval.def) { if (unitsNaval.def.hasOwnProperty(e)) { def += unitsNaval.def[e] * uw.GameData.units[e].defense; } } $('#dio_def_ship').get(0).innerHTML = def; } else { for (e in unitsNaval.att) { if (unitsNaval.att.hasOwnProperty(e)) { att += unitsNaval.att[e] * uw.GameData.units[e].attack; } } $('#dio_att_ship').get(0).innerHTML = att; } } }, 100); }); // Abfrage wegen eventueller Spionageweiterleitung getUnitInputs(); setTimeout(() => { setChangeUnitInputs("def"); }, 100); $('#select_insert_units').change(function () { var side = $(this).find('option:selected').val(); setTimeout(() => { getUnitInputs(); if (side === "att" || side === "def") { setChangeUnitInputs(side); } }, 200); }); } catch (error) { errorHandling(error, "setStrengthSimulator"); } } function getUnitInputs() { try { $('#place_sim_ground_units .place_insert_field, #place_sim_naval_units .place_insert_field').each(function () { name = $(this).attr("name").replace(/\]/g, "").split("["); const str = this; const unit_type = $(str).closest('.place_simulator_table').attr("id").split("_")[2]; let val = parseInt($(str).val(), 10); val = val || 0; if (unit_type === "ground") { unitsGround[name[2]][name[3]] = val; } else { unitsNaval[name[2]][name[3]] = val; } }); } catch (error) { errorHandling(error, "getUnitInputs"); } } function setChangeUnitInputs(side) { $('.place_insert_field[name="sim[units][' + side + '][godsent]"]').change(); setTimeout(() => { $('.place_insert_field[name="sim[units][' + side + '][colonize_ship]"]').change(); }, 100); } /******************************************************************************************************************************* * Defense form * ---------------------------------------------------------------------------------------------------------------------------- * | ● Adds a defense form to the bbcode bar * ---------------------------------------------------------------------------------------------------------------------------- *******************************************************************************************************************************/ // Funktion aufteilen... function addForm(e) { try { var textareaId = "", bbcodeBarId = ""; switch (e) { case "/alliance_forum/forum": textareaId = "#forum_post_textarea"; bbcodeBarId = "#forum"; break; case "/message/forward": textareaId = "#message_message"; bbcodeBarId = "#message_bbcodes"; break; case "/message/new": textareaId = "#message_new_message"; bbcodeBarId = "#message_bbcodes"; break; case "/message/view": textareaId = "#message_reply_message"; bbcodeBarId = "#message_bbcodes"; break; case "/player_memo/load_memo_content": textareaId = "#memo_text_area"; bbcodeBarId = "#memo_edit"; break; case "/frontend_bridge/fetch": case "/frontend_bridge/execute": textareaId = ".notes_container textarea"; bbcodeBarId = ".notes_container"; break; } if (!$(bbcodeBarId + ' .bb_button_wrapper .dio_bbcode_option.dio_def_form').get(0)) { $('').appendTo(bbcodeBarId + ' .bb_button_wrapper'); } $('.dio_def_form_button').css({ cursor: 'pointer', marginTop: '3px' }); $(bbcodeBarId + ' .dio_bbcode_option').css({ background: 'url("' + Home_url + '/img/dio/logo/bbcodebarid.png")', display: 'block', float: 'left', width: '22px', height: '23px', margin: '0 3px 0 0', position: 'relative' }); $(bbcodeBarId + ' .dio_def_form').css({ backgroundPosition: '-89px 0px' }); var imgArray = { wall: 'https://gp' + LID + '.innogamescdn.com/images/game/main/wall.png', tower: 'https://gp' + LID + '.innogamescdn.com/images/game/main/tower.png', hide: 'https://gp' + LID + '.innogamescdn.com/images/game/main/hide.png', spy: Home_url + '/img/dio/logo/40/40px-spy.png', pop: Home_url + '/img/dio/logo/40/40px-pop.png', rev1: Home_url + '/img/dio/logo/40/40px-rev1.png', rev0: Home_url + '/img/dio/logo/40/40px-rev0.png', eo1: Home_url + '/img/dio/logo/40/40px-eo1.png', eo0: Home_url + '/img/dio/logo/40/40px-eo0.png', att: Home_url + '/img/dio/logo/40/40px-att.png', sup: Home_url + '/img/dio/logo/40/40px-sup.png', zeus: Home_url + '/img/dio/logo/40/40px-zeus.png', hera: Home_url + '/img/dio/logo/40/40px-hera.png', athena: Home_url + '/img/dio/logo/40/40px-athena.png', poseidon: Home_url + '/img/dio/logo/40/40px-poseidon.png', hades: Home_url + '/img/dio/logo/40/40px-hades.png', artemis: Home_url + '/img/dio/logo/40/40px-artemis.png', nogod: Home_url + '/img/dio/logo/40/40px-nogod.png', aphrodite: Home_url + '/img/dio/logo/40/40px-aphrodite.png', ares: Home_url + '/img/dio/logo/40/40px-ares.png', captain: Home_url + '/img/dio/logo/40/40px-captain.png', commander: Home_url + '/img/dio/logo/40/40px-commander.png', priest: Home_url + '/img/dio/logo/40/40px-priest.png', phalanx: Home_url + '/img/dio/logo/40/40px-phalanx.png', ram: Home_url + '/img/dio/logo/40/40px-ram.png', militia: Home_url + '/img/dio/logo/40/40px-milice.png', // 'https://wiki.en.grepolis.com/images/9/9b/Militia_40x40.png', sword: Home_url + '/img/dio/logo/40/40px-sword.png', // 'https://wiki.en.grepolis.com/images/9/9c/Sword_40x40.png', slinger: Home_url + '/img/dio/logo/40/40px-slinger.png', // 'https://wiki.en.grepolis.com/images/d/dc/Slinger_40x40.png', archer: Home_url + '/img/dio/logo/40/40px-archer.png', // 'https://wiki.en.grepolis.com/images/1/1a/Archer_40x40.png', hoplite: Home_url + '/img/dio/logo/40/40px-hoplite.png', // 'https://wiki.en.grepolis.com/images/b/bd/Hoplite_40x40.png', rider: Home_url + '/img/dio/logo/40/40px-rider.png', // 'https://wiki.en.grepolis.com/images/e/e9/Rider_40x40.png', chariot: Home_url + '/img/dio/logo/40/40px-chariot.png', // 'https://wiki.en.grepolis.com/images/b/b8/Chariot_40x40.png', catapult: Home_url + '/img/dio/logo/40/40px-catapult.png', // 'https://wiki.en.grepolis.com/images/f/f0/Catapult_40x40.png', godsent: Home_url + '/img/dio/logo/40/40px-godsent.png', // 'https://wiki.de.grepolis.com/images/6/6e/Grepolis_Wiki_225.png', def_sum: Home_url + '/img/dio/logo/40/40px-def_sum.png', minotaur: Home_url + '/img/dio/logo/40/40px-minotaur.png', // 'https://wiki.de.grepolis.com/images/7/70/Minotaur_40x40.png', manticore: Home_url + '/img/dio/logo/40/40px-manticore.png', // 'https://wiki.de.grepolis.com/images/5/5e/Manticore_40x40.png', zyclop: Home_url + '/img/dio/logo/40/40px-zyclop.png', // 'https://wiki.de.grepolis.com/images/6/66/Zyklop_40x40.png', sea_monster: Home_url + '/img/dio/logo/40/40px-sea_monster.png', // 'https://wiki.de.grepolis.com/images/7/70/Sea_monster_40x40.png', harpy: Home_url + '/img/dio/logo/40/40px-harpy.png', // 'https://wiki.de.grepolis.com/images/8/80/Harpy_40x40.png', medusa: Home_url + '/img/dio/logo/40/40px-medusa.png', // 'https://wiki.de.grepolis.com/images/d/db/Medusa_40x40.png', centaur: Home_url + '/img/dio/logo/40/40px-centaur.png', // 'https://wiki.de.grepolis.com/images/5/53/Centaur_40x40.png', pegasus: Home_url + '/img/dio/logo/40/40px-pegasus.png', // 'https://wiki.de.grepolis.com/images/5/54/Pegasus_40x40.png', cerberus: Home_url + '/img/dio/logo/40/40px-cerberus.png', // 'https://wiki.de.grepolis.com/images/6/67/Zerberus_40x40.png', fury: Home_url + '/img/dio/logo/40/40px-fury.png', // 'https://wiki.de.grepolis.com/images/6/67/Erinys_40x40.png', griffin: Home_url + '/img/dio/logo/40/40px-griffin.png', // 'https://wiki.de.grepolis.com/images/d/d1/Unit_greif.png', calydonian_boar: Home_url + '/img/dio/logo/40/40px-calydonian_boar.png', // 'https://wiki.de.grepolis.com/images/9/93/Unit_eber.png', spartoi: Home_url + '/img/dio/logo/40/40px-spartoi.png', siren: Home_url + '/img/dio/logo/40/40px-siren.png', satyr: Home_url + '/img/dio/logo/40/40px-satyr.png', ladon: Home_url + '/img/dio/logo/40/40px-ladon.png', big_transporter: Home_url + '/img/dio/logo/40/40px-big_transporter.png', // 'https://wiki.en.grepolis.com/images/0/04/Big_transporter_40x40.png', bireme: Home_url + '/img/dio/logo/40/40px-bireme.png', // 'https://wiki.en.grepolis.com/images/4/44/Bireme_40x40.png', attack_ship: Home_url + '/img/dio/logo/40/40px-attack_ship.png', // 'https://wiki.en.grepolis.com/images/e/e6/Attack_ship_40x40.png', demolition_ship: Home_url + '/img/dio/logo/40/40px-demolition_ship.png', // 'https://wiki.en.grepolis.com/images/e/ec/Demolition_ship_40x40.png', small_transporter: Home_url + '/img/dio/logo/40/40px-small_transporter.png', // 'https://wiki.en.grepolis.com/images/8/85/Small_transporter_40x40.png', trireme: Home_url + '/img/dio/logo/40/40px-trireme.png', // 'https://wiki.en.grepolis.com/images/a/ad/Trireme_40x40.png', colonize_ship: Home_url + '/img/dio/logo/40/40px-colonize_ship.png', // 'https://wiki.en.grepolis.com/images/d/d1/Colonize_ship_40x40.png', move_icon: 'https://gp' + LID + '.innogamescdn.com/images/game/unit_overview/', // '?', bordure: Home_url + '/img/dio/logo/transition-mini.png' // Home_img + 'bordure.png' }; $('
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '
    ' + getTexts("labels", "det") + '


    ' + '
    ' + getTexts("labels", "prm") + '


    ' + '
    ' + getTexts("labels", "sil") + '


    ' + '
    ' + getTexts("labels", "mov") + '


    ' + '
    ' + dio_icon + '' + getTexts("buttons", "ins") + '
    ' + '
    ').appendTo(bbcodeBarId + ' .bb_button_wrapper'); $('.dio_bb_def_chooser').css({ display: 'none', top: '38px', left: '510px', position: 'absolute', width: '190px', zIndex: 10000 }); $(bbcodeBarId + " .dio_bb_def_chooser .checkbox_new").click(function () { $(this).toggleClass("checked"); }); $(bbcodeBarId + ' .dio_def_form').toggleClick( function () { $(this).parent().find(".dio_bb_def_chooser").get(0).style.display = "block"; }, function () { $(this).parent().find(".dio_bb_def_chooser").get(0).style.display = "none"; } ); $(bbcodeBarId + ' #dio_insert').click(function () { var textarea = $(textareaId).get(0), text = $(textarea).val(), troop_table = "", troop_img = "", troop_count = "", separator = "", move_table = "", landunit_sum = 0; $('.dio_def_form').click(); if ($('#f_uni').hasClass("checked")) { $('.units_land .unit, .units_naval .unit').each(function () { troop_img += separator + '[img]' + imgArray[this.className.split(" ")[1]] + '[/img]'; troop_count += separator + '[center]' + $(this).find(".value").get(0).innerHTML + '[/center]'; separator = "[||]"; }); } else { $('.units_land .unit').each(function () { 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); if (def > 10) { landunit_sum += parseInt($(this).find(".value").get(0).innerHTML, 10) * uw.GameData.units[a].population * ((def > 20) ? 2 : 1); } }); landunit_sum = (landunit_sum > 10000) ? ((Math.round(landunit_sum / 100)) / 10) + "k" : landunit_sum; troop_img += '[img]' + imgArray.def_sum + '[/img]'; troop_count += '[center]' + landunit_sum + '[/center]'; separator = "[||]"; $('.units_naval .unit').each(function () { troop_img += separator + '[img]' + imgArray[this.className.split(" ")[1]] + '[/img]'; troop_count += separator + '[center]' + $(this).find(".value").get(0).innerHTML + '[/center]'; }); } if (troop_img !== "") { troop_table = "\n[table][**]" + troop_img + "[/**][**]" + troop_count + "[/**][/table]\n"; } var str = '[img]' + imgArray.bordure + '[/img]' + '\n[color=#006B00][size=12][u][b]' + getTexts("labels", "ttl", true) + '[/b][/u][/size][/color]\n\n' + //'[table][**][img]'+ imgArray.sup +'[/img][||]'+ '[size=12][town]' + uw.ITowns.getTown(uw.Game.townId).getId() + '[/town] ([player]' + uw.Game.player_name + '[/player])[/size]'; if (MID == 'fr') str += '\n[size=8][url=' + Home_url + '/fr/]DIO-TOOLS-David1327[/url] - v.' + dio_version + '[/size]'; else str += '\n[size=8][url=' + Home_url + '/en/]DIO-TOOLS-David1327[/url] - v.' + dio_version + '[/size]'; //'[||][img]'+ imgArray['rev' + (uw.ITowns.getTown(uw.Game.townId).hasConqueror()?1:0)] +'[/img][/**][/table]'+ str += '\n\n[i][b]' + getTexts("labels", "inf", true) + '[/b][/i]' + troop_table + '[table][*]' + '[img]' + imgArray.wall + '[/img][|]\n' + '[img]' + imgArray.tower + '[/img][|]\n' + '[img]' + imgArray.phalanx + '[/img][|]\n' + '[img]' + imgArray.ram + '[/img][|]\n' + ($('#f_prm').hasClass("checked") ? '[img]' + imgArray.commander + '[/img][|]\n' : ' ') + ($('#f_prm').hasClass("checked") ? '[img]' + imgArray.captain + '[/img][|]\n' : ' ') + ($('#f_prm').hasClass("checked") ? '[img]' + imgArray.priest + '[/img][|]\n' : ' ') + ($('#f_sil').hasClass("checked") ? '[center][img]' + imgArray.spy + '[/img][/center][|]\n' : ' ') + '[img]' + imgArray.pop + '[/img][|]\n' + '[img]' + imgArray[(uw.ITowns.getTown(uw.Game.townId).god() || "nogod")] + '[/img][/*]\n' + '[**][center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("wall") + '[/center][||]' + '[center]' + uw.ITowns.getTown(uw.Game.townId).buildings().getBuildingLevel("tower") + '[/center][||]' + '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.phalanx ? '✔️' : '❌') + '[/center][||]' + '[center]' + (uw.ITowns.getTown(uw.Game.townId).researches().attributes.ram ? '✔️' : '❌') + '[/center][||]' + ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.commander >= uw.Timestamp.now()) ? '✔️' : '❌') + '[/center][||]' : ' ') + ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.captain >= uw.Timestamp.now()) ? '✔️' : '❌') + '[/center][||]' : ' ') + ($('#f_prm').hasClass("checked") ? '[center]' + ((uw.Game.premium_features.priest >= uw.Timestamp.now()) ? '✔️' : '❌') + '[/center][||]' : ' ') + ($('#f_sil').hasClass("checked") ? '[center]' + Math.round(uw.ITowns.getTown(uw.Game.townId).getEspionageStorage() / 1000) + 'k[/center][||]' : ' ') + '[center]' + uw.ITowns.getTown(uw.Game.townId).getAvailablePopulation() + '[/center][||]' + '[center]' + $('.favor_amount').get(0).innerHTML + '[/center]' + '[/**][/table]'; var bb_count_str = parseInt(str.match(/\[/g).length, 10), bb_count_move = 0; var i = 0; if ($('#f_mov').hasClass("checked")) { move_table += '\n[i][b]' + getTexts("labels", "mov", true) + '[/b][/i]\n[table]'; $('#toolbar_activity_commands').mouseover(); $('#toolbar_activity_commands_list .content .command').each(function () { var cl = $(this).children()[0].className.split(" "); console.log($(this).children()[0].className.split(" ")) console.log(cl[cl.length - 1]) 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)) { move_table += (i % 1) ? "" : "[**]"; i++; move_table += "[img]" + imgArray.move_icon + cl[2] + ".png[/img][||]"; move_table += getArrivalTime($(this).children()[1].innerHTML) + (uw.Game.market_id === "de" ? " Uhr[||]" : " [||]"); console.log($(this).parent()[0]) // Récupérez l'URL de chaque lien const url = $(this).find('.gp_town_link').attr('href'); // Utilisez la fonction replaceBBtowns pour extraire l'ID de la ville de l'URL const townIdMatch = url.match(/#(.*?)$/); //if (townIdMatch && townIdMatch[1]) { const ville = $.parseJSON(atob(townIdMatch[1])).id; move_table += "[town]" + ville + "[/town]"; //move_table += "[town]" + JSON.parse(atob($(this).children()[2].firstChild.href.split("#")[1])).id + "[/town]"; move_table += (i % 1) ? "[||]" : "[/**]"; console.log(move_table) } bb_count_move = parseInt(move_table.match(/\[/g).length, 10); }); if ((bb_count_str + bb_count_move) > 480) { move_table += '[**]...[/**]'; } console.log(move_table) $('#toolbar_activity_commands').mouseout(); //console.log((bb_count_str + bb_count_move)); move_table += (i % 1) ? "[/**]" : ""; move_table += "[*][|][color=#800000][size=6][i] (" + getTexts("labels", "dev", true) + ": ±1s)[/i][/size][/color][/*][/table]\n"; } str += move_table + '[img]' + imgArray.bordure + '[/img]\n'; $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + str + text.substring($(textarea).get(0).selectionEnd)); }); } catch (error) { errorHandling(error, "addForm"); } } function getArrivalTime(duration_time) { try { var server_time = $('.server_time_area').get(0).innerHTML.split(" ")[0].split(":"), arrival_time, s, m, h; duration_time = duration_time.split(":"); console.log(duration_time) s = parseInt(server_time[2], 10) + parseInt(duration_time[2], 10); m = parseInt(server_time[1], 10) + parseInt(duration_time[1], 10) + ((s >= 60) ? 1 : 0); h = parseInt(server_time[0], 10) + parseInt(duration_time[0].split(">")[1], 10) + ((m >= 60) ? 1 : 0); console.log(duration_time[0].split(">")[1]) s = s % 60; m = m % 60; h = h % 24; s = ((s < 10) ? "0" : "") + s; m = ((m < 10) ? "0" : "") + m; h = ((h < 10) ? "0" : "") + h; arrival_time = h + ":" + m + ":" + s; return arrival_time; } catch (error) { errorHandling(error, "getArrivalTime"); } } /******************************************************************************************************************************* * Smiley box * ---------------------------------------------------------------------------------------------------------------------------- * | ● Display of a smiley selection box for text input fields (forum, messages, notes): * | ● Used smileys: http://www.greensmilies.com/smilie-album/ * | + Own Grepolis smileys * ---------------------------------------------------------------------------------------------------------------------------- *******************************************************************************************************************************/ var smileyArray = {}; var SmileyBox = { loading_error: false, isHalloween: false, isXmas: false, isEaster: false, isLove: false, activate: () => { $('').appendTo('head'); // Smiley categories smileyArray.button = ["rollsmiliey", "smile"]; smileyArray.standard = [ "smilenew", "lol", "neutral_new", "afraid", "freddus_pacman", "auslachen2", "kolobok-sanduhr", "bussi2", "winken4", "flucht2", "panik4", "ins-auge-stechen", "seb_zunge", "fluch4_GREEN", "baby_junge2", "blush-reloaded6", "frown", "verlegen", "blush-pfeif", "stevieh_rolleyes", "daumendreh2", "baby_taptap", "sadnew", "hust", "confusednew", "idea2", "irre", "irre4", "sleep", "candle", "nicken", "no_sad", "thumbs-up_new", "kciuki", "thumbs-down_new", "bravo2", "oh-no2", "kaffee2", "drunk", "saufen", "freu-dance", "hecheln", "headstand", "rollsmiliey", "eazy_cool01", "motz", "cuinlove", "biggrin" ]; smileyArray.nature = [ "dinosaurier07", "flu-super-gau", "ben_cat", "schwein", "hundeleine01", "blume", "ben_sharky", "ben_cow", "charly_bissig", "gehirnschnecke_confused", "mttao_fische", "mttao_angler", "insel", "fliegeschnappen", "plapperhase", "ben_dumbo", "twitter", "elefant", "schildkroete", "elektroschocker", "spiderschwein", "oma_sessel_katze", "fred_elefant", "palmoel", "stevieh_teddy", "fips_aufsmaul", "marienkaefer", "mrkaktus", "kleeblatt2", "fred_blumenstauss", "hurra_fruehling1_lila", "fred_rasenmaeher", "fred_blumenbeet" ]; smileyArray.grepolis = [ "grepolis", "mttao_wassermann", "i-lovo-grepolis", "silvester_cuinlove", "mttao_schuetze", "kleeblatt2", "wallbash", "musketiere_fechtend", "aufsmaul", "lol1", "mttao_waage2", "steckenpferd", "skullhaufen", "pferdehaufen", "pirat5", "seb_cowboy", "gw_ranger001", "barbar", "datz", "waffe01", "sarazene_bogen", "waffe02", "waffe14", "hoplit_sword1", "pfeildurchkopf02", "saladin", "hoplit_sword3" ]; smileyArray.people = [ "greenistan", "mttao_usa", "schal_usa", "mttao_grossbritannien", "seb_hut5", "opa_boese2", "star-wars-yoda1-gruen", "hexefliegend", "snob", "seb_detektiv_ani", "devil", "segen", "borg", "hexe3b", "eazy_polizei", "stars_elvis", "mttao_chefkoch", "nikolaus", "pirate3_biggrin", "batman_skeptisch", "tubbie1", "tubbie2", "tubbie3", "kosmita", "tubbie4" ]; smileyArray.Party = [ "torte1", "torte3", "bier", "party", "party2", "fans", "band", "klokotzen", "laola", "prost", "rave", "mcdonalds", "margarita", "geschenk", "sauf", "el", "trommler", "ozboss_gitarre2", "kaffee", "kaffee3", "caipirinha", "whiskey", "drunk", "fressen", "popcorn_essen", "saufen", "energydrink1", "leckerer", "prost2", "birthday" ]; smileyArray.other = [ "steinwerfen", "herzen02", "scream-if-you-can", "kolobok", "headbash", "liebeskummer", "bussi", "brautpaar-reis", "grab-schaufler2", "boxen2", "aufsmaul", "mttao_kehren", "sm", "weckruf", "klugscheisser2", "karte2_rot", "dagegen", "party", "dafuer", "outofthebox", "pokal_gold", "koepfler", "transformer", "eazy_senseo1" ]; smileyArray.halloween = [ "zombies_alien", "zombies_lol", "zombies_rolleyes", "zombie01", "zombies_smile", "zombie02", "zombies_skeptisch", "zombies_eek", "zombies_frown", "geistani", "scream-if-you-can", "pfeildurchkopf01", "grab-schaufler", "kuerbisleuchten", "mummy3", "kuerbishaufen", "halloweenskulljongleur", "fledermausvampir", "frankenstein_lol", "halloween_confused", "zombies_razz", "halloweenstars_freddykrueger", "zombies_cool", "geist2", "fledermaus2", "halloweenstars_dracula", "batman", "halloweenstars_lastsummer", "hexe-frosch", "xmas4_hexe-frosch", "hexe-frosch2", ]; smileyArray.xmas = [ "i-love-grepolis", "santagrin", "xmas1_down", "xmas1_thumbs1", "xmas2_lol", "xmas1_frown", "xmas1_irre", "xmas1_razz", "xmas4_kaffee2", "xmas4_hurra2", "xmas4_aufsmaul", "schneeball", "schneeballwerfen", "xmas4_advent4", "nikolaus", "weihnachtsmann_junge", "schneewerfen_wald", "weihnachtsmann_nordpol", "xmas_kilroy_kamin", "xmas4_laola", "xmas3_smile", "xmas4_paketliebe", "3hlkoenige", "santa", "weihnachtsgeschenk2", "fred_weihnachten-ostern", "xmas4_wallbash", "xmas4_liebe", "xmas4_skullhaufen", "tree", "xmas1_censored", "xmas4_furz", "xmas4_nixweiss", "xmas4_altermann", "xmas4_postbote", "xmas4_postpaket", "xmas4_paketliebe", "xmas4_regenschirm2", "xmas4_respekt", "xmas4_stars_takethat_howard", "xmas4_talk", "xmas4_hundeleine01", "xmas4_spam1", "xmas4_spam3", "xmas4_google", "xmas4_selbstmord", ]; smileyArray.easter = [ "eier_bemalen_blau_hase_braun", "osterei_hase05", "osterei_bunt", "ostern_hurra2", "osterhasensmilie", "ostern_thumbs1", "ostern_nosmile", "ostern_lol", "ostern_irre", "ostern_frown", "ostern_down", "ostern_cuinlove", "ostern_confused", "ostern_blush", "ostern_biggrin", "ostern1_blush-reloaded", "ostern_alien", "ostern_censored", "ostern_cool", "ostern_stumm", "xmas4_ostern_stumm", "ostern1_xd", "ostern2_xd", "ostern2_censored", "ostern2_confused", "ostern2_cuinlove", "ostern2_down", "ostern2_thumbs1", "ostern_rofl3", "ostern2_rofl3", ]; smileyArray.love = [ "b-love2", "brautpaar-kinder", "brautpaar-reis", "cuinlove", "fips_herzen01", "heart", "herzen01", "herzen02", "herzen06", "kiss", "klk_tee", "liebesflagge", "love", "lovelove_light", "rose", "send-out-love", "teeglas_fruechtetee", "unknownauthor_knutsch", "valentinstag_biggrin", "valentinstag_confused", "valentinstag_down", "valentinstag_irre", "valentinstag_lol", "valentinstag_thumbs1", "wolke7", "xmas4_rose", ]; smileyArray.Buchstaben = [ "sign2_0", "sign2_1", "sign2_2", "sign2_3", "sign2_4", "sign2_5", "sign2_6", "sign2_7", "sign2_8", "sign2_9", "sign2_A", "sign2_B", "sign2_C", "sign2_D", "sign2_E", "sign2_F", "sign2_G", "sign2_H", "sign2_I", "sign2_J", "sign2_K", "sign2_L", "sign2_M", "sign2_N", "sign2_O", "sign2_P", "sign2_Q", "sign2_R", "sign2_S", "sign2_T", "sign2_U", "sign2_V", "sign2_W", "sign2_X", "sign2_Y", "sign2_Z", "sign2_and", "sign2_backslash", "sign2_callsign", "sign2_comma", "sign2_plus", "sign2_point", "sign2_questionmark", "sign2_quote", "sign2_slash", "sign2_space", "sign2_star", "sign2_AE", "sign2_OE", "sign2_UE", "sign2_SZ", "sign3_0", "sign3_1", "sign3_2", "sign3_3", "sign3_4", "sign3_5", "sign3_6", "sign3_7", "sign3_8", "sign3_9", "sign3_A", "sign3_B", "sign3_C", "sign3_D", "sign3_E", "sign3_F", "sign3_G", "sign3_H", "sign3_I", "sign3_J", "sign3_K", "sign3_L", "sign3_M", "sign3_N", "sign3_O", "sign3_P", "sign3_Q", "sign3_R", "sign3_S", "sign3_T", "sign3_U", "sign3_V", "sign3_W", "sign3_X", "sign3_Y", "sign3_Z", "sign3_and", "sign3_backslash", "sign3_callsign", "sign3_comma", "sign3_plus", "sign3_point", "sign3_questionmark", "sign3_quote", "sign3_slash", "sign3_space", "sign3_star", "sign3_AE", "sign3_OE", "sign3_UE", "sign3_SZ", "braille-schrift_0", "braille-schrift_1", "braille-schrift_2", "braille-schrift_3", "braille-schrift_4", "braille-schrift_5", "braille-schrift_6", "braille-schrift_7", "braille-schrift_8", "braille-schrift_9", "braille-schrift_A", "braille-schrift_B", "braille-schrift_C", "braille-schrift_D", "braille-schrift_E", "braille-schrift_F", "braille-schrift_G", "braille-schrift_H", "braille-schrift_I", "braille-schrift_J", "braille-schrift_K", "braille-schrift_L", "braille-schrift_M", "braille-schrift_N", "braille-schrift_O", "braille-schrift_P", "braille-schrift_Q", "braille-schrift_R", "braille-schrift_S", "braille-schrift_T", "braille-schrift_U", "braille-schrift_V", "braille-schrift_W", "braille-schrift_X", "braille-schrift_Y", "braille-schrift_Z", "braille-schrift_callsign", "braille-schrift_comma", "braille-schrift_point", "braille-schrift_questionmark", "braille-schrift_quote", "braille-schrift_space", "braille-schrift_AE", "braille-schrift_OE", "braille-schrift_UE", "braille-schrift_SZ", "buchstaben_0", "buchstaben_1", "buchstaben_2", "buchstaben_3", "buchstaben_4", "buchstaben_5", "buchstaben_6", "buchstaben_7", "buchstaben_8", "buchstaben_9", "buchstaben_A", "buchstaben_B", "buchstaben_C", "buchstaben_D", "buchstaben_E", "buchstaben_F", "buchstaben_G", "buchstaben_H", "buchstaben_I", "buchstaben_J", "buchstaben_K", "buchstaben_L", "buchstaben_M", "buchstaben_N", "buchstaben_O", "buchstaben_P", "buchstaben_Q", "buchstaben_R", "buchstaben_S", "buchstaben_T", "buchstaben_U", "buchstaben_V", "buchstaben_W", "buchstaben_X", "buchstaben_Y", "buchstaben_Z", "buchstaben_and", "buchstaben_callsign", "buchstaben_comma", "buchstaben_plus", "buchstaben_point", "buchstaben_questionmark", "buchstaben_quote", "buchstaben_space", "buchstaben_star", "buchstaben_AE", "buchstaben_OE", "buchstaben_UE", "xmas-sign_0", "xmas-sign_1", "xmas-sign_2", "xmas-sign_3", "xmas-sign_4", "xmas-sign_5", "xmas-sign_6", "xmas-sign_7", "xmas-sign_8", "xmas-sign_9", "xmas-sign_A", "xmas-sign_B", "xmas-sign_C", "xmas-sign_D", "xmas-sign_E", "xmas-sign_F", "xmas-sign_G", "xmas-sign_H", "xmas-sign_I", "xmas-sign_J", "xmas-sign_K", "xmas-sign_L", "xmas-sign_M", "xmas-sign_N", "xmas-sign_O", "xmas-sign_P", "xmas-sign_Q", "xmas-sign_R", "xmas-sign_S", "xmas-sign_T", "xmas-sign_U", "xmas-sign_V", "xmas-sign_W", "xmas-sign_X", "xmas-sign_Y", "xmas-sign_Z", "xmas-sign_and", "xmas-sign_backslash", "xmas-sign_callsign", "xmas-sign_comma", "xmas-sign_plus", "xmas-sign_point", "xmas-sign_questionmark", "xmas-sign_quote", "xmas-sign_slash", "xmas-sign_space", "xmas-sign_star", "xmas-sign_AE", "xmas-sign_OE", "xmas-sign_UE", "xmas-sign_SZ", ]; smileyArray.Geburtstag = ["29a", "29b", "29c"]; SmileyBox.loadSmileys(); }, deactivate: () => { $('#dio_smiley').remove(); }, // preload images loadSmileys: () => { try { // Replace german sign smilies if (MID == "de" || dio.lang() == "de") { smileyArray.standard.push("land_germany", "land_germany2", "land_germany3", "land_germany_kings"); smileyArray.other.push("dagegen2", "dafuer2"); smileyArray.people.unshift("mttao_deutschland", "schal_deutschland"); } if (MID == "fr" || dio.lang() == "fr") { smileyArray.standard.push("land_france", "land_france2", "land_france3"); smileyArray.people.unshift("mttao_frankreich", "schal_frankreich"); } if (MID == "it" || dio.lang() == "it") { smileyArray.standard.push("land_italy", "land_italy2", "land_italy3"); smileyArray.people.unshift("mttao_italien", "schal_italien"); } if (MID == "ro" || dio.lang() == "ro") { smileyArray.standard.push("land_romania", "land_romania2", "land_romania3"); smileyArray.people.unshift("mttao_rumaenien"); } if (MID == "br" || dio.lang() == "br") { smileyArray.standard.push("land_portugal", "land_portugal2", "land_portugal3"); smileyArray.people.unshift("mttao_portugal", "schal_portugal"); } if (MID == "pl" || dio.lang() == "pl") { smileyArray.standard.push("land_poland", "land_poland2", "land_poland3"); smileyArray.people.unshift("mttao_polen"); } if (MID == "es" || dio.lang() == "es") { smileyArray.standard.push("land_spain", "land_spain2", "land_spain3"); smileyArray.people.unshift("mttao_spanien", "schal_spanien"); } if (MID == "sk" || dio.lang() == "sk") { smileyArray.people.unshift("mttao_slowakei", "schal_slowakei"); } for (var a = 1; a < 101; a++) { smileyArray.Geburtstag.push("geburtstagswedler-" + a); if (a < 10) smileyArray.Buchstaben.push("rate0" + a); } smileyArray.Buchstaben.push("rate10", "rate11", "rate11b") for (var e in smileyArray) { if (smileyArray.hasOwnProperty(e)) { for (var f in smileyArray[e]) { if (smileyArray[e].hasOwnProperty(f)) { var src = smileyArray[e][f]; smileyArray[e][f] = new Image(); smileyArray[e][f].className = "smiley"; if (src.substring(0, 6) == "smile/") { smileyArray[e][f].src = "https://www.greensmilies.com/" + src + ".gif"; } else if (src.substring(0, 1) == "_") { smileyArray[e][f].src = "https://www.greensmilies.com/smile/smiley_emoticons" + src + ".gif"; } else { if (SmileyBox.loading_error == false) { //smileyArray[e][f].src = Home_img + "smiley-emoticons-" + src + ".gif"; smileyArray[e][f].src = Home_url + "/img/smileys/" + src + ".gif"; } else { smileyArray[e][f].src = 'https://i.imgur.com/VdjJJgk.gif'; } } smileyArray[e][f].onerror = function () { this.src = 'https://i.imgur.com/VdjJJgk.gif'; }; } } } } } catch (error) { errorHandling(error, "SmileyBox (loadSmileys)"); } }, // add smiley box add: (e) => { try { var bbcodeBarId = ""; switch (e) { case "/alliance_forum/forum": bbcodeBarId = "#forum"; break; case "/message/forward": bbcodeBarId = "#message_bbcodes"; break; case "/message/new": bbcodeBarId = "#message_bbcodes"; break; case "/message/view": bbcodeBarId = "#message_bbcodes";//setWonderIconsOnMap break; case "/player_memo/load_memo_content": bbcodeBarId = "#memo_edit"; // old notes break; case "/frontend_bridge/fetch": case "/frontend_bridge/execute": bbcodeBarId = ".notes_container"; // TODO: new notes break; } if (($(bbcodeBarId + ' #emots_popup_7').get(0) || $(bbcodeBarId + ' #emots_popup_15').get(0)) && (PID == 1538932 || PID === 100144)) { $(bbcodeBarId + " .bb_button_wrapper").get(0).lastChild.remove(); } if (!$(bbcodeBarId + ' .bb_button_wrapper .dio_smiley_button').get(0)) { $('').appendTo(bbcodeBarId + ' .bb_button_wrapper'); } $('
    ' + '
    ' + '
    ' + '
    ' + '
    ' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
    ' + '

    ' + '' + /*'' +*/ '
    ').appendTo(bbcodeBarId + ' .bb_button_wrapper'); $('.dio_group.standard').tooltip(getTexts("labels", "std")); $('.dio_group.grepolis').tooltip(getTexts("labels", "gre")); $('.dio_group.nature').tooltip(getTexts("labels", "nat")); $('.dio_group.people').tooltip(getTexts("labels", "ppl")); $('.dio_group.Party').tooltip(getTexts("labels", "Par")); $('.dio_group.other').tooltip(getTexts("labels", "oth")); $('.dio_group.halloween').tooltip(getTexts("labels", "hal")); $('.dio_group.xmas').tooltip(getTexts("labels", "xma")); $('.dio_group.easter').tooltip(getTexts("labels", "eas")); $('.dio_group.love').tooltip(getTexts("labels", "lov")); $(bbcodeBarId + ' .dio_group').click(function () { $('.dio_group.active').removeClass("active"); $(this).addClass("active"); // Change smiley group if ($(this).closest('.bb_button_wrapper').parent().get(0).id == "") SmileyBox.addSmileys(this.className.split(" ")[1], "." + $(this).closest('.bb_button_wrapper').parent().get(0).className); else SmileyBox.addSmileys(this.className.split(" ")[1], "#" + $(this).closest('.bb_button_wrapper').parent().get(0).id); }); SmileyBox.addSmileys("standard", bbcodeBarId); // smiley box toggle $(bbcodeBarId + " .dio_smiley_button").toggleClick( function () { this.src = smileyArray.button[0].src; $(this).closest('.bb_button_wrapper').find(".dio_smiley_box").get(0).style.display = "block"; }, function () { this.src = smileyArray.button[1].src; $(this).closest('.bb_button_wrapper').find(".dio_smiley_box").get(0).style.display = "none"; } ); } catch (error) { errorHandling(error, "SmileyBox (add)"); } }, // insert smileys from arrays into smiley box addSmileys: (type, bbcodeBarId) => { try { // reset smilies if ($(bbcodeBarId + " .dio_box_content").get(0)) { $(bbcodeBarId + " .dio_box_content").get(0).innerHTML = ''; } // add smilies for (var e in smileyArray[type]) { if (smileyArray[type].hasOwnProperty(e)) { $(smileyArray[type][e]).clone().appendTo(bbcodeBarId + " .dio_box_content"); //$('').appendTo(bbcodeBarId + " .dio_box_content"); } } $(bbcodeBarId + " .dio_box_content .smiley").click(function () { var textarea; // hide smiley box $(this).closest('.bb_button_wrapper').find(".dio_smiley_button").click(); // find textarea textarea = $(this).closest('.gpwindow_content').find("textarea").get(0); if (textarea == undefined) textarea = $(this).closest('.window_content').find("textarea").get(0); var text = $(textarea).val(); $(textarea).val(text.substring(0, $(textarea).get(0).selectionStart) + "[img]" + this.src + "[/img]" + text.substring($(textarea).get(0).selectionEnd)); }); } catch (error) { errorHandling(error, "SmileyBox (addSmileys)"); } } }; /******************************************************************************************************************************* * Favor Popup * ---------------------------------------------------------------------------------------------------------------------------- * | ● Improved favor popup * ---------------------------------------------------------------------------------------------------------------------------- *******************************************************************************************************************************/ var FavorPopup = { godArray: { zeus: 'zeus', athena: 'athena', poseidon: 'poseidon', hera: 'hera', hades: 'hades', artemis: 'artemis', aphrodite: 'aphrodite', ares: 'ares' }, activate: () => { $('.gods_area').bind('mouseover', function () { FavorPopup.setFavorPopup(); }); //Update 2.231 $('
    ').appendTo('.gods_favor_amount'); $('
    ').appendTo('.gods_favor_amount'); }, setFavorPopup: () => { try { var pic_row = "", fav_row = "", prod_row = "", tooltip_str, textColor, tooltip_fury; for (var g in FavorPopup.godArray) { if (FavorPopup.godArray.hasOwnProperty(g)) { if (uw.ITowns.player_gods.attributes.temples_for_gods[g]) { pic_row += '
    '; textColor = ((uw.ITowns.player_gods.attributes[g + "_favor"]) == uw.ITowns.player_gods.attributes.max_favor) ? textColor = "color:red;" : textColor = "color:blue"; fav_row += '' + uw.ITowns.player_gods.attributes[g + "_favor"] + ''; prod_row += '' + uw.ITowns.player_gods.attributes.production_overview[g].production + ''; } } } var fury_row = "" var fury_max = uw.ITowns.player_gods.attributes.max_fury textColor = ((uw.ITowns.player_gods.attributes.fury) == fury_max) ? textColor = "color:red;" : textColor = "color:blue"; fury_row = '' + uw.ITowns.player_gods.attributes.fury + '/' + fury_max + ''; tooltip_str = $('
    ' + pic_row + '' + '' + fav_row + '' + '' + prod_row + '' + '
    +
    '); tooltip_fury = $('
    ' + fury_row + '
    '); //Update 2.231 $('#dio_FavorPopup').tooltip(tooltip_str); $('#dio_FuryPopup').tooltip(tooltip_fury); } catch (error) { errorHandling(error, "FavorPopup (setFavorPopup)"); } }, deactivate: () => { $('.gods_area').unbind('mouseover'); $('#dio_FavorPopup').remove(); $('#dio_FuryPopup').remove(); $('#dio-amount').remove(); }, }; /******************************************************************************************************************************* * GUI Optimization * ---------------------------------------------------------------------------------------------------------------------------- * | ● Minimize daily reward-window on startup * | ● Larger taskbar * | ● Improved display of troops and trade activity boxes (movable with position memory on startup) * ---------------------------------------------------------------------------------------------------------------------------- *******************************************************************************************************************************/ // Minimize Daily reward window on startup var Reward = { activate: () => { if (MutationObserver) { var startup = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { if (mutation.addedNodes[0]) { if ($('.daily_login').get(0)) { // && !uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).isMinimized() $('.daily_login').find(".minimize").click(); //uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_SHOW_ON_LOGIN).minimize(); } } }); }); startup.observe($('body').get(0), { attributes: false, childList: true, characterData: false }); setTimeout(() => { startup.disconnect(); }, 3000); } }, deactivate: () => { }, }; // Larger taskbar var Taskbar = { activate: () => { $('.minimized_windows_area').get(0).style.width = "150%"; $('.minimized_windows_area').get(0).style.left = "-25%"; }, deactivate: () => { $('.minimized_windows_area').get(0).style.width = "100%"; $('.minimized_windows_area').get(0).style.left = "0%"; } }; /******************************************************************************************************************************* * Activity boxes * ---------------------------------------------------------------------------------------------------------------------------- * | ● Show troops and trade activity boxes * | ● Boxes are magnetic & movable (position memory) * ---------------------------------------------------------------------------------------------------------------------------- *******************************************************************************************************************************/ var ActivityBoxes = { timeout: null, activate: () => { try { //if (0 == $("#dio_taclWrap").length) $("#toolbar_activity_commands_list").wrap($("
    ", {"class":"dio_taclWrap", id:"dio_taclWrap"})) $("#toolbar_activity_recruits_list").hover( function () { if ($("#dio_plusmenuRecruits").length == 0) { $("#toolbar_activity_recruits_list").append('
    '); $('#dio_plusmenuRecruits .dio_plusback').click(() => { dio_plus_destroy("dio_plusmenuRecruits"); }); $('#dio_plusmenuRecruits .dio_plusback').tooltip(dio_icon); } }, function () { $('#dio_plusmenuRecruits').remove(); } ); $("#toolbar_activity_commands_list .sandy-box").hover( function () { if ($("#dio_plusmenuCommands").length == 0) { $("#toolbar_activity_commands_list .sandy-box").append('
    '); $('#dio_plusmenuCommands .dio_plusback').click(() => { dio_plus_destroy("dio_plusmenuCommands"); }); $('#dio_plusmenuCommands .dio_plusback').tooltip(dio_icon); } }, function () { $('#dio_plusmenuCommands').remove(); }); $("#toolbar_activity_trades_list").hover( function () { if ($("#dio_plusmenuTrades").length == 0) { $("#toolbar_activity_trades_list").append('
    '); $('#dio_plusmenuTrades .dio_plusback').click(() => { dio_plus_destroy("dio_plusmenuTrades"); }); $('#dio_plusmenuTrades .dio_plusback').tooltip(dio_icon); } }, function () { $('#dio_plusmenuTrades').remove(); } ); $("#toolbar_activity_temple_commands_list").hover( function () { if ($("#dio_plusmenuTemple_commands").length == 0) { $("#toolbar_activity_temple_commands_list").append('
    '); $('#dio_plusmenuTemple_commands .dio_plusback').click(() => { dio_plus_destroy("dio_plusmenuTemple_commands"); }); $('#dio_plusmenuTemple_commands .dio_plusback').tooltip(dio_icon); } }, function () { $('#dio_plusmenuTemple_commands').remove(); } ); $('').appendTo('head'); $('#toolbar_activity_recruits_list').draggable({ cursor: "move", handle: ".dio_plusdraghandle", start: function () { $("#dio_plusmenuRecruitsSTYLE").remove(); $('#toolbar_activity_recruits_list').addClass("displayImp"); $(".dio_plusdraghandle").css({ cursor: "grabbing" }); }, stop: function () { $(".dio_plusdraghandle").css({ cursor: "grab" }); var dio_position = $('#toolbar_activity_recruits_list').position(); $('').appendTo('head'); } }); $('#toolbar_activity_commands_list .sandy-box').draggable({ cursor: "move", handle: ".dio_plusdraghandle", start: function () { $("#dio_plusmenuCommandsSTYLE").remove(); $('#toolbar_activity_commands_list').addClass("displayImp"); $('#toolbar_activity_commands_list').addClass("dio_commands"); clearTimeout(ActivityBoxes.timeout); ActivityBoxes.timeout = null; var dio_position = $('#toolbar_activity_commands_list .sandy-box').position(); if (dio_position.left === 0 && dio_position.top === 0) $("#toolbar_activity_commands_list .sandy-box").css({ "top": "+40px !important" }); $(".dio_plusdraghandle").css({ cursor: "grabbing" }); }, stop: function () { $(".dio_plusdraghandle").css({ cursor: "grab" }); ActivityBoxes.add() var dio_position = $('#toolbar_activity_commands_list .sandy-box').position(); $('').appendTo('head'); } }); $('#toolbar_activity_trades_list').draggable({ cursor: "move", handle: ".dio_plusdraghandle", start: function () { $("#dio_plusmenuTradesSTYLE").remove(); $('#toolbar_activity_trades_list').addClass("displayImp"); $(".dio_plusdraghandle").css({ cursor: "grabbing" }); }, stop: function () { $(".dio_plusdraghandle").css({ cursor: "grab" }); var dio_position = $('#toolbar_activity_trades_list').position(); $('').appendTo('head'); } }); $('#toolbar_activity_temple_commands_list').draggable({ cursor: "move", handle: ".dio_plusdraghandle", start: function () { $("#dio_plusmenuTemple_commandsSTYLE").remove(); $('#toolbar_activity_temple_commands_list').addClass("displayImp"); $(".dio_plusdraghandle").css({ cursor: "grabbing" }); }, stop: function () { $(".dio_plusdraghandle").css({ cursor: "grab" }); var dio_position = $('#toolbar_activity_temple_commands_list').position(); $('').appendTo('head'); } }); function dio_plus_destroy(dioJQselector) { if (dioJQselector == "dio_plusmenuCommands") { $("#" + dioJQselector).parent().parent().removeClass("displayImp"); $('#toolbar_activity_commands_list').removeClass("dio_commands"); $('').appendTo('head'); clearTimeout(ActivityBoxes.timeout); ActivityBoxes.timeout = null; $('#toolbar_activity_commands_list .cancel').click(); } else $("#" + dioJQselector).parent().removeClass("displayImp"); $("#" + dioJQselector + "STYLE").remove(); } $('#toolbar_activity_recruits').dblclick(() => { dio_plus_destroy("dio_plusmenuRecruits"); }); $('#toolbar_activity_commands').dblclick(() => { dio_plus_destroy("dio_plusmenuCommands"); }); $('#toolbar_activity_trades').dblclick(() => { dio_plus_destroy("dio_plusmenuTrades"); }); $('#toolbar_activity_temple_commands').dblclick(() => { dio_plus_destroy("dio_plusmenuTemple_commands"); }); } catch (error) { errorHandling(error, "ActivityBoxes"); } }, add: () => { ActivityBoxes.timeout = setInterval(() => { $("#toolbar_activity_commands").trigger("mouseenter"); }, 1000); }, deactivate: () => {// toolbar_activity_temple_commands $('#dio_plusmenustyle').remove(); $('#dio_plusmenuRecruits').remove(); $("#dio_plusmenuRecruitsSTYLE").remove(); $('#dio_plusmenuCommands').remove(); $("#dio_plusmenuCommandsSTYLE").remove(); $('#dio_plusmenuTrades').remove(); $('#dio_plusmenuTradesSTYLE').remove(); $('#dio_plusmenuTemple_commands').remove(); $("#dio_plusmenuTemple_commandsSTYLE").remove(); clearTimeout(ActivityBoxes.timeout); ActivityBoxes.timeout = null; }, }; /******************************************************************************************************************************* * BBCode * ---------------------------------------------------------------------------------------------------------------------------- * | ● Town BBCode : Adds the town bbcode to the town tab * | ● BBcode button Player Info : Addition of a BBcode button (player and alliance) * ---------------------------------------------------------------------------------------------------------------------------- *******************************************************************************************************************************/ var Townbb = { activate: () => { Townbb.addButton(); // Style $('').appendTo("head"); }, deactivate: () => { $('#dio_townbb').remove(); $('#dio_townbb_style').remove(); $('#input_townbb').remove(); }, addButton: () => { try { $('').appendTo('.town_name_area'); $('').appendTo('.town_name_area').tooltip(dio_icon + getTexts("messages", "copy")); $("#dio_townbb").click(() => { $('#dio_townbb-clipboard').toggle(); $("#input_townbb").toggle(); $("#input_townbb").val("[town]" + uw.Game.townId + "[/town]"); }); // clipboard setTimeout(() => { dio.clipboard('#dio_townbb-clipboard', '#input_townbb', "Townbb (addButton clipboard)", null); }, 2000) // Tooltip $('#dio_townbb').tooltip(dio_icon + 'BBCode ' + uw.DM.getl10n("market").city); $('#dio_townbb-clipboard').tooltip(dio_icon + 'BBCode ' + uw.DM.getl10n("market").city); } catch (error) { errorHandling(error, "Townbb (addButton)"); } }, update: () => { $("#input_townbb").val("[town]" + uw.Game.townId + "[/town]"); }, }; // Fix icon update when switching cities function townNameObsCall() { //console.log('test') if (DATA.options.dio_tic) updateIcon() if (DATA.options.dio_Tow) Townbb.update(); if (DATA.options.dio_tra) setTimeout(() => { TransportCapacity.update(); }, 20) if (DATA.options.dio_Rtt) dio.removeTooltipps(); }; let townName = $('div.town_name.js-townname-caption.js-rename-caption.ui-game-selectable')[0]; const townNameObsConfig = { characterData: false, attributes: false, childList: true, subtree: false }; const townNameObserver = new MutationObserver(townNameObsCall); townNameObserver.observe(townName, townNameObsConfig); /******************************************************************************************************************************* * ● BBcode button Player Info : Addition of a BBcode button (player and alliance) *******************************************************************************************************************************/ var nb_clipboard = 0, nb_clipboard_ally = 0 var BBtowninfo = { activate: () => { if ($('.dio_BBplayer').get(0)) { $('div#info_tab_content div#towninfo_towninfo div.game_border ul.game_list li.even img, div#info_tab_content div#towninfo_towninfo div.game_border ul.game_list li.odd.clearfix').css({ "padding-left": "23px" }); } $('').appendTo("head"); BBtowninfo.add("player") BBtowninfo.add("alliance") BBtowninfo.add("info") }, add: (action) => { let gpwnd, action_class, action_id_ally, action_id = action, each_player = '#player_info.bold h3'; if (action == "info") { each_player = $('.gp_player_link').parent().parent().find('.list_item_left'); action_id = "player"; } if (action == "alliance") each_player = '#player_info h3.bold'; action_class = action_id action_id = action_id + nb_clipboard action_id_ally = "alliance" + nb_clipboard_ally // Sélectionnez tous les éléments h3 enfants de #player_info $(each_player).each(function () { if (!$(this).parent().find('.dio_BB' + action_class).get(0)) { nb_clipboard++ //$(this).parent().parent().find('#player_info h3').css({ "margin-right": "-400px" }); // Ajoutez le contenu à l'intérieur de chaque élément h3 if (action == "info") { $(this).parent().parent().find('.even img').css({ "padding-left": "23px" }); $(this).parent().find('.list_item_left').append('
    '); $(this).parent().find('.list_item_left').append(''); } else { $(this).before('
    '); $(this).before('
    '); } $(this).parent().find('#dio_BB' + action_id).click(function (e) { $(this).parent().parent().find('#dio_clipboard-' + action_id).toggle(); $(this).parent().parent().find('#input_BB' + action_id).toggle(); let text = ""; if (action == "info") text = "[player]" + $(this).parent().find("a.gp_player_link").text().trim() + "[/player]"; else if (action == "alliance") text = "[ally]" + $(this).parent().parent().parent().parent().find('.ui-dialog-title').text().trim() + "[/ally]"; else text = "[player]" + $(this).parent().parent().find("#player_info h3").text().trim() + "[/player]"; $(this).parent().find('#input_BB' + action_id).val(text); }); dio.clipboard('#dio_clipboard-' + action_id, '#input_BB' + action_id, "BBtowninfo (add)", null); if (action == "alliance") $(this).parent().find('#dio_BB' + action_id).tooltip(dio_icon + 'BBCode ' + uw.DM.getl10n("bbcodes").ally.name); else $(this).parent().find('#dio_BB' + action_id).tooltip(dio_icon + 'BBCode ' + uw.DM.getl10n("bbcodes").player.name); $(this).parent().find('#dio_clipboard-' + action_id).tooltip(dio_icon + getTexts("messages", "copy")); } }); let each_alliance = "#player_info a[onclick^='Layout.allianceProfile.open']"; if (action == "info") each_alliance = ".game_list a[onclick^='Layout.allianceProfile.open']"; $(each_alliance).each(function () { if (!$(this).parent().find('.dio_BBalliance').get(0)) { nb_clipboard_ally++ // Ajoutez le contenu à l'intérieur de chaque élément h3 if (action == "info") { $(this).parent().parent().find('.odd.clearfix').css({ "padding-left": "23px" }); $(this).parent().parent().find('.odd.clearfix').append('
    '); $(this).parent().parent().find('.odd.clearfix').append(''); } else { $(this).before('
    '); $(this).before('
    '); } $(this).parent().find('#dio_BB' + action_id_ally).click(function (e) { $(this).parent().find('#dio_clipboard-' + action_id_ally).toggle(); $(this).parent().find('#input_BB' + action_id_ally).toggle(); $(this).parent().find('#input_BB' + action_id_ally).val("[ally]" + dio.Extract_alliance($(this).parent().find("a[onclick^='Layout.allianceProfile.open']")) + "[/ally]"); }); dio.clipboard('#dio_clipboard-' + action_id_ally, '#input_BB' + action_id_ally, "BBtowninfo (add)", null); $(this).parent().find('#dio_BB' + action_id_ally).tooltip(dio_icon + 'BBCode ' + uw.DM.getl10n("bbcodes").ally.name); $(this).parent().find('#dio_clipboard-' + action_id_ally).tooltip(dio_icon + getTexts("messages", "copy")); } }); }, towninfo: (c) => { try { var MH = false; if (typeof (uw.mhCol) !== "undefined") { MH = true; $('div#gpwnd_' + c + ' #town_bbcode_id').css({ "margin-right": "22px" }); } // Function if (!$('#gpwnd_' + c + ' .dio_clipboard-town').get(0)) { // clipboard town $('div#gpwnd_' + c + ' #town_bbcode_link').append(''); $('div#gpwnd_' + c + ' #town_bbcode_link').click(() => { $('#dio_gpwnd_' + c + '_clipboard-town').toggle(); }); // Clipboard dio.clipboard('#dio_gpwnd_' + c + '_clipboard-town', '#input_gpwnd_' + c + '_BBtown', "BBtowninfo (add)", null); }; } catch (error) { errorHandling(error, "BBtowninfo (towninfo)"); } }, deactivate: () => { $('#dio_BBtowninfo_style').remove(); $('.input_BBplayer,.input_BBalliance').css({ "display": "none" }); $('div#info_tab_content div#towninfo_towninfo div.game_border ul.game_list li.even img, div#info_tab_content div#towninfo_towninfo div.game_border ul.game_list li.odd.clearfix').css({ "padding-left": "0px" }); }, }; /******************************************************************************************************************************* * Building Overview * ---------------------------------------------------------------------------------------------------------------------------- * | ● Culture overview : Add a counter for the party in the culture view. Quack function * | ● Culture Progress : * ---------------------------------------------------------------------------------------------------------------------------- *******************************************************************************************************************************/ var buildingControl = { activate: () => { $('').appendTo("head"); if ($('#building_overview_table_wrapper').length) { buildingControl.init(); } }, init: () => { try { var buil = Overviews.Buildings, diff = Overviews.Buildings_Dif, selection; var sort_options = [ ["option_s", uw.DM.getl10n("mass_recruit").sort_by.name, true], ["option_s ok", uw.DM.getl10n("mass_recruit").sort_by.points, true], ["option_s resource wood_img", "wood"], ["option_s resource stone_img", "stone"], ["option_s resource iron_img", "iron"], ["option_s resource pop_img", "pop"], ["option_s unit building_icon40x40 main", "main"], ["option_s unit building_icon40x40 hide", "hide"], ["option_s unit building_icon40x40 lumber", "lumber"], ["option_s unit building_icon40x40 stoner", "stoner"], ["option_s unit building_icon40x40 ironer", "ironer"], ["option_s unit building_icon40x40 market", "market"], ["option_s unit building_icon40x40 docks", "docks"], ["option_s unit building_icon40x40 barracks", "barracks"], ["option_s unit building_icon40x40 wall", "wall"], ["option_s unit building_icon40x40 storage", "storage"], ["option_s unit building_icon40x40 farm", "farm"], ["option_s unit building_icon40x40 academy", "academy"], ["option_s unit building_icon40x40 temple", "temple"], ["option_s unit building_icon40x40 theater", "theater"], ["option_s unit building_icon40x40 thermal", "thermal"], ["option_s unit building_icon40x40 library", "library"], ["option_s unit building_icon40x40 lighthouse", "lighthouse"], ["option_s unit building_icon40x40 tower", "tower"], ["option_s unit building_icon40x40 statue", "statue"], ["option_s unit building_icon40x40 oracle", "oracle"], ["option_s unit building_icon40x40 trade_office", "trade_office"], ]; var diff_options = [["option", ">", true], ["option", "=", true], ["option", "<", true],]; $("#fixed_table_header").parent().append(''); Classtest(buil) setTimeout(() => { $('#fixed_table_header .' + buil).addClass("dio_sel") $('#fixed_table_header .building_icon40x40').append('
    ') sort($("#dio_building_overview .dio_drop_Select")[0].innerText, false, true); }, 50); if (Overviews.Buildings_order) $("#dio_button_sort").addClass('active') $('#fixed_table_header').each(function () { $(this).click(function (e) { if ($(e.target)[0].id == "fixed_table_header" || $(e.target)[0].parentNode.className.split(" ")[0] == "game_arrow_left" || $(e.target)[0].parentNode.className.split(" ")[0] == "game_arrow_right") { } else { selection = $(e.target)[0].parentNode.className.split(" ")[2]; if ($(e.target)[0].className.split(" ")[1] == undefined) sort(selection, true, true); else sort(selection, true); saveValue("Overviews", JSON.stringify(Overviews)); } }); }); function Classtest(buil) { $('#dio_select').removeClass(); $(".dio_drop_Select .border-left").css({ "right": "auto", "left": "0", "z-index": 0 }); $(".dio_drop_Select .caption").css({ "left": "auto", "width": "auto", }); if (buil == uw.DM.getl10n("mass_recruit").sort_by.name || buil == uw.DM.getl10n("mass_recruit").sort_by.points) { } else if (buil == "wood" || buil == "stone" || buil == "iron" || buil == "pop") { $('#dio_select').addClass("resource " + buil + "_img"); $(".dio_drop_Select .border-left").css({ "right": "19px", "left": "auto", "z-index": 1 }); $(".dio_drop_Select .caption").css({ "left": "54px", "width": "3px", }); } else { $('#dio_select').addClass("building_icon50x50 " + buil); $(".dio_drop_Select .border-left").css({ "right": "19px", "left": "auto", "z-index": 1 }); } $('#fixed_table_header .dio_sel').removeClass("dio_sel"); $('#fixed_table_header .' + buil).addClass("dio_sel") if (buil === uw.DM.getl10n("mass_recruit").sort_by.name) { $("#dio_sortfilterbox").css({ "display": "block" }); $("#dio_numberbox").css({ "display": "none" }); } else { $("#dio_sortfilterbox").css({ "display": "none" }); $("#dio_numberbox").css({ "display": "block" }); } } // click events of the drop menu $('#dio_building_overview .select_rec .option_s').each(function () { $(this).click(function (e) { dio.drop_menu(this, '.dio_drop_Select', "Buildings"); Classtest(Overviews.Buildings) sort($("#dio_building_overview .dio_drop_Select")[0].innerText, false, true); }); }); $('#dio_building_overview .select_rec_diff .option').each(function () { $(this).click(function (e) { dio.drop_menu(this, '.dio_drop_diff', "Buildings_Dif"); sort($("#dio_building_overview .dio_drop_Select")[0].innerText, false, true); }); }); // show & hide drop menus on click $('#dio_building_overview .dio_drop_Select').click(function (e) { dio.drop_menus_open('.select_rec', '.select_rec_diff') }); $('#dio_building_overview .dio_drop_diff').click(function (e) { dio.drop_menus_open('.select_rec_diff', '.select_rec') }); $("#dio_building_overview .caption").attr("name", buil); $('#dio_building_overview .dio_drop_Select').tooltip(dio_icon); $('#dio_sort').tooltip(dio_icon); function sort(selection, filter, Sort) { if (!Sort) { Overviews.Buildings_order = !Overviews.Buildings_order; saveValue("Overviews", JSON.stringify(Overviews)); $("#dio_button_sort").toggleClass('active') } switch (selection) { case uw.DM.getl10n("mass_recruit").sort_by.name: selection = 'a.gp_town_link'; break; case uw.DM.getl10n("mass_recruit").sort_by.points: selection = '.towninfo_wrapper'; break; case "wood": selection = '.wood span.count'; break; case "stone": selection = '.stone span.count'; break; case "iron": selection = '.iron span.count'; break; case "pop": selection = '.town_population span.count'; break; default: selection = '.' + selection + ' a.current_level'; } $('#fixed_table_header .building_icon40x40 #dio_sort').attr("Class", ""); $('#fixed_table_header .building_icon40x40 #dio_sort').addClass('sorting') if (selection !== 'a.gp_town_link' || selection !== '.Points') { if (!Overviews.Buildings_order) { $(selection.split(" ")[0] + ' #dio_sort').removeClass("sorting_desc"); $(selection.split(" ")[0] + ' #dio_sort').addClass("sorting_asc"); } else { $(selection.split(" ")[0] + ' #dio_sort').removeClass("sorting_asc"); $(selection.split(" ")[0] + ' #dio_sort').addClass("sorting_desc"); } } if (!filter) setfilter(selection); var dio_ArrayUnsorted = $('#building_overview>tbody>tr').get(); dio_ArrayUnsorted.sort(function (a, b) { if (selection == '.towninfo_wrapper') { a = parseInt($($(a).find(selection)[0].children[1]).text().split(" ")[0]) || 0; b = parseInt($($(b).find(selection)[0].children[1]).text().split(" ")[0]) || 0; } else if (selection !== 'a.gp_town_link') { a = parseInt($(a).find(selection).text()) || 0; b = parseInt($(b).find(selection).text()) || 0; } else { a = $(a).find(selection).text().toLowerCase(); b = $(b).find(selection).text().toLowerCase(); if (Overviews.Buildings_order) { return a.localeCompare(b); } else { return b.localeCompare(a); } } if (Overviews.Buildings_order) { return b - a } else { return a - b } }); for (var i = 0; i < dio_ArrayUnsorted.length; i++) { dio_ArrayUnsorted[i].parentNode.appendChild(dio_ArrayUnsorted[i]); } }; function isNumber(n) { return !isNaN(parseFloat(n)) && isFinite(n); } function setfilter(selection) { $('#building_overview>tbody>tr').show(); var uio, numericfilter; if (selection == 'a.gp_town_link') uio = '#dio_sortfilterbox'; else uio = '#dio_numberbox'; if (isNumber($(uio).val())) { var dif = $("#dio_building_overview .dio_drop_diff")[0].innerText if (selection == 'a.gp_town_link') numericfilter = parseInt($('#dio_sortfilterbox').val()); else numericfilter = parseInt($('#dio_numberbox').val()); $('#building_overview>tbody>tr').each(function (i, e) { var selectedSort = ""; if (selection == 'a.gp_town_link') { selectedSort = $(e).find(selection).text(); if (!(selectedSort.indexOf(numericfilter) >= 0)) $(e).hide(); } else if (selection == '.towninfo_wrapper') { selectedSort = parseInt($($(e).find(selection)[0].children[1]).text().split(" ")[0]) || 0; } else { selectedSort = parseInt($(e).find(selection).text()) || 0; } if (numericfilter < selectedSort & dif == "<") $(e).hide(); if (numericfilter != selectedSort & dif == "=") $(e).hide(); if (numericfilter > selectedSort & dif == ">") $(e).hide(); }); } else { var namefilter = $('#dio_sortfilterbox').val(); $('#building_overview>tbody>tr').each(function (i, e) { var townname = $(e).find('a.gp_town_link').text(); if (namefilter.length > 0 && !(townname.indexOf(namefilter) >= 0)) { $(e).hide(); } }); } }; const cities = [] let cities_town = uw.ITowns.towns; $.each(cities_town, function (key, p) { cities.push({ name: p.name, points: p.getPoints() }); }); $('#suggestions').click(function (e) { $('#dio_sortfilterbox')[0].value = e.target.innerHTML; sort($("#dio_building_overview .dio_drop_Select")[0].innerText, false, true) $('#suggestions')[0].innerHTML = ""; }) $('#place_defense').click(function () { $('#suggestions')[0].innerHTML = ""; }) function suggestion() { const Search1 = $('#dio_sortfilterbox').val(); const result = cities.filter(item => item.name.toLowerCase().includes(Search1.toLowerCase())); let suggestion = ''; if (Search1 != '') { result.forEach(resultItem => { suggestion += `
    ${resultItem.name}
    ` }) } $('#suggestions')[0].innerHTML = suggestion; sort($("#dio_building_overview .dio_drop_Select")[0].innerText, false, true); } $('#dio_sortfilterbox').on("input", function () { suggestion(); },); $('#dio_numberbox').on("input", function () { sort($("#dio_building_overview .dio_drop_Select")[0].innerText, false, true); },); $("#dio_sortfilterbox").click(function (e) { setTimeout(() => { suggestion(); }, 10) }); $("#dio_button_sort").click(function (e) { sort($("#dio_building_overview .dio_drop_Select")[0].innerText, true); }); $('#dio_button_sort').tooltip(dio_icon + uw.DM.getl10n("heroes").transfer.sort_by.split(":")[0]); } catch (error) { errorHandling(error, "buildingControl (init)"); } }, grepo_input: (number, Style, ID, Text) => { if (number) return $('
    '); else return $('
    '); }, deactivate: () => { $('#dio_buildingControl_style').remove(); $('#dio_building_sort_control').remove(); $('#dio_building_overview').remove(); }, }; /******************************************************************************************************************************* * culture Overview * ---------------------------------------------------------------------------------------------------------------------------- * | ● Culture overview : Add a counter for the party in the culture view. Quack function * | ● culturePoints : * | ● Culture Progress : * | ● cultureControl : * ---------------------------------------------------------------------------------------------------------------------------- *******************************************************************************************************************************/ var cultureOverview = { timeout: null, activate: () => { if ($('#culture_points_overview_bottom').length) { cultureOverview.add(); } cultureOverview.timeout = setInterval(() => { if ($('#culture_points_overview_bottom').length) { cultureOverview.add(); } }, 50000); //0. $('').appendTo("head"); }, add: () => { try { var a = $("ul#cultur_overview_towns"); var b, c, d, e, f, i, j, k; f = 0; var g = $("ul#culture_overview_towns span.eta"); var h = $("#culture_points_overview_bottom #place_culture_count").text(); e = 0; b = $('a[class~="confirm"][class~="type_triumph"]'); d = $('a[class~="confirm"][class~="type_triumph"][class~="disabled"]'); if (d.length > 0) { for (f = 0; f < b.length; f++) { if ($(b[f]).attr("class").indexOf("disabled") > 1) { continue; c = $(b[f]).parents('li[id^="ov_town_"]'); var eltext = c[0].previousSibling; $(c).insertBefore($(d[0]).parents('li[id^="ov_town_"]')); $(eltext).insertBefore($(d[0]).parents('li[id^="ov_town_"]')) } } } e = 0; b = $('a[class~="confirm"][class~="type_theater"]'); d = $('a[class~="confirm"][class~="type_theater"][class~="disabled"]'); if (d.length > 0) { for (f = 0; f < b.length; f++) { if ($(b[f]).attr("class").indexOf("disabled") > 1) { continue; c = $(b[f]).parents('li[id^="ov_town_"]'); eltext = c[0].previousSibling; $(c).insertBefore($(d[0]).parents('li[id^="ov_town_"]')); $(eltext).insertBefore($(d[0]).parents('li[id^="ov_town_"]')) } } } e = 0; b = $('a[class~="confirm"][class~="type_party"]'); d = $('a[class~="confirm"][class~="type_party"][class~="disabled"]'); if (d.length > 0) { for (f = 0; f < b.length; f++) { if ($(b[f]).attr("class").indexOf("disabled") > 1) { continue; c = $(b[f]).parents('li[id^="ov_town_"]'); eltext = c[0].previousSibling; $(c).insertBefore($(d[0]).parents('li[id^="ov_town_"]')); $(eltext).insertBefore($(d[0]).parents('li[id^="ov_town_"]')) } } } /////// if ($('#dio_cultureBTN_wrapper').length == 0) { $("#culture_overview_wrapper").parent().append('
    ' + '
    ' + '
    '); if (!$("#dio_culture_sort_control").is(":visible")) $("#culture_overview_wrapper").css({ "top": "35px", "height": "+=-35px" }); var dio_cultureBTN_r_clicked_last = ""; function hideTownElements(JQelement) { var dio_cultureBTN_mode = ""; switch (JQelement.id) { case "dio_cultureBTN_cityfestival_r": dio_cultureBTN_mode = "ul li:eq(0)"; break; case "dio_cultureBTN_olympicgames_r": dio_cultureBTN_mode = "ul li:eq(1)"; break; case "dio_cultureBTN_triumph_r": dio_cultureBTN_mode = "ul li:eq(2)"; break; case "dio_cultureBTN_theather_r": dio_cultureBTN_mode = "ul li:eq(3)"; break; default: setTimeout(() => { uw.HumanMessage.error(dio_icon + "Error"); }, 0); break; } if (dio_cultureBTN_r_clicked_last === JQelement.id) { $("ul#culture_overview_towns li").filter(function () { return !!$(dio_cultureBTN_mode, this).find('.eta').length; }).toggle(); $("ul#culture_overview_towns li").filter(function () { return !!$(dio_cultureBTN_mode, this).find('.celebration_progressbar:not(:has(>.eta))').length; }).removeClass('hidden'); $(JQelement).toggleClass("culture_red"); } else { $("ul#culture_overview_towns li").show().filter(function () { return !!$(dio_cultureBTN_mode, this).find('.eta').length; }).hide(); $(".dio_cultureBTN_r").removeClass("culture_red"); $(JQelement).addClass("culture_red"); } dio_cultureBTN_r_clicked_last = JQelement.id; $(".dio_cultureBTN_r").css({ border: "2px groove #808080" }); $(".culture_red").css({ border: "2px groove #CC0000" }); } $(".dio_cultureBTN_r").click(function () { hideTownElements(this); }); } var dio_cultureCounter = { cityfestivals: 0, olympicgames: 0, triumph: 0, theather: 0 }; var dio_bashpoints = $("#culture_points_overview_bottom .points_count").text().split("/"); var dio_goldforgames = Math.floor($("#ui_box .gold_amount").text() / 50); dio_cultureCounter.triumph = Math.floor((parseInt(dio_bashpoints[0]) - parseInt(dio_bashpoints[1])) / 300) + 1; if (dio_cultureCounter.triumph < 0) { dio_cultureCounter.triumph = 0; } dio_cultureCounter.cityfestivals = $('a[class~="confirm"][class~="type_party"]:not(.disabled)').length; dio_cultureCounter.olympicgames = $('a[class~="confirm"][class~="type_games"]:not(.disabled)').length; if (dio_goldforgames < dio_cultureCounter.olympicgames) { dio_cultureCounter.olympicgames = dio_goldforgames; } dio_cultureCounter.theather = $('a[class~="confirm"][class~="type_theater"]:not(.disabled)').length; $("#dio_cultureBTN_cityfestival_r").text(dio_cultureCounter.cityfestivals); $("#dio_cultureBTN_olympicgames_r").text(dio_cultureCounter.olympicgames); $("#dio_cultureBTN_triumph_r").text(dio_cultureCounter.triumph); $("#dio_cultureBTN_theather_r").text(dio_cultureCounter.theather); $(".dio_cultureBTN_cityfestival").tooltip(dio_icon + getTexts("Quack", "cityfestivals") + " (" + pointNumber(dio_cultureCounter.cityfestivals) + ") "); $(".dio_cultureBTN_olympicgames").tooltip(dio_icon + getTexts("Quack", "olympicgames") + " (" + pointNumber(dio_cultureCounter.olympicgames) + ") "); $(".dio_cultureBTN_triumph").tooltip(dio_icon + getTexts("Quack", "triumph") + " (" + pointNumber(dio_cultureCounter.triumph) + ") "); $(".dio_cultureBTN_theather").tooltip(dio_icon + getTexts("Quack", "theater") + " (" + pointNumber(dio_cultureCounter.theather) + ") "); } catch (error) { errorHandling(error, "cultureOverview (add)"); } }, deactivate: () => { $("#dio_cultureOverview_style").remove(); $("#dio_cultureBTN_wrapper").remove(); clearTimeout(cultureOverview.timeout); cultureOverview.timeout = null; if (!$("#dio_culture_sort_control").is(":visible")) $("#culture_overview_wrapper").css({ "top": "0px", "height": "+=35px" }); }, }; var culturePoints = { timeout: null, activate: () => { if ($('#culture_points_overview_bottom').length || $("#place_container").length) { culturePoints.add(); } culturePoints.timeout = setInterval(() => { if ($('#culture_points_overview_bottom').length || $("#place_container").length) { culturePoints.add(); } }, 50000); //0. }, add: () => { try { let f, i, j, k, g, h; //let test = false; let test = 100; if ($("#culture_points_overview_bottom").length) { g = $("ul#culture_overview_towns span.eta"); h = $("#culture_points_overview_bottom #place_culture_count").text(); i = h.split("/"); j = parseInt(i[0]) + g.length; k = parseInt(i[1]) - j; //console.log(k); if (test != 100) { k = k - test; } if (h.indexOf("[") < 1) { if (k > 0) { $("#culture_points_overview_bottom #place_culture_count").append(" [-" + k + "]"); } else { $("#culture_points_overview_bottom #place_culture_count").append(" [] +" + k * -1 + "").find("span#dio_culture").countdown(culturePoints.heure(g, h, test)); } } else { if (k > 0) { $("#dio_culture").text("[-" + k + "]"); $("#dio_cultureplus").text(""); } else { $("#dio_culture").countdown(culturePoints.heure(g, h, test)) $("#dio_cultureplus").text(" +" + k * -1); } } h = $("#place_battle_points .points_background .points_count").text(); i = h.split("/"); j = parseInt(i[0]); k = parseInt(i[1]) - j; if (k > 0) { if (h.indexOf("[") < 1) { $("#place_battle_points .points_background .points_count").append(" [-" + k + "]"); } else { $("#dio_battle_points").text("[-" + k + "]"); } } }; if ($("#place_container").length) { let h = $("#place_container #place_culture_count").text(); let g = 0; let inProgress = parseInt($('#place_culture_in_progress').text().match(/[0-9]+/)); if (inProgress > 0) { g = inProgress; } i = h.split("/"); j = parseInt(i[0]) + g; k = parseInt(i[1]) - j; if (test != 100) { k = k - test; } if (h.indexOf("[") < 1) { if (k > 0) { $("#place_container #place_culture_count").append("[-" + k + "]"); } else { $("#place_container #place_culture_count").append(" [+" + k * -1 + "]"); } } else { if (k > 0) { $("#dio_cultureA").text("[-" + k + "]"); } else { $("#dio_cultureplusA").text(" [+" + k * -1 + "]"); } } } $('#dio_culture, #dio_cultureplus, #dio_cultureA, #dio_cultureplusA, #dio_battle_points, #dio_battle_pointsA').tooltip(dio_icon); } catch (error) { errorHandling(error, "culturePoints (add)"); } }, heure: (g, h, test) => { try { var f, i, j, k; i = h.split("/"); j = parseInt(i[0]) + g.length; k = parseInt(i[1]) - j; if (test != 100) { k = k - test; } if (k <= 0) { var l = new Array; for (f = 0; f < g.length; f++) { l.push(g[f].dataset.timestamp); } l.sort(); var m = l[l.length + k - 1]; } else { m = ""; culturePoints.add(); } } catch (error) { errorHandling(error, "culturePoints (heure)"); m = ""; } return m; }, deactivate: () => { $("#dio_culture").remove(); $("#dio_cultureplus").remove(); $("#dio_cultureA").remove(); $("#dio_cultureplusA").remove(); clearTimeout(culturePoints.timeout); culturePoints.timeout = null; }, }; var cultureProgress = { activate: () => { $('').appendTo('head'); cultureProgress.add(); }, add: () => { try { if ($("#place_culture_towns").is(":visible")) { let level = parseInt($('#place_culture_towns').text().split('/')[1]); let [currentCount, totalCount] = $('#place_culture_count').text().match(/[0-9]+/g); let inProgress = parseInt($('#place_culture_in_progress').text().match(/[0-9]+/)); let nbNeeded = (level - 1) * 3; let nbLeft = totalCount - currentCount; let percentLeft = 100 - nbLeft / nbNeeded * 100; let percentInProgress = inProgress / nbNeeded * 100; //Progress Bar if (!$("#culture_points_overview_bottom #dio-ProgressBar").length) $('
    ').insertBefore("#culture_points_overview_bottom #place_culture_bar"); if (!$("#place_container #dio-ProgressBar").length) $('
    ').insertBefore("#place_container #place_culture_bar"); $("#culture_points_overview_bottom #dio-Bar, #place_container #dio-Bar").css({ "width": "calc(" + percentLeft + "% - 1px)" }); $("#culture_points_overview_bottom #dio-ProgressBar, #place_container #dio-ProgressBar").css({ "width": percentInProgress + "%", "left": "calc(" + percentLeft + "% + 2px)", "max-width": "calc(" + (100 - percentLeft) + "% - 4px)" }); } } catch (error) { errorHandling(error, "cultureProgress"); } }, deactivate: () => { $("#dio-ProgressBar-style").remove(); $("#dio-ProgressBar").remove(); $("#dio-Bar").remove(); }, }; var cultureControl = { activate: () => { $('').appendTo("head"); if ($('#culture_points_overview_bottom').length) { cultureControl.init(); } }, val: "", init: () => { try { if (!$("#dio_cultureBTN_wrapper").is(":visible")) $("#culture_overview_wrapper").css({ "top": "35px", "height": "+=-35px" }); var buil = Overviews.Culture, diff = Overviews.Culture_Dif, hour_time = Overviews.hour, minute_time = Overviews.minute; var selection; var sort_options = [ ["option", uw.DM.getl10n("mass_recruit").sort_by.name, true], ["option", uw.DM.getl10n("inventory").tooltip.hours, true], ///["option", uw.DM.getl10n("construction_queue").research_time.split(":")[0], true], ]; var diff_options = [["option", ">", true], ["option", "=", true], ["option", "<", true],]; $("#culture_overview_wrapper").parent().append(''); if (Overviews.Culture_order) $("#dio_button_sort").addClass('active') const hr_element = '#dio_time-picker .hr', selec = "#dio_culture_overview .dio_drop_Select"; let d = new Date(), hour, minute; // EVENT LISTENERS /*$('#dio_time-picker .hr-up').click(hour_up); $('#dio_time-picker .hr-down').click(hour_down); $('#dio_time-picker .min-up').click(minute_up); $('#dio_time-picker .min-down').click(minute_down); $(hr_element).on('change', time_change); function time_change (e) { if ($(hr_element)[0].value !== '') { hour = e.target.value.split(":")[0]; minute = e.target.value.split(":")[1]; setTime(); } else sort(false, true) } function hour_up () { hour++; if (hour > 23) hour = 0; setTime(); } function hour_down () { hour--; if (hour < 0) hour = 23; setTime(); } function minute_up () { minute++; if (minute > 59) { minute = 0; if (hour != 23) hour++; else hour = 0 } setTime(); } function minute_down () { minute--; if (minute < 0) { minute = 59; if (hour != 0) hour--; else hour = 23 } setTime(); } function setTime () { $(hr_element)[0].value = formatTime(hour) + ':' + formatTime(minute); $('#dio_time-picker')[0].dataset.time = formatTime(hour) + ':' + formatTime(minute); sort(false, true) if ($(selec)[0].innerText === uw.DM.getl10n("construction_queue").research_time.split(":")[0]) { Overviews.hour = hour; Overviews.minute = minute; saveValue("Overviews", JSON.stringify(Overviews)); } } function formatTime (time) { try {if (JSON.stringify(time).length < 2) time = '0' + time;} catch (error) { return time} return time; }*/ Classtest(buil); function Classtest(buil) { if (buil === uw.DM.getl10n("mass_recruit").sort_by.name) { $("#dio_sortfilterbox").css({ "display": "block" }); $("#dio_time-picker").css({ "display": "none" }); } else { $("#dio_sortfilterbox").css({ "display": "none" }); $("#dio_time-picker").css({ "display": "block" }); if (buil === uw.DM.getl10n("construction_queue").research_time.split(":")[0]) { if (hour_time > 0 || minute_time > 0 && buil === uw.DM.getl10n("construction_queue").research_time.split(":")[0]) { hour = hour_time; minute = minute_time; } else { hour = 0; minute = 0; Overviews.hour = 0; Overviews.minute = 0; $(hr_element)[0].value = ""; return saveValue("Overviews", JSON.stringify(Overviews)); } } else { hour = d.getHours(); minute = d.getMinutes(); } ///setTime(); } } // click events of the drop menu $('#dio_culture_overview #dio_sort_towns .option').each(function () { $(this).click(function (e) { dio.drop_menu(this, '.dio_drop_Select', "Culture"); Classtest(Overviews.Culture) }); }); $('#dio_culture_overview #dio_diff_towns .option').each(function () { $(this).click(function (e) { dio.drop_menu(this, '.dio_drop_diff', "Culture_Dif") }); }); // show & hide drop menus on click $('#dio_culture_overview .dio_drop_Select').click(function (e) { dio.drop_menus_open('#dio_sort_towns', '#dio_diff_towns') }); $('#dio_culture_overview .dio_drop_diff').click(function (e) { dio.drop_menus_open('#dio_diff_towns', '#dio_sort_towns') }); function isNumber(n) { return !isNaN(parseFloat(n)) && isFinite(n); } function setfilter(selection) { $('#culture_overview_towns>li').show(); var uio, numericfilter, filter, filterstop; if (selection == 'a.gp_town_link') { uio = isNumber($('#dio_sortfilterbox').val()); if ($('#dio_sortfilterbox').val().length > 0) $("#dio_culture_sort_control .filterstop").css({ "display": "block" }); else $("#dio_culture_sort_control .filterstop").css({ "display": "none" }); } /*else { uio = $(hr_element)[0].value !== ''; if (uio) $("#dio_culture_sort_control .filterstop").css({ "display": "block" }); else $("#dio_culture_sort_control .filterstop").css({ "display": "none" }); }*/ if (uio) { var regexpInS = RegExp(/eta/); if (selection == 'a.gp_town_link') numericfilter = parseInt($('#dio_sortfilterbox').val()); else numericfilter = $('#dio_time-picker')[0].dataset.time; var diff = $(".dio_drop_diff")[0].innerText; var date = $("#dio_sort_towns").val(); $('#culture_overview_towns>li').each(function (i, e) { var selectedSort = ""; if (regexpInS.test(selection)) { /*if ($(selec)[0].innerText === uw.DM.getl10n("inventory").tooltip.hours) { try { let selectedDate = new Date(parseInt($(e).find(selection)[0].dataset.timestamp) * 1000) selectedSort = formatTime (selectedDate.getHours()) + ":" + formatTime (selectedDate.getMinutes()) } catch (error) { selectedSort = formatTime (new Date().getHours()) + ":" + formatTime (new Date().getMinutes())} } else {*/ try { const diffIn = dio.dateDiff(new Date(), new Date(parseInt($(e).find(selection)[0].dataset.timestamp) * 1000)); selectedSort = parseInt(diffIn.min + 60 * diffIn.hour); } catch (error) { selectedSort = 0; } ///} if ($(selec)[0].innerText !== uw.DM.getl10n("inventory").tooltip.hours) filter = parseInt(minute) + 60 * parseInt(hour); else filter = numericfilter if (filter < selectedSort & diff == "<") $(e).hide(); if (filter != selectedSort & diff == "=") $(e).hide(); if (filter > selectedSort & diff == ">") $(e).hide(); } else { selectedSort = $(e).find(selection).text(); if (!(selectedSort.indexOf(numericfilter) >= 0)) $(e).hide(); } }); } else { var namefilter = $('#dio_sortfilterbox').val(); $('#culture_overview_towns>li').each(function (i, e) { var townname = $(e).find('a.gp_town_link').text(); if (namefilter.length > 0 && !(townname.indexOf(namefilter) >= 0)) { $(e).hide(); } }); } }; function sort(filter, Sort) { selection = $(selec)[0].innerText; if (!Sort) { Overviews.Culture_order = !Overviews.Culture_order; saveValue("Overviews", JSON.stringify(Overviews)); $("#dio_button_sort").toggleClass('active') }; switch (selection) { case uw.DM.getl10n("inventory").tooltip.hours: case uw.DM.getl10n("construction_queue").research_time.split(":")[0]: selection = 'span.eta'; //selection = '.celebration_wrapper.small'; //$('a[class~="confirm"][class~="type_games"]')[4].parentNode.parentNode.parentNode.children[3].children[1].dataset.timestamp break; case uw.DM.getl10n("mass_recruit").sort_by.name: selection = 'a.gp_town_link'; break; } if (!filter) setfilter(selection); var dio_ArrayUnsorted = $('#culture_overview_towns>li').get(); dio_ArrayUnsorted.sort(function (a, b) { var regexpInS = RegExp(/eta/); //try {console.log($(a).find(selection)[0].children[1].children[3].children[1].dataset.timestamp) } catch (error) { "" } if (regexpInS.test(selection)) { //console.log("text") //try {console.log(parseInt($(a).find(selection)[0].dataset.timestamp)) || 0} catch (error) { } //try { a = parseInt($(a).find(selection)[0].children[1].children[3].children[1].dataset.timestamp) || 0 } catch (error) { a = 0 } //try { b = parseInt($(b).find(selection)[0].children[1].children[3].children[1].dataset.timestamp) || 0 } catch (error) { b = 0 } try { a = parseInt($(a).find(selection)[0].dataset.timestamp) || 0 } catch (error) { a = 0 } try { b = parseInt($(b).find(selection)[0].dataset.timestamp) || 0 } catch (error) { b = 0 } //console.log($(b).find(selection)) } else { a = $(a).find(selection).text().toLowerCase(); b = $(b).find(selection).text().toLowerCase(); if (Overviews.Culture_order) { return a.localeCompare(b); } else { return b.localeCompare(a); } } //console.log("text3") if (Overviews.Culture_order) { return b - a } else { return a - b } }); for (var i = 0; i < dio_ArrayUnsorted.length; i++) { dio_ArrayUnsorted[i].parentNode.appendChild(dio_ArrayUnsorted[i]); } $("#culture_overview_wrapper").scrollTop(200) $("#culture_overview_wrapper").scrollTop(0) } $('#dio_culture_sort_control .filterstop').click(function () { if ($(selec)[0].innerText === uw.DM.getl10n("mass_recruit").sort_by.name) { $('#dio_sortfilterbox')[0].value = ""; } else { $(hr_element)[0].value = ""; if (buil === uw.DM.getl10n("construction_queue").research_time.split(":")[0]) { Overviews.hour = 0; Overviews.minute = 0; saveValue("Overviews", JSON.stringify(Overviews)); } } sort(false, true); }) const cities = [] let cities_town = uw.ITowns.towns $.each(cities_town, function (key, p) { cities.push({ name: p.name, points: p.getPoints() }); }); $('#suggestions').click(function (e) { $('#dio_sortfilterbox')[0].value = e.target.innerHTML; sort(false, true); $('#suggestions')[0].innerHTML = ""; }) $('#wrapper, culture_points_overview_bottom').click(function () { $('#suggestions')[0].innerHTML = ""; }) function suggestion() { const Search1 = $('#dio_sortfilterbox').val(); const result = cities.filter(item => item.name.toLowerCase().includes(Search1.toLowerCase())); let suggestion = ''; if (Search1 != '') { result.forEach(resultItem => { suggestion += `
    ${resultItem.name}
    ` }) } $('#suggestions')[0].innerHTML = suggestion; sort(false, true); } $('#dio_sortfilterbox').on("input", function () { suggestion(); },); $('#dio_sort_towns, #dio_diff_towns').click(function () { sort(false, true) },); $("#dio_button_sort").click(function (e) { sort(true); }); $('#dio_button_sort').tooltip(dio_icon + uw.DM.getl10n("heroes").transfer.sort_by.split(":")[0]); $('a[class~="confirm"][class~="type_party"], a[class~="confirm"][class~="type_games"], a[class~="confirm"][class~="type_triumph"], a[class~="confirm"][class~="type_theater"]').on("click", function () { cultureControl.val = $('#dio_sortfilterbox').val() setTimeout(() => { fioo(); }, 500) function fioo() { //console.log("1") if (!$('.window_content.js-window-content .confirmation').is(":visible")) { setTimeout(() => { fio(); }, 500) } else setTimeout(() => { fioo() }, 500) } function fio() { //console.log("2") setTimeout(() => { sort(false, true) }, 100); setTimeout(() => { cultureControl.val = ""; }, 1000); uw.TownOverviewWindowFactory.openCultureOverview(); } },); sort(false, true) } catch (error) { errorHandling(error, "cultureControl (init)"); } }, grepo_input: (Style, ID, Text) => { return $('
    '); }, deactivate: () => { $('#dio_cultureControl_style').remove(); $('#dio_culture_sort_control').remove(); if (!$("#dio_cultureBTN_wrapper").is(":visible")) $("#culture_overview_wrapper").css({ "top": "0px", "height": "+=35px" }); }, }; /******************************************************************************************************************************* * Hides Overview * ---------------------------------------------------------------------------------------------------------------------------- * | ● City view button : Add a button for opening the city view to the sidemenu of Greplis. Quack function * | ● City view : Display the city view in a window. Quack function * ---------------------------------------------------------------------------------------------------------------------------- *******************************************************************************************************************************/ var hidesIndexIron = { timeout: null, activate: () => { hidesIndexIron.timeout = setInterval(() => { if ($('#hide_espionage').length || $('#hides_overview_wrapper').length) { if ($('#hide_espionage').length & !$('#dio_hidesIndexIron').get(0)) { hidesIndexIron.add2(); } if ($('#hides_overview_wrapper').length & !$('#dio_hidesIndexIron2').get(0)) { hidesIndexIron.add(); setTimeout(() => { $('#dio_hidesIndexIron2').remove(); }, 50000); } } }, 800); }, add: () => { try { if (!$("#dio_hidesIndexIron2").is(":visible") & $('#hides_overview_wrapper').length) { $('
    ').appendTo('#hides_overview_wrapper'); } var silver_total = 0; var city_boxes = $("#hides_overview_towns").find(".town_item"); function silverToInt(str) { return parseInt(str.split("/")[0].replace(/\D/g, "")) || 0; } if (silver_total === 0) { for (var a = 0; a < city_boxes.length; a++) { silver_total += silverToInt($(city_boxes[a]).find(".hide_progressbar").text()); } } for (var d = 0; d < city_boxes.length; d++) { var e = $(city_boxes[d]); silver_total += silverToInt(e.find(".hide_progressbar").text()); var f = e.find(".iron"); var g = Number(f.text().trim()); var h = e.find("input"); if (null != h.val() && g > 15e3) { h.val(g - 15e3).change(); e.find(".iron_img").click(); var i = uw.HidesOverview.spinners[e.find(".iron_img").attr("name")]; i.setValue(g - 15e3) } } } catch (error) { errorHandling(error, "hidesIndexIron 'add"); } }, add2: () => { try { if (!$("#dio_hidesIndexIron").is(":visible") & ('#hide_espionage').length) { $('
    ').appendTo('#hide_espionage'); } var b = uw.ITowns.getTown(parseInt(uw.Game.townId)).getCurrentResources().iron; if (b > 15e3) { $("#hide_espionage :input").val(b - 15e3); setTimeout(() => { $("#hide_espionage :input").select().blur(); }, 10); } else { $("#hide_espionage :input").val("0"); setTimeout(() => { $("#hide_espionage :input").select().blur(); }, 10); } } catch (error) { errorHandling(error, "hidesIndexIron (add2)"); } }, deactivate: () => { $('#dio_hidesIndexIron').remove(); $('#dio_hidesIndexIron2').remove(); clearTimeout(hidesIndexIron.timeout); hidesIndexIron.timeout = null; }, }; var hidesOverview = { activate: () => { $('').appendTo("head"); if ($('#hides_overview_wrapper').length) { hidesOverview.init(); } }, init: () => { try { //$("#wrapper.game_inner_box").css({ "top": "39px" }); $("#hides_overview_wrapper").css({ "height": "+=-39px" }); var silver_total = 0; var selection, order; var city_boxes = $("#hides_overview_towns").find(".town_item"); function silverToInt(str) { return parseInt(str.split("/")[0].replace(/\D/g, "")) || 0; } //if (QT.Settings.values.qmenu_settings_hidessort) { if (silver_total === 0) { for (var a = 0; a < city_boxes.length; a++) { silver_total += silverToInt($(city_boxes[a]).find(".hide_progressbar").text()); } } var sort_options = [ ["ironinstore", getTexts("caves", "stored_silver")], ["name", uw.DM.getl10n("mass_recruit").sort_by.name], ["wood", uw.DM.getl10n("mass_recruit").sort_by.wood], ["stone", uw.DM.getl10n("mass_recruit").sort_by.stone], ["iron", uw.DM.getl10n("mass_recruit").sort_by.iron] ]; $("#wrapper.game_inner_box").after(''); $('#dio_button_table_resize').tooltip(dio_icon); $('#dio_sortinit').tooltip(dio_icon + getTexts("caves", "search_for")); function table_resize_handler1() { $(this).addClass("active"); $("#hides_overview_towns").addClass("dio_resize"); city_boxes.each(function (index) { var iron_span_class = $(this).find(".box_content.res_box .iron SPAN:first-child").prop("class"); if (iron_span_class == "res_rare") { $(this).find(".iron_img").append(''); } else if (iron_span_class == "res_plenty") { $(this).find(".iron_img").append(''); } }); $(this).one("click", table_resize_handler2); } function table_resize_handler2() { $(this).removeClass("active"); $("#hides_overview_towns").removeClass("dio_resize"); city_boxes.find(".dio_res_plenty, .dio_res_rare").remove(); $(this).one("click", table_resize_handler1); } $('#dio_button_table_resize').one("click", table_resize_handler1); function isNumber(n) { return !isNaN(parseFloat(n)) && isFinite(n); } function setfilter(selection) { $('#hides_overview_towns>li').show(); if (isNumber($('#dio_sortfilterbox').val())) { var regexpRES = RegExp(/wood|stone|iron/); var regexpInS = RegExp(/eta/); var regexpNoT = RegExp(/gp_town_link/); var numericfilter = parseInt($('#dio_sortfilterbox').val()); $('#hides_overview_towns>li').each(function (i, e) { var selectedSort = ""; if (regexpRES.test(selection)) { selectedSort = parseInt($(e).find(selection).text()) || 0; } else if (regexpInS.test(selection)) { selectedSort = parseInt($(e).find(selection).text().substr(1)) || 0; } else { selectedSort = $(e).find(selection).text(); if (!(selectedSort.indexOf(numericfilter) >= 0)) { $(e).hide(); } } if (numericfilter > selectedSort) { $(e).hide(); } }); } else { var namefilter = $('#dio_sortfilterbox').val(); $('#hides_overview_towns>li').each(function (i, e) { var townname = $(e).find('a.gp_town_link').text(); if (namefilter.length > 0 && !(townname.indexOf(namefilter) >= 0)) { $(e).hide(); } }); } }; function sort(selection) { order = !order; switch (selection) { case "ironinstore": selection = 'span.eta'; break; case "name": selection = 'a.gp_town_link'; break; case "wood": selection = 'span.wood span.count'; break; case "stone": selection = 'span.stone span.count'; break; case "iron": selection = 'span.iron span.count'; break; } setfilter(selection); var dio_ArrayUnsorted = $('#hides_overview_towns>li').get(); dio_ArrayUnsorted.sort(function (a, b) { var regexpRES = RegExp(/wood|stone|iron/); var regexpInS = RegExp(/eta/); if (regexpRES.test(selection)) { a = parseInt($(a).find(selection).text()) || 0; b = parseInt($(b).find(selection).text()) || 0; } else if (regexpInS.test(selection)) { a = parseInt($(a).find(selection).text().substr(1)) || 0; b = parseInt($(b).find(selection).text().substr(1)) || 0; } else { a = $(a).find(selection).text().toLowerCase(); b = $(b).find(selection).text().toLowerCase(); if (order) { return a.localeCompare(b); } else { return b.localeCompare(a); } } if (order) { return b - a } else { return a - b } }); for (var i = 0; i < dio_ArrayUnsorted.length; i++) { dio_ArrayUnsorted[i].parentNode.appendChild(dio_ArrayUnsorted[i]); } } $("#dio_sortinit").click(function () { sort($("#dio_sort_towns").val()); $(this).toggleClass('active') }); } catch (error) { errorHandling(error, "hidesOverview (init)"); } }, refresh_silver_total: (xhr) => { var JQ_silver_total = $('#dio_hides_silver_total .silver_amount'); var silver_total = parseInt(JQ_silver_total.text()); var silver_stored = $.parseJSON(xhr.responseText).json.iron_stored; silver_total += silver_stored; JQ_silver_total.text(silver_total); }, grepo_dropdown: (ID, Options) => { var str = ''; return str; }, grepo_input: (Style, ID, Text) => { return $('
    '); }, deactivate: () => { $('#dio_hidesOverview_style').remove(); $('#dio_hides_sort_control').remove(); }, }; /******************************************************************************************************************************* * City view * ---------------------------------------------------------------------------------------------------------------------------- * | ● City view button : Add a button for opening the city view to the sidemenu of Greplis. Quack function * | ● City view : Display the city view in a window. Quack function * ---------------------------------------------------------------------------------------------------------------------------- *******************************************************************************************************************************/ var city_view_btn = { activate: () => { try { $('').appendTo('head'); $('#ui_box .nui_main_menu .middle .content ul li[data-option-id=cityview]').remove(); //$('').appendTo('#ui_box .nui_main_menu .middle .content ul').not("ul li ul"); $('#ui_box .nui_main_menu .middle .content ul li[data-option-id=messages]').removeClass("first"); //$('#ui_box .nui_main_menu .middle .content ul li[data-option-id=GRM_button]').addClass("messages main_menu_item first"); $('#ui_box .nui_main_menu .middle .content ul li[data-option-id=messages]').before('
    '); if ($("#GRM_button").is(":visible")) { $("#GRM_button").addClass('first'); $('#ui_box .nui_main_menu .middle .content ul li[data-option-id=dio_cityview]').removeClass("first"); $('').appendTo('head'); } function dio_island_overview() { $('#ui_box .nui_main_menu .middle .content ul li[data-option-id=dio_cityview] .icon').css({ 'background': 'url(' + Home_url + '/img/dio/logo/city-view.png) no-repeat -36px -0px', 'top': '8px', 'left': '5px' }); $('#ui_box .nui_main_menu .middle .content ul li[data-option-id=dio_cityview] .name').text(getTexts("grepo_mainmenu", "island_view")); } function dio_city_overview() { $('#ui_box .nui_main_menu .middle .content ul li[data-option-id=dio_cityview] .icon').css({ 'background': 'url(' + Home_url + '/img/dio/logo/city-view.png) no-repeat -3px 1px', 'top': '6px', 'left': '6px' }); $('#ui_box .nui_main_menu .middle .content ul li[data-option-id=dio_cityview] .name').text(uw.DM.getl10n("town_index").window_title); } // #Grepolis Fix: 2.287 -> 2.289 if (uw.GameEvents.ui.layout_mode) { $.Observer(uw.GameEvents.ui.layout_mode.city_overview.activate).subscribe('dio_city_overview', (e, data) => { dio_island_overview(); }); $.Observer(uw.GameEvents.ui.layout_mode.island_view.activate).subscribe('dio_island_view', (e, data) => { dio_city_overview(); }); $.Observer(uw.GameEvents.ui.layout_mode.strategic_map.activate).subscribe('dio_strategic_map', (e, data) => { dio_city_overview(); }); } else { $.Observer(uw.GameEvents.ui.bull_eye.radiobutton.city_overview.click).subscribe('dio_city_overview', (e, data) => { dio_island_overview(); }); $.Observer(uw.GameEvents.ui.bull_eye.radiobutton.island_view.click).subscribe('dio_island_view', (e, data) => { dio_city_overview(); }); $.Observer(uw.GameEvents.ui.bull_eye.radiobutton.strategic_map.click).subscribe('dio_strategic_map', (e, data) => { dio_city_overview(); }); } $('#ui_box .nui_main_menu .middle .content ul li[data-option-id=dio_cityview]').click(() => { if (!$("#ui_box .bull_eye_buttons .city_overview").hasClass('checked')) { $("#ui_box .bull_eye_buttons .city_overview").click(); } else { $("#ui_box .bull_eye_buttons .island_view").click(); } }); } catch (error) { errorHandling(error, "city_view_btn"); } }, deactivate: () => { $('#dio_cityview').remove(); $('#dio_cityview_style').remove(); $("#ui_box .nui_main_menu .middle .content ul li[data-option-id=messages]").addClass('first'); $('#ui_box .nui_main_menu .middle .content ul li[data-option-id=dio_cityview]').remove(); if ($("#GRM_button").is(":visible")) { $("#GRM_button").addClass('first'); $('#ui_box .nui_main_menu .middle .content ul li[data-option-id=messages]').removeClass("first"); $('').appendTo('head'); } }, }; var city_view_window = { activate: () => { try { if (DATA.options.dio_Ciw & (typeof (uw.MoleHoleOnBoard) == "undefined")) { $('').appendTo("head"); function WndHandlerDIOtownoverview(wndhandle) { this.wnd = wndhandle; } Function.prototype.inherits.call(WndHandlerDIOtownoverview, uw.WndHandlerDefault); WndHandlerDIOtownoverview.prototype.getDefaultWindowOptions = () => { return { height: 600, width: 800, minimizable: true, }; }; let city_overview, strategic_map, island_view; if (uw.GameEvents.ui.layout_mode) { // #Grepolis Fix: 2.287 -> 2.289 city_overview = uw.GameEvents.ui.layout_mode.city_overview.activate; strategic_map = uw.GameEvents.ui.layout_mode.strategic_map.activate; island_view = uw.GameEvents.ui.layout_mode.island_view.activate; } else { city_overview = uw.GameEvents.ui.bull_eye.radiobutton.city_overview.click; strategic_map = uw.GameEvents.ui.bull_eye.radiobutton.strategic_map.click; island_view = uw.GameEvents.ui.bull_eye.radiobutton.island_view.click; } WndHandlerDIOtownoverview.prototype.onClose = () => { $('#ui_box').append($('DIV.ui_city_overview')).append($('DIV.ui_construction_queue')); if ($("#minimap_canvas").hasClass('expanded')) { $.Observer(strategic_map).publish({}); } else { $.Observer(island_view).publish({}); } }; uw.GPWindowMgr.addWndType("DIO_TOWNOVERVIEW", "dio_townoverview", WndHandlerDIOtownoverview, 1); $.Observer(city_overview).subscribe('dio_city_overview_window', (e, data) => { if (DATA.options.dio_Ciw & (typeof (uw.MoleHoleOnBoard) == "undefined")) { var wnd = uw.GPWindowMgr.Create(uw.GPWindowMgr.TYPE_DIO_TOWNOVERVIEW) || uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_TOWNOVERVIEW); if (MID == 'zz' || dio_bug) { wnd.setTitle(getTexts("grepo_mainmenu", "city_view") + " - " + tName); } else { wnd.setTitle("
    " + getTexts("grepo_mainmenu", "city_view") + " - " + tName + "
    "); } var html = '
    '; wnd.setContent(html); var JQel = wnd.getJQElement(); JQel.find(".gpwindow_content").css({ "overflow": "hidden", "border": "1px solid black" }); JQel.find('#dio_townoverview').append($('DIV.ui_city_overview')).append($('DIV.ui_construction_queue')); $('DIV.ui_city_overview .town_background').css({ "transform": "translate(-597px, -315px)" }); } }); $("#ui_box .bull_eye_buttons .rb_map").on("rb:change:value", (e, value, old_value) => { if (value === 'island_view' || value === 'strategic_map') { var wnd = uw.GPWindowMgr.getOpenFirst(uw.Layout.wnd.TYPE_DIO_TOWNOVERVIEW); if (wnd) wnd.close(); } }); } } catch (error) { errorHandling(error, "city_view_window"); } }, deactivate: () => { $('#dio_city_view_style').remove(); if (uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_TOWNOVERVIEW)) { uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_TOWNOVERVIEW).close(); } city_btn_construction.deactivate(); }, }; var city_btn_construction = { activate: () => { let layout_mode; // #Grepolis Fix: 2.287 -> 2.289 if (uw.GameEvents.ui.layout_mode) layout_mode = uw.GameEvents.ui.layout_mode.city_overview.activate else layout_mode = uw.GameEvents.ui.bull_eye.radiobutton.city_overview.click if (!$('.city_overview_overlay.main').length) setTimeout(() => { $(".construction_queue_sprite.queue_button-idle.queue_button.btn_construction_mode.js-tutorial-btn-construction-mode").click(); }, 20); $.Observer(layout_mode).subscribe('dio_city_overview', () => { if (DATA.options.dio_Cic && !$('.city_overview_overlay.main').length) { setTimeout(() => { $(".construction_queue_sprite.queue_button-idle.queue_button.btn_construction_mode.js-tutorial-btn-construction-mode").click(); }, 20); } }); }, deactivate: () => { if ($('.city_overview_overlay.main').length) { $(".construction_queue_sprite.queue_button-idle.queue_button.btn_construction_mode.js-tutorial-btn-construction-mode").click(); } }, }; /******************************************************************************************************************************* * Holiday Special *******************************************************************************************************************************/ var HolidaySpecial = { isHalloween: false, isXmas: false, isNewYear: false, isEaster: false, activate: () => { // Xmas-Smileys -> 18 days HolidaySpecial.isXmas = dio.daystamp(344, 361); // 10. Dezember (344) / 28. Dezember (361) // NewYear -> 7 days HolidaySpecial.isNewYear = dio.daystamp(0, 7); // 1. Januar / 7. Januar if (HolidaySpecial.isXmas) { HolidaySpecial.XMas.add(); } if (HolidaySpecial.isNewYear) { HolidaySpecial.NewYear.add(); } }, XMas: { add: () => { if (MID == 'fr') { $('
    ').appendTo('#ui_box'); } else $('
    ').appendTo('#ui_box'); var dioXMAS = $('#dio_xmas'); dioXMAS.css({ background: 'url("' + Home_url + '/img/smileys/weihnachtsmann-nordpol.gif") no-repeat', height: '51px', width: '61px', position: 'absolute', bottom: '10px', left: '60px', zIndex: '4' }); dioXMAS.tooltip(getTexts("labels", "Merry")); } }, NewYear: { add: () => { var Year = new Date().getFullYear() + ""; // TODO: Jahreszahl dynamisch setzen $('
    ' + '' + '' + '' + '' + '
    ').appendTo('#ui_box'); var dioNewYear = $('#dio_newYear'); dioNewYear.css({ position: 'absolute', bottom: '10px', left: '70px', zIndex: '10' }); dioNewYear.tooltip(' ' + getTexts("labels", "Happy")); } } }; /******************************************************************************************************************************* * Scrollbar Style: Chrome, opera, safari *******************************************************************************************************************************/ var Scrollbar = { activate: () => { $('').appendTo('head'); Scrollbar.add(); }, add: () => { try { $('#dio_Scrollbar').remove(); //Blue (Bleu) if (DATA.options.dio_aaa) { Scrollbar.collor([145, 165, 193, 0.5], [37, 82, 188, 0.5], [37, 82, 188, 0.8], 'blue') } //Red (Rouge) else if (DATA.options.dio_bbb) { Scrollbar.collor([193, 145, 145, 0.5], [188, 37, 37, 0.5], [188, 37, 37, 0.8], 'red') } //Green (Vert) else if (DATA.options.dio_ccc) { Scrollbar.collor([147, 193, 145, 0.5], [37, 188, 46, 0.5], [37, 188, 46, 0.8], 'green') } //Pink (Rose) else if (DATA.options.dio_ddd) { Scrollbar.collor([165, 145, 193, 0.5], [162, 37, 188, 0.5], [162, 37, 188, 0.8], 'pink') } //White (Blanc) else if (DATA.options.dio_eee) { Scrollbar.collor([255, 255, 255, 0.5], [152, 152, 152, 0.5], [152, 152, 152, 0.8], 'white') } else { Scrollbar.collor([145, 165, 193, 0.5], [37, 82, 188, 0.5], [37, 82, 188, 0.8], 'blue') } } catch (error) { errorHandling(error, "Scrollbar"); } }, collor: (a, b, c, collor) => { //button var scroll_vertical = "height: 16px; background-image: url(" + Home_url + "/img/dio/btn/scroll-", scroll_horizontal = "width: 16px; background-image: url(" + Home_url + "/img/dio/btn/scroll-"; return $('').appendTo('head'); }, deactivate: () => { $('#dio_Scrollbar').remove(); $('#dio_Scrollbar_display').remove(); }, }; /******************************************************************************************************************************* * Forum Delete Multiple *******************************************************************************************************************************/ var ForumDeleteMultiple = { activate: () => { try { if ($('.post_functions').length > 1) { if (!$('#dio_deleteAllcheckbox').length) { if ($('div.forum_footer').length) { $("div.forum_footer").append(''); } else { $("#forum div.game_list_footer").append(''); } } } $('#dio_deleteAllcheckbox').click(function () { $('#forum input[type="checkbox"]').prop('checked', this.checked) }); // Tooltip $('#dio_deleteAllcheckbox').tooltip(dio_icon + getTexts("Quack", "mark_All")); } catch (error) { errorHandling(error, "ForumDeleteMultiple"); } }, deactivate: () => { $('#dio_deleteAllcheckbox').remove(); }, }; /******************************************************************************************************************************* * select unit shelper *******************************************************************************************************************************/ var selectunitshelper = { activate: () => { try { var wnds = uw.GPWindowMgr.getOpen(uw.Layout.wnd.TYPE_TOWN); for (var e in wnds) { if (wnds.hasOwnProperty(e)) { var wndid = wnds[e].getID(); var testel = $('DIV#gpwnd_' + wndid + ' A.dio_balanced'); if (testel.length > 0) continue; var handler = wnds[e].getHandler(); $('DIV#gpwnd_' + wndid + ' A.select_all_units').after(' | ' + getTexts("Quack", "no_overload") + ' | ' + uw.DM.getl10n("market").delete_all_market_offers + ''); $('.gtk-deselect-units').css({ "display": "none" }); $('.attack_support_window .town_units_wrapper .ship_count').css({ "margin-left": "0px" }); var dio_bl_groundUnits = new Array('sword', 'slinger', 'archer', 'hoplite', 'rider', 'chariot', 'catapult', 'minotaur', 'zyklop', 'medusa', 'cerberus', 'fury', 'centaur', 'calydonian_boar', 'godsent'); $('DIV#gpwnd_' + wndid + ' A.dio_balanced').click(function () { var units = new Array(); var item; for (var i = 0; i < dio_bl_groundUnits.length; i++) { if (handler.data.units[dio_bl_groundUnits[i]]) { item = { name: dio_bl_groundUnits[i], count: handler.data.units[dio_bl_groundUnits[i]].count, population: handler.data.units[dio_bl_groundUnits[i]].population }; units.push(item); } } var berth = ""; if (handler.data.researches && handler.data.researches.berth) { berth = handler.data.researches.berth; } else { berth = 0; } var totalCap = handler.data.units.big_transporter.count * (handler.data.units.big_transporter.capacity + berth) + handler.data.units.small_transporter.count * (handler.data.units.small_transporter.capacity + berth); units.sort(function (a, b) { return b.population - a.population; }); for (i = 0; i < units.length; i++) { if (units[i].count == 0) { units.splice(i, 1); i = i - 1; }; } var restCap = totalCap; var sendUnits = new Array(); for (i = 0; i < units.length; i++) { item = { name: units[i].name, count: 0 }; sendUnits[units[i].name] = item; }; var hasSent; var k = 0; while (units.length > 0) { hasSent = false; k = k + 1; for (i = 0; i < units.length; i++) { if (units[i].population <= restCap) { hasSent = true; units[i].count = units[i].count - 1; sendUnits[units[i].name].count = sendUnits[units[i].name].count + 1; restCap = restCap - units[i].population; } } for (i = 0; i < units.length; i++) { if (units[i].count == 0) { units.splice(i, 1); i = i - 1; }; } if (!hasSent) { break; } } handler.getUnitInputs().each(function () { if (!sendUnits[this.name]) { if (handler.data.units[this.name].count > 0) { this.value = handler.data.units[this.name].count; } else { this.value = ''; } } }); for (i = 0; i < dio_bl_groundUnits.length; i++) { if (sendUnits[dio_bl_groundUnits[i]]) { if (sendUnits[dio_bl_groundUnits[i]].count > 0) { $('DIV#gpwnd_' + wndid + ' INPUT.unit_type_' + dio_bl_groundUnits[i]).val(sendUnits[dio_bl_groundUnits[i]].count); } else { $('DIV#gpwnd_' + wndid + ' INPUT.unit_type_' + dio_bl_groundUnits[i]).val(''); } } } $('DIV#gpwnd_' + wndid + ' INPUT.unit_type_sword').trigger('change'); }); $('DIV#gpwnd_' + wndid + ' A.dio_delete').click(function () { handler.getUnitInputs().each(function () { this.value = ''; }); $('DIV#gpwnd_' + wndid + ' INPUT.unit_type_sword').trigger('change'); }); } } } catch (error) { errorHandling(error, "selectunitshelper"); } }, deactivate: () => { $('#dio-ship_count').remove(); }, }; /******************************************************************************************************************************* * hotkeys *******************************************************************************************************************************/ var hotkeys = { ImagesHotkeys: { key: Home_url + '/img/dio/logo/key.png', city_select: Home_url + '/img/dio/logo/Senate.png', administrator: Home_url + '/img/dio/logo/administrator.png', captain: Home_url + '/img/dio/logo/captain.png', menu: Home_url + '/img/dio/logo/parchment.png' }, activate: () => { $('.toolbar_activities .right').before(''); $('').appendTo('head'); if ($('#gsa_shortcutOverview').is(':visible')) { if ($('.temple_commands').is(':visible')) { $('').appendTo('head'); } else { $('').appendTo('head'); } } else { if ($('.temple_commands').is(':visible')) { $('').appendTo('head'); } else { $('').appendTo('head'); } } var mousePopupHTML = '
    ' + dio_icon + '' + getTexts("hotkeys", "hotkeys") + ':'; var mousePopupHTMLTEST = '
    '; var mousePopupArray = {}; var mousePopupArrayTEST = {}; mousePopupArray[getTexts("hotkeys", "city_select")] = [ [hotkeys.ImagesHotkeys.city_select], ["", getTexts("hotkeys", "last_city")], ["", getTexts("hotkeys", "next_city")], ["↵", getTexts("hotkeys", "jump_city")] //↵ ]; //O, B /*A, alliance B, // reports (de) C, en=city_view (fr V) fr=Caserne D, DIO-TOOLS E, settings F, alliance_forum G, Grotte H, heroes I, // Culture (Agora) 73 J, Entrepôt K, ranking L, Marché M, messages N, notes O, en=Caserne P, Port ?PROFILE Q, Profile R, Rapports S, Senate T, //Défense (Agora 84 U, // Simulateur (Agora) 85 V, // fr=city_view (en c) W, Remparts X, farming_villages Y, // En dehors (Agora) 89 Z, Académie*/ var Text_premium = uw.DM.getl10n("layout").premium_button.premium_menu; var Text_layout = uw.DM.getl10n("layout").main_menu.items; mousePopupArray[getTexts("hotkeys", "menu")] = [ [hotkeys.ImagesHotkeys.menu], [(MID == 'fr') ? "V" : "C", uw.DM.getl10n("town_index").window_title], [(MID == 'de') ? "N" : "M", Text_layout.messages], [(MID == 'de') ? "B" : "R", Text_layout.reports], ["A", Text_layout.alliance], ["F", Text_layout.allianceforum], ["K", Text_layout.ranking], ["Q", Text_layout.profile], [(MID == 'de') ? "M" : "N", uw.DM.getl10n("notes").window_title] ]; mousePopupArray[uw.DM.getl10n("advisor").curator] = [ [hotkeys.ImagesHotkeys.administrator], ["1", Text_premium.trade_overview], ["2", Text_premium.command_overview], ["3", Text_premium.recruit_overview], ["4", Text_premium.unit_overview], ["5", Text_premium.outer_units], ["6", Text_premium.building_overview], ["7", Text_premium.culture_overview], ["8", Text_premium.gods_overview], ["9", Text_premium.hides_overview], ["0", Text_premium.town_group_overview], [(MID == 'de') ? "ß" : "-", Text_premium.towns_overview] ]; mousePopupArray[getTexts("hotkeys", "captain")] = [ [hotkeys.ImagesHotkeys.captain], [(MID == 'de') ? "´" : "=", Text_premium.attack_planer], ["X", Text_premium.farm_town_overview] ]; mousePopupArrayTEST[uw.DM.getl10n("docks").buildings] = [ [hotkeys.ImagesHotkeys.city_select], ["S", dio.getName("main")], ["G", dio.getName("hide")], ["Z", dio.getName("academy")], ["P", dio.getName("docks")], [(MID == 'fr') ? "C" : "O", dio.getName("barracks")], ["J", dio.getName("storage")], ["L", dio.getName("market")], ["W", dio.getName("wall")], ]; mousePopupArrayTEST.Agora = [ [hotkeys.ImagesHotkeys.city_select], ["T", uw.DM.getl10n("place").tabs[0]], ["Y", Text_premium.outer_units], ["U", getTexts("Options", "sim")[0]], ["I", Text_premium.culture_overview] ]; mousePopupArrayTEST[uw.DM.getl10n("layout").main_menu.items.settings] = [ [hotkeys.ImagesHotkeys.menu], ["E", uw.DM.getl10n("layout").main_menu.items.settings], ["D", "DIO-TOOLS"] ]; if ($('.ui_heroes_overview_container').is(':visible')) { mousePopupArray[getTexts("hotkeys", "menu")].push(["H", getTexts("hotkeys", "council")]); } $.each(mousePopupArray, function (a, b) { mousePopupHTML += '

    ' + a + ':
    '; $.each(b, function (c, d) { if (c != 0) mousePopupHTML += '' + d[0] + '' + d[1] + '
    '; }); }); $.each(mousePopupArrayTEST, function (a, b) { mousePopupHTMLTEST += '

    ' + a + ':
    '; $.each(b, function (c, d) { if (c != 0) mousePopupHTMLTEST += '' + d[0] + '' + d[1] + '
    '; }); }); $('#dio_BTN_HK').mousePopup(new uw.MousePopup(mousePopupHTML + mousePopupHTMLTEST)); $("#dio_BTN_HK").click(() => hotkeys.add()); hotkeys.add(); }, add: () => { try { document.onkeydown = function (e) { e = e || window.event; var target = e.target.tagName.toLowerCase(); function letter(letter) { return e.key == letter.toLowerCase() || e.key == letter.toUpperCase() } // Si pas dans une case texte + détection du CTRL pressé ou non if (!$(e.target).is('textarea') && !$(e.target).is('input') && !e.ctrlKey && !e.metaKey && !e.altKey && DATA.options.dio_Hot) { // Flèches directionnelles ///if (e.key == 'ArrowLeft' || e.key == 'ArrowRight') { } if ((MID == 'fr' ? e.code == "KeyV" : e.code == 'KeyC')) { if (!$("#ui_box .bull_eye_buttons .city_overview").hasClass('checked')) { $("#ui_box .bull_eye_buttons .city_overview").click(); } else { $("#ui_box .bull_eye_buttons .island_view").click(); } } // Agora !!! if (letter("i")) uw.PlaceWindowFactory.openPlaceWindow('culture'); // simulator if (letter("u")) uw.PlaceWindowFactory.openPlaceWindow('simulator', open); // Troupes en dehors if (letter("y")) uw.PlaceWindowFactory.openPlaceWindow('units_beyond'); // Défense (Agora) if (letter("t")) uw.PlaceWindowFactory.openPlaceWindow('index'); // Sénat if (letter("s")) uw.MainWindowFactory.openMainWindow(); // Caserne if ((MID == 'fr' ? letter("c") : letter("o"))) uw.BarracksWindowFactory.openBarracksWindow(); // Grotte if (letter("g")) uw.HideWindowFactory.openHideWindow(); // Port if (letter("p")) uw.DocksWindowFactory.openDocksWindow(); // Académie //Z if (letter("z")) uw.AcademyWindowFactory.openAcademyWindow(); // Rapports if ((MID == 'de' ? letter("b") : letter("r"))) uw.Layout.wnd.Create(uw.GPWindowMgr.TYPE_REPORT, uw.DM.getl10n("layout").main_menu.items.reports || "Reports"); // Forum if (letter("f")) uw.Layout.allianceForum.open(); // if (letter("e")) uw.Layout.wnd.Create(uw.GPWindowMgr.TYPE_PLAYER_SETTINGS, getTexts("hotkeys", "settings")); // PROFILE if (letter("q")) uw.Layout.wnd.Create(uw.GPWindowMgr.TYPE_PLAYER_PROFILE_EDIT); // Remparts if (letter("w")) uw.BuildingWindowFactory.open('wall'); // Ferme if (e.code == "Numpad1") uw.BuildingWindowFactory.open('farm'); // Entrepôt if (letter("j")) uw.BuildingWindowFactory.open('storage'); // Scierie if (e.code == "Numpad2") uw.LumberWindowFactory.openLumberWindow(); // Carrière if (e.code == "Numpad3") uw.StonerWindowFactory.openStonerWindow(); // Mine d'argent if (e.code == "Numpad4") uw.IronerWindowFactory.openIronerWindow(); // Marché if (letter("l")) uw.MarketWindowFactory.openMarketWindow(); // ALLIANCE if (letter("a")) uw.Layout.wnd.Create(uw.GPWindowMgr.TYPE_ALLIANCE); // Messages if ((MID == 'de' ? letter("n") : letter("m"))) uw.Layout.wnd.Create(uw.GPWindowMgr.TYPE_MESSAGE, uw.DM.getl10n("layout").main_menu.items.messages || "Messages") // Rang if (letter("k")) uw.RankingWindowFactory.openRankingWindow(); // RACOURCI Administrateur if (e.code == "Digit1") uw.TownOverviewWindowFactory.openTradeOverview(); if (e.code == "Digit2") uw.TownOverviewWindowFactory.openCommandOverview(); if (e.code == "Digit3") uw.TownOverviewWindowFactory.openMassRecruitOverview(); if (e.code == "Digit4") uw.TownOverviewWindowFactory.openUnitsOverview(); if (e.code == "Digit5") uw.TownOverviewWindowFactory.openOuterUnitsOverview(); if (e.code == "Digit6") uw.TownOverviewWindowFactory.openBuildingsOverview(); if (e.code == "Digit7") uw.TownOverviewWindowFactory.openCultureOverview(); if (e.code == "Digit8") uw.TownOverviewWindowFactory.openGodsOverview(); if (e.code == "Digit9") uw.TownOverviewWindowFactory.openHidesOverview(); if (e.code == "Digit0") uw.TownOverviewWindowFactory.openTownGroupOverview(); if (e.key == "²" || e.code == "Minus" || e.keyCode == "63" || e.key == "-") uw.TownOverviewWindowFactory.openTownsOverview(); // Villages de paysans if (letter("x")) uw.FarmTownOverviewWindowFactory.openFarmTownOverview(); // Plannificateur if (e.key == "`" || e.code == "Equal" || (MID == 'de' ? letter("r") : letter("b"))) uw.AttackPlannerWindowFactory.openAttackPlannerWindow(); // Outil de réservation if (e.code == "ShiftRight") uw.hOpenWindow.openReservationList(); void (0); // Notes if ((MID == 'de' ? letter("m") : letter("n"))) uw.NotesWindowFactory.openNotesWindow(); // if (e.key == "Enter") { uw.WMap.mapJump({ 'id': + uw.Game.townId, 'ix': uw.WMap.islandPosition.x, 'iy': uw.WMap.islandPosition.y }); } // if (letter("h") && $('.ui_heroes_overview_container').is(':visible')) uw.HeroesWindowFactory.openHeroesWindow(); if (e.key == "ArrowUp" && $(e.target).find("ul#fto_town_list").length) uw.farmingvillageshelper.switchTown("up"); if (e.key == "ArrowDown" && $(e.target).find("ul#fto_town_list").length) uw.farmingvillageshelper.switchTown("down"); if (letter("d")) openSettings(); } } } catch (error) { errorHandling(error, "hotkeys"); } }, deactivate: () => { $('#dio_BTN_HK').remove(); $('#dio_MH_attsup_style').remove(); }, }; /******************************************************************************************************************************* * island Farming Villages *******************************************************************************************************************************/ var islandFarmingVillages = { activate: () => { try { $('').appendTo('head'); $("#island_towns_controls").append(''); $("#dio_message_island").click(function () { var spielernamen = ""; if (!$("#island_info_towns_left_sorted_by_name li span.player_name a.gp_player_link").is(":visible")) { $("#island_info_towns_left_sorted_by_name li span.player_name").each(function () { if ($(this).text() != pName && $(this).text() != uw.DM.getl10n("alliance").profile.tooltip_msg_no_recipients && $(this).text() != getTexts("messages", "no_cities") + "." && spielernamen.indexOf($(this).text()) < 0) { spielernamen += $(this).text() + ";"; } }); } else { $("#island_info_towns_left_sorted_by_name li span.player_name a.gp_player_link").each(function () { if ($(this).text() != pName && $(this).text() != uw.DM.getl10n("alliance").profile.tooltip_msg_no_recipients && $(this).text() != getTexts("messages", "no_cities") + "." && spielernamen.indexOf($(this).text()) < 0) { spielernamen += $(this).text() + ";"; } }); } uw.Layout.newMessage.open({ recipients: spielernamen }); }); // Tooltip $('#dio_message_island').tooltip(dio_icon + uw.DM.getl10n("layout").main_menu.items.messages + " " + uw.DM.getl10n("bbcodes").island.name); } catch (error) { errorHandling(error, "islandFarmingVillages"); } }, deactivate: () => { $('#dio_message_island').remove(); $('#dio_message_recipients_style').remove(); }, }; /******************************************************************************************************************************* * towns list *******************************************************************************************************************************/ var townslist = { timeout: null, activate: () => { townslist.timeout = setInterval(() => { if ($('#town_groups_list').length) { if (!$('.dio_town_bb').get(0)) { townslist.add(); } } }, 100); //0.1s createWindowType("DIO_BBCODE", getTexts("labels", "tow"), 500, 375, true, [240, 70]); //[240, 70] $('').appendTo('head'); }, add: () => { try { dio.clipboard("#dio-copy-townslist", null, "townslist", null) if (!$('#town_groups_list a.town_bb').length != 0) { $('.content .group_name .name').append('

    '); $('.dio_town_bb').click(function (e) { $('.button.js-button-caption').click(); let towngrp_id = $(this).parent().data('groupid'); if (uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_BBCODE)) { uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_BBCODE).close(); } let cities_towngroup = uw.ITowns.town_group_towns.getTowns(towngrp_id) let header = "[quote][size=9][player]" + pName + "[/player][/size] "; let bb_premium = 0, bb_premiumb = "", bb_premiumc = false; if (uw.Game.premium_features.curator >= uw.Timestamp.now()) { bb_premium = uw.DM.getl10n("layout").premium_button.premium_menu.town_group_overview + ": " + uw.MM.getCollections().TownGroup[0]._byId[towngrp_id].attributes.name + " "; header += bb_premium; bb_premiumb = "(" + bb_premium + ")"; bb_premiumc = true; } let bb_count = 0, i, bb_content = {}; const bb_ville = uw.DM.getl10n("market").city; let bb_nombre_ville = cities_towngroup.length; //bb_nombre_ville = 600 let bb_nonbre = Math.floor((bb_nombre_ville - 1) / 60) + 1; for (let i = 1; i <= bb_nonbre; i++) { bb_content[`P${i}`] = `${header} ${rr(bb_nombre_ville, bb_ville, i, bb_nonbre)}\n[table]\n`; } function rr(bb_nombre_ville, bb_ville, A, bb_nonbre) { return `(${bb_nombre_ville} ${bb_ville})${bb_nombre_ville > 60 ? `(${A}/${bb_nonbre})` : ''}`; } $.each(cities_towngroup, function (key, town) { bb_count++; let group = Math.ceil(bb_count / 60); bb_content[`P${group}`] += townslist.content(bb_count, town); }); const wnd = uw.Layout.wnd.Create(uw.GPWindowMgr.TYPE_DIO_BBCODE) || uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_BBCODE).close(); let dio_version_PUB, footer; if (MID == 'fr') dio_version_PUB = "[url=" + Home_url + "/fr/]DIO-TOOLS-David1327[/url] - v." + dio_version + "[/quote]"; else dio_version_PUB = "[url=" + Home_url + "/en/]DIO-TOOLS-David1327[/url] - v." + dio_version + "[/quote]"; footer = "[/table]" + dio_version_PUB; const expRahmen_a = "
    " + "
    " + "
    " + "
    "; const expRahmen_d = "
    "; const expRahmen_e = "
    " + uw.DM.getl10n("layout").town_name_area.no_towns_in_group + " " + bb_premiumb + "
    "; let expTitel = (bb_premiumc ? bb_premium + "(" + bb_nombre_ville + " " + bb_ville + ")" : bb_nombre_ville + " " + bb_ville) + "
    "; let bb_content_F = "
    " for (let i = 1; i <= bb_nonbre; i++) { let textareaId = `expTextareaP${i}`, buttonLabel = getTexts("messages", "copy"), Height = 240; if (bb_nombre_ville >= 61) { buttonLabel += ` (${i}/${bb_nonbre})`; Height = 120; } bb_content_F += `
    ${dio.createButton(buttonLabel, "dio-copy-townslist", null, `data-clipboard-target="#${textareaId}"`)}
    `; } if (bb_nombre_ville < 61) $("#expTextareaP1").css({ height: "-webkit-fill-available", height: "max-content" }); wnd.setContent(expRahmen_a + expTitel + (bb_nombre_ville > 0 ? bb_content_F : expRahmen_e) + expRahmen_d); $('.close_a').click(() => { uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_BBCODE).close(); }); }); } $('#dio_town_list_bb').tooltip(dio_icon + getTexts("Options", "Tol")[0]); } catch (error) { errorHandling(error, "townslist"); } }, content: (bb_count, town) => { return "[*]" + bb_count + ".[|][town]" + town.attributes.town_id + "[/town][|]" + town.town_model.attributes.points + " " + uw.DM.getl10n("mass_recruit").sort_by.points + "[|]" + uw.DM.getl10n("tooltips").ocean + " " + town.town_model.attributes.sea_id + "[/*]\n"; }, deactivate: () => { $('#dio_town_list_bb_style').remove(); if (uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_BBCODE)) { uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_BBCODE).close(); } clearTimeout(townslist.timeout); townslist.timeout = null; }, }; /******************************************************************************************************************************* * BBcode List *******************************************************************************************************************************/ var BBcodeList = { activate: () => { createWindowType("DIO_BBCODE", "BBCode", 570, 375, true, [240, 70]); //[240, 70] $('').appendTo('head'); }, player_towns: () => { try { dio.clipboard("#dio-copy-BBcodeList", null, "BBcodeList", null) if (!$('#player_towns #dio_player_towns').get(1)) { if ($('#player_towns .game_border_top').length == 1) $($('#player_towns .game_border_top')[0]).before('
    '); else $($('#player_towns .game_border_top')[1]).before('
    '); $('#player_towns #dio_player_towns').click(function (e) { // Utilisez le sélecteur jQuery pour cibler l'élément h3 et récupérer son contenu let playerName = $(this).parent().parent().parent().find("#player_info h3").text().trim(); let allianceName = ""; let element = $(this).parent().parent().parent().find('a[onclick^="Layout.allianceProfile.open"]'); if (element.text().trim() !== "") allianceName = dio.Extract_alliance(element); let ID = $("#player_towns .game_header.bold").text().trim().split(' ')[0].trim(); if (uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_BBCODE)) { uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_BBCODE).close(); } // Sélectionnez tous les éléments de liste avec la classe "gp_town_link" const townLinks = $(this).parent().find(".gp_town_link"); // Initialisez un tableau vide pour stocker les données des villes const citiesData = []; let bb_nombre_ville = 0 // Parcourez chaque élément de liste et extrayez les informations nécessaires townLinks.each(function () { // Récupérez l'URL de chaque lien const url = $(this).attr('href'); // Utilisez la fonction replaceBBtowns pour extraire l'ID de la ville de l'URL const townIdMatch = url.match(/#(.*?)$/); if (townIdMatch && townIdMatch[1]) { const townId = $.parseJSON(atob(townIdMatch[1])).id; const townName = $(this).text().trim(); const points = $(this).next().text().trim().split('|')[0].trim(); //.split(' ')[0] const ocean = $(this).next().text().trim().split('|')[1].trim(); // Ajoutez les données de la ville au tableau citiesData citiesData.push({ town_id: townId, name: townName, points: points, sea_id: ocean }); } bb_nombre_ville++ }); //bb_nombre_ville = 600 let header = "[quote][size=9][player]" + playerName + "[/player][/size]"; if (allianceName != "") header = "[quote][size=9][player]" + playerName + "[/player] ([ally]" + allianceName + "[/ally])[/size]"; let bb_count = 0, i, bb_content = {}; let bb_nonbre = Math.floor((bb_nombre_ville - 1) / 60) + 1; for (let i = 1; i <= bb_nonbre; i++) { bb_content[`P${i}`] = `${header} ${rr(bb_nombre_ville, ID, i, bb_nonbre)}\n[table]\n`; } function rr(bb_nombre_ville, ID, A, bb_nonbre) { return `(${bb_nombre_ville} ${ID})${bb_nombre_ville > 60 ? `(${A}/${bb_nonbre})` : ''}`; } $.each(citiesData, function (key, town) { bb_count++; let group = Math.ceil(bb_count / 60); bb_content[`P${group}`] += "[*]" + bb_count + ".[|][town]" + citiesData[key].town_id + "[/town][|]" + citiesData[key].points + "[|]" + citiesData[key].sea_id + "[/*]\n" }); BBcodeList.add(ID, bb_content, bb_nombre_ville) }); } $('#dio_player_towns').tooltip(dio_icon + getTexts("Options", "Tol")[0]); } catch (error) { errorHandling(error, "BBcodeList"); } }, alliance_player: () => { try { dio.clipboard("#dio-copy-BBcodeList", null, "BBcodeList", null) if (!$('#ally_towns #dio_alliance_player').get(0)) { let ID = $("#ally_towns .game_header.bold").text().trim(); $('#ally_towns .game_border_top').before('
    '); $('#dio_alliance_player').click(function (e) { if (uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_BBCODE)) { uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_BBCODE).close(); } let allyName = $(this).parent().parent().parent().parent().parent().find('.ui-dialog-title').text().trim(); // Utiliser jQuery pour sélectionner les éléments de la liste des membres const members = $(".members_list li:eq(1) ul li.even"); // Initialiser un tableau pour stocker les données extraites const memberData = []; let bb_nombre_members = 0 // Parcourir chaque élément de la liste des membres members.each(function (index, element) { // Extraire le nom du joueur const playerName = $(element).find("a.gp_player_link").attr("title"); // Extraire les points du joueur if ($(element).find("div.small-descr").text() == 0) return const points = $(element).find("div.small-descr").text().split(',')[0].trim(); // Extraire le nombre de villes du joueur const cities = $(element).find("div.small-descr").text().split(',')[1].trim(); // Ajouter les données extraites au tableau memberData.push({ player: playerName, points: points, cities: cities }); bb_nombre_members++ }); //bb_nombre_ville = 600 let header = "[quote][size=9][ally]" + allyName + "[/ally][/size]"; let bb_count = 0, i, bb_content = {}; let bb_nonbre = Math.floor((bb_nombre_members - 1) / 60) + 1; for (let i = 1; i <= bb_nonbre; i++) { bb_content[`P${i}`] = `${header} ${rr(bb_nombre_members, ID, i, bb_nonbre)}\n[table]\n`; } function rr(bb_nombre_ville, ID, A, bb_nonbre) { return `(${bb_nombre_ville} ${ID})${bb_nombre_ville > 60 ? `(${A}/${bb_nonbre})` : ''}`; } $.each(memberData, function (key, town) { bb_count++; let group = Math.ceil(bb_count / 60); bb_content[`P${group}`] += "[*]" + bb_count + ".[|][player]" + memberData[key].player + "[/player][|]" + memberData[key].points + "[|]" + memberData[key].cities + "[/*]\n" }); BBcodeList.add(ID, bb_content, bb_nombre_members) }); $('#dio_alliance_player').tooltip(dio_icon + "BBcode " + ID); } } catch (error) { errorHandling(error, "alliance_player"); } }, island_info: () => { try { dio.clipboard("#dio-copy-BBcodeList", null, "BBcodeList", null) if (!$('.island_info_wrapper #dio_island_info').get(0)) { console.log("ok") let ID = $(".island_info_wrapper .game_header.bold").text().split('(')[0].trim(); $('.island_info_wrapper .island_info_left .game_border_top').before('
    '); $('#dio_island_info').click(function (e) { if (uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_BBCODE)) { uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_BBCODE).close(); } let Island = $(this).parent().parent().parent().parent().parent().find('.island_info h4').text().trim().split(' ')[1]; let Ocean = $(this).parent().parent().parent().parent().parent().find('.islandinfo_coords').text().trim(); let spaces = $(this).parent().parent().parent().parent().parent().find('.islandinfo_free').text().trim(); let header = "[quote][size=9][island]" + Island + "[/island]\n" + Ocean + "\n" + spaces + "[/size]\n[table]\n"; // Utiliser jQuery pour sélectionner les éléments de la liste des membres let Cities = ""; let by_name = $('#island_info_towns_left_sorted_by_name:visible') let by_score = $('#island_info_towns_left_sorted_by_score:visible') let by_player = $('#island_info_towns_left_sorted_by_player:visible') if (by_name.length > 0) Cities = $('#island_info_towns_left_sorted_by_name li') if (by_score.length > 0) Cities = $('#island_info_towns_left_sorted_by_score li') if (by_player.length > 0) Cities = $('#island_info_towns_left_sorted_by_player li') // Initialiser un tableau pour stocker les données extraites let memberCities = 1, bb_content = {}; bb_content.P1 = header // Parcourir chaque élément de la liste des membres Cities.each(function () { // Récupérez l'URL de chaque lien const url = $(this).find('.gp_town_link').attr('href'); // Utilisez la fonction replaceBBtowns pour extraire l'ID de la ville de l'URL const townIdMatch = url.match(/#(.*?)$/); if (townIdMatch && townIdMatch[1]) { const ville = $.parseJSON(atob(townIdMatch[1])).id; // Récupérer les valeurs des éléments const rang = memberCities++; // Calculer le rang du joueur const points = $(this).find('.small:first').text(); // Récupérer les chiffres dans la parenthèse => .match(/\d+/)[0] let joueur = "[player]" + $(this).find('.gp_player_link').text() + "[/player]"; if (joueur == "[player][/player]") joueur = $(this).find('.small.player_name').text() let alliance = "[ally]" + $(this).find('.gp_alliance_link').text() + "[/ally]"; if (alliance == "[ally][/ally]") alliance = ""; // Si l'alliance n'est pas disponible, afficher '' // Ajouter les valeurs au tableau des données bb_content.P1 += "[*]" + rang + ".[|][town]" + ville + "[/town][|]" + points + "[|]" + joueur + "[|]" + alliance + "[/*]\n"; } }); console.log(bb_content.P1) BBcodeList.add(ID, bb_content, 20 - spaces.split(':')[1].trim()) }); $('#dio_island_info').tooltip(dio_icon + "BBcode " + ID); } } catch (error) { errorHandling(error, "island_info"); } }, add: (ID, bb_content, bb_nombre_ville) => { try { let bb_nonbre = Math.floor((bb_nombre_ville - 1) / 60) + 1; const wnd = uw.Layout.wnd.Create(uw.GPWindowMgr.TYPE_DIO_BBCODE) || uw.Layout.wnd.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_BBCODE).close(); let dio_version_PUB, footer; if (MID == 'fr') dio_version_PUB = "[url=" + Home_url + "/fr/]DIO-TOOLS-David1327[/url] - v." + dio_version + "[/quote]"; else dio_version_PUB = "[url=" + Home_url + "/en/]DIO-TOOLS-David1327[/url] - v." + dio_version + "[/quote]"; footer = "[/table]" + dio_version_PUB; const expRahmen_a = "
    " + "
    " + "
    " + "
    "; const expRahmen_d = "
    "; const expRahmen_e = "
    " + + "
    "; let expTitel = bb_nombre_ville + " " + ID + "
    "; let bb_content_F = "
    " for (let i = 1; i <= bb_nonbre; i++) { let textareaId = `expTextareaP${i}`, buttonLabel = getTexts("messages", "copy"), Height = 240; if (bb_nombre_ville >= 61) { buttonLabel += ` (${i}/${bb_nonbre})`; Height = 120; } bb_content_F += `
    ${dio.createButton(buttonLabel, "dio-copy-BBcodeList", null, `data-clipboard-target="#${textareaId}"`)}
    `; } if (bb_nombre_ville < 61) $("#expTextareaP1").css({ height: "240px" }); wnd.setContent(expRahmen_a + expTitel + (bb_nombre_ville > 0 ? bb_content_F : expRahmen_e) + expRahmen_d); $('#dio_town_list_bbb').tooltip(dio_icon + getTexts("Options", "Tol")[0]); } catch (error) { errorHandling(error, "BBcodeList"); } }, content: (bb_count, town) => { return "[*]" + bb_count + ".[|][town]" + town.attributes.town_id + "[/town][|]" + town.town_model.attributes.points + " " + uw.DM.getl10n("mass_recruit").sort_by.points + "[|]" + uw.DM.getl10n("tooltips").ocean + " " + town.town_model.attributes.sea_id + "[/*]\n"; }, deactivate: () => { $('#dio_BBcodeList_style').remove(); if (uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_BBCODE)) { uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_BBCODE).close(); } }, }; /******************************************************************************************************************************* * Message Exporter *******************************************************************************************************************************/ var MessageExport = { activate: () => { if ($('#message_message_list').length) { MessageExport.add(); } }, add: () => { try { dio.clipboard("#dio-copy-message-quote", null, "MessageExport", true) createWindowType("DIO_BBCODEE", getTexts("messages", "bbmessages"), 700, 350, true, ["center", "center", 100, 100]); const wnd = uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_MESSAGE); const wndid = wnd.getID(); if (!$("#dio_messageExport").is(":visible")) { $('#qt_messageExport').remove(); if ($("#message_message_list .subject").is(":visible")) { $("DIV#gpwnd_" + wndid + " DIV#message_message_list .game_header:first").append('
    ' + dio.createButton(getTexts("messages", "bbmessages")) + '
    '); } else { $("DIV#gpwnd_" + wndid + " DIV#message_message_list .game_header:first").append('
    ' + dio.createButton(getTexts("messages", "bbmessages")) + '
    '); } $("#dio_messageExport").tooltip(getTexts("messages", "export")); let author, alliance, alliance2, message, i, player, add_Ally; author = $("#message_partner a.gp_player_link").text().trim(); if (typeof (uw.MM.DIO.cachePlayers[author.replace(/ /g, '+')]) !== "undefined") { player = uw.MM.DIO.cachePlayers[author.replace(/ /g, '+')] if (player.alliance_id !== "" & !$("#message_partner a[onclick^='Layout.allianceProfile.open']").get(0)) { alliance = uw.MM.DIO.cacheAlliances[player.alliance_id].name.replace(/\+/g, ' ') add_Ally = uw.hCommon.alliance("n", uw.MM.DIO.cacheAlliances[player.alliance_id].name.replace(/\+/g, ' '), player.alliance_id) $('#message_partner a.gp_player_link').after(' (' + add_Ally + ')') }; }; $("#dio_messageExport").click(function () { let header = "[quote]"; //let bb_content = {} let bb_content = ""; // Titre if ($("#message_message_list .subject").is(":visible")) { message = $("#message_message_list .subject").text().trim(); } else { (message = $("#message_message_list .game_header").clone()).find("*").remove(); message = message.html().trim(); } alliance = $("#message_partner a.gp_alliance_link").text().trim(); alliance2 = $("#message_partner span a").text().trim(); author = '[player]' + author + '[/player]' if (author === "[player][/player]") author = "Grepolis"; if (alliance) { i = "(" + author + " [ally]" + alliance + "[/ally])" } else if (alliance2) { i = "(" + author + " [ally]" + alliance2 + "[/ally])" } else { i = "(" + author + ")" }; header += "[b]" + uw.DM.getl10n("layout").main_menu.items.messages + ":[/b] " + message + " " + i + "\n"; header += '[img]' + Home_url + '/img/dio/logo/transition-mini.png[/img]'; bb_content += header; let format_search = [ //mg, /<\/s>/mg, //mg, /<\/u>/mg, //mg, /<\/i>/mg, //mg, /<\/b>/mg, /
    /mg, /<\/center>/mg, /\(.*?)\<\/a>/ig, /\\(.*?)<\/a><\/span>/ig, /\\(.*?)<\/a><\/span>/ig, /\/ig, /\(.*?)/ig, /\(.*?)\<\/span\>/ig, /\(.*?) (.*?)<\/a><\/span>/ig, /\\(.*?)\<\/tbody\>\<\/table\>/ig, /\(.*?)<\/span>/ig, ]; let format_replace = [ '[s]', '[/s]', '[u]', '[/u]', '[i]', '[/i]', '[b]', '[/b]', '[center]', '[/center]', '[url=$1]$2[/url]', replaceBBtowns, replaceBBtemple, '[img]$2[/img]', '[img]$1[/img]', '[color=$1]$2[/color]', '[island]$4[/island]', '[table]$1[/table]', '[b][color=#804000]$1[/color][/b]', '[*]', '[**]', '[/*]', '[/**]', '[|]', '[||]', '', '', '[font=monospace]$1[/font]', ]; function replaceBBtemple(match, p1, offset, string) { const a = $.parseJSON(atob(p1)); return '[temple]' + a.id + '[/temple]' }; function replaceBBtowns(match, p1, offset, string) { const a = $.parseJSON(atob(p1)); return '[town]' + a.id + '[/town]' }; function replaceBBislands(match, p1, offset, string) { const a = $.parseJSON(atob(p1)); return '[island]' + a.id + '[/island]' }; $(".message_post_container .message_post").each(function (index, element) { /*index = "p" + index console.log(index) bb_content[index] = "";*/ const dio_messageExportTMP = $("#dio_messageExportTMP"); dio_messageExportTMP.empty(); let i, e, n = dio_messageExportTMP.html(); $(this).clone().appendTo(dio_messageExportTMP); e = $(this)[0].outerHTML i = e $(this).hasClass("bbcodes_town") && (i = MessageExport.replaceTownNameById($(this).find("a"), i)); //console.log(uw.MM.DIO.cacheAlliances[uw.MM.DIO.cachePlayers[$("#message_partner")[0].innerText.split(' ')[0]].alliance_id].name) dio_messageExportTMP.find(".published_report").replaceWith("[report][/report]"); //replace reports dio_messageExportTMP.find(".bbcode_awards").replaceWith("[img]" + Home_url + "/img/dio/logo/award.gif[/img]"); //replace awards dio_messageExportTMP.find(".reservation_list").replaceWith(function () { //replace reservations if (MessageExport.bbcodes_town_id($(this).find("a.gp_town_link")) == false) { dio_messageExportTMP.find(".reservation_list").replaceWith(function () { return '[reservation]9999999[/reservation]'; }) } else { dio_messageExportTMP.find(".reservation_list").replaceWith(function () { return "[reservation]" + MessageExport.bbcodes_town_id($(this).find("a.gp_town_link")) + "[/reservation]"; }) } }); dio_messageExportTMP.find(".bbcodes_spoiler").replaceWith(function () { //replace spoiler $(this).find(".button").remove(); return '[spoiler=' + $("b:first", this).text() + ']' + $(".bbcodes_spoiler_text", this).html() + '[/spoiler]'; }); dio_messageExportTMP.find(".bbcodes_quote").replaceWith(function () { //replace quotes if ($('.quote_author', this)[0]) return '[quote=' + $('.quote_author', this).text().replace(' ' + getTexts("messages", "écrit", true), '') + ']' + $(".quote_message", this).html() + '[/quote]'; else return '[quote=]' + $(".quote_message", this).html() + '[/quote]'; }); dio_messageExportTMP.find(".bbcodes_size").replaceWith(function () { //replace size return '[size=' + $(this)[0].style.fontSize + ']' + $(this).html() + '[/size]'; }); dio_messageExportTMP.find(".bbcodes_player").replaceWith(function () { //replace player return '[player]' + $(this).text() + '[/player]'; }); dio_messageExportTMP.find(".bbcodes_ally").replaceWith(function () { //replace ally return '[ally]' + $(this).text() + '[/ally]'; }); dio_messageExportTMP.find(".bbcodes_ally_deleted").replaceWith(function () { //replace ally return '[ally]' + $(this).text() + '[/ally]'; }); dio_messageExportTMP.find(".bbcodes_font").replaceWith(function () { //replace font return '[font=' + $(this).attr('class').split(' ').pop() + ']' + $(this).html() + '[/font]'; }); dio_messageExportTMP.find(".grepolis_score").replaceWith(function () { //replace score return '[score]' + $(".bbcode_playername", this).text().trim() + '[/score]'; }); dio_messageExportTMP.find(".bbcode_application").replaceWith(function () { //replace invitation à rejoindre l'alliance return '[center][img]' + Home_url + '/img/dio/logo/horizontal-separator.png[/img][/center][center][b]' + $(this).text().trim().replace(/ /mg, "[img]" + Home_url + "/img/dio/logo/espace.png[/img]") + '[/b][/center]'; }); dio_messageExportTMP.find("table").replaceWith(function () { //replace table return '[table]' + $(this)[0].outerHTML + '[/table]'; }); dio_messageExportTMP.find("table").replaceWith(function () { //replace table return $("tbody", this).html(); }); dio_messageExportTMP.find("script").remove(); //remove script tags author = '[player]' + $(".message_poster .gp_player_link", this).text() + '[/player]'; if (author === "[player][/player]") author = "Grepolis"; const postDate = $(".message_poster .message_date", this).text().trim(); bb_content += '[size=7]' + author + ' ' + postDate + '[/size]\n'; bb_content += '[img]' + Home_url + '/img/dio/logo/transition-mini2.png[/img]\n'; let postHTML = $("#dio_messageExportTMP .message_post_content").html().trim(); postHTML = postHTML.replace(e, i) postHTML = postHTML.replace(/(\r\n|\n|\r|\t)/gm, ""); //remove line-breaks, tab characters postHTML = postHTML.replace(//mg, "\n"); //add line-breaks instead of
    postHTML = postHTML.replace(/%2B/mg, "+"); //replace %2B (url) postHTML = postHTML.replace(/%2F/mg, "/"); //replace %2F (url) postHTML = postHTML.replace(/%3A/mg, ":"); //replace %3A (url) postHTML = postHTML.replace(/%3B/mg, ";"); //replace %3B (url) postHTML = postHTML.replace(/%3D/mg, "="); //replace %3D (url) postHTML = postHTML.replace(/%3F/mg, "?"); //replace %3F (url) postHTML = postHTML.replace(/%23/mg, "#"); //replace %23 (url) postHTML = postHTML.replace(/%26/mg, "&"); //replace %26 (url) postHTML = postHTML.replace(/ /mg, " "); //replace   //postHTML = postHTML.replace(/\\
    /ig, replaceBBtowns); //replace   for (i = 0; i < format_search.length; i++) { postHTML = postHTML.replace(format_search[i], format_replace[i]); } bb_content += postHTML + "\n"; bb_content += '[img]' + Home_url + '/img/dio/logo/transition-mini.png[/img]'; bb_content += "\n"; }); /*if (bb_content.p0.split("]").length) console.log(bb_content.p0.split("]").length) console.log(bb_content) console.log(bb_content.p0) console.log(bb_content.p1)*/ //bb_content = bb_content.slice(0, -1); if (MID == 'fr') bb_content += "[url=" + Home_url + "/fr/]DIO-TOOLS-David1327[/url] - v." + dio_version; else bb_content += "[url=" + Home_url + "/en/]DIO-TOOLS-David1327[/url] - v." + dio_version; bb_content += "[/quote]"; let expRahmen_a = "
    " + "
    " + "
    " + "
    " + "
    "; let expRahmen_b = "
    " + dio.createButton(getTexts("messages", "copy"), "dio-copy-message-quote", null, 'data-clipboard-target="#expTextarea"') + "
    "; let expRahmen_d = "
    "; let expRahmen_e = '
    '; //"
    " + dio.createButton(getTexts("labels", "dsc"), "dio-copy-message-quote", null, 'data-clipboard-target="#expTextarea"') + "
    "; let expTitel = getTexts("messages", "Tol"); const BBwnd = uw.GPWindowMgr.Create(uw.GPWindowMgr.TYPE_DIO_BBCODEE) || uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_BBCODEE).close(); BBwnd.setContent(expRahmen_a + expTitel + expRahmen_b + bb_content + expRahmen_c + expRahmen_d + expRahmen_e); $('#dio_help_MessageExport').tooltip('Wiki (' + dio_icon + getTexts("Options", "Mse")[0] + ')'); $("#expTextarea").focus(function () { const that = this; setTimeout(() => { $(that).select(); }, 10); }); var maxCharacters = 499; // Diviser le texte en un tableau de sections en utilisant "]" var sections = bb_content.split("]"); if (sections.length >= 400) console.log(sections) else console.log("++++") }); } } catch (error) { errorHandling(error, "MessageExport"); } }, /*bbcodes_town_id: (e) => { let t = $(e).attr("href"); return void 0 !== t && !1 !== t && "undefined" != (t = MessageExport.Link2Struct(t)).id && (t = parseInt(t.id), !isNaN(t)) && t },*/ bbcodes_town_id: (e) => { let t = $(e).attr("href"); if (void 0 === t || t === false) return; t = MessageExport.Link2Struct(t); if (t.id === undefined) return; t = parseInt(t.id); if (isNaN(t)) return; return t; }, /*Link2Struct: (l) => { let ret = {}; try { l = l.split(/#/) eval("ret=" + atob(l[1] || l[0])) } catch (e) { } return ret },*/ Link2Struct: (l) => { let ret = {}; try { l = l.split(/#/) ret = JSON.parse(atob(l[1] || l[0])) } catch (e) { } return ret }, replaceTownNameById: (t, e) => { const n = t.attr("href") , i = t.text(); if (null != n && 0 <= n.indexOf("#")) { var o = JSON.parse(atob(n.replace("#", ""))).id; e = e.replace(">" + i + "<", ">" + o + "<") } return e }, deactivate: () => { $('#dio_messageExport').remove(); if (uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_BBCODEE)) { uw.GPWindowMgr.getOpenFirst(uw.GPWindowMgr.TYPE_DIO_BBCODEE).close(); } }, }; /******************************************************************************************************************************* * Remove Tooltipps *******************************************************************************************************************************/ var removetooltipps = { activate: () => { dio.removeTooltipps(); }, deactivate: () => { }, }; /******************************************************************************************************************************* * Resource Counter * Adding total resource counter to trade overview *******************************************************************************************************************************/ var resCounter = { activate: () => { $('').appendTo("head"); if ($('#trade_overview_wrapper').length) { resCounter.init(); } }, //Counting resources in town right now init: () => { try { let wood_total = 0; let stone_total = 0; let silver_total = 0; const city_boxes = $('#trade_overview_wrapper').find(".trade_town"); for (var a = 0; a < city_boxes.length - 2; a++) { wood_total += parseInt($(city_boxes[a]).find(".resource_wood_icon").text()); stone_total += parseInt($(city_boxes[a]).find(".resource_stone_icon").text()); silver_total += parseInt($(city_boxes[a]).find(".resource_iron_icon").text()); } //Appending counter to trade window const wnd = uw.GPWindowMgr.getFocusedWindow() || false; const dio_wnd = wnd.getJQElement().find(".overview_search_bar"); dio_wnd.append('
    ' + wood_total + '
    ' + '
    ' + stone_total + '
    ' + '
    ' + silver_total + '
    '); } catch (error) { errorHandling(error, "resCounter"); } }, deactivate: () => { $('#dio_trade_overview_style').remove(); $('#dio_resource_counter').remove(); }, }; /******************************************************************************************************************************* * GRCT * ---------------------------------------------------------------------------------------------------------------------------- * | ● Numéro d'océan : Ajoute le numéro de l'océan * | ● Message de groupe : Ajoute un bouton pour envoyer un message au monde d'une alliance * | ● Inactif : Afficher les joueurs inactifs * | ● Sauvegarde des remparts : Sauvegarde des troupes des remparts * | ● Alarme d'attaque * ---------------------------------------------------------------------------------------------------------------------------- *******************************************************************************************************************************/ /******************************************************************************************************************************* * Numéro d'océan : Ajoute le numéro de l'océan *******************************************************************************************************************************/ var OceanNumbers = { activate: () => { $('').appendTo("head"); OceanNumbers.add() }, add: () => { if ($("#grcrtListSaved").is(":visible")) return; if (0 == $("#map_move_container").length) { setTimeout(function () { if (DATA.options.dio_Onb) OceanNumbers.add(); }, 100); } else { if ($("div#dio_oceanNumbers").length == 0) { $("#map_move_container").append($("
    ", { id: "dio_oceanNumbers", style: "position:absolute; top:0; left:0;" })); (uw.require("map/helpers") || uw.MapTiles).map2Pixel(100, 100); for (var d = 0; 10 > d; d++) { for (var k = 0; 10 > k; k++) { var m = (uw.require("map/helpers") || uw.MapTiles).map2Pixel(100 * k, 100 * d); $("div#dio_oceanNumbers").append($("
    ", { "class": "dio_NumbersON", style: "left:" + m.x + "px; top: " + m.y + "px; background-image: url(" + Home_url + "/img/dio/map/" + k + d + ".png);" })); } } } } }, deactivate: () => { $('#dio_Ocean_Numbers_style').remove(); }, }; /******************************************************************************************************************************* * Message de groupe *******************************************************************************************************************************/ var ally_mass_mail = { activate: () => { $('').appendTo('head'); }, add: () => { if (!$('#ally_towns #dio_ally_mass_mail').get(0)) { let ID = $("#ally_towns .game_header.bold").text().trim(); $('#ally_towns .game_border_top').before('
    '); $('#dio_ally_mass_mail').tooltip(dio_icon + ID); $('#dio_ally_mass_mail').click(() => { // Utiliser jQuery pour sélectionner les éléments de la liste des membres const members = $(".members_list li ul li.even"); let listmembers = ""; // Parcourir chaque élément de la liste des membres members.each(function (index, element) { // Extraire le nom du joueur if ($(element).find("a.gp_player_link").attr("title") != undefined) listmembers += $(element).find("a.gp_player_link").attr("title") + ";"; }); uw.Layout.newMessage.open({ recipients: listmembers }); }); }; }, deactivate: () => { $('#dio_ally_mass_mail_style').remove(); }, }; /******************************************************************************************************************************* * Inactif : Afficher les joueurs inactifs *******************************************************************************************************************************/ var idle = { activate: () => { $('').appendTo('head'); idle.add("island_info") idle.add("player") idle.add("alliance") idle.add("message") idle.add("info") }, add: (action, b) => { if ($("#grcrt_mnu").is(":visible") && action != "message") return if (action == "island_info") { let Ally = uw.MM.DIO.cacheAlliances, add_player, add_Ally, player; $('.island_info_left .gp_town_link').each(function () { // Sélectionne tous les dans la liste avec l'ID 'island_info_towns_left_sorted_by_name' let nomDuJoueur = $(this).parent().find('.player_name').text(); // Récupère le texte à l'intérieur de l'élément if (typeof (uw.MM.DIO.cachePlayers[nomDuJoueur.replace(/ /g, '+')]) !== "undefined") { player = uw.MM.DIO.cachePlayers[nomDuJoueur.replace(/ /g, '+')] add_player = uw.hCommon.player(nomDuJoueur, player.id) $(this).parent().find('.player_name').replaceWith($('').append(add_player)); // Remplace l'élément par le nouvel élément avec le lien if (player.alliance_id !== "") { add_Ally = uw.hCommon.alliance("n", uw.MM.DIO.cacheAlliances[player.alliance_id].name.replace(/\+/g, ' '), player.alliance_id) $(this).parent().find('.player_name').after(' (' + add_Ally + ')') }; }; }); }; let ina = "Inactif"; //STATS.INACTIVE let each = ''; if (action == "island_info") each = '.island_info_left .gp_player_link'; if (action == "player") each = '#player_info.bold h3'; if (action == "alliance") each = '#ally_towns .gp_player_link'; if (action == "message") each = '#message_message_list .gp_player_link'; if (action == "info") each = '#towninfo_towninfo .gp_player_link'; // Sélectionnez tous les éléments avec la classe "gp_player_link" ou "small player_name" $(each).each(function () { //if ($(this).parent().find('.dio_idle').get(0)) $('.dio_idle').remove() if (!$(this).parent().find('.dio_idle').get(0)) { let idle_nb = -1; // Créez une nouvelle div avec la classe "dio_idle" et le texte du lien let playerName = $(this).attr('title'); if (playerName !== undefined) playerName = $(this).attr('title').replace(/ /g, '+'); else playerName = $(this).text().replace(/ /g, '+'); let newDiv = $('
    '); // Ajoutez la nouvelle div avant l'élément avec la classe "gp_player_link" ou "founder_icon" if (action == "player") $(this).before($('
    ')) else if ($(this).parent().find('.founder_icon').get(0)) $(this).parent().find('.founder_icon').before(newDiv); else $(this).before(newDiv); if (typeof (uw.MM.DIO.cachePlayers[playerName]) !== "undefined") { $(this).parent().find('.dio_idle').addClass("dio_idle_days").addClass("dg"); idle_nb = -2; if (typeof (uw.MM.DIO.player_idle[uw.MM.DIO.cachePlayers[playerName].id]) !== "undefined") { idle_nb = uw.MM.DIO.player_idle[uw.MM.DIO.cachePlayers[playerName].id].idle / 24; } } $(this).parent().find('.dio_idle').html(0 > parseInt(idle_nb) ? (idle_nb == -2 ? "?" : "") : parseInt(idle_nb)); $(this).parent().find('.dio_idle').tooltip('
    ' + dio_icon + "" + ina + ": " + (0 > parseInt(idle_nb) ? "???" : uw.hours_minutes_seconds(3600 * parseInt(24 * idle_nb)) || "0") + '
    Powered by GREPODATA ≈' + uw.hours_minutes_seconds(3600) + '
    '); 7 <= idle_nb ? $(this).parent().find('.dio_idle').toggleClass("dg dr") : 2 <= idle_nb && $(this).parent().find('.dio_idle').toggleClass("dg dy"); } }); }, deactivate: () => { $('#dio_idle_style').remove(); $('.dio_idle').remove(); }, }; /******************************************************************************************************************************* * Sauvegarde des remparts : Sauvegarde des troupes des remparts *******************************************************************************************************************************/ var Save_wall = { activate: () => { $('').appendTo('head'); if ($("#building_wall").is(":visible")) Save_wall.add(); }, add: () => { if ($("#grcrtListSaved").is(":visible")) return const sauvegardes = DATA.wall; // Tableau pour stocker les sauvegardes if (!$(".dio_wall_compare").is(":visible")) { $("#building_wall .game_border").append( '
    ' + dio.createButton(uw.DM.getl10n("notes").btn_save) + '
    ' + '
    ' + getTexts("wall", "wallnotsaved") + '
    ' + //Les remparts ne sont pas enregistrés ''); $("#building_wall .game_list .even:eq(0)").append( '
    ' + '
    ' + '
    ' + dio.grepo_dropdown_flag("sauvegardeDropdown", null, null, null, null)[0].outerHTML + '
    ' + '
    ' + dio.grepo_dropdown_flag("comparerDropdownn", null, null, null, null)[0].outerHTML + '
    ' + '
    ' + ''); } $('#supprimerButton').tooltip(dio_icon + uw.DM.getl10n("notes").btn_delete); // Fonction pour sauvegarder les données actuelles function sauvegarderAujourdhui(t) { const currentDate = new Date(); const formattedDate = ("0" + currentDate.getDate()).slice(-2) + "." + ("0" + (currentDate.getMonth() + 1)).slice(-2) + "|" + ("0" + currentDate.getHours()).slice(-2) + ":" + ("0" + currentDate.getMinutes()).slice(-2) + ":" + ("0" + currentDate.getSeconds()).slice(-2); const dataAujourdhui = []; // Utilisez un seul tableau pour toutes les données // Sélectionnez toutes les données des éléments .wall_report_unit $('.odd .list_item_left:eq(1) .wall_report_unit, .odd .list_item_right:eq(1) .wall_report_unit').each(function () { const unitCount = parseInt($(this).data('unit_count')); const list = $(this).parent().parent().parent()[0].attributes[0].nodeValue.split('_')[2]; const type = '1' + list + $(this).data('type'); if (!t) dataAujourdhui.push({ type, count: unitCount }); if (!$('#' + type + '_difference').get(0)) $(this).after($('
    -
    ')); }); $('.odd .list_item_left:eq(2) .wall_report_unit, .odd .list_item_right:eq(2) .wall_report_unit').each(function () { const unitCount = parseInt($(this).data('unit_count')); const list = $(this).parent().parent().parent()[0].attributes[0].nodeValue.split('_')[2]; const type = '2' + list + $(this).data('type'); if (!t) dataAujourdhui.push({ type, count: unitCount }); if (!$('#' + type + '_difference').get(0)) $(this).after($('
    -
    ')); }); if (!t) { sauvegardes.push({ date: formattedDate, data: dataAujourdhui }); saveValue(WID + '_wall', JSON.stringify(sauvegardes)); uw.HumanMessage.success(dio_icon + getTexts("wall", "msghuman")); } } // Fonction pour comparer les données actuelles avec une sauvegarde sélectionnée function comparerDonnees(selectedSaveIndex) { const selectedSave = sauvegardes[selectedSaveIndex]; const dataAujourdhui = []; $('.dio_wall_diff').text("-").off('mouseenter mouseleave'); // Sélectionnez toutes les données des éléments .wall_report_unit $('.odd .list_item_left:eq(1) .wall_report_unit, .odd .list_item_right:eq(1) .wall_report_unit').each(function () { const unitCount = parseInt($(this).data('unit_count')); const list = $(this).parent().parent().parent()[0].attributes[0].nodeValue.split('_')[2]; const type = '1' + list + $(this).data('type'); dataAujourdhui.push({ type, count: unitCount }); }); $('.odd .list_item_left:eq(2) .wall_report_unit, .odd .list_item_right:eq(2) .wall_report_unit').each(function () { const unitCount = parseInt($(this).data('unit_count')); const list = $(this).parent().parent().parent()[0].attributes[0].nodeValue.split('_')[2]; const type = '2' + list + $(this).data('type'); dataAujourdhui.push({ type, count: unitCount }); }); const differences = []; // Comparez les données avec la sauvegarde sélectionnée for (let i = 0; i < dataAujourdhui.length; i++) { const { type, count: countAujourdhui } = dataAujourdhui[i]; let countSauvegarde = 0; for (let j = 0; j < selectedSave.data.length; j++) { if (selectedSave.data[j].type === type) { countSauvegarde = selectedSave.data[j].count; break; } } const diff = countAujourdhui - countSauvegarde; differences.push({ type, diff }); $('#' + type + '_difference').text(pointNumber(diff, true)); // Mettez à jour l'interface utilisateur avec les différences si nécessaire if (diff >= 100000) $('#' + type + '_difference').tooltip(pointNumber(diff, true)); } return differences; // Retournez les différences si besoin pour d'autres utilisations } // Fonction pour mettre à jour l'interface utilisateur avec les différences function mettreAJourDifferences(selectedSaveIndex) { const differences = comparerDonnees(selectedSaveIndex); if (differences.length > 0) { } // Mettez à jour l'interface utilisateur avec les différences si nécessaire else { uw.HumanMessage.error(dio_icon + getTexts("wall", "erreur")); } } // Fonction pour comparer deux sauvegardes et mettre à jour les différences dans l'interface utilisateur function comparerSauvegardes(indexSauvegarde1, indexSauvegarde2) { const sauvegarde1 = sauvegardes[indexSauvegarde1]; const sauvegarde2 = sauvegardes[indexSauvegarde2]; $('.dio_wall_diff').text("-").off('mouseenter mouseleave'); sauvegarde1.data.forEach(data => { const { type, count: countAujourdhui } = data; const countSauvegarde2 = sauvegarde2.data.find(data => data.type === type); if (countSauvegarde2) { const diff = countAujourdhui - countSauvegarde2.count; $('#' + type + '_difference').text(pointNumber(diff, true)); // Mettez à jour l'interface utilisateur avec les différences si nécessaire if (diff >= 100000) $('#' + type + '_difference').tooltip(pointNumber(diff, true)); } else { $('#' + type + '_difference').text(pointNumber(countAujourdhui, true)); // Mettez à jour l'interface utilisateur avec les différences si nécessaire if (countAujourdhui >= 100000) $('#' + type + '_difference').tooltip(pointNumber(countAujourdhui, true)); } }); } // Fonction pour mettre à jour le menu déroulant avec les nouvelles sauvegardes (du plus récent au plus ancien) function mettreAJourMenuDeroulant() { const dropdown = $('#sauvegardeDropdown'); dropdown.empty(); const sauvegardesInversees = sauvegardes.slice().reverse(); sauvegardesInversees.forEach((save, index) => { dropdown.append($('