From 78e470dbac0bd53b4ed36ab71b5b85db4973130f Mon Sep 17 00:00:00 2001 From: Alexander Danilov Date: Wed, 23 Oct 2024 17:20:06 +0500 Subject: [PATCH 1/3] Added control buttons to be able to control the mobile version of IITC without an app --- core/code/chat.js | 7 ++++++- core/code/smartphone.js | 19 +++++++++++-------- core/smartphone.css | 35 +++++++++++++++++++++++++++++++---- 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/core/code/chat.js b/core/code/chat.js index 044ca6de3..036a229fe 100644 --- a/core/code/chat.js +++ b/core/code/chat.js @@ -364,7 +364,12 @@ chat.show = function (name) { chat.chooser = function (event) { var t = $(event.target); var tab = t.data('channel'); - chat.chooseTab(tab); + + if (window.isSmartphone() && !window.useAppPanes()) { + window.show(tab); + } else { + chat.chooseTab(tab); + } }; /** diff --git a/core/code/smartphone.js b/core/code/smartphone.js index 5c89e7b01..0e3e51463 100644 --- a/core/code/smartphone.js +++ b/core/code/smartphone.js @@ -68,21 +68,27 @@ window.runOnSmartphonesBeforeBoot = function () { }; window.smartphone.mapButton = $('map').click(function () { + window.show('map'); $('#map').css({ visibility: 'visible', opacity: '1' }); $('#updatestatus').show(); - $('#chatcontrols a .active').removeClass('active'); + $('#chatcontrols a.active').removeClass('active'); $("#chatcontrols a:contains('map')").addClass('active'); }); window.smartphone.sideButton = $('info').click(function () { + window.show('info'); $('#scrollwrapper').show(); window.resetScrollOnNewPortal(); - $('.active').removeClass('active'); + $('#chatcontrols a.active').removeClass('active'); $("#chatcontrols a:contains('info')").addClass('active'); }); $('#chatcontrols').append(window.smartphone.mapButton).append(window.smartphone.sideButton); + if (!window.useAppPanes()) { + document.body.classList.add('show_controls'); + } + window.addHook('portalDetailsUpdated', function () { var x = $('.imgpreview img').removeClass('hide'); @@ -104,9 +110,10 @@ window.runOnSmartphonesBeforeBoot = function () { * This function is hooked to the 'portalSelected' event and is specific to the smartphone layout. * * @function smartphoneInfo + * @param {Object} selectedPortalData - The object containing details about the selected portal. */ -window.smartphoneInfo = function () { - var guid = data.selectedPortalGuid; +window.smartphoneInfo = function (selectedPortalData) { + var guid = selectedPortalData.selectedPortalGuid; if (!window.portals[guid]) return; var data = window.portals[window.selectedPortal].options.data; @@ -196,8 +203,4 @@ window.runOnSmartphonesAfterBoot = function () { $('#sidebar').animate({ scrollTop: newTop }, 200); } }); - - // make buttons in action bar flexible - var l = $('#chatcontrols a:visible'); - l.css('width', 100 / l.length + '%'); }; diff --git a/core/smartphone.css b/core/smartphone.css index f480fef89..3092b9ea4 100644 --- a/core/smartphone.css +++ b/core/smartphone.css @@ -125,10 +125,6 @@ body { margin-left: 4px; } -#sidebar, #chatcontrols, #chat, #chatinput { - background: transparent !important; -} - .leaflet-top .leaflet-control { margin-top: 5px !important; margin-left: 5px !important; @@ -257,3 +253,34 @@ body { https://github.com/IITC-CE/ingress-intel-total-conversion/issues/89 */ .leaflet-bottom { bottom: 5px; } + +/* Controls for mobile view without an app */ +:root { + --top-controls-height: 38px; +} + +body.show_controls #chatcontrols { + display: flex !important; + top: 0; + overflow-x: auto; + width: calc(100% - 1px); +} + +body.show_controls #chatcontrols a { + flex: 1; + min-width: fit-content; + padding: 0 5px; +} + +body.show_controls #map { + height: calc(100vh - var(--top-controls-height) - 25px); + margin-top: var(--top-controls-height); +} + +body.show_controls #scrollwrapper { + margin-top: var(--top-controls-height) +} + +body.show_controls #chat { + top: var(--top-controls-height) !important; +} \ No newline at end of file From 344ea9c1ef9acbf0a84e9a191df88fad301f2cfd Mon Sep 17 00:00:00 2001 From: Alexander Danilov Date: Mon, 28 Oct 2024 14:43:31 +0500 Subject: [PATCH 2/3] Update timestamps each time a build is done --- build_plugin.py | 7 +++++-- settings.py | 27 +++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/build_plugin.py b/build_plugin.py index ea776a797..25e9ab140 100755 --- a/build_plugin.py +++ b/build_plugin.py @@ -52,7 +52,7 @@ def append_line(key, value): if not re.match(r'^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$', value): print(f'{plugin_name}: wrong version format: {value}') # expected: major.minor.patch elif settings.version_timestamp: # append timestamp only for well-formed version - line = line.replace(value, '{ver}.{.build_timestamp}'.format(settings, ver=value)) + line = line.replace(value, '{ver}.{timestamp}'.format(ver=value, timestamp=settings.build_timestamp())) elif key == 'name': if value == 'IITC: Ingress intel map total conversion': is_main = True @@ -142,7 +142,10 @@ def expand_template(match, path=None): quote = "'%s'" kw, filename = match.groups() if not filename: - return quote % getattr(settings, kw) + value = getattr(settings, kw) + if callable(value): + value = value() + return quote % value fullname = path / filename if kw == 'include_raw': diff --git a/settings.py b/settings.py index 841d5e523..543c5be1e 100755 --- a/settings.py +++ b/settings.py @@ -6,11 +6,33 @@ values from localbuildsettings.py (if exists). """ +import time + + +def get_current_timestamp(): + """Get current build date and timestamp in desired formats.""" + utc = time.gmtime() + return ( + time.strftime('%Y-%m-%d-%H%M%S', utc), # build_date + time.strftime('%Y%m%d.%H%M%S', utc) # build_timestamp + ) + + +def build_timestamp(): + """Dynamically generate current build timestamp.""" + _, timestamp = get_current_timestamp() + return timestamp + + +def build_date(): + """Dynamically generate current build date.""" + date, _ = get_current_timestamp() + return date + def load(build_name, localfile=None): """Load settings for given iitc build name.""" import buildsettings as config - import time from pathlib import Path from runpy import run_path @@ -39,9 +61,6 @@ def load(build_name, localfile=None): mod = vars(__import__(__name__)) mod.pop('load') mod['build_name'] = build_name - utc = time.gmtime() - mod['build_date'] = time.strftime('%Y-%m-%d-%H%M%S', utc) - mod['build_timestamp'] = time.strftime('%Y%m%d.%H%M%S', utc) base = Path(localfile or __file__).parent mod['build_source_dir'] = base mod['build_target_dir'] = base / 'build' / build_name From dd3877b0ba0b7e67458107f2be1b957f373cb260 Mon Sep 17 00:00:00 2001 From: Alexander Danilov Date: Sun, 3 Nov 2024 14:37:04 +0500 Subject: [PATCH 3/3] Generating build time at startup --- build.py | 1 + settings.py | 27 ++++++++++----------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/build.py b/build.py index a02d77a69..d5c29f0ae 100755 --- a/build.py +++ b/build.py @@ -48,6 +48,7 @@ def run_cmds(cmds, source, target): def iitc_build(source, outdir, deps_list=None): + settings.generate_timestamps() run_cmds(settings.pre_build, source, outdir) iitc_script = 'core/total-conversion-build.js' diff --git a/settings.py b/settings.py index 543c5be1e..b45b63a3b 100755 --- a/settings.py +++ b/settings.py @@ -8,26 +8,17 @@ import time - -def get_current_timestamp(): - """Get current build date and timestamp in desired formats.""" - utc = time.gmtime() - return ( - time.strftime('%Y-%m-%d-%H%M%S', utc), # build_date - time.strftime('%Y%m%d.%H%M%S', utc) # build_timestamp - ) +_build_date = None +_build_timestamp = None -def build_timestamp(): - """Dynamically generate current build timestamp.""" - _, timestamp = get_current_timestamp() - return timestamp +def generate_timestamps(): + """Generate build date and timestamp in desired formats.""" + global _build_date, _build_timestamp - -def build_date(): - """Dynamically generate current build date.""" - date, _ = get_current_timestamp() - return date + utc = time.gmtime() + _build_date = time.strftime('%Y-%m-%d-%H%M%S', utc) + _build_timestamp = time.strftime('%Y%m%d.%H%M%S', utc) def load(build_name, localfile=None): @@ -61,6 +52,8 @@ def load(build_name, localfile=None): mod = vars(__import__(__name__)) mod.pop('load') mod['build_name'] = build_name + mod['build_date'] = lambda: _build_date + mod['build_timestamp'] = lambda: _build_timestamp base = Path(localfile or __file__).parent mod['build_source_dir'] = base mod['build_target_dir'] = base / 'build' / build_name