qrcode.js 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. var QRCode;
  2. !function() {
  3. function a(a) {
  4. this.mode = c.MODE_8BIT_BYTE,
  5. this.data = a,
  6. this.parsedData = [];
  7. for (var b = [], d = 0, e = this.data.length; e > d; d++) {
  8. var f = this.data.charCodeAt(d);
  9. f > 65536 ? (b[0] = 240 | (1835008 & f) >>> 18,
  10. b[1] = 128 | (258048 & f) >>> 12,
  11. b[2] = 128 | (4032 & f) >>> 6,
  12. b[3] = 128 | 63 & f) : f > 2048 ? (b[0] = 224 | (61440 & f) >>> 12,
  13. b[1] = 128 | (4032 & f) >>> 6,
  14. b[2] = 128 | 63 & f) : f > 128 ? (b[0] = 192 | (1984 & f) >>> 6,
  15. b[1] = 128 | 63 & f) : b[0] = f,
  16. this.parsedData = this.parsedData.concat(b)
  17. }
  18. this.parsedData.length != this.data.length && (this.parsedData.unshift(191),
  19. this.parsedData.unshift(187),
  20. this.parsedData.unshift(239))
  21. }
  22. function b(a, b) {
  23. this.typeNumber = a,
  24. this.errorCorrectLevel = b,
  25. this.modules = null,
  26. this.moduleCount = 0,
  27. this.dataCache = null,
  28. this.dataList = []
  29. }
  30. function i(a, b) {
  31. if (void 0 == a.length)
  32. throw new Error(a.length + "/" + b);
  33. for (var c = 0; c < a.length && 0 == a[c]; )
  34. c++;
  35. this.num = new Array(a.length - c + b);
  36. for (var d = 0; d < a.length - c; d++)
  37. this.num[d] = a[d + c]
  38. }
  39. function j(a, b) {
  40. this.totalCount = a,
  41. this.dataCount = b
  42. }
  43. function k() {
  44. this.buffer = [],
  45. this.length = 0
  46. }
  47. function m() {
  48. return "undefined" != typeof CanvasRenderingContext2D
  49. }
  50. function n() {
  51. var a = !1
  52. , b = navigator.userAgent;
  53. return /android/i.test(b) && (a = !0,
  54. aMat = b.toString().match(/android ([0-9]\.[0-9])/i),
  55. aMat && aMat[1] && (a = parseFloat(aMat[1]))),
  56. a
  57. }
  58. function r(a, b) {
  59. for (var c = 1, e = s(a), f = 0, g = l.length; g >= f; f++) {
  60. var h = 0;
  61. switch (b) {
  62. case d.L:
  63. h = l[f][0];
  64. break;
  65. case d.M:
  66. h = l[f][1];
  67. break;
  68. case d.Q:
  69. h = l[f][2];
  70. break;
  71. case d.H:
  72. h = l[f][3]
  73. }
  74. if (h >= e)
  75. break;
  76. c++
  77. }
  78. if (c > l.length)
  79. throw new Error("Too long data");
  80. return c
  81. }
  82. function s(a) {
  83. var b = encodeURI(a).toString().replace(/\%[0-9a-fA-F]{2}/g, "a");
  84. return b.length + (b.length != a ? 3 : 0)
  85. }
  86. a.prototype = {
  87. getLength: function() {
  88. return this.parsedData.length
  89. },
  90. write: function(a) {
  91. for (var b = 0, c = this.parsedData.length; c > b; b++)
  92. a.put(this.parsedData[b], 8)
  93. }
  94. },
  95. b.prototype = {
  96. addData: function(b) {
  97. var c = new a(b);
  98. this.dataList.push(c),
  99. this.dataCache = null
  100. },
  101. isDark: function(a, b) {
  102. if (0 > a || this.moduleCount <= a || 0 > b || this.moduleCount <= b)
  103. throw new Error(a + "," + b);
  104. return this.modules[a][b]
  105. },
  106. getModuleCount: function() {
  107. return this.moduleCount
  108. },
  109. make: function() {
  110. this.makeImpl(!1, this.getBestMaskPattern())
  111. },
  112. makeImpl: function(a, c) {
  113. this.moduleCount = 4 * this.typeNumber + 17,
  114. this.modules = new Array(this.moduleCount);
  115. for (var d = 0; d < this.moduleCount; d++) {
  116. this.modules[d] = new Array(this.moduleCount);
  117. for (var e = 0; e < this.moduleCount; e++)
  118. this.modules[d][e] = null
  119. }
  120. this.setupPositionProbePattern(0, 0),
  121. this.setupPositionProbePattern(this.moduleCount - 7, 0),
  122. this.setupPositionProbePattern(0, this.moduleCount - 7),
  123. this.setupPositionAdjustPattern(),
  124. this.setupTimingPattern(),
  125. this.setupTypeInfo(a, c),
  126. this.typeNumber >= 7 && this.setupTypeNumber(a),
  127. null == this.dataCache && (this.dataCache = b.createData(this.typeNumber, this.errorCorrectLevel, this.dataList)),
  128. this.mapData(this.dataCache, c)
  129. },
  130. setupPositionProbePattern: function(a, b) {
  131. for (var c = -1; 7 >= c; c++)
  132. if (!(-1 >= a + c || this.moduleCount <= a + c))
  133. for (var d = -1; 7 >= d; d++)
  134. -1 >= b + d || this.moduleCount <= b + d || (this.modules[a + c][b + d] = c >= 0 && 6 >= c && (0 == d || 6 == d) || d >= 0 && 6 >= d && (0 == c || 6 == c) || c >= 2 && 4 >= c && d >= 2 && 4 >= d ? !0 : !1)
  135. },
  136. getBestMaskPattern: function() {
  137. for (var a = 0, b = 0, c = 0; 8 > c; c++) {
  138. this.makeImpl(!0, c);
  139. var d = f.getLostPoint(this);
  140. (0 == c || a > d) && (a = d,
  141. b = c)
  142. }
  143. return b
  144. },
  145. createMovieClip: function(a, b, c) {
  146. var d = a.createEmptyMovieClip(b, c)
  147. , e = 1;
  148. this.make();
  149. for (var f = 0; f < this.modules.length; f++)
  150. for (var g = f * e, h = 0; h < this.modules[f].length; h++) {
  151. var i = h * e
  152. , j = this.modules[f][h];
  153. j && (d.beginFill(0, 100),
  154. d.moveTo(i, g),
  155. d.lineTo(i + e, g),
  156. d.lineTo(i + e, g + e),
  157. d.lineTo(i, g + e),
  158. d.endFill())
  159. }
  160. return d
  161. },
  162. setupTimingPattern: function() {
  163. for (var a = 8; a < this.moduleCount - 8; a++)
  164. null == this.modules[a][6] && (this.modules[a][6] = 0 == a % 2);
  165. for (var b = 8; b < this.moduleCount - 8; b++)
  166. null == this.modules[6][b] && (this.modules[6][b] = 0 == b % 2)
  167. },
  168. setupPositionAdjustPattern: function() {
  169. for (var a = f.getPatternPosition(this.typeNumber), b = 0; b < a.length; b++)
  170. for (var c = 0; c < a.length; c++) {
  171. var d = a[b]
  172. , e = a[c];
  173. if (null == this.modules[d][e])
  174. for (var g = -2; 2 >= g; g++)
  175. for (var h = -2; 2 >= h; h++)
  176. this.modules[d + g][e + h] = -2 == g || 2 == g || -2 == h || 2 == h || 0 == g && 0 == h ? !0 : !1
  177. }
  178. },
  179. setupTypeNumber: function(a) {
  180. for (var b = f.getBCHTypeNumber(this.typeNumber), c = 0; 18 > c; c++) {
  181. var d = !a && 1 == (1 & b >> c);
  182. this.modules[Math.floor(c / 3)][c % 3 + this.moduleCount - 8 - 3] = d
  183. }
  184. for (var c = 0; 18 > c; c++) {
  185. var d = !a && 1 == (1 & b >> c);
  186. this.modules[c % 3 + this.moduleCount - 8 - 3][Math.floor(c / 3)] = d
  187. }
  188. },
  189. setupTypeInfo: function(a, b) {
  190. for (var c = this.errorCorrectLevel << 3 | b, d = f.getBCHTypeInfo(c), e = 0; 15 > e; e++) {
  191. var g = !a && 1 == (1 & d >> e);
  192. 6 > e ? this.modules[e][8] = g : 8 > e ? this.modules[e + 1][8] = g : this.modules[this.moduleCount - 15 + e][8] = g
  193. }
  194. for (var e = 0; 15 > e; e++) {
  195. var g = !a && 1 == (1 & d >> e);
  196. 8 > e ? this.modules[8][this.moduleCount - e - 1] = g : 9 > e ? this.modules[8][15 - e - 1 + 1] = g : this.modules[8][15 - e - 1] = g
  197. }
  198. this.modules[this.moduleCount - 8][8] = !a
  199. },
  200. mapData: function(a, b) {
  201. for (var c = -1, d = this.moduleCount - 1, e = 7, g = 0, h = this.moduleCount - 1; h > 0; h -= 2)
  202. for (6 == h && h--; ; ) {
  203. for (var i = 0; 2 > i; i++)
  204. if (null == this.modules[d][h - i]) {
  205. var j = !1;
  206. g < a.length && (j = 1 == (1 & a[g] >>> e));
  207. var k = f.getMask(b, d, h - i);
  208. k && (j = !j),
  209. this.modules[d][h - i] = j,
  210. e--,
  211. -1 == e && (g++,
  212. e = 7)
  213. }
  214. if (d += c,
  215. 0 > d || this.moduleCount <= d) {
  216. d -= c,
  217. c = -c;
  218. break
  219. }
  220. }
  221. }
  222. },
  223. b.PAD0 = 236,
  224. b.PAD1 = 17,
  225. b.createData = function(a, c, d) {
  226. for (var e = j.getRSBlocks(a, c), g = new k, h = 0; h < d.length; h++) {
  227. var i = d[h];
  228. g.put(i.mode, 4),
  229. g.put(i.getLength(), f.getLengthInBits(i.mode, a)),
  230. i.write(g)
  231. }
  232. for (var l = 0, h = 0; h < e.length; h++)
  233. l += e[h].dataCount;
  234. if (g.getLengthInBits() > 8 * l)
  235. throw new Error("code length overflow. (" + g.getLengthInBits() + ">" + 8 * l + ")");
  236. for (g.getLengthInBits() + 4 <= 8 * l && g.put(0, 4); 0 != g.getLengthInBits() % 8; )
  237. g.putBit(!1);
  238. for (; ; ) {
  239. if (g.getLengthInBits() >= 8 * l)
  240. break;
  241. if (g.put(b.PAD0, 8),
  242. g.getLengthInBits() >= 8 * l)
  243. break;
  244. g.put(b.PAD1, 8)
  245. }
  246. return b.createBytes(g, e)
  247. }
  248. ,
  249. b.createBytes = function(a, b) {
  250. for (var c = 0, d = 0, e = 0, g = new Array(b.length), h = new Array(b.length), j = 0; j < b.length; j++) {
  251. var k = b[j].dataCount
  252. , l = b[j].totalCount - k;
  253. d = Math.max(d, k),
  254. e = Math.max(e, l),
  255. g[j] = new Array(k);
  256. for (var m = 0; m < g[j].length; m++)
  257. g[j][m] = 255 & a.buffer[m + c];
  258. c += k;
  259. var n = f.getErrorCorrectPolynomial(l)
  260. , o = new i(g[j],n.getLength() - 1)
  261. , p = o.mod(n);
  262. h[j] = new Array(n.getLength() - 1);
  263. for (var m = 0; m < h[j].length; m++) {
  264. var q = m + p.getLength() - h[j].length;
  265. h[j][m] = q >= 0 ? p.get(q) : 0
  266. }
  267. }
  268. for (var r = 0, m = 0; m < b.length; m++)
  269. r += b[m].totalCount;
  270. for (var s = new Array(r), t = 0, m = 0; d > m; m++)
  271. for (var j = 0; j < b.length; j++)
  272. m < g[j].length && (s[t++] = g[j][m]);
  273. for (var m = 0; e > m; m++)
  274. for (var j = 0; j < b.length; j++)
  275. m < h[j].length && (s[t++] = h[j][m]);
  276. return s
  277. }
  278. ;
  279. for (var c = {
  280. MODE_NUMBER: 1,
  281. MODE_ALPHA_NUM: 2,
  282. MODE_8BIT_BYTE: 4,
  283. MODE_KANJI: 8
  284. }, d = {
  285. L: 1,
  286. M: 0,
  287. Q: 3,
  288. H: 2
  289. }, e = {
  290. PATTERN000: 0,
  291. PATTERN001: 1,
  292. PATTERN010: 2,
  293. PATTERN011: 3,
  294. PATTERN100: 4,
  295. PATTERN101: 5,
  296. PATTERN110: 6,
  297. PATTERN111: 7
  298. }, f = {
  299. PATTERN_POSITION_TABLE: [[], [6, 18], [6, 22], [6, 26], [6, 30], [6, 34], [6, 22, 38], [6, 24, 42], [6, 26, 46], [6, 28, 50], [6, 30, 54], [6, 32, 58], [6, 34, 62], [6, 26, 46, 66], [6, 26, 48, 70], [6, 26, 50, 74], [6, 30, 54, 78], [6, 30, 56, 82], [6, 30, 58, 86], [6, 34, 62, 90], [6, 28, 50, 72, 94], [6, 26, 50, 74, 98], [6, 30, 54, 78, 102], [6, 28, 54, 80, 106], [6, 32, 58, 84, 110], [6, 30, 58, 86, 114], [6, 34, 62, 90, 118], [6, 26, 50, 74, 98, 122], [6, 30, 54, 78, 102, 126], [6, 26, 52, 78, 104, 130], [6, 30, 56, 82, 108, 134], [6, 34, 60, 86, 112, 138], [6, 30, 58, 86, 114, 142], [6, 34, 62, 90, 118, 146], [6, 30, 54, 78, 102, 126, 150], [6, 24, 50, 76, 102, 128, 154], [6, 28, 54, 80, 106, 132, 158], [6, 32, 58, 84, 110, 136, 162], [6, 26, 54, 82, 110, 138, 166], [6, 30, 58, 86, 114, 142, 170]],
  300. G15: 1335,
  301. G18: 7973,
  302. G15_MASK: 21522,
  303. getBCHTypeInfo: function(a) {
  304. for (var b = a << 10; f.getBCHDigit(b) - f.getBCHDigit(f.G15) >= 0; )
  305. b ^= f.G15 << f.getBCHDigit(b) - f.getBCHDigit(f.G15);
  306. return (a << 10 | b) ^ f.G15_MASK
  307. },
  308. getBCHTypeNumber: function(a) {
  309. for (var b = a << 12; f.getBCHDigit(b) - f.getBCHDigit(f.G18) >= 0; )
  310. b ^= f.G18 << f.getBCHDigit(b) - f.getBCHDigit(f.G18);
  311. return a << 12 | b
  312. },
  313. getBCHDigit: function(a) {
  314. for (var b = 0; 0 != a; )
  315. b++,
  316. a >>>= 1;
  317. return b
  318. },
  319. getPatternPosition: function(a) {
  320. return f.PATTERN_POSITION_TABLE[a - 1]
  321. },
  322. getMask: function(a, b, c) {
  323. switch (a) {
  324. case e.PATTERN000:
  325. return 0 == (b + c) % 2;
  326. case e.PATTERN001:
  327. return 0 == b % 2;
  328. case e.PATTERN010:
  329. return 0 == c % 3;
  330. case e.PATTERN011:
  331. return 0 == (b + c) % 3;
  332. case e.PATTERN100:
  333. return 0 == (Math.floor(b / 2) + Math.floor(c / 3)) % 2;
  334. case e.PATTERN101:
  335. return 0 == b * c % 2 + b * c % 3;
  336. case e.PATTERN110:
  337. return 0 == (b * c % 2 + b * c % 3) % 2;
  338. case e.PATTERN111:
  339. return 0 == (b * c % 3 + (b + c) % 2) % 2;
  340. default:
  341. throw new Error("bad maskPattern:" + a)
  342. }
  343. },
  344. getErrorCorrectPolynomial: function(a) {
  345. for (var b = new i([1],0), c = 0; a > c; c++)
  346. b = b.multiply(new i([1, g.gexp(c)],0));
  347. return b
  348. },
  349. getLengthInBits: function(a, b) {
  350. if (b >= 1 && 10 > b)
  351. switch (a) {
  352. case c.MODE_NUMBER:
  353. return 10;
  354. case c.MODE_ALPHA_NUM:
  355. return 9;
  356. case c.MODE_8BIT_BYTE:
  357. return 8;
  358. case c.MODE_KANJI:
  359. return 8;
  360. default:
  361. throw new Error("mode:" + a)
  362. }
  363. else if (27 > b)
  364. switch (a) {
  365. case c.MODE_NUMBER:
  366. return 12;
  367. case c.MODE_ALPHA_NUM:
  368. return 11;
  369. case c.MODE_8BIT_BYTE:
  370. return 16;
  371. case c.MODE_KANJI:
  372. return 10;
  373. default:
  374. throw new Error("mode:" + a)
  375. }
  376. else {
  377. if (!(41 > b))
  378. throw new Error("type:" + b);
  379. switch (a) {
  380. case c.MODE_NUMBER:
  381. return 14;
  382. case c.MODE_ALPHA_NUM:
  383. return 13;
  384. case c.MODE_8BIT_BYTE:
  385. return 16;
  386. case c.MODE_KANJI:
  387. return 12;
  388. default:
  389. throw new Error("mode:" + a)
  390. }
  391. }
  392. },
  393. getLostPoint: function(a) {
  394. for (var b = a.getModuleCount(), c = 0, d = 0; b > d; d++)
  395. for (var e = 0; b > e; e++) {
  396. for (var f = 0, g = a.isDark(d, e), h = -1; 1 >= h; h++)
  397. if (!(0 > d + h || d + h >= b))
  398. for (var i = -1; 1 >= i; i++)
  399. 0 > e + i || e + i >= b || (0 != h || 0 != i) && g == a.isDark(d + h, e + i) && f++;
  400. f > 5 && (c += 3 + f - 5)
  401. }
  402. for (var d = 0; b - 1 > d; d++)
  403. for (var e = 0; b - 1 > e; e++) {
  404. var j = 0;
  405. a.isDark(d, e) && j++,
  406. a.isDark(d + 1, e) && j++,
  407. a.isDark(d, e + 1) && j++,
  408. a.isDark(d + 1, e + 1) && j++,
  409. (0 == j || 4 == j) && (c += 3)
  410. }
  411. for (var d = 0; b > d; d++)
  412. for (var e = 0; b - 6 > e; e++)
  413. a.isDark(d, e) && !a.isDark(d, e + 1) && a.isDark(d, e + 2) && a.isDark(d, e + 3) && a.isDark(d, e + 4) && !a.isDark(d, e + 5) && a.isDark(d, e + 6) && (c += 40);
  414. for (var e = 0; b > e; e++)
  415. for (var d = 0; b - 6 > d; d++)
  416. a.isDark(d, e) && !a.isDark(d + 1, e) && a.isDark(d + 2, e) && a.isDark(d + 3, e) && a.isDark(d + 4, e) && !a.isDark(d + 5, e) && a.isDark(d + 6, e) && (c += 40);
  417. for (var k = 0, e = 0; b > e; e++)
  418. for (var d = 0; b > d; d++)
  419. a.isDark(d, e) && k++;
  420. var l = Math.abs(100 * k / b / b - 50) / 5;
  421. return c += 10 * l
  422. }
  423. }, g = {
  424. glog: function(a) {
  425. if (1 > a)
  426. throw new Error("glog(" + a + ")");
  427. return g.LOG_TABLE[a]
  428. },
  429. gexp: function(a) {
  430. for (; 0 > a; )
  431. a += 255;
  432. for (; a >= 256; )
  433. a -= 255;
  434. return g.EXP_TABLE[a]
  435. },
  436. EXP_TABLE: new Array(256),
  437. LOG_TABLE: new Array(256)
  438. }, h = 0; 8 > h; h++)
  439. g.EXP_TABLE[h] = 1 << h;
  440. for (var h = 8; 256 > h; h++)
  441. g.EXP_TABLE[h] = g.EXP_TABLE[h - 4] ^ g.EXP_TABLE[h - 5] ^ g.EXP_TABLE[h - 6] ^ g.EXP_TABLE[h - 8];
  442. for (var h = 0; 255 > h; h++)
  443. g.LOG_TABLE[g.EXP_TABLE[h]] = h;
  444. i.prototype = {
  445. get: function(a) {
  446. return this.num[a]
  447. },
  448. getLength: function() {
  449. return this.num.length
  450. },
  451. multiply: function(a) {
  452. for (var b = new Array(this.getLength() + a.getLength() - 1), c = 0; c < this.getLength(); c++)
  453. for (var d = 0; d < a.getLength(); d++)
  454. b[c + d] ^= g.gexp(g.glog(this.get(c)) + g.glog(a.get(d)));
  455. return new i(b,0)
  456. },
  457. mod: function(a) {
  458. if (this.getLength() - a.getLength() < 0)
  459. return this;
  460. for (var b = g.glog(this.get(0)) - g.glog(a.get(0)), c = new Array(this.getLength()), d = 0; d < this.getLength(); d++)
  461. c[d] = this.get(d);
  462. for (var d = 0; d < a.getLength(); d++)
  463. c[d] ^= g.gexp(g.glog(a.get(d)) + b);
  464. return new i(c,0).mod(a)
  465. }
  466. },
  467. j.RS_BLOCK_TABLE = [[1, 26, 19], [1, 26, 16], [1, 26, 13], [1, 26, 9], [1, 44, 34], [1, 44, 28], [1, 44, 22], [1, 44, 16], [1, 70, 55], [1, 70, 44], [2, 35, 17], [2, 35, 13], [1, 100, 80], [2, 50, 32], [2, 50, 24], [4, 25, 9], [1, 134, 108], [2, 67, 43], [2, 33, 15, 2, 34, 16], [2, 33, 11, 2, 34, 12], [2, 86, 68], [4, 43, 27], [4, 43, 19], [4, 43, 15], [2, 98, 78], [4, 49, 31], [2, 32, 14, 4, 33, 15], [4, 39, 13, 1, 40, 14], [2, 121, 97], [2, 60, 38, 2, 61, 39], [4, 40, 18, 2, 41, 19], [4, 40, 14, 2, 41, 15], [2, 146, 116], [3, 58, 36, 2, 59, 37], [4, 36, 16, 4, 37, 17], [4, 36, 12, 4, 37, 13], [2, 86, 68, 2, 87, 69], [4, 69, 43, 1, 70, 44], [6, 43, 19, 2, 44, 20], [6, 43, 15, 2, 44, 16], [4, 101, 81], [1, 80, 50, 4, 81, 51], [4, 50, 22, 4, 51, 23], [3, 36, 12, 8, 37, 13], [2, 116, 92, 2, 117, 93], [6, 58, 36, 2, 59, 37], [4, 46, 20, 6, 47, 21], [7, 42, 14, 4, 43, 15], [4, 133, 107], [8, 59, 37, 1, 60, 38], [8, 44, 20, 4, 45, 21], [12, 33, 11, 4, 34, 12], [3, 145, 115, 1, 146, 116], [4, 64, 40, 5, 65, 41], [11, 36, 16, 5, 37, 17], [11, 36, 12, 5, 37, 13], [5, 109, 87, 1, 110, 88], [5, 65, 41, 5, 66, 42], [5, 54, 24, 7, 55, 25], [11, 36, 12], [5, 122, 98, 1, 123, 99], [7, 73, 45, 3, 74, 46], [15, 43, 19, 2, 44, 20], [3, 45, 15, 13, 46, 16], [1, 135, 107, 5, 136, 108], [10, 74, 46, 1, 75, 47], [1, 50, 22, 15, 51, 23], [2, 42, 14, 17, 43, 15], [5, 150, 120, 1, 151, 121], [9, 69, 43, 4, 70, 44], [17, 50, 22, 1, 51, 23], [2, 42, 14, 19, 43, 15], [3, 141, 113, 4, 142, 114], [3, 70, 44, 11, 71, 45], [17, 47, 21, 4, 48, 22], [9, 39, 13, 16, 40, 14], [3, 135, 107, 5, 136, 108], [3, 67, 41, 13, 68, 42], [15, 54, 24, 5, 55, 25], [15, 43, 15, 10, 44, 16], [4, 144, 116, 4, 145, 117], [17, 68, 42], [17, 50, 22, 6, 51, 23], [19, 46, 16, 6, 47, 17], [2, 139, 111, 7, 140, 112], [17, 74, 46], [7, 54, 24, 16, 55, 25], [34, 37, 13], [4, 151, 121, 5, 152, 122], [4, 75, 47, 14, 76, 48], [11, 54, 24, 14, 55, 25], [16, 45, 15, 14, 46, 16], [6, 147, 117, 4, 148, 118], [6, 73, 45, 14, 74, 46], [11, 54, 24, 16, 55, 25], [30, 46, 16, 2, 47, 17], [8, 132, 106, 4, 133, 107], [8, 75, 47, 13, 76, 48], [7, 54, 24, 22, 55, 25], [22, 45, 15, 13, 46, 16], [10, 142, 114, 2, 143, 115], [19, 74, 46, 4, 75, 47], [28, 50, 22, 6, 51, 23], [33, 46, 16, 4, 47, 17], [8, 152, 122, 4, 153, 123], [22, 73, 45, 3, 74, 46], [8, 53, 23, 26, 54, 24], [12, 45, 15, 28, 46, 16], [3, 147, 117, 10, 148, 118], [3, 73, 45, 23, 74, 46], [4, 54, 24, 31, 55, 25], [11, 45, 15, 31, 46, 16], [7, 146, 116, 7, 147, 117], [21, 73, 45, 7, 74, 46], [1, 53, 23, 37, 54, 24], [19, 45, 15, 26, 46, 16], [5, 145, 115, 10, 146, 116], [19, 75, 47, 10, 76, 48], [15, 54, 24, 25, 55, 25], [23, 45, 15, 25, 46, 16], [13, 145, 115, 3, 146, 116], [2, 74, 46, 29, 75, 47], [42, 54, 24, 1, 55, 25], [23, 45, 15, 28, 46, 16], [17, 145, 115], [10, 74, 46, 23, 75, 47], [10, 54, 24, 35, 55, 25], [19, 45, 15, 35, 46, 16], [17, 145, 115, 1, 146, 116], [14, 74, 46, 21, 75, 47], [29, 54, 24, 19, 55, 25], [11, 45, 15, 46, 46, 16], [13, 145, 115, 6, 146, 116], [14, 74, 46, 23, 75, 47], [44, 54, 24, 7, 55, 25], [59, 46, 16, 1, 47, 17], [12, 151, 121, 7, 152, 122], [12, 75, 47, 26, 76, 48], [39, 54, 24, 14, 55, 25], [22, 45, 15, 41, 46, 16], [6, 151, 121, 14, 152, 122], [6, 75, 47, 34, 76, 48], [46, 54, 24, 10, 55, 25], [2, 45, 15, 64, 46, 16], [17, 152, 122, 4, 153, 123], [29, 74, 46, 14, 75, 47], [49, 54, 24, 10, 55, 25], [24, 45, 15, 46, 46, 16], [4, 152, 122, 18, 153, 123], [13, 74, 46, 32, 75, 47], [48, 54, 24, 14, 55, 25], [42, 45, 15, 32, 46, 16], [20, 147, 117, 4, 148, 118], [40, 75, 47, 7, 76, 48], [43, 54, 24, 22, 55, 25], [10, 45, 15, 67, 46, 16], [19, 148, 118, 6, 149, 119], [18, 75, 47, 31, 76, 48], [34, 54, 24, 34, 55, 25], [20, 45, 15, 61, 46, 16]],
  468. j.getRSBlocks = function(a, b) {
  469. var c = j.getRsBlockTable(a, b);
  470. if (void 0 == c)
  471. throw new Error("bad rs block @ typeNumber:" + a + "/errorCorrectLevel:" + b);
  472. for (var d = c.length / 3, e = [], f = 0; d > f; f++)
  473. for (var g = c[3 * f + 0], h = c[3 * f + 1], i = c[3 * f + 2], k = 0; g > k; k++)
  474. e.push(new j(h,i));
  475. return e
  476. }
  477. ,
  478. j.getRsBlockTable = function(a, b) {
  479. switch (b) {
  480. case d.L:
  481. return j.RS_BLOCK_TABLE[4 * (a - 1) + 0];
  482. case d.M:
  483. return j.RS_BLOCK_TABLE[4 * (a - 1) + 1];
  484. case d.Q:
  485. return j.RS_BLOCK_TABLE[4 * (a - 1) + 2];
  486. case d.H:
  487. return j.RS_BLOCK_TABLE[4 * (a - 1) + 3];
  488. default:
  489. return void 0
  490. }
  491. }
  492. ,
  493. k.prototype = {
  494. get: function(a) {
  495. var b = Math.floor(a / 8);
  496. return 1 == (1 & this.buffer[b] >>> 7 - a % 8)
  497. },
  498. put: function(a, b) {
  499. for (var c = 0; b > c; c++)
  500. this.putBit(1 == (1 & a >>> b - c - 1))
  501. },
  502. getLengthInBits: function() {
  503. return this.length
  504. },
  505. putBit: function(a) {
  506. var b = Math.floor(this.length / 8);
  507. this.buffer.length <= b && this.buffer.push(0),
  508. a && (this.buffer[b] |= 128 >>> this.length % 8),
  509. this.length++
  510. }
  511. };
  512. var l = [[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]]
  513. , o = function() {
  514. var a = function(a, b) {
  515. this._el = a,
  516. this._htOption = b
  517. };
  518. return a.prototype.draw = function(a) {
  519. function g(a, b) {
  520. var c = document.createElementNS("http://www.w3.org/2000/svg", a);
  521. for (var d in b)
  522. b.hasOwnProperty(d) && c.setAttribute(d, b[d]);
  523. return c
  524. }
  525. var b = this._htOption
  526. , c = this._el
  527. , d = a.getModuleCount();
  528. Math.floor(b.width / d),
  529. Math.floor(b.height / d),
  530. this.clear();
  531. var h = g("svg", {
  532. viewBox: "0 0 " + String(d) + " " + String(d),
  533. width: "100%",
  534. height: "100%",
  535. fill: b.colorLight
  536. });
  537. h.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xlink", "http://www.w3.org/1999/xlink"),
  538. c.appendChild(h),
  539. h.appendChild(g("rect", {
  540. fill: b.colorDark,
  541. width: "1",
  542. height: "1",
  543. id: "template"
  544. }));
  545. for (var i = 0; d > i; i++)
  546. for (var j = 0; d > j; j++)
  547. if (a.isDark(i, j)) {
  548. var k = g("use", {
  549. x: String(i),
  550. y: String(j)
  551. });
  552. k.setAttributeNS("http://www.w3.org/1999/xlink", "href", "#template"),
  553. h.appendChild(k)
  554. }
  555. }
  556. ,
  557. a.prototype.clear = function() {
  558. for (; this._el.hasChildNodes(); )
  559. this._el.removeChild(this._el.lastChild)
  560. }
  561. ,
  562. a
  563. }()
  564. , p = "svg" === document.documentElement.tagName.toLowerCase()
  565. , q = p ? o : m() ? function() {
  566. function a() {
  567. this._elImage.src = this._elCanvas.toDataURL("image/png"),
  568. this._elImage.style.display = "block",
  569. this._elCanvas.style.display = "none"
  570. }
  571. function d(a, b) {
  572. var c = this;
  573. if (c._fFail = b,
  574. c._fSuccess = a,
  575. null === c._bSupportDataURI) {
  576. var d = document.createElement("img")
  577. , e = function() {
  578. c._bSupportDataURI = !1,
  579. c._fFail && _fFail.call(c)
  580. }
  581. , f = function() {
  582. c._bSupportDataURI = !0,
  583. c._fSuccess && c._fSuccess.call(c)
  584. };
  585. return d.onabort = e,
  586. d.onerror = e,
  587. d.onload = f,
  588. d.src = "data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
  589. void 0
  590. }
  591. c._bSupportDataURI === !0 && c._fSuccess ? c._fSuccess.call(c) : c._bSupportDataURI === !1 && c._fFail && c._fFail.call(c)
  592. }
  593. if (this._android && this._android <= 2.1) {
  594. var b = 1 / window.devicePixelRatio
  595. , c = CanvasRenderingContext2D.prototype.drawImage;
  596. CanvasRenderingContext2D.prototype.drawImage = function(a, d, e, f, g, h, i, j) {
  597. if ("nodeName"in a && /img/i.test(a.nodeName))
  598. for (var l = arguments.length - 1; l >= 1; l--)
  599. arguments[l] = arguments[l] * b;
  600. else
  601. "undefined" == typeof j && (arguments[1] *= b,
  602. arguments[2] *= b,
  603. arguments[3] *= b,
  604. arguments[4] *= b);
  605. c.apply(this, arguments)
  606. }
  607. }
  608. var e = function(a, b) {
  609. this._bIsPainted = !1,
  610. this._android = n(),
  611. this._htOption = b,
  612. this._elCanvas = document.createElement("canvas"),
  613. this._elCanvas.width = b.width,
  614. this._elCanvas.height = b.height,
  615. a.appendChild(this._elCanvas),
  616. this._el = a,
  617. this._oContext = this._elCanvas.getContext("2d"),
  618. this._bIsPainted = !1,
  619. this._elImage = document.createElement("img"),
  620. this._elImage.style.display = "none",
  621. this._el.appendChild(this._elImage),
  622. this._bSupportDataURI = null
  623. };
  624. return e.prototype.draw = function(a) {
  625. var b = this._elImage
  626. , c = this._oContext
  627. , d = this._htOption
  628. , e = a.getModuleCount()
  629. , f = d.width / e
  630. , g = d.height / e
  631. , h = Math.round(f)
  632. , i = Math.round(g);
  633. b.style.display = "none",
  634. this.clear();
  635. for (var j = 0; e > j; j++)
  636. for (var k = 0; e > k; k++) {
  637. var l = a.isDark(j, k)
  638. , m = k * f
  639. , n = j * g;
  640. c.strokeStyle = l ? d.colorDark : d.colorLight,
  641. c.lineWidth = 1,
  642. c.fillStyle = l ? d.colorDark : d.colorLight,
  643. c.fillRect(m, n, f, g),
  644. c.strokeRect(Math.floor(m) + .5, Math.floor(n) + .5, h, i),
  645. c.strokeRect(Math.ceil(m) - .5, Math.ceil(n) - .5, h, i)
  646. }
  647. this._bIsPainted = !0
  648. }
  649. ,
  650. e.prototype.makeImage = function() {
  651. this._bIsPainted && d.call(this, a)
  652. }
  653. ,
  654. e.prototype.isPainted = function() {
  655. return this._bIsPainted
  656. }
  657. ,
  658. e.prototype.clear = function() {
  659. this._oContext.clearRect(0, 0, this._elCanvas.width, this._elCanvas.height),
  660. this._bIsPainted = !1
  661. }
  662. ,
  663. e.prototype.round = function(a) {
  664. return a ? Math.floor(1e3 * a) / 1e3 : a
  665. }
  666. ,
  667. e
  668. }() : function() {
  669. var a = function(a, b) {
  670. this._el = a,
  671. this._htOption = b
  672. };
  673. return a.prototype.draw = function(a) {
  674. for (var b = this._htOption, c = this._el, d = a.getModuleCount(), e = Math.floor(b.width / d), f = Math.floor(b.height / d), g = ['<table style="border:0;border-collapse:collapse;">'], h = 0; d > h; h++) {
  675. g.push("<tr>");
  676. for (var i = 0; d > i; i++)
  677. g.push('<td style="border:0;border-collapse:collapse;padding:0;margin:0;width:' + e + "px;height:" + f + "px;background-color:" + (a.isDark(h, i) ? b.colorDark : b.colorLight) + ';"></td>');
  678. g.push("</tr>")
  679. }
  680. g.push("</table>"),
  681. c.innerHTML = g.join("");
  682. var j = c.childNodes[0]
  683. , k = (b.width - j.offsetWidth) / 2
  684. , l = (b.height - j.offsetHeight) / 2;
  685. k > 0 && l > 0 && (j.style.margin = l + "px " + k + "px")
  686. }
  687. ,
  688. a.prototype.clear = function() {
  689. this._el.innerHTML = ""
  690. }
  691. ,
  692. a
  693. }();
  694. QRCode = function(a, b) {
  695. if (this._htOption = {
  696. width: 256,
  697. height: 256,
  698. typeNumber: 4,
  699. colorDark: "#000000",
  700. colorLight: "#ffffff",
  701. correctLevel: d.H
  702. },
  703. "string" == typeof b && (b = {
  704. text: b
  705. }),
  706. b)
  707. for (var c in b)
  708. this._htOption[c] = b[c];
  709. "string" == typeof a && (a = document.getElementById(a)),
  710. this._android = n(),
  711. this._el = a,
  712. this._oQRCode = null,
  713. this._oDrawing = new q(this._el,this._htOption),
  714. this._htOption.text && this.makeCode(this._htOption.text)
  715. }
  716. ,
  717. QRCode.prototype.makeCode = function(a) {
  718. this._oQRCode = new b(r(a, this._htOption.correctLevel),this._htOption.correctLevel),
  719. this._oQRCode.addData(a),
  720. this._oQRCode.make(),
  721. this._el.title = a,
  722. this._oDrawing.draw(this._oQRCode),
  723. this.makeImage()
  724. }
  725. ,
  726. QRCode.prototype.makeImage = function() {
  727. "function" == typeof this._oDrawing.makeImage && (!this._android || this._android >= 3) && this._oDrawing.makeImage()
  728. }
  729. ,
  730. QRCode.prototype.clear = function() {
  731. this._oDrawing.clear()
  732. }
  733. ,
  734. QRCode.CorrectLevel = d
  735. }();