1
0
Fork 0
mirror of https://git.sr.ht/~roxwize/mipilin synced 2025-01-31 02:53:36 +00:00
mipilin/static/js/admin.js

21 lines
628 B
JavaScript
Raw Permalink Normal View History

const e_user_selected = document.getElementById("user-selected");
let current;
document.querySelectorAll("#users tr").forEach((el) => {
el.addEventListener("click", () => {
current = el.querySelector("td:nth-child(2)").textContent;
e_user_selected.textContent = current;
});
});
document.querySelectorAll("button").forEach((el) => {
el.addEventListener("click", (ev) => {
if (!current) {
ev.preventDefault();
return;
};
const e = el.parentElement;
e.setAttribute("action", el.parentElement.dataset.url.replaceAll("{}", current));
});
});