mirror of
https://github.com/serratus/quaggaJS.git
synced 2026-08-13 05:31:37 +08:00
Fixed #76
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
quaggaJS
|
||||
========
|
||||
|
||||
- [Changelog](#changelog) (2015-11-15)
|
||||
- [Changelog](#changelog) (2015-11-22)
|
||||
|
||||
## What is QuaggaJS?
|
||||
|
||||
@@ -434,6 +434,12 @@ on the ``singleChannel`` flag in the configuration when using ``decodeSingle``.
|
||||
|
||||
## <a name="changelog">Changelog</a>
|
||||
|
||||
### 2015-11-22
|
||||
|
||||
- Fixes
|
||||
- Fixed inconsistencies for Code 128 decoding (See
|
||||
[\#76](https://github.com/serratus/quaggaJS/issues/76))
|
||||
|
||||
### 2015-11-15
|
||||
|
||||
- Fixes
|
||||
|
||||
Vendored
+31
-17
File diff suppressed because one or more lines are too long
Vendored
+3
-3
File diff suppressed because one or more lines are too long
@@ -58,7 +58,7 @@
|
||||
© Copyright by Christoph Oberhofer
|
||||
</p>
|
||||
</footer>
|
||||
<script src="../src/vendor/jquery-1.9.0.min.js" type="text/javascript"></script>
|
||||
<script src="vendor/jquery-1.9.0.min.js" type="text/javascript"></script>
|
||||
<script src="../dist/quagga.js" type="text/javascript"></script>
|
||||
<script src="static_images.js" type="text/javascript"></script>
|
||||
</body>
|
||||
|
||||
+31
-17
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "quagga",
|
||||
"version": "0.8.1",
|
||||
"version": "0.8.2",
|
||||
"description": "An advanced barcode-scanner written in JavaScript",
|
||||
"main": "lib/quagga.js",
|
||||
"browser": "dist/quagga.min.js",
|
||||
|
||||
+31
-16
@@ -247,7 +247,8 @@ Code128Reader.prototype._decode = function() {
|
||||
rawResult = [],
|
||||
decodedCodes = [],
|
||||
shiftNext = false,
|
||||
unshift;
|
||||
unshift,
|
||||
removeLastCharacter = true;
|
||||
|
||||
if (startInfo === null) {
|
||||
return null;
|
||||
@@ -278,6 +279,10 @@ Code128Reader.prototype._decode = function() {
|
||||
shiftNext = false;
|
||||
code = self._decodeCode(code.end);
|
||||
if (code !== null) {
|
||||
if (code.code !== self.STOP_CODE) {
|
||||
removeLastCharacter = true;
|
||||
}
|
||||
|
||||
if (code.code !== self.STOP_CODE) {
|
||||
rawResult.push(code.code);
|
||||
multiplier++;
|
||||
@@ -292,6 +297,9 @@ Code128Reader.prototype._decode = function() {
|
||||
} else if (code.code < 96) {
|
||||
result.push(String.fromCharCode(code.code - 64));
|
||||
} else {
|
||||
if (code.code !== self.STOP_CODE) {
|
||||
removeLastCharacter = false;
|
||||
}
|
||||
switch (code.code) {
|
||||
case self.CODE_SHIFT:
|
||||
shiftNext = true;
|
||||
@@ -313,6 +321,9 @@ Code128Reader.prototype._decode = function() {
|
||||
if (code.code < 96) {
|
||||
result.push(String.fromCharCode(32 + code.code));
|
||||
} else {
|
||||
if (code.code !== self.STOP_CODE) {
|
||||
removeLastCharacter = false;
|
||||
}
|
||||
switch (code.code) {
|
||||
case self.CODE_SHIFT:
|
||||
shiftNext = true;
|
||||
@@ -333,17 +344,21 @@ Code128Reader.prototype._decode = function() {
|
||||
case self.CODE_C:
|
||||
if (code.code < 100) {
|
||||
result.push(code.code < 10 ? "0" + code.code : code.code);
|
||||
}
|
||||
switch (code.code) {
|
||||
case self.CODE_A:
|
||||
codeset = self.CODE_A;
|
||||
break;
|
||||
case self.CODE_B:
|
||||
codeset = self.CODE_B;
|
||||
break;
|
||||
case self.STOP_CODE:
|
||||
done = true;
|
||||
break;
|
||||
} else {
|
||||
if (code.code !== self.STOP_CODE) {
|
||||
removeLastCharacter = false;
|
||||
}
|
||||
switch (code.code) {
|
||||
case self.CODE_A:
|
||||
codeset = self.CODE_A;
|
||||
break;
|
||||
case self.CODE_B:
|
||||
codeset = self.CODE_B;
|
||||
break;
|
||||
case self.STOP_CODE:
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -359,14 +374,11 @@ Code128Reader.prototype._decode = function() {
|
||||
return null;
|
||||
}
|
||||
|
||||
// find end bar
|
||||
code.end = self._nextUnset(self._row, code.end);
|
||||
if (!self._verifyTrailingWhitespace(code)){
|
||||
return null;
|
||||
}
|
||||
|
||||
// checksum
|
||||
// Does not work correctly yet!!! startcode - endcode?
|
||||
checksum -= multiplier * rawResult[rawResult.length - 1];
|
||||
if (checksum % 103 !== rawResult[rawResult.length - 1]) {
|
||||
return null;
|
||||
@@ -377,7 +389,10 @@ Code128Reader.prototype._decode = function() {
|
||||
}
|
||||
|
||||
// remove last code from result (checksum)
|
||||
result.splice(result.length - 1, 1);
|
||||
if (removeLastCharacter) {
|
||||
result.splice(result.length - 1, 1);
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
code: result.join(""),
|
||||
|
||||
@@ -86,7 +86,7 @@ describe('decodeSingle', function () {
|
||||
{"name": "image-005.jpg", "result": "419055603900009001012999"},
|
||||
{"name": "image-006.jpg", "result": "419055603900009001012999"},
|
||||
{"name": "image-007.jpg", "result": "T 000003552345"},
|
||||
{"name": "image-008.jpg", "result": "FANAVF1461710"},
|
||||
{"name": "image-008.jpg", "result": "FANAVF14617104"},
|
||||
{"name": "image-009.jpg", "result": "0001285112001000040801"},
|
||||
{"name": "image-010.jpg", "result": "673023"}
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user