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:48:36 +00:00
|
|
|
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-05 22:48:36 +00:00
|
|
|
let tbody = table.querySelector("tbody");
|
2023-04-03 21:57:03 +00:00
|
|
|
Object.keys(object).forEach((element) => {
|
2023-04-05 22:48:36 +00:00
|
|
|
let row = tbody.insertRow();
|
2023-04-05 22:29:15 +00:00
|
|
|
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
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|