Repositorio > Proyectos > Desarrollo web > daeshu.eu.org
Blogger estoy usando una plantilla personal.
quodaniel parseData
<script type='text/javascript'>
//<![CDATA[
(function(){
function getConfig(){ return "MiClaveSuperSecreta"; } // <-- cámbiala
function pedirPassword() {
var modal = document.createElement("div");
modal.style.position = "fixed";
modal.style.top = "0";
modal.style.left = "0";
modal.style.width = "100%";
modal.style.height = "100%";
modal.style.background = "rgba(0,0,0,0.6)";
modal.style.display = "flex";
modal.style.justifyContent = "center";
modal.style.alignItems = "center";
modal.style.zIndex = "9999";
var box = document.createElement("div");
box.style.background = "#fff";
box.style.padding = "20px";
box.style.textAlign = "center";
box.style.borderRadius = "8px";
box.style.maxWidth = "320px";
box.style.width = "90%";
var title = document.createElement("h3");
title.appendChild(document.createTextNode("Introduce la contraseña"));
var input = document.createElement("input");
input.type = "password";
input.id = "passwordInput";
input.style.padding = "10px";
input.style.fontSize = "16px";
input.style.width = "100%";
input.style.boxSizing = "border-box";
input.setAttribute("autocomplete","off");
input.setAttribute("autocapitalize","off");
input.setAttribute("autocorrect","off");
input.setAttribute("spellcheck","false");
var btn = document.createElement("button");
btn.appendChild(document.createTextNode("Entrar"));
btn.style.marginTop = "10px";
btn.style.padding = "10px 20px";
btn.style.fontSize = "16px";
btn.style.width = "100%";
function handleSubmit(){
var ingreso = input.value;
if (ingreso === getConfig()) {
if (modal && modal.parentNode) modal.parentNode.removeChild(modal);
var cv = document.getElementById("cv");
if (cv) cv.style.display = "block";
} else {
alert("Acceso denegado");
input.value = "";
input.focus();
}
}
btn.onclick = handleSubmit;
// ⌨️ Permitir Enter para enviar
input.addEventListener("keydown", function(e){
e = e || window.event;
if (e.key === "Enter" || e.keyCode === 13) {
if (e.preventDefault) e.preventDefault(); else e.returnValue = false;
handleSubmit();
}
});
box.appendChild(title);
box.appendChild(input);
box.appendChild(btn);
modal.appendChild(box);
document.body.appendChild(modal);
// Foco inmediato en el campo
setTimeout(function(){ input.focus(); }, 0);
}
document.addEventListener("DOMContentLoaded", function(){
var cv = document.getElementById("cv");
if (cv) cv.style.display = "none"; // por si acaso
pedirPassword();
});
})();
//]]>
</script>