37 lines
1.0 KiB
JavaScript
37 lines
1.0 KiB
JavaScript
|
|
document.addEventListener("DOMContentLoaded", () =>
|
|
{
|
|
fetch("isAdmin.php").then(res => res.json().then(json =>
|
|
{
|
|
if (json.message !== "ok")
|
|
{
|
|
window.location.href = "./search.html";
|
|
}
|
|
}));
|
|
|
|
fetch("viewLog.php").then(res => res.json().then(json =>
|
|
{
|
|
if (json.message === "ok")
|
|
{
|
|
for (const key of Object.keys(json.logs[0]))
|
|
{
|
|
let header = key.substring(key.indexOf("_") + 1)
|
|
header = header.charAt(0).toUpperCase() + header.slice(1);
|
|
document.querySelector("#logTable thead tr").innerHTML += `<th>${header}</th>`;
|
|
}
|
|
|
|
let body = "";
|
|
for (const row of json.logs)
|
|
{
|
|
body += "<tr>";
|
|
for (const key of Object.keys(row))
|
|
{
|
|
body += `<td>${row[key]}</td>`;
|
|
}
|
|
body += "</tr>";
|
|
}
|
|
|
|
document.querySelector("#logTable tbody").innerHTML = body;
|
|
}
|
|
}));
|
|
}); |