22 lines
666 B
JavaScript
22 lines
666 B
JavaScript
function checkPwd() {
|
|
const ls = window.localStorage;
|
|
const id = document.getElementById("public_id").dataset.content;
|
|
const pwd = ls.getItem(`ecoffee-pwd:${id}`);
|
|
if (pwd) {
|
|
const to_show = document.querySelectorAll(".needs_pwd");
|
|
to_show.forEach(el => {
|
|
el.classList.add("shown");
|
|
});
|
|
const buttons = document.querySelectorAll(".action button");
|
|
buttons.forEach(btn => {
|
|
const oldUrl= btn.getAttribute("hx-post");
|
|
btn.setAttribute("hx-post", `${oldUrl}&pwd=${pwd}`);
|
|
});
|
|
}
|
|
}
|
|
|
|
checkPwd();
|
|
|
|
document.addEventListener("htmx:afterRequest", evt => {
|
|
checkPwd();
|
|
})
|