-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
112 lines (96 loc) · 3.97 KB
/
index.html
File metadata and controls
112 lines (96 loc) · 3.97 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Dynamsoft Document Scanner</title>
<link rel="stylesheet" href="./css/index.css" />
<!-- <script src="https://cdn.jsdelivr.net/npm/dynamsoft-document-scanner@1.4.0/dist/dds.bundle.js"></script> -->
<!-- To use locally: -->
<script src="../../dist/dds.bundle.js"></script>
</head>
<body>
<div class="logo">
<!-- Logo -->
<a class="logo-container" href="https://www.dynamsoft.com" target="_blank">
<img class="logo-img" src="./assets/dynamsoftLogo.png" alt="dynamsoft-logo" />
</a>
</div>
<!-- Mobile View -->
<div id="mobile-view" class="container">
<div class="header">Dynamsoft Document Scanner</div>
<button class="start-button" id="start-scan">Scan with Live Camera</button>
</div>
<!-- Desktop View (initially hidden) -->
<div id="desktop-view" class="container" style="display: none">
<div class="header">Dynamsoft Document Scanner</div>
<div class="description">
Dynamsoft Document Scanner snaps an image of your document and performs perspective cropping to produce a corrected scan.
<a class="description-link" href="https://dynamsoft.com/mobile-web-capture/docs/guides/document-scanner.html" target="_blank">Learn more.</a>
</div>
<div class="qr-container">
<div>Scan to Open on Mobile</div>
<img src="./assets/qr-code.png" alt="https://demo.dynamsoft.com/document-scanner" class="qr-code" />
</div>
<div class="quick-start">
<div class="quick-start-header">
<div>Quick Start Option:</div>
<button class="desktop-button" id="desktop-proceed">Continue on Desktop</button>
</div>
<div class="note">Note: Desktop cameras may have limited performance. Mobile scanning is recommended for best results.</div>
</div>
</div>
<div class="footer">Powered by Dynamsoft</div>
<script>
const mobileView = document.getElementById("mobile-view");
const desktopView = document.getElementById("desktop-view");
const startScanButton = document.getElementById("start-scan");
const desktopProceedButton = document.getElementById("desktop-proceed");
let firstLoad = true;
// Handle view switching based on device type
function detectDeviceAndSetView() {
if (window.innerWidth < 1024 || !firstLoad) {
mobileView.style.display = "flex";
desktopView.style.display = "none";
} else {
mobileView.style.display = "none";
desktopView.style.display = "flex";
}
}
// Call function on page load
window.addEventListener("load", detectDeviceAndSetView);
// Initialize the Dynamsoft Document Scanner
const documentScanner = new Dynamsoft.DocumentScanner({
license: "YOUR_LICENSE_KEY_HERE",
scannerViewConfig: {
cameraEnhancerUIPath: "../../dist/document-scanner.ui.xml",
},
resultViewConfig: {
toolbarButtonsConfig: {
done: {
"label": "Return Home"
}
}
},
});
// Start scan button handler
startScanButton.addEventListener("click", async function () {
mobileView.style.display = "none";
desktopView.style.display = "none";
try {
await documentScanner.launch();
detectDeviceAndSetView();
} catch (error) {
console.error("Error scanning:", error);
detectDeviceAndSetView();
}
});
// Desktop proceed button handler
desktopProceedButton.addEventListener("click", function () {
desktopView.style.display = "none";
mobileView.style.display = "flex";
firstLoad = false;
});
</script>
</body>
</html>