-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex.html
191 lines (172 loc) · 7.54 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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Dynamsoft Barcode Reader Nodejs Demo</title>
<link type="text/css" rel="stylesheet" href="assets/css/style.css" />
<script src='jquery-1.11.3.min.js'></script>
<script type="text/javascript">
function fileSelected() {
var count = document.getElementById('fileToUpload').files.length;
if (count > 0) {
var file = document.getElementById('fileToUpload').files[0];
document.getElementById('filename').value = file.name;
}
}
function getSelectedBarcodeTypes() {
var vType = 0;
var barcodeType = document.getElementsByName("BarcodeType");
for (i = 0; i < barcodeType.length; i++) {
if (barcodeType[i].checked == true)
vType = vType | (barcodeType[i].value * 1);
}
return vType;
}
function doReadBarcode() {
var fd = new FormData();
var uploadFlag = 0;
var clsval = document.getElementById('fileUpload').getAttribute('class');
if(clsval.indexOf('hidden') == -1) {
uploadFlag = 1;
}
if(uploadFlag) {
var count = document.getElementById('fileToUpload').files.length;
if (count > 0) {
var file = document.getElementById('fileToUpload').files[0];
fd.append('fileToUpload', file);
} else {
return;
}
} else {
var url = document.getElementById('imageURL').value;
if(url != null && url != "") {
fd.append('fileToDownload', url);
} else {
return;
}
}
fd.append('uploadFlag', uploadFlag);
fd.append('barcodetype', getSelectedBarcodeTypes());
var xhr = new XMLHttpRequest();
xhr.addEventListener("load", uploadComplete, false);
if(uploadFlag) {
xhr.upload.addEventListener("progress", uploadProgress, false);
xhr.addEventListener("error", uploadFailed, false);
xhr.addEventListener("abort", uploadCanceled, false);
}
xhr.open("POST", "/upload");
xhr.send(fd);
}
function uploadProgress(evt) {
if (evt.lengthComputable) {
var percentComplete = Math.round(evt.loaded * 100 / evt.total);
document.getElementById('resultBox').innerHTML = 'Upload status: Finished ' + percentComplete.toString() + '%.';
}
else {
//document.getElementById('resultBox').innerHTML = 'unable to compute';
}
}
function uploadComplete(evt) {
document.getElementById('resultBox').innerHTML = evt.target.responseText;
}
function uploadFailed(evt) {
alert("There was an error attempting to upload the file.");
}
function uploadCanceled(evt) {
alert("The upload has been canceled by the user or the browser dropped the connection.");
}
</script>
</head>
<body>
<div id="wrapper">
<div id="dbr-nodejs">
<h1>
Dynamsoft Barcode Reader Nodejs Demo</h1>
<!--<form action="">-->
<div class="step step1">
<div id="fileUpload" class="getFile">
<span class="num">1</span>
<h4>
Upload from local:</h4>
<input type="file" id="fileToUpload" onchange="fileSelected();" />
<input type="text" readonly="readonly" id="filename" />
<input type="button" />
<a class="clickSwitch" href="javascript:void(0);">or, Specify an URL</a>
</div>
<div id="fileDownload" class="hidden getFile">
<span class="num">1</span>
<h4>
Specify an URL:</h4>
<input type="text" id="imageURL"/>
<!--<input type="button"/>-->
<a class="clickSwitch" href="javascript:void(0);">or, Upload from local</a>
</div>
</div>
<div class="step step2">
<span class="num">2</span>
<h4>
Barcode Types:</h4>
<ul class="barcodeType">
<li class="on">
<label for="chkLinear">
<input id="chkLinear" name="BarcodeType" type="checkbox" checked="true" value="0x3FF">
<span>Linear</span><br />
<div class="imgWrapper">
<img src="assets/images/oned.gif" width="90" alt="Barcode Type Linear" /></div>
</label>
</li>
<li>
<label for="chkQRCode">
<input id="chkQRCode" name="BarcodeType" type="checkbox" value="0x4000000">
<span>QRCode</span><br />
<div class="imgWrapper">
<img src="assets/images/qr.gif" width="60" alt="Barcode Type QRCode" /></div>
</label>
</li>
<li>
<label for="chkPDF417">
<input id="chkPDF417" name="BarcodeType" type="checkbox" value="0x2000000">
<span>PDF417</span><br />
<div class="imgWrapper">
<img src="assets/images/pdf417.gif" width="100" height="38" alt="Barcode Type PDF417" /></div>
</label>
</li>
<li>
<label for="chkDataMatrix">
<input id="chkDataMatrix" name="BarcodeType" type="checkbox" value="0x8000000">
<span>DataMatrix</span><br />
<div class="imgWrapper">
<img src="assets/images/dm.gif" width="60" alt="Barcode Type DataMatrix" /></div>
</label>
</li>
<li>
<label for="chkDataMatrix">
<input id="chkDataMatrix" name="BarcodeType" type="checkbox" value="0x10000000">
<span>Aztec Code</span>
<br />
<div class="imgWrapper">
<img src="assets/images/aztec.png" width="60" alt="Aztec Code" />
</div>
</label>
</li>
</ul>
</div>
<div class="step step3">
<span class="num">3</span> <a id="readBarcode" name="RecgabtnCssBarcode" onclick="doReadBarcode();">
</a>
<div id="resultBox">
</div>
</div>
<!--</form>-->
</div>
</div>
<script type="text/javascript">
$("a.clickSwitch").click(function() {
$(".getFile").toggleClass('hidden');
});
$("ul.barcodeType :checkbox").click(function() {
$(this).parents('li').toggleClass('on');
});
</script>
</body>
</html>