reqrcode.js 60 KB

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