From 0c5f20677ed6a8cc59dfd10c5207e6b6e05cc052 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Sun, 18 Dec 2022 17:11:35 -0800 Subject: [PATCH] set proper alt for instance type/status and power action --- scripts/elements.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/elements.js b/scripts/elements.js index e62b54b..dce3983 100644 --- a/scripts/elements.js +++ b/scripts/elements.js @@ -66,11 +66,17 @@ class Instance extends HTMLElement { powerButton.addEventListener("click", async () => { if (!this.actionLock) { this.actionLock = true; + let targetAction = this.status === "running" ? "shutdown" : "start"; + let targetActionDesc = targetAction === "start" ? "starting" : "shutting down"; let targetStatus = this.status === "running" ? "stopped" : "running"; let typeImg = this.shadowElement.querySelector("#instance-type"); typeImg.src = "images/actions/loading.svg"; + typeImg.alt = `instance is ${targetActionDesc}`; + let powerButton = this.shadowElement.querySelector("#power-btn"); + powerButton.src = "images/actions/loading.svg"; + powerButton.alt = `instance is ${targetActionDesc}`; await request(`/nodes/${this.node}/${this.type}/${this.vmid}/status/${targetAction}`, "POST", {node: this.node, vmid: this.vmid}); @@ -85,10 +91,11 @@ class Instance extends HTMLElement { this.status = targetStatus; typeImg.src = `images/instances/${this.type}/${this.status}.svg`; + typeImg.alt = `${this.status} instance`; - let powerButton = this.shadowElement.querySelector("#power-btn"); powerButton.src = this.status === "running" ? "images/actions/stop.svg" : "images/actions/start.svg"; powerButton.alt = this.status === "running" ? "shutdown instance" : "start instance"; + this.actionLock = false; } });