yh-hiprint 2.3.1 → 2.3.2

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.
Files changed (61) hide show
  1. package/HiprintDesigner.vue +5 -5
  2. package/column-field.js +1 -3
  3. package/designer.vue +4 -4
  4. package/font-size.js +2 -3
  5. package/index.js +1 -2
  6. package/libs/hiprint.bundle.js +331 -335
  7. package/libs/jquery.js +1 -2
  8. package/libs/jsbarcode/JsBarcode.js +251 -0
  9. package/libs/jsbarcode/barcodes/Barcode.js +17 -0
  10. package/libs/jsbarcode/barcodes/CODE128/CODE128.js +167 -0
  11. package/libs/jsbarcode/barcodes/CODE128/CODE128A.js +42 -0
  12. package/libs/jsbarcode/barcodes/CODE128/CODE128B.js +42 -0
  13. package/libs/jsbarcode/barcodes/CODE128/CODE128C.js +42 -0
  14. package/libs/jsbarcode/barcodes/CODE128/CODE128_AUTO.js +41 -0
  15. package/libs/jsbarcode/barcodes/CODE128/auto.js +73 -0
  16. package/libs/jsbarcode/barcodes/CODE128/constants.js +54 -0
  17. package/libs/jsbarcode/barcodes/CODE128/index.js +29 -0
  18. package/libs/jsbarcode/barcodes/CODE39/index.js +105 -0
  19. package/libs/jsbarcode/barcodes/EAN_UPC/EAN.js +92 -0
  20. package/libs/jsbarcode/barcodes/EAN_UPC/EAN13.js +119 -0
  21. package/libs/jsbarcode/barcodes/EAN_UPC/EAN2.js +58 -0
  22. package/libs/jsbarcode/barcodes/EAN_UPC/EAN5.js +65 -0
  23. package/libs/jsbarcode/barcodes/EAN_UPC/EAN8.js +81 -0
  24. package/libs/jsbarcode/barcodes/EAN_UPC/UPC.js +165 -0
  25. package/libs/jsbarcode/barcodes/EAN_UPC/UPCE.js +185 -0
  26. package/libs/jsbarcode/barcodes/EAN_UPC/constants.js +30 -0
  27. package/libs/jsbarcode/barcodes/EAN_UPC/encoder.js +27 -0
  28. package/libs/jsbarcode/barcodes/EAN_UPC/index.js +39 -0
  29. package/libs/jsbarcode/barcodes/GenericBarcode/index.js +55 -0
  30. package/libs/jsbarcode/barcodes/ITF/ITF.js +69 -0
  31. package/libs/jsbarcode/barcodes/ITF/ITF14.js +55 -0
  32. package/libs/jsbarcode/barcodes/ITF/constants.js +9 -0
  33. package/libs/jsbarcode/barcodes/ITF/index.js +19 -0
  34. package/libs/jsbarcode/barcodes/MSI/MSI.js +74 -0
  35. package/libs/jsbarcode/barcodes/MSI/MSI10.js +33 -0
  36. package/libs/jsbarcode/barcodes/MSI/MSI1010.js +35 -0
  37. package/libs/jsbarcode/barcodes/MSI/MSI11.js +33 -0
  38. package/libs/jsbarcode/barcodes/MSI/MSI1110.js +35 -0
  39. package/libs/jsbarcode/barcodes/MSI/checksums.js +29 -0
  40. package/libs/jsbarcode/barcodes/MSI/index.js +34 -0
  41. package/libs/jsbarcode/barcodes/codabar/index.js +92 -0
  42. package/libs/jsbarcode/barcodes/index.js +33 -0
  43. package/libs/jsbarcode/barcodes/index.tmp.js +33 -0
  44. package/libs/jsbarcode/barcodes/pharmacode/index.js +73 -0
  45. package/libs/jsbarcode/exceptions/ErrorHandler.js +54 -0
  46. package/libs/jsbarcode/exceptions/exceptions.js +67 -0
  47. package/libs/jsbarcode/help/fixOptions.js +17 -0
  48. package/libs/jsbarcode/help/getOptionsFromElement.js +41 -0
  49. package/libs/jsbarcode/help/getRenderProperties.js +108 -0
  50. package/libs/jsbarcode/help/linearizeEncodings.js +27 -0
  51. package/libs/jsbarcode/help/merge.js +11 -0
  52. package/libs/jsbarcode/help/optionsFromStrings.js +27 -0
  53. package/libs/jsbarcode/options/defaults.js +28 -0
  54. package/libs/jsbarcode/renderers/canvas.js +158 -0
  55. package/libs/jsbarcode/renderers/index.js +21 -0
  56. package/libs/jsbarcode/renderers/object.js +30 -0
  57. package/libs/jsbarcode/renderers/shared.js +101 -0
  58. package/libs/jsbarcode/renderers/svg.js +189 -0
  59. package/libs/plugins/jquery.hiwprint.js +9 -10
  60. package/libs/plugins/jquery.minicolors.js +65 -66
  61. package/package.json +1 -3
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8
+
9
+ exports.checksum = checksum;
10
+
11
+ var _encoder = require("./encoder");
12
+
13
+ var _encoder2 = _interopRequireDefault(_encoder);
14
+
15
+ var _Barcode2 = require("../Barcode.js");
16
+
17
+ var _Barcode3 = _interopRequireDefault(_Barcode2);
18
+
19
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
+
21
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
22
+
23
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
24
+
25
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
26
+ // https://en.wikipedia.org/wiki/Universal_Product_Code#Encoding
27
+
28
+ var UPC = function (_Barcode) {
29
+ _inherits(UPC, _Barcode);
30
+
31
+ function UPC(data, options) {
32
+ _classCallCheck(this, UPC);
33
+
34
+ // Add checksum if it does not exist
35
+ if (data.search(/^[0-9]{11}$/) !== -1) {
36
+ data += checksum(data);
37
+ }
38
+
39
+ var _this = _possibleConstructorReturn(this, (UPC.__proto__ || Object.getPrototypeOf(UPC)).call(this, data, options));
40
+
41
+ _this.displayValue = options.displayValue;
42
+
43
+ // Make sure the font is not bigger than the space between the guard bars
44
+ if (options.fontSize > options.width * 10) {
45
+ _this.fontSize = options.width * 10;
46
+ } else {
47
+ _this.fontSize = options.fontSize;
48
+ }
49
+
50
+ // Make the guard bars go down half the way of the text
51
+ _this.guardHeight = options.height + _this.fontSize / 2 + options.textMargin;
52
+ return _this;
53
+ }
54
+
55
+ _createClass(UPC, [{
56
+ key: "valid",
57
+ value: function valid() {
58
+ return this.data.search(/^[0-9]{12}$/) !== -1 && this.data[11] == checksum(this.data);
59
+ }
60
+ }, {
61
+ key: "encode",
62
+ value: function encode() {
63
+ if (this.options.flat) {
64
+ return this.flatEncoding();
65
+ } else {
66
+ return this.guardedEncoding();
67
+ }
68
+ }
69
+ }, {
70
+ key: "flatEncoding",
71
+ value: function flatEncoding() {
72
+ var result = "";
73
+
74
+ result += "101";
75
+ result += (0, _encoder2.default)(this.data.substr(0, 6), "LLLLLL");
76
+ result += "01010";
77
+ result += (0, _encoder2.default)(this.data.substr(6, 6), "RRRRRR");
78
+ result += "101";
79
+
80
+ return {
81
+ data: result,
82
+ text: this.text
83
+ };
84
+ }
85
+ }, {
86
+ key: "guardedEncoding",
87
+ value: function guardedEncoding() {
88
+ var result = [];
89
+
90
+ // Add the first digit
91
+ if (this.displayValue) {
92
+ result.push({
93
+ data: "00000000",
94
+ text: this.text.substr(0, 1),
95
+ options: { textAlign: "left", fontSize: this.fontSize }
96
+ });
97
+ }
98
+
99
+ // Add the guard bars
100
+ result.push({
101
+ data: "101" + (0, _encoder2.default)(this.data[0], "L"),
102
+ options: { height: this.guardHeight }
103
+ });
104
+
105
+ // Add the left side
106
+ result.push({
107
+ data: (0, _encoder2.default)(this.data.substr(1, 5), "LLLLL"),
108
+ text: this.text.substr(1, 5),
109
+ options: { fontSize: this.fontSize }
110
+ });
111
+
112
+ // Add the middle bits
113
+ result.push({
114
+ data: "01010",
115
+ options: { height: this.guardHeight }
116
+ });
117
+
118
+ // Add the right side
119
+ result.push({
120
+ data: (0, _encoder2.default)(this.data.substr(6, 5), "RRRRR"),
121
+ text: this.text.substr(6, 5),
122
+ options: { fontSize: this.fontSize }
123
+ });
124
+
125
+ // Add the end bits
126
+ result.push({
127
+ data: (0, _encoder2.default)(this.data[11], "R") + "101",
128
+ options: { height: this.guardHeight }
129
+ });
130
+
131
+ // Add the last digit
132
+ if (this.displayValue) {
133
+ result.push({
134
+ data: "00000000",
135
+ text: this.text.substr(11, 1),
136
+ options: { textAlign: "right", fontSize: this.fontSize }
137
+ });
138
+ }
139
+
140
+ return result;
141
+ }
142
+ }]);
143
+
144
+ return UPC;
145
+ }(_Barcode3.default);
146
+
147
+ // Calulate the checksum digit
148
+ // https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Calculation_of_checksum_digit
149
+
150
+
151
+ function checksum(number) {
152
+ var result = 0;
153
+
154
+ var i;
155
+ for (i = 1; i < 11; i += 2) {
156
+ result += parseInt(number[i]);
157
+ }
158
+ for (i = 0; i < 11; i += 2) {
159
+ result += parseInt(number[i]) * 3;
160
+ }
161
+
162
+ return (10 - result % 10) % 10;
163
+ }
164
+
165
+ exports.default = UPC;
@@ -0,0 +1,185 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8
+
9
+ var _encoder = require('./encoder');
10
+
11
+ var _encoder2 = _interopRequireDefault(_encoder);
12
+
13
+ var _Barcode2 = require('../Barcode.js');
14
+
15
+ var _Barcode3 = _interopRequireDefault(_Barcode2);
16
+
17
+ var _UPC = require('./UPC.js');
18
+
19
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
+
21
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
22
+
23
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
24
+
25
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
26
+ // https://en.wikipedia.org/wiki/Universal_Product_Code#Encoding
27
+ //
28
+ // UPC-E documentation:
29
+ // https://en.wikipedia.org/wiki/Universal_Product_Code#UPC-E
30
+
31
+ var EXPANSIONS = ["XX00000XXX", "XX10000XXX", "XX20000XXX", "XXX00000XX", "XXXX00000X", "XXXXX00005", "XXXXX00006", "XXXXX00007", "XXXXX00008", "XXXXX00009"];
32
+
33
+ var PARITIES = [["EEEOOO", "OOOEEE"], ["EEOEOO", "OOEOEE"], ["EEOOEO", "OOEEOE"], ["EEOOOE", "OOEEEO"], ["EOEEOO", "OEOOEE"], ["EOOEEO", "OEEOOE"], ["EOOOEE", "OEEEOO"], ["EOEOEO", "OEOEOE"], ["EOEOOE", "OEOEEO"], ["EOOEOE", "OEEOEO"]];
34
+
35
+ var UPCE = function (_Barcode) {
36
+ _inherits(UPCE, _Barcode);
37
+
38
+ function UPCE(data, options) {
39
+ _classCallCheck(this, UPCE);
40
+
41
+ var _this = _possibleConstructorReturn(this, (UPCE.__proto__ || Object.getPrototypeOf(UPCE)).call(this, data, options));
42
+ // Code may be 6 or 8 digits;
43
+ // A 7 digit code is ambiguous as to whether the extra digit
44
+ // is a UPC-A check or number system digit.
45
+
46
+
47
+ _this.isValid = false;
48
+ if (data.search(/^[0-9]{6}$/) !== -1) {
49
+ _this.middleDigits = data;
50
+ _this.upcA = expandToUPCA(data, "0");
51
+ _this.text = options.text || '' + _this.upcA[0] + data + _this.upcA[_this.upcA.length - 1];
52
+ _this.isValid = true;
53
+ } else if (data.search(/^[01][0-9]{7}$/) !== -1) {
54
+ _this.middleDigits = data.substring(1, data.length - 1);
55
+ _this.upcA = expandToUPCA(_this.middleDigits, data[0]);
56
+
57
+ if (_this.upcA[_this.upcA.length - 1] === data[data.length - 1]) {
58
+ _this.isValid = true;
59
+ } else {
60
+ // checksum mismatch
61
+ return _possibleConstructorReturn(_this);
62
+ }
63
+ } else {
64
+ return _possibleConstructorReturn(_this);
65
+ }
66
+
67
+ _this.displayValue = options.displayValue;
68
+
69
+ // Make sure the font is not bigger than the space between the guard bars
70
+ if (options.fontSize > options.width * 10) {
71
+ _this.fontSize = options.width * 10;
72
+ } else {
73
+ _this.fontSize = options.fontSize;
74
+ }
75
+
76
+ // Make the guard bars go down half the way of the text
77
+ _this.guardHeight = options.height + _this.fontSize / 2 + options.textMargin;
78
+ return _this;
79
+ }
80
+
81
+ _createClass(UPCE, [{
82
+ key: 'valid',
83
+ value: function valid() {
84
+ return this.isValid;
85
+ }
86
+ }, {
87
+ key: 'encode',
88
+ value: function encode() {
89
+ if (this.options.flat) {
90
+ return this.flatEncoding();
91
+ } else {
92
+ return this.guardedEncoding();
93
+ }
94
+ }
95
+ }, {
96
+ key: 'flatEncoding',
97
+ value: function flatEncoding() {
98
+ var result = "";
99
+
100
+ result += "101";
101
+ result += this.encodeMiddleDigits();
102
+ result += "010101";
103
+
104
+ return {
105
+ data: result,
106
+ text: this.text
107
+ };
108
+ }
109
+ }, {
110
+ key: 'guardedEncoding',
111
+ value: function guardedEncoding() {
112
+ var result = [];
113
+
114
+ // Add the UPC-A number system digit beneath the quiet zone
115
+ if (this.displayValue) {
116
+ result.push({
117
+ data: "00000000",
118
+ text: this.text[0],
119
+ options: { textAlign: "left", fontSize: this.fontSize }
120
+ });
121
+ }
122
+
123
+ // Add the guard bars
124
+ result.push({
125
+ data: "101",
126
+ options: { height: this.guardHeight }
127
+ });
128
+
129
+ // Add the 6 UPC-E digits
130
+ result.push({
131
+ data: this.encodeMiddleDigits(),
132
+ text: this.text.substring(1, 7),
133
+ options: { fontSize: this.fontSize }
134
+ });
135
+
136
+ // Add the end bits
137
+ result.push({
138
+ data: "010101",
139
+ options: { height: this.guardHeight }
140
+ });
141
+
142
+ // Add the UPC-A check digit beneath the quiet zone
143
+ if (this.displayValue) {
144
+ result.push({
145
+ data: "00000000",
146
+ text: this.text[7],
147
+ options: { textAlign: "right", fontSize: this.fontSize }
148
+ });
149
+ }
150
+
151
+ return result;
152
+ }
153
+ }, {
154
+ key: 'encodeMiddleDigits',
155
+ value: function encodeMiddleDigits() {
156
+ var numberSystem = this.upcA[0];
157
+ var checkDigit = this.upcA[this.upcA.length - 1];
158
+ var parity = PARITIES[parseInt(checkDigit)][parseInt(numberSystem)];
159
+ return (0, _encoder2.default)(this.middleDigits, parity);
160
+ }
161
+ }]);
162
+
163
+ return UPCE;
164
+ }(_Barcode3.default);
165
+
166
+ function expandToUPCA(middleDigits, numberSystem) {
167
+ var lastUpcE = parseInt(middleDigits[middleDigits.length - 1]);
168
+ var expansion = EXPANSIONS[lastUpcE];
169
+
170
+ var result = "";
171
+ var digitIndex = 0;
172
+ for (var i = 0; i < expansion.length; i++) {
173
+ var c = expansion[i];
174
+ if (c === 'X') {
175
+ result += middleDigits[digitIndex++];
176
+ } else {
177
+ result += c;
178
+ }
179
+ }
180
+
181
+ result = '' + numberSystem + result;
182
+ return '' + result + (0, _UPC.checksum)(result);
183
+ }
184
+
185
+ exports.default = UPCE;
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ // Standard start end and middle bits
7
+ var SIDE_BIN = exports.SIDE_BIN = '101';
8
+ var MIDDLE_BIN = exports.MIDDLE_BIN = '01010';
9
+
10
+ var BINARIES = exports.BINARIES = {
11
+ 'L': [// The L (left) type of encoding
12
+ '0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011'],
13
+ 'G': [// The G type of encoding
14
+ '0100111', '0110011', '0011011', '0100001', '0011101', '0111001', '0000101', '0010001', '0001001', '0010111'],
15
+ 'R': [// The R (right) type of encoding
16
+ '1110010', '1100110', '1101100', '1000010', '1011100', '1001110', '1010000', '1000100', '1001000', '1110100'],
17
+ 'O': [// The O (odd) encoding for UPC-E
18
+ '0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011'],
19
+ 'E': [// The E (even) encoding for UPC-E
20
+ '0100111', '0110011', '0011011', '0100001', '0011101', '0111001', '0000101', '0010001', '0001001', '0010111']
21
+ };
22
+
23
+ // Define the EAN-2 structure
24
+ var EAN2_STRUCTURE = exports.EAN2_STRUCTURE = ['LL', 'LG', 'GL', 'GG'];
25
+
26
+ // Define the EAN-5 structure
27
+ var EAN5_STRUCTURE = exports.EAN5_STRUCTURE = ['GGLLL', 'GLGLL', 'GLLGL', 'GLLLG', 'LGGLL', 'LLGGL', 'LLLGG', 'LGLGL', 'LGLLG', 'LLGLG'];
28
+
29
+ // Define the EAN-13 structure
30
+ var EAN13_STRUCTURE = exports.EAN13_STRUCTURE = ['LLLLLL', 'LLGLGG', 'LLGGLG', 'LLGGGL', 'LGLLGG', 'LGGLLG', 'LGGGLL', 'LGLGLG', 'LGLGGL', 'LGGLGL'];
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _constants = require('./constants');
8
+
9
+ // Encode data string
10
+ var encode = function encode(data, structure, separator) {
11
+ var encoded = data.split('').map(function (val, idx) {
12
+ return _constants.BINARIES[structure[idx]];
13
+ }).map(function (val, idx) {
14
+ return val ? val[data[idx]] : '';
15
+ });
16
+
17
+ if (separator) {
18
+ var last = data.length - 1;
19
+ encoded = encoded.map(function (val, idx) {
20
+ return idx < last ? val + separator : val;
21
+ });
22
+ }
23
+
24
+ return encoded.join('');
25
+ };
26
+
27
+ exports.default = encode;
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UPCE = exports.UPC = exports.EAN2 = exports.EAN5 = exports.EAN8 = exports.EAN13 = undefined;
7
+
8
+ var _EAN = require('./EAN13.js');
9
+
10
+ var _EAN2 = _interopRequireDefault(_EAN);
11
+
12
+ var _EAN3 = require('./EAN8.js');
13
+
14
+ var _EAN4 = _interopRequireDefault(_EAN3);
15
+
16
+ var _EAN5 = require('./EAN5.js');
17
+
18
+ var _EAN6 = _interopRequireDefault(_EAN5);
19
+
20
+ var _EAN7 = require('./EAN2.js');
21
+
22
+ var _EAN8 = _interopRequireDefault(_EAN7);
23
+
24
+ var _UPC = require('./UPC.js');
25
+
26
+ var _UPC2 = _interopRequireDefault(_UPC);
27
+
28
+ var _UPCE = require('./UPCE.js');
29
+
30
+ var _UPCE2 = _interopRequireDefault(_UPCE);
31
+
32
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
+
34
+ exports.EAN13 = _EAN2.default;
35
+ exports.EAN8 = _EAN4.default;
36
+ exports.EAN5 = _EAN6.default;
37
+ exports.EAN2 = _EAN8.default;
38
+ exports.UPC = _UPC2.default;
39
+ exports.UPCE = _UPCE2.default;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.GenericBarcode = undefined;
7
+
8
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
9
+
10
+ var _Barcode2 = require("../Barcode.js");
11
+
12
+ var _Barcode3 = _interopRequireDefault(_Barcode2);
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17
+
18
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
19
+
20
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
21
+
22
+ var GenericBarcode = function (_Barcode) {
23
+ _inherits(GenericBarcode, _Barcode);
24
+
25
+ function GenericBarcode(data, options) {
26
+ _classCallCheck(this, GenericBarcode);
27
+
28
+ return _possibleConstructorReturn(this, (GenericBarcode.__proto__ || Object.getPrototypeOf(GenericBarcode)).call(this, data, options)); // Sets this.data and this.text
29
+ }
30
+
31
+ // Return the corresponding binary numbers for the data provided
32
+
33
+
34
+ _createClass(GenericBarcode, [{
35
+ key: "encode",
36
+ value: function encode() {
37
+ return {
38
+ data: "10101010101010101010101010101010101010101",
39
+ text: this.text
40
+ };
41
+ }
42
+
43
+ // Resturn true/false if the string provided is valid for this encoder
44
+
45
+ }, {
46
+ key: "valid",
47
+ value: function valid() {
48
+ return true;
49
+ }
50
+ }]);
51
+
52
+ return GenericBarcode;
53
+ }(_Barcode3.default);
54
+
55
+ exports.GenericBarcode = GenericBarcode;
@@ -0,0 +1,69 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8
+
9
+ var _constants = require('./constants');
10
+
11
+ var _Barcode2 = require('../Barcode');
12
+
13
+ var _Barcode3 = _interopRequireDefault(_Barcode2);
14
+
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+
17
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
+
19
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
20
+
21
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
22
+
23
+ var ITF = function (_Barcode) {
24
+ _inherits(ITF, _Barcode);
25
+
26
+ function ITF() {
27
+ _classCallCheck(this, ITF);
28
+
29
+ return _possibleConstructorReturn(this, (ITF.__proto__ || Object.getPrototypeOf(ITF)).apply(this, arguments));
30
+ }
31
+
32
+ _createClass(ITF, [{
33
+ key: 'valid',
34
+ value: function valid() {
35
+ return this.data.search(/^([0-9]{2})+$/) !== -1;
36
+ }
37
+ }, {
38
+ key: 'encode',
39
+ value: function encode() {
40
+ var _this2 = this;
41
+
42
+ // Calculate all the digit pairs
43
+ var encoded = this.data.match(/.{2}/g).map(function (pair) {
44
+ return _this2.encodePair(pair);
45
+ }).join('');
46
+
47
+ return {
48
+ data: _constants.START_BIN + encoded + _constants.END_BIN,
49
+ text: this.text
50
+ };
51
+ }
52
+
53
+ // Calculate the data of a number pair
54
+
55
+ }, {
56
+ key: 'encodePair',
57
+ value: function encodePair(pair) {
58
+ var second = _constants.BINARIES[pair[1]];
59
+
60
+ return _constants.BINARIES[pair[0]].split('').map(function (first, idx) {
61
+ return (first === '1' ? '111' : '1') + (second[idx] === '1' ? '000' : '0');
62
+ }).join('');
63
+ }
64
+ }]);
65
+
66
+ return ITF;
67
+ }(_Barcode3.default);
68
+
69
+ exports.default = ITF;
@@ -0,0 +1,55 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8
+
9
+ var _ITF2 = require('./ITF');
10
+
11
+ var _ITF3 = _interopRequireDefault(_ITF2);
12
+
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+
15
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16
+
17
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
18
+
19
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
20
+
21
+ // Calculate the checksum digit
22
+ var checksum = function checksum(data) {
23
+ var res = data.substr(0, 13).split('').map(function (num) {
24
+ return parseInt(num, 10);
25
+ }).reduce(function (sum, n, idx) {
26
+ return sum + n * (3 - idx % 2 * 2);
27
+ }, 0);
28
+
29
+ return Math.ceil(res / 10) * 10 - res;
30
+ };
31
+
32
+ var ITF14 = function (_ITF) {
33
+ _inherits(ITF14, _ITF);
34
+
35
+ function ITF14(data, options) {
36
+ _classCallCheck(this, ITF14);
37
+
38
+ // Add checksum if it does not exist
39
+ if (data.search(/^[0-9]{13}$/) !== -1) {
40
+ data += checksum(data);
41
+ }
42
+ return _possibleConstructorReturn(this, (ITF14.__proto__ || Object.getPrototypeOf(ITF14)).call(this, data, options));
43
+ }
44
+
45
+ _createClass(ITF14, [{
46
+ key: 'valid',
47
+ value: function valid() {
48
+ return this.data.search(/^[0-9]{14}$/) !== -1 && +this.data[13] === checksum(this.data);
49
+ }
50
+ }]);
51
+
52
+ return ITF14;
53
+ }(_ITF3.default);
54
+
55
+ exports.default = ITF14;
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var START_BIN = exports.START_BIN = '1010';
7
+ var END_BIN = exports.END_BIN = '11101';
8
+
9
+ var BINARIES = exports.BINARIES = ['00110', '10001', '01001', '11000', '00101', '10100', '01100', '00011', '10010', '01010'];
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ITF14 = exports.ITF = undefined;
7
+
8
+ var _ITF = require('./ITF');
9
+
10
+ var _ITF2 = _interopRequireDefault(_ITF);
11
+
12
+ var _ITF3 = require('./ITF14');
13
+
14
+ var _ITF4 = _interopRequireDefault(_ITF3);
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ exports.ITF = _ITF2.default;
19
+ exports.ITF14 = _ITF4.default;