| 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 | 1×
1×
1×
1×
514×
514×
514×
514×
514×
514×
1×
10684×
1×
899×
1×
514×
1×
10684×
10684×
5×
5×
24×
24×
3×
3×
3×
3×
45×
45×
2×
2×
76×
76×
86×
86×
183×
183×
489×
489×
462×
462×
2629×
2629×
6677×
6677×
10684×
10684×
10684×
10684×
10684×
1×
10684×
374830×
1×
10684×
10684×
305897×
305897×
305897×
151641×
301181×
305897×
10684×
1×
10684×
10684×
10684×
10684×
2724420×
10707652×
10684×
10684×
374830×
374830×
374830×
374830×
374830×
373616×
10707652×
10707652×
10684×
1×
10684×
10684×
316581×
316581×
10684×
1×
1×
| define(["require", "exports", "./qr-barcode-values"], function (require, exports, qr_barcode_values_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ErrorCorrectionCodewords = (function () {
function ErrorCorrectionCodewords(version, correctionLevel) {
this.alpha = [1, 2, 4, 8, 16, 32, 64, 128, 29, 58, 116, 232, 205, 135, 19, 38, 76, 152, 45, 90, 180, 117, 234, 201, 143,
3, 6, 12, 24, 48, 96, 192, 157, 39, 78, 156, 37, 74, 148, 53, 106, 212, 181, 119, 238, 193, 159, 35, 70, 140, 5, 10, 20, 40, 80,
160, 93, 186, 105, 210, 185, 111, 222, 161, 95, 190, 97, 194, 153, 47, 94, 188, 101, 202, 137, 15, 30, 60, 120, 240, 253, 231,
211, 187, 107, 214, 177, 127, 254, 225, 223, 163, 91, 182, 113, 226, 217, 175, 67, 134, 17, 34, 68, 136, 13, 26, 52, 104, 208,
189, 103, 206, 129, 31, 62, 124, 248, 237, 199, 147, 59, 118, 236, 197, 151, 51, 102, 204, 133, 23, 46, 92, 184, 109, 218, 169,
79, 158, 33, 66, 132, 21, 42, 84, 168, 77, 154, 41, 82, 164, 85, 170, 73, 146, 57, 114, 228, 213, 183, 115, 230, 209, 191, 99,
198, 145, 63, 126, 252, 229, 215, 179, 123, 246, 241, 255, 227, 219, 171, 75, 150, 49, 98, 196, 149, 55, 110, 220, 165, 87,
174, 65, 130, 25, 50, 100, 200, 141, 7, 14, 28, 56, 112, 224, 221, 167, 83, 166, 81, 162, 89, 178, 121, 242, 249, 239, 195,
155, 43, 86, 172, 69, 138, 9, 18, 36, 72, 144, 61, 122, 244, 245, 247, 243, 251, 235, 203, 139, 11, 22, 44, 88, 176, 125,
250, 233, 207, 131, 27, 54, 108, 216, 173, 71, 142];
this.mQrBarcodeValues = new qr_barcode_values_1.PdfQRBarcodeValues(version, correctionLevel);
var variable = 'DataCapacity';
this.mLength = this.mQrBarcodeValues["" + variable];
variable = 'NumberOfErrorCorrectingCodeWords';
this.eccw = this.mQrBarcodeValues["" + variable];
}
Object.defineProperty(ErrorCorrectionCodewords.prototype, "DC", {
set: function (value) {
this.mDataCodeWord = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ErrorCorrectionCodewords.prototype, "DataBits", {
set: function (value) {
this.databits = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ErrorCorrectionCodewords.prototype, "Eccw", {
set: function (value) {
this.eccw = value;
},
enumerable: true,
configurable: true
});
ErrorCorrectionCodewords.prototype.getErcw = function () {
this.decimalValue = [this.databits];
switch (this.eccw) {
case 7:
this.gx = [0, 87, 229, 146, 149, 238, 102, 21];
break;
case 10:
this.gx = [0, 251, 67, 46, 61, 118, 70, 64, 94, 32, 45];
break;
case 13:
this.gx = [0, 74, 152, 176, 100, 86, 100, 106, 104, 130, 218, 206, 140, 78];
break;
case 15:
this.gx = [0, 8, 183, 61, 91, 202, 37, 51, 58, 58, 237, 140, 124, 5, 99, 105];
break;
case 16:
this.gx = [0, 120, 104, 107, 109, 102, 161, 76, 3, 91, 191, 147, 169, 182, 194, 225, 120];
break;
case 17:
this.gx = [0, 43, 139, 206, 78, 43, 239, 123, 206, 214, 147, 24, 99, 150, 39, 243, 163, 136];
break;
case 18:
this.gx = [0, 215, 234, 158, 94, 184, 97, 118, 170, 79, 187, 152, 148, 252, 179, 5, 98, 96, 153];
break;
case 20:
this.gx = [0, 17, 60, 79, 50, 61, 163, 26, 187, 202, 180, 221, 225, 83, 239, 156, 164, 212, 212, 188, 190];
break;
case 22:
this.gx = [0, 210, 171, 247, 242, 93, 230, 14, 109, 221, 53, 200, 74, 8, 172, 98, 80, 219, 134, 160, 105, 165, 231];
break;
case 24:
this.gx = [0, 229, 121, 135, 48, 211, 117, 251, 126, 159, 180, 169, 152, 192, 226, 228, 218, 111, 0, 117, 232, 87,
96, 227, 21];
break;
case 26:
this.gx = [0, 173, 125, 158, 2, 103, 182, 118, 17, 145, 201, 111, 28, 165, 53, 161, 21, 245, 142, 13, 102, 48, 227, 153,
145, 218, 70];
break;
case 28:
this.gx = [0, 168, 223, 200, 104, 224, 234, 108, 180, 110, 190, 195, 147, 205, 27, 232, 201, 21, 43, 245, 87, 42, 195,
212, 119, 242, 37, 9, 123];
break;
case 30:
this.gx = [0, 41, 173, 145, 152, 216, 31, 179, 182, 50, 48, 110, 86, 239, 96, 222, 125, 42, 173, 226, 193, 224, 130,
156, 37, 251, 216, 238, 40, 192, 180];
break;
}
this.gx = this.getElement(this.gx, this.alpha);
this.toDecimal(this.mDataCodeWord);
var decimalRepresentation = this.divide();
var ecw = this.toBinary(decimalRepresentation);
return ecw;
};
ErrorCorrectionCodewords.prototype.toDecimal = function (inString) {
for (var i = 0; i < inString.length; i++) {
this.decimalValue[parseInt(i.toString(), 10)] = parseInt(inString[parseInt(i.toString(), 10)], 2);
}
};
ErrorCorrectionCodewords.prototype.toBinary = function (decimalRepresentation) {
var toBinary = [];
for (var i = 0; i < this.eccw; i++) {
var str = '';
var temp = decimalRepresentation[parseInt(i.toString(), 10)].toString(2);
if (temp.length < 8) {
for (var j = 0; j < 8 - temp.length; j++) {
str += '0';
}
}
toBinary[parseInt(i.toString(), 10)] = str + temp;
}
return toBinary;
};
ErrorCorrectionCodewords.prototype.divide = function () {
var errorCorrectionCodewordCount = this.eccw;
var exponentTable = this.alpha;
var logTable = [];
for (var exponentIndex = 0; exponentIndex < 255; exponentIndex++) {
logTable[parseInt(exponentTable[parseInt(exponentIndex.toString(), 10)].toString(), 10)] = exponentIndex;
}
var multiplyInGaloisField = function (firstValue, secondValue) { return (firstValue === 0 || secondValue === 0) ? 0 :
exponentTable[parseInt(((logTable[parseInt(firstValue.toString(), 10)] +
logTable[parseInt(secondValue.toString(), 10)]) % 255).toString(), 10)]; };
var errorCorrectionRemainder = new Array(errorCorrectionCodewordCount).fill(0);
for (var dataCodewordIndex = 0; dataCodewordIndex < this.mDataCodeWord.length; dataCodewordIndex++) {
var dataCodeword = parseInt(this.mDataCodeWord[parseInt(dataCodewordIndex.toString(), 10)], 2);
var leadingCoefficient = dataCodeword ^ errorCorrectionRemainder[0];
errorCorrectionRemainder.shift();
errorCorrectionRemainder.push(0);
if (leadingCoefficient !== 0) {
for (var coefficientIndex = 0; coefficientIndex < errorCorrectionCodewordCount; coefficientIndex++) {
var generatorCoefficient = this.gx[parseInt(coefficientIndex.toString(), 10) + 1];
errorCorrectionRemainder[parseInt(coefficientIndex.toString(), 10)] ^=
multiplyInGaloisField(generatorCoefficient, leadingCoefficient);
}
}
}
return errorCorrectionRemainder;
};
ErrorCorrectionCodewords.prototype.getElement = function (element, alpha) {
var gx = [element.length];
for (var i = 0; i < element.length; i++) {
Iif (element[parseInt(i.toString(), 10)] > 255) {
element[parseInt(i.toString(), 10)] = element[parseInt(i.toString(), 10)] - 255;
}
gx[parseInt(i.toString(), 10)] = alpha[element[parseInt(i.toString(), 10)]];
}
return gx;
};
return ErrorCorrectionCodewords;
}());
exports.ErrorCorrectionCodewords = ErrorCorrectionCodewords;
});
|