Created
January 12, 2024 18:34
-
-
Save mvark/856c100b85f838249810f98ea6b5b406 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<!-- Based on this HTML5 QR Code Reader sample by Minhaz https://blog.minhazav.dev/research/html5-qrcode.html --> | |
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=5"> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<title>OFF Bar Code Scanner</title> | |
</head> | |
<body> | |
<div id="desc">Scan Barcode to view details on Open Food Facts</div> | |
<div id="reader"></div> | |
<!-- html5-qrcode.min.js - https://raw.githubusercontent.com/mebjas/html5-qrcode/master/minified/html5-qrcode.min.js --> | |
<script src="html5-qrcode.min.js" type="text/javascript"></script> | |
<script type="text/javascript"> | |
function onScanSuccess(decodedText, decodedResult) { | |
document.getElementById('desc').innerHTML = "Barcode detected: " + decodedText + "...redirecting to Open Food Facts" ; | |
html5QrcodeScanner.clear(); | |
window.location.href = "https://world.openfoodfacts.org/product/" + decodedText; | |
} | |
var html5QrcodeScanner = new Html5QrcodeScanner( | |
"reader", { fps: 10, qrbox: 250 }); | |
html5QrcodeScanner.render(onScanSuccess); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment