From a9c939a3af968d4631e45f06d08acdd95a00fe45 Mon Sep 17 00:00:00 2001 From: elijahr2411 Date: Sun, 29 Jan 2023 00:10:47 -0500 Subject: [PATCH] Fix multiple nodes on the same server being broken (scoping issue, switch to foreach) --- src/index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/index.js b/src/index.js index c99c16d..9b85bf1 100644 --- a/src/index.js +++ b/src/index.js @@ -524,14 +524,14 @@ function multicollab(url) { await vm.connect(); var list = await vm.list(); vm.disconnect(); - for (var i = 0; i < list.length; i++) { - var id = list[i].id; - var name = list[i].name; + list.forEach((curr) => { + var id = curr.id; + var name = curr.name; if (id === window.location.hash.substring(1)) { openVM(url, id); res(false); } - vms.push(list[i]); + vms.push(curr); var div = document.createElement("div"); div.classList = "col-sm-4"; var card = document.createElement("div"); @@ -539,7 +539,7 @@ function multicollab(url) { card.setAttribute("data-cvm-node", id); card.addEventListener("click", () => openVM(url, id)); var img = document.createElement("img"); - img.src = "data:image/png;base64," + list[i].thumb; + img.src = "data:image/png;base64," + curr.thumb; img.classList = "card-img-top"; var bdy = document.createElement("div"); bdy.classList = "card-body"; @@ -549,9 +549,9 @@ function multicollab(url) { card.appendChild(img); card.appendChild(bdy); div.appendChild(card); - list[i].element = div; + curr.element = div; reloadVMList(); - } + }); res(true); }); }