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 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 8× 1× 6× 1× 5× 1× 8× 8× 1× 5× 5× 1× 5× 5× 43× 43× 1× 8× 8× 8× 8× 8× 60× 60× 60× 8× 8× 8× 8× 1× 5× 5× 5× 5× 5× 5× 4× 4× 5× 5× 5× 5× 5× 1× 1× | /* 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 Code93 = (function (_super) { __extends(Code93, _super); function Code93() { return _super !== null && _super.apply(this, arguments) || this; } Code93.prototype.validateInput = function (value) { if (value.search(/^[0-9A-Z\-\.\*\$\/\+\ %\ ]+$/) === -1) { return 'Supports A-Z, 0-9, and symbols ( - . $ / + % SPACE).'; } else { return undefined; } }; Code93.prototype.getCharacterWeight = function () { var codes = { '0': '0', '1': '1', '2': '2', '3': '3', '4': '4', '5': '5', '6': '6', '7': '7', '8': '8', '9': '9', 'A': '10', 'B': '11', 'C': '12', 'D': '13', 'E': '14', 'F': '15', 'G': '16', 'H': '17', 'I': '18', 'J': '19', 'K': '20', 'L': '21', 'M': '22', 'N': '23', 'O': '24', 'P': '25', 'Q': '26', 'R': '27', 'S': '28', 'T': '29', 'U': '30', 'V': '31', 'W': '32', 'X': '33', 'Y': '34', 'Z': '35', '-': '36', '.': '37', ' ': '38', '$': '39', '/': '40', '+': '41', '%': '42', '($)': '43', '(/)': '44', '(+)': '45', '(%)': '46' }; return codes; }; Code93.prototype.getCodeValue = function () { var codes = { '0': '100010100', '1': '101001000', '2': '101000100', '3': '101000010', '4': '100101000', '5': '100100100', '6': '100100010', '7': '101010000', '8': '100010010', '9': '100001010', 'A': '110101000', 'B': '110100100', 'C': '110100010', 'D': '110010100', 'E': '110010010', 'F': '110001010', 'G': '101101000', 'H': '101100100', 'I': '101100010', 'J': '100110100', 'K': '100011010', 'L': '101011000', 'M': '101001100', 'N': '101000110', 'O': '100101100', 'P': '100010110', 'Q': '110110100', 'R': '110110010', 'S': '110101100', 'T': '110100110', 'U': '110010110', 'V': '110011010', 'W': '101101100', 'X': '101100110', 'Y': '100110110', 'Z': '100111010', '-': '100101110', '.': '111010100', ' ': '111010010', '$': '111001010', '/': '101101110', '+': '101110110', '%': '110101110', '($)': '100100110', '(/)': '111010110', '(+)': '100110010', '(%)': '111011010' }; return codes; }; Code93.prototype.getPatternCollection = function (givenCharacter, codes, encodingValue) { var code = encodingValue; for (var i = 0; i < givenCharacter.length; i++) { var char = givenCharacter[parseInt(i.toString(), 10)]; code.push(codes["" + char]); } }; Code93.prototype.calculateCheckSum = function (givenCharacter) { var value = givenCharacter; var weightSum = 0; var j = 0; var codes = this.getCharacterWeight(); for (var i = value.length; i > 0; i--) { var characterValue = codes[value[parseInt(j.toString(), 10)]] * i; weightSum += characterValue; j++; } var moduloValue = weightSum % 47; var objectValue = Object.keys(codes); var appendSymbol = objectValue[parseInt(moduloValue.toString(), 10)]; return appendSymbol; }; Code93.prototype.draw = function (canvas) { var codes = this.getCodeValue(); var encodingValue = []; var givenCharacter = this.value; var startStopCharacter = '101011110'; var terminationBar = '1'; if (this.enableCheckSum) { givenCharacter += this.calculateCheckSum(givenCharacter); givenCharacter += this.calculateCheckSum(givenCharacter); } encodingValue.push(startStopCharacter); this.getPatternCollection(givenCharacter, codes, encodingValue); encodingValue.push(startStopCharacter); encodingValue.push(terminationBar); this.calculateBarCodeAttributes(encodingValue, canvas); }; return Code93; }(one_dimension_1.OneDimension)); exports.Code93 = Code93; }); |