Update index.html

This commit is contained in:
ErikrafT 2025-04-12 09:40:27 -03:00 committed by GitHub
parent 20815612e4
commit 1844322a3f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 25 additions and 28 deletions

View File

@ -102,14 +102,9 @@
<i class="fa-brands fa-bluetooth-b icon" style="font-size: 24px;"></i> <i class="fa-brands fa-bluetooth-b icon" style="font-size: 24px;"></i>
</div> --> </div> -->
<!-- Botão estilo PairDrop para abrir o leitor de QR Code --> <div id="openQRScanner" class="icon-button" title="Escanear QR Code" data-i18n-key="header.scan-qr" data-i18n-attrs="title">
<div id="openQRScanner" class="icon-button" data-i18n-key="header.qr-scan" data-i18n-attrs="title"> <i class="fa-solid fa-qrcode"></i>
<i class="fa-solid fa-qrcode"></i> </div>
</div>
<!-- Div onde o leitor será exibido -->
<div id="qr-reader" style="width: 300px; margin: 20px auto; display: none;"></div>
<div id="pair-device" class="icon-button" data-i18n-key="header.pair-device" data-i18n-attrs="title"> <div id="pair-device" class="icon-button" data-i18n-key="header.pair-device" data-i18n-attrs="title">
<svg class="icon"> <svg class="icon">
@ -963,31 +958,33 @@
</svg> </svg>
<!-- Scripts --> <!-- Scripts -->
<script src="https://unpkg.com/html5-qrcode"></script>
<script> <script>
document.getElementById("openQRScanner").addEventListener("click", () => { const qrReaderDiv = document.getElementById("qr-reader");
const qrReader = document.getElementById("qr-reader"); const qrButton = document.getElementById("openQRScanner");
qrReader.style.display = "block";
const html5QrCode = new Html5Qrcode("qr-reader"); qrButton.addEventListener("click", () => {
qrReaderDiv.style.display = "block";
const html5QrCode = new Html5Qrcode("qr-reader");
html5QrCode.start( html5QrCode.start(
{ facingMode: "environment" }, // Câmera traseira { facingMode: "environment" },
{ fps: 10, qrbox: 250 }, {
qrCodeMessage => { fps: 10,
console.log("QR Code detectado:", qrCodeMessage); qrbox: 250
html5QrCode.stop().then(() => { },
qrReader.style.display = "none"; qrCodeMessage => {
window.location.href = qrCodeMessage; // Redireciona console.log("QR Code:", qrCodeMessage);
// Redireciona ou insere o link escaneado
window.location.href = qrCodeMessage;
html5QrCode.stop();
},
errorMessage => {
console.warn("Erro QR:", errorMessage);
}
).catch(err => {
console.error("Erro ao iniciar o leitor", err);
}); });
},
error => {
// Erros de leitura ignorados (podem ser logados se quiser)
}
).catch(err => {
alert("Erro ao acessar a câmera: " + err);
}); });
});
</script> </script>
<!-- <!--