Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
martinius96 authored Oct 29, 2023
1 parent 1d466ad commit 8b7848f
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions docs/AR/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ <h1 id="text-content" style="color: white; font-size: 48px;">HELLO WORLD</h1>
<script>
let scanner = new Instascan.Scanner({ video: document.getElementById('qr-video'), mirror: false });
let lastQRScanTime = 0;
let textTimeout;

// Funkce pro zobrazení textu na obrazovce
function showTextOverlay() {
Expand All @@ -32,22 +33,15 @@ <h1 id="text-content" style="color: white; font-size: 48px;">HELLO WORLD</h1>
overlay.style.display = 'none';
}

// Funkce pro aktualizaci času posledního skenování
function updateLastQRScanTime() {
lastQRScanTime = Date.now();
}

let textOverlayTimeout;

scanner.addListener('scan', function (content) {
if (content.startsWith("https://arduino.clanweb.eu/studna_s_prekladom/full_vypis.php")) {
document.getElementById('qr-result').textContent = content;
updateLastQRScanTime(); // Aktualizovat čas posledního skenování QR kódu
lastQRScanTime = Date.now(); // Aktualizovat čas posledního skenování QR kódu
showTextOverlay();

// Resetovat interval pro skrytí textu
clearTimeout(textOverlayTimeout);
textOverlayTimeout = setTimeout(hideTextOverlay, 5000);
// Resetovat timeout pro skrytí textu
clearTimeout(textTimeout);
textTimeout = setTimeout(hideTextOverlay, 5000);
} else {
document.getElementById('qr-result').textContent = "Invalid QR Code";
hideTextOverlay();
Expand All @@ -63,6 +57,13 @@ <h1 id="text-content" style="color: white; font-size: 48px;">HELLO WORLD</h1>
}).catch(function (e) {
console.error(e);
});

// Kontrola na skrytí textu každou sekundu
setInterval(function() {
if (Date.now() - lastQRScanTime >= 5000) {
hideTextOverlay();
}
}, 1000);
</script>
</body>
</html>

0 comments on commit 8b7848f

Please sign in to comment.