// ==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(
'
' +
'' +
// Check latest version
'
' +
// Donate button
'
' + dio.createBtnDonate(getTexts("Settings", "Donate"), null, null, 0, getTexts("link", "Donate")) + '
' +
//
'
' +
// Settings navigation
'' +
// Settings content
'
' +
// Units tab
'
' +
' ' +
'
' + getTexts("Options", "ava")[0] + '
' +
'
' + getTexts("Options", "ava2")[0] + '
' +
'' + getTexts("Options", "ava")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "sen")[0] + '
' +
'' + getTexts("Options", "sen")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "str")[0] + '
' +
'' + getTexts("Options", "str")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "tra")[0] + '
' +
'' + getTexts("Options", "tra")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "com")[0] + '
' +
'' + getTexts("Options", "com")[1] + ' ' +
'' + getTexts("Settings", "Learn_more") + '
' +
' ' +
' ' +
'
' + getTexts("Options", "Rtt")[0] + '
' +
'' + getTexts("Options", "Rtt")[1] + '
' +
'
' +
// Icons tab
'
' +
' ' +
'
' + getTexts("Options", "tic")[0] + '
' +
'
' + getTexts("Options", "tic2")[0] + '
' +
'' + getTexts("Options", "tic")[1] + '
' +
'' +
'
' + 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") + ' ' +
'
' +
'' + getTexts("Options", "tic")[2] + ':
' +
'
' +
'
' +
'
' +
'
' +
'
' +
' ' +
' ' +
' ' +
'' + (typeof (uw.FLASK_GAME) !== "undefined" ? ('
' + getTexts("Options", "til")[0] + '
' + getTexts("Options", "FLASK")[0] + '
') : (
'
' + getTexts("Options", "til")[0] + '
')) +
'' + getTexts("Options", "til")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "tim")[0] + '
' + getTexts("Options", "tiw")[0] + '
' +
'' + getTexts("Options", "tim")[1] + '
' +
' ' +
' ' +
' ' +
'
' + getTexts("Options", "tow")[0] + '
' +
'' + getTexts("Options", "tow")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "Tol")[0] + '
' +
'' + getTexts("Options", "Tol")[1] + '
' +
'
' +
// Forum tab
'
' +
' ' +
'
' + getTexts("Options", "sml")[0] + '
' +
'' + getTexts("Options", "sml")[1] + '
' +
' ' +
' ' +
' ' +
' ' +
' ' +
' ' +
' ' +
' ' +
' ' +
'
' + getTexts("Options", "bbc")[0] + '
' +
'' + getTexts("Options", "bbc")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "Fdm")[0] + '
' +
'' + getTexts("Options", "Fdm")[1] + '
' +
'
' +
// Trade tab
'
' +
' ' +
'
' + getTexts("Options", "rec")[0] + '
' +
'' + getTexts("Options", "rec")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "per")[0] + '
' +
'' + getTexts("Options", "per")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "Tti")[0] + '
' +
'' + getTexts("Options", "Tti")[1] + '
' +
' ' +
'
' +
// Layout tab
'
' +
' ' +
'
' + getTexts("Options", "sim")[0] + '
' +
'' + getTexts("Options", "sim")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "tsk")[0] + '
' +
'' + getTexts("Options", "tsk")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "pop")[0] + '
' +
'' + getTexts("Options", "pop")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "con")[0] + '
' +
'' + getTexts("Options", "con")[1] + '
' +
' ' +
((Browser !== 'Firefox') ? ('' +
' ' +
'
' + getTexts("Options", "Scr")[0] + '
' +
'' + getTexts("Options", "Scr")[1] + '
' +
' ' +
' ') : "") +
'' +
' ' +
'
' + getTexts("Options", "act")[0] + '
' +
'' + getTexts("Options", "act")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "Cic")[0] + '
' +
'' + getTexts("Options", "Cic")[1] + '
' +
'
' +
//reports
'
' +
' ' +
'
' + getTexts("Options", "way")[0] + '
' +
'' + getTexts("Options", "way")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "cnt")[0] + '
' +
'' + getTexts("Options", "cnt")[1] + '
' +
' ' +
' ' +
' ' +
'' + (typeof (uw.FLASK_GAME) !== "undefined" ? ('
' + getTexts("Options", "Sel")[0] + '
' + getTexts("Options", "FLASK")[0] + '
') : (
'
' + getTexts("Options", "Sel")[0] + '
')) +
'' + getTexts("Options", "Sel")[1] + '
' +
'
' +
// Other Stuff tab
'
' +
' ' +
'
' + getTexts("Options", "scr")[0] + '
' +
'' + getTexts("Options", "scr")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "BBt")[0] + '
' +
'' + getTexts("Options", "BBt")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "rew")[0] + '
' +
'' + getTexts("Options", "rew")[1] + '
' +
' ' +
/*' ' +
'
' + getTexts("Options", "err")[0] + '
' +
'' + getTexts("Options", "err")[1] + '
' +*/
//((Game.features.is_domination_active = false) ? (
((uw.Game.features.end_game_type == "end_game_type_world_wonder") ? (
' ' +
'
' + getTexts("Settings", "cat_wonders") + getTexts("Options", "wwc")[0] + '
' +
'' + getTexts("Options", "wwc")[1] + '
' +
' ' +
' ') : "") +
'
' +
// Premium
'
' +
' ' +
'
' + getTexts("Options", "Cul")[0] + '
' +
'' + getTexts("Options", "Cul")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "Cup")[0] + '
' +
'' + getTexts("Options", "Cup")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "Cuo")[0] + '
' +
'' + getTexts("Options", "Cuo")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "Hio")[0] + '
' +
'' + getTexts("Options", "Hio")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "Rct")[0] + '
' +
'' + getTexts("Options", "Rct")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "Ish")[0] + '
' +
'' + getTexts("Options", "Ish")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "Cuc")[0] + '
' +
'' + getTexts("Options", "Cuc")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "Buc")[0] + '
' +
'' + getTexts("Options", "Buc")[1] + '
' +
'
' +
// Quack
'
' +
' ' +
'
' + getTexts("Options", "Mse")[0] + '
' +
'' + getTexts("Options", "Mse")[1] + ' ' +
'' + getTexts("Settings", "Learn_more") + '
' +
' ' +
' ' +
'
' + getTexts("Options", "Hot")[0] + '
' +
'' + getTexts("Options", "Hot")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "Isl")[0] + '
' +
'' + getTexts("Options", "Isl")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "Hid")[0] + '
' +
'' + getTexts("Options", "Hid")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "Cib")[0] + '
' +
'' + getTexts("Options", "Cib")[1] + '
' +
' ' +
' ' +
'' + (typeof (uw.MoleHoleOnBoard) !== "undefined" ? ('
' + getTexts("Options", "Ciw")[0] + '
' + getTexts("Options", "Mole")[0] + '
') : (
'
' + getTexts("Options", "Ciw")[0] + '
')) +
'' + getTexts("Options", "Ciw")[1] + '
' +
' ' +
((MID == 'fr' || MID == 'de' || MID == 'en' || MID == 'zz') ? (
' ' +
'
' + getTexts("Options", "Rep")[0] + '
' +
'' + getTexts("Options", "Rep")[1] + '
') : "") +
'
' +
// GRCT
'
' +
' ' +
'
' + getTexts("Options", "BBl")[0] + '
' +
'' + getTexts("Options", "BBl")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "Amm")[0] + '
' +
'' + getTexts("Options", "Amm")[1] + '
' +
' ' +
'' + getTexts("Settings", "Comp_GRCT") + '
' +
' ' +
' ' +
'
' + getTexts("Options", "Onb")[0] + '
' +
'' + getTexts("Options", "Onb")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "Idl")[0] + '
' +
'' + getTexts("Options", "Idl")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "Saw")[0] + '
' +
'' + getTexts("Options", "Saw")[1] + '
' +
' ' +
' ' +
'
' + getTexts("Options", "Att")[0] + '
' +
'' + getTexts("Options", "Att")[1] + '
' +
'' + getTexts("labels", "Volume") + ' ' +
//'URL https:// .mp3: ' +
//' ' +
//'Définir l\'URL ' +
'
' +
/*' ' +
' ' +
'' +
'?????
' +*/
'
' +
'
' +
// Links (Forum, PM, ...)
'
' +
'
');
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 = '' + (group = null == group ? "" : '');
var option_image = "";
if (label != null) {
$.each(label, (a, b) => {
str += '' + b + ' '
});
};
str += (group = null == group ? "" : ' ') + (group2 = null == group2 ? "" : '');
$.each(Options, (a, b) => {
if (LANG[b]) { option_image = '' + Home_url + '/img/flag/flag.16.' + b + '.png'; }
else { option_image = ""; }
var option_name = (LANG[b]) ? b.toUpperCase() : b;
str += '' + option_name + ' '
});
str += ((group = null == group) || (group2 = null == group2) ? "" : ' ') + ' ';
return $(str);
},
grepo_dropdown: (ID, Class, Options, sel) => {
var str = '';
$.each(Options, function (a, b, c) { //class, name, ><
if (b[2]) { str += '
' + (b[2] == true ? b[1] : b[2]) + '
' }
else if (b[1]) { str += '
' }
else { str += '
' }
});
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 $(' ');
},
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") + '
';
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") + '
';
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 = '
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'
' + 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 =
'
' +
'' +
'' +
'' +
'
' +
'
' + 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] + '
' +
'
' +
'' + getTexts("labels", "donat") + ' ' +
(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 += '' + donations[d][4] + ' ' + donations[d][2] + '€ ';
}
for (d = 0; d < donations2.length; d++) { donation_table2 += '' + donations2[d][4] + ' ' + donations2[d][2] + '€ '; }
for (d = 0; d < donations3.length; d++) { donation_table3 += '' + donations3[d][4] + ' ' + donations3[d][2] + '€ '; }
for (d = 0; d < donations4.length; d++) { donation_table4 += '' + donations4[d][4] + ' ' + donations4[d][2] + '€ '; }
return donation_table + '
' + 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.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", "trans_infotext1") + ' ' +
''; // style="opacity:0.30;"
$.each(languages, function (index, language) {
if (language != getTexts("translations", "info") & language != getTexts("translations", "add_lang")) { HTML_tab3 += '
'; }
});
HTML_tab3 += '
' +
'' + getTexts("translations", "trans_infotext2") + ' ' +
' ' +
'' + getTexts("translations", "trans_infotext3") +
' ' + getTexts("translations", "trans_infotext4") + ' ' +
'' + dio.createButton(getTexts("translations", "send")) + '
' +
'' + getTexts("translations", "trans_infotext5") + ' ' +
'' + getTexts("translations", "trans_infotext6") + ' ' +
'' +
'' + getTexts("Settings", "cat_forum") + ' ' +
'' +
'' + getTexts("Settings", "forum") + ' ' +
'' +
'Discord ' +
' ' + getTexts("translations", "credits") + ': ';
HTML_tab3 += '' +
(function () {
var translations = [
["DE", "Diony / Krieger des Lichts / Anastasia23"],
["EN", "Diony"],
["IT", "amliam / Pyrux"],
["FR", "eclat49 / David1327"],
["RU", "MrBobr"],
["PL", "anpu / Drbrzeszczot"],
["ES", "Juana de Castilla"],
["BR", "HELL / BUGS"],
["CZ", "Piwus"],
["RO", "Nicolae01"],
["NL", "Firebloem / Analist434343"],
["GR", "AbstractGR"],
];
translations.sort()
var translation_table = "";
for (var d = 0; d < translations.length; d++) {
translation_table += '' + translations[d][0] + ': ' + translations[d][1] + ' ';
}
return translation_table;
})() +
'
';
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.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 = "" + 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 = "" + 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 += '' + getTexts("translations", "name") + '
';
langHTML_tab3 += ' ';
langHTML_tab3 += '
';
}
$.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 += '' + d + '
';
langHTML_tab3 += (LANG[lang_tab3] != undefined && LANG[lang_tab3][a] != undefined && LANG[lang_tab3][a][c] != undefined) ?
' ' : ' ';
langHTML_tab3 += ' ';
}
else {
langHTML_tab3 += '' + d[0] + '\n
' + d[1] + '
';
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 += '
';
}
});
$("#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 = "