From 13c036b3f99cdaa06faa4a4068514c510941064f Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Tue, 19 Sep 2023 20:59:28 +0000 Subject: [PATCH] fix linting errors --- scripts/account.js | 6 +++++- scripts/index.js | 14 +++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/account.js b/scripts/account.js index a068e62..7140e41 100644 --- a/scripts/account.js +++ b/scripts/account.js @@ -66,7 +66,7 @@ function createResourceUsageChart (resourceName, resourceAvail, resourceUsed, re const R = Math.min(usedRatio * 510, 255); const G = Math.min((1 - usedRatio) * 510, 255); const usedColor = `rgb(${R}, ${G}, 0)`; - new Chart(canvas, { + createChart(canvas, { type: "pie", data: { labels: [ @@ -103,6 +103,10 @@ function createResourceUsageChart (resourceName, resourceAvail, resourceUsed, re return container; } +function createChart (ctx, data) { + return new window.Chart(ctx, data); +} + function parseNumber (value, unitData) { if (!unitData) { return `${value}`; diff --git a/scripts/index.js b/scripts/index.js index a0c18ff..c5a5604 100644 --- a/scripts/index.js +++ b/scripts/index.js @@ -47,15 +47,15 @@ async function populateInstances () { } else { criteria = (a, b) => { - const a_inc = a.name.includes(searchQuery); - const b_inc = b.name.includes(searchQuery); - if (a_inc && b_inc) { + const aInc = a.name.includes(searchQuery); + const bInc = b.name.includes(searchQuery); + if (aInc && bInc) { return a.vmid > b.vmid ? 1 : -1; } - else if (a_inc && !b_inc) { + else if (aInc && !bInc) { return -1; } - else if (!a_inc && b_inc) { + else if (!aInc && bInc) { return 1; } else { @@ -64,9 +64,9 @@ async function populateInstances () { }; } instances.sort(criteria); - //console.log(instances) + // console.log(instances) const instanceContainer = document.querySelector("#instance-container"); - instanceContainer.innerHTML = ``; + instanceContainer.innerHTML = ""; for (let i = 0; i < instances.length; i++) { const newInstance = document.createElement("instance-card"); newInstance.data = instances[i];