DevPlace CI / test (push) Failing after 44m45s
Continuous Delivery could never be turned off once a crop was planted. Add a one-shot per-plot "stop after harvest" flag (POST /game/plot/stop, Devii tool game_plot_stop, game_plots.stop_after_harvest), cleared by the next plant, autoreplant claim or Refactor. Autoreplant now also respects crop locks through the shared _crop_lock predicate. Plan and measurements in happyplanting.md. Also includes the pending community sync, node network and related work in the tree; the full suite passed (4999) with all of it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
40 lines
1.5 KiB
JavaScript
40 lines
1.5 KiB
JavaScript
// retoor <retoor@molodetz.nl>
|
|
|
|
import { Poller } from "./Poller.js";
|
|
|
|
const REFRESH_MS = 3000;
|
|
const BUSY = "true";
|
|
|
|
class AdminCommunity {
|
|
constructor() {
|
|
this.root = document.querySelector("[data-community-root]");
|
|
if (!this.root || this.root.dataset.busy !== BUSY) return;
|
|
this.poller = new Poller(() => this.refresh(), REFRESH_MS, { pauseHidden: true, immediate: false });
|
|
}
|
|
|
|
async refresh() {
|
|
const response = await fetch(window.location.href, { headers: { "Accept": "text/html" }, credentials: "same-origin" });
|
|
if (!response.ok) return;
|
|
const fresh = new DOMParser().parseFromString(await response.text(), "text/html");
|
|
const next = fresh.querySelector("[data-community-root]");
|
|
if (!next) return;
|
|
this.root.querySelectorAll("[data-live]").forEach((section) => {
|
|
const replacement = next.querySelector(`[data-live="${section.dataset.live}"]`);
|
|
if (replacement) this.swap(section, replacement);
|
|
});
|
|
this.root.dataset.busy = next.dataset.busy;
|
|
if (next.dataset.busy !== BUSY) this.poller.stop();
|
|
}
|
|
|
|
swap(section, replacement) {
|
|
const open = [...section.querySelectorAll("details[data-keep-open]")].map((item) => item.open);
|
|
section.innerHTML = replacement.innerHTML;
|
|
section.querySelectorAll("details[data-keep-open]").forEach((item, index) => {
|
|
item.open = Boolean(open[index]);
|
|
});
|
|
}
|
|
}
|
|
|
|
window.AdminCommunity = AdminCommunity;
|
|
export { AdminCommunity };
|