2023-04-03 21:57:03 +00:00
|
|
|
import {requestPVE, requestAPI} from "./utils.js";
|
|
|
|
|
|
|
|
window.addEventListener("DOMContentLoaded", init);
|
|
|
|
|
|
|
|
async function init () {
|
|
|
|
let resources = await requestAPI("/user/resources");
|
2023-04-05 22:29:15 +00:00
|
|
|
document.querySelector("main").append(buildResourceTable(resources.resources, "#resource-table"));
|
2023-04-03 21:57:03 +00:00
|
|
|
}
|
|
|
|
|
2023-04-05 22:29:15 +00:00
|
|
|
function buildResourceTable (object, tableid) {
|
2023-04-03 21:57:03 +00:00
|
|
|
|
|
|
|
if (object instanceof Object) {
|
2023-04-05 22:29:15 +00:00
|
|
|
|
|
|
|
let table = document.querySelector(tableid);
|
2023-04-03 21:57:03 +00:00
|
|
|
Object.keys(object).forEach((element) => {
|
2023-04-05 22:29:15 +00:00
|
|
|
let row = table.insertRow();
|
|
|
|
let key = row.insertCell();
|
|
|
|
key.innerText = `${element}`;
|
|
|
|
let val = row.insertCell();
|
|
|
|
val.innerText = `${object[element]}`
|
|
|
|
let total = row.insertCell();;
|
|
|
|
total.innerText = `${object[element]}`
|
2023-04-03 21:57:03 +00:00
|
|
|
});
|
|
|
|
return table;
|
|
|
|
}
|
|
|
|
else {
|
2023-04-05 22:29:15 +00:00
|
|
|
return null;
|
2023-04-03 21:57:03 +00:00
|
|
|
}
|
|
|
|
}
|