Adding Code39VINReader
@ -0,0 +1,59 @@
|
|||||||
|
/* jshint undef: true, unused: true, browser:true, devel: true */
|
||||||
|
/* global define */
|
||||||
|
|
||||||
|
define(
|
||||||
|
[
|
||||||
|
"./code_39_reader"
|
||||||
|
],
|
||||||
|
function(Code39Reader) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
function Code39VINReader() {
|
||||||
|
Code39Reader.call(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
var patterns = {
|
||||||
|
IOQ: /[IOQ]/g,
|
||||||
|
AZ09: /[A-Z0-9]{17}/
|
||||||
|
};
|
||||||
|
|
||||||
|
Code39VINReader.prototype = Object.create(Code39Reader.prototype);
|
||||||
|
Code39VINReader.prototype.constructor = Code39VINReader;
|
||||||
|
|
||||||
|
// Cribbed from:
|
||||||
|
// https://github.com/zxing/zxing/blob/master/core/src/main/java/com/google/zxing/client/result/VINResultParser.java
|
||||||
|
Code39VINReader.prototype._decode = function() {
|
||||||
|
var result = Code39Reader.prototype._decode.apply(this);
|
||||||
|
if (!result) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var code = result.code;
|
||||||
|
|
||||||
|
if (!code) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = code.replace(patterns.IOQ, '');
|
||||||
|
|
||||||
|
if (!code.match(patterns.AZ09)) {
|
||||||
|
console.log('Failed AZ09 pattern code:', code);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this._checkChecksum(code)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.code = code;
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
Code39VINReader.prototype._checkChecksum = function(code) {
|
||||||
|
// TODO
|
||||||
|
return !!code;
|
||||||
|
};
|
||||||
|
|
||||||
|
return (Code39VINReader);
|
||||||
|
}
|
||||||
|
);
|
Before Width: | Height: | Size: 7.0 MiB |
Before Width: | Height: | Size: 5.1 MiB |
Before Width: | Height: | Size: 4.5 MiB |
Before Width: | Height: | Size: 4.4 MiB |
Before Width: | Height: | Size: 5.8 MiB |
Before Width: | Height: | Size: 5.5 MiB |
Before Width: | Height: | Size: 2.7 MiB |
Before Width: | Height: | Size: 3.2 MiB |
After Width: | Height: | Size: 381 KiB |
After Width: | Height: | Size: 615 KiB |
After Width: | Height: | Size: 500 KiB |
After Width: | Height: | Size: 483 KiB |
After Width: | Height: | Size: 548 KiB |
After Width: | Height: | Size: 513 KiB |
After Width: | Height: | Size: 312 KiB |
After Width: | Height: | Size: 356 KiB |
After Width: | Height: | Size: 387 KiB |
After Width: | Height: | Size: 375 KiB |