当前位置:   article > 正文

uniapph5页面使用扫码功能_uniapp h5 扫码

uniapp h5 扫码

问题:

uniapp官方的扫码api不支持在h5使用

解决:

因为uniapp官方的扫码api不支持在h5页面使用,我自己在网上找了一个扫码方法封装到项目的utils目录下的qrcode.js文件,具体代码在博客最下方。

页面代码:

  1. <template>
  2. <view class="content">
  3. <button @click="scanCode">扫描二维码</button>
  4. </view>
  5. </template>
  6. <script>
  7. //引入扫码的方法
  8. import qrcode from "../../utils/qrcode";
  9. export default {
  10. data() {
  11. return {
  12. title: "Hello",
  13. };
  14. },
  15. onLoad() {},
  16. methods: {
  17. scanCode() {
  18. uni.chooseImage({
  19. sizeType: ["original"],
  20. count: 1,
  21. success: function (res) {
  22. const tempFilePaths = res.tempFilePaths[0]; // 获取到二维码图片的链接
  23. qrcode.decode(tempFilePaths); // 解析二维码图片
  24. qrcode.callback = async function (res1) {
  25. // 解析失败返回 error decoding QR Code
  26. if (res1 == "error decoding QR Code") {
  27. uni.showToast({
  28. title: "二维码解析失败",
  29. duration: 2000,
  30. icon: "none",
  31. });
  32. } else {
  33. //扫码成功 res1就是扫描二维码的结果在这里写扫码成功的逻辑
  34. }
  35. };
  36. },
  37. });
  38. },
  39. },
  40. };
  41. </script>
  42. <style></style>

注意:

通过相机拍摄或者相册中选取二维码图片最好只包含一个二维码,背景不要太复杂,不然可能导致二维码解析失败。

扫码方法代码:

  1. // qrcode.js
  2. var _aa = {};
  3. _aa._ab = function (f, e) {
  4. var d = qrcode.width;
  5. var b = qrcode.height;
  6. var c = true;
  7. for (var g = 0; g < e.length && c; g += 2) {
  8. var a = Math.floor(e[g]);
  9. var h = Math.floor(e[g + 1]);
  10. if (a < -1 || a > d || h < -1 || h > b) {
  11. throw "Error._ab ";
  12. }
  13. c = false;
  14. if (a == -1) {
  15. e[g] = 0;
  16. c = true;
  17. } else {
  18. if (a == d) {
  19. e[g] = d - 1;
  20. c = true;
  21. }
  22. }
  23. if (h == -1) {
  24. e[g + 1] = 0;
  25. c = true;
  26. } else {
  27. if (h == b) {
  28. e[g + 1] = b - 1;
  29. c = true;
  30. }
  31. }
  32. }
  33. c = true;
  34. for (var g = e.length - 2; g >= 0 && c; g -= 2) {
  35. var a = Math.floor(e[g]);
  36. var h = Math.floor(e[g + 1]);
  37. if (a < -1 || a > d || h < -1 || h > b) {
  38. throw "Error._ab ";
  39. }
  40. c = false;
  41. if (a == -1) {
  42. e[g] = 0;
  43. c = true;
  44. } else {
  45. if (a == d) {
  46. e[g] = d - 1;
  47. c = true;
  48. }
  49. }
  50. if (h == -1) {
  51. e[g + 1] = 0;
  52. c = true;
  53. } else {
  54. if (h == b) {
  55. e[g + 1] = b - 1;
  56. c = true;
  57. }
  58. }
  59. }
  60. };
  61. _aa._af = function (b, d, a) {
  62. var k = new _ac(d);
  63. var j = new Array(d << 1);
  64. for (var f = 0; f < d; f++) {
  65. var g = j.length;
  66. var i = f + 0.5;
  67. for (var h = 0; h < g; h += 2) {
  68. j[h] = (h >> 1) + 0.5;
  69. j[h + 1] = i;
  70. }
  71. a._ad(j);
  72. _aa._ab(b, j);
  73. try {
  74. for (var h = 0; h < g; h += 2) {
  75. var e = b[Math.floor(j[h]) + qrcode.width * Math.floor(j[h + 1])];
  76. if (e) {
  77. k._dq(h >> 1, f);
  78. }
  79. }
  80. } catch (c) {
  81. throw "Error._ab";
  82. }
  83. }
  84. return k;
  85. };
  86. _aa._ah = function (h, o, l, k, q, p, b, a, f, e, n, m, s, r, d, c, j, i) {
  87. var g = _ae._ag(l, k, q, p, b, a, f, e, n, m, s, r, d, c, j, i);
  88. return _aa._af(h, o, g);
  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. function _a2(a, c, b) {
  101. this._bm = a;
  102. if (b) {
  103. this._do = new Array(c, b);
  104. } else {
  105. this._do = new Array(c);
  106. }
  107. this.__defineGetter__("_bo", function () {
  108. return this._bm;
  109. });
  110. this.__defineGetter__("_dn", function () {
  111. return this._bm * this._fo;
  112. });
  113. this.__defineGetter__("_fo", function () {
  114. var e = 0;
  115. for (var d = 0; d < this._do.length; d++) {
  116. e += this._do[d].length;
  117. }
  118. return e;
  119. });
  120. this._fb = function () {
  121. return this._do;
  122. };
  123. }
  124. function _a3(k, l, h, g, f, e) {
  125. this._bs = k;
  126. this._ar = l;
  127. this._do = new Array(h, g, f, e);
  128. var j = 0;
  129. var b = h._bo;
  130. var a = h._fb();
  131. for (var d = 0; d < a.length; d++) {
  132. var c = a[d];
  133. j += c.Count * (c._dm + b);
  134. }
  135. this._br = j;
  136. this.__defineGetter__("_fd", function () {
  137. return this._bs;
  138. });
  139. this.__defineGetter__("_as", function () {
  140. return this._ar;
  141. });
  142. this.__defineGetter__("_dp", function () {
  143. return this._br;
  144. });
  145. this.__defineGetter__("_cr", function () {
  146. return 17 + 4 * this._bs;
  147. });
  148. this._aq = function () {
  149. var q = this._cr;
  150. var o = new _ac(q);
  151. o._bq(0, 0, 9, 9);
  152. o._bq(q - 8, 0, 8, 9);
  153. o._bq(0, q - 8, 9, 8);
  154. var n = this._ar.length;
  155. for (var m = 0; m < n; m++) {
  156. var p = this._ar[m] - 2;
  157. for (var r = 0; r < n; r++) {
  158. if ((m == 0 && (r == 0 || r == n - 1)) || (m == n - 1 && r == 0)) {
  159. continue;
  160. }
  161. o._bq(this._ar[r] - 2, p, 5, 5);
  162. }
  163. }
  164. o._bq(6, 9, 1, q - 17);
  165. o._bq(9, 6, q - 17, 1);
  166. if (this._bs > 6) {
  167. o._bq(q - 11, 0, 3, 6);
  168. o._bq(0, q - 11, 6, 3);
  169. }
  170. return o;
  171. };
  172. this._bu = function (i) {
  173. return this._do[i.ordinal()];
  174. };
  175. }
  176. _a3._bv = new Array(
  177. 31892,
  178. 34236,
  179. 39577,
  180. 42195,
  181. 48118,
  182. 51042,
  183. 55367,
  184. 58893,
  185. 63784,
  186. 68472,
  187. 70749,
  188. 76311,
  189. 79154,
  190. 84390,
  191. 87683,
  192. 92361,
  193. 96236,
  194. 102084,
  195. 102881,
  196. 110507,
  197. 110734,
  198. 117786,
  199. 119615,
  200. 126325,
  201. 127568,
  202. 133589,
  203. 136944,
  204. 141498,
  205. 145311,
  206. 150283,
  207. 152622,
  208. 158308,
  209. 161089,
  210. 167017
  211. );
  212. _a3.VERSIONS = _ay();
  213. _a3._av = function (a) {
  214. if (a < 1 || a > 40) {
  215. throw "bad arguments";
  216. }
  217. return _a3.VERSIONS[a - 1];
  218. };
  219. _a3._at = function (b) {
  220. if (b % 4 != 1) {
  221. throw "Error _at";
  222. }
  223. try {
  224. return _a3._av((b - 17) >> 2);
  225. } catch (a) {
  226. throw "Error _av";
  227. }
  228. };
  229. _a3._aw = function (d) {
  230. var b = 4294967295;
  231. var f = 0;
  232. for (var c = 0; c < _a3._bv.length; c++) {
  233. var a = _a3._bv[c];
  234. if (a == d) {
  235. return this._av(c + 7);
  236. }
  237. var e = _ax._gj(d, a);
  238. if (e < b) {
  239. f = c + 7;
  240. b = e;
  241. }
  242. }
  243. if (b <= 3) {
  244. return this._av(f);
  245. }
  246. return null;
  247. };
  248. function _ay() {
  249. return new Array(
  250. new _a3(
  251. 1,
  252. new Array(),
  253. new _a2(7, new _a1(1, 19)),
  254. new _a2(10, new _a1(1, 16)),
  255. new _a2(13, new _a1(1, 13)),
  256. new _a2(17, new _a1(1, 9))
  257. ),
  258. new _a3(
  259. 2,
  260. new Array(6, 18),
  261. new _a2(10, new _a1(1, 34)),
  262. new _a2(16, new _a1(1, 28)),
  263. new _a2(22, new _a1(1, 22)),
  264. new _a2(28, new _a1(1, 16))
  265. ),
  266. new _a3(
  267. 3,
  268. new Array(6, 22),
  269. new _a2(15, new _a1(1, 55)),
  270. new _a2(26, new _a1(1, 44)),
  271. new _a2(18, new _a1(2, 17)),
  272. new _a2(22, new _a1(2, 13))
  273. ),
  274. new _a3(
  275. 4,
  276. new Array(6, 26),
  277. new _a2(20, new _a1(1, 80)),
  278. new _a2(18, new _a1(2, 32)),
  279. new _a2(26, new _a1(2, 24)),
  280. new _a2(16, new _a1(4, 9))
  281. ),
  282. new _a3(
  283. 5,
  284. new Array(6, 30),
  285. new _a2(26, new _a1(1, 108)),
  286. new _a2(24, new _a1(2, 43)),
  287. new _a2(18, new _a1(2, 15), new _a1(2, 16)),
  288. new _a2(22, new _a1(2, 11), new _a1(2, 12))
  289. ),
  290. new _a3(
  291. 6,
  292. new Array(6, 34),
  293. new _a2(18, new _a1(2, 68)),
  294. new _a2(16, new _a1(4, 27)),
  295. new _a2(24, new _a1(4, 19)),
  296. new _a2(28, new _a1(4, 15))
  297. ),
  298. new _a3(
  299. 7,
  300. new Array(6, 22, 38),
  301. new _a2(20, new _a1(2, 78)),
  302. new _a2(18, new _a1(4, 31)),
  303. new _a2(18, new _a1(2, 14), new _a1(4, 15)),
  304. new _a2(26, new _a1(4, 13), new _a1(1, 14))
  305. ),
  306. new _a3(
  307. 8,
  308. new Array(6, 24, 42),
  309. new _a2(24, new _a1(2, 97)),
  310. new _a2(22, new _a1(2, 38), new _a1(2, 39)),
  311. new _a2(22, new _a1(4, 18), new _a1(2, 19)),
  312. new _a2(26, new _a1(4, 14), new _a1(2, 15))
  313. ),
  314. new _a3(
  315. 9,
  316. new Array(6, 26, 46),
  317. new _a2(30, new _a1(2, 116)),
  318. new _a2(22, new _a1(3, 36), new _a1(2, 37)),
  319. new _a2(20, new _a1(4, 16), new _a1(4, 17)),
  320. new _a2(24, new _a1(4, 12), new _a1(4, 13))
  321. ),
  322. new _a3(
  323. 10,
  324. new Array(6, 28, 50),
  325. new _a2(18, new _a1(2, 68), new _a1(2, 69)),
  326. new _a2(26, new _a1(4, 43), new _a1(1, 44)),
  327. new _a2(24, new _a1(6, 19), new _a1(2, 20)),
  328. new _a2(28, new _a1(6, 15), new _a1(2, 16))
  329. ),
  330. new _a3(
  331. 11,
  332. new Array(6, 30, 54),
  333. new _a2(20, new _a1(4, 81)),
  334. new _a2(30, new _a1(1, 50), new _a1(4, 51)),
  335. new _a2(28, new _a1(4, 22), new _a1(4, 23)),
  336. new _a2(24, new _a1(3, 12), new _a1(8, 13))
  337. ),
  338. new _a3(
  339. 12,
  340. new Array(6, 32, 58),
  341. new _a2(24, new _a1(2, 92), new _a1(2, 93)),
  342. new _a2(22, new _a1(6, 36), new _a1(2, 37)),
  343. new _a2(26, new _a1(4, 20), new _a1(6, 21)),
  344. new _a2(28, new _a1(7, 14), new _a1(4, 15))
  345. ),
  346. new _a3(
  347. 13,
  348. new Array(6, 34, 62),
  349. new _a2(26, new _a1(4, 107)),
  350. new _a2(22, new _a1(8, 37), new _a1(1, 38)),
  351. new _a2(24, new _a1(8, 20), new _a1(4, 21)),
  352. new _a2(22, new _a1(12, 11), new _a1(4, 12))
  353. ),
  354. new _a3(
  355. 14,
  356. new Array(6, 26, 46, 66),
  357. new _a2(30, new _a1(3, 115), new _a1(1, 116)),
  358. new _a2(24, new _a1(4, 40), new _a1(5, 41)),
  359. new _a2(20, new _a1(11, 16), new _a1(5, 17)),
  360. new _a2(24, new _a1(11, 12), new _a1(5, 13))
  361. ),
  362. new _a3(
  363. 15,
  364. new Array(6, 26, 48, 70),
  365. new _a2(22, new _a1(5, 87), new _a1(1, 88)),
  366. new _a2(24, new _a1(5, 41), new _a1(5, 42)),
  367. new _a2(30, new _a1(5, 24), new _a1(7, 25)),
  368. new _a2(24, new _a1(11, 12), new _a1(7, 13))
  369. ),
  370. new _a3(
  371. 16,
  372. new Array(6, 26, 50, 74),
  373. new _a2(24, new _a1(5, 98), new _a1(1, 99)),
  374. new _a2(28, new _a1(7, 45), new _a1(3, 46)),
  375. new _a2(24, new _a1(15, 19), new _a1(2, 20)),
  376. new _a2(30, new _a1(3, 15), new _a1(13, 16))
  377. ),
  378. new _a3(
  379. 17,
  380. new Array(6, 30, 54, 78),
  381. new _a2(28, new _a1(1, 107), new _a1(5, 108)),
  382. new _a2(28, new _a1(10, 46), new _a1(1, 47)),
  383. new _a2(28, new _a1(1, 22), new _a1(15, 23)),
  384. new _a2(28, new _a1(2, 14), new _a1(17, 15))
  385. ),
  386. new _a3(
  387. 18,
  388. new Array(6, 30, 56, 82),
  389. new _a2(30, new _a1(5, 120), new _a1(1, 121)),
  390. new _a2(26, new _a1(9, 43), new _a1(4, 44)),
  391. new _a2(28, new _a1(17, 22), new _a1(1, 23)),
  392. new _a2(28, new _a1(2, 14), new _a1(19, 15))
  393. ),
  394. new _a3(
  395. 19,
  396. new Array(6, 30, 58, 86),
  397. new _a2(28, new _a1(3, 113), new _a1(4, 114)),
  398. new _a2(26, new _a1(3, 44), new _a1(11, 45)),
  399. new _a2(26, new _a1(17, 21), new _a1(4, 22)),
  400. new _a2(26, new _a1(9, 13), new _a1(16, 14))
  401. ),
  402. new _a3(
  403. 20,
  404. new Array(6, 34, 62, 90),
  405. new _a2(28, new _a1(3, 107), new _a1(5, 108)),
  406. new _a2(26, new _a1(3, 41), new _a1(13, 42)),
  407. new _a2(30, new _a1(15, 24), new _a1(5, 25)),
  408. new _a2(28, new _a1(15, 15), new _a1(10, 16))
  409. ),
  410. new _a3(
  411. 21,
  412. new Array(6, 28, 50, 72, 94),
  413. new _a2(28, new _a1(4, 116), new _a1(4, 117)),
  414. new _a2(26, new _a1(17, 42)),
  415. new _a2(28, new _a1(17, 22), new _a1(6, 23)),
  416. new _a2(30, new _a1(19, 16), new _a1(6, 17))
  417. ),
  418. new _a3(
  419. 22,
  420. new Array(6, 26, 50, 74, 98),
  421. new _a2(28, new _a1(2, 111), new _a1(7, 112)),
  422. new _a2(28, new _a1(17, 46)),
  423. new _a2(30, new _a1(7, 24), new _a1(16, 25)),
  424. new _a2(24, new _a1(34, 13))
  425. ),
  426. new _a3(
  427. 23,
  428. new Array(6, 30, 54, 74, 102),
  429. new _a2(30, new _a1(4, 121), new _a1(5, 122)),
  430. new _a2(28, new _a1(4, 47), new _a1(14, 48)),
  431. new _a2(30, new _a1(11, 24), new _a1(14, 25)),
  432. new _a2(30, new _a1(16, 15), new _a1(14, 16))
  433. ),
  434. new _a3(
  435. 24,
  436. new Array(6, 28, 54, 80, 106),
  437. new _a2(30, new _a1(6, 117), new _a1(4, 118)),
  438. new _a2(28, new _a1(6, 45), new _a1(14, 46)),
  439. new _a2(30, new _a1(11, 24), new _a1(16, 25)),
  440. new _a2(30, new _a1(30, 16), new _a1(2, 17))
  441. ),
  442. new _a3(
  443. 25,
  444. new Array(6, 32, 58, 84, 110),
  445. new _a2(26, new _a1(8, 106), new _a1(4, 107)),
  446. new _a2(28, new _a1(8, 47), new _a1(13, 48)),
  447. new _a2(30, new _a1(7, 24), new _a1(22, 25)),
  448. new _a2(30, new _a1(22, 15), new _a1(13, 16))
  449. ),
  450. new _a3(
  451. 26,
  452. new Array(6, 30, 58, 86, 114),
  453. new _a2(28, new _a1(10, 114), new _a1(2, 115)),
  454. new _a2(28, new _a1(19, 46), new _a1(4, 47)),
  455. new _a2(28, new _a1(28, 22), new _a1(6, 23)),
  456. new _a2(30, new _a1(33, 16), new _a1(4, 17))
  457. ),
  458. new _a3(
  459. 27,
  460. new Array(6, 34, 62, 90, 118),
  461. new _a2(30, new _a1(8, 122), new _a1(4, 123)),
  462. new _a2(28, new _a1(22, 45), new _a1(3, 46)),
  463. new _a2(30, new _a1(8, 23), new _a1(26, 24)),
  464. new _a2(30, new _a1(12, 15), new _a1(28, 16))
  465. ),
  466. new _a3(
  467. 28,
  468. new Array(6, 26, 50, 74, 98, 122),
  469. new _a2(30, new _a1(3, 117), new _a1(10, 118)),
  470. new _a2(28, new _a1(3, 45), new _a1(23, 46)),
  471. new _a2(30, new _a1(4, 24), new _a1(31, 25)),
  472. new _a2(30, new _a1(11, 15), new _a1(31, 16))
  473. ),
  474. new _a3(
  475. 29,
  476. new Array(6, 30, 54, 78, 102, 126),
  477. new _a2(30, new _a1(7, 116), new _a1(7, 117)),
  478. new _a2(28, new _a1(21, 45), new _a1(7, 46)),
  479. new _a2(30, new _a1(1, 23), new _a1(37, 24)),
  480. new _a2(30, new _a1(19, 15), new _a1(26, 16))
  481. ),
  482. new _a3(
  483. 30,
  484. new Array(6, 26, 52, 78, 104, 130),
  485. new _a2(30, new _a1(5, 115), new _a1(10, 116)),
  486. new _a2(28, new _a1(19, 47), new _a1(10, 48)),
  487. new _a2(30, new _a1(15, 24), new _a1(25, 25)),
  488. new _a2(30, new _a1(23, 15), new _a1(25, 16))
  489. ),
  490. new _a3(
  491. 31,
  492. new Array(6, 30, 56, 82, 108, 134),
  493. new _a2(30, new _a1(13, 115), new _a1(3, 116)),
  494. new _a2(28, new _a1(2, 46), new _a1(29, 47)),
  495. new _a2(30, new _a1(42, 24), new _a1(1, 25)),
  496. new _a2(30, new _a1(23, 15), new _a1(28, 16))
  497. ),
  498. new _a3(
  499. 32,
  500. new Array(6, 34, 60, 86, 112, 138),
  501. new _a2(30, new _a1(17, 115)),
  502. new _a2(28, new _a1(10, 46), new _a1(23, 47)),
  503. new _a2(30, new _a1(10, 24), new _a1(35, 25)),
  504. new _a2(30, new _a1(19, 15), new _a1(35, 16))
  505. ),
  506. new _a3(
  507. 33,
  508. new Array(6, 30, 58, 86, 114, 142),
  509. new _a2(30, new _a1(17, 115), new _a1(1, 116)),
  510. new _a2(28, new _a1(14, 46), new _a1(21, 47)),
  511. new _a2(30, new _a1(29, 24), new _a1(19, 25)),
  512. new _a2(30, new _a1(11, 15), new _a1(46, 16))
  513. ),
  514. new _a3(
  515. 34,
  516. new Array(6, 34, 62, 90, 118, 146),
  517. new _a2(30, new _a1(13, 115), new _a1(6, 116)),
  518. new _a2(28, new _a1(14, 46), new _a1(23, 47)),
  519. new _a2(30, new _a1(44, 24), new _a1(7, 25)),
  520. new _a2(30, new _a1(59, 16), new _a1(1, 17))
  521. ),
  522. new _a3(
  523. 35,
  524. new Array(6, 30, 54, 78, 102, 126, 150),
  525. new _a2(30, new _a1(12, 121), new _a1(7, 122)),
  526. new _a2(28, new _a1(12, 47), new _a1(26, 48)),
  527. new _a2(30, new _a1(39, 24), new _a1(14, 25)),
  528. new _a2(30, new _a1(22, 15), new _a1(41, 16))
  529. ),
  530. new _a3(
  531. 36,
  532. new Array(6, 24, 50, 76, 102, 128, 154),
  533. new _a2(30, new _a1(6, 121), new _a1(14, 122)),
  534. new _a2(28, new _a1(6, 47), new _a1(34, 48)),
  535. new _a2(30, new _a1(46, 24), new _a1(10, 25)),
  536. new _a2(30, new _a1(2, 15), new _a1(64, 16))
  537. ),
  538. new _a3(
  539. 37,
  540. new Array(6, 28, 54, 80, 106, 132, 158),
  541. new _a2(30, new _a1(17, 122), new _a1(4, 123)),
  542. new _a2(28, new _a1(29, 46), new _a1(14, 47)),
  543. new _a2(30, new _a1(49, 24), new _a1(10, 25)),
  544. new _a2(30, new _a1(24, 15), new _a1(46, 16))
  545. ),
  546. new _a3(
  547. 38,
  548. new Array(6, 32, 58, 84, 110, 136, 162),
  549. new _a2(30, new _a1(4, 122), new _a1(18, 123)),
  550. new _a2(28, new _a1(13, 46), new _a1(32, 47)),
  551. new _a2(30, new _a1(48, 24), new _a1(14, 25)),
  552. new _a2(30, new _a1(42, 15), new _a1(32, 16))
  553. ),
  554. new _a3(
  555. 39,
  556. new Array(6, 26, 54, 82, 110, 138, 166),
  557. new _a2(30, new _a1(20, 117), new _a1(4, 118)),
  558. new _a2(28, new _a1(40, 47), new _a1(7, 48)),
  559. new _a2(30, new _a1(43, 24), new _a1(22, 25)),
  560. new _a2(30, new _a1(10, 15), new _a1(67, 16))
  561. ),
  562. new _a3(
  563. 40,
  564. new Array(6, 30, 58, 86, 114, 142, 170),
  565. new _a2(30, new _a1(19, 118), new _a1(6, 119)),
  566. new _a2(28, new _a1(18, 47), new _a1(31, 48)),
  567. new _a2(30, new _a1(34, 24), new _a1(34, 25)),
  568. new _a2(30, new _a1(20, 15), new _a1(61, 16))
  569. )
  570. );
  571. }
  572. function _ae(i, f, c, h, e, b, g, d, a) {
  573. this.a11 = i;
  574. this.a12 = h;
  575. this.a13 = g;
  576. this.a21 = f;
  577. this.a22 = e;
  578. this.a23 = d;
  579. this.a31 = c;
  580. this.a32 = b;
  581. this.a33 = a;
  582. this._ad = function (v) {
  583. var s = v.length;
  584. var z = this.a11;
  585. var w = this.a12;
  586. var u = this.a13;
  587. var q = this.a21;
  588. var p = this.a22;
  589. var o = this.a23;
  590. var m = this.a31;
  591. var k = this.a32;
  592. var j = this.a33;
  593. for (var n = 0; n < s; n += 2) {
  594. var t = v[n];
  595. var r = v[n + 1];
  596. var l = u * t + o * r + j;
  597. v[n] = (z * t + q * r + m) / l;
  598. v[n + 1] = (w * t + p * r + k) / l;
  599. }
  600. };
  601. this._fp = function (m, k) {
  602. var q = m.length;
  603. for (var l = 0; l < q; l++) {
  604. var j = m[l];
  605. var p = k[l];
  606. var o = this.a13 * j + this.a23 * p + this.a33;
  607. m[l] = (this.a11 * j + this.a21 * p + this.a31) / o;
  608. k[l] = (this.a12 * j + this.a22 * p + this.a32) / o;
  609. }
  610. };
  611. this._fr = function () {
  612. return new _ae(
  613. this.a22 * this.a33 - this.a23 * this.a32,
  614. this.a23 * this.a31 - this.a21 * this.a33,
  615. this.a21 * this.a32 - this.a22 * this.a31,
  616. this.a13 * this.a32 - this.a12 * this.a33,
  617. this.a11 * this.a33 - this.a13 * this.a31,
  618. this.a12 * this.a31 - this.a11 * this.a32,
  619. this.a12 * this.a23 - this.a13 * this.a22,
  620. this.a13 * this.a21 - this.a11 * this.a23,
  621. this.a11 * this.a22 - this.a12 * this.a21
  622. );
  623. };
  624. this.times = function (j) {
  625. return new _ae(
  626. this.a11 * j.a11 + this.a21 * j.a12 + this.a31 * j.a13,
  627. this.a11 * j.a21 + this.a21 * j.a22 + this.a31 * j.a23,
  628. this.a11 * j.a31 + this.a21 * j.a32 + this.a31 * j.a33,
  629. this.a12 * j.a11 + this.a22 * j.a12 + this.a32 * j.a13,
  630. this.a12 * j.a21 + this.a22 * j.a22 + this.a32 * j.a23,
  631. this.a12 * j.a31 + this.a22 * j.a32 + this.a32 * j.a33,
  632. this.a13 * j.a11 + this.a23 * j.a12 + this.a33 * j.a13,
  633. this.a13 * j.a21 + this.a23 * j.a22 + this.a33 * j.a23,
  634. this.a13 * j.a31 + this.a23 * j.a32 + this.a33 * j.a33
  635. );
  636. };
  637. }
  638. _ae._ag = function (p, e, o, d, n, c, m, b, h, q, l, f, a, j, i, r) {
  639. var g = this._be(p, e, o, d, n, c, m, b);
  640. var k = this._bf(h, q, l, f, a, j, i, r);
  641. return k.times(g);
  642. };
  643. _ae._bf = function (d, p, c, m, b, k, a, j) {
  644. var h = j - k;
  645. var f = p - m + k - j;
  646. if (h == 0 && f == 0) {
  647. return new _ae(c - d, b - c, d, m - p, k - m, p, 0, 0, 1);
  648. } else {
  649. var q = c - b;
  650. var o = a - b;
  651. var l = d - c + b - a;
  652. var i = m - k;
  653. var e = q * h - o * i;
  654. var n = (l * h - o * f) / e;
  655. var g = (q * f - l * i) / e;
  656. return new _ae(
  657. c - d + n * c,
  658. a - d + g * a,
  659. d,
  660. m - p + n * m,
  661. j - p + g * j,
  662. p,
  663. n,
  664. g,
  665. 1
  666. );
  667. }
  668. };
  669. _ae._be = function (f, h, d, g, b, e, a, c) {
  670. return this._bf(f, h, d, g, b, e, a, c)._fr();
  671. };
  672. function _bg(b, a) {
  673. this.bits = b;
  674. this.points = a;
  675. }
  676. function Detector(a) {
  677. this.image = a;
  678. this._am = null;
  679. this._bi = function (m, l, c, b) {
  680. var d = Math.abs(b - l) > Math.abs(c - m);
  681. if (d) {
  682. var r = m;
  683. m = l;
  684. l = r;
  685. r = c;
  686. c = b;
  687. b = r;
  688. }
  689. var j = Math.abs(c - m);
  690. var i = Math.abs(b - l);
  691. var p = -j >> 1;
  692. var u = l < b ? 1 : -1;
  693. var f = m < c ? 1 : -1;
  694. var e = 0;
  695. for (var h = m, g = l; h != c; h += f) {
  696. var t = d ? g : h;
  697. var s = d ? h : g;
  698. if (e == 1) {
  699. if (this.image[t + s * qrcode.width]) {
  700. e++;
  701. }
  702. } else {
  703. if (!this.image[t + s * qrcode.width]) {
  704. e++;
  705. }
  706. }
  707. if (e == 3) {
  708. var o = h - m;
  709. var n = g - l;
  710. return Math.sqrt(o * o + n * n);
  711. }
  712. p += i;
  713. if (p > 0) {
  714. if (g == b) {
  715. break;
  716. }
  717. g += u;
  718. p -= j;
  719. }
  720. }
  721. var k = c - m;
  722. var q = b - l;
  723. return Math.sqrt(k * k + q * q);
  724. };
  725. this._bh = function (i, g, h, f) {
  726. var b = this._bi(i, g, h, f);
  727. var e = 1;
  728. var d = i - (h - i);
  729. if (d < 0) {
  730. e = i / (i - d);
  731. d = 0;
  732. } else {
  733. if (d >= qrcode.width) {
  734. e = (qrcode.width - 1 - i) / (d - i);
  735. d = qrcode.width - 1;
  736. }
  737. }
  738. var c = Math.floor(g - (f - g) * e);
  739. e = 1;
  740. if (c < 0) {
  741. e = g / (g - c);
  742. c = 0;
  743. } else {
  744. if (c >= qrcode.height) {
  745. e = (qrcode.height - 1 - g) / (c - g);
  746. c = qrcode.height - 1;
  747. }
  748. }
  749. d = Math.floor(i + (d - i) * e);
  750. b += this._bi(i, g, d, c);
  751. return b - 1;
  752. };
  753. this._bj = function (c, d) {
  754. var b = this._bh(
  755. Math.floor(c.X),
  756. Math.floor(c.Y),
  757. Math.floor(d.X),
  758. Math.floor(d.Y)
  759. );
  760. var e = this._bh(
  761. Math.floor(d.X),
  762. Math.floor(d.Y),
  763. Math.floor(c.X),
  764. Math.floor(c.Y)
  765. );
  766. if (isNaN(b)) {
  767. return e / 7;
  768. }
  769. if (isNaN(e)) {
  770. return b / 7;
  771. }
  772. return (b + e) / 14;
  773. };
  774. this._bk = function (d, c, b) {
  775. return (this._bj(d, c) + this._bj(d, b)) / 2;
  776. };
  777. this.distance = function (d, b) {
  778. var e = d.X - b.X;
  779. var c = d.Y - b.Y;
  780. return Math.sqrt(e * e + c * c);
  781. };
  782. this._bx = function (g, f, d, e) {
  783. var b = Math.round(this.distance(g, f) / e);
  784. var c = Math.round(this.distance(g, d) / e);
  785. var h = ((b + c) >> 1) + 7;
  786. switch (h & 3) {
  787. case 0:
  788. h++;
  789. break;
  790. case 2:
  791. h--;
  792. break;
  793. case 3:
  794. throw "Error";
  795. }
  796. return h;
  797. };
  798. this._bl = function (g, f, d, j) {
  799. var k = Math.floor(j * g);
  800. var h = Math.max(0, f - k);
  801. var i = Math.min(qrcode.width - 1, f + k);
  802. if (i - h < g * 3) {
  803. throw "Error";
  804. }
  805. var b = Math.max(0, d - k);
  806. var c = Math.min(qrcode.height - 1, d + k);
  807. var e = new _ak(this.image, h, b, i - h, c - b, g, this._am);
  808. return e.find();
  809. };
  810. this.createTransform = function (l, h, k, b, g) {
  811. var j = g - 3.5;
  812. var i;
  813. var f;
  814. var e;
  815. var c;
  816. if (b != null) {
  817. i = b.X;
  818. f = b.Y;
  819. e = c = j - 3;
  820. } else {
  821. i = h.X - l.X + k.X;
  822. f = h.Y - l.Y + k.Y;
  823. e = c = j;
  824. }
  825. var d = _ae._ag(
  826. 3.5,
  827. 3.5,
  828. j,
  829. 3.5,
  830. e,
  831. c,
  832. 3.5,
  833. j,
  834. l.X,
  835. l.Y,
  836. h.X,
  837. h.Y,
  838. i,
  839. f,
  840. k.X,
  841. k.Y
  842. );
  843. return d;
  844. };
  845. this._bz = function (e, b, d) {
  846. var c = _aa;
  847. return c._af(e, d, b);
  848. };
  849. this._cd = function (q) {
  850. var j = q._gq;
  851. var h = q._gs;
  852. var n = q._gp;
  853. var d = this._bk(j, h, n);
  854. if (d < 1) {
  855. throw "Error";
  856. }
  857. var r = this._bx(j, h, n, d);
  858. var b = _a3._at(r);
  859. var k = b._cr - 7;
  860. var l = null;
  861. if (b._as.length > 0) {
  862. var f = h.X - j.X + n.X;
  863. var e = h.Y - j.Y + n.Y;
  864. var c = 1 - 3 / k;
  865. var t = Math.floor(j.X + c * (f - j.X));
  866. var s = Math.floor(j.Y + c * (e - j.Y));
  867. for (var p = 4; p <= 16; p <<= 1) {
  868. l = this._bl(d, t, s, p);
  869. break;
  870. }
  871. }
  872. var g = this.createTransform(j, h, n, l, r);
  873. var m = this._bz(this.image, g, r);
  874. var o;
  875. if (l == null) {
  876. o = new Array(n, j, h);
  877. } else {
  878. o = new Array(n, j, h, l);
  879. }
  880. return new _bg(m, o);
  881. };
  882. this.detect = function () {
  883. var b = new _cc()._ce(this.image);
  884. return this._cd(b);
  885. };
  886. }
  887. var _ca = 21522;
  888. var _cb = new Array(
  889. new Array(21522, 0),
  890. new Array(20773, 1),
  891. new Array(24188, 2),
  892. new Array(23371, 3),
  893. new Array(17913, 4),
  894. new Array(16590, 5),
  895. new Array(20375, 6),
  896. new Array(19104, 7),
  897. new Array(30660, 8),
  898. new Array(29427, 9),
  899. new Array(32170, 10),
  900. new Array(30877, 11),
  901. new Array(26159, 12),
  902. new Array(25368, 13),
  903. new Array(27713, 14),
  904. new Array(26998, 15),
  905. new Array(5769, 16),
  906. new Array(5054, 17),
  907. new Array(7399, 18),
  908. new Array(6608, 19),
  909. new Array(1890, 20),
  910. new Array(597, 21),
  911. new Array(3340, 22),
  912. new Array(2107, 23),
  913. new Array(13663, 24),
  914. new Array(12392, 25),
  915. new Array(16177, 26),
  916. new Array(14854, 27),
  917. new Array(9396, 28),
  918. new Array(8579, 29),
  919. new Array(11994, 30),
  920. new Array(11245, 31)
  921. );
  922. var _ch = new Array(0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4);
  923. function _ax(a) {
  924. this._cf = _cg.forBits((a >> 3) & 3);
  925. this._fe = a & 7;
  926. this.__defineGetter__("_cg", function () {
  927. return this._cf;
  928. });
  929. this.__defineGetter__("_dx", function () {
  930. return this._fe;
  931. });
  932. this.GetHashCode = function () {
  933. return (this._cf.ordinal() << 3) | _fe;
  934. };
  935. this.Equals = function (c) {
  936. var b = c;
  937. return this._cf == b._cf && this._fe == b._fe;
  938. };
  939. }
  940. _ax._gj = function (d, c) {
  941. d ^= c;
  942. return (
  943. _ch[d & 15] +
  944. _ch[_ew(d, 4) & 15] +
  945. _ch[_ew(d, 8) & 15] +
  946. _ch[_ew(d, 12) & 15] +
  947. _ch[_ew(d, 16) & 15] +
  948. _ch[_ew(d, 20) & 15] +
  949. _ch[_ew(d, 24) & 15] +
  950. _ch[_ew(d, 28) & 15]
  951. );
  952. };
  953. _ax._ci = function (a) {
  954. var b = _ax._cj(a);
  955. if (b != null) {
  956. return b;
  957. }
  958. return _ax._cj(a ^ _ca);
  959. };
  960. _ax._cj = function (d) {
  961. var b = 4294967295;
  962. var a = 0;
  963. for (var c = 0; c < _cb.length; c++) {
  964. var g = _cb[c];
  965. var f = g[0];
  966. if (f == d) {
  967. return new _ax(g[1]);
  968. }
  969. var e = this._gj(d, f);
  970. if (e < b) {
  971. a = g[1];
  972. b = e;
  973. }
  974. }
  975. if (b <= 3) {
  976. return new _ax(a);
  977. }
  978. return null;
  979. };
  980. function _cg(a, c, b) {
  981. this._ff = a;
  982. this.bits = c;
  983. this.name = b;
  984. this.__defineGetter__("Bits", function () {
  985. return this.bits;
  986. });
  987. this.__defineGetter__("Name", function () {
  988. return this.name;
  989. });
  990. this.ordinal = function () {
  991. return this._ff;
  992. };
  993. }
  994. _cg.forBits = function (a) {
  995. if (a < 0 || a >= FOR_BITS.length) {
  996. throw "bad arguments";
  997. }
  998. return FOR_BITS[a];
  999. };
  1000. var L = new _cg(0, 1, "L");
  1001. var M = new _cg(1, 0, "M");
  1002. var Q = new _cg(2, 3, "Q");
  1003. var H = new _cg(3, 2, "H");
  1004. var FOR_BITS = new Array(M, L, H, Q);
  1005. function _ac(d, a) {
  1006. if (!a) {
  1007. a = d;
  1008. }
  1009. if (d < 1 || a < 1) {
  1010. throw "Both dimensions must be greater than 0";
  1011. }
  1012. this.width = d;
  1013. this.height = a;
  1014. var c = d >> 5;
  1015. if ((d & 31) != 0) {
  1016. c++;
  1017. }
  1018. this.rowSize = c;
  1019. this.bits = new Array(c * a);
  1020. for (var b = 0; b < this.bits.length; b++) {
  1021. this.bits[b] = 0;
  1022. }
  1023. this.__defineGetter__("Width", function () {
  1024. return this.width;
  1025. });
  1026. this.__defineGetter__("Height", function () {
  1027. return this.height;
  1028. });
  1029. this.__defineGetter__("Dimension", function () {
  1030. if (this.width != this.height) {
  1031. throw "Can't call getDimension() on a non-square matrix";
  1032. }
  1033. return this.width;
  1034. });
  1035. this._ds = function (e, g) {
  1036. var f = g * this.rowSize + (e >> 5);
  1037. return (_ew(this.bits[f], e & 31) & 1) != 0;
  1038. };
  1039. this._dq = function (e, g) {
  1040. var f = g * this.rowSize + (e >> 5);
  1041. this.bits[f] |= 1 << (e & 31);
  1042. };
  1043. this.flip = function (e, g) {
  1044. var f = g * this.rowSize + (e >> 5);
  1045. this.bits[f] ^= 1 << (e & 31);
  1046. };
  1047. this.clear = function () {
  1048. var e = this.bits.length;
  1049. for (var f = 0; f < e; f++) {
  1050. this.bits[f] = 0;
  1051. }
  1052. };
  1053. this._bq = function (g, j, f, m) {
  1054. if (j < 0 || g < 0) {
  1055. throw "Left and top must be nonnegative";
  1056. }
  1057. if (m < 1 || f < 1) {
  1058. throw "Height and width must be at least 1";
  1059. }
  1060. var l = g + f;
  1061. var e = j + m;
  1062. if (e > this.height || l > this.width) {
  1063. throw "The region must fit inside the matrix";
  1064. }
  1065. for (var i = j; i < e; i++) {
  1066. var h = i * this.rowSize;
  1067. for (var k = g; k < l; k++) {
  1068. this.bits[h + (k >> 5)] |= 1 << (k & 31);
  1069. }
  1070. }
  1071. };
  1072. }
  1073. function _dl(a, b) {
  1074. this._dv = a;
  1075. this._dw = b;
  1076. this.__defineGetter__("_du", function () {
  1077. return this._dv;
  1078. });
  1079. this.__defineGetter__("Codewords", function () {
  1080. return this._dw;
  1081. });
  1082. }
  1083. _dl._gn = function (c, h, r) {
  1084. if (c.length != h._dp) {
  1085. throw "bad arguments";
  1086. }
  1087. var k = h._bu(r);
  1088. var e = 0;
  1089. var d = k._fb();
  1090. for (var q = 0; q < d.length; q++) {
  1091. e += d[q].Count;
  1092. }
  1093. var l = new Array(e);
  1094. var n = 0;
  1095. for (var o = 0; o < d.length; o++) {
  1096. var f = d[o];
  1097. for (var q = 0; q < f.Count; q++) {
  1098. var m = f._dm;
  1099. var s = k._bo + m;
  1100. l[n++] = new _dl(m, new Array(s));
  1101. }
  1102. }
  1103. var t = l[0]._dw.length;
  1104. var b = l.length - 1;
  1105. while (b >= 0) {
  1106. var v = l[b]._dw.length;
  1107. if (v == t) {
  1108. break;
  1109. }
  1110. b--;
  1111. }
  1112. b++;
  1113. var g = t - k._bo;
  1114. var a = 0;
  1115. for (var q = 0; q < g; q++) {
  1116. for (var o = 0; o < n; o++) {
  1117. l[o]._dw[q] = c[a++];
  1118. }
  1119. }
  1120. for (var o = b; o < n; o++) {
  1121. l[o]._dw[g] = c[a++];
  1122. }
  1123. var p = l[0]._dw.length;
  1124. for (var q = g; q < p; q++) {
  1125. for (var o = 0; o < n; o++) {
  1126. var u = o < b ? q : q + 1;
  1127. l[o]._dw[u] = c[a++];
  1128. }
  1129. }
  1130. return l;
  1131. };
  1132. function _cl(a) {
  1133. var b = a.Dimension;
  1134. if (b < 21 || (b & 3) != 1) {
  1135. throw "Error _cl";
  1136. }
  1137. this._au = a;
  1138. this._cp = null;
  1139. this._co = null;
  1140. this._dk = function (d, c, e) {
  1141. return this._au._ds(d, c) ? (e << 1) | 1 : e << 1;
  1142. };
  1143. this._cm = function () {
  1144. if (this._co != null) {
  1145. return this._co;
  1146. }
  1147. var g = 0;
  1148. for (var e = 0; e < 6; e++) {
  1149. g = this._dk(e, 8, g);
  1150. }
  1151. g = this._dk(7, 8, g);
  1152. g = this._dk(8, 8, g);
  1153. g = this._dk(8, 7, g);
  1154. for (var c = 5; c >= 0; c--) {
  1155. g = this._dk(8, c, g);
  1156. }
  1157. this._co = _ax._ci(g);
  1158. if (this._co != null) {
  1159. return this._co;
  1160. }
  1161. var f = this._au.Dimension;
  1162. g = 0;
  1163. var d = f - 8;
  1164. for (var e = f - 1; e >= d; e--) {
  1165. g = this._dk(e, 8, g);
  1166. }
  1167. for (var c = f - 7; c < f; c++) {
  1168. g = this._dk(8, c, g);
  1169. }
  1170. this._co = _ax._ci(g);
  1171. if (this._co != null) {
  1172. return this._co;
  1173. }
  1174. throw "Error _cm";
  1175. };
  1176. this._cq = function () {
  1177. if (this._cp != null) {
  1178. return this._cp;
  1179. }
  1180. var h = this._au.Dimension;
  1181. var f = (h - 17) >> 2;
  1182. if (f <= 6) {
  1183. return _a3._av(f);
  1184. }
  1185. var g = 0;
  1186. var e = h - 11;
  1187. for (var c = 5; c >= 0; c--) {
  1188. for (var d = h - 9; d >= e; d--) {
  1189. g = this._dk(d, c, g);
  1190. }
  1191. }
  1192. this._cp = _a3._aw(g);
  1193. if (this._cp != null && this._cp._cr == h) {
  1194. return this._cp;
  1195. }
  1196. g = 0;
  1197. for (var d = 5; d >= 0; d--) {
  1198. for (var c = h - 9; c >= e; c--) {
  1199. g = this._dk(d, c, g);
  1200. }
  1201. }
  1202. this._cp = _a3._aw(g);
  1203. if (this._cp != null && this._cp._cr == h) {
  1204. return this._cp;
  1205. }
  1206. throw "Error _cq";
  1207. };
  1208. this._gk = function () {
  1209. var q = this._cm();
  1210. var o = this._cq();
  1211. var c = _dx._gl(q._dx);
  1212. var f = this._au.Dimension;
  1213. c._dj(this._au, f);
  1214. var k = o._aq();
  1215. var n = true;
  1216. var r = new Array(o._dp);
  1217. var m = 0;
  1218. var p = 0;
  1219. var h = 0;
  1220. for (var e = f - 1; e > 0; e -= 2) {
  1221. if (e == 6) {
  1222. e--;
  1223. }
  1224. for (var l = 0; l < f; l++) {
  1225. var g = n ? f - 1 - l : l;
  1226. for (var d = 0; d < 2; d++) {
  1227. if (!k._ds(e - d, g)) {
  1228. h++;
  1229. p <<= 1;
  1230. if (this._au._ds(e - d, g)) {
  1231. p |= 1;
  1232. }
  1233. if (h == 8) {
  1234. r[m++] = p;
  1235. h = 0;
  1236. p = 0;
  1237. }
  1238. }
  1239. }
  1240. }
  1241. n ^= true;
  1242. }
  1243. if (m != o._dp) {
  1244. throw "Error _gk";
  1245. }
  1246. return r;
  1247. };
  1248. }
  1249. var _dx = {};
  1250. _dx._gl = function (a) {
  1251. if (a < 0 || a > 7) {
  1252. throw "bad arguments";
  1253. }
  1254. return _dx._dy[a];
  1255. };
  1256. function _fg() {
  1257. this._dj = function (c, d) {
  1258. for (var b = 0; b < d; b++) {
  1259. for (var a = 0; a < d; a++) {
  1260. if (this._fw(b, a)) {
  1261. c.flip(a, b);
  1262. }
  1263. }
  1264. }
  1265. };
  1266. this._fw = function (b, a) {
  1267. return ((b + a) & 1) == 0;
  1268. };
  1269. }
  1270. function _fh() {
  1271. this._dj = function (c, d) {
  1272. for (var b = 0; b < d; b++) {
  1273. for (var a = 0; a < d; a++) {
  1274. if (this._fw(b, a)) {
  1275. c.flip(a, b);
  1276. }
  1277. }
  1278. }
  1279. };
  1280. this._fw = function (b, a) {
  1281. return (b & 1) == 0;
  1282. };
  1283. }
  1284. function _fi() {
  1285. this._dj = function (c, d) {
  1286. for (var b = 0; b < d; b++) {
  1287. for (var a = 0; a < d; a++) {
  1288. if (this._fw(b, a)) {
  1289. c.flip(a, b);
  1290. }
  1291. }
  1292. }
  1293. };
  1294. this._fw = function (b, a) {
  1295. return a % 3 == 0;
  1296. };
  1297. }
  1298. function _fj() {
  1299. this._dj = function (c, d) {
  1300. for (var b = 0; b < d; b++) {
  1301. for (var a = 0; a < d; a++) {
  1302. if (this._fw(b, a)) {
  1303. c.flip(a, b);
  1304. }
  1305. }
  1306. }
  1307. };
  1308. this._fw = function (b, a) {
  1309. return (b + a) % 3 == 0;
  1310. };
  1311. }
  1312. function _fk() {
  1313. this._dj = function (c, d) {
  1314. for (var b = 0; b < d; b++) {
  1315. for (var a = 0; a < d; a++) {
  1316. if (this._fw(b, a)) {
  1317. c.flip(a, b);
  1318. }
  1319. }
  1320. }
  1321. };
  1322. this._fw = function (b, a) {
  1323. return ((_ew(b, 1) + a / 3) & 1) == 0;
  1324. };
  1325. }
  1326. function _fl() {
  1327. this._dj = function (c, d) {
  1328. for (var b = 0; b < d; b++) {
  1329. for (var a = 0; a < d; a++) {
  1330. if (this._fw(b, a)) {
  1331. c.flip(a, b);
  1332. }
  1333. }
  1334. }
  1335. };
  1336. this._fw = function (c, b) {
  1337. var a = c * b;
  1338. return (a & 1) + (a % 3) == 0;
  1339. };
  1340. }
  1341. function _fm() {
  1342. this._dj = function (c, d) {
  1343. for (var b = 0; b < d; b++) {
  1344. for (var a = 0; a < d; a++) {
  1345. if (this._fw(b, a)) {
  1346. c.flip(a, b);
  1347. }
  1348. }
  1349. }
  1350. };
  1351. this._fw = function (c, b) {
  1352. var a = c * b;
  1353. return (((a & 1) + (a % 3)) & 1) == 0;
  1354. };
  1355. }
  1356. function _fn() {
  1357. this._dj = function (c, d) {
  1358. for (var b = 0; b < d; b++) {
  1359. for (var a = 0; a < d; a++) {
  1360. if (this._fw(b, a)) {
  1361. c.flip(a, b);
  1362. }
  1363. }
  1364. }
  1365. };
  1366. this._fw = function (b, a) {
  1367. return ((((b + a) & 1) + ((b * a) % 3)) & 1) == 0;
  1368. };
  1369. }
  1370. _dx._dy = new Array(
  1371. new _fg(),
  1372. new _fh(),
  1373. new _fi(),
  1374. new _fj(),
  1375. new _fk(),
  1376. new _fl(),
  1377. new _fm(),
  1378. new _fn()
  1379. );
  1380. function _db(a) {
  1381. this._fa = a;
  1382. this.decode = function (j, f) {
  1383. var c = new _bp(this._fa, j);
  1384. var p = new Array(f);
  1385. for (var g = 0; g < p.length; g++) {
  1386. p[g] = 0;
  1387. }
  1388. var m = false;
  1389. var d = true;
  1390. for (var g = 0; g < f; g++) {
  1391. var q = c.evaluateAt(this._fa.exp(m ? g + 1 : g));
  1392. p[p.length - 1 - g] = q;
  1393. if (q != 0) {
  1394. d = false;
  1395. }
  1396. }
  1397. if (d) {
  1398. return;
  1399. }
  1400. var b = new _bp(this._fa, p);
  1401. var l = this._eb(this._fa._ba(f, 1), b, f);
  1402. var o = l[0];
  1403. var n = l[1];
  1404. var k = this._ey(o);
  1405. var e = this._di(n, k, m);
  1406. for (var g = 0; g < k.length; g++) {
  1407. var h = j.length - 1 - this._fa.log(k[g]);
  1408. if (h < 0) {
  1409. throw "ReedSolomonException Bad error location";
  1410. }
  1411. j[h] = _az._bd(j[h], e[g]);
  1412. }
  1413. };
  1414. this._eb = function (z, y, f) {
  1415. if (z._ec < y._ec) {
  1416. var w = z;
  1417. z = y;
  1418. y = w;
  1419. }
  1420. var B = z;
  1421. var k = y;
  1422. var o = this._fa.One;
  1423. var j = this._fa.Zero;
  1424. var e = this._fa.Zero;
  1425. var i = this._fa.One;
  1426. while (k._ec >= Math.floor(f / 2)) {
  1427. var x = B;
  1428. var g = o;
  1429. var v = e;
  1430. B = k;
  1431. o = j;
  1432. e = i;
  1433. if (B.Zero) {
  1434. throw "r_{i-1} was zero";
  1435. }
  1436. k = x;
  1437. var m = this._fa.Zero;
  1438. var p = B._ex(B._ec);
  1439. var h = this._fa.inverse(p);
  1440. while (k._ec >= B._ec && !k.Zero) {
  1441. var c = k._ec - B._ec;
  1442. var A = this._fa.multiply(k._ex(k._ec), h);
  1443. m = m._bd(this._fa._ba(c, A));
  1444. k = k._bd(B._dc(c, A));
  1445. }
  1446. j = m.multiply1(o)._bd(g);
  1447. i = m.multiply1(e)._bd(v);
  1448. }
  1449. var u = i._ex(0);
  1450. if (u == 0) {
  1451. throw "ReedSolomonException sigmaTilde(0) was zero";
  1452. }
  1453. var d = this._fa.inverse(u);
  1454. var n = i.multiply2(d);
  1455. var l = k.multiply2(d);
  1456. return new Array(n, l);
  1457. };
  1458. this._ey = function (f) {
  1459. var g = f._ec;
  1460. if (g == 1) {
  1461. return new Array(f._ex(1));
  1462. }
  1463. var b = new Array(g);
  1464. var d = 0;
  1465. for (var c = 1; c < 256 && d < g; c++) {
  1466. if (f.evaluateAt(c) == 0) {
  1467. b[d] = this._fa.inverse(c);
  1468. d++;
  1469. }
  1470. }
  1471. if (d != g) {
  1472. throw "Error locator degree does not match number of roots";
  1473. }
  1474. return b;
  1475. };
  1476. this._di = function (f, h, g) {
  1477. var k = h.length;
  1478. var l = new Array(k);
  1479. for (var e = 0; e < k; e++) {
  1480. var b = this._fa.inverse(h[e]);
  1481. var c = 1;
  1482. for (var d = 0; d < k; d++) {
  1483. if (e != d) {
  1484. c = this._fa.multiply(c, _az._bd(1, this._fa.multiply(h[d], b)));
  1485. }
  1486. }
  1487. l[e] = this._fa.multiply(f.evaluateAt(b), this._fa.inverse(c));
  1488. if (g) {
  1489. l[e] = this._fa.multiply(l[e], b);
  1490. }
  1491. }
  1492. return l;
  1493. };
  1494. }
  1495. function _bp(f, e) {
  1496. if (e == null || e.length == 0) {
  1497. throw "bad arguments";
  1498. }
  1499. this._fa = f;
  1500. var c = e.length;
  1501. if (c > 1 && e[0] == 0) {
  1502. var d = 1;
  1503. while (d < c && e[d] == 0) {
  1504. d++;
  1505. }
  1506. if (d == c) {
  1507. this._dd = f.Zero._dd;
  1508. } else {
  1509. this._dd = new Array(c - d);
  1510. for (var b = 0; b < this._dd.length; b++) {
  1511. this._dd[b] = 0;
  1512. }
  1513. for (var a = 0; a < this._dd.length; a++) {
  1514. this._dd[a] = e[d + a];
  1515. }
  1516. }
  1517. } else {
  1518. this._dd = e;
  1519. }
  1520. this.__defineGetter__("Zero", function () {
  1521. return this._dd[0] == 0;
  1522. });
  1523. this.__defineGetter__("_ec", function () {
  1524. return this._dd.length - 1;
  1525. });
  1526. this.__defineGetter__("Coefficients", function () {
  1527. return this._dd;
  1528. });
  1529. this._ex = function (g) {
  1530. return this._dd[this._dd.length - 1 - g];
  1531. };
  1532. this.evaluateAt = function (h) {
  1533. if (h == 0) {
  1534. return this._ex(0);
  1535. }
  1536. var l = this._dd.length;
  1537. if (h == 1) {
  1538. var g = 0;
  1539. for (var k = 0; k < l; k++) {
  1540. g = _az._bd(g, this._dd[k]);
  1541. }
  1542. return g;
  1543. }
  1544. var j = this._dd[0];
  1545. for (var k = 1; k < l; k++) {
  1546. j = _az._bd(this._fa.multiply(h, j), this._dd[k]);
  1547. }
  1548. return j;
  1549. };
  1550. this._bd = function (g) {
  1551. if (this._fa != g._fa) {
  1552. throw "GF256Polys do not have same _az _fa";
  1553. }
  1554. if (this.Zero) {
  1555. return g;
  1556. }
  1557. if (g.Zero) {
  1558. return this;
  1559. }
  1560. var o = this._dd;
  1561. var n = g._dd;
  1562. if (o.length > n.length) {
  1563. var j = o;
  1564. o = n;
  1565. n = j;
  1566. }
  1567. var h = new Array(n.length);
  1568. var k = n.length - o.length;
  1569. for (var m = 0; m < k; m++) {
  1570. h[m] = n[m];
  1571. }
  1572. for (var l = k; l < n.length; l++) {
  1573. h[l] = _az._bd(o[l - k], n[l]);
  1574. }
  1575. return new _bp(f, h);
  1576. };
  1577. this.multiply1 = function (o) {
  1578. if (this._fa != o._fa) {
  1579. throw "GF256Polys do not have same _az _fa";
  1580. }
  1581. if (this.Zero || o.Zero) {
  1582. return this._fa.Zero;
  1583. }
  1584. var q = this._dd;
  1585. var g = q.length;
  1586. var l = o._dd;
  1587. var n = l.length;
  1588. var p = new Array(g + n - 1);
  1589. for (var m = 0; m < g; m++) {
  1590. var h = q[m];
  1591. for (var k = 0; k < n; k++) {
  1592. p[m + k] = _az._bd(p[m + k], this._fa.multiply(h, l[k]));
  1593. }
  1594. }
  1595. return new _bp(this._fa, p);
  1596. };
  1597. this.multiply2 = function (g) {
  1598. if (g == 0) {
  1599. return this._fa.Zero;
  1600. }
  1601. if (g == 1) {
  1602. return this;
  1603. }
  1604. var j = this._dd.length;
  1605. var k = new Array(j);
  1606. for (var h = 0; h < j; h++) {
  1607. k[h] = this._fa.multiply(this._dd[h], g);
  1608. }
  1609. return new _bp(this._fa, k);
  1610. };
  1611. this._dc = function (l, g) {
  1612. if (l < 0) {
  1613. throw "bad arguments";
  1614. }
  1615. if (g == 0) {
  1616. return this._fa.Zero;
  1617. }
  1618. var j = this._dd.length;
  1619. var k = new Array(j + l);
  1620. for (var h = 0; h < k.length; h++) {
  1621. k[h] = 0;
  1622. }
  1623. for (var h = 0; h < j; h++) {
  1624. k[h] = this._fa.multiply(this._dd[h], g);
  1625. }
  1626. return new _bp(this._fa, k);
  1627. };
  1628. this.divide = function (l) {
  1629. if (this._fa != l._fa) {
  1630. throw "GF256Polys do not have same _az _fa";
  1631. }
  1632. if (l.Zero) {
  1633. throw "Divide by 0";
  1634. }
  1635. var j = this._fa.Zero;
  1636. var o = this;
  1637. var g = l._ex(l._ec);
  1638. var n = this._fa.inverse(g);
  1639. while (o._ec >= l._ec && !o.Zero) {
  1640. var m = o._ec - l._ec;
  1641. var h = this._fa.multiply(o._ex(o._ec), n);
  1642. var i = l._dc(m, h);
  1643. var k = this._fa._ba(m, h);
  1644. j = j._bd(k);
  1645. o = o._bd(i);
  1646. }
  1647. return new Array(j, o);
  1648. };
  1649. }
  1650. function _az(b) {
  1651. this._gh = new Array(256);
  1652. this._gi = new Array(256);
  1653. var a = 1;
  1654. for (var e = 0; e < 256; e++) {
  1655. this._gh[e] = a;
  1656. a <<= 1;
  1657. if (a >= 256) {
  1658. a ^= b;
  1659. }
  1660. }
  1661. for (var e = 0; e < 255; e++) {
  1662. this._gi[this._gh[e]] = e;
  1663. }
  1664. var d = new Array(1);
  1665. d[0] = 0;
  1666. this.zero = new _bp(this, new Array(d));
  1667. var c = new Array(1);
  1668. c[0] = 1;
  1669. this.one = new _bp(this, new Array(c));
  1670. this.__defineGetter__("Zero", function () {
  1671. return this.zero;
  1672. });
  1673. this.__defineGetter__("One", function () {
  1674. return this.one;
  1675. });
  1676. this._ba = function (j, f) {
  1677. if (j < 0) {
  1678. throw "bad arguments";
  1679. }
  1680. if (f == 0) {
  1681. return zero;
  1682. }
  1683. var h = new Array(j + 1);
  1684. for (var g = 0; g < h.length; g++) {
  1685. h[g] = 0;
  1686. }
  1687. h[0] = f;
  1688. return new _bp(this, h);
  1689. };
  1690. this.exp = function (f) {
  1691. return this._gh[f];
  1692. };
  1693. this.log = function (f) {
  1694. if (f == 0) {
  1695. throw "bad arguments";
  1696. }
  1697. return this._gi[f];
  1698. };
  1699. this.inverse = function (f) {
  1700. if (f == 0) {
  1701. throw "System.ArithmeticException";
  1702. }
  1703. return this._gh[255 - this._gi[f]];
  1704. };
  1705. this.multiply = function (g, f) {
  1706. if (g == 0 || f == 0) {
  1707. return 0;
  1708. }
  1709. if (g == 1) {
  1710. return f;
  1711. }
  1712. if (f == 1) {
  1713. return g;
  1714. }
  1715. return this._gh[(this._gi[g] + this._gi[f]) % 255];
  1716. };
  1717. }
  1718. _az._bb = new _az(285);
  1719. _az._bc = new _az(301);
  1720. _az._bd = function (d, c) {
  1721. return d ^ c;
  1722. };
  1723. var Decoder = {};
  1724. Decoder.rsDecoder = new _db(_az._bb);
  1725. Decoder.correctErrors = function (g, b) {
  1726. var d = g.length;
  1727. var f = new Array(d);
  1728. for (var e = 0; e < d; e++) {
  1729. f[e] = g[e] & 255;
  1730. }
  1731. var a = g.length - b;
  1732. try {
  1733. Decoder.rsDecoder.decode(f, a);
  1734. } catch (c) {
  1735. throw c;
  1736. }
  1737. for (var e = 0; e < b; e++) {
  1738. g[e] = f[e];
  1739. }
  1740. };
  1741. Decoder.decode = function (q) {
  1742. var b = new _cl(q);
  1743. var o = b._cq();
  1744. var c = b._cm()._cg;
  1745. var p = b._gk();
  1746. var a = _dl._gn(p, o, c);
  1747. var f = 0;
  1748. for (var k = 0; k < a.length; k++) {
  1749. f += a[k]._du;
  1750. }
  1751. var e = new Array(f);
  1752. var n = 0;
  1753. for (var h = 0; h < a.length; h++) {
  1754. var m = a[h];
  1755. var d = m.Codewords;
  1756. var g = m._du;
  1757. Decoder.correctErrors(d, g);
  1758. for (var k = 0; k < g; k++) {
  1759. e[n++] = d[k];
  1760. }
  1761. }
  1762. var l = new QRCodeDataBlockReader(e, o._fd, c.Bits);
  1763. return l;
  1764. };
  1765. var qrcode = {};
  1766. qrcode.imagedata = null;
  1767. qrcode.width = 0;
  1768. qrcode.height = 0;
  1769. qrcode.qrCodeSymbol = null;
  1770. qrcode.debug = false;
  1771. qrcode.maxImgSize = 1024 * 1024;
  1772. qrcode._eo = [
  1773. [10, 9, 8, 8],
  1774. [12, 11, 16, 10],
  1775. [14, 13, 16, 12],
  1776. ];
  1777. qrcode.callback = null;
  1778. qrcode.vidSuccess = function (a) {
  1779. qrcode.localstream = a;
  1780. if (qrcode.webkit) {
  1781. qrcode.video.src = window.webkitURL.createObjectURL(a);
  1782. } else {
  1783. if (qrcode.moz) {
  1784. qrcode.video.mozSrcObject = a;
  1785. qrcode.video.play();
  1786. } else {
  1787. qrcode.video.src = a;
  1788. }
  1789. }
  1790. qrcode.gUM = true;
  1791. qrcode.canvas_qr2 = document.createElement("canvas");
  1792. qrcode.canvas_qr2.id = "qr-canvas";
  1793. qrcode.qrcontext2 = qrcode.canvas_qr2.getContext("2d");
  1794. qrcode.canvas_qr2.width = qrcode.video.videoWidth;
  1795. qrcode.canvas_qr2.height = qrcode.video.videoHeight;
  1796. setTimeout(qrcode.captureToCanvas, 500);
  1797. };
  1798. qrcode.vidError = function (a) {
  1799. qrcode.gUM = false;
  1800. return;
  1801. };
  1802. qrcode.captureToCanvas = function () {
  1803. if (qrcode.gUM) {
  1804. try {
  1805. if (qrcode.video.videoWidth == 0) {
  1806. setTimeout(qrcode.captureToCanvas, 500);
  1807. return;
  1808. } else {
  1809. qrcode.canvas_qr2.width = qrcode.video.videoWidth;
  1810. qrcode.canvas_qr2.height = qrcode.video.videoHeight;
  1811. }
  1812. qrcode.qrcontext2.drawImage(qrcode.video, 0, 0);
  1813. try {
  1814. qrcode.decode();
  1815. } catch (a) {
  1816. console.log(a);
  1817. setTimeout(qrcode.captureToCanvas, 500);
  1818. }
  1819. } catch (a) {
  1820. console.log(a);
  1821. setTimeout(qrcode.captureToCanvas, 500);
  1822. }
  1823. }
  1824. };
  1825. qrcode.setWebcam = function (c) {
  1826. var d = navigator;
  1827. qrcode.video = document.getElementById(c);
  1828. var a = true;
  1829. if (navigator.mediaDevices && navigator.mediaDevices.enumerateDevices) {
  1830. try {
  1831. navigator.mediaDevices.enumerateDevices().then(function (e) {
  1832. e.forEach(function (f) {
  1833. console.log("deb1");
  1834. if (f.kind === "videoinput") {
  1835. if (f.label.toLowerCase().search("back") > -1) {
  1836. a = [
  1837. {
  1838. sourceId: f.deviceId,
  1839. },
  1840. ];
  1841. }
  1842. }
  1843. console.log(f.kind + ": " + f.label + " id = " + f.deviceId);
  1844. });
  1845. });
  1846. } catch (b) {
  1847. console.log(b);
  1848. }
  1849. } else {
  1850. console.log("no navigator.mediaDevices.enumerateDevices");
  1851. }
  1852. if (d.getUserMedia) {
  1853. d.getUserMedia(
  1854. {
  1855. video: a,
  1856. audio: false,
  1857. },
  1858. qrcode.vidSuccess,
  1859. qrcode.vidError
  1860. );
  1861. } else {
  1862. if (d.webkitGetUserMedia) {
  1863. qrcode.webkit = true;
  1864. d.webkitGetUserMedia(
  1865. {
  1866. video: a,
  1867. audio: false,
  1868. },
  1869. qrcode.vidSuccess,
  1870. qrcode.vidError
  1871. );
  1872. } else {
  1873. if (d.mozGetUserMedia) {
  1874. qrcode.moz = true;
  1875. d.mozGetUserMedia(
  1876. {
  1877. video: a,
  1878. audio: false,
  1879. },
  1880. qrcode.vidSuccess,
  1881. qrcode.vidError
  1882. );
  1883. }
  1884. }
  1885. }
  1886. };
  1887. qrcode.decode = function (d) {
  1888. if (arguments.length == 0) {
  1889. if (qrcode.canvas_qr2) {
  1890. var b = qrcode.canvas_qr2;
  1891. var a = qrcode.qrcontext2;
  1892. } else {
  1893. var b = document.getElementById("qr-canvas");
  1894. var a = b.getContext("2d");
  1895. }
  1896. qrcode.width = b.width;
  1897. qrcode.height = b.height;
  1898. qrcode.imagedata = a.getImageData(0, 0, qrcode.width, qrcode.height);
  1899. qrcode.result = qrcode.process(a);
  1900. if (qrcode.callback != null) {
  1901. qrcode.callback(qrcode.result);
  1902. }
  1903. return qrcode.result;
  1904. } else {
  1905. var c = new Image();
  1906. c.crossOrigin = "Anonymous";
  1907. c.onload = function () {
  1908. var g = document.getElementById("out-canvas");
  1909. if (g != null) {
  1910. var j = g.getContext("2d");
  1911. j.clearRect(0, 0, 320, 240);
  1912. j.drawImage(c, 0, 0, 320, 240);
  1913. }
  1914. var i = document.createElement("canvas");
  1915. var h = i.getContext("2d");
  1916. var f = c.height;
  1917. var l = c.width;
  1918. if (c.width * c.height > qrcode.maxImgSize) {
  1919. var k = c.width / c.height;
  1920. f = Math.sqrt(qrcode.maxImgSize / k);
  1921. l = k * f;
  1922. }
  1923. i.width = l;
  1924. i.height = f;
  1925. h.drawImage(c, 0, 0, i.width, i.height);
  1926. qrcode.width = i.width;
  1927. qrcode.height = i.height;
  1928. try {
  1929. qrcode.imagedata = h.getImageData(0, 0, i.width, i.height);
  1930. } catch (m) {
  1931. qrcode.result =
  1932. "Cross domain image reading not supported in your browser! Save it to your computer then drag and drop the file!";
  1933. if (qrcode.callback != null) {
  1934. qrcode.callback(qrcode.result);
  1935. }
  1936. return;
  1937. }
  1938. try {
  1939. qrcode.result = qrcode.process(h);
  1940. } catch (m) {
  1941. console.log(m);
  1942. qrcode.result = "error decoding QR Code";
  1943. }
  1944. if (qrcode.callback != null) {
  1945. qrcode.callback(qrcode.result);
  1946. }
  1947. };
  1948. c.onerror = function () {
  1949. if (qrcode.callback != null) {
  1950. qrcode.callback("Failed to load the image");
  1951. }
  1952. };
  1953. c.src = d;
  1954. }
  1955. };
  1956. qrcode.isUrl = function (a) {
  1957. var b =
  1958. /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
  1959. return b.test(a);
  1960. };
  1961. qrcode.decode_url = function (b) {
  1962. var d = "";
  1963. try {
  1964. d = escape(b);
  1965. } catch (c) {
  1966. console.log(c);
  1967. d = b;
  1968. }
  1969. var a = "";
  1970. try {
  1971. a = decodeURIComponent(d);
  1972. } catch (c) {
  1973. console.log(c);
  1974. a = d;
  1975. }
  1976. return a;
  1977. };
  1978. qrcode.decode_utf8 = function (a) {
  1979. if (qrcode.isUrl(a)) {
  1980. return qrcode.decode_url(a);
  1981. } else {
  1982. return a;
  1983. }
  1984. };
  1985. qrcode.process = function (q) {
  1986. var a = new Date().getTime();
  1987. var c = qrcode.grayScaleToBitmap(qrcode.grayscale());
  1988. if (qrcode.debug) {
  1989. for (var m = 0; m < qrcode.height; m++) {
  1990. for (var n = 0; n < qrcode.width; n++) {
  1991. var o = n * 4 + m * qrcode.width * 4;
  1992. qrcode.imagedata.data[o] = c[n + m * qrcode.width] ? 0 : 0;
  1993. qrcode.imagedata.data[o + 1] = c[n + m * qrcode.width] ? 0 : 0;
  1994. qrcode.imagedata.data[o + 2] = c[n + m * qrcode.width] ? 255 : 0;
  1995. }
  1996. }
  1997. q.putImageData(qrcode.imagedata, 0, 0);
  1998. }
  1999. var h = new Detector(c);
  2000. var p = h.detect();
  2001. if (qrcode.debug) {
  2002. for (var m = 0; m < p.bits.Height; m++) {
  2003. for (var n = 0; n < p.bits.Width; n++) {
  2004. var o = n * 4 * 2 + m * 2 * qrcode.width * 4;
  2005. qrcode.imagedata.data[o] = p.bits._ds(n, m) ? 0 : 0;
  2006. qrcode.imagedata.data[o + 1] = p.bits._ds(n, m) ? 0 : 0;
  2007. qrcode.imagedata.data[o + 2] = p.bits._ds(n, m) ? 255 : 0;
  2008. }
  2009. }
  2010. q.putImageData(qrcode.imagedata, 0, 0);
  2011. }
  2012. var k = Decoder.decode(p.bits);
  2013. var g = k.DataByte;
  2014. var l = "";
  2015. for (var f = 0; f < g.length; f++) {
  2016. for (var e = 0; e < g[f].length; e++) {
  2017. l += String.fromCharCode(g[f][e]);
  2018. }
  2019. }
  2020. var d = new Date().getTime();
  2021. var b = d - a;
  2022. console.log(b);
  2023. return qrcode.decode_utf8(l);
  2024. };
  2025. qrcode.getPixel = function (b, d) {
  2026. if (qrcode.width < b) {
  2027. throw "point error";
  2028. }
  2029. if (qrcode.height < d) {
  2030. throw "point error";
  2031. }
  2032. var a = b * 4 + d * qrcode.width * 4;
  2033. var c =
  2034. (qrcode.imagedata.data[a] * 33 +
  2035. qrcode.imagedata.data[a + 1] * 34 +
  2036. qrcode.imagedata.data[a + 2] * 33) /
  2037. 100;
  2038. return c;
  2039. };
  2040. qrcode.binarize = function (d) {
  2041. var c = new Array(qrcode.width * qrcode.height);
  2042. for (var e = 0; e < qrcode.height; e++) {
  2043. for (var b = 0; b < qrcode.width; b++) {
  2044. var a = qrcode.getPixel(b, e);
  2045. c[b + e * qrcode.width] = a <= d ? true : false;
  2046. }
  2047. }
  2048. return c;
  2049. };
  2050. qrcode._em = function (d) {
  2051. var c = 4;
  2052. var k = Math.floor(qrcode.width / c);
  2053. var j = Math.floor(qrcode.height / c);
  2054. var f = new Array(c);
  2055. for (var g = 0; g < c; g++) {
  2056. f[g] = new Array(c);
  2057. for (var e = 0; e < c; e++) {
  2058. f[g][e] = new Array(0, 0);
  2059. }
  2060. }
  2061. for (var o = 0; o < c; o++) {
  2062. for (var a = 0; a < c; a++) {
  2063. f[a][o][0] = 255;
  2064. for (var l = 0; l < j; l++) {
  2065. for (var n = 0; n < k; n++) {
  2066. var h = d[k * a + n + (j * o + l) * qrcode.width];
  2067. if (h < f[a][o][0]) {
  2068. f[a][o][0] = h;
  2069. }
  2070. if (h > f[a][o][1]) {
  2071. f[a][o][1] = h;
  2072. }
  2073. }
  2074. }
  2075. }
  2076. }
  2077. var m = new Array(c);
  2078. for (var b = 0; b < c; b++) {
  2079. m[b] = new Array(c);
  2080. }
  2081. for (var o = 0; o < c; o++) {
  2082. for (var a = 0; a < c; a++) {
  2083. m[a][o] = Math.floor((f[a][o][0] + f[a][o][1]) / 2);
  2084. }
  2085. }
  2086. return m;
  2087. };
  2088. qrcode.grayScaleToBitmap = function (f) {
  2089. var k = qrcode._em(f);
  2090. var b = k.length;
  2091. var e = Math.floor(qrcode.width / b);
  2092. var d = Math.floor(qrcode.height / b);
  2093. var h = new ArrayBuffer(qrcode.width * qrcode.height);
  2094. var c = new Uint8Array(h);
  2095. for (var j = 0; j < b; j++) {
  2096. for (var a = 0; a < b; a++) {
  2097. for (var g = 0; g < d; g++) {
  2098. for (var i = 0; i < e; i++) {
  2099. c[e * a + i + (d * j + g) * qrcode.width] =
  2100. f[e * a + i + (d * j + g) * qrcode.width] < k[a][j] ? true : false;
  2101. }
  2102. }
  2103. }
  2104. }
  2105. return c;
  2106. };
  2107. qrcode.grayscale = function () {
  2108. var e = new ArrayBuffer(qrcode.width * qrcode.height);
  2109. var c = new Uint8Array(e);
  2110. for (var d = 0; d < qrcode.height; d++) {
  2111. for (var b = 0; b < qrcode.width; b++) {
  2112. var a = qrcode.getPixel(b, d);
  2113. c[b + d * qrcode.width] = a;
  2114. }
  2115. }
  2116. return c;
  2117. };
  2118. function _ew(a, b) {
  2119. if (a >= 0) {
  2120. return a >> b;
  2121. } else {
  2122. return (a >> b) + (2 << ~b);
  2123. }
  2124. }
  2125. var _gf = 3;
  2126. var _eh = 57;
  2127. var _el = 8;
  2128. var _eg = 2;
  2129. qrcode._er = function (c) {
  2130. function b(m, k) {
  2131. var n = m.X - k.X;
  2132. var l = m.Y - k.Y;
  2133. return Math.sqrt(n * n + l * l);
  2134. }
  2135. function d(k, o, n) {
  2136. var m = o.x;
  2137. var l = o.y;
  2138. return (n.x - m) * (k.y - l) - (n.y - l) * (k.x - m);
  2139. }
  2140. var i = b(c[0], c[1]);
  2141. var f = b(c[1], c[2]);
  2142. var e = b(c[0], c[2]);
  2143. var a, j, h;
  2144. if (f >= i && f >= e) {
  2145. j = c[0];
  2146. a = c[1];
  2147. h = c[2];
  2148. } else {
  2149. if (e >= f && e >= i) {
  2150. j = c[1];
  2151. a = c[0];
  2152. h = c[2];
  2153. } else {
  2154. j = c[2];
  2155. a = c[0];
  2156. h = c[1];
  2157. }
  2158. }
  2159. if (d(a, j, h) < 0) {
  2160. var g = a;
  2161. a = h;
  2162. h = g;
  2163. }
  2164. c[0] = a;
  2165. c[1] = j;
  2166. c[2] = h;
  2167. };
  2168. function _cz(c, a, b) {
  2169. this.x = c;
  2170. this.y = a;
  2171. this.count = 1;
  2172. this._aj = b;
  2173. this.__defineGetter__("_ei", function () {
  2174. return this._aj;
  2175. });
  2176. this.__defineGetter__("Count", function () {
  2177. return this.count;
  2178. });
  2179. this.__defineGetter__("X", function () {
  2180. return this.x;
  2181. });
  2182. this.__defineGetter__("Y", function () {
  2183. return this.y;
  2184. });
  2185. this._ek = function () {
  2186. this.count++;
  2187. };
  2188. this._ev = function (f, e, d) {
  2189. if (Math.abs(e - this.y) <= f && Math.abs(d - this.x) <= f) {
  2190. var g = Math.abs(f - this._aj);
  2191. return g <= 1 || g / this._aj <= 1;
  2192. }
  2193. return false;
  2194. };
  2195. }
  2196. function _es(a) {
  2197. this._go = a[0];
  2198. this._gu = a[1];
  2199. this._gr = a[2];
  2200. this.__defineGetter__("_gp", function () {
  2201. return this._go;
  2202. });
  2203. this.__defineGetter__("_gq", function () {
  2204. return this._gu;
  2205. });
  2206. this.__defineGetter__("_gs", function () {
  2207. return this._gr;
  2208. });
  2209. }
  2210. function _cc() {
  2211. this.image = null;
  2212. this._cv = [];
  2213. this._ge = false;
  2214. this._al = new Array(0, 0, 0, 0, 0);
  2215. this._am = null;
  2216. this.__defineGetter__("_da", function () {
  2217. this._al[0] = 0;
  2218. this._al[1] = 0;
  2219. this._al[2] = 0;
  2220. this._al[3] = 0;
  2221. this._al[4] = 0;
  2222. return this._al;
  2223. });
  2224. this._ao = function (f) {
  2225. var b = 0;
  2226. for (var d = 0; d < 5; d++) {
  2227. var e = f[d];
  2228. if (e == 0) {
  2229. return false;
  2230. }
  2231. b += e;
  2232. }
  2233. if (b < 7) {
  2234. return false;
  2235. }
  2236. var c = Math.floor((b << _el) / 7);
  2237. var a = Math.floor(c / 2);
  2238. return (
  2239. Math.abs(c - (f[0] << _el)) < a &&
  2240. Math.abs(c - (f[1] << _el)) < a &&
  2241. Math.abs(3 * c - (f[2] << _el)) < 3 * a &&
  2242. Math.abs(c - (f[3] << _el)) < a &&
  2243. Math.abs(c - (f[4] << _el)) < a
  2244. );
  2245. };
  2246. this._an = function (b, a) {
  2247. return a - b[4] - b[3] - b[2] / 2;
  2248. };
  2249. this._ap = function (a, j, d, g) {
  2250. var c = this.image;
  2251. var h = qrcode.height;
  2252. var b = this._da;
  2253. var f = a;
  2254. while (f >= 0 && c[j + f * qrcode.width]) {
  2255. b[2]++;
  2256. f--;
  2257. }
  2258. if (f < 0) {
  2259. return NaN;
  2260. }
  2261. while (f >= 0 && !c[j + f * qrcode.width] && b[1] <= d) {
  2262. b[1]++;
  2263. f--;
  2264. }
  2265. if (f < 0 || b[1] > d) {
  2266. return NaN;
  2267. }
  2268. while (f >= 0 && c[j + f * qrcode.width] && b[0] <= d) {
  2269. b[0]++;
  2270. f--;
  2271. }
  2272. if (b[0] > d) {
  2273. return NaN;
  2274. }
  2275. f = a + 1;
  2276. while (f < h && c[j + f * qrcode.width]) {
  2277. b[2]++;
  2278. f++;
  2279. }
  2280. if (f == h) {
  2281. return NaN;
  2282. }
  2283. while (f < h && !c[j + f * qrcode.width] && b[3] < d) {
  2284. b[3]++;
  2285. f++;
  2286. }
  2287. if (f == h || b[3] >= d) {
  2288. return NaN;
  2289. }
  2290. while (f < h && c[j + f * qrcode.width] && b[4] < d) {
  2291. b[4]++;
  2292. f++;
  2293. }
  2294. if (b[4] >= d) {
  2295. return NaN;
  2296. }
  2297. var e = b[0] + b[1] + b[2] + b[3] + b[4];
  2298. if (5 * Math.abs(e - g) >= 2 * g) {
  2299. return NaN;
  2300. }
  2301. return this._ao(b) ? this._an(b, f) : NaN;
  2302. };
  2303. this._ej = function (b, a, e, h) {
  2304. var d = this.image;
  2305. var i = qrcode.width;
  2306. var c = this._da;
  2307. var g = b;
  2308. while (g >= 0 && d[g + a * qrcode.width]) {
  2309. c[2]++;
  2310. g--;
  2311. }
  2312. if (g < 0) {
  2313. return NaN;
  2314. }
  2315. while (g >= 0 && !d[g + a * qrcode.width] && c[1] <= e) {
  2316. c[1]++;
  2317. g--;
  2318. }
  2319. if (g < 0 || c[1] > e) {
  2320. return NaN;
  2321. }
  2322. while (g >= 0 && d[g + a * qrcode.width] && c[0] <= e) {
  2323. c[0]++;
  2324. g--;
  2325. }
  2326. if (c[0] > e) {
  2327. return NaN;
  2328. }
  2329. g = b + 1;
  2330. while (g < i && d[g + a * qrcode.width]) {
  2331. c[2]++;
  2332. g++;
  2333. }
  2334. if (g == i) {
  2335. return NaN;
  2336. }
  2337. while (g < i && !d[g + a * qrcode.width] && c[3] < e) {
  2338. c[3]++;
  2339. g++;
  2340. }
  2341. if (g == i || c[3] >= e) {
  2342. return NaN;
  2343. }
  2344. while (g < i && d[g + a * qrcode.width] && c[4] < e) {
  2345. c[4]++;
  2346. g++;
  2347. }
  2348. if (c[4] >= e) {
  2349. return NaN;
  2350. }
  2351. var f = c[0] + c[1] + c[2] + c[3] + c[4];
  2352. if (5 * Math.abs(f - h) >= h) {
  2353. return NaN;
  2354. }
  2355. return this._ao(c) ? this._an(c, g) : NaN;
  2356. };
  2357. this._cu = function (c, f, e) {
  2358. var d = c[0] + c[1] + c[2] + c[3] + c[4];
  2359. var n = this._an(c, e);
  2360. var b = this._ap(f, Math.floor(n), c[2], d);
  2361. if (!isNaN(b)) {
  2362. n = this._ej(Math.floor(n), Math.floor(b), c[2], d);
  2363. if (!isNaN(n)) {
  2364. var l = d / 7;
  2365. var m = false;
  2366. var h = this._cv.length;
  2367. for (var g = 0; g < h; g++) {
  2368. var a = this._cv[g];
  2369. if (a._ev(l, b, n)) {
  2370. a._ek();
  2371. m = true;
  2372. break;
  2373. }
  2374. }
  2375. if (!m) {
  2376. var k = new _cz(n, b, l);
  2377. this._cv.push(k);
  2378. if (this._am != null) {
  2379. this._am._ep(k);
  2380. }
  2381. }
  2382. return true;
  2383. }
  2384. }
  2385. return false;
  2386. };
  2387. this._ee = function () {
  2388. var h = this._cv.length;
  2389. if (h < 3) {
  2390. throw "Couldn't find enough finder patterns (found " + h + ")";
  2391. }
  2392. if (h > 3) {
  2393. var b = 0;
  2394. var j = 0;
  2395. for (var d = 0; d < h; d++) {
  2396. var g = this._cv[d]._ei;
  2397. b += g;
  2398. j += g * g;
  2399. }
  2400. var a = b / h;
  2401. this._cv.sort(function (m, l) {
  2402. var k = Math.abs(l._ei - a);
  2403. var i = Math.abs(m._ei - a);
  2404. if (k < i) {
  2405. return -1;
  2406. } else {
  2407. if (k == i) {
  2408. return 0;
  2409. } else {
  2410. return 1;
  2411. }
  2412. }
  2413. });
  2414. var e = Math.sqrt(j / h - a * a);
  2415. var c = Math.max(0.2 * a, e);
  2416. for (var d = this._cv.length - 1; d >= 0; d--) {
  2417. var f = this._cv[d];
  2418. if (Math.abs(f._ei - a) > c) {
  2419. this._cv.splice(d, 1);
  2420. }
  2421. }
  2422. }
  2423. if (this._cv.length > 3) {
  2424. this._cv.sort(function (k, i) {
  2425. if (k.count > i.count) {
  2426. return -1;
  2427. }
  2428. if (k.count < i.count) {
  2429. return 1;
  2430. }
  2431. return 0;
  2432. });
  2433. }
  2434. return new Array(this._cv[0], this._cv[1], this._cv[2]);
  2435. };
  2436. this._eq = function () {
  2437. var b = this._cv.length;
  2438. if (b <= 1) {
  2439. return 0;
  2440. }
  2441. var c = null;
  2442. for (var d = 0; d < b; d++) {
  2443. var a = this._cv[d];
  2444. if (a.Count >= _eg) {
  2445. if (c == null) {
  2446. c = a;
  2447. } else {
  2448. this._ge = true;
  2449. return Math.floor((Math.abs(c.X - a.X) - Math.abs(c.Y - a.Y)) / 2);
  2450. }
  2451. }
  2452. }
  2453. return 0;
  2454. };
  2455. this._cx = function () {
  2456. var g = 0;
  2457. var c = 0;
  2458. var a = this._cv.length;
  2459. for (var d = 0; d < a; d++) {
  2460. var f = this._cv[d];
  2461. if (f.Count >= _eg) {
  2462. g++;
  2463. c += f._ei;
  2464. }
  2465. }
  2466. if (g < 3) {
  2467. return false;
  2468. }
  2469. var e = c / a;
  2470. var b = 0;
  2471. for (var d = 0; d < a; d++) {
  2472. f = this._cv[d];
  2473. b += Math.abs(f._ei - e);
  2474. }
  2475. return b <= 0.05 * c;
  2476. };
  2477. this._ce = function (e) {
  2478. var o = false;
  2479. this.image = e;
  2480. var n = qrcode.height;
  2481. var k = qrcode.width;
  2482. var a = Math.floor((3 * n) / (4 * _eh));
  2483. if (a < _gf || o) {
  2484. a = _gf;
  2485. }
  2486. var g = false;
  2487. var d = new Array(5);
  2488. for (var h = a - 1; h < n && !g; h += a) {
  2489. d[0] = 0;
  2490. d[1] = 0;
  2491. d[2] = 0;
  2492. d[3] = 0;
  2493. d[4] = 0;
  2494. var b = 0;
  2495. for (var f = 0; f < k; f++) {
  2496. if (e[f + h * qrcode.width]) {
  2497. if ((b & 1) == 1) {
  2498. b++;
  2499. }
  2500. d[b]++;
  2501. } else {
  2502. if ((b & 1) == 0) {
  2503. if (b == 4) {
  2504. if (this._ao(d)) {
  2505. var c = this._cu(d, h, f);
  2506. if (c) {
  2507. a = 2;
  2508. if (this._ge) {
  2509. g = this._cx();
  2510. } else {
  2511. var m = this._eq();
  2512. if (m > d[2]) {
  2513. h += m - d[2] - a;
  2514. f = k - 1;
  2515. }
  2516. }
  2517. } else {
  2518. do {
  2519. f++;
  2520. } while (f < k && !e[f + h * qrcode.width]);
  2521. f--;
  2522. }
  2523. b = 0;
  2524. d[0] = 0;
  2525. d[1] = 0;
  2526. d[2] = 0;
  2527. d[3] = 0;
  2528. d[4] = 0;
  2529. } else {
  2530. d[0] = d[2];
  2531. d[1] = d[3];
  2532. d[2] = d[4];
  2533. d[3] = 1;
  2534. d[4] = 0;
  2535. b = 3;
  2536. }
  2537. } else {
  2538. d[++b]++;
  2539. }
  2540. } else {
  2541. d[b]++;
  2542. }
  2543. }
  2544. }
  2545. if (this._ao(d)) {
  2546. var c = this._cu(d, h, k);
  2547. if (c) {
  2548. a = d[0];
  2549. if (this._ge) {
  2550. g = _cx();
  2551. }
  2552. }
  2553. }
  2554. }
  2555. var l = this._ee();
  2556. qrcode._er(l);
  2557. return new _es(l);
  2558. };
  2559. }
  2560. function _ai(c, a, b) {
  2561. this.x = c;
  2562. this.y = a;
  2563. this.count = 1;
  2564. this._aj = b;
  2565. this.__defineGetter__("_ei", function () {
  2566. return this._aj;
  2567. });
  2568. this.__defineGetter__("Count", function () {
  2569. return this.count;
  2570. });
  2571. this.__defineGetter__("X", function () {
  2572. return Math.floor(this.x);
  2573. });
  2574. this.__defineGetter__("Y", function () {
  2575. return Math.floor(this.y);
  2576. });
  2577. this._ek = function () {
  2578. this.count++;
  2579. };
  2580. this._ev = function (f, e, d) {
  2581. if (Math.abs(e - this.y) <= f && Math.abs(d - this.x) <= f) {
  2582. var g = Math.abs(f - this._aj);
  2583. return g <= 1 || g / this._aj <= 1;
  2584. }
  2585. return false;
  2586. };
  2587. }
  2588. function _ak(g, c, b, f, a, e, d) {
  2589. this.image = g;
  2590. this._cv = new Array();
  2591. this.startX = c;
  2592. this.startY = b;
  2593. this.width = f;
  2594. this.height = a;
  2595. this._ef = e;
  2596. this._al = new Array(0, 0, 0);
  2597. this._am = d;
  2598. this._an = function (i, h) {
  2599. return h - i[2] - i[1] / 2;
  2600. };
  2601. this._ao = function (l) {
  2602. var k = this._ef;
  2603. var h = k / 2;
  2604. for (var j = 0; j < 3; j++) {
  2605. if (Math.abs(k - l[j]) >= h) {
  2606. return false;
  2607. }
  2608. }
  2609. return true;
  2610. };
  2611. this._ap = function (h, q, l, o) {
  2612. var k = this.image;
  2613. var p = qrcode.height;
  2614. var j = this._al;
  2615. j[0] = 0;
  2616. j[1] = 0;
  2617. j[2] = 0;
  2618. var n = h;
  2619. while (n >= 0 && k[q + n * qrcode.width] && j[1] <= l) {
  2620. j[1]++;
  2621. n--;
  2622. }
  2623. if (n < 0 || j[1] > l) {
  2624. return NaN;
  2625. }
  2626. while (n >= 0 && !k[q + n * qrcode.width] && j[0] <= l) {
  2627. j[0]++;
  2628. n--;
  2629. }
  2630. if (j[0] > l) {
  2631. return NaN;
  2632. }
  2633. n = h + 1;
  2634. while (n < p && k[q + n * qrcode.width] && j[1] <= l) {
  2635. j[1]++;
  2636. n++;
  2637. }
  2638. if (n == p || j[1] > l) {
  2639. return NaN;
  2640. }
  2641. while (n < p && !k[q + n * qrcode.width] && j[2] <= l) {
  2642. j[2]++;
  2643. n++;
  2644. }
  2645. if (j[2] > l) {
  2646. return NaN;
  2647. }
  2648. var m = j[0] + j[1] + j[2];
  2649. if (5 * Math.abs(m - o) >= 2 * o) {
  2650. return NaN;
  2651. }
  2652. return this._ao(j) ? this._an(j, n) : NaN;
  2653. };
  2654. this._cu = function (l, o, n) {
  2655. var m = l[0] + l[1] + l[2];
  2656. var t = this._an(l, n);
  2657. var k = this._ap(o, Math.floor(t), 2 * l[1], m);
  2658. if (!isNaN(k)) {
  2659. var s = (l[0] + l[1] + l[2]) / 3;
  2660. var q = this._cv.length;
  2661. for (var p = 0; p < q; p++) {
  2662. var h = this._cv[p];
  2663. if (h._ev(s, k, t)) {
  2664. return new _ai(t, k, s);
  2665. }
  2666. }
  2667. var r = new _ai(t, k, s);
  2668. this._cv.push(r);
  2669. if (this._am != null) {
  2670. this._am._ep(r);
  2671. }
  2672. }
  2673. return null;
  2674. };
  2675. this.find = function () {
  2676. var p = this.startX;
  2677. var s = this.height;
  2678. var q = p + f;
  2679. var r = b + (s >> 1);
  2680. var m = new Array(0, 0, 0);
  2681. for (var k = 0; k < s; k++) {
  2682. var o = r + ((k & 1) == 0 ? (k + 1) >> 1 : -((k + 1) >> 1));
  2683. m[0] = 0;
  2684. m[1] = 0;
  2685. m[2] = 0;
  2686. var n = p;
  2687. while (n < q && !g[n + qrcode.width * o]) {
  2688. n++;
  2689. }
  2690. var h = 0;
  2691. while (n < q) {
  2692. if (g[n + o * qrcode.width]) {
  2693. if (h == 1) {
  2694. m[h]++;
  2695. } else {
  2696. if (h == 2) {
  2697. if (this._ao(m)) {
  2698. var l = this._cu(m, o, n);
  2699. if (l != null) {
  2700. return l;
  2701. }
  2702. }
  2703. m[0] = m[2];
  2704. m[1] = 1;
  2705. m[2] = 0;
  2706. h = 1;
  2707. } else {
  2708. m[++h]++;
  2709. }
  2710. }
  2711. } else {
  2712. if (h == 1) {
  2713. h++;
  2714. }
  2715. m[h]++;
  2716. }
  2717. n++;
  2718. }
  2719. if (this._ao(m)) {
  2720. var l = this._cu(m, o, q);
  2721. if (l != null) {
  2722. return l;
  2723. }
  2724. }
  2725. }
  2726. if (!(this._cv.length == 0)) {
  2727. return this._cv[0];
  2728. }
  2729. throw "Couldn't find enough alignment patterns";
  2730. };
  2731. }
  2732. function QRCodeDataBlockReader(c, a, b) {
  2733. this._ed = 0;
  2734. this._cw = 7;
  2735. this.dataLength = 0;
  2736. this.blocks = c;
  2737. this._en = b;
  2738. if (a <= 9) {
  2739. this.dataLengthMode = 0;
  2740. } else {
  2741. if (a >= 10 && a <= 26) {
  2742. this.dataLengthMode = 1;
  2743. } else {
  2744. if (a >= 27 && a <= 40) {
  2745. this.dataLengthMode = 2;
  2746. }
  2747. }
  2748. }
  2749. this._gd = function (f) {
  2750. var k = 0;
  2751. if (f < this._cw + 1) {
  2752. var m = 0;
  2753. for (var e = 0; e < f; e++) {
  2754. m += 1 << e;
  2755. }
  2756. m <<= this._cw - f + 1;
  2757. k = (this.blocks[this._ed] & m) >> (this._cw - f + 1);
  2758. this._cw -= f;
  2759. return k;
  2760. } else {
  2761. if (f < this._cw + 1 + 8) {
  2762. var j = 0;
  2763. for (var e = 0; e < this._cw + 1; e++) {
  2764. j += 1 << e;
  2765. }
  2766. k = (this.blocks[this._ed] & j) << (f - (this._cw + 1));
  2767. this._ed++;
  2768. k += this.blocks[this._ed] >> (8 - (f - (this._cw + 1)));
  2769. this._cw = this._cw - (f % 8);
  2770. if (this._cw < 0) {
  2771. this._cw = 8 + this._cw;
  2772. }
  2773. return k;
  2774. } else {
  2775. if (f < this._cw + 1 + 16) {
  2776. var j = 0;
  2777. var h = 0;
  2778. for (var e = 0; e < this._cw + 1; e++) {
  2779. j += 1 << e;
  2780. }
  2781. var g = (this.blocks[this._ed] & j) << (f - (this._cw + 1));
  2782. this._ed++;
  2783. var d = this.blocks[this._ed] << (f - (this._cw + 1 + 8));
  2784. this._ed++;
  2785. for (var e = 0; e < f - (this._cw + 1 + 8); e++) {
  2786. h += 1 << e;
  2787. }
  2788. h <<= 8 - (f - (this._cw + 1 + 8));
  2789. var l = (this.blocks[this._ed] & h) >> (8 - (f - (this._cw + 1 + 8)));
  2790. k = g + d + l;
  2791. this._cw = this._cw - ((f - 8) % 8);
  2792. if (this._cw < 0) {
  2793. this._cw = 8 + this._cw;
  2794. }
  2795. return k;
  2796. } else {
  2797. return 0;
  2798. }
  2799. }
  2800. }
  2801. };
  2802. this.NextMode = function () {
  2803. if (this._ed > this.blocks.length - this._en - 2) {
  2804. return 0;
  2805. } else {
  2806. return this._gd(4);
  2807. }
  2808. };
  2809. this.getDataLength = function (d) {
  2810. var e = 0;
  2811. while (true) {
  2812. if (d >> e == 1) {
  2813. break;
  2814. }
  2815. e++;
  2816. }
  2817. return this._gd(qrcode._eo[this.dataLengthMode][e]);
  2818. };
  2819. this.getRomanAndFigureString = function (h) {
  2820. var f = h;
  2821. var g = 0;
  2822. var j = "";
  2823. var d = new Array(
  2824. "0",
  2825. "1",
  2826. "2",
  2827. "3",
  2828. "4",
  2829. "5",
  2830. "6",
  2831. "7",
  2832. "8",
  2833. "9",
  2834. "A",
  2835. "B",
  2836. "C",
  2837. "D",
  2838. "E",
  2839. "F",
  2840. "G",
  2841. "H",
  2842. "I",
  2843. "J",
  2844. "K",
  2845. "L",
  2846. "M",
  2847. "N",
  2848. "O",
  2849. "P",
  2850. "Q",
  2851. "R",
  2852. "S",
  2853. "T",
  2854. "U",
  2855. "V",
  2856. "W",
  2857. "X",
  2858. "Y",
  2859. "Z",
  2860. " ",
  2861. "$",
  2862. "%",
  2863. "*",
  2864. "+",
  2865. "-",
  2866. ".",
  2867. "/",
  2868. ":"
  2869. );
  2870. do {
  2871. if (f > 1) {
  2872. g = this._gd(11);
  2873. var i = Math.floor(g / 45);
  2874. var e = g % 45;
  2875. j += d[i];
  2876. j += d[e];
  2877. f -= 2;
  2878. } else {
  2879. if (f == 1) {
  2880. g = this._gd(6);
  2881. j += d[g];
  2882. f -= 1;
  2883. }
  2884. }
  2885. } while (f > 0);
  2886. return j;
  2887. };
  2888. this.getFigureString = function (f) {
  2889. var d = f;
  2890. var e = 0;
  2891. var g = "";
  2892. do {
  2893. if (d >= 3) {
  2894. e = this._gd(10);
  2895. if (e < 100) {
  2896. g += "0";
  2897. }
  2898. if (e < 10) {
  2899. g += "0";
  2900. }
  2901. d -= 3;
  2902. } else {
  2903. if (d == 2) {
  2904. e = this._gd(7);
  2905. if (e < 10) {
  2906. g += "0";
  2907. }
  2908. d -= 2;
  2909. } else {
  2910. if (d == 1) {
  2911. e = this._gd(4);
  2912. d -= 1;
  2913. }
  2914. }
  2915. }
  2916. g += e;
  2917. } while (d > 0);
  2918. return g;
  2919. };
  2920. this.get8bitByteArray = function (g) {
  2921. var e = g;
  2922. var f = 0;
  2923. var d = new Array();
  2924. do {
  2925. f = this._gd(8);
  2926. d.push(f);
  2927. e--;
  2928. } while (e > 0);
  2929. return d;
  2930. };
  2931. this.getKanjiString = function (j) {
  2932. var g = j;
  2933. var i = 0;
  2934. var h = "";
  2935. do {
  2936. i = _gd(13);
  2937. var e = i % 192;
  2938. var f = i / 192;
  2939. var k = (f << 8) + e;
  2940. var d = 0;
  2941. if (k + 33088 <= 40956) {
  2942. d = k + 33088;
  2943. } else {
  2944. d = k + 49472;
  2945. }
  2946. h += String.fromCharCode(d);
  2947. g--;
  2948. } while (g > 0);
  2949. return h;
  2950. };
  2951. this.__defineGetter__("DataByte", function () {
  2952. var h = new Array();
  2953. var e = 1;
  2954. var f = 2;
  2955. var d = 4;
  2956. var o = 8;
  2957. do {
  2958. var l = this.NextMode();
  2959. if (l == 0) {
  2960. if (h.length > 0) {
  2961. break;
  2962. } else {
  2963. throw "Empty data block";
  2964. }
  2965. }
  2966. if (l != e && l != f && l != d && l != o) {
  2967. throw (
  2968. "Invalid mode: " +
  2969. l +
  2970. " in (block:" +
  2971. this._ed +
  2972. " bit:" +
  2973. this._cw +
  2974. ")"
  2975. );
  2976. }
  2977. var g = this.getDataLength(l);
  2978. if (g < 1) {
  2979. throw "Invalid data length: " + g;
  2980. }
  2981. switch (l) {
  2982. case e:
  2983. var m = this.getFigureString(g);
  2984. var k = new Array(m.length);
  2985. for (var i = 0; i < m.length; i++) {
  2986. k[i] = m.charCodeAt(i);
  2987. }
  2988. h.push(k);
  2989. break;
  2990. case f:
  2991. var m = this.getRomanAndFigureString(g);
  2992. var k = new Array(m.length);
  2993. for (var i = 0; i < m.length; i++) {
  2994. k[i] = m.charCodeAt(i);
  2995. }
  2996. h.push(k);
  2997. break;
  2998. case d:
  2999. var n = this.get8bitByteArray(g);
  3000. h.push(n);
  3001. break;
  3002. case o:
  3003. var m = this.getKanjiString(g);
  3004. h.push(m);
  3005. break;
  3006. }
  3007. } while (true);
  3008. return h;
  3009. });
  3010. }
  3011. export default qrcode;

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/寸_铁/article/detail/931281
推荐阅读
相关标签
  

闽ICP备14008679号