Tracker and ITS-G5 as separate overlays, Overlays grouped by category: the tracker gets a name/icon/color, charging from its USB power topic, a floating info card (per-device opacity), a trail of the last 1–24 h and optional position logging that survives restarts (LiveStore); hiking trails keep their main checkbox as an all-countries toggle
This commit is contained in:
1 parent
3fc8c75c60
commit
0e5f79f8e4
9 files changed
+801
-205
No files matched your search
@@ -202,7 +202,10 @@ export class HikingTrailsControl {
|
||||
this._details = li.querySelector(".overlays-panel__details");
|
||||
this._countryList = li.querySelector(".hiking-trail-countries");
|
||||
|
||||
this._checkbox.addEventListener("change", (event) => this._toggleOnline(event.target.checked));
|
||||
this._checkbox.addEventListener("change", (event) => {
|
||||
if (this._offlineCountries.length) this._toggleAllCountries(event.target.checked);
|
||||
else this._toggleOnline(event.target.checked);
|
||||
});
|
||||
this._nameButton.addEventListener("click", () => {
|
||||
if (this._offlineCountries.length === 0) return; // nothing to expand into yet
|
||||
const expanding = this._details.hidden;
|
||||
@@ -222,7 +225,10 @@ export class HikingTrailsControl {
|
||||
if (countries.length === 0) return;
|
||||
|
||||
if (this._active) this._toggleOnline(false);
|
||||
this._checkbox.hidden = true;
|
||||
// The main checkbox stays: offline it switches every country at once
|
||||
// (indeterminate while only some are on); the name opens the list.
|
||||
this._checkbox.checked = false;
|
||||
this._checkbox.title = "All countries — click the name to pick some";
|
||||
|
||||
this._countryList.innerHTML = countries
|
||||
.map(
|
||||
@@ -237,7 +243,10 @@ export class HikingTrailsControl {
|
||||
)
|
||||
.join("");
|
||||
this._countryList.querySelectorAll(".hiking-trail-countries__toggle").forEach((input) => {
|
||||
input.addEventListener("change", (event) => this._toggleCountry(event.target.value, event.target.checked));
|
||||
input.addEventListener("change", (event) => {
|
||||
this._toggleCountry(event.target.value, event.target.checked);
|
||||
this._syncMainCheckbox();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -247,6 +256,23 @@ export class HikingTrailsControl {
|
||||
if (!input || input.checked) return;
|
||||
input.checked = true;
|
||||
this._toggleCountry(code, true);
|
||||
this._syncMainCheckbox();
|
||||
}
|
||||
|
||||
_toggleAllCountries(active) {
|
||||
this._countryList.querySelectorAll(".hiking-trail-countries__toggle").forEach((input) => {
|
||||
if (input.checked === active) return;
|
||||
input.checked = active;
|
||||
this._toggleCountry(input.value, active);
|
||||
});
|
||||
this._syncMainCheckbox();
|
||||
}
|
||||
|
||||
_syncMainCheckbox() {
|
||||
const inputs = [...this._countryList.querySelectorAll(".hiking-trail-countries__toggle")];
|
||||
const on = inputs.filter((input) => input.checked).length;
|
||||
this._checkbox.checked = on > 0 && on === inputs.length;
|
||||
this._checkbox.indeterminate = on > 0 && on < inputs.length;
|
||||
}
|
||||
|
||||
_toggleOnline(active) {
|
||||
|
||||
Reference in new issue
Block a user