From 76fea95adc591735d84ae12789fba8ed32096176 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Wed, 21 Dec 2022 01:36:24 -0800 Subject: [PATCH] fix string to int parsing --- scripts/config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/config.js b/scripts/config.js index 78a4eff..2f40e1c 100644 --- a/scripts/config.js +++ b/scripts/config.js @@ -33,8 +33,9 @@ async function populateForm (node, type, vmid) { let sata = config.data[`sata${i}`]; sata = `{"${sata.replaceAll(":", '":"').replaceAll("=", '":"').replaceAll(",", '","')}"}`; sata = JSON.parse(sata); + let sizeNum = +(sata.size.replaceAll("G", "").replaceAll("M", "")); let sizeUnit = sata.size.includes("G") ? "GiB" : "MiB"; - addFormLine("resources", `SATA ${i}`, {type: "number", value: sizeUnit === "GiB" ? +(sata.size).toFixed(3) : +(sata.size / 1024).toFixed(3), min: 0.016}, "GiB"); + addFormLine("resources", `SATA ${i}`, {type: "number", value: sizeUnit === "GiB" ? sizeNum.toFixed(3) : (sizeNum / 1024).toFixed(3), min: 0.016}, "GiB"); i++; } }