Lint: fix errors and remove unused variables
**Motivations:** - Ensure lint config is not degraded and fix all lint errors for pousse workflow. **Root causes:** - Unused variables kept with _ prefix instead of removed (_row, _questReward, _i). - getAnimalBlockOrigin had 5 parameters (max 4). - use of continue statement (no-continue rule). **Correctifs:** - ESLint config verified; no eslint-disable in codebase. - Removed unused variable _row (biome-rules); removed dead function _questReward (quests); removed unused map param _i (state.js). - getAnimalBlockOrigin refactored to 4 params (pos object instead of x, y). - Replaced continue with if (cell) block in normalizeLoadedCells (state.js). - JSDoc param names aligned with _height, _y (biome-rules). **Evolutions:** - (none) **Pages affectées:** - web/js/biome-rules.js - web/js/quests.js - web/js/state.js - web/js/placement.js
This commit is contained in:
@@ -19,53 +19,61 @@ function setMyZooId(id) {
|
||||
myZooId = id;
|
||||
}
|
||||
|
||||
async function runBootNoBase(rootEl) {
|
||||
rootEl.innerHTML = "<div class=\"boot-panel\"><h1>Construis un zoo</h1>" +
|
||||
"<p>Connectez-vous à un serveur pour jouer (compte et sauvegarde en base).</p>" +
|
||||
"<div style=\"margin-top: 1rem;\"><label for=\"boot-api-url\">URL du serveur</label><input id=\"boot-api-url\" type=\"text\" placeholder=\"https://...\" style=\"display:block;margin-top:4px;width:100%;\" /></div>" +
|
||||
"<button id=\"boot-connect\" type=\"button\" style=\"margin-top: 8px;\">Se connecter</button>" +
|
||||
"<p id=\"boot-err\" class=\"boot-err\"></p></div>";
|
||||
const urlInput = document.getElementById("boot-api-url");
|
||||
try {
|
||||
const stored = localStorage.getItem("builazoo_api_url");
|
||||
if (stored) urlInput.value = stored;
|
||||
} catch (_) {
|
||||
// ignore localStorage
|
||||
}
|
||||
const errEl = document.getElementById("boot-err");
|
||||
await new Promise((resolve) => {
|
||||
document.getElementById("boot-connect").addEventListener("click", () => {
|
||||
const url = urlInput.value.trim();
|
||||
if (!url) {
|
||||
errEl.textContent = "Indiquez l'URL du serveur.";
|
||||
return;
|
||||
}
|
||||
setApiBaseUrl(url);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
rootEl.innerHTML = "";
|
||||
}
|
||||
|
||||
async function runBootWithBase(rootEl) {
|
||||
rootEl.innerHTML = "<div class=\"boot-panel\"><p>Chargement…</p></div>";
|
||||
while (true) {
|
||||
try {
|
||||
state = await bootstrapFromApi(setMyZooId, rootEl);
|
||||
break;
|
||||
} catch (e) {
|
||||
console.error("bootstrapFromApi failed", e);
|
||||
rootEl.innerHTML = "<div class=\"boot-panel\"><h1>Construis un zoo</h1><p class=\"boot-err\">Erreur de connexion au serveur.</p><button id=\"boot-retry\" type=\"button\">Réessayer</button></div>";
|
||||
const errP = rootEl.querySelector(".boot-err");
|
||||
if (errP && e && e.message) errP.textContent = e.message;
|
||||
await new Promise((resolve) => {
|
||||
document.getElementById("boot-retry").addEventListener("click", () => resolve());
|
||||
});
|
||||
}
|
||||
}
|
||||
rootEl.innerHTML = "";
|
||||
}
|
||||
|
||||
(async () => {
|
||||
let base = getApiBase();
|
||||
if (!base) {
|
||||
root.innerHTML = "<div class=\"boot-panel\"><h1>Construis un zoo</h1>" +
|
||||
"<p>Connectez-vous à un serveur pour jouer (compte et sauvegarde en base).</p>" +
|
||||
"<div style=\"margin-top: 1rem;\"><label for=\"boot-api-url\">URL du serveur</label><input id=\"boot-api-url\" type=\"text\" placeholder=\"https://...\" style=\"display:block;margin-top:4px;width:100%;\" /></div>" +
|
||||
"<button id=\"boot-connect\" type=\"button\" style=\"margin-top: 8px;\">Se connecter</button>" +
|
||||
"<p id=\"boot-err\" class=\"boot-err\"></p></div>";
|
||||
const urlInput = document.getElementById("boot-api-url");
|
||||
try {
|
||||
const stored = localStorage.getItem("builazoo_api_url");
|
||||
if (stored) urlInput.value = stored;
|
||||
} catch (_) {
|
||||
// ignore localStorage
|
||||
}
|
||||
const errEl = document.getElementById("boot-err");
|
||||
await new Promise((resolve) => {
|
||||
document.getElementById("boot-connect").addEventListener("click", () => {
|
||||
const url = urlInput.value.trim();
|
||||
if (!url) {
|
||||
errEl.textContent = "Indiquez l'URL du serveur.";
|
||||
return;
|
||||
}
|
||||
setApiBaseUrl(url);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
root.innerHTML = "";
|
||||
await runBootNoBase(root);
|
||||
base = getApiBase();
|
||||
}
|
||||
if (base) {
|
||||
root.innerHTML = "<div class=\"boot-panel\"><p>Chargement…</p></div>";
|
||||
while (true) {
|
||||
try {
|
||||
state = await bootstrapFromApi(setMyZooId, root);
|
||||
break;
|
||||
} catch (e) {
|
||||
console.error("bootstrapFromApi failed", e);
|
||||
root.innerHTML = "<div class=\"boot-panel\"><h1>Construis un zoo</h1><p class=\"boot-err\">Erreur de connexion au serveur.</p><button id=\"boot-retry\" type=\"button\">Réessayer</button></div>";
|
||||
const errP = root.querySelector(".boot-err");
|
||||
if (errP && e && e.message) errP.textContent = e.message;
|
||||
await new Promise((resolve) => {
|
||||
document.getElementById("boot-retry").addEventListener("click", () => resolve());
|
||||
});
|
||||
}
|
||||
}
|
||||
root.innerHTML = "";
|
||||
await runBootWithBase(root);
|
||||
}
|
||||
if (state) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user