-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbarcodedetection.html
More file actions
36 lines (34 loc) · 946 Bytes
/
Copy pathbarcodedetection.html
File metadata and controls
36 lines (34 loc) · 946 Bytes
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
<html>
<head>
<title>Barcode Detection Info</title>
</head>
<body>
<script>
const msg = document.createElement('p');
if (!('BarcodeDetector' in window)) {
msg.textContent = "Barcode detection not supported.";
document.body.appendChild(msg);
} else {
BarcodeDetector.getSupportedFormats().then((formats) => {
if (formats.length == 0) {
msg.textContent = "No barcode formats supported.";
document.body.appendChild(msg);
return;
}
msg.textContent = "Supported barcode formats:"
document.body.appendChild(msg);
const list = document.createElement('ul');
for (const format of formats) {
const entry = document.createElement('li');
entry.textContent = format;
list.appendChild(entry);
}
msg.appendChild(list);
}, (error) => {
msg.textContent = `${error.name}: ${error.message}`;
document.body.appendChild(msg);
});
}
</script>
</body>
</html>