@nebularstreams/statify 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/dist/.DS_Store +0 -0
  2. package/dist/website.simple/webfonts/fa-brands-400.woff2 +0 -0
  3. package/dist/website.simple/webfonts/fa-solid-900.eot +0 -0
  4. package/dist/website.simple/webfonts/fa-solid-900.svg +4649 -0
  5. package/dist/website.simple/webfonts/fa-solid-900.ttf +0 -0
  6. package/dist/website.simple/webfonts/fa-solid-900.woff +0 -0
  7. package/dist/website.simple/webfonts/fa-solid-900.woff2 +0 -0
  8. package/dist/website.simple/website.css +32 -0
  9. package/dist/website.simple/website.min.js +6 -0
  10. package/dist/website.software/webfonts/fa-brands-400.woff2 +0 -0
  11. package/dist/website.software/webfonts/fa-solid-900.eot +0 -0
  12. package/dist/website.software/webfonts/fa-solid-900.svg +4649 -0
  13. package/dist/website.software/webfonts/fa-solid-900.ttf +0 -0
  14. package/dist/website.software/webfonts/fa-solid-900.woff +0 -0
  15. package/dist/website.software/webfonts/fa-solid-900.woff2 +0 -0
  16. package/dist/website.software/website.css +32 -0
  17. package/dist/website.software/website.min.js +6 -0
  18. package/dist/website.worlds/webfonts/fa-brands-400.woff2 +0 -0
  19. package/dist/website.worlds/webfonts/fa-solid-900.eot +0 -0
  20. package/dist/website.worlds/webfonts/fa-solid-900.svg +4649 -0
  21. package/dist/website.worlds/webfonts/fa-solid-900.ttf +0 -0
  22. package/dist/website.worlds/webfonts/fa-solid-900.woff +0 -0
  23. package/dist/website.worlds/webfonts/fa-solid-900.woff2 +0 -0
  24. package/dist/website.worlds/website.css +32 -0
  25. package/dist/website.worlds/website.min.js +6 -0
  26. package/package.json +49 -0
  27. package/readme.md +105 -0
  28. package/src/publisher-lib.js +179 -0
  29. package/src/publisher-list.js +91 -0
  30. package/src/publisher.js +38 -0
  31. package/src/util/cdn/nobj.cdn.js +88 -0
  32. package/src/util/htmlroute.js +39 -0
  33. package/src/util/markdown/lib.showdown.icon.js +62 -0
  34. package/src/util/markdown/lib.showdown.yt.js +54 -0
  35. package/src/util/markdown/markdown.js +144 -0
  36. package/src/util/navibar/util.navibar.js +63 -0
  37. package/src/util/sha.js +20 -0
  38. package/src/util/tokenizer.js +234 -0
  39. package/src/util/widgets/NoticeWidget.js +30 -0
  40. package/src/util/widgets/app.widgets.js +70 -0
  41. package/src/util/widgets/util.definewidget.js +14 -0
  42. package/src/widgets/Cookies.js +55 -0
  43. package/src/widgets/Frameset-simple.js +114 -0
  44. package/src/widgets/Frameset.js +124 -0
  45. package/src/widgets/Page.js +356 -0
  46. package/src/widgets/RightSide.js +93 -0
  47. package/src/widgets/Snippets.js +75 -0
  48. package/src/widgets/Tail.js +11 -0
  49. package/src/widgets/Widgets.js +10 -0
  50. package/src/widgets.client/Client.js +22 -0
  51. package/src/widgets.features/FeatureList.js +364 -0
  52. package/src/widgets.features/Youtube.js +23 -0
  53. package/src/widgets.features/bootcol.js +29 -0
  54. package/src/widgets.features/css/feature.css +112 -0
  55. package/src/widgets.features/css/tail.css +4 -0
  56. package/src/widgets.howto/Faq.js +201 -0
  57. package/src/widgets.howto/HowTo.js +419 -0
  58. package/src/widgets.howto/Tiles.js +51 -0
  59. package/src/widgets.howto/script-contractable.js +31 -0
  60. package/src/widgets.markdown/Document.js +84 -0
  61. package/src/widgets.market/MarketItem.js +278 -0
  62. package/src/widgets.market/MarketItem.orig.js +268 -0
  63. package/src/widgets.market/MarketItem.strips.js +276 -0
  64. package/src/widgets.market/StoryLicenseWIdget.js +45 -0
  65. package/src/widgets.market/app.utils.js +238 -0
  66. package/src.website/css/app/animations.css +27 -0
  67. package/src.website/css/app/ismobile.css +7 -0
  68. package/src.website/css/app/style.css +51 -0
  69. package/src.website/css/app/style.fullheight.css +9 -0
  70. package/src.website/css/app/style.mdblocks.css +59 -0
  71. package/src.website/css/app/style.putosafari.css +3 -0
  72. package/src.website/css/bootstrap/bootstrap-tiny-core.css +47 -0
  73. package/src.website/css/bootstrap/bootstrap-tiny-media-columns.css +1276 -0
  74. package/src.website/css/bootstrap/bootstrap-tiny-media-custom.css +59 -0
  75. package/src.website/css/bootstrap/bootstrap-tiny-media-display.css +279 -0
  76. package/src.website/css/bootstrap/bootstrap-tiny-media-flex.css +881 -0
  77. package/src.website/css/bootstrap/bootstrap-tiny-media-fonts.css +39 -0
  78. package/src.website/css/bootstrap/bootstrap-tiny-media-paddings.css +1348 -0
  79. package/src.website/css/css-core/core.ext.css +65 -0
  80. package/src.website/css/css-core/frontpage.css +28 -0
  81. package/src.website/css/css-core/root.css +34 -0
  82. package/src.website/css/css-core/root.fullheight.css +12 -0
  83. package/src.website/css/css-core/ui.dialog.round.css +14 -0
  84. package/src.website/css/css-core/ui.navibar.css +28 -0
  85. package/src.website/css/css-core/ui.notifications.css +12 -0
  86. package/src.website/css/css-featurelist/feature.css +196 -0
  87. package/src.website/css/css-featurelist/tail.css +4 -0
  88. package/src.website/css/css-screens/doc.css +22 -0
  89. package/src.website/css/css-screens/screens-meta.css +3 -0
  90. package/src.website/css/css-unsplash/unsplash.css +32 -0
  91. package/src.website/css/css-videos/youtube.css +28 -0
  92. package/src.website/css/css-wiki/wiki.css +206 -0
  93. package/src.website/css/css-wiki/wiki.sidepane.css +16 -0
  94. package/src.website/css/fontawesome/fa-brands.css +18 -0
  95. package/src.website/css/fontawesome/fa-solid.css +16 -0
  96. package/src.website/css/fontawesome/fa.css +4359 -0
  97. package/src.website/css/skin/mierda.css +15 -0
  98. package/src.website/css/skin/skin.dark.css +85 -0
  99. package/src.website/css/skin/skin.light.css +27 -0
  100. package/src.website/css/skin/vars.font.css +8 -0
  101. package/src.website/css/skin/vars.sizes.css +4 -0
  102. package/src.website/package-lock.json +2160 -0
  103. package/src.website/package.json +28 -0
  104. package/src.website/public/webfonts/fa-brands-400.woff2 +0 -0
  105. package/src.website/public/webfonts/fa-solid-900.eot +0 -0
  106. package/src.website/public/webfonts/fa-solid-900.svg +4649 -0
  107. package/src.website/public/webfonts/fa-solid-900.ttf +0 -0
  108. package/src.website/public/webfonts/fa-solid-900.woff +0 -0
  109. package/src.website/public/webfonts/fa-solid-900.woff2 +0 -0
  110. package/src.website/rollup.simple.mjs +36 -0
  111. package/src.website/rollup.software.mjs +36 -0
  112. package/src.website/rollup.terser.mjs +24 -0
  113. package/src.website/rollup.worlds.mjs +36 -0
  114. package/src.website/src/app/app.style.mjs +36 -0
  115. package/src.website/src/app/index.mjs +118 -0
  116. package/src.website/src/config.js +8 -0
  117. package/src.website/src/core/cdnmodel.mjs +7 -0
  118. package/src.website/src/core/clientruntime.mjs +41 -0
  119. package/src.website/src/core.cookies/analytics.mjs +96 -0
  120. package/src.website/src/core.cookies/cookiemanager.mjs +128 -0
  121. package/src.website/src/core.cookies/css/cookies.css +80 -0
  122. package/src.website/src/core.cookies/css/nocookies.css +48 -0
  123. package/src.website/src/core.extra/css/contractable.css +12 -0
  124. package/src.website/src/core.extra/css/faq.css +42 -0
  125. package/src.website/src/core.extra/css/howto.css +81 -0
  126. package/src.website/src/core.extra/extra.document.mjs +83 -0
  127. package/src.website/src/core.extra/extra.faq.mjs +30 -0
  128. package/src.website/src/core.extra/extra.mjs +62 -0
  129. package/src.website/src/main.simple.mjs +4 -0
  130. package/src.website/src/main.software.mjs +10 -0
  131. package/src.website/src/main.worlds.mjs +9 -0
  132. package/src.website/src/support/ismobile.mjs +4 -0
  133. package/src.website/src/support/nonce.mjs +4 -0
  134. package/src.website/src/support/persistsettings.mjs +41 -0
  135. package/src.website/src/support/qrcode.mjs +1269 -0
  136. package/src.website/src/support/timeutils.mjs +237 -0
  137. package/src.website/src/widgets/index.mjs +22 -0
  138. package/src.website/src.widgets/widgets.market/index.mjs +11 -0
  139. package/src.website/src.widgets/widgets.market/widgets/market/DiscoverWidget.mjs +401 -0
  140. package/src.website/src.widgets/widgets.market/widgets/market/EmptyNew.mjs +28 -0
  141. package/src.website/src.widgets/widgets.market/widgets/market/MarketDetail.mjs +78 -0
  142. package/src.website/src.widgets/widgets.market/widgets/market/MarketItem.mjs +349 -0
  143. package/src.website/src.widgets/widgets.market/widgets/market/MarketWidget.mjs +437 -0
  144. package/src.website/src.widgets/widgets.market/widgets/market/StoryLicenseWidget.mjs +34 -0
  145. package/src.website/src.widgets/widgets.market/widgets/market/css/market.css +394 -0
  146. package/src.website/src.widgets/widgets.market/widgets/market/css/notice.css +6 -0
  147. package/src.website/src.widgets/widgets.market/widgets/navibar/NaviBarWidget.mjs +58 -0
  148. package/src.website/src.widgets/widgets.market/widgets/navibar/css/titlebar.css +68 -0
  149. package/src.website/src.widgets/widgets.market/widgets/navibar/css/ui.navibar.css +28 -0
  150. package/src.website/src.widgets/widgets.software/index.mjs +9 -0
  151. package/src.website/src.widgets/widgets.software/widgets/BootStrapColumnWidget.mjs +17 -0
  152. package/src.website/src.widgets/widgets.software/widgets/DownloadWidget.mjs +210 -0
  153. package/src.website/src.widgets/widgets.software/widgets/LicenseWidget.js +103 -0
  154. package/src.website/src.widgets/widgets.software/widgets/css/download/download.css +110 -0
  155. package/src.website/src.widgets/widgets.software/widgets/css/license/beta.css +28 -0
  156. package/src.website/src.widgets/widgets.software/widgets/css/license/button.css +30 -0
  157. package/src.website/src.widgets/widgets.software/widgets/css/license/front.css +46 -0
  158. package/src.website/src.widgets/widgets.software/widgets/css/license/licenses.css +13 -0
  159. package/src.website/src.widgets/widgets.software/widgets/css/license/overstate.css +15 -0
  160. package/src.website/src.widgets/widgets.software/widgets/css/license/story.css +8 -0
  161. package/src.website/src.widgets/widgets.software/widgets/css/license/toolbar.css +9 -0
  162. package/src.website/src.widgets/widgets.software/widgets/support/version.mjs +88 -0
  163. package/src.website/src.widgets/widgets.worlds/index.mjs +11 -0
  164. package/src.website/src.widgets/widgets.worlds/widgets/LocalBrowser.mjs +386 -0
  165. package/src.website/src.widgets/widgets.worlds/widgets/LocalLauncher.code.mjs +247 -0
  166. package/src.website/src.widgets/widgets.worlds/widgets/LocalLauncher.mjs +239 -0
  167. package/src.website/src.widgets/widgets.worlds/widgets/css/input.css +32 -0
  168. package/src.website/src.widgets/widgets.worlds/widgets/css/localprojects.css +188 -0
  169. package/templates/documentation/assets/docs.css +7 -0
  170. package/templates/documentation/assets/images/right.webp +0 -0
  171. package/templates/documentation/images.json +12 -0
  172. package/templates/documentation/metadata.json +120 -0
  173. package/templates/documentation/pages/cookies.md +25 -0
  174. package/templates/documentation/pages/index.md +13 -0
  175. package/templates/documentation/pages/privacy.md +50 -0
  176. package/templates/documentation/pages/tos.md +49 -0
  177. package/templates/landing/assets/res/carousel/image-1.webp +0 -0
  178. package/templates/landing/assets/res/carousel/image-2.webp +0 -0
  179. package/templates/landing/assets/res/carousel/image-3.webp +0 -0
  180. package/templates/landing/assets/res/custom.css +122 -0
  181. package/templates/landing/assets/res/logos/favicon.ico +0 -0
  182. package/templates/landing/assets/res/logos/favicon.png +0 -0
  183. package/templates/landing/assets/res/logos/logo.medallion.png +0 -0
  184. package/templates/landing/assets/res/logos/logo.white.png +0 -0
  185. package/templates/landing/assets/res/proj/banda-tech-client.webp +0 -0
  186. package/templates/landing/assets/res/proj/banda-tech-server.webp +0 -0
  187. package/templates/landing/assets/res/proj/proj-common-ground.webp +0 -0
  188. package/templates/landing/assets/res/proj/proj-fieldnote.webp +0 -0
  189. package/templates/landing/assets/res/proj/proj-tribes.webp +0 -0
  190. package/templates/landing/images.json +932 -0
  191. package/templates/landing/metadata.json +115 -0
  192. package/templates/landing/pages/index.json +268 -0
  193. package/tool/cli.js +183 -0
@@ -0,0 +1,1269 @@
1
+ /**
2
+ * @fileoverview
3
+ * - Using the 'QRCode for Javascript library'
4
+ * - Fixed dataset of 'QRCode for Javascript library' for support full-spec.
5
+ * - this library has no dependencies.
6
+ *
7
+ * @author davidshimjs
8
+ * @see <a href="http://www.d-project.com/" target="_blank">http://www.d-project.com/</a>
9
+ * @see <a href="http://jeromeetienne.github.com/jquery-qrcode/" target="_blank">http://jeromeetienne.github.com/jquery-qrcode/</a>
10
+ */
11
+ var QRCode;
12
+
13
+ (function () {
14
+
15
+ "use strict";
16
+
17
+ //---------------------------------------------------------------------
18
+ // QRCode for JavaScript
19
+ //
20
+ // Copyright (c) 2009 Kazuhiko Arase
21
+ //
22
+ // URL: http://www.d-project.com/
23
+ //
24
+ // Licensed under the MIT license:
25
+ // http://www.opensource.org/licenses/mit-license.php
26
+ //
27
+ // The word "QR Code" is registered trademark of
28
+ // DENSO WAVE INCORPORATED
29
+ // http://www.denso-wave.com/qrcode/faqpatent-e.html
30
+ //
31
+ //---------------------------------------------------------------------
32
+
33
+ var /** @const {number } */ PIXEL_OFF = 0,
34
+ /** @const {number } */ PIXEL_POS = 2,
35
+ /** @const {number } */ PIXEL_TYP = 3,
36
+ /** @const {number } */ PIXEL_TIM = 4,
37
+ /** @const {number } */ PIXEL_DATA = 1;
38
+
39
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
40
+
41
+ function QR8bitByte(data) {
42
+ this.mode = QRMode.MODE_8BIT_BYTE;
43
+ this.data = data;
44
+ this.parsedData = [];
45
+
46
+ // Added to support UTF-8 Characters
47
+ for (var i = 0, l = this.data.length; i < l; i++) {
48
+
49
+ var byteArray = [],
50
+ code = this.data.charCodeAt(i);
51
+
52
+ if (code > 0x10000) {
53
+ byteArray[0] = 0xF0 | ((code & 0x1C0000) >>> 18);
54
+ byteArray[1] = 0x80 | ((code & 0x3F000) >>> 12);
55
+ byteArray[2] = 0x80 | ((code & 0xFC0) >>> 6);
56
+ byteArray[3] = 0x80 | (code & 0x3F);
57
+ } else if (code > 0x800) {
58
+ byteArray[0] = 0xE0 | ((code & 0xF000) >>> 12);
59
+ byteArray[1] = 0x80 | ((code & 0xFC0) >>> 6);
60
+ byteArray[2] = 0x80 | (code & 0x3F);
61
+ } else if (code > 0x80) {
62
+ byteArray[0] = 0xC0 | ((code & 0x7C0) >>> 6);
63
+ byteArray[1] = 0x80 | (code & 0x3F);
64
+ } else {
65
+ byteArray[0] = code;
66
+ }
67
+
68
+ this.parsedData.push(byteArray);
69
+ }
70
+
71
+ this.parsedData = Array.prototype.concat.apply([], this.parsedData);
72
+
73
+ if (this.parsedData.length !== this.data.length) {
74
+ this.parsedData.unshift(191);
75
+ this.parsedData.unshift(187);
76
+ this.parsedData.unshift(239);
77
+ }
78
+ }
79
+
80
+
81
+ QR8bitByte.prototype = {
82
+ getLength: function () {
83
+ return this.parsedData.length;
84
+ },
85
+ write: function (buffer) {
86
+ for (var i = 0, l = this.parsedData.length; i < l; i++) {
87
+ buffer.put(this.parsedData[i], 8);
88
+ }
89
+ }
90
+ };
91
+
92
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
93
+
94
+ function QRCodeModel(typeNumber, errorCorrectLevel) {
95
+ this.typeNumber = typeNumber;
96
+ this.errorCorrectLevel = errorCorrectLevel;
97
+ this.modules = null;
98
+ this.moduleCount = 0;
99
+ this.dataCache = null;
100
+ this.dataList = [];
101
+ }
102
+
103
+ QRCodeModel.prototype = {
104
+ addData: function (data) {
105
+ var newData = new QR8bitByte(data);
106
+ this.dataList.push(newData);
107
+ this.dataCache = null;
108
+ },
109
+ isDark: function (row, col) {
110
+ if (row < 0 || this.moduleCount <= row || col < 0 || this.moduleCount <= col) {
111
+ throw new Error(row + "," + col);
112
+ }
113
+ return this.modules[row][col];
114
+ },
115
+ isAnyDark: function (row, col) {
116
+ if (row < 0 || this.moduleCount <= row || col < 0 || this.moduleCount <= col) {
117
+ throw new Error(row + "," + col);
118
+ }
119
+ return this.modules[row][col] > 0;
120
+ },
121
+ getModuleCount: function () {
122
+ return this.moduleCount;
123
+ },
124
+ make: function () {
125
+ this.makeImpl(false, this.getBestMaskPattern());
126
+ },
127
+ makeImpl: function (test, maskPattern) {
128
+ var count = this.moduleCount = this.typeNumber * 4 + 17;
129
+ this.modules = new Array(count);
130
+ for (var row = 0; row < count; row++) {
131
+ this.modules[row] = new Array(count);
132
+ for (var col = 0; col < count; col++) {
133
+ this.modules[row][col] = null;
134
+ }
135
+ }
136
+ this.setupPositionProbePattern(0, 0);
137
+ this.setupPositionProbePattern(this.moduleCount - 7, 0);
138
+ this.setupPositionProbePattern(0, this.moduleCount - 7);
139
+ this.setupPositionAdjustPattern();
140
+ this.setupTimingPattern();
141
+ this.setupTypeInfo(test, maskPattern);
142
+ if (this.typeNumber >= 7) {
143
+ this.setupTypeNumber(test);
144
+ }
145
+ if (this.dataCache === null) {
146
+ this.dataCache = QRCodeModel.createData(this.typeNumber, this.errorCorrectLevel, this.dataList);
147
+ }
148
+ this.mapData(this.dataCache, maskPattern);
149
+ },
150
+ setupPositionProbePattern: function (row, col) {
151
+ for (var r = -1; r <= 7; r++) {
152
+ if (row + r <= -1 || this.moduleCount <= row + r) continue;
153
+ for (var c = -1; c <= 7; c++) {
154
+ if (col + c <= -1 || this.moduleCount <= col + c) continue;
155
+ if ((0 <= r && r <= 6 && (c === 0 || c === 6)) || (0 <= c && c <= 6 && (r === 0 || r === 6)) || (2 <= r && r <= 4 && 2 <= c && c <= 4)) {
156
+ this.modules[row + r][col + c] = PIXEL_POS;
157
+ } else {
158
+ this.modules[row + r][col + c] = PIXEL_OFF;
159
+ }
160
+ }
161
+ }
162
+ },
163
+ getBestMaskPattern: function () {
164
+
165
+ var minLostPoint = 0,
166
+ pattern = 0;
167
+
168
+ for (var i = 0; i < 8; i++) {
169
+ this.makeImpl(true, i);
170
+ var lostPoint = QRUtil.getLostPoint(this);
171
+ if (i === 0 || minLostPoint > lostPoint) {
172
+ minLostPoint = lostPoint;
173
+ pattern = i;
174
+ }
175
+ }
176
+ return pattern;
177
+ },
178
+ setupTimingPattern: function () {
179
+ for (var r = 8, l = this.moduleCount - 8; r < l; r++) {
180
+ if (this.modules[r][6] !== null) {
181
+ continue;
182
+ }
183
+ this.modules[r][6] = (r % 2 === 0) ? PIXEL_TIM : PIXEL_OFF;
184
+ }
185
+ for (var c = 8; c < l; c++) {
186
+ if (this.modules[6][c] !== null) {
187
+ continue;
188
+ }
189
+ this.modules[6][c] = (c % 2 === 0) ? PIXEL_TIM : PIXEL_OFF;
190
+ }
191
+ },
192
+ setupPositionAdjustPattern: function () {
193
+
194
+ var pos = QRUtil.getPatternPosition(this.typeNumber),
195
+ l = pos.length;
196
+
197
+ for (var i = 0; i < l; i++) {
198
+ for (var j = 0; j < l; j++) {
199
+
200
+ var row = pos[i],
201
+ col = pos[j];
202
+
203
+ if (this.modules[row][col] !== null) {
204
+ continue;
205
+ }
206
+
207
+ for (var r = -2; r <= 2; r++) {
208
+ for (var c = -2; c <= 2; c++) {
209
+ if (r === -2 || r === 2 || c === -2 || c === 2 || (r === 0 && c === 0)) {
210
+ this.modules[row + r][col + c] = PIXEL_POS;
211
+ } else {
212
+ this.modules[row + r][col + c] = PIXEL_OFF;
213
+ }
214
+ }
215
+ }
216
+ }
217
+ }
218
+ },
219
+ setupTypeNumber: function (test) {
220
+
221
+ var bits = QRUtil.getBCHTypeNumber(this.typeNumber);
222
+
223
+ for (var i = 0; i < 18; i++) {
224
+ this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = (!test && ((bits >> i) & 1) === 1) ? PIXEL_TYP : PIXEL_OFF;
225
+ }
226
+
227
+ for (i = 0; i < 18; i++) {
228
+ this.modules[i % 3 + this.moduleCount - 8 - 3][Math.floor(i / 3)] = (!test && ((bits >> i) & 1) === 1) ? PIXEL_TYP : PIXEL_OFF;
229
+ }
230
+ },
231
+
232
+ setupTypeInfo: function (test, maskPattern) {
233
+
234
+ var data = (this.errorCorrectLevel << 3) | maskPattern,
235
+ bits = QRUtil.getBCHTypeInfo(data),
236
+ mod;
237
+
238
+ for (var i = 0; i < 15; i++) {
239
+ mod = (!test && ((bits >> i) & 1) === 1) ? PIXEL_TYP : PIXEL_OFF;
240
+ if (i < 6) {
241
+ this.modules[i][8] = mod;
242
+ } else if (i < 8) {
243
+ this.modules[i + 1][8] = mod;
244
+ } else {
245
+ this.modules[this.moduleCount - 15 + i][8] = mod;
246
+ }
247
+ }
248
+ for (i = 0; i < 15; i++) {
249
+ mod = (!test && ((bits >> i) & 1) === 1) ? PIXEL_TYP : PIXEL_OFF;
250
+ if (i < 8) {
251
+ this.modules[8][this.moduleCount - i - 1] = mod;
252
+ } else if (i < 9) {
253
+ this.modules[8][15 - i - 1 + 1] = mod;
254
+ } else {
255
+ this.modules[8][15 - i - 1] = mod;
256
+ }
257
+ }
258
+ this.modules[this.moduleCount - 8][8] = (!test);
259
+ },
260
+
261
+ mapData: function (data, maskPattern) {
262
+
263
+ var inc = -1,
264
+ row = this.moduleCount - 1,
265
+ bitIndex = 7,
266
+ byteIndex = 0,
267
+ dataLen = data.length;
268
+
269
+ for (var col = this.moduleCount - 1; col > 0; col -= 2) {
270
+
271
+ if (col === 6) col--;
272
+
273
+ while (true) {
274
+ for (var c = 0; c < 2; c++) {
275
+ if (this.modules[row][col - c] === null) {
276
+ var dark = false;
277
+ if (byteIndex < dataLen) {
278
+ dark = (((data[byteIndex] >>> bitIndex) & 1) === 1);
279
+ }
280
+ var mask = QRUtil.getMask(maskPattern, row, col - c);
281
+ if (mask) {
282
+ dark = !dark;
283
+ }
284
+ this.modules[row][col - c] = dark ? PIXEL_DATA : PIXEL_OFF;
285
+ bitIndex--;
286
+ if (bitIndex === -1) {
287
+ byteIndex++;
288
+ bitIndex = 7;
289
+ }
290
+ }
291
+ }
292
+ row += inc;
293
+ if (row < 0 || this.moduleCount <= row) {
294
+ row -= inc;
295
+ inc = -inc;
296
+ break;
297
+ }
298
+ }
299
+ }
300
+ }
301
+ };
302
+ QRCodeModel.PAD0 = 0xEC;
303
+ QRCodeModel.PAD1 = 0x11;
304
+ QRCodeModel.createData = function (typeNumber, errorCorrectLevel, dataList) {
305
+
306
+ var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectLevel),
307
+ buffer = new QRBitBuffer(),
308
+ totalDataCount = 0;
309
+
310
+ for (var i = 0, l = dataList.length; i < l; i++) {
311
+ var data = dataList[i];
312
+ buffer.put(data.mode, 4);
313
+ buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber));
314
+ data.write(buffer);
315
+ }
316
+
317
+ for (i = 0, l = rsBlocks.length; i < l; i++) {
318
+ totalDataCount += rsBlocks[i].dataCount;
319
+ }
320
+
321
+ var totalDataBits = totalDataCount << 3;
322
+
323
+ if (buffer.getLengthInBits() > totalDataBits) {
324
+ throw new Error("code length overflow. (" + buffer.getLengthInBits() + ">" + totalDataBits + ")");
325
+ }
326
+ if (buffer.getLengthInBits() + 4 <= totalDataBits) {
327
+ buffer.put(0, 4);
328
+ }
329
+ while (buffer.getLengthInBits() % 8 !== 0) {
330
+ buffer.putBit(false);
331
+ }
332
+ while (true) {
333
+ if (buffer.getLengthInBits() >= totalDataBits) {
334
+ break;
335
+ }
336
+ buffer.put(QRCodeModel.PAD0, 8);
337
+ if (buffer.getLengthInBits() >= totalDataBits) {
338
+ break;
339
+ }
340
+ buffer.put(QRCodeModel.PAD1, 8);
341
+ }
342
+ return QRCodeModel.createBytes(buffer, rsBlocks);
343
+ };
344
+ QRCodeModel.createBytes = function (buffer, rsBlocks) {
345
+
346
+ var offset = 0,
347
+ maxDcCount = 0,
348
+ maxEcCount = 0,
349
+ dcdata = new Array(rsBlocks.length),
350
+ ecdata = new Array(rsBlocks.length),
351
+ totalCodeCount = 0,
352
+ i,
353
+ r,
354
+ l,
355
+ l2;
356
+
357
+ for (r = 0, l = rsBlocks.length; r < l; r++) {
358
+
359
+ var dcCount = rsBlocks[r].dataCount,
360
+ ecCount = rsBlocks[r].totalCount - dcCount;
361
+
362
+ maxDcCount = Math.max(maxDcCount, dcCount);
363
+ maxEcCount = Math.max(maxEcCount, ecCount);
364
+ dcdata[r] = new Array(dcCount);
365
+
366
+ for (i = 0, l2 = dcdata[r].length; i < l2; i++) {
367
+ dcdata[r][i] = 0xff & buffer.buffer[i + offset];
368
+ }
369
+
370
+ offset += dcCount;
371
+
372
+ var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount),
373
+ rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1),
374
+ modPoly = rawPoly.mod(rsPoly),
375
+ modPolyLen = modPoly.getLength();
376
+
377
+ ecdata[r] = new Array(rsPoly.getLength() - 1);
378
+
379
+ for (i = 0, l2 = ecdata[r].length; i < l2; i++) {
380
+ var modIndex = i + modPolyLen - ecdata[r].length;
381
+ ecdata[r][i] = (modIndex >= 0) ? modPoly.get(modIndex) : 0;
382
+ }
383
+ }
384
+
385
+ for (i = 0, l2 = rsBlocks.length; i < l2; i++) {
386
+ totalCodeCount += rsBlocks[i].totalCount;
387
+ }
388
+
389
+ var data = new Array(totalCodeCount),
390
+ index = 0;
391
+
392
+ for (i = 0; i < maxDcCount; i++) {
393
+ for (r = 0, l = rsBlocks.length; r < l; r++) {
394
+ if (i < dcdata[r].length) {
395
+ data[index++] = dcdata[r][i];
396
+ }
397
+ }
398
+ }
399
+
400
+ for (i = 0; i < maxEcCount; i++) {
401
+ for (r = 0, l = rsBlocks.length; r < l; r++) {
402
+ if (i < ecdata[r].length) {
403
+ data[index++] = ecdata[r][i];
404
+ }
405
+ }
406
+ }
407
+ return data;
408
+ };
409
+
410
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
411
+
412
+ var QRMode = {
413
+ MODE_NUMBER: 1 << 0,
414
+ MODE_ALPHA_NUM: 1 << 1,
415
+ MODE_8BIT_BYTE: 1 << 2,
416
+ MODE_KANJI: 1 << 3
417
+ };
418
+ var QRErrorCorrectLevel = {
419
+ L: 1,
420
+ M: 0,
421
+ Q: 3,
422
+ H: 2
423
+ };
424
+ var QRMaskPattern = {
425
+ PATTERN000: 0,
426
+ PATTERN001: 1,
427
+ PATTERN010: 2,
428
+ PATTERN011: 3,
429
+ PATTERN100: 4,
430
+ PATTERN101: 5,
431
+ PATTERN110: 6,
432
+ PATTERN111: 7
433
+ };
434
+ var QRUtil = {
435
+ PATTERN_POSITION_TABLE: [
436
+ [],
437
+ [6, 18],
438
+ [6, 22],
439
+ [6, 26],
440
+ [6, 30],
441
+ [6, 34],
442
+ [6, 22, 38],
443
+ [6, 24, 42],
444
+ [6, 26, 46],
445
+ [6, 28, 50],
446
+ [6, 30, 54],
447
+ [6, 32, 58],
448
+ [6, 34, 62],
449
+ [6, 26, 46, 66],
450
+ [6, 26, 48, 70],
451
+ [6, 26, 50, 74],
452
+ [6, 30, 54, 78],
453
+ [6, 30, 56, 82],
454
+ [6, 30, 58, 86],
455
+ [6, 34, 62, 90],
456
+ [6, 28, 50, 72, 94],
457
+ [6, 26, 50, 74, 98],
458
+ [6, 30, 54, 78, 102],
459
+ [6, 28, 54, 80, 106],
460
+ [6, 32, 58, 84, 110],
461
+ [6, 30, 58, 86, 114],
462
+ [6, 34, 62, 90, 118],
463
+ [6, 26, 50, 74, 98, 122],
464
+ [6, 30, 54, 78, 102, 126],
465
+ [6, 26, 52, 78, 104, 130],
466
+ [6, 30, 56, 82, 108, 134],
467
+ [6, 34, 60, 86, 112, 138],
468
+ [6, 30, 58, 86, 114, 142],
469
+ [6, 34, 62, 90, 118, 146],
470
+ [6, 30, 54, 78, 102, 126, 150],
471
+ [6, 24, 50, 76, 102, 128, 154],
472
+ [6, 28, 54, 80, 106, 132, 158],
473
+ [6, 32, 58, 84, 110, 136, 162],
474
+ [6, 26, 54, 82, 110, 138, 166],
475
+ [6, 30, 58, 86, 114, 142, 170]
476
+ ],
477
+ G15: (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0),
478
+ G18: (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0),
479
+ G15_MASK: (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1),
480
+ getBCHTypeInfo: function (data) {
481
+ var d = data << 10;
482
+ while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) {
483
+ d ^= (QRUtil.G15 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15)));
484
+ }
485
+ return ((data << 10) | d) ^ QRUtil.G15_MASK;
486
+ },
487
+ getBCHTypeNumber: function (data) {
488
+ var d = data << 12;
489
+ while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) {
490
+ d ^= (QRUtil.G18 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18)));
491
+ }
492
+ return (data << 12) | d;
493
+ },
494
+ getBCHDigit: function (data) {
495
+ var digit = 0;
496
+ while (data !== 0) {
497
+ digit++;
498
+ data >>>= 1;
499
+ }
500
+ return digit;
501
+ },
502
+ getPatternPosition: function (typeNumber) {
503
+ return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1];
504
+ },
505
+ getMask: function (maskPattern, i, j) {
506
+ switch (maskPattern) {
507
+ case QRMaskPattern.PATTERN000:
508
+ return (i + j) % 2 === 0;
509
+ case QRMaskPattern.PATTERN001:
510
+ return i % 2 === 0;
511
+ case QRMaskPattern.PATTERN010:
512
+ return j % 3 === 0;
513
+ case QRMaskPattern.PATTERN011:
514
+ return (i + j) % 3 === 0;
515
+ case QRMaskPattern.PATTERN100:
516
+ return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0;
517
+ case QRMaskPattern.PATTERN101:
518
+ return (i * j) % 2 + (i * j) % 3 === 0;
519
+ case QRMaskPattern.PATTERN110:
520
+ return ((i * j) % 2 + (i * j) % 3) % 2 === 0;
521
+ case QRMaskPattern.PATTERN111:
522
+ return ((i * j) % 3 + (i + j) % 2) % 2 === 0;
523
+ default:
524
+ throw new Error("bad maskPattern:" + maskPattern);
525
+ }
526
+ },
527
+ getErrorCorrectPolynomial: function (errorCorrectLength) {
528
+ var a = new QRPolynomial([1], 0);
529
+ for (var i = 0; i < errorCorrectLength; i++) {
530
+ a = a.multiply(new QRPolynomial([1, QRMath.gexp(i)], 0));
531
+ }
532
+ return a;
533
+ },
534
+ getLengthInBits: function (mode, type) {
535
+ if (1 <= type && type < 10) {
536
+ switch (mode) {
537
+ case QRMode.MODE_NUMBER:
538
+ return 10;
539
+ case QRMode.MODE_ALPHA_NUM:
540
+ return 9;
541
+ case QRMode.MODE_8BIT_BYTE:
542
+ return 8;
543
+ case QRMode.MODE_KANJI:
544
+ return 8;
545
+ default:
546
+ throw new Error("mode:" + mode);
547
+ }
548
+ } else if (type < 27) {
549
+ switch (mode) {
550
+ case QRMode.MODE_NUMBER:
551
+ return 12;
552
+ case QRMode.MODE_ALPHA_NUM:
553
+ return 11;
554
+ case QRMode.MODE_8BIT_BYTE:
555
+ return 16;
556
+ case QRMode.MODE_KANJI:
557
+ return 10;
558
+ default:
559
+ throw new Error("mode:" + mode);
560
+ }
561
+ } else if (type < 41) {
562
+ switch (mode) {
563
+ case QRMode.MODE_NUMBER:
564
+ return 14;
565
+ case QRMode.MODE_ALPHA_NUM:
566
+ return 13;
567
+ case QRMode.MODE_8BIT_BYTE:
568
+ return 16;
569
+ case QRMode.MODE_KANJI:
570
+ return 12;
571
+ default:
572
+ throw new Error("mode:" + mode);
573
+ }
574
+ } else {
575
+ throw new Error("type:" + type);
576
+ }
577
+ },
578
+ getLostPoint: function (qrCode) {
579
+
580
+ var moduleCount = qrCode.getModuleCount(),
581
+ lostPoint = 0,
582
+ row,
583
+ col;
584
+
585
+ for (row = 0; row < moduleCount; row++) {
586
+ for (col = 0; col < moduleCount; col++) {
587
+
588
+ var sameCount = 0,
589
+ dark = qrCode.isAnyDark(row, col);
590
+
591
+ for (var r = -1; r <= 1; r++) {
592
+ if (row + r < 0 || moduleCount <= row + r) {
593
+ continue;
594
+ }
595
+ for (var c = -1; c <= 1; c++) {
596
+ if (col + c < 0 || moduleCount <= col + c) {
597
+ continue;
598
+ }
599
+ if (r === 0 && c === 0) {
600
+ continue;
601
+ }
602
+ if (dark === qrCode.isAnyDark(row + r, col + c)) {
603
+ sameCount++;
604
+ }
605
+ }
606
+ }
607
+ if (sameCount > 5) {
608
+ lostPoint += (3 + sameCount - 5);
609
+ }
610
+ }
611
+ }
612
+ for (row = 0; row < moduleCount - 1; row++) {
613
+ for (col = 0; col < moduleCount - 1; col++) {
614
+ var count = 0;
615
+ if (qrCode.isDark(row, col)) count++;
616
+ if (qrCode.isDark(row + 1, col)) count++;
617
+ if (qrCode.isDark(row, col + 1)) count++;
618
+ if (qrCode.isDark(row + 1, col + 1)) count++;
619
+ if (count === 0 || count === 4) {
620
+ lostPoint += 3;
621
+ }
622
+ }
623
+ }
624
+ for (row = 0; row < moduleCount; row++) {
625
+ for (col = 0; col < moduleCount - 6; col++) {
626
+ if (qrCode.isDark(row, col) && !qrCode.isDark(row, col + 1) && qrCode.isDark(row, col + 2) && qrCode.isDark(row, col + 3) && qrCode.isDark(row,
627
+ col + 4) && !qrCode.isDark(row, col + 5) && qrCode.isDark(row, col + 6)) {
628
+ lostPoint += 40;
629
+ }
630
+ }
631
+ }
632
+ for (col = 0; col < moduleCount; col++) {
633
+ for (row = 0; row < moduleCount - 6; row++) {
634
+ if (qrCode.isDark(row, col) && !qrCode.isDark(row + 1, col) && qrCode.isDark(row + 2, col) && qrCode.isDark(row + 3, col) && qrCode.isDark(row + 4,
635
+ col) && !qrCode.isDark(row + 5, col) && qrCode.isDark(row + 6, col)) {
636
+ lostPoint += 40;
637
+ }
638
+ }
639
+ }
640
+ var darkCount = 0;
641
+ for (col = 0; col < moduleCount; col++) {
642
+ for (row = 0; row < moduleCount; row++) {
643
+ if (qrCode.isDark(row, col)) {
644
+ darkCount++;
645
+ }
646
+ }
647
+ }
648
+ var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
649
+ lostPoint += ratio * 10;
650
+ return lostPoint;
651
+ }
652
+ };
653
+
654
+ var QRMath = {
655
+ glog: function (n) {
656
+ if (n < 1) {
657
+ throw new Error("glog(" + n + ")");
658
+ }
659
+ return QRMath.LOG_TABLE[n];
660
+ },
661
+ gexp: function (n) {
662
+ while (n < 0) {
663
+ n += 255;
664
+ }
665
+ while (n >= 256) {
666
+ n -= 255;
667
+ }
668
+ return QRMath.EXP_TABLE[n];
669
+ },
670
+ EXP_TABLE: new Array(256),
671
+ LOG_TABLE: new Array(256)
672
+ };
673
+
674
+ for (var i = 0; i < 8; i++) {
675
+ QRMath.EXP_TABLE[i] = 1 << i;
676
+ }
677
+ for (i = 8; i < 256; i++) {
678
+ QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4] ^ QRMath.EXP_TABLE[i - 5] ^ QRMath.EXP_TABLE[i - 6] ^ QRMath.EXP_TABLE[i - 8];
679
+ }
680
+ for (i = 0; i < 255; i++) {
681
+ QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]] = i;
682
+ }
683
+
684
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
685
+
686
+ function QRPolynomial(num, shift) {
687
+
688
+ if (num.length === undefined) {
689
+ throw new Error(num.length + "/" + shift);
690
+ }
691
+ var offset = 0,
692
+ len = num.length;
693
+
694
+ while (offset < len && num[offset] === 0) {
695
+ offset++;
696
+ }
697
+ this.num = new Array(len - offset + shift);
698
+
699
+ for (var i = 0; i < len - offset; i++) {
700
+ this.num[i] = num[i + offset];
701
+ }
702
+ }
703
+
704
+ QRPolynomial.prototype = {
705
+ get: function (index) {
706
+ return this.num[index];
707
+ },
708
+ getLength: function () {
709
+ return this.num.length;
710
+ },
711
+ multiply: function (e) {
712
+
713
+ var len = this.getLength(),
714
+ elen = e.getLength(),
715
+ num = new Array(len + elen - 1);
716
+
717
+ for (var i = 0; i < len; i++) {
718
+ for (var j = 0; j < elen; j++) {
719
+ num[i + j] ^= QRMath.gexp(QRMath.glog(this.get(i)) + QRMath.glog(e.get(j)));
720
+ }
721
+ }
722
+ return new QRPolynomial(num, 0);
723
+ },
724
+ mod: function (e) {
725
+ if (this.getLength() - e.getLength() < 0) {
726
+ return this;
727
+ }
728
+ var ratio = QRMath.glog(this.get(0)) - QRMath.glog(e.get(0));
729
+ var num = new Array(this.getLength());
730
+ for (var i = 0; i < this.getLength(); i++) {
731
+ num[i] = this.get(i);
732
+ }
733
+ for (i = 0; i < e.getLength(); i++) {
734
+ num[i] ^= QRMath.gexp(QRMath.glog(e.get(i)) + ratio);
735
+ }
736
+ return new QRPolynomial(num, 0).mod(e);
737
+ }
738
+ };
739
+
740
+ function QRRSBlock(totalCount, dataCount) {
741
+ this.totalCount = totalCount;
742
+ this.dataCount = dataCount;
743
+ }
744
+
745
+ QRRSBlock.RS_BLOCK_TABLE = [
746
+ [1, 26, 19],
747
+ [1, 26, 16],
748
+ [1, 26, 13],
749
+ [1, 26, 9],
750
+ [1, 44, 34],
751
+ [1, 44, 28],
752
+ [1, 44, 22],
753
+ [1, 44, 16],
754
+ [1, 70, 55],
755
+ [1, 70, 44],
756
+ [2, 35, 17],
757
+ [2, 35, 13],
758
+ [1, 100, 80],
759
+ [2, 50, 32],
760
+ [2, 50, 24],
761
+ [4, 25, 9],
762
+ [1, 134, 108],
763
+ [2, 67, 43],
764
+ [2, 33, 15, 2, 34, 16],
765
+ [2, 33, 11, 2, 34, 12],
766
+ [2, 86, 68],
767
+ [4, 43, 27],
768
+ [4, 43, 19],
769
+ [4, 43, 15],
770
+ [2, 98, 78],
771
+ [4, 49, 31],
772
+ [2, 32, 14, 4, 33, 15],
773
+ [4, 39, 13, 1, 40, 14],
774
+ [2, 121, 97],
775
+ [2, 60, 38, 2, 61, 39],
776
+ [4, 40, 18, 2, 41, 19],
777
+ [4, 40, 14, 2, 41, 15],
778
+ [2, 146, 116],
779
+ [3, 58, 36, 2, 59, 37],
780
+ [4, 36, 16, 4, 37, 17],
781
+ [4, 36, 12, 4, 37, 13],
782
+ [2, 86, 68, 2, 87, 69],
783
+ [4, 69, 43, 1, 70, 44],
784
+ [6, 43, 19, 2, 44, 20],
785
+ [6, 43, 15, 2, 44, 16],
786
+ [4, 101, 81],
787
+ [1, 80, 50, 4, 81, 51],
788
+ [4, 50, 22, 4, 51, 23],
789
+ [3, 36, 12, 8, 37, 13],
790
+ [2, 116, 92, 2, 117, 93],
791
+ [6, 58, 36, 2, 59, 37],
792
+ [4, 46, 20, 6, 47, 21],
793
+ [7, 42, 14, 4, 43, 15],
794
+ [4, 133, 107],
795
+ [8, 59, 37, 1, 60, 38],
796
+ [8, 44, 20, 4, 45, 21],
797
+ [12, 33, 11, 4, 34, 12],
798
+ [3, 145, 115, 1, 146, 116],
799
+ [4, 64, 40, 5, 65, 41],
800
+ [11, 36, 16, 5, 37, 17],
801
+ [11, 36, 12, 5, 37, 13],
802
+ [5, 109, 87, 1, 110, 88],
803
+ [5, 65, 41, 5, 66, 42],
804
+ [5, 54, 24, 7, 55, 25],
805
+ [11, 36, 12],
806
+ [5, 122, 98, 1, 123, 99],
807
+ [7, 73, 45, 3, 74, 46],
808
+ [15, 43, 19, 2, 44, 20],
809
+ [3, 45, 15, 13, 46, 16],
810
+ [1, 135, 107, 5, 136, 108],
811
+ [10, 74, 46, 1, 75, 47],
812
+ [1, 50, 22, 15, 51, 23],
813
+ [2, 42, 14, 17, 43, 15],
814
+ [5, 150, 120, 1, 151, 121],
815
+ [9, 69, 43, 4, 70, 44],
816
+ [17, 50, 22, 1, 51, 23],
817
+ [2, 42, 14, 19, 43, 15],
818
+ [3, 141, 113, 4, 142, 114],
819
+ [3, 70, 44, 11, 71, 45],
820
+ [17, 47, 21, 4, 48, 22],
821
+ [9, 39, 13, 16, 40, 14],
822
+ [3, 135, 107, 5, 136, 108],
823
+ [3, 67, 41, 13, 68, 42],
824
+ [15, 54, 24, 5, 55, 25],
825
+ [15, 43, 15, 10, 44, 16],
826
+ [4, 144, 116, 4, 145, 117],
827
+ [17, 68, 42],
828
+ [17, 50, 22, 6, 51, 23],
829
+ [19, 46, 16, 6, 47, 17],
830
+ [2, 139, 111, 7, 140, 112],
831
+ [17, 74, 46],
832
+ [7, 54, 24, 16, 55, 25],
833
+ [34, 37, 13],
834
+ [4, 151, 121, 5, 152, 122],
835
+ [4, 75, 47, 14, 76, 48],
836
+ [11, 54, 24, 14, 55, 25],
837
+ [16, 45, 15, 14, 46, 16],
838
+ [6, 147, 117, 4, 148, 118],
839
+ [6, 73, 45, 14, 74, 46],
840
+ [11, 54, 24, 16, 55, 25],
841
+ [30, 46, 16, 2, 47, 17],
842
+ [8, 132, 106, 4, 133, 107],
843
+ [8, 75, 47, 13, 76, 48],
844
+ [7, 54, 24, 22, 55, 25],
845
+ [22, 45, 15, 13, 46, 16],
846
+ [10, 142, 114, 2, 143, 115],
847
+ [19, 74, 46, 4, 75, 47],
848
+ [28, 50, 22, 6, 51, 23],
849
+ [33, 46, 16, 4, 47, 17],
850
+ [8, 152, 122, 4, 153, 123],
851
+ [22, 73, 45, 3, 74, 46],
852
+ [8, 53, 23, 26, 54, 24],
853
+ [12, 45, 15, 28, 46, 16],
854
+ [3, 147, 117, 10, 148, 118],
855
+ [3, 73, 45, 23, 74, 46],
856
+ [4, 54, 24, 31, 55, 25],
857
+ [11, 45, 15, 31, 46, 16],
858
+ [7, 146, 116, 7, 147, 117],
859
+ [21, 73, 45, 7, 74, 46],
860
+ [1, 53, 23, 37, 54, 24],
861
+ [19, 45, 15, 26, 46, 16],
862
+ [5, 145, 115, 10, 146, 116],
863
+ [19, 75, 47, 10, 76, 48],
864
+ [15, 54, 24, 25, 55, 25],
865
+ [23, 45, 15, 25, 46, 16],
866
+ [13, 145, 115, 3, 146, 116],
867
+ [2, 74, 46, 29, 75, 47],
868
+ [42, 54, 24, 1, 55, 25],
869
+ [23, 45, 15, 28, 46, 16],
870
+ [17, 145, 115],
871
+ [10, 74, 46, 23, 75, 47],
872
+ [10, 54, 24, 35, 55, 25],
873
+ [19, 45, 15, 35, 46, 16],
874
+ [17, 145, 115, 1, 146, 116],
875
+ [14, 74, 46, 21, 75, 47],
876
+ [29, 54, 24, 19, 55, 25],
877
+ [11, 45, 15, 46, 46, 16],
878
+ [13, 145, 115, 6, 146, 116],
879
+ [14, 74, 46, 23, 75, 47],
880
+ [44, 54, 24, 7, 55, 25],
881
+ [59, 46, 16, 1, 47, 17],
882
+ [12, 151, 121, 7, 152, 122],
883
+ [12, 75, 47, 26, 76, 48],
884
+ [39, 54, 24, 14, 55, 25],
885
+ [22, 45, 15, 41, 46, 16],
886
+ [6, 151, 121, 14, 152, 122],
887
+ [6, 75, 47, 34, 76, 48],
888
+ [46, 54, 24, 10, 55, 25],
889
+ [2, 45, 15, 64, 46, 16],
890
+ [17, 152, 122, 4, 153, 123],
891
+ [29, 74, 46, 14, 75, 47],
892
+ [49, 54, 24, 10, 55, 25],
893
+ [24, 45, 15, 46, 46, 16],
894
+ [4, 152, 122, 18, 153, 123],
895
+ [13, 74, 46, 32, 75, 47],
896
+ [48, 54, 24, 14, 55, 25],
897
+ [42, 45, 15, 32, 46, 16],
898
+ [20, 147, 117, 4, 148, 118],
899
+ [40, 75, 47, 7, 76, 48],
900
+ [43, 54, 24, 22, 55, 25],
901
+ [10, 45, 15, 67, 46, 16],
902
+ [19, 148, 118, 6, 149, 119],
903
+ [18, 75, 47, 31, 76, 48],
904
+ [34, 54, 24, 34, 55, 25],
905
+ [20, 45, 15, 61, 46, 16]
906
+ ];
907
+ QRRSBlock.getRSBlocks = function (typeNumber, errorCorrectLevel) {
908
+
909
+ var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel);
910
+
911
+ if (rsBlock === undefined) {
912
+ throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel);
913
+ }
914
+
915
+ var length = rsBlock.length / 3,
916
+ list = [];
917
+
918
+ for (var i = 0; i < length; i++) {
919
+
920
+ var count = rsBlock[i * 3],
921
+ totalCount = rsBlock[i * 3 + 1],
922
+ dataCount = rsBlock[i * 3 + 2];
923
+
924
+ for (var j = 0; j < count; j++) {
925
+ list.push(new QRRSBlock(totalCount, dataCount));
926
+ }
927
+ }
928
+ return list;
929
+ };
930
+
931
+ QRRSBlock.getRsBlockTable = function (typeNumber, errorCorrectLevel) {
932
+ switch (errorCorrectLevel) {
933
+ case QRErrorCorrectLevel.L:
934
+ return QRRSBlock.RS_BLOCK_TABLE[((typeNumber - 1) << 2)];
935
+ case QRErrorCorrectLevel.M:
936
+ return QRRSBlock.RS_BLOCK_TABLE[((typeNumber - 1) << 2) + 1];
937
+ case QRErrorCorrectLevel.Q:
938
+ return QRRSBlock.RS_BLOCK_TABLE[((typeNumber - 1) << 2) + 2];
939
+ case QRErrorCorrectLevel.H:
940
+ return QRRSBlock.RS_BLOCK_TABLE[((typeNumber - 1) << 2) + 3];
941
+ default:
942
+ return undefined;
943
+ }
944
+ };
945
+
946
+ function QRBitBuffer() {
947
+ this.buffer = [];
948
+ this.length = 0;
949
+ }
950
+
951
+ QRBitBuffer.prototype = {
952
+ get: function (index) {
953
+ var bufIndex = Math.floor(index / 8);
954
+ return ((this.buffer[bufIndex] >>> (7 - index % 8)) & 1) === 1;
955
+ },
956
+ put: function (num, length) {
957
+ for (var i = 0; i < length; i++) {
958
+ this.putBit(((num >>> (length - i - 1)) & 1) === 1);
959
+ }
960
+ },
961
+ getLengthInBits: function () {
962
+ return this.length;
963
+ },
964
+ putBit: function (bit) {
965
+ var bufIndex = Math.floor(this.length / 8);
966
+ if (this.buffer.length <= bufIndex) {
967
+ this.buffer.push(0);
968
+ }
969
+ if (bit) {
970
+ this.buffer[bufIndex] |= (0x80 >>> (this.length % 8));
971
+ }
972
+ this.length++;
973
+ }
974
+ };
975
+ var QRCodeLimitLength = [
976
+ [17, 14, 11, 7],
977
+ [32, 26, 20, 14],
978
+ [53, 42, 32, 24],
979
+ [78, 62, 46, 34],
980
+ [106, 84, 60, 44],
981
+ [134, 106, 74, 58],
982
+ [154, 122, 86, 64],
983
+ [192, 152, 108, 84],
984
+ [230, 180, 130, 98],
985
+ [271, 213, 151, 119],
986
+ [321, 251, 177, 137],
987
+ [367, 287, 203, 155],
988
+ [425, 331, 241, 177],
989
+ [458, 362, 258, 194],
990
+ [520, 412, 292, 220],
991
+ [586, 450, 322, 250],
992
+ [644, 504, 364, 280],
993
+ [718, 560, 394, 310],
994
+ [792, 624, 442, 338],
995
+ [858, 666, 482, 382],
996
+ [929, 711, 509, 403],
997
+ [1003, 779, 565, 439],
998
+ [1091, 857, 611, 461],
999
+ [1171, 911, 661, 511],
1000
+ [1273, 997, 715, 535],
1001
+ [1367, 1059, 751, 593],
1002
+ [1465, 1125, 805, 625],
1003
+ [1528, 1190, 868, 658],
1004
+ [1628, 1264, 908, 698],
1005
+ [1732, 1370, 982, 742],
1006
+ [1840, 1452, 1030, 790],
1007
+ [1952, 1538, 1112, 842],
1008
+ [2068, 1628, 1168, 898],
1009
+ [2188, 1722, 1228, 958],
1010
+ [2303, 1809, 1283, 983],
1011
+ [2431, 1911, 1351, 1051],
1012
+ [2563, 1989, 1423, 1093],
1013
+ [2699, 2099, 1499, 1139],
1014
+ [2809, 2213, 1579, 1219],
1015
+ [2953, 2331, 1663, 1273]
1016
+ ];
1017
+
1018
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1019
+
1020
+ var Drawing = (function () {
1021
+
1022
+ var Drawing = function (el, htOption) {
1023
+ this._el = el;
1024
+ this._htOption = htOption;
1025
+ };
1026
+
1027
+ Drawing.prototype.draw = function (oQRCode) {
1028
+ var $qrSvg = this.getSvg(oQRCode);
1029
+ this.clear();
1030
+ this._el.appendChild($qrSvg);
1031
+ };
1032
+
1033
+ Drawing.prototype.getSvg = function (oQRCode, options) {
1034
+
1035
+ if (options) {
1036
+ for (var o in options) {
1037
+ this._htOption[o] = options[o];
1038
+ }
1039
+ }
1040
+
1041
+ var _htOption = this._htOption,
1042
+ nCount = oQRCode.getModuleCount();
1043
+
1044
+ function makeSVG(tag, attrs) {
1045
+ var el = document.createElementNS("http://www.w3.org/2000/svg", tag);
1046
+ for (var k in attrs) {
1047
+ attrs.hasOwnProperty(k) && el.setAttribute(k, attrs[k]);
1048
+ }
1049
+ return el;
1050
+ }
1051
+
1052
+ var svg = makeSVG("svg", {
1053
+ "viewBox": "0 0 " + String(nCount) + " " + String(nCount),
1054
+ "width": "100%",
1055
+ "height": "100%"
1056
+ // 'fill': _htOption.colorLight
1057
+ });
1058
+
1059
+ svg.setAttribute("xmlns", "http://www.w3.org/2000/svg");
1060
+
1061
+ var color = _htOption.colorDark || "black",
1062
+ colorAlt = _htOption.colorAlt || color,
1063
+ colors = [color, colorAlt, colorAlt, colorAlt],
1064
+ childOptions = {
1065
+ width: "1",
1066
+ height: "1"
1067
+ };
1068
+
1069
+ for (var row = 0; row < nCount; row++) {
1070
+ childOptions.y = row;
1071
+ for (var col = 0; col < nCount; col++) {
1072
+ var pixel = oQRCode.isDark(row, col);
1073
+ if (pixel > 0) {
1074
+ childOptions.x = col;
1075
+ childOptions.fill = colors[pixel - 1] || color;
1076
+ svg.appendChild(makeSVG("rect", childOptions));
1077
+ }
1078
+ }
1079
+ }
1080
+ return svg;
1081
+ };
1082
+
1083
+ Drawing.prototype.clear = function () {
1084
+ while (this._el.hasChildNodes()) {
1085
+ this._el.removeChild(this._el.lastChild);
1086
+ }
1087
+ };
1088
+ return Drawing;
1089
+ })();
1090
+
1091
+
1092
+ /**
1093
+ * Get the type by string length
1094
+ *
1095
+ * @private
1096
+ * @param {String} sText
1097
+ * @param {Number} nCorrectLevel
1098
+ * @return {Number} type
1099
+ */
1100
+ function _getTypeNumber(sText, nCorrectLevel) {
1101
+ var nType = 1;
1102
+ var length = _getUTF8Length(sText);
1103
+
1104
+ for (var i = 0, len = QRCodeLimitLength.length; i <= len; i++) {
1105
+ var nLimit = 0;
1106
+
1107
+ switch (nCorrectLevel) {
1108
+ case QRErrorCorrectLevel.L:
1109
+ nLimit = QRCodeLimitLength[i][0];
1110
+ break;
1111
+ case QRErrorCorrectLevel.M:
1112
+ nLimit = QRCodeLimitLength[i][1];
1113
+ break;
1114
+ case QRErrorCorrectLevel.Q:
1115
+ nLimit = QRCodeLimitLength[i][2];
1116
+ break;
1117
+ case QRErrorCorrectLevel.H:
1118
+ nLimit = QRCodeLimitLength[i][3];
1119
+ break;
1120
+ }
1121
+
1122
+ if (length <= nLimit) {
1123
+ break;
1124
+ } else {
1125
+ nType++;
1126
+ }
1127
+ }
1128
+
1129
+ if (nType > QRCodeLimitLength.length) {
1130
+ throw new Error("Too long data");
1131
+ }
1132
+
1133
+ return nType;
1134
+ }
1135
+
1136
+ function _getUTF8Length(sText) {
1137
+ var replacedText = encodeURI(sText)
1138
+ .toString()
1139
+ .replace(/%[0-9a-fA-F]{2}/g, "a");
1140
+ return replacedText.length + (replacedText.length !== sText ? 3 : 0);
1141
+ }
1142
+
1143
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1144
+
1145
+
1146
+ /**
1147
+ * @class QRCode
1148
+ * @constructor
1149
+ * @example
1150
+ * new QRCode(document.getElementById("test"), "http://jindo.dev.naver.com/collie");
1151
+ *
1152
+ * @example
1153
+ * var oQRCode = new QRCode("test", {
1154
+ * text : "http://naver.com",
1155
+ * width : 128,
1156
+ * height : 128
1157
+ * });
1158
+ *
1159
+ * oQRCode.clear(); // Clear the QRCode.
1160
+ * oQRCode.makeCode("http://map.naver.com"); // Re-create the QRCode.
1161
+ * oQRCode.getSvg(); // get qrcode as svg
1162
+ *
1163
+ * @param {HTMLElement|String} el target element or 'id' attribute of element.
1164
+ * @param {Object|String} vOption
1165
+ * @param {String} vOption.text QRCode link data
1166
+ * @param {Number} [vOption.width=256]
1167
+ * @param {Number} [vOption.height=256]
1168
+ * @param {String} [vOption.colorDark="#000000"]
1169
+ * @param {String} [vOption.colorLight="#ffffff"]
1170
+ * @param {QRCode.CorrectLevel} [vOption.correctLevel=QRCode.CorrectLevel.H] [L|M|Q|H]
1171
+ */
1172
+ QRCode = function (el, vOption) {
1173
+ this._htOption = {
1174
+ width: 256,
1175
+ height: 256,
1176
+ typeNumber: 4,
1177
+ colorDark: "black",
1178
+ colorLight: "white",
1179
+ correctLevel: QRErrorCorrectLevel.H
1180
+ };
1181
+
1182
+ if (typeof vOption === "string") {
1183
+ vOption = {
1184
+ text: vOption
1185
+ };
1186
+ }
1187
+
1188
+ // Overwrites options
1189
+ if (vOption) {
1190
+ for (var i in vOption) {
1191
+ this._htOption[i] = vOption[i];
1192
+ }
1193
+ }
1194
+
1195
+ if (typeof el === "string") {
1196
+ el = document.getElementById(el);
1197
+ }
1198
+
1199
+ this._el = el;
1200
+ this._oQRCode = null;
1201
+ this._oDrawing = new Drawing(this._el, this._htOption);
1202
+
1203
+ if (this._htOption.text) {
1204
+ this.makeCode(this._htOption.text);
1205
+ }
1206
+ };
1207
+
1208
+ /**
1209
+ * Make the QRCode
1210
+ *
1211
+ * @param {String} sText link data
1212
+ */
1213
+ QRCode.prototype.makeCode = function (sText) {
1214
+ this._oQRCode = new QRCodeModel(_getTypeNumber(sText, this._htOption.correctLevel), this._htOption.correctLevel);
1215
+ this._oQRCode.addData(sText);
1216
+ this._oQRCode.make();
1217
+ this._el.title = sText;
1218
+ this._oDrawing.draw(this._oQRCode);
1219
+ this.makeImage();
1220
+ };
1221
+
1222
+ QRCode.prototype.getSvg = function (sText, opts) {
1223
+ this._oQRCode = new QRCodeModel(_getTypeNumber(sText, this._htOption.correctLevel), this._htOption.correctLevel);
1224
+ this._oQRCode.addData(sText);
1225
+ this._oQRCode.make();
1226
+ return this._oDrawing.getSvg(this._oQRCode, opts);
1227
+ };
1228
+
1229
+ /**
1230
+ * Make the Image from Canvas element
1231
+ * - It occurs automatically
1232
+ *
1233
+ * @private
1234
+ */
1235
+ QRCode.prototype.makeImage = function () {
1236
+ if (typeof this._oDrawing.makeImage === "function") {
1237
+ this._oDrawing.makeImage();
1238
+ }
1239
+ };
1240
+
1241
+ /**
1242
+ * Clear the QRCode
1243
+ */
1244
+ QRCode.prototype.clear = function () {
1245
+ this._oDrawing.clear();
1246
+ };
1247
+
1248
+ /**
1249
+ * @name QRCode.CorrectLevel
1250
+ */
1251
+ QRCode.CorrectLevel = QRErrorCorrectLevel;
1252
+
1253
+ })();
1254
+ /*
1255
+
1256
+ svg = new QRCode().getSvg(
1257
+ qurl,
1258
+ {"colorDark": "black", "colorAlt": "#400000"}
1259
+ );
1260
+
1261
+ $QR
1262
+ .html(svg);
1263
+
1264
+ */
1265
+
1266
+ const qrCodeInstance = new QRCode();
1267
+
1268
+ export default qrCodeInstance;
1269
+