├── .eslintignore
├── .eslintrc.json
├── .gitignore
├── LICENSE
├── README.md
├── _config.yml
├── _locales
├── en
│ └── messages.json
└── zh
│ └── messages.json
├── background.js
├── icons
├── QR-32.png
└── QR-48.png
├── manifest.json
├── package.json
├── popup
├── qrcode_decoder.js
├── qrcode_encoder.js
├── show_qrcode.css
├── show_qrcode.html
└── show_qrcode.js
└── screenshot
├── content-menu.png
├── selected_text.png
└── url.png
/.eslintignore:
--------------------------------------------------------------------------------
1 | **/node_modules/**
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "parserOptions": {
4 | "ecmaVersion": 2017
5 | },
6 | "env": {
7 | "browser": true,
8 | "es6": true,
9 | "webextensions": true
10 | },
11 | "extends": [
12 | "eslint:recommended"
13 | ],
14 | "rules": {
15 | "no-console": 0,
16 | "no-unused-vars": ["warn", { "vars": "all", "args": "all" } ],
17 | "no-undef": ["warn"],
18 | "no-proto": ["error"],
19 | "prefer-arrow-callback": ["warn"],
20 | "prefer-spread": ["warn"]
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .idea
3 | dist
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 OceanApart
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # QR Code Util
2 |
3 | A Firefox add-on that transforms between text and QR Code totally offline using the WebExtensions API.
4 |
5 | ## Browser Compatibility
6 |
7 | developed on Firefox 57.0b10
8 |
9 | ## Known Issues
10 |
11 | 1. `已拦截跨源请求:同源策略禁止读取位于 http://img3.imgtn.bdimg.com/it/u=4145755343,2268587096&fm=27&gp=0.jpg 的远程资源。(原因:CORS 头缺少 'Access-Control-Allow-Origin')。`
12 |
13 | ## License
14 |
15 | MIT License
16 |
17 | ## Thanks
18 |
19 | - [webextensions-examples](https://github.com/mdn/webextensions-examples) by mdn
20 | - [qrcodejs](https://github.com/davidshimjs/qrcodejs) by davidshimjs
21 | - [jsqrcode](https://github.com/LazarSoft/jsqrcode) by LazarSoft
22 | - [qcode-decoder](https://github.com/cirocosta/qcode-decoder) by cirocosta
23 | - [QRScaner](https://github.com/laobubu/QRScaner) by laobubu
24 | - [JS-HTML5-QRCode-Generator](JS-HTML5-QRCode-Generator) by amanuel
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-leap-day
--------------------------------------------------------------------------------
/_locales/en/messages.json:
--------------------------------------------------------------------------------
1 | {
2 | "addOnName": {
3 | "message": "QR Code Util"
4 | },
5 | "contextMenu-img": {
6 | "message": "Decode this image"
7 | },
8 | "contextMenu-text": {
9 | "message": "Encode selected text"
10 | },
11 | "contextMenu-link": {
12 | "message": "Encode selected link"
13 | },
14 | "decode-error": {
15 | "message": "Failed to decoding QR Code."
16 | },
17 | "failed-load": {
18 | "message": "Failed to load the image."
19 | }
20 | }
--------------------------------------------------------------------------------
/_locales/zh/messages.json:
--------------------------------------------------------------------------------
1 | {
2 | "addOnName": {
3 | "message": "二维码实用工具"
4 | },
5 | "contextMenu-img": {
6 | "message": "识别图片二维码"
7 | },
8 | "contextMenu-text": {
9 | "message": "为选中文本生成二维码"
10 | },
11 | "contextMenu-link": {
12 | "message": "为选中链接生成二维码"
13 | },
14 | "decode-error": {
15 | "message": "二维码解析失败"
16 | },
17 | "fail-load": {
18 | "message": "图片加载失败"
19 | }
20 | }
--------------------------------------------------------------------------------
/background.js:
--------------------------------------------------------------------------------
1 | if (typeof browser === 'undefined')
2 | var browser = chrome;
3 |
4 | var lastImage = '';
5 | var text = '';
6 |
7 | browser.contextMenus.create({
8 | id: "qr-img",
9 | title: browser.i18n.getMessage("contextMenu-img"),
10 | contexts: ["image"]
11 | });
12 |
13 | browser.contextMenus.create({
14 | id: "qr-text",
15 | title: browser.i18n.getMessage("contextMenu-text"),
16 | contexts: ["selection"]
17 | });
18 |
19 | browser.contextMenus.create({
20 | id: "qr-link",
21 | title: browser.i18n.getMessage("contextMenu-link"),
22 | contexts: ["link"]
23 | });
24 |
25 | // context menus clicked event
26 | browser.contextMenus.onClicked.addListener(function (info) {
27 | if (info.menuItemId === "qr-img") {
28 | lastImage = info.srcUrl;
29 | // alert(lastImage);
30 | browser.browserAction.openPopup();
31 | }
32 | if (info.menuItemId === "qr-text") {
33 | text = info.selectionText;
34 | // alert(lastImage);
35 | browser.browserAction.openPopup();
36 | }
37 | if (info.menuItemId === "qr-link") {
38 | text = info.linkUrl;
39 | // alert(lastImage);
40 | browser.browserAction.openPopup();
41 | }
42 | });
43 |
44 | browser.runtime.onMessage.addListener(
45 | function (request, sender, sendResponse) {
46 | if (request === 'get_data') {
47 | if (text !== '') {
48 | sendResponse({
49 | type: "text",
50 | text: text
51 | });
52 | // set empty
53 | text = '';
54 | } else if (lastImage !== '') {
55 | sendResponse({
56 | type: "img",
57 | img: lastImage
58 | });
59 | // set empty
60 | lastImage = '';
61 | }
62 | }
63 | });
64 |
65 |
--------------------------------------------------------------------------------
/icons/QR-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OceanApart/QR-Code-Util-Web-Extension/ab85d0140b3c4cd74b2d5e8911e96be391515c21/icons/QR-32.png
--------------------------------------------------------------------------------
/icons/QR-48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OceanApart/QR-Code-Util-Web-Extension/ab85d0140b3c4cd74b2d5e8911e96be391515c21/icons/QR-48.png
--------------------------------------------------------------------------------
/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "A Firefox add-on that transforms between text and QR Code totally offline using the WebExtensions API.",
3 | "manifest_version": 2,
4 | "name": "QR Code Util",
5 | "version": "0.2.1",
6 | "default_locale": "zh",
7 | "homepage_url": "https://oceanapart.github.io/QR-Code-Util-Web-Extension/",
8 |
9 | "icons": {
10 | "32": "icons/QR-32.png",
11 | "48": "icons/QR-48.png"
12 | },
13 |
14 | "permissions": [
15 | "activeTab",
16 | "contextMenus"
17 | ],
18 |
19 | "background": {
20 | "scripts": [
21 | "background.js"
22 | ]
23 | },
24 |
25 | "browser_action": {
26 | "default_icon": "icons/QR-32.png",
27 | "default_title": "QR Code Util",
28 | "default_popup": "popup/show_qrcode.html"
29 | },
30 |
31 | "commands": {
32 | "_execute_browser_action": {
33 | "suggested_key": {
34 | "default": "Ctrl+Q",
35 | "mac": "MacCtrl+Q"
36 | }
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "QR-Code-Util",
3 | "title": "QR Code Util Firefox addon",
4 | "version": "0.2.1",
5 | "description": "A Firefox add-on that transforms between text and QR Code totally offline using the WebExtensions API.",
6 | "devDependencies": {
7 | "eslint": "^4.4.1"
8 | },
9 | "repository": {
10 | "type": "git",
11 | "url": "git+github.com:OceanApart/QR-Code-Fx-add-ons.git"
12 | },
13 | "scripts": {
14 | "test": "eslint .",
15 | "lint": "eslint ."
16 | },
17 | "license": "MIT",
18 | "bugs": {
19 | "url": "https://github.com/OceanApart/QR-Code-Fx-add-ons/issues"
20 | },
21 | "keywords": [
22 | "qrcode",
23 | "webextensions",
24 | "firefox"
25 | ],
26 | "homepage": "https://oceanapart.github.io/QR-Code-Util-Web-Extension/",
27 | "dependencies": {
28 | "babel-eslint": "^7.2.3"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/popup/qrcode_decoder.js:
--------------------------------------------------------------------------------
1 | var _aa = {};
2 | _aa._ab = function (f, e) {
3 | var d = qrcode.width;
4 | var b = qrcode.height;
5 | var c = true;
6 | for (var g = 0; g < e.length && c; g += 2) {
7 | var a = Math.floor(e[g]);
8 | var h = Math.floor(e[g + 1]);
9 | if (a < -1 || a > d || h < -1 || h > b) {
10 | throw"Error._ab "
11 | }
12 | c = false;
13 | if (a == -1) {
14 | e[g] = 0;
15 | c = true
16 | } else {
17 | if (a == d) {
18 | e[g] = d - 1;
19 | c = true
20 | }
21 | }
22 | if (h == -1) {
23 | e[g + 1] = 0;
24 | c = true
25 | } else {
26 | if (h == b) {
27 | e[g + 1] = b - 1;
28 | c = true
29 | }
30 | }
31 | }
32 | c = true;
33 | for (var g = e.length - 2; g >= 0 && c; g -= 2) {
34 | var a = Math.floor(e[g]);
35 | var h = Math.floor(e[g + 1]);
36 | if (a < -1 || a > d || h < -1 || h > b) {
37 | throw"Error._ab "
38 | }
39 | c = false;
40 | if (a == -1) {
41 | e[g] = 0;
42 | c = true
43 | } else {
44 | if (a == d) {
45 | e[g] = d - 1;
46 | c = true
47 | }
48 | }
49 | if (h == -1) {
50 | e[g + 1] = 0;
51 | c = true
52 | } else {
53 | if (h == b) {
54 | e[g + 1] = b - 1;
55 | c = true
56 | }
57 | }
58 | }
59 | };
60 | _aa._af = function (b, d, a) {
61 | var k = new _ac(d);
62 | var j = new Array(d << 1);
63 | for (var f = 0; f < d; f++) {
64 | var g = j.length;
65 | var i = f + 0.5;
66 | for (var h = 0; h < g; h += 2) {
67 | j[h] = (h >> 1) + 0.5;
68 | j[h + 1] = i
69 | }
70 | a._ad(j);
71 | _aa._ab(b, j);
72 | try {
73 | for (var h = 0; h < g; h += 2) {
74 | var e = b[Math.floor(j[h]) + qrcode.width * Math.floor(j[h + 1])];
75 | if (e) {
76 | k._dq(h >> 1, f)
77 | }
78 | }
79 | } catch (c) {
80 | throw"Error._ab"
81 | }
82 | }
83 | return k
84 | };
85 | _aa._ah = function (h, o, l, k, q, p, b, a, f, e, n, m, s, r, d, c, j, i) {
86 | var g = _ae._ag(l, k, q, p, b, a, f, e, n, m, s, r, d, c, j, i);
87 | return _aa._af(h, o, g)
88 | };
89 |
90 | function _a1(b, a) {
91 | this.count = b;
92 | this._fc = a;
93 | this.__defineGetter__("Count", function () {
94 | return this.count
95 | });
96 | this.__defineGetter__("_dm", function () {
97 | return this._fc
98 | })
99 | }
100 |
101 | function _a2(a, c, b) {
102 | this._bm = a;
103 | if (b) {
104 | this._do = new Array(c, b)
105 | } else {
106 | this._do = new Array(c)
107 | }
108 | this.__defineGetter__("_bo", function () {
109 | return this._bm
110 | });
111 | this.__defineGetter__("_dn", function () {
112 | return this._bm * this._fo
113 | });
114 | this.__defineGetter__("_fo", function () {
115 | var e = 0;
116 | for (var d = 0; d < this._do.length; d++) {
117 | e += this._do[d].length
118 | }
119 | return e
120 | });
121 | this._fb = function () {
122 | return this._do
123 | }
124 | }
125 |
126 | function _a3(k, l, h, g, f, e) {
127 | this._bs = k;
128 | this._ar = l;
129 | this._do = new Array(h, g, f, e);
130 | var j = 0;
131 | var b = h._bo;
132 | var a = h._fb();
133 | for (var d = 0; d < a.length; d++) {
134 | var c = a[d];
135 | j += c.Count * (c._dm + b)
136 | }
137 | this._br = j;
138 | this.__defineGetter__("_fd", function () {
139 | return this._bs
140 | });
141 | this.__defineGetter__("_as", function () {
142 | return this._ar
143 | });
144 | this.__defineGetter__("_dp", function () {
145 | return this._br
146 | });
147 | this.__defineGetter__("_cr", function () {
148 | return 17 + 4 * this._bs
149 | });
150 | this._aq = function () {
151 | var q = this._cr;
152 | var o = new _ac(q);
153 | o._bq(0, 0, 9, 9);
154 | o._bq(q - 8, 0, 8, 9);
155 | o._bq(0, q - 8, 9, 8);
156 | var n = this._ar.length;
157 | for (var m = 0; m < n; m++) {
158 | var p = this._ar[m] - 2;
159 | for (var r = 0; r < n; r++) {
160 | if ((m == 0 && (r == 0 || r == n - 1)) || (m == n - 1 && r == 0)) {
161 | continue
162 | }
163 | o._bq(this._ar[r] - 2, p, 5, 5)
164 | }
165 | }
166 | o._bq(6, 9, 1, q - 17);
167 | o._bq(9, 6, q - 17, 1);
168 | if (this._bs > 6) {
169 | o._bq(q - 11, 0, 3, 6);
170 | o._bq(0, q - 11, 6, 3)
171 | }
172 | return o
173 | };
174 | this._bu = function (i) {
175 | return this._do[i.ordinal()]
176 | }
177 | }
178 |
179 | _a3._bv = new Array(31892, 34236, 39577, 42195, 48118, 51042, 55367, 58893, 63784, 68472, 70749, 76311, 79154, 84390, 87683, 92361, 96236, 102084, 102881, 110507, 110734, 117786, 119615, 126325, 127568, 133589, 136944, 141498, 145311, 150283, 152622, 158308, 161089, 167017);
180 | _a3.VERSIONS = _ay();
181 | _a3._av = function (a) {
182 | if (a < 1 || a > 40) {
183 | throw"bad arguments"
184 | }
185 | return _a3.VERSIONS[a - 1]
186 | };
187 | _a3._at = function (b) {
188 | if (b % 4 != 1) {
189 | throw"Error _at"
190 | }
191 | try {
192 | return _a3._av((b - 17) >> 2)
193 | } catch (a) {
194 | throw"Error _av"
195 | }
196 | };
197 | _a3._aw = function (d) {
198 | var b = 4294967295;
199 | var f = 0;
200 | for (var c = 0; c < _a3._bv.length; c++) {
201 | var a = _a3._bv[c];
202 | if (a == d) {
203 | return this._av(c + 7)
204 | }
205 | var e = _ax._gj(d, a);
206 | if (e < b) {
207 | f = c + 7;
208 | b = e
209 | }
210 | }
211 | if (b <= 3) {
212 | return this._av(f)
213 | }
214 | return null
215 | };
216 |
217 | function _ay() {
218 | return new Array(new _a3(1, new Array(), new _a2(7, new _a1(1, 19)), new _a2(10, new _a1(1, 16)), new _a2(13, new _a1(1, 13)), new _a2(17, new _a1(1, 9))), new _a3(2, new Array(6, 18), new _a2(10, new _a1(1, 34)), new _a2(16, new _a1(1, 28)), new _a2(22, new _a1(1, 22)), new _a2(28, new _a1(1, 16))), new _a3(3, new Array(6, 22), new _a2(15, new _a1(1, 55)), new _a2(26, new _a1(1, 44)), new _a2(18, new _a1(2, 17)), new _a2(22, new _a1(2, 13))), new _a3(4, new Array(6, 26), new _a2(20, new _a1(1, 80)), new _a2(18, new _a1(2, 32)), new _a2(26, new _a1(2, 24)), new _a2(16, new _a1(4, 9))), new _a3(5, new Array(6, 30), new _a2(26, new _a1(1, 108)), new _a2(24, new _a1(2, 43)), new _a2(18, new _a1(2, 15), new _a1(2, 16)), new _a2(22, new _a1(2, 11), new _a1(2, 12))), new _a3(6, new Array(6, 34), new _a2(18, new _a1(2, 68)), new _a2(16, new _a1(4, 27)), new _a2(24, new _a1(4, 19)), new _a2(28, new _a1(4, 15))), new _a3(7, new Array(6, 22, 38), new _a2(20, new _a1(2, 78)), new _a2(18, new _a1(4, 31)), new _a2(18, new _a1(2, 14), new _a1(4, 15)), new _a2(26, new _a1(4, 13), new _a1(1, 14))), new _a3(8, new Array(6, 24, 42), new _a2(24, new _a1(2, 97)), new _a2(22, new _a1(2, 38), new _a1(2, 39)), new _a2(22, new _a1(4, 18), new _a1(2, 19)), new _a2(26, new _a1(4, 14), new _a1(2, 15))), new _a3(9, new Array(6, 26, 46), new _a2(30, new _a1(2, 116)), new _a2(22, new _a1(3, 36), new _a1(2, 37)), new _a2(20, new _a1(4, 16), new _a1(4, 17)), new _a2(24, new _a1(4, 12), new _a1(4, 13))), new _a3(10, new Array(6, 28, 50), new _a2(18, new _a1(2, 68), new _a1(2, 69)), new _a2(26, new _a1(4, 43), new _a1(1, 44)), new _a2(24, new _a1(6, 19), new _a1(2, 20)), new _a2(28, new _a1(6, 15), new _a1(2, 16))), new _a3(11, new Array(6, 30, 54), new _a2(20, new _a1(4, 81)), new _a2(30, new _a1(1, 50), new _a1(4, 51)), new _a2(28, new _a1(4, 22), new _a1(4, 23)), new _a2(24, new _a1(3, 12), new _a1(8, 13))), new _a3(12, new Array(6, 32, 58), new _a2(24, new _a1(2, 92), new _a1(2, 93)), new _a2(22, new _a1(6, 36), new _a1(2, 37)), new _a2(26, new _a1(4, 20), new _a1(6, 21)), new _a2(28, new _a1(7, 14), new _a1(4, 15))), new _a3(13, new Array(6, 34, 62), new _a2(26, new _a1(4, 107)), new _a2(22, new _a1(8, 37), new _a1(1, 38)), new _a2(24, new _a1(8, 20), new _a1(4, 21)), new _a2(22, new _a1(12, 11), new _a1(4, 12))), new _a3(14, new Array(6, 26, 46, 66), new _a2(30, new _a1(3, 115), new _a1(1, 116)), new _a2(24, new _a1(4, 40), new _a1(5, 41)), new _a2(20, new _a1(11, 16), new _a1(5, 17)), new _a2(24, new _a1(11, 12), new _a1(5, 13))), new _a3(15, new Array(6, 26, 48, 70), new _a2(22, new _a1(5, 87), new _a1(1, 88)), new _a2(24, new _a1(5, 41), new _a1(5, 42)), new _a2(30, new _a1(5, 24), new _a1(7, 25)), new _a2(24, new _a1(11, 12), new _a1(7, 13))), new _a3(16, new Array(6, 26, 50, 74), new _a2(24, new _a1(5, 98), new _a1(1, 99)), new _a2(28, new _a1(7, 45), new _a1(3, 46)), new _a2(24, new _a1(15, 19), new _a1(2, 20)), new _a2(30, new _a1(3, 15), new _a1(13, 16))), new _a3(17, new Array(6, 30, 54, 78), new _a2(28, new _a1(1, 107), new _a1(5, 108)), new _a2(28, new _a1(10, 46), new _a1(1, 47)), new _a2(28, new _a1(1, 22), new _a1(15, 23)), new _a2(28, new _a1(2, 14), new _a1(17, 15))), new _a3(18, new Array(6, 30, 56, 82), new _a2(30, new _a1(5, 120), new _a1(1, 121)), new _a2(26, new _a1(9, 43), new _a1(4, 44)), new _a2(28, new _a1(17, 22), new _a1(1, 23)), new _a2(28, new _a1(2, 14), new _a1(19, 15))), new _a3(19, new Array(6, 30, 58, 86), new _a2(28, new _a1(3, 113), new _a1(4, 114)), new _a2(26, new _a1(3, 44), new _a1(11, 45)), new _a2(26, new _a1(17, 21), new _a1(4, 22)), new _a2(26, new _a1(9, 13), new _a1(16, 14))), new _a3(20, new Array(6, 34, 62, 90), new _a2(28, new _a1(3, 107), new _a1(5, 108)), new _a2(26, new _a1(3, 41), new _a1(13, 42)), new _a2(30, new _a1(15, 24), new _a1(5, 25)), new _a2(28, new _a1(15, 15), new _a1(10, 16))), new _a3(21, new Array(6, 28, 50, 72, 94), new _a2(28, new _a1(4, 116), new _a1(4, 117)), new _a2(26, new _a1(17, 42)), new _a2(28, new _a1(17, 22), new _a1(6, 23)), new _a2(30, new _a1(19, 16), new _a1(6, 17))), new _a3(22, new Array(6, 26, 50, 74, 98), new _a2(28, new _a1(2, 111), new _a1(7, 112)), new _a2(28, new _a1(17, 46)), new _a2(30, new _a1(7, 24), new _a1(16, 25)), new _a2(24, new _a1(34, 13))), new _a3(23, new Array(6, 30, 54, 74, 102), new _a2(30, new _a1(4, 121), new _a1(5, 122)), new _a2(28, new _a1(4, 47), new _a1(14, 48)), new _a2(30, new _a1(11, 24), new _a1(14, 25)), new _a2(30, new _a1(16, 15), new _a1(14, 16))), new _a3(24, new Array(6, 28, 54, 80, 106), new _a2(30, new _a1(6, 117), new _a1(4, 118)), new _a2(28, new _a1(6, 45), new _a1(14, 46)), new _a2(30, new _a1(11, 24), new _a1(16, 25)), new _a2(30, new _a1(30, 16), new _a1(2, 17))), new _a3(25, new Array(6, 32, 58, 84, 110), new _a2(26, new _a1(8, 106), new _a1(4, 107)), new _a2(28, new _a1(8, 47), new _a1(13, 48)), new _a2(30, new _a1(7, 24), new _a1(22, 25)), new _a2(30, new _a1(22, 15), new _a1(13, 16))), new _a3(26, new Array(6, 30, 58, 86, 114), new _a2(28, new _a1(10, 114), new _a1(2, 115)), new _a2(28, new _a1(19, 46), new _a1(4, 47)), new _a2(28, new _a1(28, 22), new _a1(6, 23)), new _a2(30, new _a1(33, 16), new _a1(4, 17))), new _a3(27, new Array(6, 34, 62, 90, 118), new _a2(30, new _a1(8, 122), new _a1(4, 123)), new _a2(28, new _a1(22, 45), new _a1(3, 46)), new _a2(30, new _a1(8, 23), new _a1(26, 24)), new _a2(30, new _a1(12, 15), new _a1(28, 16))), new _a3(28, new Array(6, 26, 50, 74, 98, 122), new _a2(30, new _a1(3, 117), new _a1(10, 118)), new _a2(28, new _a1(3, 45), new _a1(23, 46)), new _a2(30, new _a1(4, 24), new _a1(31, 25)), new _a2(30, new _a1(11, 15), new _a1(31, 16))), new _a3(29, new Array(6, 30, 54, 78, 102, 126), new _a2(30, new _a1(7, 116), new _a1(7, 117)), new _a2(28, new _a1(21, 45), new _a1(7, 46)), new _a2(30, new _a1(1, 23), new _a1(37, 24)), new _a2(30, new _a1(19, 15), new _a1(26, 16))), new _a3(30, new Array(6, 26, 52, 78, 104, 130), new _a2(30, new _a1(5, 115), new _a1(10, 116)), new _a2(28, new _a1(19, 47), new _a1(10, 48)), new _a2(30, new _a1(15, 24), new _a1(25, 25)), new _a2(30, new _a1(23, 15), new _a1(25, 16))), new _a3(31, new Array(6, 30, 56, 82, 108, 134), new _a2(30, new _a1(13, 115), new _a1(3, 116)), new _a2(28, new _a1(2, 46), new _a1(29, 47)), new _a2(30, new _a1(42, 24), new _a1(1, 25)), new _a2(30, new _a1(23, 15), new _a1(28, 16))), new _a3(32, new Array(6, 34, 60, 86, 112, 138), new _a2(30, new _a1(17, 115)), new _a2(28, new _a1(10, 46), new _a1(23, 47)), new _a2(30, new _a1(10, 24), new _a1(35, 25)), new _a2(30, new _a1(19, 15), new _a1(35, 16))), new _a3(33, new Array(6, 30, 58, 86, 114, 142), new _a2(30, new _a1(17, 115), new _a1(1, 116)), new _a2(28, new _a1(14, 46), new _a1(21, 47)), new _a2(30, new _a1(29, 24), new _a1(19, 25)), new _a2(30, new _a1(11, 15), new _a1(46, 16))), new _a3(34, new Array(6, 34, 62, 90, 118, 146), new _a2(30, new _a1(13, 115), new _a1(6, 116)), new _a2(28, new _a1(14, 46), new _a1(23, 47)), new _a2(30, new _a1(44, 24), new _a1(7, 25)), new _a2(30, new _a1(59, 16), new _a1(1, 17))), new _a3(35, new Array(6, 30, 54, 78, 102, 126, 150), new _a2(30, new _a1(12, 121), new _a1(7, 122)), new _a2(28, new _a1(12, 47), new _a1(26, 48)), new _a2(30, new _a1(39, 24), new _a1(14, 25)), new _a2(30, new _a1(22, 15), new _a1(41, 16))), new _a3(36, new Array(6, 24, 50, 76, 102, 128, 154), new _a2(30, new _a1(6, 121), new _a1(14, 122)), new _a2(28, new _a1(6, 47), new _a1(34, 48)), new _a2(30, new _a1(46, 24), new _a1(10, 25)), new _a2(30, new _a1(2, 15), new _a1(64, 16))), new _a3(37, new Array(6, 28, 54, 80, 106, 132, 158), new _a2(30, new _a1(17, 122), new _a1(4, 123)), new _a2(28, new _a1(29, 46), new _a1(14, 47)), new _a2(30, new _a1(49, 24), new _a1(10, 25)), new _a2(30, new _a1(24, 15), new _a1(46, 16))), new _a3(38, new Array(6, 32, 58, 84, 110, 136, 162), new _a2(30, new _a1(4, 122), new _a1(18, 123)), new _a2(28, new _a1(13, 46), new _a1(32, 47)), new _a2(30, new _a1(48, 24), new _a1(14, 25)), new _a2(30, new _a1(42, 15), new _a1(32, 16))), new _a3(39, new Array(6, 26, 54, 82, 110, 138, 166), new _a2(30, new _a1(20, 117), new _a1(4, 118)), new _a2(28, new _a1(40, 47), new _a1(7, 48)), new _a2(30, new _a1(43, 24), new _a1(22, 25)), new _a2(30, new _a1(10, 15), new _a1(67, 16))), new _a3(40, new Array(6, 30, 58, 86, 114, 142, 170), new _a2(30, new _a1(19, 118), new _a1(6, 119)), new _a2(28, new _a1(18, 47), new _a1(31, 48)), new _a2(30, new _a1(34, 24), new _a1(34, 25)), new _a2(30, new _a1(20, 15), new _a1(61, 16))))
219 | }
220 |
221 | function _ae(i, f, c, h, e, b, g, d, a) {
222 | this.a11 = i;
223 | this.a12 = h;
224 | this.a13 = g;
225 | this.a21 = f;
226 | this.a22 = e;
227 | this.a23 = d;
228 | this.a31 = c;
229 | this.a32 = b;
230 | this.a33 = a;
231 | this._ad = function (v) {
232 | var s = v.length;
233 | var z = this.a11;
234 | var w = this.a12;
235 | var u = this.a13;
236 | var q = this.a21;
237 | var p = this.a22;
238 | var o = this.a23;
239 | var m = this.a31;
240 | var k = this.a32;
241 | var j = this.a33;
242 | for (var n = 0; n < s; n += 2) {
243 | var t = v[n];
244 | var r = v[n + 1];
245 | var l = u * t + o * r + j;
246 | v[n] = (z * t + q * r + m) / l;
247 | v[n + 1] = (w * t + p * r + k) / l
248 | }
249 | };
250 | this._fp = function (m, k) {
251 | var q = m.length;
252 | for (var l = 0; l < q; l++) {
253 | var j = m[l];
254 | var p = k[l];
255 | var o = this.a13 * j + this.a23 * p + this.a33;
256 | m[l] = (this.a11 * j + this.a21 * p + this.a31) / o;
257 | k[l] = (this.a12 * j + this.a22 * p + this.a32) / o
258 | }
259 | };
260 | this._fr = function () {
261 | return new _ae(this.a22 * this.a33 - this.a23 * this.a32, this.a23 * this.a31 - this.a21 * this.a33, this.a21 * this.a32 - this.a22 * this.a31, this.a13 * this.a32 - this.a12 * this.a33, this.a11 * this.a33 - this.a13 * this.a31, this.a12 * this.a31 - this.a11 * this.a32, this.a12 * this.a23 - this.a13 * this.a22, this.a13 * this.a21 - this.a11 * this.a23, this.a11 * this.a22 - this.a12 * this.a21)
262 | };
263 | this.times = function (j) {
264 | return new _ae(this.a11 * j.a11 + this.a21 * j.a12 + this.a31 * j.a13, this.a11 * j.a21 + this.a21 * j.a22 + this.a31 * j.a23, this.a11 * j.a31 + this.a21 * j.a32 + this.a31 * j.a33, this.a12 * j.a11 + this.a22 * j.a12 + this.a32 * j.a13, this.a12 * j.a21 + this.a22 * j.a22 + this.a32 * j.a23, this.a12 * j.a31 + this.a22 * j.a32 + this.a32 * j.a33, this.a13 * j.a11 + this.a23 * j.a12 + this.a33 * j.a13, this.a13 * j.a21 + this.a23 * j.a22 + this.a33 * j.a23, this.a13 * j.a31 + this.a23 * j.a32 + this.a33 * j.a33)
265 | }
266 | }
267 |
268 | _ae._ag = function (p, e, o, d, n, c, m, b, h, q, l, f, a, j, i, r) {
269 | var g = this._be(p, e, o, d, n, c, m, b);
270 | var k = this._bf(h, q, l, f, a, j, i, r);
271 | return k.times(g)
272 | };
273 | _ae._bf = function (d, p, c, m, b, k, a, j) {
274 | var h = j - k;
275 | var f = p - m + k - j;
276 | if (h == 0 && f == 0) {
277 | return new _ae(c - d, b - c, d, m - p, k - m, p, 0, 0, 1)
278 | } else {
279 | var q = c - b;
280 | var o = a - b;
281 | var l = d - c + b - a;
282 | var i = m - k;
283 | var e = q * h - o * i;
284 | var n = (l * h - o * f) / e;
285 | var g = (q * f - l * i) / e;
286 | return new _ae(c - d + n * c, a - d + g * a, d, m - p + n * m, j - p + g * j, p, n, g, 1)
287 | }
288 | };
289 | _ae._be = function (f, h, d, g, b, e, a, c) {
290 | return this._bf(f, h, d, g, b, e, a, c)._fr()
291 | };
292 |
293 | function _bg(b, a) {
294 | this.bits = b;
295 | this.points = a
296 | }
297 |
298 | function Detector(a) {
299 | this.image = a;
300 | this._am = null;
301 | this._bi = function (m, l, c, b) {
302 | var d = Math.abs(b - l) > Math.abs(c - m);
303 | if (d) {
304 | var r = m;
305 | m = l;
306 | l = r;
307 | r = c;
308 | c = b;
309 | b = r
310 | }
311 | var j = Math.abs(c - m);
312 | var i = Math.abs(b - l);
313 | var p = -j >> 1;
314 | var u = l < b ? 1 : -1;
315 | var f = m < c ? 1 : -1;
316 | var e = 0;
317 | for (var h = m, g = l; h != c; h += f) {
318 | var t = d ? g : h;
319 | var s = d ? h : g;
320 | if (e == 1) {
321 | if (this.image[t + s * qrcode.width]) {
322 | e++
323 | }
324 | } else {
325 | if (!this.image[t + s * qrcode.width]) {
326 | e++
327 | }
328 | }
329 | if (e == 3) {
330 | var o = h - m;
331 | var n = g - l;
332 | return Math.sqrt((o * o + n * n))
333 | }
334 | p += i;
335 | if (p > 0) {
336 | if (g == b) {
337 | break
338 | }
339 | g += u;
340 | p -= j
341 | }
342 | }
343 | var k = c - m;
344 | var q = b - l;
345 | return Math.sqrt((k * k + q * q))
346 | };
347 | this._bh = function (i, g, h, f) {
348 | var b = this._bi(i, g, h, f);
349 | var e = 1;
350 | var d = i - (h - i);
351 | if (d < 0) {
352 | e = i / (i - d);
353 | d = 0
354 | } else {
355 | if (d >= qrcode.width) {
356 | e = (qrcode.width - 1 - i) / (d - i);
357 | d = qrcode.width - 1
358 | }
359 | }
360 | var c = Math.floor(g - (f - g) * e);
361 | e = 1;
362 | if (c < 0) {
363 | e = g / (g - c);
364 | c = 0
365 | } else {
366 | if (c >= qrcode.height) {
367 | e = (qrcode.height - 1 - g) / (c - g);
368 | c = qrcode.height - 1
369 | }
370 | }
371 | d = Math.floor(i + (d - i) * e);
372 | b += this._bi(i, g, d, c);
373 | return b - 1
374 | };
375 | this._bj = function (c, d) {
376 | var b = this._bh(Math.floor(c.X), Math.floor(c.Y), Math.floor(d.X), Math.floor(d.Y));
377 | var e = this._bh(Math.floor(d.X), Math.floor(d.Y), Math.floor(c.X), Math.floor(c.Y));
378 | if (isNaN(b)) {
379 | return e / 7
380 | }
381 | if (isNaN(e)) {
382 | return b / 7
383 | }
384 | return (b + e) / 14
385 | };
386 | this._bk = function (d, c, b) {
387 | return (this._bj(d, c) + this._bj(d, b)) / 2
388 | };
389 | this.distance = function (d, b) {
390 | var e = d.X - b.X;
391 | var c = d.Y - b.Y;
392 | return Math.sqrt((e * e + c * c))
393 | };
394 | this._bx = function (g, f, d, e) {
395 | var b = Math.round(this.distance(g, f) / e);
396 | var c = Math.round(this.distance(g, d) / e);
397 | var h = ((b + c) >> 1) + 7;
398 | switch (h & 3) {
399 | case 0:
400 | h++;
401 | break;
402 | case 2:
403 | h--;
404 | break;
405 | case 3:
406 | throw"Error"
407 | }
408 | return h
409 | };
410 | this._bl = function (g, f, d, j) {
411 | var k = Math.floor(j * g);
412 | var h = Math.max(0, f - k);
413 | var i = Math.min(qrcode.width - 1, f + k);
414 | if (i - h < g * 3) {
415 | throw"Error"
416 | }
417 | var b = Math.max(0, d - k);
418 | var c = Math.min(qrcode.height - 1, d + k);
419 | var e = new _ak(this.image, h, b, i - h, c - b, g, this._am);
420 | return e.find()
421 | };
422 | this.createTransform = function (l, h, k, b, g) {
423 | var j = g - 3.5;
424 | var i;
425 | var f;
426 | var e;
427 | var c;
428 | if (b != null) {
429 | i = b.X;
430 | f = b.Y;
431 | e = c = j - 3
432 | } else {
433 | i = (h.X - l.X) + k.X;
434 | f = (h.Y - l.Y) + k.Y;
435 | e = c = j
436 | }
437 | var d = _ae._ag(3.5, 3.5, j, 3.5, e, c, 3.5, j, l.X, l.Y, h.X, h.Y, i, f, k.X, k.Y);
438 | return d
439 | };
440 | this._bz = function (e, b, d) {
441 | var c = _aa;
442 | return c._af(e, d, b)
443 | };
444 | this._cd = function (q) {
445 | var j = q._gq;
446 | var h = q._gs;
447 | var n = q._gp;
448 | var d = this._bk(j, h, n);
449 | if (d < 1) {
450 | throw"Error"
451 | }
452 | var r = this._bx(j, h, n, d);
453 | var b = _a3._at(r);
454 | var k = b._cr - 7;
455 | var l = null;
456 | if (b._as.length > 0) {
457 | var f = h.X - j.X + n.X;
458 | var e = h.Y - j.Y + n.Y;
459 | var c = 1 - 3 / k;
460 | var t = Math.floor(j.X + c * (f - j.X));
461 | var s = Math.floor(j.Y + c * (e - j.Y));
462 | for (var p = 4; p <= 16; p <<= 1) {
463 | l = this._bl(d, t, s, p);
464 | break
465 | }
466 | }
467 | var g = this.createTransform(j, h, n, l, r);
468 | var m = this._bz(this.image, g, r);
469 | var o;
470 | if (l == null) {
471 | o = new Array(n, j, h)
472 | } else {
473 | o = new Array(n, j, h, l)
474 | }
475 | return new _bg(m, o)
476 | };
477 | this.detect = function () {
478 | var b = new _cc()._ce(this.image);
479 | return this._cd(b)
480 | }
481 | }
482 |
483 | var _ca = 21522;
484 | var _cb = new Array(new Array(21522, 0), new Array(20773, 1), new Array(24188, 2), new Array(23371, 3), new Array(17913, 4), new Array(16590, 5), new Array(20375, 6), new Array(19104, 7), new Array(30660, 8), new Array(29427, 9), new Array(32170, 10), new Array(30877, 11), new Array(26159, 12), new Array(25368, 13), new Array(27713, 14), new Array(26998, 15), new Array(5769, 16), new Array(5054, 17), new Array(7399, 18), new Array(6608, 19), new Array(1890, 20), new Array(597, 21), new Array(3340, 22), new Array(2107, 23), new Array(13663, 24), new Array(12392, 25), new Array(16177, 26), new Array(14854, 27), new Array(9396, 28), new Array(8579, 29), new Array(11994, 30), new Array(11245, 31));
485 | var _ch = new Array(0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4);
486 |
487 | function _ax(a) {
488 | this._cf = _cg.forBits((a >> 3) & 3);
489 | this._fe = (a & 7);
490 | this.__defineGetter__("_cg", function () {
491 | return this._cf
492 | });
493 | this.__defineGetter__("_dx", function () {
494 | return this._fe
495 | });
496 | this.GetHashCode = function () {
497 | return (this._cf.ordinal() << 3) | this._fe
498 | };
499 | this.Equals = function (c) {
500 | var b = c;
501 | return this._cf == b._cf && this._fe == b._fe
502 | }
503 | }
504 |
505 | _ax._gj = function (d, c) {
506 | d ^= c;
507 | return _ch[d & 15] + _ch[(_ew(d, 4) & 15)] + _ch[(_ew(d, 8) & 15)] + _ch[(_ew(d, 12) & 15)] + _ch[(_ew(d, 16) & 15)] + _ch[(_ew(d, 20) & 15)] + _ch[(_ew(d, 24) & 15)] + _ch[(_ew(d, 28) & 15)]
508 | };
509 | _ax._ci = function (a) {
510 | var b = _ax._cj(a);
511 | if (b != null) {
512 | return b
513 | }
514 | return _ax._cj(a ^ _ca)
515 | };
516 | _ax._cj = function (d) {
517 | var b = 4294967295;
518 | var a = 0;
519 | for (var c = 0; c < _cb.length; c++) {
520 | var g = _cb[c];
521 | var f = g[0];
522 | if (f == d) {
523 | return new _ax(g[1])
524 | }
525 | var e = this._gj(d, f);
526 | if (e < b) {
527 | a = g[1];
528 | b = e
529 | }
530 | }
531 | if (b <= 3) {
532 | return new _ax(a)
533 | }
534 | return null
535 | };
536 |
537 | function _cg(a, c, b) {
538 | this._ff = a;
539 | this.bits = c;
540 | this.name = b;
541 | this.__defineGetter__("Bits", function () {
542 | return this.bits
543 | });
544 | this.__defineGetter__("Name", function () {
545 | return this.name
546 | });
547 | this.ordinal = function () {
548 | return this._ff
549 | }
550 | }
551 |
552 | _cg.forBits = function (a) {
553 | if (a < 0 || a >= FOR_BITS.length) {
554 | throw"bad arguments"
555 | }
556 | return FOR_BITS[a]
557 | };
558 | var L = new _cg(0, 1, "L");
559 | var M = new _cg(1, 0, "M");
560 | var Q = new _cg(2, 3, "Q");
561 | var H = new _cg(3, 2, "H");
562 | var FOR_BITS = new Array(M, L, H, Q);
563 |
564 | function _ac(d, a) {
565 | if (!a) {
566 | a = d
567 | }
568 | if (d < 1 || a < 1) {
569 | throw"Both dimensions must be greater than 0"
570 | }
571 | this.width = d;
572 | this.height = a;
573 | var c = d >> 5;
574 | if ((d & 31) != 0) {
575 | c++
576 | }
577 | this.rowSize = c;
578 | this.bits = new Array(c * a);
579 | for (var b = 0; b < this.bits.length; b++) {
580 | this.bits[b] = 0
581 | }
582 | this.__defineGetter__("Width", function () {
583 | return this.width
584 | });
585 | this.__defineGetter__("Height", function () {
586 | return this.height
587 | });
588 | this.__defineGetter__("Dimension", function () {
589 | if (this.width != this.height) {
590 | throw"Can't call getDimension() on a non-square matrix"
591 | }
592 | return this.width
593 | });
594 | this._ds = function (e, g) {
595 | var f = g * this.rowSize + (e >> 5);
596 | return ((_ew(this.bits[f], (e & 31))) & 1) != 0
597 | };
598 | this._dq = function (e, g) {
599 | var f = g * this.rowSize + (e >> 5);
600 | this.bits[f] |= 1 << (e & 31)
601 | };
602 | this.flip = function (e, g) {
603 | var f = g * this.rowSize + (e >> 5);
604 | this.bits[f] ^= 1 << (e & 31)
605 | };
606 | this.clear = function () {
607 | var e = this.bits.length;
608 | for (var f = 0; f < e; f++) {
609 | this.bits[f] = 0
610 | }
611 | };
612 | this._bq = function (g, j, f, m) {
613 | if (j < 0 || g < 0) {
614 | throw"Left and top must be nonnegative"
615 | }
616 | if (m < 1 || f < 1) {
617 | throw"Height and width must be at least 1"
618 | }
619 | var l = g + f;
620 | var e = j + m;
621 | if (e > this.height || l > this.width) {
622 | throw"The region must fit inside the matrix"
623 | }
624 | for (var i = j; i < e; i++) {
625 | var h = i * this.rowSize;
626 | for (var k = g; k < l; k++) {
627 | this.bits[h + (k >> 5)] |= 1 << (k & 31)
628 | }
629 | }
630 | }
631 | }
632 |
633 | function _dl(a, b) {
634 | this._dv = a;
635 | this._dw = b;
636 | this.__defineGetter__("_du", function () {
637 | return this._dv
638 | });
639 | this.__defineGetter__("Codewords", function () {
640 | return this._dw
641 | })
642 | }
643 |
644 | _dl._gn = function (c, h, r) {
645 | if (c.length != h._dp) {
646 | throw"bad arguments"
647 | }
648 | var k = h._bu(r);
649 | var e = 0;
650 | var d = k._fb();
651 | for (var q = 0; q < d.length; q++) {
652 | e += d[q].Count
653 | }
654 | var l = new Array(e);
655 | var n = 0;
656 | for (var o = 0; o < d.length; o++) {
657 | var f = d[o];
658 | for (var q = 0; q < f.Count; q++) {
659 | var m = f._dm;
660 | var s = k._bo + m;
661 | l[n++] = new _dl(m, new Array(s))
662 | }
663 | }
664 | var t = l[0]._dw.length;
665 | var b = l.length - 1;
666 | while (b >= 0) {
667 | var v = l[b]._dw.length;
668 | if (v == t) {
669 | break
670 | }
671 | b--
672 | }
673 | b++;
674 | var g = t - k._bo;
675 | var a = 0;
676 | for (var q = 0; q < g; q++) {
677 | for (var o = 0; o < n; o++) {
678 | l[o]._dw[q] = c[a++]
679 | }
680 | }
681 | for (var o = b; o < n; o++) {
682 | l[o]._dw[g] = c[a++]
683 | }
684 | var p = l[0]._dw.length;
685 | for (var q = g; q < p; q++) {
686 | for (var o = 0; o < n; o++) {
687 | var u = o < b ? q : q + 1;
688 | l[o]._dw[u] = c[a++]
689 | }
690 | }
691 | return l
692 | };
693 |
694 | function _cl(a) {
695 | var b = a.Dimension;
696 | if (b < 21 || (b & 3) != 1) {
697 | throw"Error _cl"
698 | }
699 | this._au = a;
700 | this._cp = null;
701 | this._co = null;
702 | this._dk = function (d, c, e) {
703 | return this._au._ds(d, c) ? (e << 1) | 1 : e << 1
704 | };
705 | this._cm = function () {
706 | if (this._co != null) {
707 | return this._co
708 | }
709 | var g = 0;
710 | for (var e = 0; e < 6; e++) {
711 | g = this._dk(e, 8, g)
712 | }
713 | g = this._dk(7, 8, g);
714 | g = this._dk(8, 8, g);
715 | g = this._dk(8, 7, g);
716 | for (var c = 5; c >= 0; c--) {
717 | g = this._dk(8, c, g)
718 | }
719 | this._co = _ax._ci(g);
720 | if (this._co != null) {
721 | return this._co
722 | }
723 | var f = this._au.Dimension;
724 | g = 0;
725 | var d = f - 8;
726 | for (var e = f - 1; e >= d; e--) {
727 | g = this._dk(e, 8, g)
728 | }
729 | for (var c = f - 7; c < f; c++) {
730 | g = this._dk(8, c, g)
731 | }
732 | this._co = _ax._ci(g);
733 | if (this._co != null) {
734 | return this._co
735 | }
736 | throw"Error _cm"
737 | };
738 | this._cq = function () {
739 | if (this._cp != null) {
740 | return this._cp
741 | }
742 | var h = this._au.Dimension;
743 | var f = (h - 17) >> 2;
744 | if (f <= 6) {
745 | return _a3._av(f)
746 | }
747 | var g = 0;
748 | var e = h - 11;
749 | for (var c = 5; c >= 0; c--) {
750 | for (var d = h - 9; d >= e; d--) {
751 | g = this._dk(d, c, g)
752 | }
753 | }
754 | this._cp = _a3._aw(g);
755 | if (this._cp != null && this._cp._cr == h) {
756 | return this._cp
757 | }
758 | g = 0;
759 | for (var d = 5; d >= 0; d--) {
760 | for (var c = h - 9; c >= e; c--) {
761 | g = this._dk(d, c, g)
762 | }
763 | }
764 | this._cp = _a3._aw(g);
765 | if (this._cp != null && this._cp._cr == h) {
766 | return this._cp
767 | }
768 | throw"Error _cq"
769 | };
770 | this._gk = function () {
771 | var q = this._cm();
772 | var o = this._cq();
773 | var c = _dx._gl(q._dx);
774 | var f = this._au.Dimension;
775 | c._dj(this._au, f);
776 | var k = o._aq();
777 | var n = true;
778 | var r = new Array(o._dp);
779 | var m = 0;
780 | var p = 0;
781 | var h = 0;
782 | for (var e = f - 1; e > 0; e -= 2) {
783 | if (e == 6) {
784 | e--
785 | }
786 | for (var l = 0; l < f; l++) {
787 | var g = n ? f - 1 - l : l;
788 | for (var d = 0; d < 2; d++) {
789 | if (!k._ds(e - d, g)) {
790 | h++;
791 | p <<= 1;
792 | if (this._au._ds(e - d, g)) {
793 | p |= 1
794 | }
795 | if (h == 8) {
796 | r[m++] = p;
797 | h = 0;
798 | p = 0
799 | }
800 | }
801 | }
802 | }
803 | n ^= true
804 | }
805 | if (m != o._dp) {
806 | throw"Error _gk"
807 | }
808 | return r
809 | }
810 | }
811 |
812 | var _dx = {};
813 | _dx._gl = function (a) {
814 | if (a < 0 || a > 7) {
815 | throw"bad arguments"
816 | }
817 | return _dx._dy[a]
818 | };
819 |
820 | function _fg() {
821 | this._dj = function (c, d) {
822 | for (var b = 0; b < d; b++) {
823 | for (var a = 0; a < d; a++) {
824 | if (this._fw(b, a)) {
825 | c.flip(a, b)
826 | }
827 | }
828 | }
829 | };
830 | this._fw = function (b, a) {
831 | return ((b + a) & 1) == 0
832 | }
833 | }
834 |
835 | function _fh() {
836 | this._dj = function (c, d) {
837 | for (var b = 0; b < d; b++) {
838 | for (var a = 0; a < d; a++) {
839 | if (this._fw(b, a)) {
840 | c.flip(a, b)
841 | }
842 | }
843 | }
844 | };
845 | this._fw = function (b, a) {
846 | return (b & 1) == 0
847 | }
848 | }
849 |
850 | function _fi() {
851 | this._dj = function (c, d) {
852 | for (var b = 0; b < d; b++) {
853 | for (var a = 0; a < d; a++) {
854 | if (this._fw(b, a)) {
855 | c.flip(a, b)
856 | }
857 | }
858 | }
859 | };
860 | this._fw = function (b, a) {
861 | return a % 3 == 0
862 | }
863 | }
864 |
865 | function _fj() {
866 | this._dj = function (c, d) {
867 | for (var b = 0; b < d; b++) {
868 | for (var a = 0; a < d; a++) {
869 | if (this._fw(b, a)) {
870 | c.flip(a, b)
871 | }
872 | }
873 | }
874 | };
875 | this._fw = function (b, a) {
876 | return (b + a) % 3 == 0
877 | }
878 | }
879 |
880 | function _fk() {
881 | this._dj = function (c, d) {
882 | for (var b = 0; b < d; b++) {
883 | for (var a = 0; a < d; a++) {
884 | if (this._fw(b, a)) {
885 | c.flip(a, b)
886 | }
887 | }
888 | }
889 | };
890 | this._fw = function (b, a) {
891 | return (((_ew(b, 1)) + (a / 3)) & 1) == 0
892 | }
893 | }
894 |
895 | function _fl() {
896 | this._dj = function (c, d) {
897 | for (var b = 0; b < d; b++) {
898 | for (var a = 0; a < d; a++) {
899 | if (this._fw(b, a)) {
900 | c.flip(a, b)
901 | }
902 | }
903 | }
904 | };
905 | this._fw = function (c, b) {
906 | var a = c * b;
907 | return (a & 1) + (a % 3) == 0
908 | }
909 | }
910 |
911 | function _fm() {
912 | this._dj = function (c, d) {
913 | for (var b = 0; b < d; b++) {
914 | for (var a = 0; a < d; a++) {
915 | if (this._fw(b, a)) {
916 | c.flip(a, b)
917 | }
918 | }
919 | }
920 | };
921 | this._fw = function (c, b) {
922 | var a = c * b;
923 | return (((a & 1) + (a % 3)) & 1) == 0
924 | }
925 | }
926 |
927 | function _fn() {
928 | this._dj = function (c, d) {
929 | for (var b = 0; b < d; b++) {
930 | for (var a = 0; a < d; a++) {
931 | if (this._fw(b, a)) {
932 | c.flip(a, b)
933 | }
934 | }
935 | }
936 | };
937 | this._fw = function (b, a) {
938 | return ((((b + a) & 1) + ((b * a) % 3)) & 1) == 0
939 | }
940 | }
941 |
942 | _dx._dy = new Array(new _fg(), new _fh(), new _fi(), new _fj(), new _fk(), new _fl(), new _fm(), new _fn());
943 |
944 | function _db(a) {
945 | this._fa = a;
946 | this.decode = function (j, f) {
947 | var c = new _bp(this._fa, j);
948 | var p = new Array(f);
949 | for (var g = 0; g < p.length; g++) {
950 | p[g] = 0
951 | }
952 | var m = false;
953 | var d = true;
954 | for (var g = 0; g < f; g++) {
955 | var q = c.evaluateAt(this._fa.exp(m ? g + 1 : g));
956 | p[p.length - 1 - g] = q;
957 | if (q != 0) {
958 | d = false
959 | }
960 | }
961 | if (d) {
962 | return
963 | }
964 | var b = new _bp(this._fa, p);
965 | var l = this._eb(this._fa._ba(f, 1), b, f);
966 | var o = l[0];
967 | var n = l[1];
968 | var k = this._ey(o);
969 | var e = this._di(n, k, m);
970 | for (var g = 0; g < k.length; g++) {
971 | var h = j.length - 1 - this._fa.log(k[g]);
972 | if (h < 0) {
973 | throw"ReedSolomonException Bad error location"
974 | }
975 | j[h] = _az._bd(j[h], e[g])
976 | }
977 | };
978 | this._eb = function (z, y, f) {
979 | if (z._ec < y._ec) {
980 | var w = z;
981 | z = y;
982 | y = w
983 | }
984 | var B = z;
985 | var k = y;
986 | var o = this._fa.One;
987 | var j = this._fa.Zero;
988 | var e = this._fa.Zero;
989 | var i = this._fa.One;
990 | while (k._ec >= Math.floor(f / 2)) {
991 | var x = B;
992 | var g = o;
993 | var v = e;
994 | B = k;
995 | o = j;
996 | e = i;
997 | if (B.Zero) {
998 | throw"r_{i-1} was zero"
999 | }
1000 | k = x;
1001 | var m = this._fa.Zero;
1002 | var p = B._ex(B._ec);
1003 | var h = this._fa.inverse(p);
1004 | while (k._ec >= B._ec && !k.Zero) {
1005 | var c = k._ec - B._ec;
1006 | var A = this._fa.multiply(k._ex(k._ec), h);
1007 | m = m._bd(this._fa._ba(c, A));
1008 | k = k._bd(B._dc(c, A))
1009 | }
1010 | j = m.multiply1(o)._bd(g);
1011 | i = m.multiply1(e)._bd(v)
1012 | }
1013 | var u = i._ex(0);
1014 | if (u == 0) {
1015 | throw"ReedSolomonException sigmaTilde(0) was zero"
1016 | }
1017 | var d = this._fa.inverse(u);
1018 | var n = i.multiply2(d);
1019 | var l = k.multiply2(d);
1020 | return new Array(n, l)
1021 | };
1022 | this._ey = function (f) {
1023 | var g = f._ec;
1024 | if (g == 1) {
1025 | return new Array(f._ex(1))
1026 | }
1027 | var b = new Array(g);
1028 | var d = 0;
1029 | for (var c = 1; c < 256 && d < g; c++) {
1030 | if (f.evaluateAt(c) == 0) {
1031 | b[d] = this._fa.inverse(c);
1032 | d++
1033 | }
1034 | }
1035 | if (d != g) {
1036 | throw"Error locator degree does not match number of roots"
1037 | }
1038 | return b
1039 | };
1040 | this._di = function (f, h, g) {
1041 | var k = h.length;
1042 | var l = new Array(k);
1043 | for (var e = 0; e < k; e++) {
1044 | var b = this._fa.inverse(h[e]);
1045 | var c = 1;
1046 | for (var d = 0; d < k; d++) {
1047 | if (e != d) {
1048 | c = this._fa.multiply(c, _az._bd(1, this._fa.multiply(h[d], b)))
1049 | }
1050 | }
1051 | l[e] = this._fa.multiply(f.evaluateAt(b), this._fa.inverse(c));
1052 | if (g) {
1053 | l[e] = this._fa.multiply(l[e], b)
1054 | }
1055 | }
1056 | return l
1057 | }
1058 | }
1059 |
1060 | function _bp(f, e) {
1061 | if (e == null || e.length == 0) {
1062 | throw"bad arguments"
1063 | }
1064 | this._fa = f;
1065 | var c = e.length;
1066 | if (c > 1 && e[0] == 0) {
1067 | var d = 1;
1068 | while (d < c && e[d] == 0) {
1069 | d++
1070 | }
1071 | if (d == c) {
1072 | this._dd = f.Zero._dd
1073 | } else {
1074 | this._dd = new Array(c - d);
1075 | for (var b = 0; b < this._dd.length; b++) {
1076 | this._dd[b] = 0
1077 | }
1078 | for (var a = 0; a < this._dd.length; a++) {
1079 | this._dd[a] = e[d + a]
1080 | }
1081 | }
1082 | } else {
1083 | this._dd = e
1084 | }
1085 | this.__defineGetter__("Zero", function () {
1086 | return this._dd[0] == 0
1087 | });
1088 | this.__defineGetter__("_ec", function () {
1089 | return this._dd.length - 1
1090 | });
1091 | this.__defineGetter__("Coefficients", function () {
1092 | return this._dd
1093 | });
1094 | this._ex = function (g) {
1095 | return this._dd[this._dd.length - 1 - g]
1096 | };
1097 | this.evaluateAt = function (h) {
1098 | if (h == 0) {
1099 | return this._ex(0)
1100 | }
1101 | var l = this._dd.length;
1102 | if (h == 1) {
1103 | var g = 0;
1104 | for (var k = 0; k < l; k++) {
1105 | g = _az._bd(g, this._dd[k])
1106 | }
1107 | return g
1108 | }
1109 | var j = this._dd[0];
1110 | for (var k = 1; k < l; k++) {
1111 | j = _az._bd(this._fa.multiply(h, j), this._dd[k])
1112 | }
1113 | return j
1114 | };
1115 | this._bd = function (g) {
1116 | if (this._fa != g._fa) {
1117 | throw"GF256Polys do not have same _az _fa"
1118 | }
1119 | if (this.Zero) {
1120 | return g
1121 | }
1122 | if (g.Zero) {
1123 | return this
1124 | }
1125 | var o = this._dd;
1126 | var n = g._dd;
1127 | if (o.length > n.length) {
1128 | var j = o;
1129 | o = n;
1130 | n = j
1131 | }
1132 | var h = new Array(n.length);
1133 | var k = n.length - o.length;
1134 | for (var m = 0; m < k; m++) {
1135 | h[m] = n[m]
1136 | }
1137 | for (var l = k; l < n.length; l++) {
1138 | h[l] = _az._bd(o[l - k], n[l])
1139 | }
1140 | return new _bp(f, h)
1141 | };
1142 | this.multiply1 = function (o) {
1143 | if (this._fa != o._fa) {
1144 | throw"GF256Polys do not have same _az _fa"
1145 | }
1146 | if (this.Zero || o.Zero) {
1147 | return this._fa.Zero
1148 | }
1149 | var q = this._dd;
1150 | var g = q.length;
1151 | var l = o._dd;
1152 | var n = l.length;
1153 | var p = new Array(g + n - 1);
1154 | for (var m = 0; m < g; m++) {
1155 | var h = q[m];
1156 | for (var k = 0; k < n; k++) {
1157 | p[m + k] = _az._bd(p[m + k], this._fa.multiply(h, l[k]))
1158 | }
1159 | }
1160 | return new _bp(this._fa, p)
1161 | };
1162 | this.multiply2 = function (g) {
1163 | if (g == 0) {
1164 | return this._fa.Zero
1165 | }
1166 | if (g == 1) {
1167 | return this
1168 | }
1169 | var j = this._dd.length;
1170 | var k = new Array(j);
1171 | for (var h = 0; h < j; h++) {
1172 | k[h] = this._fa.multiply(this._dd[h], g)
1173 | }
1174 | return new _bp(this._fa, k)
1175 | };
1176 | this._dc = function (l, g) {
1177 | if (l < 0) {
1178 | throw"bad arguments"
1179 | }
1180 | if (g == 0) {
1181 | return this._fa.Zero
1182 | }
1183 | var j = this._dd.length;
1184 | var k = new Array(j + l);
1185 | for (var h = 0; h < k.length; h++) {
1186 | k[h] = 0
1187 | }
1188 | for (var h = 0; h < j; h++) {
1189 | k[h] = this._fa.multiply(this._dd[h], g)
1190 | }
1191 | return new _bp(this._fa, k)
1192 | };
1193 | this.divide = function (l) {
1194 | if (this._fa != l._fa) {
1195 | throw"GF256Polys do not have same _az _fa"
1196 | }
1197 | if (l.Zero) {
1198 | throw"Divide by 0"
1199 | }
1200 | var j = this._fa.Zero;
1201 | var o = this;
1202 | var g = l._ex(l._ec);
1203 | var n = this._fa.inverse(g);
1204 | while (o._ec >= l._ec && !o.Zero) {
1205 | var m = o._ec - l._ec;
1206 | var h = this._fa.multiply(o._ex(o._ec), n);
1207 | var i = l._dc(m, h);
1208 | var k = this._fa._ba(m, h);
1209 | j = j._bd(k);
1210 | o = o._bd(i)
1211 | }
1212 | return new Array(j, o)
1213 | }
1214 | }
1215 |
1216 | function _az(b) {
1217 | this._gh = new Array(256);
1218 | this._gi = new Array(256);
1219 | var a = 1;
1220 | for (var e = 0; e < 256; e++) {
1221 | this._gh[e] = a;
1222 | a <<= 1;
1223 | if (a >= 256) {
1224 | a ^= b
1225 | }
1226 | }
1227 | for (var e = 0; e < 255; e++) {
1228 | this._gi[this._gh[e]] = e
1229 | }
1230 | var d = new Array(1);
1231 | d[0] = 0;
1232 | this.zero = new _bp(this, new Array(d));
1233 | var c = new Array(1);
1234 | c[0] = 1;
1235 | this.one = new _bp(this, new Array(c));
1236 | this.__defineGetter__("Zero", function () {
1237 | return this.zero
1238 | });
1239 | this.__defineGetter__("One", function () {
1240 | return this.one
1241 | });
1242 | this._ba = function (j, f) {
1243 | if (j < 0) {
1244 | throw"bad arguments"
1245 | }
1246 | if (f == 0) {
1247 | return this.zero
1248 | }
1249 | var h = new Array(j + 1);
1250 | for (var g = 0; g < h.length; g++) {
1251 | h[g] = 0
1252 | }
1253 | h[0] = f;
1254 | return new _bp(this, h)
1255 | };
1256 | this.exp = function (f) {
1257 | return this._gh[f]
1258 | };
1259 | this.log = function (f) {
1260 | if (f == 0) {
1261 | throw"bad arguments"
1262 | }
1263 | return this._gi[f]
1264 | };
1265 | this.inverse = function (f) {
1266 | if (f == 0) {
1267 | throw"System.ArithmeticException"
1268 | }
1269 | return this._gh[255 - this._gi[f]]
1270 | };
1271 | this.multiply = function (g, f) {
1272 | if (g == 0 || f == 0) {
1273 | return 0
1274 | }
1275 | if (g == 1) {
1276 | return f
1277 | }
1278 | if (f == 1) {
1279 | return g
1280 | }
1281 | return this._gh[(this._gi[g] + this._gi[f]) % 255]
1282 | }
1283 | }
1284 |
1285 | _az._bb = new _az(285);
1286 | _az._bc = new _az(301);
1287 | _az._bd = function (d, c) {
1288 | return d ^ c
1289 | };
1290 | var Decoder = {};
1291 | Decoder.rsDecoder = new _db(_az._bb);
1292 | Decoder.correctErrors = function (g, b) {
1293 | var d = g.length;
1294 | var f = new Array(d);
1295 | for (var e = 0; e < d; e++) {
1296 | f[e] = g[e] & 255
1297 | }
1298 | var a = g.length - b;
1299 | try {
1300 | Decoder.rsDecoder.decode(f, a)
1301 | } catch (c) {
1302 | throw c
1303 | }
1304 | for (var e = 0; e < b; e++) {
1305 | g[e] = f[e]
1306 | }
1307 | };
1308 | Decoder.decode = function (q) {
1309 | var b = new _cl(q);
1310 | var o = b._cq();
1311 | var c = b._cm()._cg;
1312 | var p = b._gk();
1313 | var a = _dl._gn(p, o, c);
1314 | var f = 0;
1315 | for (var k = 0; k < a.length; k++) {
1316 | f += a[k]._du
1317 | }
1318 | var e = new Array(f);
1319 | var n = 0;
1320 | for (var h = 0; h < a.length; h++) {
1321 | var m = a[h];
1322 | var d = m.Codewords;
1323 | var g = m._du;
1324 | Decoder.correctErrors(d, g);
1325 | for (var k = 0; k < g; k++) {
1326 | e[n++] = d[k]
1327 | }
1328 | }
1329 | var l = new QRCodeDataBlockReader(e, o._fd, c.Bits);
1330 | return l
1331 | };
1332 | var qrcode = {};
1333 | qrcode.imagedata = null;
1334 | qrcode.width = 0;
1335 | qrcode.height = 0;
1336 | qrcode.qrCodeSymbol = null;
1337 | qrcode.debug = false;
1338 | qrcode.maxImgSize = 1024 * 1024;
1339 | qrcode._eo = [[10, 9, 8, 8], [12, 11, 16, 10], [14, 13, 16, 12]];
1340 | qrcode.callback = null;
1341 | qrcode.vidSuccess = function (a) {
1342 | qrcode.localstream = a;
1343 | if (qrcode.webkit) {
1344 | qrcode.video.src = window.webkitURL.createObjectURL(a)
1345 | } else {
1346 | if (qrcode.moz) {
1347 | qrcode.video.mozSrcObject = a;
1348 | qrcode.video.play()
1349 | } else {
1350 | qrcode.video.src = a
1351 | }
1352 | }
1353 | qrcode.gUM = true;
1354 | qrcode.canvas_qr2 = document.createElement("canvas");
1355 | qrcode.canvas_qr2.id = "qr-canvas";
1356 | qrcode.qrcontext2 = qrcode.canvas_qr2.getContext("2d");
1357 | qrcode.canvas_qr2.width = qrcode.video.videoWidth;
1358 | qrcode.canvas_qr2.height = qrcode.video.videoHeight;
1359 | setTimeout(qrcode.captureToCanvas, 500)
1360 | };
1361 | qrcode.vidError = function (a) {
1362 | qrcode.gUM = false;
1363 | return
1364 | };
1365 | qrcode.captureToCanvas = function () {
1366 | if (qrcode.gUM) {
1367 | try {
1368 | if (qrcode.video.videoWidth == 0) {
1369 | setTimeout(qrcode.captureToCanvas, 500);
1370 | return
1371 | } else {
1372 | qrcode.canvas_qr2.width = qrcode.video.videoWidth;
1373 | qrcode.canvas_qr2.height = qrcode.video.videoHeight
1374 | }
1375 | qrcode.qrcontext2.drawImage(qrcode.video, 0, 0);
1376 | try {
1377 | qrcode.decode()
1378 | } catch (a) {
1379 | console.log(a);
1380 | setTimeout(qrcode.captureToCanvas, 500)
1381 | }
1382 | } catch (a) {
1383 | console.log(a);
1384 | setTimeout(qrcode.captureToCanvas, 500)
1385 | }
1386 | }
1387 | };
1388 | qrcode.setWebcam = function (c) {
1389 | var d = navigator;
1390 | qrcode.video = document.getElementById(c);
1391 | var a = true;
1392 | if (navigator.mediaDevices && navigator.mediaDevices.enumerateDevices) {
1393 | try {
1394 | navigator.mediaDevices.enumerateDevices().then(function (e) {
1395 | e.forEach(function (f) {
1396 | console.log("deb1");
1397 | if (f.kind === "videoinput") {
1398 | if (f.label.toLowerCase().search("back") > -1) {
1399 | a = [{sourceId: f.deviceId}]
1400 | }
1401 | }
1402 | console.log(f.kind + ": " + f.label + " id = " + f.deviceId)
1403 | })
1404 | })
1405 | } catch (b) {
1406 | console.log(b)
1407 | }
1408 | } else {
1409 | console.log("no navigator.mediaDevices.enumerateDevices")
1410 | }
1411 | if (d.getUserMedia) {
1412 | d.getUserMedia({video: a, audio: false}, qrcode.vidSuccess, qrcode.vidError)
1413 | } else {
1414 | if (d.webkitGetUserMedia) {
1415 | qrcode.webkit = true;
1416 | d.webkitGetUserMedia({video: a, audio: false}, qrcode.vidSuccess, qrcode.vidError)
1417 | } else {
1418 | if (d.mozGetUserMedia) {
1419 | qrcode.moz = true;
1420 | d.mozGetUserMedia({video: a, audio: false}, qrcode.vidSuccess, qrcode.vidError)
1421 | }
1422 | }
1423 | }
1424 | };
1425 | qrcode.decode = function (d) {
1426 | if (arguments.length == 0) {
1427 | if (qrcode.canvas_qr2) {
1428 | var b = qrcode.canvas_qr2;
1429 | var a = qrcode.qrcontext2
1430 | } else {
1431 | var b = document.getElementById("qr-canvas");
1432 | var a = b.getContext("2d")
1433 | }
1434 | qrcode.width = b.width;
1435 | qrcode.height = b.height;
1436 | qrcode.imagedata = a.getImageData(0, 0, qrcode.width, qrcode.height);
1437 | qrcode.result = qrcode.process(a);
1438 | if (qrcode.callback != null) {
1439 | qrcode.callback(qrcode.result)
1440 | }
1441 | return qrcode.result
1442 | } else {
1443 | var c = new Image();
1444 | c.crossOrigin = "Anonymous";
1445 | c.onload = function () {
1446 | var g = document.getElementById("out-canvas");
1447 | if (g != null) {
1448 | var j = g.getContext("2d");
1449 | j.clearRect(0, 0, 320, 240);
1450 | j.drawImage(c, 0, 0, 320, 240)
1451 | }
1452 | var i = document.createElement("canvas");
1453 | var h = i.getContext("2d");
1454 | var f = c.height;
1455 | var l = c.width;
1456 | if (c.width * c.height > qrcode.maxImgSize) {
1457 | var k = c.width / c.height;
1458 | f = Math.sqrt(qrcode.maxImgSize / k);
1459 | l = k * f
1460 | }
1461 | i.width = l;
1462 | i.height = f;
1463 | h.drawImage(c, 0, 0, i.width, i.height);
1464 | qrcode.width = i.width;
1465 | qrcode.height = i.height;
1466 | try {
1467 | qrcode.imagedata = h.getImageData(0, 0, i.width, i.height)
1468 | } catch (m) {
1469 | qrcode.result = "Cross domain image reading not supported in your browser! Save it to your computer then drag and drop the file!";
1470 | if (qrcode.callback != null) {
1471 | qrcode.callback(qrcode.result)
1472 | }
1473 | return
1474 | }
1475 | try {
1476 | qrcode.result = qrcode.process(h)
1477 | } catch (m) {
1478 | console.log(m);
1479 | qrcode.result = "error decoding QR Code"
1480 | }
1481 | if (qrcode.callback != null) {
1482 | qrcode.callback(qrcode.result)
1483 | }
1484 | };
1485 | c.onerror = function () {
1486 | if (qrcode.callback != null) {
1487 | qrcode.callback("Failed to load the image")
1488 | }
1489 | };
1490 | c.src = d
1491 | }
1492 | };
1493 | qrcode.isUrl = function (a) {
1494 | var b = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
1495 | return b.test(a)
1496 | };
1497 | qrcode.decode_url = function (b) {
1498 | var d = "";
1499 | try {
1500 | d = escape(b)
1501 | } catch (c) {
1502 | console.log(c);
1503 | d = b
1504 | }
1505 | var a = "";
1506 | try {
1507 | a = decodeURIComponent(d)
1508 | } catch (c) {
1509 | console.log(c);
1510 | a = d
1511 | }
1512 | return a
1513 | };
1514 | qrcode.decode_utf8 = function (a) {
1515 | if (qrcode.isUrl(a)) {
1516 | return qrcode.decode_url(a)
1517 | } else {
1518 | return a
1519 | }
1520 | };
1521 | qrcode.process = function (q) {
1522 | var a = new Date().getTime();
1523 | var c = qrcode.grayScaleToBitmap(qrcode.grayscale());
1524 | if (qrcode.debug) {
1525 | for (var m = 0; m < qrcode.height; m++) {
1526 | for (var n = 0; n < qrcode.width; n++) {
1527 | var o = (n * 4) + (m * qrcode.width * 4);
1528 | qrcode.imagedata.data[o] = c[n + m * qrcode.width] ? 0 : 0;
1529 | qrcode.imagedata.data[o + 1] = c[n + m * qrcode.width] ? 0 : 0;
1530 | qrcode.imagedata.data[o + 2] = c[n + m * qrcode.width] ? 255 : 0
1531 | }
1532 | }
1533 | q.putImageData(qrcode.imagedata, 0, 0)
1534 | }
1535 | var h = new Detector(c);
1536 | var p = h.detect();
1537 | if (qrcode.debug) {
1538 | for (var m = 0; m < p.bits.Height; m++) {
1539 | for (var n = 0; n < p.bits.Width; n++) {
1540 | var o = (n * 4 * 2) + (m * 2 * qrcode.width * 4);
1541 | qrcode.imagedata.data[o] = p.bits._ds(n, m) ? 0 : 0;
1542 | qrcode.imagedata.data[o + 1] = p.bits._ds(n, m) ? 0 : 0;
1543 | qrcode.imagedata.data[o + 2] = p.bits._ds(n, m) ? 255 : 0
1544 | }
1545 | }
1546 | q.putImageData(qrcode.imagedata, 0, 0)
1547 | }
1548 | var k = Decoder.decode(p.bits);
1549 | var g = k.DataByte;
1550 | var l = "";
1551 | for (var f = 0; f < g.length; f++) {
1552 | for (var e = 0; e < g[f].length; e++) {
1553 | l += String.fromCharCode(g[f][e])
1554 | }
1555 | }
1556 | var d = new Date().getTime();
1557 | var b = d - a;
1558 | console.log(b);
1559 | return qrcode.decode_utf8(l)
1560 | };
1561 | qrcode.getPixel = function (b, d) {
1562 | if (qrcode.width < b) {
1563 | throw"point error"
1564 | }
1565 | if (qrcode.height < d) {
1566 | throw"point error"
1567 | }
1568 | var a = (b * 4) + (d * qrcode.width * 4);
1569 | var c = (qrcode.imagedata.data[a] * 33 + qrcode.imagedata.data[a + 1] * 34 + qrcode.imagedata.data[a + 2] * 33) / 100;
1570 | return c
1571 | };
1572 | qrcode.binarize = function (d) {
1573 | var c = new Array(qrcode.width * qrcode.height);
1574 | for (var e = 0; e < qrcode.height; e++) {
1575 | for (var b = 0; b < qrcode.width; b++) {
1576 | var a = qrcode.getPixel(b, e);
1577 | c[b + e * qrcode.width] = a <= d ? true : false
1578 | }
1579 | }
1580 | return c
1581 | };
1582 | qrcode._em = function (d) {
1583 | var c = 4;
1584 | var k = Math.floor(qrcode.width / c);
1585 | var j = Math.floor(qrcode.height / c);
1586 | var f = new Array(c);
1587 | for (var g = 0; g < c; g++) {
1588 | f[g] = new Array(c);
1589 | for (var e = 0; e < c; e++) {
1590 | f[g][e] = new Array(0, 0)
1591 | }
1592 | }
1593 | for (var o = 0; o < c; o++) {
1594 | for (var a = 0; a < c; a++) {
1595 | f[a][o][0] = 255;
1596 | for (var l = 0; l < j; l++) {
1597 | for (var n = 0; n < k; n++) {
1598 | var h = d[k * a + n + (j * o + l) * qrcode.width];
1599 | if (h < f[a][o][0]) {
1600 | f[a][o][0] = h
1601 | }
1602 | if (h > f[a][o][1]) {
1603 | f[a][o][1] = h
1604 | }
1605 | }
1606 | }
1607 | }
1608 | }
1609 | var m = new Array(c);
1610 | for (var b = 0; b < c; b++) {
1611 | m[b] = new Array(c)
1612 | }
1613 | for (var o = 0; o < c; o++) {
1614 | for (var a = 0; a < c; a++) {
1615 | m[a][o] = Math.floor((f[a][o][0] + f[a][o][1]) / 2)
1616 | }
1617 | }
1618 | return m
1619 | };
1620 | qrcode.grayScaleToBitmap = function (f) {
1621 | var k = qrcode._em(f);
1622 | var b = k.length;
1623 | var e = Math.floor(qrcode.width / b);
1624 | var d = Math.floor(qrcode.height / b);
1625 | var h = new ArrayBuffer(qrcode.width * qrcode.height);
1626 | var c = new Uint8Array(h);
1627 | for (var j = 0; j < b; j++) {
1628 | for (var a = 0; a < b; a++) {
1629 | for (var g = 0; g < d; g++) {
1630 | for (var i = 0; i < e; i++) {
1631 | c[e * a + i + (d * j + g) * qrcode.width] = (f[e * a + i + (d * j + g) * qrcode.width] < k[a][j]) ? true : false
1632 | }
1633 | }
1634 | }
1635 | }
1636 | return c
1637 | };
1638 | qrcode.grayscale = function () {
1639 | var e = new ArrayBuffer(qrcode.width * qrcode.height);
1640 | var c = new Uint8Array(e);
1641 | for (var d = 0; d < qrcode.height; d++) {
1642 | for (var b = 0; b < qrcode.width; b++) {
1643 | var a = qrcode.getPixel(b, d);
1644 | c[b + d * qrcode.width] = a
1645 | }
1646 | }
1647 | return c
1648 | };
1649 |
1650 | function _ew(a, b) {
1651 | if (a >= 0) {
1652 | return a >> b
1653 | } else {
1654 | return (a >> b) + (2 << ~b)
1655 | }
1656 | }
1657 |
1658 | var _gf = 3;
1659 | var _eh = 57;
1660 | var _el = 8;
1661 | var _eg = 2;
1662 | qrcode._er = function (c) {
1663 | function b(m, k) {
1664 | var n = m.X - k.X;
1665 | var l = m.Y - k.Y;
1666 | return Math.sqrt((n * n + l * l))
1667 | }
1668 |
1669 | function d(k, o, n) {
1670 | var m = o.x;
1671 | var l = o.y;
1672 | return ((n.x - m) * (k.y - l)) - ((n.y - l) * (k.x - m))
1673 | }
1674 |
1675 | var i = b(c[0], c[1]);
1676 | var f = b(c[1], c[2]);
1677 | var e = b(c[0], c[2]);
1678 | var a, j, h;
1679 | if (f >= i && f >= e) {
1680 | j = c[0];
1681 | a = c[1];
1682 | h = c[2]
1683 | } else {
1684 | if (e >= f && e >= i) {
1685 | j = c[1];
1686 | a = c[0];
1687 | h = c[2]
1688 | } else {
1689 | j = c[2];
1690 | a = c[0];
1691 | h = c[1]
1692 | }
1693 | }
1694 | if (d(a, j, h) < 0) {
1695 | var g = a;
1696 | a = h;
1697 | h = g
1698 | }
1699 | c[0] = a;
1700 | c[1] = j;
1701 | c[2] = h
1702 | };
1703 |
1704 | function _cz(c, a, b) {
1705 | this.x = c;
1706 | this.y = a;
1707 | this.count = 1;
1708 | this._aj = b;
1709 | this.__defineGetter__("_ei", function () {
1710 | return this._aj
1711 | });
1712 | this.__defineGetter__("Count", function () {
1713 | return this.count
1714 | });
1715 | this.__defineGetter__("X", function () {
1716 | return this.x
1717 | });
1718 | this.__defineGetter__("Y", function () {
1719 | return this.y
1720 | });
1721 | this._ek = function () {
1722 | this.count++
1723 | };
1724 | this._ev = function (f, e, d) {
1725 | if (Math.abs(e - this.y) <= f && Math.abs(d - this.x) <= f) {
1726 | var g = Math.abs(f - this._aj);
1727 | return g <= 1 || g / this._aj <= 1
1728 | }
1729 | return false
1730 | }
1731 | }
1732 |
1733 | function _es(a) {
1734 | this._go = a[0];
1735 | this._gu = a[1];
1736 | this._gr = a[2];
1737 | this.__defineGetter__("_gp", function () {
1738 | return this._go
1739 | });
1740 | this.__defineGetter__("_gq", function () {
1741 | return this._gu
1742 | });
1743 | this.__defineGetter__("_gs", function () {
1744 | return this._gr
1745 | })
1746 | }
1747 |
1748 | function _cc() {
1749 | this.image = null;
1750 | this._cv = [];
1751 | this._ge = false;
1752 | this._al = new Array(0, 0, 0, 0, 0);
1753 | this._am = null;
1754 | this.__defineGetter__("_da", function () {
1755 | this._al[0] = 0;
1756 | this._al[1] = 0;
1757 | this._al[2] = 0;
1758 | this._al[3] = 0;
1759 | this._al[4] = 0;
1760 | return this._al
1761 | });
1762 | this._ao = function (f) {
1763 | var b = 0;
1764 | for (var d = 0; d < 5; d++) {
1765 | var e = f[d];
1766 | if (e == 0) {
1767 | return false
1768 | }
1769 | b += e
1770 | }
1771 | if (b < 7) {
1772 | return false
1773 | }
1774 | var c = Math.floor((b << _el) / 7);
1775 | var a = Math.floor(c / 2);
1776 | return Math.abs(c - (f[0] << _el)) < a && Math.abs(c - (f[1] << _el)) < a && Math.abs(3 * c - (f[2] << _el)) < 3 * a && Math.abs(c - (f[3] << _el)) < a && Math.abs(c - (f[4] << _el)) < a
1777 | };
1778 | this._an = function (b, a) {
1779 | return (a - b[4] - b[3]) - b[2] / 2
1780 | };
1781 | this._ap = function (a, j, d, g) {
1782 | var c = this.image;
1783 | var h = qrcode.height;
1784 | var b = this._da;
1785 | var f = a;
1786 | while (f >= 0 && c[j + f * qrcode.width]) {
1787 | b[2]++;
1788 | f--
1789 | }
1790 | if (f < 0) {
1791 | return NaN
1792 | }
1793 | while (f >= 0 && !c[j + f * qrcode.width] && b[1] <= d) {
1794 | b[1]++;
1795 | f--
1796 | }
1797 | if (f < 0 || b[1] > d) {
1798 | return NaN
1799 | }
1800 | while (f >= 0 && c[j + f * qrcode.width] && b[0] <= d) {
1801 | b[0]++;
1802 | f--
1803 | }
1804 | if (b[0] > d) {
1805 | return NaN
1806 | }
1807 | f = a + 1;
1808 | while (f < h && c[j + f * qrcode.width]) {
1809 | b[2]++;
1810 | f++
1811 | }
1812 | if (f == h) {
1813 | return NaN
1814 | }
1815 | while (f < h && !c[j + f * qrcode.width] && b[3] < d) {
1816 | b[3]++;
1817 | f++
1818 | }
1819 | if (f == h || b[3] >= d) {
1820 | return NaN
1821 | }
1822 | while (f < h && c[j + f * qrcode.width] && b[4] < d) {
1823 | b[4]++;
1824 | f++
1825 | }
1826 | if (b[4] >= d) {
1827 | return NaN
1828 | }
1829 | var e = b[0] + b[1] + b[2] + b[3] + b[4];
1830 | if (5 * Math.abs(e - g) >= 2 * g) {
1831 | return NaN
1832 | }
1833 | return this._ao(b) ? this._an(b, f) : NaN
1834 | };
1835 | this._ej = function (b, a, e, h) {
1836 | var d = this.image;
1837 | var i = qrcode.width;
1838 | var c = this._da;
1839 | var g = b;
1840 | while (g >= 0 && d[g + a * qrcode.width]) {
1841 | c[2]++;
1842 | g--
1843 | }
1844 | if (g < 0) {
1845 | return NaN
1846 | }
1847 | while (g >= 0 && !d[g + a * qrcode.width] && c[1] <= e) {
1848 | c[1]++;
1849 | g--
1850 | }
1851 | if (g < 0 || c[1] > e) {
1852 | return NaN
1853 | }
1854 | while (g >= 0 && d[g + a * qrcode.width] && c[0] <= e) {
1855 | c[0]++;
1856 | g--
1857 | }
1858 | if (c[0] > e) {
1859 | return NaN
1860 | }
1861 | g = b + 1;
1862 | while (g < i && d[g + a * qrcode.width]) {
1863 | c[2]++;
1864 | g++
1865 | }
1866 | if (g == i) {
1867 | return NaN
1868 | }
1869 | while (g < i && !d[g + a * qrcode.width] && c[3] < e) {
1870 | c[3]++;
1871 | g++
1872 | }
1873 | if (g == i || c[3] >= e) {
1874 | return NaN
1875 | }
1876 | while (g < i && d[g + a * qrcode.width] && c[4] < e) {
1877 | c[4]++;
1878 | g++
1879 | }
1880 | if (c[4] >= e) {
1881 | return NaN
1882 | }
1883 | var f = c[0] + c[1] + c[2] + c[3] + c[4];
1884 | if (5 * Math.abs(f - h) >= h) {
1885 | return NaN
1886 | }
1887 | return this._ao(c) ? this._an(c, g) : NaN
1888 | };
1889 | this._cu = function (c, f, e) {
1890 | var d = c[0] + c[1] + c[2] + c[3] + c[4];
1891 | var n = this._an(c, e);
1892 | var b = this._ap(f, Math.floor(n), c[2], d);
1893 | if (!isNaN(b)) {
1894 | n = this._ej(Math.floor(n), Math.floor(b), c[2], d);
1895 | if (!isNaN(n)) {
1896 | var l = d / 7;
1897 | var m = false;
1898 | var h = this._cv.length;
1899 | for (var g = 0; g < h; g++) {
1900 | var a = this._cv[g];
1901 | if (a._ev(l, b, n)) {
1902 | a._ek();
1903 | m = true;
1904 | break
1905 | }
1906 | }
1907 | if (!m) {
1908 | var k = new _cz(n, b, l);
1909 | this._cv.push(k);
1910 | if (this._am != null) {
1911 | this._am._ep(k)
1912 | }
1913 | }
1914 | return true
1915 | }
1916 | }
1917 | return false
1918 | };
1919 | this._ee = function () {
1920 | var h = this._cv.length;
1921 | if (h < 3) {
1922 | throw"Couldn't find enough finder patterns (found " + h + ")"
1923 | }
1924 | if (h > 3) {
1925 | var b = 0;
1926 | var j = 0;
1927 | for (var d = 0; d < h; d++) {
1928 | var g = this._cv[d]._ei;
1929 | b += g;
1930 | j += (g * g)
1931 | }
1932 | var a = b / h;
1933 | this._cv.sort(function (m, l) {
1934 | var k = Math.abs(l._ei - a);
1935 | var i = Math.abs(m._ei - a);
1936 | if (k < i) {
1937 | return (-1)
1938 | } else {
1939 | if (k == i) {
1940 | return 0
1941 | } else {
1942 | return 1
1943 | }
1944 | }
1945 | });
1946 | var e = Math.sqrt(j / h - a * a);
1947 | var c = Math.max(0.2 * a, e);
1948 | for (var d = this._cv.length - 1; d >= 0; d--) {
1949 | var f = this._cv[d];
1950 | if (Math.abs(f._ei - a) > c) {
1951 | this._cv.splice(d, 1)
1952 | }
1953 | }
1954 | }
1955 | if (this._cv.length > 3) {
1956 | this._cv.sort(function (k, i) {
1957 | if (k.count > i.count) {
1958 | return -1
1959 | }
1960 | if (k.count < i.count) {
1961 | return 1
1962 | }
1963 | return 0
1964 | })
1965 | }
1966 | return new Array(this._cv[0], this._cv[1], this._cv[2])
1967 | };
1968 | this._eq = function () {
1969 | var b = this._cv.length;
1970 | if (b <= 1) {
1971 | return 0
1972 | }
1973 | var c = null;
1974 | for (var d = 0; d < b; d++) {
1975 | var a = this._cv[d];
1976 | if (a.Count >= _eg) {
1977 | if (c == null) {
1978 | c = a
1979 | } else {
1980 | this._ge = true;
1981 | return Math.floor((Math.abs(c.X - a.X) - Math.abs(c.Y - a.Y)) / 2)
1982 | }
1983 | }
1984 | }
1985 | return 0
1986 | };
1987 | this._cx = function () {
1988 | var g = 0;
1989 | var c = 0;
1990 | var a = this._cv.length;
1991 | for (var d = 0; d < a; d++) {
1992 | var f = this._cv[d];
1993 | if (f.Count >= _eg) {
1994 | g++;
1995 | c += f._ei
1996 | }
1997 | }
1998 | if (g < 3) {
1999 | return false
2000 | }
2001 | var e = c / a;
2002 | var b = 0;
2003 | for (var d = 0; d < a; d++) {
2004 | f = this._cv[d];
2005 | b += Math.abs(f._ei - e)
2006 | }
2007 | return b <= 0.05 * c
2008 | };
2009 | this._ce = function (e) {
2010 | var o = false;
2011 | this.image = e;
2012 | var n = qrcode.height;
2013 | var k = qrcode.width;
2014 | var a = Math.floor((3 * n) / (4 * _eh));
2015 | if (a < _gf || o) {
2016 | a = _gf
2017 | }
2018 | var g = false;
2019 | var d = new Array(5);
2020 | for (var h = a - 1; h < n && !g; h += a) {
2021 | d[0] = 0;
2022 | d[1] = 0;
2023 | d[2] = 0;
2024 | d[3] = 0;
2025 | d[4] = 0;
2026 | var b = 0;
2027 | for (var f = 0; f < k; f++) {
2028 | if (e[f + h * qrcode.width]) {
2029 | if ((b & 1) == 1) {
2030 | b++
2031 | }
2032 | d[b]++
2033 | } else {
2034 | if ((b & 1) == 0) {
2035 | if (b == 4) {
2036 | if (this._ao(d)) {
2037 | var c = this._cu(d, h, f);
2038 | if (c) {
2039 | a = 2;
2040 | if (this._ge) {
2041 | g = this._cx()
2042 | } else {
2043 | var m = this._eq();
2044 | if (m > d[2]) {
2045 | h += m - d[2] - a;
2046 | f = k - 1
2047 | }
2048 | }
2049 | } else {
2050 | do {
2051 | f++
2052 | } while (f < k && !e[f + h * qrcode.width]);
2053 | f--
2054 | }
2055 | b = 0;
2056 | d[0] = 0;
2057 | d[1] = 0;
2058 | d[2] = 0;
2059 | d[3] = 0;
2060 | d[4] = 0
2061 | } else {
2062 | d[0] = d[2];
2063 | d[1] = d[3];
2064 | d[2] = d[4];
2065 | d[3] = 1;
2066 | d[4] = 0;
2067 | b = 3
2068 | }
2069 | } else {
2070 | d[++b]++
2071 | }
2072 | } else {
2073 | d[b]++
2074 | }
2075 | }
2076 | }
2077 | if (this._ao(d)) {
2078 | var c = this._cu(d, h, k);
2079 | if (c) {
2080 | a = d[0];
2081 | if (this._ge) {
2082 | g = this._cx()
2083 | }
2084 | }
2085 | }
2086 | }
2087 | var l = this._ee();
2088 | qrcode._er(l);
2089 | return new _es(l)
2090 | }
2091 | }
2092 |
2093 | function _ai(c, a, b) {
2094 | this.x = c;
2095 | this.y = a;
2096 | this.count = 1;
2097 | this._aj = b;
2098 | this.__defineGetter__("_ei", function () {
2099 | return this._aj
2100 | });
2101 | this.__defineGetter__("Count", function () {
2102 | return this.count
2103 | });
2104 | this.__defineGetter__("X", function () {
2105 | return Math.floor(this.x)
2106 | });
2107 | this.__defineGetter__("Y", function () {
2108 | return Math.floor(this.y)
2109 | });
2110 | this._ek = function () {
2111 | this.count++
2112 | };
2113 | this._ev = function (f, e, d) {
2114 | if (Math.abs(e - this.y) <= f && Math.abs(d - this.x) <= f) {
2115 | var g = Math.abs(f - this._aj);
2116 | return g <= 1 || g / this._aj <= 1
2117 | }
2118 | return false
2119 | }
2120 | }
2121 |
2122 | function _ak(g, c, b, f, a, e, d) {
2123 | this.image = g;
2124 | this._cv = new Array();
2125 | this.startX = c;
2126 | this.startY = b;
2127 | this.width = f;
2128 | this.height = a;
2129 | this._ef = e;
2130 | this._al = new Array(0, 0, 0);
2131 | this._am = d;
2132 | this._an = function (i, h) {
2133 | return (h - i[2]) - i[1] / 2
2134 | };
2135 | this._ao = function (l) {
2136 | var k = this._ef;
2137 | var h = k / 2;
2138 | for (var j = 0; j < 3; j++) {
2139 | if (Math.abs(k - l[j]) >= h) {
2140 | return false
2141 | }
2142 | }
2143 | return true
2144 | };
2145 | this._ap = function (h, q, l, o) {
2146 | var k = this.image;
2147 | var p = qrcode.height;
2148 | var j = this._al;
2149 | j[0] = 0;
2150 | j[1] = 0;
2151 | j[2] = 0;
2152 | var n = h;
2153 | while (n >= 0 && k[q + n * qrcode.width] && j[1] <= l) {
2154 | j[1]++;
2155 | n--
2156 | }
2157 | if (n < 0 || j[1] > l) {
2158 | return NaN
2159 | }
2160 | while (n >= 0 && !k[q + n * qrcode.width] && j[0] <= l) {
2161 | j[0]++;
2162 | n--
2163 | }
2164 | if (j[0] > l) {
2165 | return NaN
2166 | }
2167 | n = h + 1;
2168 | while (n < p && k[q + n * qrcode.width] && j[1] <= l) {
2169 | j[1]++;
2170 | n++
2171 | }
2172 | if (n == p || j[1] > l) {
2173 | return NaN
2174 | }
2175 | while (n < p && !k[q + n * qrcode.width] && j[2] <= l) {
2176 | j[2]++;
2177 | n++
2178 | }
2179 | if (j[2] > l) {
2180 | return NaN
2181 | }
2182 | var m = j[0] + j[1] + j[2];
2183 | if (5 * Math.abs(m - o) >= 2 * o) {
2184 | return NaN
2185 | }
2186 | return this._ao(j) ? this._an(j, n) : NaN
2187 | };
2188 | this._cu = function (l, o, n) {
2189 | var m = l[0] + l[1] + l[2];
2190 | var t = this._an(l, n);
2191 | var k = this._ap(o, Math.floor(t), 2 * l[1], m);
2192 | if (!isNaN(k)) {
2193 | var s = (l[0] + l[1] + l[2]) / 3;
2194 | var q = this._cv.length;
2195 | for (var p = 0; p < q; p++) {
2196 | var h = this._cv[p];
2197 | if (h._ev(s, k, t)) {
2198 | return new _ai(t, k, s)
2199 | }
2200 | }
2201 | var r = new _ai(t, k, s);
2202 | this._cv.push(r);
2203 | if (this._am != null) {
2204 | this._am._ep(r)
2205 | }
2206 | }
2207 | return null
2208 | };
2209 | this.find = function () {
2210 | var p = this.startX;
2211 | var s = this.height;
2212 | var q = p + f;
2213 | var r = b + (s >> 1);
2214 | var m = new Array(0, 0, 0);
2215 | for (var k = 0; k < s; k++) {
2216 | var o = r + ((k & 1) == 0 ? ((k + 1) >> 1) : -((k + 1) >> 1));
2217 | m[0] = 0;
2218 | m[1] = 0;
2219 | m[2] = 0;
2220 | var n = p;
2221 | while (n < q && !g[n + qrcode.width * o]) {
2222 | n++
2223 | }
2224 | var h = 0;
2225 | while (n < q) {
2226 | if (g[n + o * qrcode.width]) {
2227 | if (h == 1) {
2228 | m[h]++
2229 | } else {
2230 | if (h == 2) {
2231 | if (this._ao(m)) {
2232 | var l = this._cu(m, o, n);
2233 | if (l != null) {
2234 | return l
2235 | }
2236 | }
2237 | m[0] = m[2];
2238 | m[1] = 1;
2239 | m[2] = 0;
2240 | h = 1
2241 | } else {
2242 | m[++h]++
2243 | }
2244 | }
2245 | } else {
2246 | if (h == 1) {
2247 | h++
2248 | }
2249 | m[h]++
2250 | }
2251 | n++
2252 | }
2253 | if (this._ao(m)) {
2254 | var l = this._cu(m, o, q);
2255 | if (l != null) {
2256 | return l
2257 | }
2258 | }
2259 | }
2260 | if (!(this._cv.length == 0)) {
2261 | return this._cv[0]
2262 | }
2263 | throw"Couldn't find enough alignment patterns"
2264 | }
2265 | }
2266 |
2267 | function QRCodeDataBlockReader(c, a, b) {
2268 | this._ed = 0;
2269 | this._cw = 7;
2270 | this.dataLength = 0;
2271 | this.blocks = c;
2272 | this._en = b;
2273 | if (a <= 9) {
2274 | this.dataLengthMode = 0
2275 | } else {
2276 | if (a >= 10 && a <= 26) {
2277 | this.dataLengthMode = 1
2278 | } else {
2279 | if (a >= 27 && a <= 40) {
2280 | this.dataLengthMode = 2
2281 | }
2282 | }
2283 | }
2284 | this._gd = function (f) {
2285 | var k = 0;
2286 | if (f < this._cw + 1) {
2287 | var m = 0;
2288 | for (var e = 0; e < f; e++) {
2289 | m += (1 << e)
2290 | }
2291 | m <<= (this._cw - f + 1);
2292 | k = (this.blocks[this._ed] & m) >> (this._cw - f + 1);
2293 | this._cw -= f;
2294 | return k
2295 | } else {
2296 | if (f < this._cw + 1 + 8) {
2297 | var j = 0;
2298 | for (var e = 0; e < this._cw + 1; e++) {
2299 | j += (1 << e)
2300 | }
2301 | k = (this.blocks[this._ed] & j) << (f - (this._cw + 1));
2302 | this._ed++;
2303 | k += ((this.blocks[this._ed]) >> (8 - (f - (this._cw + 1))));
2304 | this._cw = this._cw - f % 8;
2305 | if (this._cw < 0) {
2306 | this._cw = 8 + this._cw
2307 | }
2308 | return k
2309 | } else {
2310 | if (f < this._cw + 1 + 16) {
2311 | var j = 0;
2312 | var h = 0;
2313 | for (var e = 0; e < this._cw + 1; e++) {
2314 | j += (1 << e)
2315 | }
2316 | var g = (this.blocks[this._ed] & j) << (f - (this._cw + 1));
2317 | this._ed++;
2318 | var d = this.blocks[this._ed] << (f - (this._cw + 1 + 8));
2319 | this._ed++;
2320 | for (var e = 0; e < f - (this._cw + 1 + 8); e++) {
2321 | h += (1 << e)
2322 | }
2323 | h <<= 8 - (f - (this._cw + 1 + 8));
2324 | var l = (this.blocks[this._ed] & h) >> (8 - (f - (this._cw + 1 + 8)));
2325 | k = g + d + l;
2326 | this._cw = this._cw - (f - 8) % 8;
2327 | if (this._cw < 0) {
2328 | this._cw = 8 + this._cw
2329 | }
2330 | return k
2331 | } else {
2332 | return 0
2333 | }
2334 | }
2335 | }
2336 | };
2337 | this.NextMode = function () {
2338 | if ((this._ed > this.blocks.length - this._en - 2)) {
2339 | return 0
2340 | } else {
2341 | return this._gd(4)
2342 | }
2343 | };
2344 | this.getDataLength = function (d) {
2345 | var e = 0;
2346 | while (true) {
2347 | if ((d >> e) == 1) {
2348 | break
2349 | }
2350 | e++
2351 | }
2352 | return this._gd(qrcode._eo[this.dataLengthMode][e])
2353 | };
2354 | this.getRomanAndFigureString = function (h) {
2355 | var f = h;
2356 | var g = 0;
2357 | var j = "";
2358 | var d = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", " ", "$", "%", "*", "+", "-", ".", "/", ":");
2359 | do {
2360 | if (f > 1) {
2361 | g = this._gd(11);
2362 | var i = Math.floor(g / 45);
2363 | var e = g % 45;
2364 | j += d[i];
2365 | j += d[e];
2366 | f -= 2
2367 | } else {
2368 | if (f == 1) {
2369 | g = this._gd(6);
2370 | j += d[g];
2371 | f -= 1
2372 | }
2373 | }
2374 | } while (f > 0);
2375 | return j
2376 | };
2377 | this.getFigureString = function (f) {
2378 | var d = f;
2379 | var e = 0;
2380 | var g = "";
2381 | do {
2382 | if (d >= 3) {
2383 | e = this._gd(10);
2384 | if (e < 100) {
2385 | g += "0"
2386 | }
2387 | if (e < 10) {
2388 | g += "0"
2389 | }
2390 | d -= 3
2391 | } else {
2392 | if (d == 2) {
2393 | e = this._gd(7);
2394 | if (e < 10) {
2395 | g += "0"
2396 | }
2397 | d -= 2
2398 | } else {
2399 | if (d == 1) {
2400 | e = this._gd(4);
2401 | d -= 1
2402 | }
2403 | }
2404 | }
2405 | g += e
2406 | } while (d > 0);
2407 | return g
2408 | };
2409 | this.get8bitByteArray = function (g) {
2410 | var e = g;
2411 | var f = 0;
2412 | var d = new Array();
2413 | do {
2414 | f = this._gd(8);
2415 | d.push(f);
2416 | e--
2417 | } while (e > 0);
2418 | return d
2419 | };
2420 | this.getKanjiString = function (j) {
2421 | var g = j;
2422 | var i = 0;
2423 | var h = "";
2424 | do {
2425 | i = this._gd(13);
2426 | var e = i % 192;
2427 | var f = i / 192;
2428 | var k = (f << 8) + e;
2429 | var d = 0;
2430 | if (k + 33088 <= 40956) {
2431 | d = k + 33088
2432 | } else {
2433 | d = k + 49472
2434 | }
2435 | h += String.fromCharCode(d);
2436 | g--
2437 | } while (g > 0);
2438 | return h
2439 | };
2440 | this.parseECIValue = function () {
2441 | var f = 0;
2442 | var e = this._gd(8);
2443 | if ((e & 128) == 0) {
2444 | f = e & 127
2445 | }
2446 | if ((e & 192) == 128) {
2447 | var d = this._gd(8);
2448 | f = ((e & 63) << 8) | d
2449 | }
2450 | if ((e & 224) == 192) {
2451 | var g = this._gd(8);
2452 | f = ((e & 31) << 16) | g
2453 | }
2454 | return f
2455 | };
2456 | this.__defineGetter__("DataByte", function () {
2457 | var h = new Array();
2458 | var e = 1;
2459 | var f = 2;
2460 | var d = 4;
2461 | var n = 7;
2462 | var p = 8;
2463 | do {
2464 | var l = this.NextMode();
2465 | if (l == 0) {
2466 | if (h.length > 0) {
2467 | break
2468 | } else {
2469 | throw"Empty data block"
2470 | }
2471 | }
2472 | if (l != e && l != f && l != d && l != p && l != n) {
2473 | throw"Invalid mode: " + l + " in (block:" + this._ed + " bit:" + this._cw + ")"
2474 | }
2475 | if (l == n) {
2476 | var o = this.parseECIValue()
2477 | } else {
2478 | var g = this.getDataLength(l);
2479 | if (g < 1) {
2480 | throw"Invalid data length: " + g
2481 | }
2482 | switch (l) {
2483 | case e:
2484 | var m = this.getFigureString(g);
2485 | var k = new Array(m.length);
2486 | for (var i = 0; i < m.length; i++) {
2487 | k[i] = m.charCodeAt(i)
2488 | }
2489 | h.push(k);
2490 | break;
2491 | case f:
2492 | var m = this.getRomanAndFigureString(g);
2493 | var k = new Array(m.length);
2494 | for (var i = 0; i < m.length; i++) {
2495 | k[i] = m.charCodeAt(i)
2496 | }
2497 | h.push(k);
2498 | break;
2499 | case d:
2500 | var o = this.get8bitByteArray(g);
2501 | h.push(o);
2502 | break;
2503 | case p:
2504 | var m = this.getKanjiString(g);
2505 | h.push(m);
2506 | break
2507 | }
2508 | }
2509 | } while (true);
2510 | return h
2511 | })
2512 | };window.qrcode = qrcode;
--------------------------------------------------------------------------------
/popup/qrcode_encoder.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @fileoverview
3 | * - Using the 'QRCode for Javascript library'
4 | * - Fixed dataset of 'QRCode for Javascript library' for support full-spec.
5 | * - this library has no dependencies.
6 | *
7 | * @author davidshimjs
8 | * @see http://www.d-project.com/
9 | * @see http://jeromeetienne.github.com/jquery-qrcode/
10 | */
11 | var QRCodeEncoder;
12 |
13 | (function () {
14 | //---------------------------------------------------------------------
15 | // QRCode for JavaScript
16 | //
17 | // Copyright (c) 2009 Kazuhiko Arase
18 | //
19 | // URL: http://www.d-project.com/
20 | //
21 | // Licensed under the MIT license:
22 | // http://www.opensource.org/licenses/mit-license.php
23 | //
24 | // The word "QR Code" is registered trademark of
25 | // DENSO WAVE INCORPORATED
26 | // http://www.denso-wave.com/qrcode/faqpatent-e.html
27 | //
28 | //---------------------------------------------------------------------
29 | function QR8bitByte(data) {
30 | this.mode = QRMode.MODE_8BIT_BYTE;
31 | this.data = data;
32 | this.parsedData = [];
33 |
34 | // Added to support UTF-8 Characters
35 | for (var i = 0, l = this.data.length; i < l; i++) {
36 | var byteArray = [];
37 | var code = this.data.charCodeAt(i);
38 |
39 | if (code > 0x10000) {
40 | byteArray[0] = 0xF0 | ((code & 0x1C0000) >>> 18);
41 | byteArray[1] = 0x80 | ((code & 0x3F000) >>> 12);
42 | byteArray[2] = 0x80 | ((code & 0xFC0) >>> 6);
43 | byteArray[3] = 0x80 | (code & 0x3F);
44 | } else if (code > 0x800) {
45 | byteArray[0] = 0xE0 | ((code & 0xF000) >>> 12);
46 | byteArray[1] = 0x80 | ((code & 0xFC0) >>> 6);
47 | byteArray[2] = 0x80 | (code & 0x3F);
48 | } else if (code > 0x80) {
49 | byteArray[0] = 0xC0 | ((code & 0x7C0) >>> 6);
50 | byteArray[1] = 0x80 | (code & 0x3F);
51 | } else {
52 | byteArray[0] = code;
53 | }
54 |
55 | this.parsedData.push(byteArray);
56 | }
57 |
58 | this.parsedData = Array.prototype.concat.apply([], this.parsedData);
59 |
60 | if (this.parsedData.length != this.data.length) {
61 | this.parsedData.unshift(191);
62 | this.parsedData.unshift(187);
63 | this.parsedData.unshift(239);
64 | }
65 | }
66 |
67 | QR8bitByte.prototype = {
68 | getLength: function (buffer) {
69 | return this.parsedData.length;
70 | },
71 | write: function (buffer) {
72 | for (var i = 0, l = this.parsedData.length; i < l; i++) {
73 | buffer.put(this.parsedData[i], 8);
74 | }
75 | }
76 | };
77 |
78 | function QRCodeModel(typeNumber, errorCorrectLevel) {
79 | this.typeNumber = typeNumber;
80 | this.errorCorrectLevel = errorCorrectLevel;
81 | this.modules = null;
82 | this.moduleCount = 0;
83 | this.dataCache = null;
84 | this.dataList = [];
85 | }
86 |
87 | QRCodeModel.prototype={addData:function(data){var newData=new QR8bitByte(data);this.dataList.push(newData);this.dataCache=null;},isDark:function(row,col){if(row<0||this.moduleCount<=row||col<0||this.moduleCount<=col){throw new Error(row+","+col);}
88 | return this.modules[row][col];},getModuleCount:function(){return this.moduleCount;},make:function(){this.makeImpl(false,this.getBestMaskPattern());},makeImpl:function(test,maskPattern){this.moduleCount=this.typeNumber*4+17;this.modules=new Array(this.moduleCount);for(var row=0;row=7){this.setupTypeNumber(test);}
90 | if(this.dataCache==null){this.dataCache=QRCodeModel.createData(this.typeNumber,this.errorCorrectLevel,this.dataList);}
91 | this.mapData(this.dataCache,maskPattern);},setupPositionProbePattern:function(row,col){for(var r=-1;r<=7;r++){if(row+r<=-1||this.moduleCount<=row+r)continue;for(var c=-1;c<=7;c++){if(col+c<=-1||this.moduleCount<=col+c)continue;if((0<=r&&r<=6&&(c==0||c==6))||(0<=c&&c<=6&&(r==0||r==6))||(2<=r&&r<=4&&2<=c&&c<=4)){this.modules[row+r][col+c]=true;}else{this.modules[row+r][col+c]=false;}}}},getBestMaskPattern:function(){var minLostPoint=0;var pattern=0;for(var i=0;i<8;i++){this.makeImpl(true,i);var lostPoint=QRUtil.getLostPoint(this);if(i==0||minLostPoint>lostPoint){minLostPoint=lostPoint;pattern=i;}}
92 | return pattern;},createMovieClip:function(target_mc,instance_name,depth){var qr_mc=target_mc.createEmptyMovieClip(instance_name,depth);var cs=1;this.make();for(var row=0;row>i)&1)==1);this.modules[Math.floor(i/3)][i%3+this.moduleCount-8-3]=mod;}
98 | for(var i=0;i<18;i++){var mod=(!test&&((bits>>i)&1)==1);this.modules[i%3+this.moduleCount-8-3][Math.floor(i/3)]=mod;}},setupTypeInfo:function(test,maskPattern){var data=(this.errorCorrectLevel<<3)|maskPattern;var bits=QRUtil.getBCHTypeInfo(data);for(var i=0;i<15;i++){var mod=(!test&&((bits>>i)&1)==1);if(i<6){this.modules[i][8]=mod;}else if(i<8){this.modules[i+1][8]=mod;}else{this.modules[this.moduleCount-15+i][8]=mod;}}
99 | for(var i=0;i<15;i++){var mod=(!test&&((bits>>i)&1)==1);if(i<8){this.modules[8][this.moduleCount-i-1]=mod;}else if(i<9){this.modules[8][15-i-1+1]=mod;}else{this.modules[8][15-i-1]=mod;}}
100 | this.modules[this.moduleCount-8][8]=(!test);},mapData:function(data,maskPattern){var inc=-1;var row=this.moduleCount-1;var bitIndex=7;var byteIndex=0;for(var col=this.moduleCount-1;col>0;col-=2){if(col==6)col--;while(true){for(var c=0;c<2;c++){if(this.modules[row][col-c]==null){var dark=false;if(byteIndex>>bitIndex)&1)==1);}
101 | var mask=QRUtil.getMask(maskPattern,row,col-c);if(mask){dark=!dark;}
102 | this.modules[row][col-c]=dark;bitIndex--;if(bitIndex==-1){byteIndex++;bitIndex=7;}}}
103 | row+=inc;if(row<0||this.moduleCount<=row){row-=inc;inc=-inc;break;}}}}};QRCodeModel.PAD0=0xEC;QRCodeModel.PAD1=0x11;QRCodeModel.createData=function(typeNumber,errorCorrectLevel,dataList){var rsBlocks=QRRSBlock.getRSBlocks(typeNumber,errorCorrectLevel);var buffer=new QRBitBuffer();for(var i=0;itotalDataCount*8){throw new Error("code length overflow. ("
106 | +buffer.getLengthInBits()
107 | +">"
108 | +totalDataCount*8
109 | +")");}
110 | if(buffer.getLengthInBits()+4<=totalDataCount*8){buffer.put(0,4);}
111 | while(buffer.getLengthInBits()%8!=0){buffer.putBit(false);}
112 | while(true){if(buffer.getLengthInBits()>=totalDataCount*8){break;}
113 | buffer.put(QRCodeModel.PAD0,8);if(buffer.getLengthInBits()>=totalDataCount*8){break;}
114 | buffer.put(QRCodeModel.PAD1,8);}
115 | return QRCodeModel.createBytes(buffer,rsBlocks);};QRCodeModel.createBytes=function(buffer,rsBlocks){var offset=0;var maxDcCount=0;var maxEcCount=0;var dcdata=new Array(rsBlocks.length);var ecdata=new Array(rsBlocks.length);for(var r=0;r=0)?modPoly.get(modIndex):0;}}
117 | var totalCodeCount=0;for(var i=0;i=0){d^=(QRUtil.G15<<(QRUtil.getBCHDigit(d)-QRUtil.getBCHDigit(QRUtil.G15)));}
121 | return((data<<10)|d)^QRUtil.G15_MASK;},getBCHTypeNumber:function(data){var d=data<<12;while(QRUtil.getBCHDigit(d)-QRUtil.getBCHDigit(QRUtil.G18)>=0){d^=(QRUtil.G18<<(QRUtil.getBCHDigit(d)-QRUtil.getBCHDigit(QRUtil.G18)));}
122 | return(data<<12)|d;},getBCHDigit:function(data){var digit=0;while(data!=0){digit++;data>>>=1;}
123 | return digit;},getPatternPosition:function(typeNumber){return QRUtil.PATTERN_POSITION_TABLE[typeNumber-1];},getMask:function(maskPattern,i,j){switch(maskPattern){case QRMaskPattern.PATTERN000:return(i+j)%2==0;case QRMaskPattern.PATTERN001:return i%2==0;case QRMaskPattern.PATTERN010:return j%3==0;case QRMaskPattern.PATTERN011:return(i+j)%3==0;case QRMaskPattern.PATTERN100:return(Math.floor(i/2)+Math.floor(j/3))%2==0;case QRMaskPattern.PATTERN101:return(i*j)%2+(i*j)%3==0;case QRMaskPattern.PATTERN110:return((i*j)%2+(i*j)%3)%2==0;case QRMaskPattern.PATTERN111:return((i*j)%3+(i+j)%2)%2==0;default:throw new Error("bad maskPattern:"+maskPattern);}},getErrorCorrectPolynomial:function(errorCorrectLength){var a=new QRPolynomial([1],0);for(var i=0;i5){lostPoint+=(3+sameCount-5);}}}
129 | for(var row=0;row=256){n-=255;}
136 | return QRMath.EXP_TABLE[n];},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)};for(var i=0;i<8;i++){QRMath.EXP_TABLE[i]=1<>>(7-index%8))&1)==1;},put:function(num,length){for(var i=0;i>>(length-i-1))&1)==1);}},getLengthInBits:function(){return this.length;},putBit:function(bit){var bufIndex=Math.floor(this.length/8);if(this.buffer.length<=bufIndex){this.buffer.push(0);}
151 | if(bit){this.buffer[bufIndex]|=(0x80>>>(this.length%8));}
152 | this.length++;}};var QRCodeLimitLength=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]];
153 |
154 | function _isSupportCanvas() {
155 | return typeof CanvasRenderingContext2D != "undefined";
156 | }
157 |
158 | // android 2.x doesn't support Data-URI spec
159 | function _getAndroid() {
160 | var android = false;
161 | var sAgent = navigator.userAgent;
162 |
163 | if (/android/i.test(sAgent)) { // android
164 | android = true;
165 | var aMat = sAgent.toString().match(/android ([0-9]\.[0-9])/i);
166 |
167 | if (aMat && aMat[1]) {
168 | android = parseFloat(aMat[1]);
169 | }
170 | }
171 |
172 | return android;
173 | }
174 |
175 | var svgDrawer = (function() {
176 |
177 | var Drawing = function (el, htOption) {
178 | this._el = el;
179 | this._htOption = htOption;
180 | };
181 |
182 | Drawing.prototype.draw = function (oQRCode) {
183 | var _htOption = this._htOption;
184 | var _el = this._el;
185 | var nCount = oQRCode.getModuleCount();
186 | var nWidth = Math.floor(_htOption.width / nCount);
187 | var nHeight = Math.floor(_htOption.height / nCount);
188 |
189 | this.clear();
190 |
191 | function makeSVG(tag, attrs) {
192 | var el = document.createElementNS('http://www.w3.org/2000/svg', tag);
193 | for (var k in attrs)
194 | if (attrs.hasOwnProperty(k)) el.setAttribute(k, attrs[k]);
195 | return el;
196 | }
197 |
198 | var svg = makeSVG("svg" , {'viewBox': '0 0 ' + String(nCount) + " " + String(nCount), 'width': '100%', 'height': '100%', 'fill': _htOption.colorLight});
199 | svg.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xlink", "http://www.w3.org/1999/xlink");
200 | _el.appendChild(svg);
201 |
202 | svg.appendChild(makeSVG("rect", {"fill": _htOption.colorLight, "width": "100%", "height": "100%"}));
203 | svg.appendChild(makeSVG("rect", {"fill": _htOption.colorDark, "width": "1", "height": "1", "id": "template"}));
204 |
205 | for (var row = 0; row < nCount; row++) {
206 | for (var col = 0; col < nCount; col++) {
207 | if (oQRCode.isDark(row, col)) {
208 | var child = makeSVG("use", {"x": String(col), "y": String(row)});
209 | child.setAttributeNS("http://www.w3.org/1999/xlink", "href", "#template")
210 | svg.appendChild(child);
211 | }
212 | }
213 | }
214 | };
215 | Drawing.prototype.clear = function () {
216 | while (this._el.hasChildNodes())
217 | this._el.removeChild(this._el.lastChild);
218 | };
219 | return Drawing;
220 | })();
221 |
222 | var useSVG = document.documentElement.tagName.toLowerCase() === "svg";
223 |
224 | // Drawing in DOM by using Table tag
225 | var Drawing = useSVG ? svgDrawer : !_isSupportCanvas() ? (function () {
226 | var Drawing = function (el, htOption) {
227 | this._el = el;
228 | this._htOption = htOption;
229 | };
230 |
231 | /**
232 | * Draw the QRCode
233 | *
234 | * @param {QRCodeEncoder} oQRCode
235 | */
236 | Drawing.prototype.draw = function (oQRCode) {
237 | var _htOption = this._htOption;
238 | var _el = this._el;
239 | var nCount = oQRCode.getModuleCount();
240 | var nWidth = Math.floor(_htOption.width / nCount);
241 | var nHeight = Math.floor(_htOption.height / nCount);
242 | var aHTML = [''];
243 |
244 | for (var row = 0; row < nCount; row++) {
245 | aHTML.push('');
246 |
247 | for (var col = 0; col < nCount; col++) {
248 | aHTML.push(' | ');
249 | }
250 |
251 | aHTML.push('
');
252 | }
253 |
254 | aHTML.push('
');
255 | _el.innerHTML = aHTML.join('');
256 |
257 | // Fix the margin values as real size.
258 | var elTable = _el.childNodes[0];
259 | var nLeftMarginTable = (_htOption.width - elTable.offsetWidth) / 2;
260 | var nTopMarginTable = (_htOption.height - elTable.offsetHeight) / 2;
261 |
262 | if (nLeftMarginTable > 0 && nTopMarginTable > 0) {
263 | elTable.style.margin = nTopMarginTable + "px " + nLeftMarginTable + "px";
264 | }
265 | };
266 |
267 | /**
268 | * Clear the QRCode
269 | */
270 | Drawing.prototype.clear = function () {
271 | this._el.innerHTML = '';
272 | };
273 |
274 | return Drawing;
275 | })() : (function () { // Drawing in Canvas
276 | function _onMakeImage() {
277 | this._elImage.src = this._elCanvas.toDataURL("image/png");
278 | this._elImage.style.display = "block";
279 | this._elCanvas.style.display = "none";
280 | }
281 |
282 | // Android 2.1 bug workaround
283 | // http://code.google.com/p/android/issues/detail?id=5141
284 | if (this._android && this._android <= 2.1) {
285 | var factor = 1 / window.devicePixelRatio;
286 | var drawImage = CanvasRenderingContext2D.prototype.drawImage;
287 | CanvasRenderingContext2D.prototype.drawImage = function (image, sx, sy, sw, sh, dx, dy, dw, dh) {
288 | if (("nodeName" in image) && /img/i.test(image.nodeName)) {
289 | for (var i = arguments.length - 1; i >= 1; i--) {
290 | arguments[i] = arguments[i] * factor;
291 | }
292 | } else if (typeof dw == "undefined") {
293 | arguments[1] *= factor;
294 | arguments[2] *= factor;
295 | arguments[3] *= factor;
296 | arguments[4] *= factor;
297 | }
298 |
299 | drawImage.apply(this, arguments);
300 | };
301 | }
302 |
303 | /**
304 | * Check whether the user's browser supports Data URI or not
305 | *
306 | * @private
307 | * @param {Function} fSuccess Occurs if it supports Data URI
308 | * @param {Function} fFail Occurs if it doesn't support Data URI
309 | */
310 | function _safeSetDataURI(fSuccess, fFail) {
311 | var self = this;
312 | self._fFail = fFail;
313 | self._fSuccess = fSuccess;
314 |
315 | // Check it just once
316 | if (self._bSupportDataURI === null) {
317 | var el = document.createElement("img");
318 | var fOnError = function() {
319 | self._bSupportDataURI = false;
320 |
321 | if (self._fFail) {
322 | self._fFail.call(self);
323 | }
324 | };
325 | var fOnSuccess = function() {
326 | self._bSupportDataURI = true;
327 |
328 | if (self._fSuccess) {
329 | self._fSuccess.call(self);
330 | }
331 | };
332 |
333 | el.onabort = fOnError;
334 | el.onerror = fOnError;
335 | el.onload = fOnSuccess;
336 | el.src = "data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; // the Image contains 1px data.
337 | return;
338 | } else if (self._bSupportDataURI === true && self._fSuccess) {
339 | self._fSuccess.call(self);
340 | } else if (self._bSupportDataURI === false && self._fFail) {
341 | self._fFail.call(self);
342 | }
343 | };
344 |
345 | /**
346 | * Drawing QRCode by using canvas
347 | *
348 | * @constructor
349 | * @param {HTMLElement} el
350 | * @param {Object} htOption QRCode Options
351 | */
352 | var Drawing = function (el, htOption) {
353 | this._bIsPainted = false;
354 | this._android = _getAndroid();
355 |
356 | this._htOption = htOption;
357 | this._elCanvas = document.createElement("canvas");
358 | this._elCanvas.width = htOption.width;
359 | this._elCanvas.height = htOption.height;
360 | el.appendChild(this._elCanvas);
361 | this._el = el;
362 | this._oContext = this._elCanvas.getContext("2d");
363 | this._bIsPainted = false;
364 | this._elImage = document.createElement("img");
365 | this._elImage.alt = "Scan me!";
366 | this._elImage.style.display = "none";
367 | this._el.appendChild(this._elImage);
368 | this._bSupportDataURI = null;
369 | };
370 |
371 | /**
372 | * Draw the QRCode
373 | *
374 | * @param {QRCodeEncoder} oQRCode
375 | */
376 | Drawing.prototype.draw = function (oQRCode) {
377 | var _elImage = this._elImage;
378 | var _oContext = this._oContext;
379 | var _htOption = this._htOption;
380 |
381 | var nCount = oQRCode.getModuleCount();
382 | var nWidth = _htOption.width / nCount;
383 | var nHeight = _htOption.height / nCount;
384 | var nRoundedWidth = Math.round(nWidth);
385 | var nRoundedHeight = Math.round(nHeight);
386 |
387 | _elImage.style.display = "none";
388 | this.clear();
389 |
390 | for (var row = 0; row < nCount; row++) {
391 | for (var col = 0; col < nCount; col++) {
392 | var bIsDark = oQRCode.isDark(row, col);
393 | var nLeft = col * nWidth;
394 | var nTop = row * nHeight;
395 | _oContext.strokeStyle = bIsDark ? _htOption.colorDark : _htOption.colorLight;
396 | _oContext.lineWidth = 1;
397 | _oContext.fillStyle = bIsDark ? _htOption.colorDark : _htOption.colorLight;
398 | _oContext.fillRect(nLeft, nTop, nWidth, nHeight);
399 |
400 | // 안티 앨리어싱 방지 처리
401 | _oContext.strokeRect(
402 | Math.floor(nLeft) + 0.5,
403 | Math.floor(nTop) + 0.5,
404 | nRoundedWidth,
405 | nRoundedHeight
406 | );
407 |
408 | _oContext.strokeRect(
409 | Math.ceil(nLeft) - 0.5,
410 | Math.ceil(nTop) - 0.5,
411 | nRoundedWidth,
412 | nRoundedHeight
413 | );
414 | }
415 | }
416 |
417 | this._bIsPainted = true;
418 | };
419 |
420 | /**
421 | * Make the image from Canvas if the browser supports Data URI.
422 | */
423 | Drawing.prototype.makeImage = function () {
424 | if (this._bIsPainted) {
425 | _safeSetDataURI.call(this, _onMakeImage);
426 | }
427 | };
428 |
429 | /**
430 | * Return whether the QRCode is painted or not
431 | *
432 | * @return {Boolean}
433 | */
434 | Drawing.prototype.isPainted = function () {
435 | return this._bIsPainted;
436 | };
437 |
438 | /**
439 | * Clear the QRCode
440 | */
441 | Drawing.prototype.clear = function () {
442 | this._oContext.clearRect(0, 0, this._elCanvas.width, this._elCanvas.height);
443 | this._bIsPainted = false;
444 | };
445 |
446 | /**
447 | * @private
448 | * @param {Number} nNumber
449 | */
450 | Drawing.prototype.round = function (nNumber) {
451 | if (!nNumber) {
452 | return nNumber;
453 | }
454 |
455 | return Math.floor(nNumber * 1000) / 1000;
456 | };
457 |
458 | return Drawing;
459 | })();
460 |
461 | /**
462 | * Get the type by string length
463 | *
464 | * @private
465 | * @param {String} sText
466 | * @param {Number} nCorrectLevel
467 | * @return {Number} type
468 | */
469 | function _getTypeNumber(sText, nCorrectLevel) {
470 | var nType = 1;
471 | var length = _getUTF8Length(sText);
472 |
473 | for (var i = 0, len = QRCodeLimitLength.length; i <= len; i++) {
474 | var nLimit = 0;
475 |
476 | switch (nCorrectLevel) {
477 | case QRErrorCorrectLevel.L :
478 | nLimit = QRCodeLimitLength[i][0];
479 | break;
480 | case QRErrorCorrectLevel.M :
481 | nLimit = QRCodeLimitLength[i][1];
482 | break;
483 | case QRErrorCorrectLevel.Q :
484 | nLimit = QRCodeLimitLength[i][2];
485 | break;
486 | case QRErrorCorrectLevel.H :
487 | nLimit = QRCodeLimitLength[i][3];
488 | break;
489 | }
490 |
491 | if (length <= nLimit) {
492 | break;
493 | } else {
494 | nType++;
495 | }
496 | }
497 |
498 | if (nType > QRCodeLimitLength.length) {
499 | throw new Error("Too long data");
500 | }
501 |
502 | return nType;
503 | }
504 |
505 | function _getUTF8Length(sText) {
506 | var replacedText = encodeURI(sText).toString().replace(/\%[0-9a-fA-F]{2}/g, 'a');
507 | return replacedText.length + (replacedText.length != sText ? 3 : 0);
508 | }
509 |
510 | /**
511 | * @class QRCodeEncoder
512 | * @constructor
513 | * @example
514 | * new QRCode(document.getElementById("test"), "http://jindo.dev.naver.com/collie");
515 | *
516 | * @example
517 | * var oQRCode = new QRCode("test", {
518 | * text : "http://naver.com",
519 | * width : 128,
520 | * height : 128
521 | * });
522 | *
523 | * oQRCode.clear(); // Clear the QRCode.
524 | * oQRCode.makeCode("http://map.naver.com"); // Re-create the QRCode.
525 | *
526 | * @param {HTMLElement|String} el target element or 'id' attribute of element.
527 | * @param {Object|String} vOption
528 | * @param {String} vOption.text QRCode link data
529 | * @param {Number} [vOption.width=256]
530 | * @param {Number} [vOption.height=256]
531 | * @param {String} [vOption.colorDark="#000000"]
532 | * @param {String} [vOption.colorLight="#ffffff"]
533 | * @param {QRCodeEncoder.CorrectLevel} [vOption.correctLevel=QRCode.CorrectLevel.H] [L|M|Q|H]
534 | */
535 | QRCodeEncoder = function (el, vOption) {
536 | this._htOption = {
537 | width : 256,
538 | height : 256,
539 | typeNumber : 4,
540 | colorDark : "#000000",
541 | colorLight : "#ffffff",
542 | correctLevel : QRErrorCorrectLevel.H
543 | };
544 |
545 | if (typeof vOption === 'string') {
546 | vOption = {
547 | text : vOption
548 | };
549 | }
550 |
551 | // Overwrites options
552 | if (vOption) {
553 | for (var i in vOption) {
554 | this._htOption[i] = vOption[i];
555 | }
556 | }
557 |
558 | if (typeof el == "string") {
559 | el = document.getElementById(el);
560 | }
561 |
562 | if (this._htOption.useSVG) {
563 | Drawing = svgDrawer;
564 | }
565 |
566 | this._android = _getAndroid();
567 | this._el = el;
568 | this._oQRCode = null;
569 | this._oDrawing = new Drawing(this._el, this._htOption);
570 |
571 | if (this._htOption.text) {
572 | this.makeCode(this._htOption.text);
573 | }
574 | };
575 |
576 | /**
577 | * Make the QRCode
578 | *
579 | * @param {String} sText link data
580 | */
581 | QRCodeEncoder.prototype.makeCode = function (sText) {
582 | this._oQRCode = new QRCodeModel(_getTypeNumber(sText, this._htOption.correctLevel), this._htOption.correctLevel);
583 | this._oQRCode.addData(sText);
584 | this._oQRCode.make();
585 | this._el.title = sText;
586 | this._oDrawing.draw(this._oQRCode);
587 | this.makeImage();
588 | };
589 |
590 | /**
591 | * Make the Image from Canvas element
592 | * - It occurs automatically
593 | * - Android below 3 doesn't support Data-URI spec.
594 | *
595 | * @private
596 | */
597 | QRCodeEncoder.prototype.makeImage = function () {
598 | if (typeof this._oDrawing.makeImage == "function" && (!this._android || this._android >= 3)) {
599 | this._oDrawing.makeImage();
600 | }
601 | };
602 |
603 | /**
604 | * Clear the QRCode
605 | */
606 | QRCodeEncoder.prototype.clear = function () {
607 | this._oDrawing.clear();
608 | };
609 |
610 | /**
611 | * @name QRCodeEncoder.CorrectLevel
612 | */
613 | QRCodeEncoder.CorrectLevel = QRErrorCorrectLevel;
614 | })();
--------------------------------------------------------------------------------
/popup/show_qrcode.css:
--------------------------------------------------------------------------------
1 | .container {
2 | display: flex;
3 | justify-content: center;
4 | align-self: center;
5 | width: 160px;
6 | flex-wrap: wrap;
7 | }
8 |
9 | #qrbox {
10 | /*TODO change unit*/
11 | height: 150px;
12 | background: white;
13 | padding: 8px;
14 | }
15 |
16 | #inputbox {
17 | /*TODO change style*/
18 | margin: 0 0 5px 0;
19 | }
20 |
--------------------------------------------------------------------------------
/popup/show_qrcode.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/popup/show_qrcode.js:
--------------------------------------------------------------------------------
1 | function setInputBox(text) {
2 | inputBox.setAttribute("value", text);
3 | // inputBox.focus();
4 | // inputBox.select();
5 | }
6 |
7 | function curURLToCode() {
8 | /* old Firefox API */
9 | if (self && self.port) {
10 | self.port.on('show', function onShow(data) {
11 | qrEncoder.makeCode(data.url);
12 | setInputBox(data.url);
13 | });
14 | }
15 | /* WebExtensions API */
16 | var activeTab = browser.tabs.query({currentWindow: true, active: true});
17 | if (browser.tabs && browser.tabs.query) {
18 | activeTab.then(function (data) {
19 | data = data[0];
20 | /* only tab in set */
21 | qrEncoder.makeCode(data.url);
22 | setInputBox(data.url);
23 | });
24 | }
25 | }
26 |
27 | function generateQRCode() {
28 | // empty input
29 | if (!inputBox.value)
30 | curURLToCode();
31 | else
32 | qrEncoder.makeCode(inputBox.value);
33 | }
34 |
35 |
36 | // init
37 | var inputBox = document.getElementById("inputbox");
38 | var qrDecoder = qrcode;
39 | var qrEncoder = new QRCodeEncoder(document.getElementById("qrbox"), {
40 | // text: "asdf",
41 | // TODO popup windows size and custom CorrectLevel
42 | width: 150,
43 | height: 150,
44 | colorDark: "#000000",
45 | colorLight: "#ffffff",
46 | correctLevel: QRCodeEncoder.CorrectLevel.M
47 | });
48 | generateQRCode();
49 | // init end
50 |
51 | browser.runtime.sendMessage('get_data', function (data) {
52 | if (data.type === 'img') {
53 | var img = new Image();
54 | var canvas = document.createElement("canvas");
55 | var ctx = canvas.getContext("2d");
56 |
57 | img.src = data.img;
58 | canvas.width = img.width;
59 | canvas.height = img.height;
60 | img.crossOrigin = '';
61 | // load image and decode
62 | img.onload = function () {
63 | canvas.width = img.width;
64 | canvas.height = img.height;
65 | ctx.drawImage(img, 0, 0, img.width, img.height);
66 | var dataURL = canvas.toDataURL("image/png");
67 | // console.log(dataURL);
68 | qrDecoder.decode(dataURL);
69 | };
70 | } else if (data.type === 'text') {
71 | setInputBox(data.text);
72 | generateQRCode();
73 | }
74 | });
75 |
76 | // listen on mouse event
77 | inputBox.addEventListener("keyup", function (e) {
78 | generateQRCode();
79 | // Enter keydown
80 | // if (e.keyCode == 13) {
81 | // generateQRCode();
82 | // }
83 | });
84 |
85 | // Set qrDecoder.callback to function "func(data)", where data will get the decoded information.
86 | qrDecoder.callback = function (result) {
87 | if (result === 'Failed to load the image') {
88 | setInputBox(browser.i18n.getMessage("failed-load"));
89 | }
90 | else if (result === 'error decoding QR Code') {
91 | setInputBox(browser.i18n.getMessage("decode-error"));
92 | }
93 | else {
94 | console.log(result);
95 | setInputBox(result);
96 | }
97 | generateQRCode();
98 | };
--------------------------------------------------------------------------------
/screenshot/content-menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OceanApart/QR-Code-Util-Web-Extension/ab85d0140b3c4cd74b2d5e8911e96be391515c21/screenshot/content-menu.png
--------------------------------------------------------------------------------
/screenshot/selected_text.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OceanApart/QR-Code-Util-Web-Extension/ab85d0140b3c4cd74b2d5e8911e96be391515c21/screenshot/selected_text.png
--------------------------------------------------------------------------------
/screenshot/url.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OceanApart/QR-Code-Util-Web-Extension/ab85d0140b3c4cd74b2d5e8911e96be391515c21/screenshot/url.png
--------------------------------------------------------------------------------