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 677d6f8 commit 696bbfa
Showing 1 changed file with 23 additions and 32 deletions.
55 changes: 23 additions & 32 deletions docs/AR/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
<h1>QR Code Scanner</h1>
<video id="qr-video" style="width: 100%; height: auto;" autoplay></video>
<canvas id="qr-canvas" style="display: none;"></canvas>
<div id="table-data" style="display: none;"></div>
<div id="qr-result" style="margin-top: 20px;"></div>
<div id="table-data"></div>
<!-- Nový div pro zobrazení textu -->
<div id="text-overlay" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: none; align-items: center; justify-content: center; background-color: rgba(0, 0, 0, 0.7); z-index: 999;">
<h1 id="text-content" style="color: white; font-size: 48px;">HELLO WORLD</h1>
<div id="text-content" style="color: white; font-size: 16px;"></div>
</div>

<script src="https://rawgit.com/schmich/instascan-builds/master/instascan.min.js"></script>
Expand Down Expand Up @@ -40,30 +41,27 @@ <h1 id="text-content" style="color: white; font-size: 48px;">HELLO WORLD</h1>
let isTextVisible = false;

scanner.addListener('scan', function (content) {
// Zde můžete provést načtení dat z cílové adresy a extrahovat požadované informace.
// Pro tuto ukázku jsem nahradil text "HELLO WORLD" daty z cílové stránky.
fetch(content) // Načte cílovou stránku
.then(response => response.text()) // Převede response na text
.then(html => {
// Zde můžete provést analýzu HTML a extrakci dat
const data = extractDataFromHTML(html);
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
isTextVisible = true;

// Zobrazíme získaná data
document.getElementById('table-data').textContent = JSON.stringify(data);

updateLastQRScanTime();
showTextOverlay();
isTextVisible = true;

// Resetovat timeout pro skrytí textu
clearTimeout(textTimeout);
textTimeout = setTimeout(hideTextOverlay, 5000);
})
.catch(error => {
console.error('Error loading data from URL');
hideTextOverlay();
isTextVisible = false;
});
// Načtení obsahu ze stránky
const xhr = new XMLHttpRequest();
xhr.open("GET", content, true);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
// Zobrazíme obsah na overlayi
document.getElementById('text-content').innerHTML = xhr.responseText;
showTextOverlay();
}
};
xhr.send();
} else {
document.getElementById('qr-result').textContent = "Invalid QR Code";
hideTextOverlay();
isTextVisible = false;
}
});

Instascan.Camera.getCameras().then(function (cameras) {
Expand All @@ -83,13 +81,6 @@ <h1 id="text-content" style="color: white; font-size: 48px;">HELLO WORLD</h1>
isTextVisible = false;
}
}, 1000);

// Funkce pro extrakci dat z HTML
function extractDataFromHTML(html) {
// Zde můžete provést analýzu HTML kódu a extrakci potřebných dat.
// V tomto příkladu pouze zobrazíme HTML kód.
return html;
}
</script>
</body>
</html>

0 comments on commit 696bbfa

Please sign in to comment.