add error view
This commit is contained in:
parent
049402203b
commit
d5d6d53946
3 changed files with 35 additions and 4 deletions
|
@ -113,5 +113,17 @@
|
||||||
</footer>
|
</footer>
|
||||||
</article>
|
</article>
|
||||||
</dialog>
|
</dialog>
|
||||||
|
|
||||||
|
<dialog id="error">
|
||||||
|
<article>
|
||||||
|
<header t="error"></header>
|
||||||
|
|
||||||
|
<textarea readonly id="error-message"></textarea>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
<button t="close" id="error-close"></button>
|
||||||
|
</footer>
|
||||||
|
</article>
|
||||||
|
</dialog>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,4 +1,17 @@
|
||||||
function initEnterPassword() {
|
function initErrorDialog() {
|
||||||
|
const dialog = document.querySelector("dialog#error");
|
||||||
|
const message = document.querySelector("textarea#error-message");
|
||||||
|
const close = document.querySelector("button#error-close");
|
||||||
|
|
||||||
|
close.addEventListener("click", () => dialog.close());
|
||||||
|
|
||||||
|
return (err) => {
|
||||||
|
message.value = err.toString();
|
||||||
|
dialog.showModal();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function initEnterPassword(errorDialog) {
|
||||||
const form = document.querySelector("form#enter-password");
|
const form = document.querySelector("form#enter-password");
|
||||||
const fieldset = document.querySelector("fieldset#enter-password");
|
const fieldset = document.querySelector("fieldset#enter-password");
|
||||||
const submit = document.querySelector("button#enter-password");
|
const submit = document.querySelector("button#enter-password");
|
||||||
|
@ -28,6 +41,8 @@ function initEnterPassword() {
|
||||||
|
|
||||||
link.value = url.toString();
|
link.value = url.toString();
|
||||||
dialog.showModal();
|
dialog.showModal();
|
||||||
|
} catch (error) {
|
||||||
|
errorDialog(error);
|
||||||
} finally {
|
} finally {
|
||||||
fieldset.disabled = false;
|
fieldset.disabled = false;
|
||||||
submit.ariaBusy = "false";
|
submit.ariaBusy = "false";
|
||||||
|
@ -50,7 +65,7 @@ function initEnterPassword() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function confirmViewPassword() {
|
async function confirmViewPassword(errorDialog) {
|
||||||
const dialog = document.querySelector("dialog#confirm");
|
const dialog = document.querySelector("dialog#confirm");
|
||||||
const close = document.querySelector("button#confirm-close");
|
const close = document.querySelector("button#confirm-close");
|
||||||
const ok = document.querySelector("button#confirm-ok");
|
const ok = document.querySelector("button#confirm-ok");
|
||||||
|
@ -89,6 +104,8 @@ async function confirmViewPassword() {
|
||||||
const password = await decryptPassword(encryptedPassword, key, iv);
|
const password = await decryptPassword(encryptedPassword, key, iv);
|
||||||
|
|
||||||
viewPassword(password);
|
viewPassword(password);
|
||||||
|
} catch (error) {
|
||||||
|
errorDialog(error);
|
||||||
} finally {
|
} finally {
|
||||||
close.disabled = false;
|
close.disabled = false;
|
||||||
ok.disabled = false;
|
ok.disabled = false;
|
||||||
|
@ -113,6 +130,7 @@ async function viewPassword(password) {
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener("load", () => {
|
window.addEventListener("load", () => {
|
||||||
initEnterPassword();
|
const errorDialog = initErrorDialog();
|
||||||
confirmViewPassword();
|
initEnterPassword(errorDialog);
|
||||||
|
confirmViewPassword(errorDialog);
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
"not-found-reason": "The password you requested may have expired, been viewed before or never even existed in the first place.",
|
"not-found-reason": "The password you requested may have expired, been viewed before or never even existed in the first place.",
|
||||||
"reveal-password": "Reveal Password",
|
"reveal-password": "Reveal Password",
|
||||||
"reveal-password-once": "You may only reveal the password once",
|
"reveal-password-once": "You may only reveal the password once",
|
||||||
|
"error": "Error",
|
||||||
"copy": "Copy",
|
"copy": "Copy",
|
||||||
"close": "Close",
|
"close": "Close",
|
||||||
"ok": "OK"
|
"ok": "OK"
|
||||||
|
|
Loading…
Add table
Reference in a new issue