| 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 | 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 19× 1× 18× 18× 18× 7× 11× 1× 11× 11× 11× 1× 1× 1× 1× 1× 1× 1× 2× 2× 1× 11× 1× 9× 9× 9× 9× 9× 9× 8× 9× 9× 9× 1× 10× 10× 10× 10× 1× 7× 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", "./qr-code-util", "../gs1/gs1-parser"], function (require, exports, qr_code_util_1, gs1_parser_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var GS = String.fromCharCode(29); var Gs1QRCode = (function (_super) { __extends(Gs1QRCode, _super); function Gs1QRCode() { return _super !== null && _super.apply(this, arguments) || this; } Gs1QRCode.prototype.validateInput = function (char) { var result = gs1_parser_1.parseGs1(char); this.gs1Result = result; if (!result.ok) { return this.message(result.error); } return undefined; }; Gs1QRCode.prototype.buildGs1Data = function () { var success = this.gs1Result; var data = GS + success.encodingData; if (success.separatingFnc1After.length) { var separators = success.separatingFnc1After; var index = void 0; for (index = separators.length - 1; index >= 0; index--) { var elementIndex = separators[parseInt(index.toString(), 10)]; var offset = GS.length; var boundary = void 0; for (boundary = 0; boundary <= elementIndex; boundary++) { var element = success.elements[parseInt(boundary.toString(), 10)]; offset += element.ai.length + element.value.length; } data = data.substring(0, offset) + GS + data.substring(offset); } } return data; }; Gs1QRCode.prototype.draw = function (char, canvas, height, width, margin, displayText, mode, foreColor, logo) { var result = this.gs1Result && this.gs1Result.ok ? this.gs1Result : gs1_parser_1.parseGs1(char); Iif (!result.ok) { return false; } this.gs1Result = result; this.text = this.buildGs1Data(); var originalText = displayText.text; if (!originalText) { displayText.text = result.humanReadableText; } var valid = _super.prototype.draw.call(this, this.text, canvas, height, width, margin, displayText, mode, foreColor, logo); displayText.text = originalText; return valid; }; Gs1QRCode.prototype.initialize = function () { _super.prototype.initialize.call(this); this.mInputMode = 'BinaryMode'; this.mIsEci = false; this.mIsFnc1FirstPosition = true; }; Gs1QRCode.prototype.message = function (key) { return this.locale ? (this.locale.getConstant(key) || key) : key; }; return Gs1QRCode; }(qr_code_util_1.QRCode)); exports.Gs1QRCode = Gs1QRCode; }); |