feat: check for password existence
This commit is contained in:
parent
b03df8f0e4
commit
498ecdf68b
7 changed files with 73 additions and 15 deletions
22
app/javascript/list.js
Normal file
22
app/javascript/list.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
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();
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue