Files
proxmark-doors/templates/door.html
2025-05-15 02:34:51 +01:00

126 lines
4.0 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Smart Door Lock</title>
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<style>
body {
font-family: 'Arial', sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
}
#lockContainer {
text-align: center;
background-color: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
#lockIcon {
font-size: 60px;
color: #3498db; /* Default color for locked icon */
}
#idCardStatus {
margin-top: 20px;
}
p {
margin: 0;
font-size: 18px;
color: #555;
}
p.accessGranted {
color: #2ecc71;
}
p.accessDenied {
color: #e74c3c;
}
</style>
</head>
<body>
<div id="lockContainer">
<div id="lockIcon">&#128274;</div>
<div id="idCardStatus">
<p>Waiting for card...</p>
</div>
</div>
<script>
var requestInProgress = false;
var currentUid = null;
const checkIdCardContents = async (sector, requiredContents) => {
const data = await fetch("/api/sector/" + sector);
const dump = (await data.json()).dump;
console.log(dump === requiredContents);
return dump === requiredContents;
};
const checkIdCardStatus = () => {
fetch("/api/uid").then(async (data) => {
const uid = (await data.json()).uid;
if (uid === currentUid) {
setTimeout(checkIdCardStatus, 0);
return;
}
currentUid = uid;
if (uid) {
const item = {{allowed_ids|tojson}}[uid];
if (item === undefined) updateStatus("Access Denied - ID: " + uid, "accessDenied", "&#128274;"); // Change to locked icon
else if (item[1].length > 0) {
updateStatus("ID: " + uid, "", "&#128274;", "<b>Reading card, please wait...</b>");
let contentsCorrect = true;
for (let sectorInfo of item[1]) {
if (!(await checkIdCardContents(...sectorInfo))) {
contentsCorrect = false;
break;
}
}
if (contentsCorrect) {
updateStatus("Unlocked - ID: " + uid, "accessGranted", "&#128275;", item[0] + "<br/></br><b>Card contents correct</b>");
} else {
updateStatus("Access Denied - ID: " + uid, "accessDenied", "&#128274;", "<b>Card contents incorrect</b>");
}
} else {
updateStatus("Unlocked - ID: " + uid, "accessGranted", "&#128275;", item[0]);
}
} else {
updateStatus("Waiting for card...", "", "&#128274;"); // No loading icon
}
setTimeout(checkIdCardStatus, 0);
}).catch((err) => {
console.log(err);
updateStatus("Error occurred while checking ID card status.", "", "&#128274;"); // No loading icon
setTimeout(checkIdCardStatus, 0);
});
}
const updateStatus = (status, className, icon, message = '') => {
$("#idCardStatus").html("<p class='" + className + "'>" + status + "</p>");
if (message != '') {
$("#idCardStatus").append("<br/><p class='" + className + "'>" + message + "</p>");}
$("#lockIcon").html(icon);
};
// Initial check when the page loads
checkIdCardStatus();
</script>
</body>
</html>