diff --git a/src/index.html b/src/index.html
index 6fe3805..9bf0fe6 100644
--- a/src/index.html
+++ b/src/index.html
@@ -2474,8 +2474,10 @@ window.toggleEditConsulta = async function() {
openEditModal(full);
};
+// Pede senha admin — retorna Promise
function askPassword() {
return new Promise(resolve => {
+ const pw = config.admin_password;
const overlay = document.createElement('div');
overlay.style.cssText = 'position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.5);z-index:999999;display:flex;align-items:center;justify-content:center;';
overlay.id = 'pw-modal';
@@ -2485,21 +2487,24 @@ function askPassword() {
Senha incorreta
-
+
`;
document.body.appendChild(overlay);
const inp = document.getElementById('pw-input');
inp.focus();
- window._pwResolve = resolve;
+
+ document.getElementById('pw-cancel-btn').addEventListener('click', () => {
+ document.getElementById('pw-modal').remove();
+ resolve(false);
+ });
inp.addEventListener('keydown', e => { if (e.key === 'Enter') document.getElementById('pw-ok-btn').click(); });
document.getElementById('pw-ok-btn').addEventListener('click', () => {
const val = document.getElementById('pw-input').value;
if (val === pw) {
document.getElementById('pw-modal').remove();
- window._pwResult = true;
- window._pwResolve && window._pwResolve(true);
+ resolve(true);
} else {
document.getElementById('pw-error').style.display = 'block';
inp.value = '';