// // ==UserScript== // // @name IkaTweaks // @description Improvements for Ikariam // @version 2.2 // @author Yvonne P. // @license MIT; https://opensource.org/licenses/MIT // @icon http://de.ikariam.gameforge.com/favicon.ico // @namespace YveOne // @include /^https?:\/\/s\d+-\w+\.ikariam\.gameforge\.com.*?$/ // @run-at document-start // // @downloadURL none // ==/UserScript== // /* jshint esversion: 6 */ /* global $ */ /* global ikariam */ /* global ajax */ /* global GM_info */ /* global dataSetForView */ /* global LocalizationStrings */ (function(window){ "use strict"; var jshintUnused; //-------------------------------------------------------------------------------------------------- // CONSTANTS const _LINKS_ = { OnePiece : 'http://www.iconarchive.com/show/one-piece-character-icons-by-crountch.html', GreasyFork : 'https://greasyfork.org/de/scripts/401313-ikatweaks', OpenUserJS : 'https://openuserjs.org/scripts/YveOne/IkaTweaks', GitHubRepo : 'https://github.com/YveOne/Userscript-IkaTweaks', }; // CONSTANTS //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- // SYSTEM FUNCTIONS function forEach(obj, func) {for(var k in obj){if(obj.hasOwnProperty(k)){func(obj[k],k,obj);}}} function jsonDecode(str, dflt) {var obj=null;try{obj=JSON.parse(str);}catch(e){}return((obj!==null)?obj:dflt);} function injectCSS(cssText) {var el=document.createElement('style');el.setAttribute('type','text/css');if(el.styleSheet){el.styleSheet.cssText=cssText;}else{el.appendChild(document.createTextNode(cssText));}document.querySelector('head').appendChild(el);return el;} function hookFunction(obj, fn, cb) {(function(of){obj[fn]=function(){var ret=of.apply(this,arguments);cb.apply(this,[ret,of,arguments]);return ret;};}(obj[fn]));} function waitFor(cond, func, tOut, sleep) {sleep=sleep||33;var tEnd=tOut?(new Date()).getTime()+tOut:null;var ret,w4=function(){ret=cond();if(ret){return func(ret);}if(tEnd && tEnd<(new Date()).getTime()){return func(false);}setTimeout(w4,sleep);};w4();} function removeElement(el) {try{return el.parentNode.removeChild(el);}catch(e){}return null;} function forceInt(str) {return parseInt(str.replace(/\D/g, ''));} function randomInclusive(min, max) {min=Math.ceil(min);max=Math.floor(max);return Math.floor(Math.random()*(max-min+1))+min; } function timestamp() {return Math.round(new Date().getTime()/1000)} // v3 (c) Yvonne P. function LocalStorageHandler(tag) { var data = JSON.parse(localStorage.getItem(tag)) || { storedKeys : {}, }; function unsetItem(k1) { var s = {}; forEach(data.storedKeys, (_, k) => { if (k1 !== k) { s[k] = data.storedKeys[k]; } }); if (data) { data.storedKeys = s; } localStorage.setItem(tag, JSON.stringify(data)); } function setItem(k) { if (data) { data.storedKeys[tag] = (new Date()).getTime(); data.storedKeys[k] = (new Date()).getTime(); } localStorage.setItem(tag, JSON.stringify(data)); } this.drop = function(key) { key = tag+key; localStorage.removeItem(key); unsetItem(key); return (typeof localStorage.getItem(key) == 'undefined'); }; this.save = function(key, val) { key = tag+key; localStorage.setItem(key, val); setItem(key); return (localStorage.getItem(key) == val); }; this.load = function(key, dflt) { key = tag+key; var v = localStorage.getItem(key); return (v!==null ) ? v : dflt; }; this.data = function() { return JSON.parse(JSON.stringify(data)); }; this.clear = function(t) { var b = true; if (typeof t == 'string') { var s = [t]; forEach(data.storedKeys, (_, k) => { s.push(' "'+k+'"'); }); b = confirm(s.join("\n")); } if (b) { forEach(data.storedKeys, (_, k) => { localStorage.removeItem(k); }); data = null; return true; } return false; }; } // v2 (c) Yvonne P. function EasyTemplates() { var that = this; var tplList = {}; var regExpParseHtml = new RegExp('\\{[a-zA-Z0-9_]+\\}', 'gi'); this.set = function(id, html) { tplList[id] = html; }; this.get = function(id, data) { id = id || ''; return (tplList[id]) ? that.parse(tplList[id], data) : 'Template "'+id+'" not found'; }; this.getEach = function(obj, func) { var ret = []; var keys = Object.keys(obj); while(keys.length) { var k = keys.shift(); var a = func(obj[k], k, obj); if(a) ret.push(that.get.apply(null, a)); } return ret.join(''); }; this.parse = function(html, data) { html = html || ''; data = data || {}; return html.replace(regExpParseHtml, function(x){ var y = data[x.substr(1, x.length-2)]; return (y!==null && typeof y!='undefined') ? y : x; }); }; } // v3 (c) Yvonne P. function LanguageHandler(useLocal, baseLocal) { var str = {}; var ctr = {}; var als = {}; function get(k) { return (typeof str[k]=='string') ? str[k] : k; } function set(c, l, n) { if (c instanceof Array) { while(c.length) { set(c.shift(), n); } return; } if (als[c] == useLocal) { c = als[c]; } ctr[c] = l; if (c == baseLocal) { forEach(n, (v, k) => { if (v !== null) { str[k] = (typeof str[k]=='string') ? str[k] : v.toString(); } }); } else { if (c == useLocal) { forEach(n, (v, k) => { if (v !== null) { str[k] = v.toString(); } }); } } } var ret = function() { if(arguments.length==1) return get.apply(null, arguments); if(arguments.length==3) return set.apply(null, arguments); return str; }; ret.codes = function() { return JSON.parse(JSON.stringify(ctr)); }; ret.alias = function(a, b) { als[a] = b; }; ret.local = function() { return useLocal; }; return ret; } const TPL = new EasyTemplates(); const LS = new LocalStorageHandler('IkaTweaks_'); const LANG = LanguageHandler(LS.load('LANG', location.hostname.match(/s\d+\-(\w+)\.ikariam\.gameforge\.com/i)[1]), 'en'); // SYSTEM FUNCTIONS //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- // HTML: Select DropDown TPL.set('SelectContainer', `
`); TPL.set('SelectOption', ` `); function SelectDropDown(selectId, size, options, selected) { this.val = function() { return $(`#js_${selectId}Options`).val(); }; this.tpl = function() { return TPL.get('SelectContainer', { selectSize : size, selectId : selectId, selectOptions : TPL.getEach(options, function(v, k){ return ['SelectOption', { value : k, text : v, selected: (selected == k) ? 'selected="selected"' : '', }]; }), }); }; this.change = function(cb) { $('#js_'+selectId+'Options').change(cb); }; } // HTML: Select DropDown //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- // HTML: Checkboxes function isChecked(id) { return $(id+'Img').hasClass('checked'); } // HTML: Checkboxes //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- // hooks (function(){ const _injectCSS = injectCSS; const queue = []; var headAvailable = false; injectCSS = function(css, cb) { if (headAvailable) { (cb||function(){})(_injectCSS(css)); } else { queue.push([css, cb]); } }; waitFor(function(){ return document.querySelector('head'); }, function(){ headAvailable = true; while(queue.length) { injectCSS.apply(null, queue.shift()); } }, 2000, 33); }()); waitFor.ajaxResponder = (function(waitFor){ var resp = false; var queue = []; waitFor(function(){ try{return ikariam.controller;}catch(e){} return false; }, function(ctrl){ if(!ctrl || ctrl===null) return; if(ctrl.ajaxResponder===null){ctrl.ajaxResponder=ikariam.getClass(ajax.Responder);} resp = ctrl.ajaxResponder; while(queue.length) { queue.shift()(resp); } }, 2000, 100); return function(cb) { if (typeof cb !== 'function') return; if (resp) { cb(resp); } else { queue.push(cb); } }; }(waitFor)); // hooks //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- // CORE const IkaTweaks = {}; (function(IkaTweaks){ const mainViewIcon = 'https://raw.githubusercontent.com/YveOne/Userscript-IkaTweaks/master/images/mainViewIcon.png'; var enabledModules = jsonDecode(LS.load('modules'), {}); var definedModules = {}; var sidebarButtons = []; function loadModule(modId) { var modData = jsonDecode(LS.load(modId), {}); definedModules[modId].func(modData, function() { LS.save(modId, JSON.stringify(modData)); }); } injectCSS(` #IkaTweaks_sidebar1 .centerButton .button {width:200px;margin:2px 0px;} #IkaTweaks_sidebar2 .centerButton .button {width:200px;margin:2px 0px;} #IkaTweaks_c:before, #UpdateChecker_c:before { content: url('${mainViewIcon}'); } /** extend h3 header **/ .contentBox01h .header.hidden { overflow: hidden; height: 0px; padding-top: 7px; } `); IkaTweaks.setModule = function(modId, modFunc) { if (typeof enabledModules[modId] == 'undefined') enabledModules[modId] = false; definedModules[modId] = { name: `{str_${modId}_name}`, info: `{str_${modId}_info}`, func: modFunc, }; if (enabledModules[modId]) { loadModule(modId); } // window icon injectCSS(`#${modId}_c:before { content: url('${mainViewIcon}'); }`); }; IkaTweaks.addSidebarButton = function(btnText, btnFunc, useTop) { sidebarButtons.push({text:btnText,func:btnFunc,useTop:useTop}); }; IkaTweaks.success = function(t) { if (!t) { t = LANG('str_success'+randomInclusive(0,4)); } ikariam.controller.ajaxResponder.provideFeedback([{ location: 1, text: t, type: 10 }]); }; IkaTweaks.warning = function(t) { ikariam.controller.ajaxResponder.provideFeedback([{ location: 1, text: t, type: 11 }]); }; IkaTweaks.notice = function(t) { ikariam.controller.ajaxResponder.provideFeedback([{ location: 1, text: t, type: 12 }]); }; IkaTweaks.changeHTML = function(id, html, cb) { waitFor.ajaxResponder((ajaxResponder) => { html = TPL.get('IkaTweaksFrame', { version : GM_info.script.version, mainview: html, buttons1: TPL.getEach(sidebarButtons, function(btn, i){ return (!btn.useTop) ? null : ['IkaTweaksSidebar_button', { btnId: 'IkaTweaksSidebar_button'+i, btnText: btn.text }]; }), buttons2: TPL.getEach(sidebarButtons, function(btn, i){ return (btn.useTop) ? null : ['IkaTweaksSidebar_button', { btnId: 'IkaTweaksSidebar_button'+i, btnText: btn.text }]; }), }); html = TPL.parse(html, LANG()); ajaxResponder.changeHTML([id,html], true); setTimeout(ikariam.controller.adjustSizes, 1000); var sidebarButtonsLength = sidebarButtons.length; for(var i=0; i

{str_IkaTweaks} {version}

{buttons1}

{str_modules}

{buttons2}
{mainview} `); TPL.set('IkaTweaksSidebar_button', ` `); TPL.set('IkaTweaksMainview_tabbedWindow', `

{str_IkaTweaks_menu}

{mainviewContent}
`); TPL.set('IkaTweaksMainview_modulesWindow', `

{str_IkaTweaks_tabModules}

{modulesTR}
{str_enabled} {str_name} {str_description}
`); TPL.set('IkaTweaksMainview_tabbedWindow_modulesTR', ` {modName} {modInfo} `); TPL.set('IkaTweaksMainview_aboutWindow', `
{select}

{str_IkaTweaks_aboutHeader}

{str_ClearStorageInfo}

{str_IkaTweaks_creditsHeader}

{str_IkaTweaks_aboutCredits}
`); var showSettingsWindow, showAboutWindow, tutorialHintInterval; showSettingsWindow = function(){ IkaTweaks.changeHTML('IkaTweaks', TPL.get('IkaTweaksMainview_tabbedWindow', { mainviewContent: TPL.get('IkaTweaksMainview_modulesWindow', { modulesTR: TPL.getEach(definedModules, function(mod, modId){ return ['IkaTweaksMainview_tabbedWindow_modulesTR', { modId : modId, modName : mod.name, modInfo : mod.info, checked : enabledModules[modId] ? 'checked="checked"' : '', }]; }), }), }), function(){ $('#IkaTweaks_modulesTable tr').not(':even').addClass('alt'); ikariam.controller.replaceCheckboxes(); $('#js_tab_IkaTweaksMainview_modulesWindow').addClass('selected'); $('#js_tab_IkaTweaksMainview_modulesWindow').click(showSettingsWindow); $('#js_tab_IkaTweaksMainview_aboutWindow').click(showAboutWindow); $('#js_IkaTweaks_saveModulesButton').click(function(){ var l = {}; forEach(definedModules, (_, modId) => { l[modId] = isChecked('#IkaTweaksMainview_Checkbox'+modId); }); enabledModules = l; LS.save('modules', JSON.stringify(enabledModules)); LS.save('reopenSettingWindow', '1'); location.reload(); }); if(document.getElementById('js_IkaTweaks_tutorialArrow')) { clearInterval(tutorialHintInterval); LS.save('tutorialDone', '1'); $('#js_IkaTweaks_tutorialArrow').fadeOut(); } }); }; showAboutWindow = function(){ var LangSelect = new SelectDropDown('IkaTweaks_Languages', 175, LANG.codes(), LANG.local()); IkaTweaks.changeHTML('IkaTweaks', TPL.get('IkaTweaksMainview_tabbedWindow', { mainviewContent: TPL.get('IkaTweaksMainview_aboutWindow', { select : LangSelect.tpl(), }), }), function(){ ikariam.controller.replaceDropdownMenus(); $('#js_tab_IkaTweaksMainview_aboutWindow').addClass('selected'); $('#js_tab_IkaTweaksMainview_modulesWindow').click(showSettingsWindow); $('#js_tab_IkaTweaksMainview_aboutWindow').click(showAboutWindow); $('#js_IkaTweaks_saveLanguageButton').click(function(){ LS.save('LANG', LangSelect.val()); LS.save('reopenSettingWindow', '1'); location.reload(); }); $('#js_IkaTweaks_clearStorageButton').click(function(){ if(LS.clear()) { LS.save('reopenSettingWindow', '1'); location.reload(); } }); $('#js_IkaTweaks_openGreasyForkButton').attr({ 'href': _LINKS_.GreasyFork, 'target': '_blank', }); $('#js_IkaTweaks_openOpenUserJSButton').attr({ 'href': _LINKS_.OpenUserJS, 'target': '_blank', }); $('#js_IkaTweaks_openGitHubRepoButton').attr({ 'href': _LINKS_.GitHubRepo, 'target': '_blank', }); $('#myEmail').attr('style', 'position:absolute;width:82px;height:14px;display:inline-block;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFIAAAAOCAYAAAC8YEsXAAAACXBIWXMAAAsTAAALEwEAmpwYAAAABGdBTUEAALGOfPtRkwAAACBjSFJNAAB6JQAAgIMAAPn/AACA6QAAdTAAAOpgAAA6mAAAF2+SX8VGAAADP0lEQVR42mL8//8/wyigHAAEEAuMEaor8A7KTAfi1WSYFQrEaUDsCsRKUH4nCfrLgdgFiI2h/LNAvAfNjA4oXQHEu4F4FpluJQRAYSFEwK8zQYzVlz+A1QEEEAuSpCDUgWfJtPws1GPIHiYWnIEG4Cxo4DFAI6MDGriuSGIwMIsCtxICgkT4tRPZnwABxISmACR5D8qeCY0ZEF6FpEYJ6nGYeAc0EAShtDHU8y7QVAaLQZieu1A+DOyG0oxQM8qhZtyDRqwSkjnIwBhJfSia+2YiqUF2qxKeFAZTV44lp9yFysEC7h56bgMIICYcBq+CZtNOKA5FMuQMUqAbI2VJF6gedKAENQ8Wi2eRIgYW8CbQADWGqlFCss8VRwpPg9opiOb5NKg5sAi/h2TmGSLc14EWwB3Q4qMTas8qbAEGEECMsMoGWEb+h6YKWCzsQco6yA46g6QOBP5DUw5MnxCSZWFYyktjJDNWIZWFIDFlqD1K0FQA47/DYu47qJmr0dTC3CMIDWgTNLeaoBUJHWjqkN13Buq2CixyYPOAZSSYDRBAuFLkPaij/0MxrAIAWfgeTe17AuXJPaj+d1CzkFOFCzQw0qAOvoekB5kWJGD+PaSUyICUAo2R/PAfyU70FHkPrfxDlitH0n8GlyMAAghf1t4DjSVGpJrxHhZPESqYO5BSJCNaakY24z2anntI2YtQpTILGpBpSGrfQ/3AiIRNsLQk3qP5QQlNrgKLGRgAIICY8DgOlrWRC/PVaLVyBxE1nyCecuoeUkCFIqWAciSxVdAmGT7QCbUnDSmgZqFVeOVQu5WwRAKyOuQycDVSZQqT243NAQABxITHYbCs3QH1lBJS+QRL7ml4mgcuUIfDPPkfWpa9RypvVkPN6oRG3F0kPiwQYeWsEhFNEuTIPgtNTR1I/qiARl45tKjBpg45Z1RAzTsDlXPBFakAAYSrsiGUVSsIFOCkNn73IHkSWzHjQqCBPFAAXtkABBATFkcbE9CcBk05q6CB8J7ChrEJNMXeRTJ3FVIqEMRVLg0gMEZvBgEEEBNaeUCsx1cjlS+UppR70LaiMlLPiAGpsnPFkVIHA4CHGUAAMY4OWlAHAAQYAH37+Z/ovMxFAAAAAElFTkSuQmCC);'); $('#myEmail').after(''); $('#creditUrl1').attr({ 'href': _LINKS_.OnePiece, 'target': '_blank', }).html(_LINKS_.OnePiece); }); }; waitFor(function(){ return (typeof $ != 'undefined'); }, function(jQ){ if(!jQ) return; $('#GF_toolbar ul li.options').after($('
  • ').append($('',{ 'id' : 'IkaTweaksToolbarButton', 'click': function(){ showSettingsWindow();return false; }, 'href' : '#', 'class': 'noViewParameters', 'title': 'IkaTweaks', 'text' : 'IkaTweaks' }))); var tutorialDone = LS.load('tutorialDone'); var showArrow = !tutorialDone; switch(LS.load('version', false)) { case false: if (tutorialDone) { alert(`IkaTweaks: Important information!\n\nThis new version contains a lot of changes and bug fixes. Please open the menu and check your settings.\nSorry for the inconveniences and thanks for using (and supporting) IkaTweaks =)`); showArrow = true; } break; } LS.save('version', GM_info.script.version); if(showArrow) { var e=20; var arrow = $('
    ').attr({ 'id': 'js_IkaTweaks_tutorialArrow', 'class': 'aniArrow', 'style': 'top:'+e+'px;display:block;', }).appendTo($('#IkaTweaksToolbarButton'))[0]; var arrowCounter=0; tutorialHintInterval = setInterval(function(){ arrow.style.top = (e+(Math.sin(++arrowCounter/15)*10))+'px'; }, 10); } if(LS.load('reopenSettingWindow')) { LS.drop('reopenSettingWindow'); showSettingsWindow(); } }, 3000, 333); IkaTweaks.addSidebarButton('{str_IkaTweaks_menu}', showSettingsWindow, true); })(IkaTweaks); // CORE //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- // MODULE: GeneralTweaks IkaTweaks.setModule('GeneralTweaks', function(modData, modDataSave){ // bug fixes if(typeof modData.fixResearchWindowList == 'undefined') modData.fixResearchWindowList = true; if(typeof modData.fixCitySelectItems == 'undefined') modData.fixCitySelectItems = true; if(typeof modData.fixWindowTopPadding == 'undefined') modData.fixWindowTopPadding = true; if(typeof modData.fixScrollbars == 'undefined') modData.fixScrollbars = true; if(typeof modData.fixHoverEffectSwitching == 'undefined') modData.fixHoverEffectSwitching = true; // anti ads if(typeof modData.adsHideSpeedUpButton == 'undefined') modData.adsHideSpeedUpButton = false; if(typeof modData.adsHideWindowAds == 'undefined') modData.adsHideWindowAds = true; if(typeof modData.adsHideHappyHour == 'undefined') modData.adsHideHappyHour = false; if(typeof modData.adsHideOfferBoxes == 'undefined') modData.adsHideOfferBoxes = true; if(typeof modData.adsHideSlotResourceShop == 'undefined') modData.adsHideSlotResourceShop = false; if(typeof modData.adsHideSlotPremiumTrader == 'undefined') modData.adsHideSlotPremiumTrader = false; if(typeof modData.adsHideArchiveButtons == 'undefined') modData.adsHideArchiveButtons = false; if(typeof modData.adsHideMilitaryDummies == 'undefined') modData.adsHideMilitaryDummies = false; if(typeof modData.adsHideAdvisorButtons == 'undefined') modData.adsHideAdvisorButtons = false; // animations if(typeof modData.animHideWalkers == 'undefined') modData.animHideWalkers = false; if(typeof modData.animHideBirdsOnly == 'undefined') modData.animHideBirdsOnly = false; if(typeof modData.animHideWalkerBubbles == 'undefined') modData.animHideWalkerBubbles = false; // cities if(typeof modData.cityIgnoreCapital == 'undefined') modData.cityIgnoreCapital = false; if(typeof modData.cityHidePirateFortress == 'undefined') modData.cityHidePirateFortress = false; if(typeof modData.cityHideLockedPosition == 'undefined') modData.cityHideLockedPosition = false; if(typeof modData.cityUseCustomBackground == 'undefined') modData.cityCustomBackground = false; if(typeof modData.cityCustomBackground == 'undefined') modData.cityCustomBackground = 0; if(typeof modData.cityHideDailyTasks == 'undefined') modData.cityHideDailyTasks = false; if(typeof modData.cityHideRegistrationGifts == 'undefined') modData.cityHideRegistrationGifts = false; if(typeof modData.cityHideFlyingShop == 'undefined') modData.cityHideFlyingShop = true; if(typeof modData.cityHideAmbrosiaFountain == 'undefined') modData.cityHideAmbrosiaFountain = true; // ressources if(typeof modData.ressShowMissing == 'undefined') modData.ressShowMissing = true; if(typeof modData.ressShowRemaining == 'undefined') modData.ressShowRemaining = false; // interactive if(typeof modData.fixHoverToBackground == 'undefined') modData.fixHoverToBackground = false; if(typeof modData.actShowMouseoverPlaques == 'undefined') modData.actShowMouseoverPlaques = false; if(typeof modData.actHideMouseoverTitles == 'undefined') modData.actHideMouseoverTitles = false; if(typeof modData.actPreventPlaqueScaling == 'undefined') modData.actPreventPlaqueScaling = false; // // cities // const CITY_BACKGROUNDS_COUNT = 5; const CITY_BACKGROUNDS = [ { 'nw': '//gf2.geo.gfsrv.net/cdn1b/1e250328264c77f3d5d2de7176bf3b.jpg', 'ne': '//gf1.geo.gfsrv.net/cdnc1/552b032dccb6186776fa0a8e7aff38.jpg', 'sw': '//gf1.geo.gfsrv.net/cdn36/d1c51f8791b8dd42887b4f4cab84a5.jpg', 'se': '//gf2.geo.gfsrv.net/cdna2/bc0dc662a07cc16cdd6622f599a7cb.jpg', }, { 'nw': '//gf1.geo.gfsrv.net/cdn01/29c74235f5eff480c7f7c205e644fe.jpg', 'ne': '//gf3.geo.gfsrv.net/cdn54/ee1e1655ebd0b1a7e5c0bc584824a4.jpg', 'sw': '//gf1.geo.gfsrv.net/cdnf7/07f4d3bb04d1cfc0ec565aee163ed2.jpg', 'se': '//gf2.geo.gfsrv.net/cdn14/0aee9fee17624ef1322ee6f6133309.jpg', }, { 'nw': '//gf1.geo.gfsrv.net/cdn3b/2b919d92c79b0b9a80cefafe88ef58.jpg', 'ne': '//gf3.geo.gfsrv.net/cdne1/4d56d4e51fefd7cd46ece81109f119.jpg', 'sw': '//gf2.geo.gfsrv.net/cdn10/df064c1633744b1c33cc4573575891.jpg', 'se': '//gf3.geo.gfsrv.net/cdnba/1c46d69d1413178b52ac9a82f32048.jpg', }, { 'nw': '//gf3.geo.gfsrv.net/cdn88/88e5a1eb809101da2282719be49d7e.jpg', 'ne': '//gf2.geo.gfsrv.net/cdn42/7345451d8a2b1184ef6b6df6878267.jpg', 'sw': '//gf2.geo.gfsrv.net/cdn43/a6f005720cf4571d51aebaa2437036.jpg', 'se': '//gf3.geo.gfsrv.net/cdn81/cd248b5153bee36d2308765f7894bd.jpg', }, { 'nw': '//gf2.geo.gfsrv.net/cdn1a/3d1c1893f5c157a63e54560d9c1604.jpg', 'ne': '//gf2.geo.gfsrv.net/cdn44/462ee215d7a6c299758d0c30aa48bc.jpg', 'sw': '//gf2.geo.gfsrv.net/cdna6/44fb3d605e47d91f1b978788be16ed.jpg', 'se': '//gf2.geo.gfsrv.net/cdn40/c52fc8f2b70787f27a15b4f62e323c.jpg', }, ]; const CITY_BACKGROUNDS_CAPITAL = [ { 'nw': '//gf2.geo.gfsrv.net/cdn1b/1e250328264c77f3d5d2de7176bf3b.jpg', 'ne': '//gf2.geo.gfsrv.net/cdn1b/2a9c139ad689ed5a5838d1b5d65bb5.jpg', 'sw': '//gf1.geo.gfsrv.net/cdn36/d1c51f8791b8dd42887b4f4cab84a5.jpg', 'se': '//gf3.geo.gfsrv.net/cdnea/94eaf99ed5ac493a18ed532df203fa.jpg', }, { 'nw': '//gf1.geo.gfsrv.net/cdn01/29c74235f5eff480c7f7c205e644fe.jpg', 'ne': '//gf3.geo.gfsrv.net/cdnbd/5316ff26044f7fa39c37e905024309.jpg', 'sw': '//gf1.geo.gfsrv.net/cdnf7/07f4d3bb04d1cfc0ec565aee163ed2.jpg', 'se': '//gf3.geo.gfsrv.net/cdne2/d2f889c380847628d9d843e0a787d3.jpg', }, { 'nw': '//gf1.geo.gfsrv.net/cdn3b/2b919d92c79b0b9a80cefafe88ef58.jpg', 'ne': '//gf3.geo.gfsrv.net/cdn80/3972d1d22db3b9b49e584948275208.jpg', 'sw': '//gf2.geo.gfsrv.net/cdn10/df064c1633744b1c33cc4573575891.jpg', 'se': '//gf2.geo.gfsrv.net/cdnd2/b069fd71423e719623114c24f6f507.jpg', }, { 'nw': '//gf2.geo.gfsrv.net/cdn41/4aff5cf60ff96eb23c895080f236f1.jpg', 'ne': '//gf2.geo.gfsrv.net/cdnd6/65c6ef4f57cc4467d7a91c6ab34c88.jpg', 'sw': '//gf2.geo.gfsrv.net/cdn43/a6f005720cf4571d51aebaa2437036.jpg', 'se': '//gf3.geo.gfsrv.net/cdned/09edd1df297346b09f7de8a6c021f4.jpg', }, { 'nw': '//gf2.geo.gfsrv.net/cdnd6/875162f980bf06afcbc2dd3af6d23c.jpg', 'ne': '//gf1.geo.gfsrv.net/cdn01/eeba3ad6b113d71ef18fb594070641.jpg', 'sw': '//gf2.geo.gfsrv.net/cdna6/44fb3d605e47d91f1b978788be16ed.jpg', 'se': '//gf2.geo.gfsrv.net/cdn46/12f80c826b9a4f841f3bd0d49df1d3.jpg', }, ]; // // interactive // function actRescalePlaques() { switch(ikariam.backgroundView.id) { case 'city': if (modData.actPreventPlaqueScaling) { var s = 1/ikariam.worldview_scale_city; $('.timetofinish').each(function() { $(this).css('transform', 'scale(' + s + ')'); }); } else { $('.timetofinish').each(function() { $(this).css('transform', ''); }); } break; case 'island': if (modData.actPreventPlaqueScaling) { var s = 1/ikariam.worldview_scale_island; $('#island .location_list .cityLocationScroll').each(function() { $(this).css('transform', 'scale(' + s + ')'); }); } else { $('#island .location_list .cityLocationScroll').each(function() { $(this).css('transform', ''); }); } break; } } function actOnMouseover() { switch(ikariam.backgroundView.id) { case 'city': var title = $(this).attr('title'); if (modData.actShowMouseoverPlaques) { var pos = forceInt($(this).attr('id')); $('#js_CityPosition'+pos+'Scroll').css('display', 'block'); $('#js_CityPosition'+pos+'Scroll').css('pointer-events', 'none'); $('#js_CityPosition'+pos+'ScrollName').text(title); } if (modData.actHideMouseoverTitles) { $(this).attr('title', null); $(this).attr('_title', title); } break; case 'island': if (modData.actHideMouseoverTitles) { var title = $(this).attr('title'); $(this).attr('title', null); $(this).attr('_title', title); } break; } } function actOnMouseout() { switch(ikariam.backgroundView.id) { case 'city': var pos = forceInt($(this).attr('id')); $('#js_CityPosition'+pos+'Scroll').css('display', ''); $('#js_CityPosition'+pos+'Scroll').css('pointer-events', ''); var title = $(this).attr('title') || $(this).attr('_title'); $(this).attr('title', title); $(this).attr('_title', null); if (modData.fixHoverEffectSwitching) { $('#position'+pos+' .img_pos.hover').addClass('invisible'); } break; case 'island': var title = $(this).attr('title') || $(this).attr('_title'); $(this).attr('title', title); $(this).attr('_title', null); if (modData.fixHoverEffectSwitching) { $(this).prev().removeClass('invisible'); } break; } } function actSetHoverHandlers() { switch(ikariam.backgroundView.id) { case 'city': if (modData.actShowMouseoverPlaques) { $('#city #locations .building a:not([_title])').each(function() { $(this).on('mouseover', actOnMouseover); $(this).on('mouseout', actOnMouseout); }); } else { $('#city #locations .building a[_title]').each(function() { $(this).off('mouseover'); $(this).off('mouseout'); var title = $(this).attr('_title'); $(this).attr('title', title); $(this).attr('_title', null); }); } break; case 'island': if (modData.actHideMouseoverTitles) { $('#island a.island_feature_img:not([_title])').each(function() { $(this).on('mouseover', actOnMouseover); $(this).on('mouseout', actOnMouseout); }); } else { $('#island a.island_feature_img[_title]').each(function() { $(this).off('mouseover'); $(this).off('mouseout'); var title = $(this).attr('_title'); $(this).attr('title', title); $(this).attr('_title', null); }); } break; } } waitFor(function(){ try{ jshintUnused = dataSetForView.relatedCityData; jshintUnused = ikariam.backgroundView.screen.update; return true; }catch(e){} return false; }, function(v){ if(!v) return; hookFunction(ikariam.backgroundView.screen, 'update', function() { actSetHoverHandlers(); actRescalePlaques(); }); hookFunction(ikariam.controller, 'scaleWorldMap', actRescalePlaques); actSetHoverHandlers(); actRescalePlaques(); }, 2000, 33); // // ressources // function onViewChanged() { var res = { 'wood':'resource', 'wine':'1', 'marble':'2', 'glass':'3', 'sulfur':'4', }; $('#buildingUpgrade ul.resources li').each(function(i){ var t = $(this); forEach(res, (v, k) => { if (t.hasClass(k)) { var req = parseInt(t.html().replace(/\D+/g,'')); var cur = ikariam.model.currentResources[v]; var lft = req-cur; if (lft>0) { if (modData.ressShowMissing) { t.addClass('red bold').css({'line-height':'initial'}); t.append('-'+ikariam.model.shortenValue(lft,6)+''); } } else { if(modData.ressShowRemaining) { t.css({'line-height':'initial'}); t.append('+'+ikariam.model.shortenValue(lft*-1,6)+''); } } return; } }); }); } waitFor.ajaxResponder((ajaxResponder) => { hookFunction(ajaxResponder, 'changeView', onViewChanged); onViewChanged(); }); var cssElement; function updateCSS() { var css = []; // // bugFixes // if (modData.fixResearchWindowList) { css.push('ol.research_type { width: 220px !important; }'); } if (modData.fixCitySelectItems) { css.push('.dropdownContainer.city_select li.last-child { background-position: left -142px !important; padding-bottom: 3px; }'); css.push('.dropdownContainer.city_select li.last-child:hover{ background-position: left -196px !important; }'); } if (modData.fixWindowTopPadding) { css.push('#container .mainContentBox .mainContent { padding-top: 20px !important; }'); } if (modData.fixScrollbars) { /** fix scrollbar x position **/ css.push('#container .scroller { background-position-x: -1px !important; }'); /** fix scroll window margin top **/ css.push('#container .mainContentBox .mainContentScroll { margin-top: -0.5px; }'); /** fix scroll area margin right to parent view window **/ css.push('#container .scroll_area { margin-right: 3px; }'); css.push('#container .scroll_area.scroll_disabled { margin-right: 0px; }'); } if (modData.fixHoverToBackground) { css.push('#city #locations .img_pos.buildingimg { z-index: 2; pointer-events: none; }'); css.push('#city #locations .img_pos.constructionSite { z-index: 2; pointer-events: none; }'); //css.push('#island a.island_feature_img { z-index: 3; position: absolute; }'); } // // antiAds // if (modData.adsHideHappyHour) { css.push('div.btnIngameCountdown.happyHour { height: 0; padding: 0; overflow: hidden; }'); // screw that display:block } if (modData.adsHideSpeedUpButton) { css.push('#city #locations .timetofinish.buildingSpeedup { padding-right: 16px; pointer-events: none; }'); css.push('#city .buildingSpeedupButton { display: none; }'); } if (modData.adsHideSlotResourceShop) { css.push('#container .slot_menu li.expandable.resourceShop { display: none !important; }'); } if (modData.adsHideSlotPremiumTrader) { css.push('#container .slot_menu li[onclick^="ajaxHandlerCall(\'?view=premiumTrader\')"] { display: none !important; }'); } if (modData.adsHideOfferBoxes) { css.push('#townHall .premiumOffer { display: none !important; }'); css.push('#warehouse .premiumOfferBox { display: none !important; }'); css.push('#finances #js_BadTaxAccountantOffer { display: none !important; }'); css.push('#finances td.premiumOffer { height: unset; padding: unset; }'); // premium boxes in mines css.push('#setWorkers .content { min-height: unset !important; }'); css.push('#setWorkers #workersWrapper + .premiumOfferBox { display: none !important; }'); // bottom premium boxes in advisor views css.push('#tab_tradeAdvisor > div.contentBox01h:last-child { display: none !important; }'); css.push('#militaryAdvisor #militaryMovements + div.contentBox01h { display: none !important; }'); css.push('#researchAdvisor .mainContent > div.contentBox01h:last-child { display: none !important; }'); css.push('#diplomacyAdvisor #tab_diplomacyAdvisor > div:last-child.contentBox01h { display: none !important; }'); } if (modData.adsHideWindowAds) { css.push('#container .mainContent > div:first-child.center { display: none !important; }'); // advertising at top of each view window } if (modData.adsHideArchiveButtons) { css.push('#tab_diplomacyAdvisor .button_bar_msg { display: none !important; }'); css.push('#tab_diplomacyAdvisor .button_bar_right { display: none !important; }'); } if (modData.adsHideMilitaryDummies) { css.push('#barracks #premium_btn { display: none !important; }'); css.push('#barracks #premium_btn2 { display: none !important; }'); css.push('#shipyard #premium_btn { display: none !important; }'); css.push('#shipyard #premium_btn2 { display: none !important; }'); css.push('#cityMilitary #premium_btn { display: none !important; }'); css.push('#cityMilitary #premium_btn2 { display: none !important; }'); } if (modData.adsHideAdvisorButtons) { css.push('#header #advisors a#js_GlobalMenu_citiesPremium { display: none; }'); css.push('#header #advisors a#js_GlobalMenu_militaryPremium { display: none; }'); css.push('#header #advisors a#js_GlobalMenu_researchPremium { display: none; }'); css.push('#header #advisors a#js_GlobalMenu_diplomacyPremium { display: none; }'); } // // animations // if (modData.animHideWalkers) { css.push('#walkers { display: none; }'); } if (modData.animHideBirdsOnly) { css.push('div.bird, div.animated_bird { display: none; }'); } if (modData.animHideWalkerBubbles) { css.push('.not_selectable, .animation {pointer-events: none;}'); } // // cities // if (modData.cityHideLockedPosition) { css.push('#locations .lockedPosition { display: none; }'); } if (modData.cityHideDailyTasks) { css.push('#city #cityDailyTasks { display: none; }'); } if (modData.cityHideRegistrationGifts) { css.push('#cityRegistrationGifts { display: none; }'); } if (modData.cityHideFlyingShop) { css.push('#city #cityFlyingShopContainer { display: none; }'); } if (modData.cityHideAmbrosiaFountain) { css.push('#city #cityAmbrosiaFountain { display: none; }'); } if (modData.cityHidePirateFortress) { css.push('#city #pirateFortressBackground { display: none; }'); css.push('#city #pirateFortressShip { display: none; }'); css.push('#city #locations #position17 { display: none; }'); } if (modData.cityIgnoreCapital || modData.cityUsecityCustomBackground) { var townBackgrounds = []; var capitalBackgrounds = []; if (modData.cityUsecityCustomBackground) { for(var i=0; i

    {str_GeneralTweaks_name}

    {str_GeneralTweaks_bugFixes}

    {bugFixesTR}

    {str_GeneralTweaks_antiAds}

    {antiAdsTR}

    {str_GeneralTweaks_animations}

    {animationsTR}

    {str_GeneralTweaks_cities}

    {citiesTR}

    {str_GeneralTweaks_interactive}

    {interactiveTR}

    {str_GeneralTweaks_ressources}

    {ressourcesTR}
    `); TPL.set('GeneralTweaks_settingTR', ` {text} `); TPL.set('GeneralTweaks_settingSelectTR', ` {text} {selectContainer} `); IkaTweaks.addSidebarButton('{str_GeneralTweaks_name}', function() { var bugFixes = { fixResearchWindowList : modData.fixResearchWindowList, fixCitySelectItems : modData.fixCitySelectItems, fixWindowTopPadding : modData.fixWindowTopPadding, fixScrollbars : modData.fixScrollbars, fixHoverEffectSwitching : modData.fixHoverEffectSwitching, fixHoverToBackground : modData.fixHoverToBackground, }; var antiAds = { adsHideSpeedUpButton : modData.adsHideSpeedUpButton, adsHideWindowAds : modData.adsHideWindowAds, adsHideHappyHour : modData.adsHideHappyHour, adsHideOfferBoxes : modData.adsHideOfferBoxes, adsHideSlotResourceShop : modData.adsHideSlotResourceShop, adsHideSlotPremiumTrader : modData.adsHideSlotPremiumTrader, adsHideArchiveButtons : modData.adsHideArchiveButtons, adsHideMilitaryDummies : modData.adsHideMilitaryDummies, adsHideAdvisorButtons : modData.adsHideAdvisorButtons, }; var animations = { animHideWalkers : modData.animHideWalkers, animHideWalkerBubbles : modData.animHideWalkerBubbles, animHideBirdsOnly : modData.animHideBirdsOnly, }; var cities = { cityIgnoreCapital : modData.cityIgnoreCapital, cityHidePirateFortress : modData.cityHidePirateFortress, cityHideLockedPosition : modData.cityHideLockedPosition, cityUseCustomBackground : modData.cityUseCustomBackground, cityHideDailyTasks : modData.cityHideDailyTasks, cityHideRegistrationGifts : modData.cityHideRegistrationGifts, cityHideFlyingShop : modData.cityHideFlyingShop, cityHideAmbrosiaFountain : modData.cityHideAmbrosiaFountain, }; var interactive = { actShowMouseoverPlaques : modData.actShowMouseoverPlaques, actHideMouseoverTitles : modData.actHideMouseoverTitles, actPreventPlaqueScaling : modData.actPreventPlaqueScaling, }; var ressources = { ressShowMissing : modData.ressShowMissing, ressShowRemaining : modData.ressShowRemaining, }; var cityCustomBackgroundList = [ '1', '2', '3', '4', '5', ].map((level) => { return TPL.parse(LANG('str_GeneralTweaks_cityUseCustomBackgroundLevel'), {level:level}); }); var cityCustomBackgroundSelect = new SelectDropDown('GeneralTweaks_customBackgroundSelect', 95, cityCustomBackgroundList, modData.cityCustomBackground); IkaTweaks.changeHTML('GeneralTweaks', TPL.get('GeneralTweaks_settingsWindow', { bugFixesTR: TPL.getEach(bugFixes, function(checked, k){ return ['GeneralTweaks_settingTR', { id : k, text : '{str_GeneralTweaks_'+k+'}', checked : (checked) ? 'checked="checked"' : '', }]; }), antiAdsTR: TPL.getEach(antiAds, function(checked, k){ return ['GeneralTweaks_settingTR', { id : k, text : '{str_GeneralTweaks_'+k+'}', checked : (checked) ? 'checked="checked"' : '', }]; }), animationsTR: TPL.getEach(animations, function(checked, k){ return ['GeneralTweaks_settingTR', { id : k, text : '{str_GeneralTweaks_'+k+'}', checked : (checked) ? 'checked="checked"' : '', }]; }), citiesTR: TPL.getEach(cities, function(checked, k){ switch(k) { case 'cityUseCustomBackground': return ['GeneralTweaks_settingSelectTR', { id : k, text : '{str_GeneralTweaks_cityUseCustomBackground}', checked : (checked) ? 'checked="checked"' : '', selectContainer : cityCustomBackgroundSelect.tpl(), }]; default: return ['GeneralTweaks_settingTR', { id : k, text : '{str_GeneralTweaks_'+k+'}', checked : (checked) ? 'checked="checked"' : '', }]; } }), interactiveTR: TPL.getEach(interactive, function(checked, k){ return ['GeneralTweaks_settingTR', { id : k, text : '{str_GeneralTweaks_'+k+'}', checked : (checked) ? 'checked="checked"' : '', }]; }), ressourcesTR: TPL.getEach(ressources, function(checked, k){ return ['GeneralTweaks_settingTR', { id : k, text : '{str_GeneralTweaks_'+k+'}', checked : (checked) ? 'checked="checked"' : '', }]; }), }), function(){ $('#GeneralTweaks_bugFixesTable tr').not(':even').addClass('alt'); $('#GeneralTweaks_antiAdsTable tr').not(':even').addClass('alt'); $('#GeneralTweaks_animationsTable tr').not(':even').addClass('alt'); $('#GeneralTweaks_citiesTable tr').not(':even').addClass('alt'); $('#GeneralTweaks_interactiveTable tr').not(':even').addClass('alt'); $('#GeneralTweaks_ressourcesTable tr').not(':even').addClass('alt'); ikariam.controller.replaceCheckboxes(); ikariam.controller.replaceDropdownMenus(); $('#js_GeneralTweaks_settingsButton').click(function(){ forEach(bugFixes, (_, k) => { modData[k] = isChecked('#GeneralTweaks_settingCheckbox'+k); }); forEach(antiAds, (_, k) => { modData[k] = isChecked('#GeneralTweaks_settingCheckbox'+k); }); forEach(animations, (_, k) => { modData[k] = isChecked('#GeneralTweaks_settingCheckbox'+k); }); forEach(cities, (_, k) => { modData[k] = isChecked('#GeneralTweaks_settingCheckbox'+k); }); forEach(interactive, (_, k) => { modData[k] = isChecked('#GeneralTweaks_settingCheckbox'+k); }); forEach(ressources, (_, k) => { modData[k] = isChecked('#GeneralTweaks_settingCheckbox'+k); }); modData.cityCustomBackground = parseInt(cityCustomBackgroundSelect.val()); modDataSave(); updateCSS(); actRescalePlaques(); actSetHoverHandlers(); IkaTweaks.success(); }); }); }); }); // MODULE: GeneralTweaks //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- // MODULE: CityListing IkaTweaks.setModule('CityListing', function(modData, modDataSave){ if(typeof modData.hideCoords == 'undefined') modData.hideCoords = false; if(typeof modData.showTradegoods == 'undefined') modData.showTradegoods = true; if(typeof modData.highlightSelected == 'undefined') modData.highlightSelected = true; if(typeof modData.sortList == 'undefined') modData.sortList = true; if(typeof modData.sortedList == 'undefined') modData.sortedList = []; if(typeof modData.sortEverywhere == 'undefined') modData.sortEverywhere = false; // afterI = after what child ele append others? // chields = {cityId:listEle, cityId:listEle, ...} function sortElementChilds(parent, childs, afterI, altRows) { var sortedList = modData.sortedList.slice(0), ch; while(sortedList.length) { ch = childs[sortedList.pop()]; // from last, to fist if (ch) { // remove element from DOM and append again at top parent.children().eq(afterI).before(ch); } } if (altRows) { sortedList = modData.sortedList.slice(0); var alt = false; while(sortedList.length) { ch = childs[sortedList.shift()]; // but now from first to last if (ch) { ch.removeClass('alt'); if (alt) { ch.addClass('alt'); } alt = !alt; } } } } var tradegoodImagesCache = {}; var tradegoodImagePaths = { '1': '/skin/resources/icon_wine.png', '2': '/skin/resources/icon_marble.png', '3': '/skin/resources/icon_glass.png', '4': '/skin/resources/icon_sulfur.png' }; function getTradegoodImage(k, cityId, tradegood) { var cacheKey = k+cityId; var img = tradegoodImagesCache[cacheKey] || $(''); tradegoodImagesCache[cacheKey] = img; img.attr({ 'class': 'citySelectTradegoodIcon', 'src': tradegoodImagePaths[tradegood] || '', }); return img; } function updateCitySelect_appendTradegoods() { var relatedCityData = ikariam.model.relatedCityData, relatedCity = relatedCityData[relatedCityData.selectedCity]; $('#js_citySelectContainer span').append(getTradegoodImage('span', relatedCity.id, relatedCity.tradegood)); var citySelectUl = $('#dropDown_js_citySelectContainer ul'); citySelectUl.addClass('width'+citySelectUl.width()); forEach(relatedCityData, (relatedCity, cityKey) => { if (relatedCity && relatedCity.relationship == 'ownCity') { $('#dropDown_js_citySelectContainer li[selectvalue="'+relatedCity.id+'"]').append(getTradegoodImage('li', relatedCity.id, relatedCity.tradegood)); } }); } function updateCitySelect_highlightSelected() { var relatedCityData = ikariam.model.relatedCityData, relatedCity = relatedCityData[relatedCityData.selectedCity]; $('#dropDown_js_citySelectContainer li[selectvalue="'+relatedCity.id+'"]').addClass('active'); } function updateCitySelect_hideCoords() { var aSpan = $('#js_citySelectContainer span a'); aSpan.text(aSpan.text().replace(/\[\d+\:\d+\]\s+/, '')); var aLi = $('#dropDown_js_citySelectContainer li a'); aLi.each(function(){ $(this).text($(this).text().replace(/\[\d+\:\d+\]\s+/, '')); }); } function updateCitySelect_sort() { var parent = $('#dropDown_js_citySelectContainer ul'); var childs = {}; $('#dropDown_js_citySelectContainer ul li').each(function(i){ childs[$(this).attr('selectvalue').match(/\d+/)] = $(this); }); sortElementChilds(parent, childs, 0); // refresh classes for :first and :last (function(li){ li.removeClass('first-child'); li.removeClass('last-child'); li.first().addClass('first-child'); li.last().addClass('last-child'); })(parent.children()); } function updateCitySelect() { if(modData.showTradegoods) updateCitySelect_appendTradegoods(); if(modData.highlightSelected) updateCitySelect_highlightSelected(); if(modData.hideCoords) updateCitySelect_hideCoords(); if(modData.sortList) updateCitySelect_sort(); } function changeViewUpdate() { if(!(modData.sortList && modData.sortEverywhere)) return; var unsortedIds = []; forEach(ikariam.model.relatedCityData, (relatedCity, cityKey) => { if (relatedCity && relatedCity.relationship == 'ownCity') { unsortedIds.push(relatedCity.id); } }); var parent, childs = {}; if(document.getElementById('palace_c')) { parent = $('#palace_c table:eq(1) tbody'); parent.find('tr:gt(0)').each(function(i){ childs[unsortedIds[i]] = $(this); }); return sortElementChilds(parent, childs, 1, true); } if(document.getElementById('palaceColony_c')) { parent = $('#palaceColony_c table:eq(0) tbody'); parent.find('tr').each(function(i){ childs[unsortedIds[i]] = $(this); }); return sortElementChilds(parent, childs, 0); } if(document.getElementById('culturalPossessions_assign_c')) { parent = $('#culturalPossessions_assign_c ul:eq(1)'); parent.find('li').each(function(i){ childs[unsortedIds[i]] = $(this); }); return sortElementChilds(parent, childs, 0); } if(document.getElementById('finances_c')) { parent = $('#finances_c table:eq(1) tbody'); parent.find('tr:gt(0)').each(function(i){ childs[unsortedIds[i]] = $(this); }); return sortElementChilds(parent, childs, 1, true); } if(document.getElementById('port_c')) { parent = $('#port_c ul.cities'); parent.find('li').each(function(i){ childs[$(this).attr('id').match(/\d+/)] = $(this); }); return sortElementChilds(parent, childs, 0); } } waitFor(function(){ try{ jshintUnused = ikariam.backgroundView.updateCityDropdownMenu; jshintUnused = ikariam.model.relatedCityData; return true; }catch(e){} return false; }, function(ret){ if(!ret) return; hookFunction(ikariam.backgroundView, 'updateCityDropdownMenu', updateCitySelect); updateCitySelect(); }, 5000, 33); waitFor.ajaxResponder((ajaxResponder) => { hookFunction(ajaxResponder, 'changeView', changeViewUpdate); changeViewUpdate(); }); injectCSS(` img.citySelectTradegoodIcon {width:15px;height:12px;position:absolute;margin-top:5px;} ul.width177 img.citySelectTradegoodIcon {left:138px;} ul.width158 img.citySelectTradegoodIcon {left:138px;} #js_citySelectContainer span img.citySelectTradegoodIcon {left:146px;width:20px;height:16px;} #js_citySelectContainer span a {display:inline;} .dropdownContainer.city_select li.active{font-weight:bold;} #CityListing_sortingList button {cursor:pointer;display:inline-block;border:none;width:17px;height:17px;} #CityListing_sortingList button.up {background:url(/skin/friends/button17_up.png) no-repeat center 0px;} #CityListing_sortingList button.down {background:url(/skin/friends/button17_down.png) no-repeat center 0px;} `); TPL.set('CityListing_settingsWindow', `

    {str_CityListing_name}

    {settingsTR}
    `); TPL.set('CityListing_settingTR', ` {text} `); TPL.set('CityListing_settingListTR', ` {text}
    {subTR}
    `); IkaTweaks.addSidebarButton('{str_CityListing_name}', function(){ var checkboxes = { hideCoords : modData.hideCoords, showTradegoods : modData.showTradegoods, highlightSelected : modData.highlightSelected, sortList : modData.sortList, }; var checkboxes2 = { sortEverywhere : modData.sortEverywhere, }; IkaTweaks.changeHTML('CityListing', TPL.get('CityListing_settingsWindow', { settingsTR: TPL.getEach(checkboxes, function(checked, k){ switch(k) { case 'sortList': return ['CityListing_settingListTR', { id : k, text : '{str_CityListing_'+k+'}', checked : (checked) ? 'checked="checked"' : '', subTR : TPL.getEach(checkboxes2, function(checked, k){ return ['CityListing_settingTR', { id : k, text : '{str_CityListing_'+k+'}', checked : (checked) ? 'checked="checked"' : '', }]; }), }]; default: return ['CityListing_settingTR', { id : k, text : '{str_CityListing_'+k+'}', checked : (checked) ? 'checked="checked"' : '', }]; } }), }), function(){ $('#CityListing_settingTable tr').not(':even').addClass('alt'); var CityListing_sortingList = $('#CityListing_sortingList'); ikariam.controller.replaceCheckboxes(); var relatedCity, relatedCityData = ikariam.model.relatedCityData; // add current ids of moddata var newSortedList = []; while (modData.sortedList.length) { relatedCity = relatedCityData['city_'+modData.sortedList.shift()]; if (relatedCity && relatedCity.relationship == 'ownCity') { if (newSortedList.indexOf(relatedCity.id) == -1) { newSortedList.push(relatedCity.id); } } } // add missing ownCity ids of relatedCityData forEach(relatedCityData, (relatedCity, cityKey) => { if (relatedCity && relatedCity.relationship == 'ownCity') { if (newSortedList.indexOf(relatedCity.id) == -1) { newSortedList.push(relatedCity.id); } } }); function onClickSortUp(that) { var tr = $(this).closest('tr'); // jshint ignore:line var ch = CityListing_sortingList.children(); if(tr[0] === ch.first()[0]) ch.last().after(tr); else tr.prev().before(tr); } function onClickSortDown() { var tr = $(this).closest('tr'); // jshint ignore:line var ch = CityListing_sortingList.children(); if(tr[0] === ch.last()[0]) ch.first().before(tr); else tr.next().after(tr); } // fill #CityListing_sortingList while(newSortedList.length) { var cityId = newSortedList.shift(); modData.sortedList.push(cityId); CityListing_sortingList.append($('', {cityId:cityId}) .append($('') .append($('