jqwidgets-ng 14.1.19 → 15.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/jqwidgets/jqx-all.js +3188 -30
- package/jqwidgets/jqxangular.js +1 -1
- package/jqwidgets/jqxbarcode.js +1088 -7
- package/jqwidgets/jqxbargauge.js +1 -1
- package/jqwidgets/jqxbulletchart.js +1 -1
- package/jqwidgets/jqxbuttongroup.js +1 -1
- package/jqwidgets/jqxbuttons.js +1 -1
- package/jqwidgets/jqxcalendar.js +2 -2
- package/jqwidgets/jqxchart.annotations.js +2 -2
- package/jqwidgets/jqxchart.api.js +1 -1
- package/jqwidgets/jqxchart.core.js +1 -1
- package/jqwidgets/jqxchart.js +2 -2
- package/jqwidgets/jqxchart.rangeselector.js +1 -1
- package/jqwidgets/jqxchart.waterfall.js +1 -1
- package/jqwidgets/jqxcheckbox.js +1 -1
- package/jqwidgets/jqxcheckboxgroup.js +396 -0
- package/jqwidgets/jqxcolorpicker.js +1 -1
- package/jqwidgets/jqxcombobox.js +1 -1
- package/jqwidgets/jqxcomplexinput.js +1 -1
- package/jqwidgets/jqxcore.js +1 -1
- package/jqwidgets/jqxdata.export.js +1 -1
- package/jqwidgets/jqxdata.js +2 -2
- package/jqwidgets/jqxdatatable.js +1 -1
- package/jqwidgets/jqxdate.js +1 -1
- package/jqwidgets/jqxdatetimeinput.js +2 -2
- package/jqwidgets/jqxdocking.js +1 -1
- package/jqwidgets/jqxdockinglayout.js +1 -1
- package/jqwidgets/jqxdockpanel.js +1 -1
- package/jqwidgets/jqxdragdrop.js +1 -1
- package/jqwidgets/jqxdraw.js +1 -1
- package/jqwidgets/jqxdropdownbutton.js +1 -1
- package/jqwidgets/jqxdropdownlist.js +1 -1
- package/jqwidgets/jqxeditor.js +1 -1
- package/jqwidgets/jqxexpander.js +1 -1
- package/jqwidgets/jqxfileupload.js +1 -1
- package/jqwidgets/jqxform.js +1 -1
- package/jqwidgets/jqxformattedinput.js +1 -1
- package/jqwidgets/jqxgauge.js +1 -1
- package/jqwidgets/jqxgrid.aggregates.js +1 -1
- package/jqwidgets/jqxgrid.chart.js +89 -84
- package/jqwidgets/jqxgrid.columnsreorder.js +1 -1
- package/jqwidgets/jqxgrid.columnsresize.js +1 -1
- package/jqwidgets/jqxgrid.edit.js +1 -1
- package/jqwidgets/jqxgrid.export.js +2 -2
- package/jqwidgets/jqxgrid.filter.js +2 -2
- package/jqwidgets/jqxgrid.grouping.js +2 -2
- package/jqwidgets/jqxgrid.js +2 -2
- package/jqwidgets/jqxgrid.pager.js +1 -1
- package/jqwidgets/jqxgrid.selection.js +1 -1
- package/jqwidgets/jqxgrid.sort.js +1 -1
- package/jqwidgets/jqxgrid.storage.js +1 -1
- package/jqwidgets/jqxheatmap.js +1 -1
- package/jqwidgets/jqxinput.js +1 -1
- package/jqwidgets/jqxkanban.js +1 -1
- package/jqwidgets/jqxknob.js +1 -1
- package/jqwidgets/jqxknockout.js +1 -1
- package/jqwidgets/jqxlayout.js +1 -1
- package/jqwidgets/jqxlistbox.js +2 -2
- package/jqwidgets/jqxlistmenu.js +1 -1
- package/jqwidgets/jqxloader.js +1 -1
- package/jqwidgets/jqxmaskedinput.js +2 -2
- package/jqwidgets/jqxmenu.js +1 -1
- package/jqwidgets/jqxnavbar.js +1 -1
- package/jqwidgets/jqxnavigationbar.js +1 -1
- package/jqwidgets/jqxnotification.js +1 -1
- package/jqwidgets/jqxnumberinput.js +2 -2
- package/jqwidgets/jqxpanel.js +1 -1
- package/jqwidgets/jqxpasswordinput.js +1 -1
- package/jqwidgets/jqxpivot.js +1 -1
- package/jqwidgets/jqxpivotdesigner.js +1 -1
- package/jqwidgets/jqxpivotgrid.js +1 -1
- package/jqwidgets/jqxpopover.js +1 -1
- package/jqwidgets/jqxprogressbar.js +1 -1
- package/jqwidgets/jqxqrcode.js +1318 -7
- package/jqwidgets/jqxradiobutton.js +2 -2
- package/jqwidgets/jqxradiobuttongroup.js +384 -0
- package/jqwidgets/jqxrangeselector.js +1 -1
- package/jqwidgets/jqxrating.js +1 -1
- package/jqwidgets/jqxresponsivepanel.js +1 -1
- package/jqwidgets/jqxribbon.js +1 -1
- package/jqwidgets/jqxscheduler.api.js +2 -2
- package/jqwidgets/jqxscheduler.js +1 -1
- package/jqwidgets/jqxscrollbar.js +1 -1
- package/jqwidgets/jqxscrollview.js +1 -1
- package/jqwidgets/jqxslider.js +1 -1
- package/jqwidgets/jqxsortable.js +1 -1
- package/jqwidgets/jqxsplitlayout.js +6 -2445
- package/jqwidgets/jqxsplitter.js +1 -1
- package/jqwidgets/jqxswitchbutton.js +1 -1
- package/jqwidgets/jqxtabs.js +1 -1
- package/jqwidgets/jqxtagcloud.js +1 -1
- package/jqwidgets/jqxtextarea.js +1 -1
- package/jqwidgets/jqxtimepicker.js +1 -1
- package/jqwidgets/jqxtoolbar.js +1 -1
- package/jqwidgets/jqxtooltip.js +1 -1
- package/jqwidgets/jqxtouch.js +1 -1
- package/jqwidgets/jqxtree.js +1 -1
- package/jqwidgets/jqxtreegrid.js +1 -1
- package/jqwidgets/jqxtreemap.js +1 -1
- package/jqwidgets/jqxvalidator.js +1 -1
- package/jqwidgets/jqxwindow.js +1 -1
- package/jqwidgets/styles/jqx.base.css +123 -109
- package/jqwidgets/styles/jqx.light.css +6 -13
- package/package.json +6 -3
package/jqwidgets/jqxbarcode.js
CHANGED
|
@@ -1,18 +1,1099 @@
|
|
|
1
1
|
/*
|
|
2
|
-
jQWidgets
|
|
2
|
+
jQWidgets v15.0.0 (2022-Nov)
|
|
3
3
|
Copyright (c) 2011-2022 jQWidgets.
|
|
4
4
|
License: https://jqwidgets.com/license/
|
|
5
5
|
*/
|
|
6
6
|
/* eslint-disable */
|
|
7
7
|
|
|
8
|
-
/*
|
|
9
|
-
jQWidgets v14.0.0 (2022-May)
|
|
10
|
-
Copyright (c) 2011-2022 jQWidgets.
|
|
11
|
-
License: https://jqwidgets.com/license/
|
|
12
|
-
*/
|
|
8
|
+
/* tslint:disable */
|
|
13
9
|
/* eslint-disable */
|
|
10
|
+
(function ($) {
|
|
11
|
+
|
|
12
|
+
$.jqx.jqxWidget("jqxBarcode", "", {});
|
|
13
|
+
|
|
14
|
+
$.extend($.jqx._jqxBarcode.prototype, {
|
|
15
|
+
defineInstance: function () {
|
|
16
|
+
var settings = {
|
|
17
|
+
value: '12345',
|
|
18
|
+
type: 'codabar',
|
|
19
|
+
backgroundColor: 'white',
|
|
20
|
+
lineWidth: 4,
|
|
21
|
+
lineHeight: 50,
|
|
22
|
+
lineColor: 'black',
|
|
23
|
+
displayLabel: true,
|
|
24
|
+
labelPosition: 'bottom',
|
|
25
|
+
labelFontSize: 14,
|
|
26
|
+
labelMarginTop: 5,
|
|
27
|
+
labelMarginBottom: 5,
|
|
28
|
+
labelColor: 'black',
|
|
29
|
+
labelFont: 'monospace',
|
|
30
|
+
renderAs: 'svg'
|
|
31
|
+
}
|
|
32
|
+
$.extend(true, this, settings);
|
|
33
|
+
return settings;
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
createInstance: function (args) {
|
|
38
|
+
var that = this;
|
|
39
|
+
|
|
40
|
+
var barcode = new Barcode(this.element);
|
|
41
|
+
barcode.value = that.value;
|
|
42
|
+
barcode.type = that.type;
|
|
43
|
+
barcode.backgroundColor = that.backgroundColor;
|
|
44
|
+
barcode.lineWidth = that.lineWidth;
|
|
45
|
+
barcode.lineHeight = that.lineHeight;
|
|
46
|
+
barcode.lineColor = that.lineColor;
|
|
47
|
+
barcode.displayLabel = that.displayLabel;
|
|
48
|
+
barcode.labelPosition = that.labelPosition;
|
|
49
|
+
barcode.labelFontSize = that.labelFontSize;
|
|
50
|
+
barcode.labelMarginTop = that.labelMarginTop;
|
|
51
|
+
barcode.labelMarginBottom = that.labelMarginBottom;
|
|
52
|
+
barcode.labelColor = that.labelColor;
|
|
53
|
+
barcode.labelFont = that.labelFont;
|
|
54
|
+
barcode.renderAs = that.renderAs;
|
|
55
|
+
|
|
56
|
+
this.element.innerHTML = barcode.template();
|
|
57
|
+
this.barcode = barcode;
|
|
58
|
+
barcode.refresh();
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
getDataURL: function (format) {
|
|
62
|
+
return this.barcode.getDataURL(format);
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
export: function (format, fileName) {
|
|
66
|
+
this.barcode.export(format, fileName);
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
isValid: function () {
|
|
70
|
+
return this.barcode.isValid(false);
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
propertyChangedHandler: function (object, key, oldvalue, value) {
|
|
74
|
+
var that = object;
|
|
75
|
+
|
|
76
|
+
that.barcode.refresh();
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
})(jqxBaseFramework);
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class Barcode {
|
|
83
|
+
constructor(host) {
|
|
84
|
+
this.host = host;
|
|
85
|
+
}
|
|
86
|
+
// Barcode's properties.
|
|
87
|
+
static get properties() {
|
|
88
|
+
return {
|
|
89
|
+
value: {
|
|
90
|
+
type: 'string',
|
|
91
|
+
value: '',
|
|
92
|
+
},
|
|
93
|
+
type: {
|
|
94
|
+
value: 'codabar',
|
|
95
|
+
type: 'string',
|
|
96
|
+
allowedValues: [
|
|
97
|
+
'pharmacode',
|
|
98
|
+
'codabar',
|
|
99
|
+
'code128a',
|
|
100
|
+
'code128b',
|
|
101
|
+
'code128c',
|
|
102
|
+
'msi',
|
|
103
|
+
'msi10',
|
|
104
|
+
'msi11',
|
|
105
|
+
'msi1010',
|
|
106
|
+
'msi1110',
|
|
107
|
+
'ean13',
|
|
108
|
+
'ean8',
|
|
109
|
+
'code39',
|
|
110
|
+
'code93',
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
backgroundColor: {
|
|
114
|
+
value: 'white',
|
|
115
|
+
type: 'string',
|
|
116
|
+
},
|
|
117
|
+
lineWidth: {
|
|
118
|
+
value: 4,
|
|
119
|
+
type: 'number',
|
|
120
|
+
},
|
|
121
|
+
lineHeight: {
|
|
122
|
+
value: 50,
|
|
123
|
+
type: 'number',
|
|
124
|
+
},
|
|
125
|
+
lineColor: {
|
|
126
|
+
value: 'black',
|
|
127
|
+
type: 'string',
|
|
128
|
+
},
|
|
129
|
+
displayLabel: {
|
|
130
|
+
value: true,
|
|
131
|
+
type: 'boolean',
|
|
132
|
+
},
|
|
133
|
+
labelPosition: {
|
|
134
|
+
value: 'bottom',
|
|
135
|
+
type: 'string',
|
|
136
|
+
allowedValues: ['top', 'bottom'],
|
|
137
|
+
},
|
|
138
|
+
labelFontSize: {
|
|
139
|
+
value: 14,
|
|
140
|
+
type: 'number',
|
|
141
|
+
},
|
|
142
|
+
labelMarginTop: {
|
|
143
|
+
value: 5,
|
|
144
|
+
type: 'number',
|
|
145
|
+
},
|
|
146
|
+
labelMarginBottom: {
|
|
147
|
+
value: 5,
|
|
148
|
+
type: 'number',
|
|
149
|
+
},
|
|
150
|
+
labelColor: {
|
|
151
|
+
value: 'black',
|
|
152
|
+
type: 'string',
|
|
153
|
+
},
|
|
154
|
+
labelFont: {
|
|
155
|
+
value: 'monospace',
|
|
156
|
+
type: 'string',
|
|
157
|
+
},
|
|
158
|
+
renderAs: {
|
|
159
|
+
value: 'svg',
|
|
160
|
+
type: 'string',
|
|
161
|
+
allowedValues: ['svg', 'canvas'],
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Barcode's template. */
|
|
167
|
+
template() {
|
|
168
|
+
return '<div class="jqx-barcode-container"></div>';
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Refreshes the UI Component.
|
|
173
|
+
*/
|
|
174
|
+
refresh() {
|
|
175
|
+
const that = this;
|
|
176
|
+
that._generateCode(that.renderAs);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Generates barcode
|
|
181
|
+
*/
|
|
182
|
+
_generateCode(renderAs, hidden = false) {
|
|
183
|
+
const that = this;
|
|
184
|
+
const encoded = this._getEncoded(that.type, that.value);
|
|
185
|
+
const barcodeLength = encoded.length * that.lineWidth;
|
|
186
|
+
const barcodeHeight =
|
|
187
|
+
that.lineHeight +
|
|
188
|
+
that.displayLabel *
|
|
189
|
+
(that.labelMarginTop + that.labelMarginBottom + that.labelFontSize);
|
|
190
|
+
let x = 0,
|
|
191
|
+
y = 0,
|
|
192
|
+
container;
|
|
193
|
+
|
|
194
|
+
that.isValid();
|
|
195
|
+
|
|
196
|
+
if (renderAs === 'svg') {
|
|
197
|
+
container = document.createElementNS(
|
|
198
|
+
'http://www.w3.org/2000/svg',
|
|
199
|
+
'svg'
|
|
200
|
+
);
|
|
201
|
+
container.setAttribute('width', barcodeLength);
|
|
202
|
+
container.setAttribute('height', barcodeHeight);
|
|
203
|
+
container.setAttributeNS(
|
|
204
|
+
'http://www.w3.org/2000/xmlns/',
|
|
205
|
+
'xmlns:svg',
|
|
206
|
+
'http://www.w3.org/2000/svg'
|
|
207
|
+
);
|
|
208
|
+
container.style.backgroundColor = that.backgroundColor;
|
|
209
|
+
}
|
|
210
|
+
else if (renderAs === 'canvas') {
|
|
211
|
+
container = document.createElement('canvas');
|
|
212
|
+
container.setAttribute('width', barcodeLength);
|
|
213
|
+
container.setAttribute('height', barcodeHeight);
|
|
214
|
+
let ctx = container.getContext('2d');
|
|
215
|
+
ctx.fillStyle = that.backgroundColor;
|
|
216
|
+
ctx.fillRect(0, 0, barcodeLength, barcodeHeight);
|
|
217
|
+
}
|
|
218
|
+
if (hidden) {
|
|
219
|
+
container.style.display = 'none';
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
container.classList.add('jqx-barcode');
|
|
223
|
+
that.host.firstChild.appendChild(container);
|
|
224
|
+
|
|
225
|
+
if (that.displayLabel && that.labelPosition === 'top') {
|
|
226
|
+
y += that.labelMarginTop + that.labelFontSize;
|
|
227
|
+
renderAs === 'svg'
|
|
228
|
+
? that._drawTextSVG(barcodeLength / 2, y, container)
|
|
229
|
+
: that._drawTextCanvas(barcodeLength / 2, y, container);
|
|
230
|
+
y += that.labelMarginBottom;
|
|
231
|
+
}
|
|
232
|
+
for (let line of encoded) {
|
|
233
|
+
if (line === '1') {
|
|
234
|
+
renderAs === 'svg'
|
|
235
|
+
? that._drawStepSVG(that.lineColor, 1, x, y, container)
|
|
236
|
+
: that._drawStepCanvas(that.lineColor, 1, x, y, container);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
renderAs === 'svg'
|
|
240
|
+
? that._drawStepSVG('white', 0, x, y, container)
|
|
241
|
+
: that._drawStepCanvas('white', 0, x, y, container);
|
|
242
|
+
}
|
|
243
|
+
x += that.lineWidth;
|
|
244
|
+
}
|
|
245
|
+
if (that.displayLabel && that.labelPosition === 'bottom') {
|
|
246
|
+
y += that.lineHeight + that.labelMarginTop + that.labelFontSize;
|
|
247
|
+
renderAs === 'svg'
|
|
248
|
+
? that._drawTextSVG(barcodeLength / 2, y, container)
|
|
249
|
+
: that._drawTextCanvas(barcodeLength / 2, y, container);
|
|
250
|
+
}
|
|
251
|
+
//Removes previous container
|
|
252
|
+
if (that.host.firstChild.children.length === 2) {
|
|
253
|
+
if (that.host.firstChild.children[1].style.display !== 'none') {
|
|
254
|
+
that.host.firstChild.removeChild(that.host.firstChild.firstChild);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Gets barcode encoded string
|
|
261
|
+
*/
|
|
262
|
+
_getEncoded(type, value) {
|
|
263
|
+
const that = this;
|
|
264
|
+
let encoded;
|
|
265
|
+
switch (type) {
|
|
266
|
+
case 'pharmacode': {
|
|
267
|
+
encoded = that._getEncodedPharmacode(value);
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
case 'codabar': {
|
|
271
|
+
encoded = that._getEncodedCodabar(value);
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
case 'code128a': {
|
|
275
|
+
encoded = that._getEncodedCode128(value, 'A');
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
case 'code128b': {
|
|
279
|
+
encoded = that._getEncodedCode128(value, 'B');
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
case 'code128c': {
|
|
283
|
+
encoded = that._getEncodedCode128(that.value, 'C');
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
case 'msi': {
|
|
287
|
+
encoded = that._getEncodedMSI(that.value, '');
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
case 'msi10': {
|
|
291
|
+
encoded = that._getEncodedMSI(that.value, '10');
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
case 'msi11': {
|
|
295
|
+
encoded = that._getEncodedMSI(that.value, '11');
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
case 'msi1010': {
|
|
299
|
+
encoded = that._getEncodedMSI(that.value, '1010');
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
case 'msi1110': {
|
|
303
|
+
encoded = that._getEncodedMSI(that.value, '1010');
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
case 'ean13': {
|
|
307
|
+
encoded = that._getEncodedEAN(that.value, '13');
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
case 'ean8': {
|
|
311
|
+
encoded = that._getEncodedEAN(that.value, '8');
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
case 'code39': {
|
|
315
|
+
encoded = that._getEncodedCode39(that.value);
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
case 'code93': {
|
|
319
|
+
encoded = that._getEncodedCode93(that.value);
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return encoded;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Validates the barcode value
|
|
328
|
+
*/
|
|
329
|
+
isValid(isQRcode = false) {
|
|
330
|
+
const that = this;
|
|
331
|
+
const type = that.type;
|
|
332
|
+
const val = that.value;
|
|
333
|
+
|
|
334
|
+
let charactersRegex = /[^@!(一-龠)(ぁ-ゔ)(ァ-ヴー)\d0-9A-Z \$\%\*\+\-\.\/\:\=\?\^\{\|\}\~]/gm,
|
|
335
|
+
patternValidity = true,
|
|
336
|
+
lengthValidity = true,
|
|
337
|
+
illegalChars = [];
|
|
338
|
+
if (!isQRcode) {
|
|
339
|
+
switch (type) {
|
|
340
|
+
case 'pharmacode': {
|
|
341
|
+
charactersRegex = /[^\d]/gm;
|
|
342
|
+
lengthValidity = val.length >= 1 && val.length <= 6;
|
|
343
|
+
patternValidity = +val >= 3 && +val <= 131070;
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
case 'codabar': {
|
|
347
|
+
charactersRegex = /[^ABCD\d\$-]/gm;
|
|
348
|
+
patternValidity = /^[A-D]\d+[A-D]$/gm.test(val);
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
case 'code128a': {
|
|
352
|
+
charactersRegex = /[^\x20-\x5F]/gm;
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
case 'code128b': {
|
|
356
|
+
charactersRegex = /[^\x20-\x7F]/gm;
|
|
357
|
+
break;
|
|
358
|
+
}
|
|
359
|
+
case 'code128c': {
|
|
360
|
+
charactersRegex = /[^\d]/gm;
|
|
361
|
+
break;
|
|
362
|
+
}
|
|
363
|
+
case 'msi':
|
|
364
|
+
case 'msi10':
|
|
365
|
+
case 'msi11':
|
|
366
|
+
case 'msi1010':
|
|
367
|
+
case 'msi1110': {
|
|
368
|
+
charactersRegex = /[^\d]/gm;
|
|
369
|
+
break;
|
|
370
|
+
}
|
|
371
|
+
case 'ean13': {
|
|
372
|
+
charactersRegex = /[^\d]/gm;
|
|
373
|
+
lengthValidity = val.length === 13 || val.length === 12;
|
|
374
|
+
break;
|
|
375
|
+
}
|
|
376
|
+
case 'ean8': {
|
|
377
|
+
charactersRegex = /[^\d]/gm;
|
|
378
|
+
lengthValidity = val.length === 7 || val.length === 8;
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
case 'code39': {
|
|
382
|
+
charactersRegex = /[^\w\*.]/gm;
|
|
383
|
+
patternValidity = /^\*\*$/gm.test(val);
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
case 'code93': {
|
|
387
|
+
charactersRegex = /[^\w\*.\-\* \$+\/%]/gm;
|
|
388
|
+
patternValidity = /^\*\*$/gm.test(val);
|
|
389
|
+
break;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
illegalChars = val.match(charactersRegex);
|
|
395
|
+
if (!patternValidity || illegalChars || !lengthValidity) {
|
|
396
|
+
this.host.dispatchEvent(new CustomEvent("invalid", {
|
|
397
|
+
detail: {
|
|
398
|
+
value: val,
|
|
399
|
+
invalidCharacters: illegalChars,
|
|
400
|
+
patternValidity: patternValidity,
|
|
401
|
+
lengthValidity: lengthValidity
|
|
402
|
+
}
|
|
403
|
+
}));
|
|
404
|
+
return false;
|
|
405
|
+
}
|
|
406
|
+
return true;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Draws the label text in SVG
|
|
411
|
+
*/
|
|
412
|
+
_drawTextSVG(x, y, svg_container) {
|
|
413
|
+
const that = this;
|
|
414
|
+
|
|
415
|
+
let textElem = document.createElementNS(
|
|
416
|
+
'http://www.w3.org/2000/svg',
|
|
417
|
+
'text'
|
|
418
|
+
);
|
|
419
|
+
textElem.setAttribute('x', x);
|
|
420
|
+
textElem.setAttribute('y', y);
|
|
421
|
+
textElem.setAttribute('text-anchor', 'middle');
|
|
422
|
+
textElem.classList.add('jqx-barcode-label');
|
|
423
|
+
textElem.style.fill = that.labelColor;
|
|
424
|
+
textElem.style.fontFamily = that.labelFont;
|
|
425
|
+
textElem.style.fontSize = that.labelFontSize + 'px';
|
|
426
|
+
textElem.textContent = that.value;
|
|
427
|
+
svg_container.appendChild(textElem);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Draws the label text in Canvas
|
|
432
|
+
*/
|
|
433
|
+
_drawTextCanvas(x, y, canvas) {
|
|
434
|
+
const that = this;
|
|
435
|
+
let ctx = canvas.getContext('2d');
|
|
436
|
+
ctx.font = `${that.labelFontSize}px ${that.labelFont}`;
|
|
437
|
+
ctx.fillStyle = that.labelColor;
|
|
438
|
+
ctx.textAlign = 'center';
|
|
439
|
+
ctx.fillText(that.value, x, y);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Draws a single unit bar in svg
|
|
444
|
+
*/
|
|
445
|
+
_drawStepSVG(color, opacity, x, y, svg_container) {
|
|
446
|
+
const that = this;
|
|
447
|
+
if (that.squareWidth) {
|
|
448
|
+
that.lineWidth = that.squareWidth;
|
|
449
|
+
that.lineHeight = that.squareWidth;
|
|
450
|
+
}
|
|
451
|
+
let rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
|
|
452
|
+
rect.setAttribute('x', x);
|
|
453
|
+
rect.setAttribute('y', y);
|
|
454
|
+
rect.setAttribute('width', that.lineWidth);
|
|
455
|
+
rect.setAttribute('height', that.lineHeight);
|
|
456
|
+
rect.setAttribute('fill-opacity', opacity);
|
|
457
|
+
rect.style.fill = color;
|
|
458
|
+
svg_container.appendChild(rect);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Draws a single unit bar in canvas
|
|
463
|
+
*/
|
|
464
|
+
_drawStepCanvas(color, opacity, x, y, canvas) {
|
|
465
|
+
const that = this;
|
|
466
|
+
if (that.squareWidth) {
|
|
467
|
+
that.lineWidth = that.squareWidth;
|
|
468
|
+
that.lineHeight = that.squareWidth;
|
|
469
|
+
}
|
|
470
|
+
let ctx = canvas.getContext('2d');
|
|
471
|
+
ctx.beginPath();
|
|
472
|
+
ctx.globalAlpha = opacity;
|
|
473
|
+
ctx.strokeStyle = color;
|
|
474
|
+
ctx.fillStyle = color;
|
|
475
|
+
ctx.rect(x, y, that.lineWidth, that.lineHeight);
|
|
476
|
+
ctx.fill();
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Encodes data in pharmacode format
|
|
481
|
+
*/
|
|
482
|
+
_getEncodedPharmacode(val) {
|
|
483
|
+
let encoded = '';
|
|
484
|
+
|
|
485
|
+
while (val !== 0) {
|
|
486
|
+
if (val % 2 === 0) {
|
|
487
|
+
encoded = '11100' + encoded;
|
|
488
|
+
val = (val - 2) / 2;
|
|
489
|
+
}
|
|
490
|
+
else {
|
|
491
|
+
encoded = '100' + encoded;
|
|
492
|
+
val = (val - 1) / 2;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
encoded = encoded.slice(0, -2);
|
|
497
|
+
|
|
498
|
+
return encoded;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Encodes data in codabar format
|
|
503
|
+
*/
|
|
504
|
+
_getEncodedCodabar(val) {
|
|
505
|
+
let encoded = '';
|
|
506
|
+
const sets = {
|
|
507
|
+
0: 1010100110,
|
|
508
|
+
1: 1010110010,
|
|
509
|
+
2: 1010010110,
|
|
510
|
+
3: 1100101010,
|
|
511
|
+
4: 1011010010,
|
|
512
|
+
5: 1101010010,
|
|
513
|
+
6: 1001010110,
|
|
514
|
+
7: 1001011010,
|
|
515
|
+
8: 1001101010,
|
|
516
|
+
9: 1101001010,
|
|
517
|
+
'-': 1010011010,
|
|
518
|
+
$: 1011001010,
|
|
519
|
+
':': 11010110110,
|
|
520
|
+
'/': 11011010110,
|
|
521
|
+
'.': 11011011010,
|
|
522
|
+
'+': 10110110110,
|
|
523
|
+
A: 10110010010,
|
|
524
|
+
B: 10010010110,
|
|
525
|
+
C: 10100100110,
|
|
526
|
+
D: 10100110010,
|
|
527
|
+
};
|
|
528
|
+
|
|
529
|
+
for (let char of val) {
|
|
530
|
+
encoded += sets[char];
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
encoded = encoded.slice(0, -1);
|
|
534
|
+
|
|
535
|
+
return encoded;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Encodes data in code39 format
|
|
540
|
+
*/
|
|
541
|
+
_getEncodedCode39(val) {
|
|
542
|
+
let encoded = '';
|
|
543
|
+
const chars = [
|
|
544
|
+
'0',
|
|
545
|
+
'1',
|
|
546
|
+
'2',
|
|
547
|
+
'3',
|
|
548
|
+
'4',
|
|
549
|
+
'5',
|
|
550
|
+
'6',
|
|
551
|
+
'7',
|
|
552
|
+
'8',
|
|
553
|
+
'9',
|
|
554
|
+
'A',
|
|
555
|
+
'B',
|
|
556
|
+
'C',
|
|
557
|
+
'D',
|
|
558
|
+
'E',
|
|
559
|
+
'F',
|
|
560
|
+
'G',
|
|
561
|
+
'H',
|
|
562
|
+
'I',
|
|
563
|
+
'J',
|
|
564
|
+
'K',
|
|
565
|
+
'L',
|
|
566
|
+
'M',
|
|
567
|
+
'N',
|
|
568
|
+
'O',
|
|
569
|
+
'P',
|
|
570
|
+
'Q',
|
|
571
|
+
'R',
|
|
572
|
+
'S',
|
|
573
|
+
'T',
|
|
574
|
+
'U',
|
|
575
|
+
'V',
|
|
576
|
+
'W',
|
|
577
|
+
'X',
|
|
578
|
+
'Y',
|
|
579
|
+
'Z',
|
|
580
|
+
'-',
|
|
581
|
+
'.',
|
|
582
|
+
' ',
|
|
583
|
+
'$',
|
|
584
|
+
'/',
|
|
585
|
+
'+',
|
|
586
|
+
'%',
|
|
587
|
+
'*',
|
|
588
|
+
];
|
|
589
|
+
const set = [
|
|
590
|
+
20957, 29783, 23639, 30485, 20951, 29813, 23669, 20855, 29789, 23645,
|
|
591
|
+
29975, 23831, 30533, 22295, 30149, 24005, 21623, 29981, 23837, 22301,
|
|
592
|
+
30023, 23879, 30545, 22343, 30161, 24017, 21959, 30065, 23921, 22385,
|
|
593
|
+
29015, 18263, 29141, 17879, 29045, 18293, 17783, 29021, 18269, 17477,
|
|
594
|
+
17489, 17681, 20753, 35770,
|
|
595
|
+
];
|
|
596
|
+
|
|
597
|
+
for (let char of val) {
|
|
598
|
+
encoded += set[chars.indexOf(char)].toString(2) + '0';
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
encoded = encoded.slice(0, -1);
|
|
602
|
+
|
|
603
|
+
return encoded;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* Encodes data in code93 format
|
|
608
|
+
*/
|
|
609
|
+
_getEncodedCode93(val) {
|
|
610
|
+
let encoded = '';
|
|
611
|
+
const chars = [
|
|
612
|
+
'0',
|
|
613
|
+
'1',
|
|
614
|
+
'2',
|
|
615
|
+
'3',
|
|
616
|
+
'4',
|
|
617
|
+
'5',
|
|
618
|
+
'6',
|
|
619
|
+
'7',
|
|
620
|
+
'8',
|
|
621
|
+
'9',
|
|
622
|
+
'A',
|
|
623
|
+
'B',
|
|
624
|
+
'C',
|
|
625
|
+
'D',
|
|
626
|
+
'E',
|
|
627
|
+
'F',
|
|
628
|
+
'G',
|
|
629
|
+
'H',
|
|
630
|
+
'I',
|
|
631
|
+
'J',
|
|
632
|
+
'K',
|
|
633
|
+
'L',
|
|
634
|
+
'M',
|
|
635
|
+
'N',
|
|
636
|
+
'O',
|
|
637
|
+
'P',
|
|
638
|
+
'Q',
|
|
639
|
+
'R',
|
|
640
|
+
'S',
|
|
641
|
+
'T',
|
|
642
|
+
'U',
|
|
643
|
+
'V',
|
|
644
|
+
'W',
|
|
645
|
+
'X',
|
|
646
|
+
'Y',
|
|
647
|
+
'Z',
|
|
648
|
+
'-',
|
|
649
|
+
'.',
|
|
650
|
+
' ',
|
|
651
|
+
'$',
|
|
652
|
+
'/',
|
|
653
|
+
'+',
|
|
654
|
+
'%',
|
|
655
|
+
'*',
|
|
656
|
+
];
|
|
657
|
+
const set = [
|
|
658
|
+
100010100, 101001000, 101000100, 101000010, 100101000, 100100100,
|
|
659
|
+
100100010, 101010000, 100010010, 100001010, 110101000, 110100100,
|
|
660
|
+
110100010, 110010100, 110010010, 110001010, 101101000, 101100100,
|
|
661
|
+
101100010, 100110100, 100011010, 101011000, 101001100, 101000110,
|
|
662
|
+
100101100, 100010110, 110110100, 110110010, 110101100, 110100110,
|
|
663
|
+
110010110, 110011010, 101101100, 101100110, 100110110, 100111010,
|
|
664
|
+
100101110, 111010100, 111010010, 111001010, 111010110, 100110010,
|
|
665
|
+
111011010, 101011110,
|
|
666
|
+
];
|
|
667
|
+
|
|
668
|
+
for (let char of val) {
|
|
669
|
+
encoded += set[chars.indexOf(char)] + '0';
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
encoded = encoded.slice(0, -1);
|
|
673
|
+
|
|
674
|
+
return encoded;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* Encodes data in MSI format
|
|
679
|
+
*/
|
|
680
|
+
_getEncodedMSI(val, mod) {
|
|
681
|
+
let encoded = '';
|
|
682
|
+
const sets = {
|
|
683
|
+
0: 100100100100,
|
|
684
|
+
1: 100100100110,
|
|
685
|
+
2: 100100110100,
|
|
686
|
+
3: 100100110110,
|
|
687
|
+
4: 100110100100,
|
|
688
|
+
5: 100110100110,
|
|
689
|
+
6: 100110110100,
|
|
690
|
+
7: 100110110110,
|
|
691
|
+
8: 110100100100,
|
|
692
|
+
9: 110100100110,
|
|
693
|
+
};
|
|
694
|
+
|
|
695
|
+
encoded += '110';
|
|
696
|
+
|
|
697
|
+
if (mod === '10') {
|
|
698
|
+
val += this._getMSIMod10(val);
|
|
699
|
+
}
|
|
700
|
+
else if (mod === '11') {
|
|
701
|
+
val += this._getMSIMod11(val);
|
|
702
|
+
}
|
|
703
|
+
else if (mod === '1010') {
|
|
704
|
+
val += this._getMSIMod10(val);
|
|
705
|
+
val += this._getMSIMod10(val);
|
|
706
|
+
}
|
|
707
|
+
else if (mod === '1110') {
|
|
708
|
+
val += this._getMSIMod11(val);
|
|
709
|
+
val += this._getMSIMod10(val);
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
for (let char of val) {
|
|
713
|
+
encoded += sets[char];
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
encoded += '1001';
|
|
717
|
+
|
|
718
|
+
return encoded;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* Encodes data in EAN format
|
|
723
|
+
*/
|
|
724
|
+
_getEncodedEAN(val, type) {
|
|
725
|
+
let encoded = '';
|
|
726
|
+
const table = [
|
|
727
|
+
[
|
|
728
|
+
'0001101',
|
|
729
|
+
'0011001',
|
|
730
|
+
'0010011',
|
|
731
|
+
'0111101',
|
|
732
|
+
'0100011',
|
|
733
|
+
'0110001',
|
|
734
|
+
'0101111',
|
|
735
|
+
'0111011',
|
|
736
|
+
'0110111',
|
|
737
|
+
'0001011',
|
|
738
|
+
],
|
|
739
|
+
[
|
|
740
|
+
'0100111',
|
|
741
|
+
'0110011',
|
|
742
|
+
'0011011',
|
|
743
|
+
'0100001',
|
|
744
|
+
'0011101',
|
|
745
|
+
'0111001',
|
|
746
|
+
'0000101',
|
|
747
|
+
'0010001',
|
|
748
|
+
'0001001',
|
|
749
|
+
'0010111',
|
|
750
|
+
],
|
|
751
|
+
[
|
|
752
|
+
'1110010',
|
|
753
|
+
'1100110',
|
|
754
|
+
'1101100',
|
|
755
|
+
'1000010',
|
|
756
|
+
'1011100',
|
|
757
|
+
'1001110',
|
|
758
|
+
'1010000',
|
|
759
|
+
'1000100',
|
|
760
|
+
'1001000',
|
|
761
|
+
'1110100',
|
|
762
|
+
],
|
|
763
|
+
];
|
|
764
|
+
const ean13_set = [
|
|
765
|
+
'000000',
|
|
766
|
+
'001011',
|
|
767
|
+
'001101',
|
|
768
|
+
'001110',
|
|
769
|
+
'010011',
|
|
770
|
+
'011001',
|
|
771
|
+
'011100',
|
|
772
|
+
'010101',
|
|
773
|
+
'010110',
|
|
774
|
+
'011010',
|
|
775
|
+
];
|
|
776
|
+
|
|
777
|
+
//Compute check digit and add it to the string if it doesn't exist
|
|
778
|
+
if (val.length === 12 || val.length === 7) {
|
|
779
|
+
let intSumEven = 0,
|
|
780
|
+
intSumOdd = 0,
|
|
781
|
+
intCheck,
|
|
782
|
+
stopper;
|
|
783
|
+
|
|
784
|
+
if (val.length === 7) {
|
|
785
|
+
stopper = 5;
|
|
786
|
+
}
|
|
787
|
+
else {
|
|
788
|
+
stopper = 12;
|
|
789
|
+
}
|
|
790
|
+
for (let i = 0; i < stopper; i += 2) {
|
|
791
|
+
intSumEven += parseInt(val[i]);
|
|
792
|
+
intSumOdd += parseInt(val[i + 1]);
|
|
793
|
+
}
|
|
794
|
+
intCheck = (intSumOdd * 3 + intSumEven) % 10;
|
|
795
|
+
if (intCheck > 0) {
|
|
796
|
+
intCheck = 10 - intCheck;
|
|
797
|
+
}
|
|
798
|
+
val += intCheck;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
if (type === '13') {
|
|
802
|
+
encoded += '101';
|
|
803
|
+
let structure = ean13_set[val[0]];
|
|
804
|
+
for (let i = 1; i < 7; i++) {
|
|
805
|
+
encoded += table[structure[i - 1]][val[i]];
|
|
806
|
+
}
|
|
807
|
+
encoded += '01010';
|
|
808
|
+
for (let i = 0; i < 6; i++) {
|
|
809
|
+
encoded += table[2][val[i + 7]];
|
|
810
|
+
}
|
|
811
|
+
encoded += '101';
|
|
812
|
+
}
|
|
813
|
+
else if (type === '8') {
|
|
814
|
+
encoded += '101';
|
|
815
|
+
for (let i = 0; i < 4; i++) {
|
|
816
|
+
encoded += table[0][val[i]];
|
|
817
|
+
}
|
|
818
|
+
encoded += '01010';
|
|
819
|
+
for (let i = 0; i < 4; i++) {
|
|
820
|
+
encoded += table[2][val[i + 4]];
|
|
821
|
+
}
|
|
822
|
+
encoded += '101';
|
|
823
|
+
}
|
|
824
|
+
return encoded;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
/**
|
|
828
|
+
* Gets the mod10 value of the MSI format
|
|
829
|
+
*/
|
|
830
|
+
_getMSIMod10(val) {
|
|
831
|
+
let sum = 0;
|
|
832
|
+
for (var i = 0; i < val.length; i++) {
|
|
833
|
+
var n = parseInt(val[i]);
|
|
834
|
+
if ((i + val.length) % 2 === 0) {
|
|
835
|
+
sum += n;
|
|
836
|
+
}
|
|
837
|
+
else {
|
|
838
|
+
sum += ((n * 2) % 10) + Math.floor((n * 2) / 10);
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
return (10 - (sum % 10)) % 10;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* Gets the mod11 value of the MSI format
|
|
846
|
+
*/
|
|
847
|
+
_getMSIMod11(val) {
|
|
848
|
+
let sum = 0;
|
|
849
|
+
var weights = [2, 3, 4, 5, 6, 7];
|
|
850
|
+
for (var i = 0; i < val.length; i++) {
|
|
851
|
+
var n = parseInt(val[val.length - 1 - i]);
|
|
852
|
+
sum += weights[i % weights.length] * n;
|
|
853
|
+
}
|
|
854
|
+
return (11 - (sum % 11)) % 11;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
/**
|
|
858
|
+
* Encodes data in code128 format
|
|
859
|
+
*/
|
|
860
|
+
_getEncodedCode128(val, type) {
|
|
861
|
+
let encoded = '',
|
|
862
|
+
elements = [],
|
|
863
|
+
checkSum = 0,
|
|
864
|
+
start;
|
|
865
|
+
const table = [
|
|
866
|
+
[' ', ' ', '00', '11011001100'],
|
|
867
|
+
['!', '!', '01', '11001101100'],
|
|
868
|
+
['"', '"', '02', '11001100110'],
|
|
869
|
+
['#', '#', '03', '10010011000'],
|
|
870
|
+
['$', '$', '04', '10010001100'],
|
|
871
|
+
['%', '%', '05', '10001001100'],
|
|
872
|
+
['&', '&', '06', '10011001000'],
|
|
873
|
+
['\'', '\'', '07', '10011000100'],
|
|
874
|
+
['(', '(', '08', '10001100100'],
|
|
875
|
+
[')', ')', '09', '11001001000'],
|
|
876
|
+
['*', '*', '10', '11001000100'],
|
|
877
|
+
['+', '+', '11', '11000100100'],
|
|
878
|
+
[',', ',', '12', '10110011100'],
|
|
879
|
+
['-', '-', '13', '10011011100'],
|
|
880
|
+
['.', '.', '14', '10011001110'],
|
|
881
|
+
['/', '/', '15', '10111001100'],
|
|
882
|
+
['0', '0', '16', '10011101100'],
|
|
883
|
+
['1', '1', '17', '10011100110'],
|
|
884
|
+
['2', '2', '18', '11001110010'],
|
|
885
|
+
['3', '3', '19', '11001011100'],
|
|
886
|
+
['4', '4', '20', '11001001110'],
|
|
887
|
+
['5', '5', '21', '11011100100'],
|
|
888
|
+
['6', '6', '22', '11001110100'],
|
|
889
|
+
['7', '7', '23', '11101101110'],
|
|
890
|
+
['8', '8', '24', '11101001100'],
|
|
891
|
+
['9', '9', '25', '11100101100'],
|
|
892
|
+
[':', ':', '26', '11100100110'],
|
|
893
|
+
[';', ';', '27', '11101100100'],
|
|
894
|
+
['<', '<', '28', '11100110100'],
|
|
895
|
+
['=', '=', '29', '11100110010'],
|
|
896
|
+
['>', '>', '30', '11011011000'],
|
|
897
|
+
['?', '?', '31', '11011000110'],
|
|
898
|
+
['@', '@', '32', '11000110110'],
|
|
899
|
+
['A', 'A', '33', '10100011000'],
|
|
900
|
+
['B', 'B', '34', '10001011000'],
|
|
901
|
+
['C', 'C', '35', '10001000110'],
|
|
902
|
+
['D', 'D', '36', '10110001000'],
|
|
903
|
+
['E', 'E', '37', '10001101000'],
|
|
904
|
+
['F', 'F', '38', '10001100010'],
|
|
905
|
+
['G', 'G', '39', '11010001000'],
|
|
906
|
+
['H', 'H', '40', '11000101000'],
|
|
907
|
+
['I', 'I', '41', '11000100010'],
|
|
908
|
+
['J', 'J', '42', '10110111000'],
|
|
909
|
+
['K', 'K', '43', '10110001110'],
|
|
910
|
+
['L', 'L', '44', '10001101110'],
|
|
911
|
+
['M', 'M', '45', '10111011000'],
|
|
912
|
+
['N', 'N', '46', '10111000110'],
|
|
913
|
+
['O', 'O', '47', '10001110110'],
|
|
914
|
+
['P', 'P', '48', '11101110110'],
|
|
915
|
+
['Q', 'Q', '49', '11010001110'],
|
|
916
|
+
['R', 'R', '50', '11000101110'],
|
|
917
|
+
['S', 'S', '51', '11011101000'],
|
|
918
|
+
['T', 'T', '52', '11011100010'],
|
|
919
|
+
['U', 'U', '53', '11011101110'],
|
|
920
|
+
['V', 'V', '54', '11101011000'],
|
|
921
|
+
['W', 'W', '55', '11101000110'],
|
|
922
|
+
['X', 'X', '56', '11100010110'],
|
|
923
|
+
['Y', 'Y', '57', '11101101000'],
|
|
924
|
+
['Z', 'Z', '58', '11101100010'],
|
|
925
|
+
['[', '[', '59', '11100011010'],
|
|
926
|
+
['\\', '\\', '60', '11101111010'],
|
|
927
|
+
[']', ']', '61', '11001000010'],
|
|
928
|
+
['^', '^', '62', '11110001010'],
|
|
929
|
+
['_', '_', '63', '10100110000'],
|
|
930
|
+
['NUL', '`', '64', '10100001100'],
|
|
931
|
+
['SOH', 'a', '65', '10010110000'],
|
|
932
|
+
['STX', 'b', '66', '10010000110'],
|
|
933
|
+
['ETX', 'c', '67', '10000101100'],
|
|
934
|
+
['EOT', 'd', '68', '10000100110'],
|
|
935
|
+
['ENQ', 'e', '69', '10110010000'],
|
|
936
|
+
['ACK', 'f', '70', '10110000100'],
|
|
937
|
+
['BEL', 'g', '71', '10011010000'],
|
|
938
|
+
['BS', 'h', '72', '10011000010'],
|
|
939
|
+
['HT', 'i', '73', '10000110100'],
|
|
940
|
+
['LF', 'j', '74', '10000110010'],
|
|
941
|
+
['VT', 'k', '75', '11000010010'],
|
|
942
|
+
['FF', 'l', '76', '11001010000'],
|
|
943
|
+
['CR', 'm', '77', '11110111010'],
|
|
944
|
+
['SO', 'n', '78', '11000010100'],
|
|
945
|
+
['SI', 'o', '79', '10001111010'],
|
|
946
|
+
['DLE', 'p', '80', '10100111100'],
|
|
947
|
+
['DC1', 'q', '81', '10010111100'],
|
|
948
|
+
['DC2', 'r', '82', '10010011110'],
|
|
949
|
+
['DC3', 's', '83', '10111100100'],
|
|
950
|
+
['DC4', 't', '84', '10011110100'],
|
|
951
|
+
['NAK', 'u', '85', '10011110010'],
|
|
952
|
+
['SYN', 'v', '86', '11110100100'],
|
|
953
|
+
['ETB', 'w', '87', '11110010100'],
|
|
954
|
+
['CAN', 'x', '88', '11110010010'],
|
|
955
|
+
['EM', 'y', '89', '11011011110'],
|
|
956
|
+
['SUB', 'z', '90', '11011110110'],
|
|
957
|
+
['ESC', '[', '91', '11110110110'],
|
|
958
|
+
['FS', '|', '92', '10101111000'],
|
|
959
|
+
['GS', ']', '93', '10100011110'],
|
|
960
|
+
['RS', '~', '94', '10001011110'],
|
|
961
|
+
['US', 'DEL', '95', '10111101000'],
|
|
962
|
+
['FNC3', 'FNC3', '96', '10111100010'],
|
|
963
|
+
['FNC2', 'FNC2', '97', '11110101000'],
|
|
964
|
+
['SHIFT', 'SHIFT', '98', '11110100010'],
|
|
965
|
+
['CODEC', 'CODEC', '99', '10111011110'],
|
|
966
|
+
['CODEB', 'FNC4', 'CODEB', '10111101110'],
|
|
967
|
+
['FNC4', 'CODEA', 'CODEA', '11101011110'],
|
|
968
|
+
['FNC1', 'FNC1', 'FNC1', '11110101110'],
|
|
969
|
+
['StartA', 'StartA', 'StartA', '11010000100'],
|
|
970
|
+
['StartB', 'StartB', 'StartB', '11010010000'],
|
|
971
|
+
['StartC', 'StartC', 'StartC', '11010011100'],
|
|
972
|
+
['Stop', 'Stop', 'Stop', '1100011101011'],
|
|
973
|
+
];
|
|
974
|
+
if (type === 'A') {
|
|
975
|
+
start = 103;
|
|
976
|
+
for (const [i, char] of val.split('').entries()) {
|
|
977
|
+
let element = table.find((x) => x[0] === char);
|
|
978
|
+
if (element) {
|
|
979
|
+
elements.push(element);
|
|
980
|
+
checkSum += i * element.length;
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
else if (type === 'B') {
|
|
985
|
+
start = 104;
|
|
986
|
+
for (const [i, char] of val.split('').entries()) {
|
|
987
|
+
let element = table.find((x) => x[1] === char);
|
|
988
|
+
if (element) {
|
|
989
|
+
elements.push(element);
|
|
990
|
+
checkSum += i * element.length;
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
else if (type === 'C') {
|
|
995
|
+
start = 105;
|
|
996
|
+
for (let i = 0; i < val.length - 1; i += 2) {
|
|
997
|
+
let substr = val.substring(i, 2);
|
|
998
|
+
let element = table.find((x) => x[2] === substr);
|
|
999
|
+
if (element) {
|
|
1000
|
+
elements.push(element);
|
|
1001
|
+
checkSum += substr * element.length;
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
checkSum += start;
|
|
1007
|
+
elements.push(table[checkSum % 103]);
|
|
1008
|
+
elements.unshift(table[start]);
|
|
1009
|
+
elements.push(table[106]);
|
|
1010
|
+
elements.forEach((el) => (encoded += el[3]));
|
|
1011
|
+
|
|
1012
|
+
return encoded;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
/**
|
|
1016
|
+
* Gets the Base64 String of the barcode
|
|
1017
|
+
*
|
|
1018
|
+
* @param {String} format Sets the dataURL format of the string. Allowed values are 'svg', 'png', 'jpg'
|
|
1019
|
+
*/
|
|
1020
|
+
getDataURL(format) {
|
|
1021
|
+
const that = this;
|
|
1022
|
+
if (format === 'svg') {
|
|
1023
|
+
if (that.renderAs !== 'svg') {
|
|
1024
|
+
that._generateCode('svg', true);
|
|
1025
|
+
}
|
|
1026
|
+
let svg = that.host.querySelector('svg');
|
|
1027
|
+
let data = new XMLSerializer().serializeToString(svg);
|
|
1028
|
+
let svgBlob = new Blob([data], {
|
|
1029
|
+
type: 'image/svg+xml;charset=utf-8',
|
|
1030
|
+
});
|
|
1031
|
+
const url = URL.createObjectURL(svgBlob);
|
|
1032
|
+
return url;
|
|
1033
|
+
}
|
|
1034
|
+
else if (format === 'png' || format === 'jpg') {
|
|
1035
|
+
let file_format = format === 'png' ? 'png' : 'jpeg';
|
|
1036
|
+
if (that.renderAs !== 'canvas') {
|
|
1037
|
+
that._generateCode('canvas', true);
|
|
1038
|
+
}
|
|
1039
|
+
let canvas = that.host.querySelector('canvas');
|
|
1040
|
+
const url = canvas.toDataURL(`image/${file_format}`);
|
|
1041
|
+
return url;
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
/**
|
|
1046
|
+
* Gets the Base64 String of the barcode asynchronously
|
|
1047
|
+
*
|
|
1048
|
+
* @param {String} format Sets the dataURL format of the string. Allowed values are 'svg', 'png', 'jpg'
|
|
1049
|
+
*/
|
|
1050
|
+
getDataURLAsync(format) {
|
|
1051
|
+
const that = this;
|
|
1052
|
+
return new Promise((resolve, reject) => {
|
|
1053
|
+
let url = that.getDataURL(format);
|
|
1054
|
+
if (url) {
|
|
1055
|
+
resolve(url);
|
|
1056
|
+
}
|
|
1057
|
+
else {
|
|
1058
|
+
reject();
|
|
1059
|
+
}
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
/**
|
|
1064
|
+
* Export the barcode to a file
|
|
1065
|
+
*
|
|
1066
|
+
* @param {String} format Sets the export format of the barcode. Allowed values are 'svg', 'png', 'jpg'
|
|
1067
|
+
* @param {String} fileName Sets the name of the exported file
|
|
1068
|
+
*/
|
|
1069
|
+
export(format = 'png', fileName = 'barcode') {
|
|
1070
|
+
const that = this;
|
|
1071
|
+
that.getDataURLAsync(format).then((url) => {
|
|
1072
|
+
let a = document.createElement('a');
|
|
1073
|
+
|
|
1074
|
+
a.setAttribute('download', `${fileName}.${format}`);
|
|
1075
|
+
a.setAttribute('href', url);
|
|
1076
|
+
a.setAttribute('target', '_blank');
|
|
1077
|
+
|
|
1078
|
+
a.click();
|
|
1079
|
+
});
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
/**
|
|
1083
|
+
* Called when a property is changed.
|
|
1084
|
+
*/
|
|
1085
|
+
propertyChangedHandler(propertyName, oldValue, newValue) {
|
|
1086
|
+
const that = this;
|
|
1087
|
+
|
|
1088
|
+
that.refresh();
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
ready() {
|
|
1092
|
+
const that = this;
|
|
1093
|
+
this._generateCode(that.renderAs);
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
14
1096
|
|
|
15
|
-
!function(e){e.jqx.jqxWidget("jqxBarcode","",{}),e.extend(e.jqx._jqxBarcode.prototype,{defineInstance:function(){var t={value:"12345",type:"codabar",backgroundColor:"white",lineWidth:4,lineHeight:50,lineColor:"black",displayLabel:!0,labelPosition:"bottom",labelFontSize:14,labelMarginTop:5,labelMarginBottom:5,labelColor:"black",labelFont:"monospace",renderAs:"svg"};return e.extend(!0,this,t),t},createInstance:function(e){var t=new Barcode(this.element);t.value=this.value,t.type=this.type,t.backgroundColor=this.backgroundColor,t.lineWidth=this.lineWidth,t.lineHeight=this.lineHeight,t.lineColor=this.lineColor,t.displayLabel=this.displayLabel,t.labelPosition=this.labelPosition,t.labelFontSize=this.labelFontSize,t.labelMarginTop=this.labelMarginTop,t.labelMarginBottom=this.labelMarginBottom,t.labelColor=this.labelColor,t.labelFont=this.labelFont,t.renderAs=this.renderAs,this.element.innerHTML=t.template(),this.barcode=t,t.refresh()},getDataURL:function(e){return this.barcode.getDataURL(e)},export:function(e,t){this.barcode.export(e,t)},isValid:function(){return this.barcode.isValid(!1)},propertyChangedHandler:function(e,t,a,l){e.barcode.refresh()}})}(jqxBaseFramework);class Barcode{constructor(e){this.host=e}static get properties(){return{value:{type:"string",value:""},type:{value:"codabar",type:"string",allowedValues:["pharmacode","codabar","code128a","code128b","code128c","msi","msi10","msi11","msi1010","msi1110","ean13","ean8","code39","code93"]},backgroundColor:{value:"white",type:"string"},lineWidth:{value:4,type:"number"},lineHeight:{value:50,type:"number"},lineColor:{value:"black",type:"string"},displayLabel:{value:!0,type:"boolean"},labelPosition:{value:"bottom",type:"string",allowedValues:["top","bottom"]},labelFontSize:{value:14,type:"number"},labelMarginTop:{value:5,type:"number"},labelMarginBottom:{value:5,type:"number"},labelColor:{value:"black",type:"string"},labelFont:{value:"monospace",type:"string"},renderAs:{value:"svg",type:"string",allowedValues:["svg","canvas"]}}}template(){return'<div class="jqx-barcode-container"></div>'}refresh(){this._generateCode(this.renderAs)}_generateCode(e,t=!1){const a=this,l=this._getEncoded(a.type,a.value),i=l.length*a.lineWidth,r=a.lineHeight+a.displayLabel*(a.labelMarginTop+a.labelMarginBottom+a.labelFontSize);let o,n=0,s=0;if(a.isValid(),"svg"===e)(o=document.createElementNS("http://www.w3.org/2000/svg","svg")).setAttribute("width",i),o.setAttribute("height",r),o.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:svg","http://www.w3.org/2000/svg"),o.style.backgroundColor=a.backgroundColor;else if("canvas"===e){(o=document.createElement("canvas")).setAttribute("width",i),o.setAttribute("height",r);let e=o.getContext("2d");e.fillStyle=a.backgroundColor,e.fillRect(0,0,i,r)}t&&(o.style.display="none"),o.classList.add("jqx-barcode"),a.host.firstChild.appendChild(o),a.displayLabel&&"top"===a.labelPosition&&(s+=a.labelMarginTop+a.labelFontSize,"svg"===e?a._drawTextSVG(i/2,s,o):a._drawTextCanvas(i/2,s,o),s+=a.labelMarginBottom);for(let t of l)"1"===t?"svg"===e?a._drawStepSVG(a.lineColor,1,n,s,o):a._drawStepCanvas(a.lineColor,1,n,s,o):"svg"===e?a._drawStepSVG("white",0,n,s,o):a._drawStepCanvas("white",0,n,s,o),n+=a.lineWidth;a.displayLabel&&"bottom"===a.labelPosition&&(s+=a.lineHeight+a.labelMarginTop+a.labelFontSize,"svg"===e?a._drawTextSVG(i/2,s,o):a._drawTextCanvas(i/2,s,o)),2===a.host.firstChild.children.length&&"none"!==a.host.firstChild.children[1].style.display&&a.host.firstChild.removeChild(a.host.firstChild.firstChild)}_getEncoded(e,t){const a=this;let l;switch(e){case"pharmacode":l=a._getEncodedPharmacode(t);break;case"codabar":l=a._getEncodedCodabar(t);break;case"code128a":l=a._getEncodedCode128(t,"A");break;case"code128b":l=a._getEncodedCode128(t,"B");break;case"code128c":l=a._getEncodedCode128(a.value,"C");break;case"msi":l=a._getEncodedMSI(a.value,"");break;case"msi10":l=a._getEncodedMSI(a.value,"10");break;case"msi11":l=a._getEncodedMSI(a.value,"11");break;case"msi1010":case"msi1110":l=a._getEncodedMSI(a.value,"1010");break;case"ean13":l=a._getEncodedEAN(a.value,"13");break;case"ean8":l=a._getEncodedEAN(a.value,"8");break;case"code39":l=a._getEncodedCode39(a.value);break;case"code93":l=a._getEncodedCode93(a.value)}return l}isValid(e=!1){const t=this.type,a=this.value;let l=/[^@!(一-龠)(ぁ-ゔ)(ァ-ヴー)\d0-9A-Z \$\%\*\+\-\.\/\:\=\?\^\{\|\}\~]/gm,i=!0,r=!0,o=[];if(!e)switch(t){case"pharmacode":l=/[^\d]/gm,r=a.length>=1&&a.length<=6,i=+a>=3&&+a<=131070;break;case"codabar":l=/[^ABCD\d\$-]/gm,i=/^[A-D]\d+[A-D]$/gm.test(a);break;case"code128a":l=/[^\x20-\x5F]/gm;break;case"code128b":l=/[^\x20-\x7F]/gm;break;case"code128c":l=/[^\d]/gm;break;case"msi":case"msi10":case"msi11":case"msi1010":case"msi1110":l=/[^\d]/gm;break;case"ean13":l=/[^\d]/gm,r=13===a.length||12===a.length;break;case"ean8":l=/[^\d]/gm,r=7===a.length||8===a.length;break;case"code39":l=/[^\w\*.]/gm,i=/^\*\*$/gm.test(a);break;case"code93":l=/[^\w\*.\-\* \$+\/%]/gm,i=/^\*\*$/gm.test(a)}return o=a.match(l),!(!i||o||!r)||(this.host.dispatchEvent(new CustomEvent("invalid",{detail:{value:a,invalidCharacters:o,patternValidity:i,lengthValidity:r}})),!1)}_drawTextSVG(e,t,a){let l=document.createElementNS("http://www.w3.org/2000/svg","text");l.setAttribute("x",e),l.setAttribute("y",t),l.setAttribute("text-anchor","middle"),l.classList.add("jqx-barcode-label"),l.style.fill=this.labelColor,l.style.fontFamily=this.labelFont,l.style.fontSize=this.labelFontSize+"px",l.textContent=this.value,a.appendChild(l)}_drawTextCanvas(e,t,a){let l=a.getContext("2d");l.font=`${this.labelFontSize}px ${this.labelFont}`,l.fillStyle=this.labelColor,l.textAlign="center",l.fillText(this.value,e,t)}_drawStepSVG(e,t,a,l,i){const r=this;r.squareWidth&&(r.lineWidth=r.squareWidth,r.lineHeight=r.squareWidth);let o=document.createElementNS("http://www.w3.org/2000/svg","rect");o.setAttribute("x",a),o.setAttribute("y",l),o.setAttribute("width",r.lineWidth),o.setAttribute("height",r.lineHeight),o.setAttribute("fill-opacity",t),o.style.fill=e,i.appendChild(o)}_drawStepCanvas(e,t,a,l,i){const r=this;r.squareWidth&&(r.lineWidth=r.squareWidth,r.lineHeight=r.squareWidth);let o=i.getContext("2d");o.beginPath(),o.globalAlpha=t,o.strokeStyle=e,o.fillStyle=e,o.rect(a,l,r.lineWidth,r.lineHeight),o.fill()}_getEncodedPharmacode(e){let t="";for(;0!==e;)e%2==0?(t="11100"+t,e=(e-2)/2):(t="100"+t,e=(e-1)/2);return t=t.slice(0,-2)}_getEncodedCodabar(e){let t="";const a={0:1010100110,1:1010110010,2:1010010110,3:1100101010,4:1011010010,5:1101010010,6:1001010110,7:1001011010,8:1001101010,9:1101001010,"-":1010011010,$:1011001010,":":11010110110,"/":11011010110,".":11011011010,"+":10110110110,A:10110010010,B:10010010110,C:10100100110,D:10100110010};for(let l of e)t+=a[l];return t=t.slice(0,-1)}_getEncodedCode39(e){let t="";const a=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","."," ","$","/","+","%","*"],l=[20957,29783,23639,30485,20951,29813,23669,20855,29789,23645,29975,23831,30533,22295,30149,24005,21623,29981,23837,22301,30023,23879,30545,22343,30161,24017,21959,30065,23921,22385,29015,18263,29141,17879,29045,18293,17783,29021,18269,17477,17489,17681,20753,35770];for(let i of e)t+=l[a.indexOf(i)].toString(2)+"0";return t=t.slice(0,-1)}_getEncodedCode93(e){let t="";const a=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","."," ","$","/","+","%","*"],l=[100010100,101001e3,101000100,101000010,100101e3,100100100,100100010,10101e4,100010010,100001010,110101e3,110100100,110100010,110010100,110010010,110001010,101101e3,101100100,101100010,100110100,100011010,101011e3,101001100,101000110,100101100,100010110,110110100,110110010,110101100,110100110,110010110,110011010,101101100,101100110,100110110,100111010,100101110,111010100,111010010,111001010,111010110,100110010,111011010,101011110];for(let i of e)t+=l[a.indexOf(i)]+"0";return t=t.slice(0,-1)}_getEncodedMSI(e,t){let a="";const l={0:100100100100,1:100100100110,2:100100110100,3:100100110110,4:100110100100,5:100110100110,6:100110110100,7:100110110110,8:110100100100,9:110100100110};a+="110","10"===t?e+=this._getMSIMod10(e):"11"===t?e+=this._getMSIMod11(e):"1010"===t?(e+=this._getMSIMod10(e),e+=this._getMSIMod10(e)):"1110"===t&&(e+=this._getMSIMod11(e),e+=this._getMSIMod10(e));for(let t of e)a+=l[t];return a+="1001"}_getEncodedEAN(e,t){let a="";const l=[["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"],["1110010","1100110","1101100","1000010","1011100","1001110","1010000","1000100","1001000","1110100"]],i=["000000","001011","001101","001110","010011","011001","011100","010101","010110","011010"];if(12===e.length||7===e.length){let t,a,l=0,i=0;a=7===e.length?5:12;for(let t=0;t<a;t+=2)l+=parseInt(e[t]),i+=parseInt(e[t+1]);(t=(3*i+l)%10)>0&&(t=10-t),e+=t}if("13"===t){a+="101";let t=i[e[0]];for(let i=1;i<7;i++)a+=l[t[i-1]][e[i]];a+="01010";for(let t=0;t<6;t++)a+=l[2][e[t+7]];a+="101"}else if("8"===t){a+="101";for(let t=0;t<4;t++)a+=l[0][e[t]];a+="01010";for(let t=0;t<4;t++)a+=l[2][e[t+4]];a+="101"}return a}_getMSIMod10(e){let t=0;for(var a=0;a<e.length;a++){var l=parseInt(e[a]);(a+e.length)%2==0?t+=l:t+=2*l%10+Math.floor(2*l/10)}return(10-t%10)%10}_getMSIMod11(e){let t=0;for(var a=[2,3,4,5,6,7],l=0;l<e.length;l++){var i=parseInt(e[e.length-1-l]);t+=a[l%a.length]*i}return(11-t%11)%11}_getEncodedCode128(e,t){let a,l="",i=[],r=0;const o=[[" "," ","00","11011001100"],["!","!","01","11001101100"],['"','"',"02","11001100110"],["#","#","03","10010011000"],["$","$","04","10010001100"],["%","%","05","10001001100"],["&","&","06","10011001000"],["'","'","07","10011000100"],["(","(","08","10001100100"],[")",")","09","11001001000"],["*","*","10","11001000100"],["+","+","11","11000100100"],[",",",","12","10110011100"],["-","-","13","10011011100"],[".",".","14","10011001110"],["/","/","15","10111001100"],["0","0","16","10011101100"],["1","1","17","10011100110"],["2","2","18","11001110010"],["3","3","19","11001011100"],["4","4","20","11001001110"],["5","5","21","11011100100"],["6","6","22","11001110100"],["7","7","23","11101101110"],["8","8","24","11101001100"],["9","9","25","11100101100"],[":",":","26","11100100110"],[";",";","27","11101100100"],["<","<","28","11100110100"],["=","=","29","11100110010"],[">",">","30","11011011000"],["?","?","31","11011000110"],["@","@","32","11000110110"],["A","A","33","10100011000"],["B","B","34","10001011000"],["C","C","35","10001000110"],["D","D","36","10110001000"],["E","E","37","10001101000"],["F","F","38","10001100010"],["G","G","39","11010001000"],["H","H","40","11000101000"],["I","I","41","11000100010"],["J","J","42","10110111000"],["K","K","43","10110001110"],["L","L","44","10001101110"],["M","M","45","10111011000"],["N","N","46","10111000110"],["O","O","47","10001110110"],["P","P","48","11101110110"],["Q","Q","49","11010001110"],["R","R","50","11000101110"],["S","S","51","11011101000"],["T","T","52","11011100010"],["U","U","53","11011101110"],["V","V","54","11101011000"],["W","W","55","11101000110"],["X","X","56","11100010110"],["Y","Y","57","11101101000"],["Z","Z","58","11101100010"],["[","[","59","11100011010"],["\\","\\","60","11101111010"],["]","]","61","11001000010"],["^","^","62","11110001010"],["_","_","63","10100110000"],["NUL","`","64","10100001100"],["SOH","a","65","10010110000"],["STX","b","66","10010000110"],["ETX","c","67","10000101100"],["EOT","d","68","10000100110"],["ENQ","e","69","10110010000"],["ACK","f","70","10110000100"],["BEL","g","71","10011010000"],["BS","h","72","10011000010"],["HT","i","73","10000110100"],["LF","j","74","10000110010"],["VT","k","75","11000010010"],["FF","l","76","11001010000"],["CR","m","77","11110111010"],["SO","n","78","11000010100"],["SI","o","79","10001111010"],["DLE","p","80","10100111100"],["DC1","q","81","10010111100"],["DC2","r","82","10010011110"],["DC3","s","83","10111100100"],["DC4","t","84","10011110100"],["NAK","u","85","10011110010"],["SYN","v","86","11110100100"],["ETB","w","87","11110010100"],["CAN","x","88","11110010010"],["EM","y","89","11011011110"],["SUB","z","90","11011110110"],["ESC","[","91","11110110110"],["FS","|","92","10101111000"],["GS","]","93","10100011110"],["RS","~","94","10001011110"],["US","DEL","95","10111101000"],["FNC3","FNC3","96","10111100010"],["FNC2","FNC2","97","11110101000"],["SHIFT","SHIFT","98","11110100010"],["CODEC","CODEC","99","10111011110"],["CODEB","FNC4","CODEB","10111101110"],["FNC4","CODEA","CODEA","11101011110"],["FNC1","FNC1","FNC1","11110101110"],["StartA","StartA","StartA","11010000100"],["StartB","StartB","StartB","11010010000"],["StartC","StartC","StartC","11010011100"],["Stop","Stop","Stop","1100011101011"]];if("A"===t){a=103;for(const[t,a]of e.split("").entries()){let e=o.find(e=>e[0]===a);e&&(i.push(e),r+=t*e.length)}}else if("B"===t){a=104;for(const[t,a]of e.split("").entries()){let e=o.find(e=>e[1]===a);e&&(i.push(e),r+=t*e.length)}}else if("C"===t){a=105;for(let t=0;t<e.length-1;t+=2){let a=e.substring(t,2),l=o.find(e=>e[2]===a);l&&(i.push(l),r+=a*l.length)}}return r+=a,i.push(o[r%103]),i.unshift(o[a]),i.push(o[106]),i.forEach(e=>l+=e[3]),l}getDataURL(e){const t=this;if("svg"===e){"svg"!==t.renderAs&&t._generateCode("svg",!0);let e=t.host.querySelector("svg"),a=(new XMLSerializer).serializeToString(e),l=new Blob([a],{type:"image/svg+xml;charset=utf-8"});return URL.createObjectURL(l)}if("png"===e||"jpg"===e){let a="png"===e?"png":"jpeg";return"canvas"!==t.renderAs&&t._generateCode("canvas",!0),t.host.querySelector("canvas").toDataURL(`image/${a}`)}}getDataURLAsync(e){const t=this;return new Promise((a,l)=>{let i=t.getDataURL(e);i?a(i):l()})}export(e="png",t="barcode"){this.getDataURLAsync(e).then(a=>{let l=document.createElement("a");l.setAttribute("download",`${t}.${e}`),l.setAttribute("href",a),l.setAttribute("target","_blank"),l.click()})}propertyChangedHandler(e,t,a){this.refresh()}ready(){this._generateCode(this.renderAs)}}
|
|
16
1097
|
|
|
17
1098
|
|
|
18
1099
|
|