Update index.html

This commit is contained in:
ErikrafT 2025-04-12 10:00:46 -03:00 committed by GitHub
parent 8be3ce5ca9
commit 6126ebd35f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 35 additions and 33 deletions

View File

@ -956,16 +956,17 @@
</svg>
<!-- Scripts -->
<script src="https://unpkg.com/html5-qrcode"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
const qrBtn = document.getElementById("openQRScanner");
const qrReader = document.getElementById("qr-reader");
// Verifique se o botão foi encontrado
console.log(qrBtn); // Verificar se o botão foi encontrado corretamente.
if (qrBtn) {
qrBtn.addEventListener("click", async () => {
console.log("Botão clicado"); // Verifique se o evento de clique foi acionado
console.log("Botão clicado");
qrReader.style.display = "block"; // Tornar o leitor visível ao clicar
const html5QrCode = new Html5Qrcode("qr-reader");
@ -974,7 +975,6 @@
const devices = await Html5Qrcode.getCameras();
if (devices && devices.length) {
// Tenta achar a traseira com base no nome
const backCamera = devices.find(d => d.label.toLowerCase().includes("back")) || devices[0];
await html5QrCode.start(
@ -992,11 +992,13 @@
}
);
} else {
alert("Nenhuma câmera encontrada.");
alert("📷|Nenhuma câmera encontrada.");
}
} catch (err) {
console.error("Erro ao acessar a câmera: ", err);
alert("Erro ao acessar a câmera: " + err);
alert("🪲Erro ao acessar a câmera: " + err);
}
});
}
});
</script>