diff options
| author | altaf-creator <dev@altafcreator.com> | 2025-12-02 15:39:04 +0700 |
|---|---|---|
| committer | altaf-creator <dev@altafcreator.com> | 2025-12-02 15:39:04 +0700 |
| commit | 988db9361ca86765dc1645bcdcb77466cfd0e8e0 (patch) | |
| tree | ffbcae9086ae23c2a8911803d1507d7ee4d1e4d7 /frontend/main.js | |
| parent | a69d6aa6f0f2e98bcacb4016bf5530d5a420270f (diff) | |
block is now a cookie
Diffstat (limited to 'frontend/main.js')
| -rw-r--r-- | frontend/main.js | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/frontend/main.js b/frontend/main.js index e677c68..6c46b20 100644 --- a/frontend/main.js +++ b/frontend/main.js @@ -25,10 +25,7 @@ async function checkUserStatus() { async function checkMachineStatus() { const response = await fetch(`${API_URL}/status`, { method: "POST", - headers: { - "Content-Type": "application/json" - }, - body: JSON.stringify({block: 1}), + credentials: "include", }); return await response.json(); } @@ -69,17 +66,41 @@ function start() { }); } +// --- information loading + cookie setting (from server) +async function information(urlParam = null) { + const response = fetch(`${API_URL}/info`, { + credentials: "include", + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ "machine_id": urlParam ? urlParam : await browser.cookies.get({name: "auth_block", url: API_URL}) }) + }); + + const block = await response.json()["block"]; + + document.getElementById("logo-id").innerText = block; + + return Promise.resolve(block); +} + // ------ page specific ----- // ---- machine status page +const STATUS_INTERVAL = 30 + // --- machines visual async function startUpdateMachines() { + const urlParams = new URLSearchParams(window.location.search); + + await information(urlParams.get("block")); + updateMachines(); while (true) { - await delay(30 * 1000); + await delay(STATUS_INTERVAL * 1000); await updateMachines(); } |
