-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
66 lines (57 loc) · 2.16 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<html>
<head>
<title>Scan QR Code</title>
<body>
<div id="qr-reader" style="width:500px"></div>
<div id="qr-reader-results">
</div>
</body>
<!-- <script src="html5-qrcode.min.js"></script> -->
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="/ms-icon-144x144.png">
<meta name="theme-color" content="#ffffff">
<script src="html5-qrcode.min.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
<script>
function docReady(fn) {
// see if DOM is already available
if (document.readyState === "complete"
|| document.readyState === "interactive") {
// call on next available tick
setTimeout(fn, 1);
} else {
document.addEventListener("DOMContentLoaded", fn);
}
}
docReady(function () {
var resultContainer = document.getElementById('qr-reader-results');
var lastResult, countResults = 0;
function onScanSuccess(decodedText, decodedResult) {
if (decodedText !== lastResult) {
++countResults;
lastResult = decodedText;
// Handle on success condition with the decoded message.
console.log(`Scan result ${decodedText}`, decodedResult);
var item = document.createElement('li');
var text = document.createTextNode(decodedText);
item.appendChild(text);
var ul = document.createElement('ul');
ul.appendChild(item);
resultContainer.append(ul);
// resultContainer.append(decodedResult);
}
}
let config = {
fps: 10,
qrbox: { width: 100, height: 100 },
rememberLastUsedCamera: true,
// Only support camera scan type.
// supportedScanTypes: [Html5QrcodeScanType.SCAN_TYPE_CAMERA]
};
var html5QrcodeScanner = new Html5QrcodeScanner("qr-reader", { fps: 10, qrbox: 250 });
html5QrcodeScanner.render(onScanSuccess);
});
</script>
</head>
</html>