UNPKG

2.15 kBHTMLView Raw
1<!DOCTYPE html>
2<html lang="en">
3
4 <head>
5 <meta charset="utf-8">
6 <title>Scandit Example Page</title>
7 <meta name="viewport" content="width=device-width, initial-scale=1.0">
8 <script src="build/browser/index.min.js"></script>
9
10 <!-- The following is only an example style for the container element and other demo elements, it's not required -->
11 <style>
12 body {
13 background-color: black;
14 color: white;
15 font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
16 }
17
18 .scanner {
19 position: absolute;
20 top: 0;
21 bottom: 0;
22 left: 0;
23 right: 0;
24 margin: auto;
25 max-width: 1280px;
26 max-height: 80%;
27 }
28
29 .result-text {
30 padding: 1rem;
31 font-size: 18pt;
32 text-align: center;
33 }
34 </style>
35 </head>
36
37 <body>
38 <div id="scandit-barcode-picker" class="scanner"></div>
39 <div id="scandit-barcode-result" class="result-text"></div>
40
41 <script>
42 ScanditSDK.configure("YOUR_LICENSE_KEY_IS_NEEDED_HERE", {
43 engineLocation: "build"
44 }).then(function() {
45 return ScanditSDK.BarcodePicker.create(document.getElementById("scandit-barcode-picker"), { playSoundOnScan: true, vibrateOnScan: true })
46 .then(function(barcodePicker) {
47 var scanSettings = new ScanditSDK.ScanSettings({ enabledSymbologies: ["ean8", "ean13", "upca", "upce", "code128", "code39", "code93", "itf"], codeDuplicateFilter: 1000 });
48 barcodePicker.applyScanSettings(scanSettings);
49 barcodePicker
50 .on("scan", function(scanResult) {
51 document.getElementById("scandit-barcode-result").innerHTML = scanResult.barcodes.reduce(function(string, barcode) {
52 return string + ScanditSDK.Barcode.Symbology.toHumanizedName(barcode.symbology) + ": " + barcode.data + "<br>";
53 }, "");
54 })
55 .on("scanError", function(error) {
56 console.error(error);
57 });
58 });
59 }).catch(function(error) {
60 alert(error);
61 });
62
63 </script>
64 </body>
65
66</html>