all files / barcode/one-dimension/ code32.js

100% Statements 41/41
95% Branches 19/20
100% Functions 13/13
100% Lines 38/38
11 statements, 6 functions, 9 branches Ignored     
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          12×   12×                               88× 3256× 80×                
/* istanbul ignore next */ 
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
define(["require", "exports", "../one-dimension"], function (require, exports, one_dimension_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Code32 = (function (_super) {
        __extends(Code32, _super);
        function Code32() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        Code32.prototype.validateInput = function (char) {
            if (char.length === 8 && char.match(/^[0-9]+$/)) {
                return undefined;
            }
            else {
                return 'Accepts 9 numeric characters.';
            }
        };
        Code32.prototype.getCodeValue = function () {
            var symbolTable = [['0', 0, ['111331311']], ['1', 1, ['311311113']], ['2', 2, ['113311113']], ['3', 3, ['313311111']],
                ['4', 4, ['111331113']], ['5', 5, ['311331111']], ['6', 6, ['113331111']], ['7', 7, ['111311313']], ['8', 8, ['311311311']],
                ['9', 9, ['113311311']], ['A', 10, ['113113113']], ['B', 11, ['113113113']], ['C', 12, ['313113111']], ['D', 13, ['111133113']],
                ['E', 14, ['221211']], ['F', 15, ['113133111']], ['G', 0x10, ['111113313']], ['H', 0x11, ['311113311']], ['I', 0x12, ['112311']],
                ['J', 0x13, ['111133311']], ['K', 20, ['311111133']], ['L', 0x15, ['113111133']], ['M', 0x16, ['313111131']],
                ['N', 0x17, ['111131133']],
                ['O', 0x18, ['121122']], ['P', 0x19, ['113131131']], ['Q', 0x1a, ['111111333']], ['R', 0x1b, ['311111331']],
                ['S', 0x1c, ['113111331']],
                ['T', 0x1d, ['111131331']], ['U', 30, ['331111113']], ['V', 0x1f, ['133111113']], ['W', 0x20, ['333111111']],
                ['X', 0x21, ['131131113']], ['Y', 0x22, ['331131111']], ['Z', 0x23, ['133131111']], ['*', 0, ['131131311']]
            ];
            return symbolTable;
        };
        Code32.prototype.getPatternCollection = function (givenChar) {
            var code = [];
            var codes = this.getCodeValue();
            for (var i = 0; i <= givenChar.length; i++) {
                for (var j = 0; j < codes.length; j++) {
                    if (givenChar[parseInt(i.toString(), 10)] === codes[parseInt(j.toString(), 10)][0]) {
                        code.push(codes[parseInt(j.toString(), 10)][2][0]);
                    }
                }
            }
            return code;
        };
        Code32.prototype.draw = function (canvas) {
            var value = this.value;
            var givenChar = '*' + value + '*';
            var codes = this.getPatternCollection(givenChar);
            this.calculateBarCodeAttributes(codes, canvas);
        };
        return Code32;
    }(one_dimension_1.OneDimension));
    exports.Code32 = Code32;
});