class PaginateTable { constructor(url) { this.page = 0; this.items = []; this.url = url; this.headers = []; } async contents() { if(this.page < 0) this.page = 0; const resp = await fetch(`${this.url}?page=${this.page}`); console.assert(resp.status == 200, "failed to get it"); this.items = await resp.json(); this.headers = Object.keys(this.items[0]); return this.items; } } class GetJson { constructor(url) { this.item; this.url = url; } async item() { const resp = await fetch(`${this.url}`); console.assert(resp.status == 200, "failed to get it"); this.item = await resp.json(); return this.item; } } const ConfirmDelete = async (table, obj_id) => { if(confirm("Are you sure?")) { await fetch("/api/admin/table/" + table + "/" + obj_id + "/", { method: "DELETE" }); window.location = "/admin/table/" + table + "/"; } else { return false; } }