Advertisement
Guest User

Untitled

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