A website for my game dev stuff that supports chat, etc.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

46 lines
958 B

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;
}
}