agent-yes 1.200.0 → 1.202.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 (38) hide show
  1. package/default.config.yaml +8 -8
  2. package/dist/{SUPPORTED_CLIS-Dt-oEBTl.js → SUPPORTED_CLIS-Cc4YcXL_.js} +2 -2
  3. package/dist/SUPPORTED_CLIS-ChdPabFX.js +9 -0
  4. package/dist/{agentShare-D-9ppbuL.js → agentShare-e4ErqbAZ.js} +2 -2
  5. package/dist/cli.js +4 -4
  6. package/dist/index.js +2 -2
  7. package/dist/{notifyDaemon-CQZ_wPhN.js → notifyDaemon-Bo-RiQ2N.js} +2 -2
  8. package/dist/{rustBinary-C5SrmIUM.js → rustBinary-Dd7-HOFy.js} +2 -2
  9. package/dist/{schedule-lPUt6BkE.js → schedule-Hu3krhNK.js} +4 -4
  10. package/dist/{serve-DlUJ7Hg9.js → serve-D4B43UQC.js} +12 -12
  11. package/dist/{setup-Dalhb8_0.js → setup-hUonzP6V.js} +2 -2
  12. package/dist/{subcommands-g1kLml5I.js → subcommands-DQmW41_L.js} +1 -1
  13. package/dist/{subcommands-DvXyUjWT.js → subcommands-DbiyHGKA.js} +53 -11
  14. package/dist/{ts-Oyau4Eap.js → ts--ZOQIaTr.js} +2 -2
  15. package/dist/{versionChecker-CeLrr-kQ.js → versionChecker-D2egG8Wk.js} +2 -2
  16. package/dist/{ws-DZDjlG3o.js → ws-CygS4IEs.js} +2 -2
  17. package/lab/ui/console-logic.js +32 -2
  18. package/lab/ui/index.html +99 -24
  19. package/lab/ui/qrcode.js +548 -565
  20. package/lab/ui/room-client.js +70 -91
  21. package/lab/ui/sw.js +17 -7
  22. package/package.json +7 -7
  23. package/scripts/build-rgui.ts +3 -1
  24. package/ts/agentShare.spec.ts +5 -3
  25. package/ts/badges.spec.ts +84 -1
  26. package/ts/badges.ts +69 -5
  27. package/ts/notifyDaemon.spec.ts +2 -8
  28. package/ts/notifyDaemon.ts +32 -33
  29. package/ts/notifyInbox.spec.ts +2 -1
  30. package/ts/notifyRouter.spec.ts +7 -11
  31. package/ts/notifyStore.spec.ts +4 -1
  32. package/ts/notifyStore.ts +18 -14
  33. package/ts/serve.spec.ts +4 -6
  34. package/ts/serve.ts +69 -17
  35. package/ts/subcommands.ts +46 -18
  36. package/ts/ws.spec.ts +31 -7
  37. package/ts/ws.ts +15 -4
  38. package/dist/SUPPORTED_CLIS-D8PoWxsA.js +0 -9
package/lab/ui/qrcode.js CHANGED
@@ -15,8 +15,7 @@
15
15
  //
16
16
  //---------------------------------------------------------------------
17
17
 
18
- var qrcode = function() {
19
-
18
+ var qrcode = (function () {
20
19
  //---------------------------------------------------------------------
21
20
  // qrcode
22
21
  //---------------------------------------------------------------------
@@ -26,9 +25,8 @@ var qrcode = function() {
26
25
  * @param typeNumber 1 to 40
27
26
  * @param errorCorrectionLevel 'L','M','Q','H'
28
27
  */
29
- var qrcode = function(typeNumber, errorCorrectionLevel) {
30
-
31
- var PAD0 = 0xEC;
28
+ var qrcode = function (typeNumber, errorCorrectionLevel) {
29
+ var PAD0 = 0xec;
32
30
  var PAD1 = 0x11;
33
31
 
34
32
  var _typeNumber = typeNumber;
@@ -40,10 +38,9 @@ var qrcode = function() {
40
38
 
41
39
  var _this = {};
42
40
 
43
- var makeImpl = function(test, maskPattern) {
44
-
41
+ var makeImpl = function (test, maskPattern) {
45
42
  _moduleCount = _typeNumber * 4 + 17;
46
- _modules = function(moduleCount) {
43
+ _modules = (function (moduleCount) {
47
44
  var modules = new Array(moduleCount);
48
45
  for (var row = 0; row < moduleCount; row += 1) {
49
46
  modules[row] = new Array(moduleCount);
@@ -52,7 +49,7 @@ var qrcode = function() {
52
49
  }
53
50
  }
54
51
  return modules;
55
- }(_moduleCount);
52
+ })(_moduleCount);
56
53
 
57
54
  setupPositionProbePattern(0, 0);
58
55
  setupPositionProbePattern(_moduleCount - 7, 0);
@@ -72,19 +69,18 @@ var qrcode = function() {
72
69
  mapData(_dataCache, maskPattern);
73
70
  };
74
71
 
75
- var setupPositionProbePattern = function(row, col) {
76
-
72
+ var setupPositionProbePattern = function (row, col) {
77
73
  for (var r = -1; r <= 7; r += 1) {
78
-
79
74
  if (row + r <= -1 || _moduleCount <= row + r) continue;
80
75
 
81
76
  for (var c = -1; c <= 7; c += 1) {
82
-
83
77
  if (col + c <= -1 || _moduleCount <= col + c) continue;
84
78
 
85
- if ( (0 <= r && r <= 6 && (c == 0 || c == 6) )
86
- || (0 <= c && c <= 6 && (r == 0 || r == 6) )
87
- || (2 <= r && r <= 4 && 2 <= c && c <= 4) ) {
79
+ if (
80
+ (0 <= r && r <= 6 && (c == 0 || c == 6)) ||
81
+ (0 <= c && c <= 6 && (r == 0 || r == 6)) ||
82
+ (2 <= r && r <= 4 && 2 <= c && c <= 4)
83
+ ) {
88
84
  _modules[row + r][col + c] = true;
89
85
  } else {
90
86
  _modules[row + r][col + c] = false;
@@ -93,13 +89,11 @@ var qrcode = function() {
93
89
  }
94
90
  };
95
91
 
96
- var getBestMaskPattern = function() {
97
-
92
+ var getBestMaskPattern = function () {
98
93
  var minLostPoint = 0;
99
94
  var pattern = 0;
100
95
 
101
96
  for (var i = 0; i < 8; i += 1) {
102
-
103
97
  makeImpl(true, i);
104
98
 
105
99
  var lostPoint = QRUtil.getLostPoint(_this);
@@ -113,31 +107,27 @@ var qrcode = function() {
113
107
  return pattern;
114
108
  };
115
109
 
116
- var setupTimingPattern = function() {
117
-
110
+ var setupTimingPattern = function () {
118
111
  for (var r = 8; r < _moduleCount - 8; r += 1) {
119
112
  if (_modules[r][6] != null) {
120
113
  continue;
121
114
  }
122
- _modules[r][6] = (r % 2 == 0);
115
+ _modules[r][6] = r % 2 == 0;
123
116
  }
124
117
 
125
118
  for (var c = 8; c < _moduleCount - 8; c += 1) {
126
119
  if (_modules[6][c] != null) {
127
120
  continue;
128
121
  }
129
- _modules[6][c] = (c % 2 == 0);
122
+ _modules[6][c] = c % 2 == 0;
130
123
  }
131
124
  };
132
125
 
133
- var setupPositionAdjustPattern = function() {
134
-
126
+ var setupPositionAdjustPattern = function () {
135
127
  var pos = QRUtil.getPatternPosition(_typeNumber);
136
128
 
137
129
  for (var i = 0; i < pos.length; i += 1) {
138
-
139
130
  for (var j = 0; j < pos.length; j += 1) {
140
-
141
131
  var row = pos[i];
142
132
  var col = pos[j];
143
133
 
@@ -146,11 +136,8 @@ var qrcode = function() {
146
136
  }
147
137
 
148
138
  for (var r = -2; r <= 2; r += 1) {
149
-
150
139
  for (var c = -2; c <= 2; c += 1) {
151
-
152
- if (r == -2 || r == 2 || c == -2 || c == 2
153
- || (r == 0 && c == 0) ) {
140
+ if (r == -2 || r == 2 || c == -2 || c == 2 || (r == 0 && c == 0)) {
154
141
  _modules[row + r][col + c] = true;
155
142
  } else {
156
143
  _modules[row + r][col + c] = false;
@@ -161,30 +148,27 @@ var qrcode = function() {
161
148
  }
162
149
  };
163
150
 
164
- var setupTypeNumber = function(test) {
165
-
151
+ var setupTypeNumber = function (test) {
166
152
  var bits = QRUtil.getBCHTypeNumber(_typeNumber);
167
153
 
168
154
  for (var i = 0; i < 18; i += 1) {
169
- var mod = (!test && ( (bits >> i) & 1) == 1);
170
- _modules[Math.floor(i / 3)][i % 3 + _moduleCount - 8 - 3] = mod;
155
+ var mod = !test && ((bits >> i) & 1) == 1;
156
+ _modules[Math.floor(i / 3)][(i % 3) + _moduleCount - 8 - 3] = mod;
171
157
  }
172
158
 
173
159
  for (var i = 0; i < 18; i += 1) {
174
- var mod = (!test && ( (bits >> i) & 1) == 1);
175
- _modules[i % 3 + _moduleCount - 8 - 3][Math.floor(i / 3)] = mod;
160
+ var mod = !test && ((bits >> i) & 1) == 1;
161
+ _modules[(i % 3) + _moduleCount - 8 - 3][Math.floor(i / 3)] = mod;
176
162
  }
177
163
  };
178
164
 
179
- var setupTypeInfo = function(test, maskPattern) {
180
-
165
+ var setupTypeInfo = function (test, maskPattern) {
181
166
  var data = (_errorCorrectionLevel << 3) | maskPattern;
182
167
  var bits = QRUtil.getBCHTypeInfo(data);
183
168
 
184
169
  // vertical
185
170
  for (var i = 0; i < 15; i += 1) {
186
-
187
- var mod = (!test && ( (bits >> i) & 1) == 1);
171
+ var mod = !test && ((bits >> i) & 1) == 1;
188
172
 
189
173
  if (i < 6) {
190
174
  _modules[i][8] = mod;
@@ -197,8 +181,7 @@ var qrcode = function() {
197
181
 
198
182
  // horizontal
199
183
  for (var i = 0; i < 15; i += 1) {
200
-
201
- var mod = (!test && ( (bits >> i) & 1) == 1);
184
+ var mod = !test && ((bits >> i) & 1) == 1;
202
185
 
203
186
  if (i < 8) {
204
187
  _modules[8][_moduleCount - i - 1] = mod;
@@ -210,11 +193,10 @@ var qrcode = function() {
210
193
  }
211
194
 
212
195
  // fixed module
213
- _modules[_moduleCount - 8][8] = (!test);
196
+ _modules[_moduleCount - 8][8] = !test;
214
197
  };
215
198
 
216
- var mapData = function(data, maskPattern) {
217
-
199
+ var mapData = function (data, maskPattern) {
218
200
  var inc = -1;
219
201
  var row = _moduleCount - 1;
220
202
  var bitIndex = 7;
@@ -222,19 +204,15 @@ var qrcode = function() {
222
204
  var maskFunc = QRUtil.getMaskFunction(maskPattern);
223
205
 
224
206
  for (var col = _moduleCount - 1; col > 0; col -= 2) {
225
-
226
207
  if (col == 6) col -= 1;
227
208
 
228
209
  while (true) {
229
-
230
210
  for (var c = 0; c < 2; c += 1) {
231
-
232
211
  if (_modules[row][col - c] == null) {
233
-
234
212
  var dark = false;
235
213
 
236
214
  if (byteIndex < data.length) {
237
- dark = ( ( (data[byteIndex] >>> bitIndex) & 1) == 1);
215
+ dark = ((data[byteIndex] >>> bitIndex) & 1) == 1;
238
216
  }
239
217
 
240
218
  var mask = maskFunc(row, col - c);
@@ -264,8 +242,7 @@ var qrcode = function() {
264
242
  }
265
243
  };
266
244
 
267
- var createBytes = function(buffer, rsBlocks) {
268
-
245
+ var createBytes = function (buffer, rsBlocks) {
269
246
  var offset = 0;
270
247
 
271
248
  var maxDcCount = 0;
@@ -275,7 +252,6 @@ var qrcode = function() {
275
252
  var ecdata = new Array(rsBlocks.length);
276
253
 
277
254
  for (var r = 0; r < rsBlocks.length; r += 1) {
278
-
279
255
  var dcCount = rsBlocks[r].dataCount;
280
256
  var ecCount = rsBlocks[r].totalCount - dcCount;
281
257
 
@@ -296,7 +272,7 @@ var qrcode = function() {
296
272
  ecdata[r] = new Array(rsPoly.getLength() - 1);
297
273
  for (var i = 0; i < ecdata[r].length; i += 1) {
298
274
  var modIndex = i + modPoly.getLength() - ecdata[r].length;
299
- ecdata[r][i] = (modIndex >= 0)? modPoly.getAt(modIndex) : 0;
275
+ ecdata[r][i] = modIndex >= 0 ? modPoly.getAt(modIndex) : 0;
300
276
  }
301
277
  }
302
278
 
@@ -329,8 +305,7 @@ var qrcode = function() {
329
305
  return data;
330
306
  };
331
307
 
332
- var createData = function(typeNumber, errorCorrectionLevel, dataList) {
333
-
308
+ var createData = function (typeNumber, errorCorrectionLevel, dataList) {
334
309
  var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectionLevel);
335
310
 
336
311
  var buffer = qrBitBuffer();
@@ -338,7 +313,7 @@ var qrcode = function() {
338
313
  for (var i = 0; i < dataList.length; i += 1) {
339
314
  var data = dataList[i];
340
315
  buffer.put(data.getMode(), 4);
341
- buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber) );
316
+ buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber));
342
317
  data.write(buffer);
343
318
  }
344
319
 
@@ -349,11 +324,7 @@ var qrcode = function() {
349
324
  }
350
325
 
351
326
  if (buffer.getLengthInBits() > totalDataCount * 8) {
352
- throw 'code length overflow. ('
353
- + buffer.getLengthInBits()
354
- + '>'
355
- + totalDataCount * 8
356
- + ')';
327
+ throw "code length overflow. (" + buffer.getLengthInBits() + ">" + totalDataCount * 8 + ")";
357
328
  }
358
329
 
359
330
  // end code
@@ -368,7 +339,6 @@ var qrcode = function() {
368
339
 
369
340
  // padding
370
341
  while (true) {
371
-
372
342
  if (buffer.getLengthInBits() >= totalDataCount * 8) {
373
343
  break;
374
344
  }
@@ -383,45 +353,44 @@ var qrcode = function() {
383
353
  return createBytes(buffer, rsBlocks);
384
354
  };
385
355
 
386
- _this.addData = function(data, mode) {
387
-
388
- mode = mode || 'Byte';
356
+ _this.addData = function (data, mode) {
357
+ mode = mode || "Byte";
389
358
 
390
359
  var newData = null;
391
360
 
392
- switch(mode) {
393
- case 'Numeric' :
394
- newData = qrNumber(data);
395
- break;
396
- case 'Alphanumeric' :
397
- newData = qrAlphaNum(data);
398
- break;
399
- case 'Byte' :
400
- newData = qr8BitByte(data);
401
- break;
402
- case 'Kanji' :
403
- newData = qrKanji(data);
404
- break;
405
- default :
406
- throw 'mode:' + mode;
361
+ switch (mode) {
362
+ case "Numeric":
363
+ newData = qrNumber(data);
364
+ break;
365
+ case "Alphanumeric":
366
+ newData = qrAlphaNum(data);
367
+ break;
368
+ case "Byte":
369
+ newData = qr8BitByte(data);
370
+ break;
371
+ case "Kanji":
372
+ newData = qrKanji(data);
373
+ break;
374
+ default:
375
+ throw "mode:" + mode;
407
376
  }
408
377
 
409
378
  _dataList.push(newData);
410
379
  _dataCache = null;
411
380
  };
412
381
 
413
- _this.isDark = function(row, col) {
382
+ _this.isDark = function (row, col) {
414
383
  if (row < 0 || _moduleCount <= row || col < 0 || _moduleCount <= col) {
415
- throw row + ',' + col;
384
+ throw row + "," + col;
416
385
  }
417
386
  return _modules[row][col];
418
387
  };
419
388
 
420
- _this.getModuleCount = function() {
389
+ _this.getModuleCount = function () {
421
390
  return _moduleCount;
422
391
  };
423
392
 
424
- _this.make = function() {
393
+ _this.make = function () {
425
394
  if (_typeNumber < 1) {
426
395
  var typeNumber = 1;
427
396
 
@@ -432,7 +401,7 @@ var qrcode = function() {
432
401
  for (var i = 0; i < _dataList.length; i++) {
433
402
  var data = _dataList[i];
434
403
  buffer.put(data.getMode(), 4);
435
- buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber) );
404
+ buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber));
436
405
  data.write(buffer);
437
406
  }
438
407
 
@@ -449,53 +418,50 @@ var qrcode = function() {
449
418
  _typeNumber = typeNumber;
450
419
  }
451
420
 
452
- makeImpl(false, getBestMaskPattern() );
421
+ makeImpl(false, getBestMaskPattern());
453
422
  };
454
423
 
455
- _this.createTableTag = function(cellSize, margin) {
456
-
424
+ _this.createTableTag = function (cellSize, margin) {
457
425
  cellSize = cellSize || 2;
458
- margin = (typeof margin == 'undefined')? cellSize * 4 : margin;
426
+ margin = typeof margin == "undefined" ? cellSize * 4 : margin;
459
427
 
460
- var qrHtml = '';
428
+ var qrHtml = "";
461
429
 
462
430
  qrHtml += '<table style="';
463
- qrHtml += ' border-width: 0px; border-style: none;';
464
- qrHtml += ' border-collapse: collapse;';
465
- qrHtml += ' padding: 0px; margin: ' + margin + 'px;';
431
+ qrHtml += " border-width: 0px; border-style: none;";
432
+ qrHtml += " border-collapse: collapse;";
433
+ qrHtml += " padding: 0px; margin: " + margin + "px;";
466
434
  qrHtml += '">';
467
- qrHtml += '<tbody>';
435
+ qrHtml += "<tbody>";
468
436
 
469
437
  for (var r = 0; r < _this.getModuleCount(); r += 1) {
470
-
471
- qrHtml += '<tr>';
438
+ qrHtml += "<tr>";
472
439
 
473
440
  for (var c = 0; c < _this.getModuleCount(); c += 1) {
474
441
  qrHtml += '<td style="';
475
- qrHtml += ' border-width: 0px; border-style: none;';
476
- qrHtml += ' border-collapse: collapse;';
477
- qrHtml += ' padding: 0px; margin: 0px;';
478
- qrHtml += ' width: ' + cellSize + 'px;';
479
- qrHtml += ' height: ' + cellSize + 'px;';
480
- qrHtml += ' background-color: ';
481
- qrHtml += _this.isDark(r, c)? '#000000' : '#ffffff';
482
- qrHtml += ';';
442
+ qrHtml += " border-width: 0px; border-style: none;";
443
+ qrHtml += " border-collapse: collapse;";
444
+ qrHtml += " padding: 0px; margin: 0px;";
445
+ qrHtml += " width: " + cellSize + "px;";
446
+ qrHtml += " height: " + cellSize + "px;";
447
+ qrHtml += " background-color: ";
448
+ qrHtml += _this.isDark(r, c) ? "#000000" : "#ffffff";
449
+ qrHtml += ";";
483
450
  qrHtml += '"/>';
484
451
  }
485
452
 
486
- qrHtml += '</tr>';
453
+ qrHtml += "</tr>";
487
454
  }
488
455
 
489
- qrHtml += '</tbody>';
490
- qrHtml += '</table>';
456
+ qrHtml += "</tbody>";
457
+ qrHtml += "</table>";
491
458
 
492
459
  return qrHtml;
493
460
  };
494
461
 
495
- _this.createSvgTag = function(cellSize, margin, alt, title) {
496
-
462
+ _this.createSvgTag = function (cellSize, margin, alt, title) {
497
463
  var opts = {};
498
- if (typeof arguments[0] == 'object') {
464
+ if (typeof arguments[0] == "object") {
499
465
  // Called by options.
500
466
  opts = arguments[0];
501
467
  // overwrite cellSize and margin.
@@ -506,83 +472,89 @@ var qrcode = function() {
506
472
  }
507
473
 
508
474
  cellSize = cellSize || 2;
509
- margin = (typeof margin == 'undefined')? cellSize * 4 : margin;
475
+ margin = typeof margin == "undefined" ? cellSize * 4 : margin;
510
476
 
511
477
  // Compose alt property surrogate
512
- alt = (typeof alt === 'string') ? {text: alt} : alt || {};
478
+ alt = typeof alt === "string" ? { text: alt } : alt || {};
513
479
  alt.text = alt.text || null;
514
- alt.id = (alt.text) ? alt.id || 'qrcode-description' : null;
480
+ alt.id = alt.text ? alt.id || "qrcode-description" : null;
515
481
 
516
482
  // Compose title property surrogate
517
- title = (typeof title === 'string') ? {text: title} : title || {};
483
+ title = typeof title === "string" ? { text: title } : title || {};
518
484
  title.text = title.text || null;
519
- title.id = (title.text) ? title.id || 'qrcode-title' : null;
485
+ title.id = title.text ? title.id || "qrcode-title" : null;
520
486
 
521
487
  var size = _this.getModuleCount() * cellSize + margin * 2;
522
- var c, mc, r, mr, qrSvg='', rect;
488
+ var c,
489
+ mc,
490
+ r,
491
+ mr,
492
+ qrSvg = "",
493
+ rect;
523
494
 
524
- rect = 'l' + cellSize + ',0 0,' + cellSize +
525
- ' -' + cellSize + ',0 0,-' + cellSize + 'z ';
495
+ rect = "l" + cellSize + ",0 0," + cellSize + " -" + cellSize + ",0 0,-" + cellSize + "z ";
526
496
 
527
497
  qrSvg += '<svg version="1.1" xmlns="http://www.w3.org/2000/svg"';
528
- qrSvg += !opts.scalable ? ' width="' + size + 'px" height="' + size + 'px"' : '';
529
- qrSvg += ' viewBox="0 0 ' + size + ' ' + size + '" ';
498
+ qrSvg += !opts.scalable ? ' width="' + size + 'px" height="' + size + 'px"' : "";
499
+ qrSvg += ' viewBox="0 0 ' + size + " " + size + '" ';
530
500
  qrSvg += ' preserveAspectRatio="xMinYMin meet"';
531
- qrSvg += (title.text || alt.text) ? ' role="img" aria-labelledby="' +
532
- escapeXml([title.id, alt.id].join(' ').trim() ) + '"' : '';
533
- qrSvg += '>';
534
- qrSvg += (title.text) ? '<title id="' + escapeXml(title.id) + '">' +
535
- escapeXml(title.text) + '</title>' : '';
536
- qrSvg += (alt.text) ? '<description id="' + escapeXml(alt.id) + '">' +
537
- escapeXml(alt.text) + '</description>' : '';
501
+ qrSvg +=
502
+ title.text || alt.text
503
+ ? ' role="img" aria-labelledby="' + escapeXml([title.id, alt.id].join(" ").trim()) + '"'
504
+ : "";
505
+ qrSvg += ">";
506
+ qrSvg += title.text
507
+ ? '<title id="' + escapeXml(title.id) + '">' + escapeXml(title.text) + "</title>"
508
+ : "";
509
+ qrSvg += alt.text
510
+ ? '<description id="' + escapeXml(alt.id) + '">' + escapeXml(alt.text) + "</description>"
511
+ : "";
538
512
  qrSvg += '<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>';
539
513
  qrSvg += '<path d="';
540
514
 
541
515
  for (r = 0; r < _this.getModuleCount(); r += 1) {
542
516
  mr = r * cellSize + margin;
543
517
  for (c = 0; c < _this.getModuleCount(); c += 1) {
544
- if (_this.isDark(r, c) ) {
545
- mc = c*cellSize+margin;
546
- qrSvg += 'M' + mc + ',' + mr + rect;
518
+ if (_this.isDark(r, c)) {
519
+ mc = c * cellSize + margin;
520
+ qrSvg += "M" + mc + "," + mr + rect;
547
521
  }
548
522
  }
549
523
  }
550
524
 
551
525
  qrSvg += '" stroke="transparent" fill="black"/>';
552
- qrSvg += '</svg>';
526
+ qrSvg += "</svg>";
553
527
 
554
528
  return qrSvg;
555
529
  };
556
530
 
557
- _this.createDataURL = function(cellSize, margin) {
558
-
531
+ _this.createDataURL = function (cellSize, margin) {
559
532
  cellSize = cellSize || 2;
560
- margin = (typeof margin == 'undefined')? cellSize * 4 : margin;
533
+ margin = typeof margin == "undefined" ? cellSize * 4 : margin;
561
534
 
562
535
  var size = _this.getModuleCount() * cellSize + margin * 2;
563
536
  var min = margin;
564
537
  var max = size - margin;
565
538
 
566
- return createDataURL(size, size, function(x, y) {
539
+ return createDataURL(size, size, function (x, y) {
567
540
  if (min <= x && x < max && min <= y && y < max) {
568
- var c = Math.floor( (x - min) / cellSize);
569
- var r = Math.floor( (y - min) / cellSize);
570
- return _this.isDark(r, c)? 0 : 1;
541
+ var c = Math.floor((x - min) / cellSize);
542
+ var r = Math.floor((y - min) / cellSize);
543
+ return _this.isDark(r, c) ? 0 : 1;
571
544
  } else {
572
545
  return 1;
573
546
  }
574
- } );
547
+ });
575
548
  };
576
549
 
577
- _this.createImgTag = function(cellSize, margin, alt) {
578
-
550
+ _this.createImgTag = function (cellSize, margin, alt) {
579
551
  cellSize = cellSize || 2;
580
- margin = (typeof margin == 'undefined')? cellSize * 4 : margin;
552
+ margin = typeof margin == "undefined" ? cellSize * 4 : margin;
581
553
 
582
554
  var size = _this.getModuleCount() * cellSize + margin * 2;
583
555
 
584
- var img = '';
585
- img += '<img';
556
+ var img = "";
557
+ img += "<img";
586
558
  img += '\u0020src="';
587
559
  img += _this.createDataURL(cellSize, margin);
588
560
  img += '"';
@@ -597,29 +569,39 @@ var qrcode = function() {
597
569
  img += escapeXml(alt);
598
570
  img += '"';
599
571
  }
600
- img += '/>';
572
+ img += "/>";
601
573
 
602
574
  return img;
603
575
  };
604
576
 
605
- var escapeXml = function(s) {
606
- var escaped = '';
577
+ var escapeXml = function (s) {
578
+ var escaped = "";
607
579
  for (var i = 0; i < s.length; i += 1) {
608
580
  var c = s.charAt(i);
609
- switch(c) {
610
- case '<': escaped += '&lt;'; break;
611
- case '>': escaped += '&gt;'; break;
612
- case '&': escaped += '&amp;'; break;
613
- case '"': escaped += '&quot;'; break;
614
- default : escaped += c; break;
581
+ switch (c) {
582
+ case "<":
583
+ escaped += "&lt;";
584
+ break;
585
+ case ">":
586
+ escaped += "&gt;";
587
+ break;
588
+ case "&":
589
+ escaped += "&amp;";
590
+ break;
591
+ case '"':
592
+ escaped += "&quot;";
593
+ break;
594
+ default:
595
+ escaped += c;
596
+ break;
615
597
  }
616
598
  }
617
599
  return escaped;
618
600
  };
619
601
 
620
- var _createHalfASCII = function(margin) {
602
+ var _createHalfASCII = function (margin) {
621
603
  var cellSize = 1;
622
- margin = (typeof margin == 'undefined')? cellSize * 2 : margin;
604
+ margin = typeof margin == "undefined" ? cellSize * 2 : margin;
623
605
 
624
606
  var size = _this.getModuleCount() * cellSize + margin * 2;
625
607
  var min = margin;
@@ -628,52 +610,63 @@ var qrcode = function() {
628
610
  var y, x, r1, r2, p;
629
611
 
630
612
  var blocks = {
631
- '██': '',
632
- '': '',
633
- '': '',
634
- ' ': ' '
613
+ "██": "",
614
+ "": "",
615
+ "": "",
616
+ " ": " ",
635
617
  };
636
618
 
637
619
  var blocksLastLineNoMargin = {
638
- '██': '',
639
- '': '',
640
- '': ' ',
641
- ' ': ' '
620
+ "██": "",
621
+ "": "",
622
+ "": " ",
623
+ " ": " ",
642
624
  };
643
625
 
644
- var ascii = '';
626
+ var ascii = "";
645
627
  for (y = 0; y < size; y += 2) {
646
628
  r1 = Math.floor((y - min) / cellSize);
647
629
  r2 = Math.floor((y + 1 - min) / cellSize);
648
630
  for (x = 0; x < size; x += 1) {
649
- p = '';
650
-
651
- if (min <= x && x < max && min <= y && y < max && _this.isDark(r1, Math.floor((x - min) / cellSize))) {
652
- p = ' ';
631
+ p = "";
632
+
633
+ if (
634
+ min <= x &&
635
+ x < max &&
636
+ min <= y &&
637
+ y < max &&
638
+ _this.isDark(r1, Math.floor((x - min) / cellSize))
639
+ ) {
640
+ p = " ";
653
641
  }
654
642
 
655
- if (min <= x && x < max && min <= y+1 && y+1 < max && _this.isDark(r2, Math.floor((x - min) / cellSize))) {
656
- p += ' ';
657
- }
658
- else {
659
- p += '█';
643
+ if (
644
+ min <= x &&
645
+ x < max &&
646
+ min <= y + 1 &&
647
+ y + 1 < max &&
648
+ _this.isDark(r2, Math.floor((x - min) / cellSize))
649
+ ) {
650
+ p += " ";
651
+ } else {
652
+ p += "█";
660
653
  }
661
654
 
662
655
  // Output 2 characters per pixel, to create full square. 1 character per pixels gives only half width of square.
663
- ascii += (margin < 1 && y+1 >= max) ? blocksLastLineNoMargin[p] : blocks[p];
656
+ ascii += margin < 1 && y + 1 >= max ? blocksLastLineNoMargin[p] : blocks[p];
664
657
  }
665
658
 
666
- ascii += '\n';
659
+ ascii += "\n";
667
660
  }
668
661
 
669
662
  if (size % 2 && margin > 0) {
670
- return ascii.substring(0, ascii.length - size - 1) + Array(size+1).join('');
663
+ return ascii.substring(0, ascii.length - size - 1) + Array(size + 1).join("");
671
664
  }
672
665
 
673
- return ascii.substring(0, ascii.length-1);
666
+ return ascii.substring(0, ascii.length - 1);
674
667
  };
675
668
 
676
- _this.createASCII = function(cellSize, margin) {
669
+ _this.createASCII = function (cellSize, margin) {
677
670
  cellSize = cellSize || 1;
678
671
 
679
672
  if (cellSize < 2) {
@@ -681,7 +674,7 @@ var qrcode = function() {
681
674
  }
682
675
 
683
676
  cellSize -= 1;
684
- margin = (typeof margin == 'undefined')? cellSize * 2 : margin;
677
+ margin = typeof margin == "undefined" ? cellSize * 2 : margin;
685
678
 
686
679
  var size = _this.getModuleCount() * cellSize + margin * 2;
687
680
  var min = margin;
@@ -689,18 +682,24 @@ var qrcode = function() {
689
682
 
690
683
  var y, x, r, p;
691
684
 
692
- var white = Array(cellSize+1).join('██');
693
- var black = Array(cellSize+1).join(' ');
685
+ var white = Array(cellSize + 1).join("██");
686
+ var black = Array(cellSize + 1).join(" ");
694
687
 
695
- var ascii = '';
696
- var line = '';
688
+ var ascii = "";
689
+ var line = "";
697
690
  for (y = 0; y < size; y += 1) {
698
- r = Math.floor( (y - min) / cellSize);
699
- line = '';
691
+ r = Math.floor((y - min) / cellSize);
692
+ line = "";
700
693
  for (x = 0; x < size; x += 1) {
701
694
  p = 1;
702
695
 
703
- if (min <= x && x < max && min <= y && y < max && _this.isDark(r, Math.floor((x - min) / cellSize))) {
696
+ if (
697
+ min <= x &&
698
+ x < max &&
699
+ min <= y &&
700
+ y < max &&
701
+ _this.isDark(r, Math.floor((x - min) / cellSize))
702
+ ) {
704
703
  p = 0;
705
704
  }
706
705
 
@@ -709,23 +708,23 @@ var qrcode = function() {
709
708
  }
710
709
 
711
710
  for (r = 0; r < cellSize; r += 1) {
712
- ascii += line + '\n';
711
+ ascii += line + "\n";
713
712
  }
714
713
  }
715
714
 
716
- return ascii.substring(0, ascii.length-1);
715
+ return ascii.substring(0, ascii.length - 1);
717
716
  };
718
717
 
719
- _this.renderTo2dContext = function(context, cellSize) {
718
+ _this.renderTo2dContext = function (context, cellSize) {
720
719
  cellSize = cellSize || 2;
721
720
  var length = _this.getModuleCount();
722
721
  for (var row = 0; row < length; row++) {
723
722
  for (var col = 0; col < length; col++) {
724
- context.fillStyle = _this.isDark(row, col) ? 'black' : 'white';
723
+ context.fillStyle = _this.isDark(row, col) ? "black" : "white";
725
724
  context.fillRect(col * cellSize, row * cellSize, cellSize, cellSize);
726
725
  }
727
726
  }
728
- }
727
+ };
729
728
 
730
729
  return _this;
731
730
  };
@@ -735,17 +734,17 @@ var qrcode = function() {
735
734
  //---------------------------------------------------------------------
736
735
 
737
736
  qrcode.stringToBytesFuncs = {
738
- 'default' : function(s) {
737
+ default: function (s) {
739
738
  var bytes = [];
740
739
  for (var i = 0; i < s.length; i += 1) {
741
740
  var c = s.charCodeAt(i);
742
741
  bytes.push(c & 0xff);
743
742
  }
744
743
  return bytes;
745
- }
744
+ },
746
745
  };
747
746
 
748
- qrcode.stringToBytes = qrcode.stringToBytesFuncs['default'];
747
+ qrcode.stringToBytes = qrcode.stringToBytesFuncs["default"];
749
748
 
750
749
  //---------------------------------------------------------------------
751
750
  // qrcode.createStringToBytes
@@ -756,16 +755,14 @@ var qrcode = function() {
756
755
  * [16bit Unicode],[16bit Bytes], ...
757
756
  * @param numChars
758
757
  */
759
- qrcode.createStringToBytes = function(unicodeData, numChars) {
760
-
758
+ qrcode.createStringToBytes = function (unicodeData, numChars) {
761
759
  // create conversion map.
762
760
 
763
- var unicodeMap = function() {
764
-
761
+ var unicodeMap = (function () {
765
762
  var bin = base64DecodeInputStream(unicodeData);
766
- var read = function() {
763
+ var read = function () {
767
764
  var b = bin.read();
768
- if (b == -1) throw 'eof';
765
+ if (b == -1) throw "eof";
769
766
  return b;
770
767
  };
771
768
 
@@ -777,21 +774,21 @@ var qrcode = function() {
777
774
  var b1 = read();
778
775
  var b2 = read();
779
776
  var b3 = read();
780
- var k = String.fromCharCode( (b0 << 8) | b1);
777
+ var k = String.fromCharCode((b0 << 8) | b1);
781
778
  var v = (b2 << 8) | b3;
782
779
  unicodeMap[k] = v;
783
780
  count += 1;
784
781
  }
785
782
  if (count != numChars) {
786
- throw count + ' != ' + numChars;
783
+ throw count + " != " + numChars;
787
784
  }
788
785
 
789
786
  return unicodeMap;
790
- }();
787
+ })();
791
788
 
792
- var unknownChar = '?'.charCodeAt(0);
789
+ var unknownChar = "?".charCodeAt(0);
793
790
 
794
- return function(s) {
791
+ return function (s) {
795
792
  var bytes = [];
796
793
  for (var i = 0; i < s.length; i += 1) {
797
794
  var c = s.charCodeAt(i);
@@ -799,8 +796,8 @@ var qrcode = function() {
799
796
  bytes.push(c);
800
797
  } else {
801
798
  var b = unicodeMap[s.charAt(i)];
802
- if (typeof b == 'number') {
803
- if ( (b & 0xff) == b) {
799
+ if (typeof b == "number") {
800
+ if ((b & 0xff) == b) {
804
801
  // 1byte
805
802
  bytes.push(b);
806
803
  } else {
@@ -822,10 +819,10 @@ var qrcode = function() {
822
819
  //---------------------------------------------------------------------
823
820
 
824
821
  var QRMode = {
825
- MODE_NUMBER : 1 << 0,
826
- MODE_ALPHA_NUM : 1 << 1,
827
- MODE_8BIT_BYTE : 1 << 2,
828
- MODE_KANJI : 1 << 3
822
+ MODE_NUMBER: 1 << 0,
823
+ MODE_ALPHA_NUM: 1 << 1,
824
+ MODE_8BIT_BYTE: 1 << 2,
825
+ MODE_KANJI: 1 << 3,
829
826
  };
830
827
 
831
828
  //---------------------------------------------------------------------
@@ -833,10 +830,10 @@ var qrcode = function() {
833
830
  //---------------------------------------------------------------------
834
831
 
835
832
  var QRErrorCorrectionLevel = {
836
- L : 1,
837
- M : 0,
838
- Q : 3,
839
- H : 2
833
+ L: 1,
834
+ M: 0,
835
+ Q: 3,
836
+ H: 2,
840
837
  };
841
838
 
842
839
  //---------------------------------------------------------------------
@@ -844,22 +841,21 @@ var qrcode = function() {
844
841
  //---------------------------------------------------------------------
845
842
 
846
843
  var QRMaskPattern = {
847
- PATTERN000 : 0,
848
- PATTERN001 : 1,
849
- PATTERN010 : 2,
850
- PATTERN011 : 3,
851
- PATTERN100 : 4,
852
- PATTERN101 : 5,
853
- PATTERN110 : 6,
854
- PATTERN111 : 7
844
+ PATTERN000: 0,
845
+ PATTERN001: 1,
846
+ PATTERN010: 2,
847
+ PATTERN011: 3,
848
+ PATTERN100: 4,
849
+ PATTERN101: 5,
850
+ PATTERN110: 6,
851
+ PATTERN111: 7,
855
852
  };
856
853
 
857
854
  //---------------------------------------------------------------------
858
855
  // QRUtil
859
856
  //---------------------------------------------------------------------
860
857
 
861
- var QRUtil = function() {
862
-
858
+ var QRUtil = (function () {
863
859
  var PATTERN_POSITION_TABLE = [
864
860
  [],
865
861
  [6, 18],
@@ -900,15 +896,16 @@ var qrcode = function() {
900
896
  [6, 28, 54, 80, 106, 132, 158],
901
897
  [6, 32, 58, 84, 110, 136, 162],
902
898
  [6, 26, 54, 82, 110, 138, 166],
903
- [6, 30, 58, 86, 114, 142, 170]
899
+ [6, 30, 58, 86, 114, 142, 170],
904
900
  ];
905
901
  var G15 = (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0);
906
- var G18 = (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0);
902
+ var G18 =
903
+ (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0);
907
904
  var G15_MASK = (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1);
908
905
 
909
906
  var _this = {};
910
907
 
911
- var getBCHDigit = function(data) {
908
+ var getBCHDigit = function (data) {
912
909
  var digit = 0;
913
910
  while (data != 0) {
914
911
  digit += 1;
@@ -917,108 +914,126 @@ var qrcode = function() {
917
914
  return digit;
918
915
  };
919
916
 
920
- _this.getBCHTypeInfo = function(data) {
917
+ _this.getBCHTypeInfo = function (data) {
921
918
  var d = data << 10;
922
919
  while (getBCHDigit(d) - getBCHDigit(G15) >= 0) {
923
- d ^= (G15 << (getBCHDigit(d) - getBCHDigit(G15) ) );
920
+ d ^= G15 << (getBCHDigit(d) - getBCHDigit(G15));
924
921
  }
925
- return ( (data << 10) | d) ^ G15_MASK;
922
+ return ((data << 10) | d) ^ G15_MASK;
926
923
  };
927
924
 
928
- _this.getBCHTypeNumber = function(data) {
925
+ _this.getBCHTypeNumber = function (data) {
929
926
  var d = data << 12;
930
927
  while (getBCHDigit(d) - getBCHDigit(G18) >= 0) {
931
- d ^= (G18 << (getBCHDigit(d) - getBCHDigit(G18) ) );
928
+ d ^= G18 << (getBCHDigit(d) - getBCHDigit(G18));
932
929
  }
933
930
  return (data << 12) | d;
934
931
  };
935
932
 
936
- _this.getPatternPosition = function(typeNumber) {
933
+ _this.getPatternPosition = function (typeNumber) {
937
934
  return PATTERN_POSITION_TABLE[typeNumber - 1];
938
935
  };
939
936
 
940
- _this.getMaskFunction = function(maskPattern) {
941
-
937
+ _this.getMaskFunction = function (maskPattern) {
942
938
  switch (maskPattern) {
943
-
944
- case QRMaskPattern.PATTERN000 :
945
- return function(i, j) { return (i + j) % 2 == 0; };
946
- case QRMaskPattern.PATTERN001 :
947
- return function(i, j) { return i % 2 == 0; };
948
- case QRMaskPattern.PATTERN010 :
949
- return function(i, j) { return j % 3 == 0; };
950
- case QRMaskPattern.PATTERN011 :
951
- return function(i, j) { return (i + j) % 3 == 0; };
952
- case QRMaskPattern.PATTERN100 :
953
- return function(i, j) { return (Math.floor(i / 2) + Math.floor(j / 3) ) % 2 == 0; };
954
- case QRMaskPattern.PATTERN101 :
955
- return function(i, j) { return (i * j) % 2 + (i * j) % 3 == 0; };
956
- case QRMaskPattern.PATTERN110 :
957
- return function(i, j) { return ( (i * j) % 2 + (i * j) % 3) % 2 == 0; };
958
- case QRMaskPattern.PATTERN111 :
959
- return function(i, j) { return ( (i * j) % 3 + (i + j) % 2) % 2 == 0; };
960
-
961
- default :
962
- throw 'bad maskPattern:' + maskPattern;
963
- }
964
- };
965
-
966
- _this.getErrorCorrectPolynomial = function(errorCorrectLength) {
939
+ case QRMaskPattern.PATTERN000:
940
+ return function (i, j) {
941
+ return (i + j) % 2 == 0;
942
+ };
943
+ case QRMaskPattern.PATTERN001:
944
+ return function (i, j) {
945
+ return i % 2 == 0;
946
+ };
947
+ case QRMaskPattern.PATTERN010:
948
+ return function (i, j) {
949
+ return j % 3 == 0;
950
+ };
951
+ case QRMaskPattern.PATTERN011:
952
+ return function (i, j) {
953
+ return (i + j) % 3 == 0;
954
+ };
955
+ case QRMaskPattern.PATTERN100:
956
+ return function (i, j) {
957
+ return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 == 0;
958
+ };
959
+ case QRMaskPattern.PATTERN101:
960
+ return function (i, j) {
961
+ return ((i * j) % 2) + ((i * j) % 3) == 0;
962
+ };
963
+ case QRMaskPattern.PATTERN110:
964
+ return function (i, j) {
965
+ return (((i * j) % 2) + ((i * j) % 3)) % 2 == 0;
966
+ };
967
+ case QRMaskPattern.PATTERN111:
968
+ return function (i, j) {
969
+ return (((i * j) % 3) + ((i + j) % 2)) % 2 == 0;
970
+ };
971
+
972
+ default:
973
+ throw "bad maskPattern:" + maskPattern;
974
+ }
975
+ };
976
+
977
+ _this.getErrorCorrectPolynomial = function (errorCorrectLength) {
967
978
  var a = qrPolynomial([1], 0);
968
979
  for (var i = 0; i < errorCorrectLength; i += 1) {
969
- a = a.multiply(qrPolynomial([1, QRMath.gexp(i)], 0) );
980
+ a = a.multiply(qrPolynomial([1, QRMath.gexp(i)], 0));
970
981
  }
971
982
  return a;
972
983
  };
973
984
 
974
- _this.getLengthInBits = function(mode, type) {
975
-
985
+ _this.getLengthInBits = function (mode, type) {
976
986
  if (1 <= type && type < 10) {
977
-
978
987
  // 1 - 9
979
988
 
980
- switch(mode) {
981
- case QRMode.MODE_NUMBER : return 10;
982
- case QRMode.MODE_ALPHA_NUM : return 9;
983
- case QRMode.MODE_8BIT_BYTE : return 8;
984
- case QRMode.MODE_KANJI : return 8;
985
- default :
986
- throw 'mode:' + mode;
989
+ switch (mode) {
990
+ case QRMode.MODE_NUMBER:
991
+ return 10;
992
+ case QRMode.MODE_ALPHA_NUM:
993
+ return 9;
994
+ case QRMode.MODE_8BIT_BYTE:
995
+ return 8;
996
+ case QRMode.MODE_KANJI:
997
+ return 8;
998
+ default:
999
+ throw "mode:" + mode;
987
1000
  }
988
-
989
1001
  } else if (type < 27) {
990
-
991
1002
  // 10 - 26
992
1003
 
993
- switch(mode) {
994
- case QRMode.MODE_NUMBER : return 12;
995
- case QRMode.MODE_ALPHA_NUM : return 11;
996
- case QRMode.MODE_8BIT_BYTE : return 16;
997
- case QRMode.MODE_KANJI : return 10;
998
- default :
999
- throw 'mode:' + mode;
1004
+ switch (mode) {
1005
+ case QRMode.MODE_NUMBER:
1006
+ return 12;
1007
+ case QRMode.MODE_ALPHA_NUM:
1008
+ return 11;
1009
+ case QRMode.MODE_8BIT_BYTE:
1010
+ return 16;
1011
+ case QRMode.MODE_KANJI:
1012
+ return 10;
1013
+ default:
1014
+ throw "mode:" + mode;
1000
1015
  }
1001
-
1002
1016
  } else if (type < 41) {
1003
-
1004
1017
  // 27 - 40
1005
1018
 
1006
- switch(mode) {
1007
- case QRMode.MODE_NUMBER : return 14;
1008
- case QRMode.MODE_ALPHA_NUM : return 13;
1009
- case QRMode.MODE_8BIT_BYTE : return 16;
1010
- case QRMode.MODE_KANJI : return 12;
1011
- default :
1012
- throw 'mode:' + mode;
1019
+ switch (mode) {
1020
+ case QRMode.MODE_NUMBER:
1021
+ return 14;
1022
+ case QRMode.MODE_ALPHA_NUM:
1023
+ return 13;
1024
+ case QRMode.MODE_8BIT_BYTE:
1025
+ return 16;
1026
+ case QRMode.MODE_KANJI:
1027
+ return 12;
1028
+ default:
1029
+ throw "mode:" + mode;
1013
1030
  }
1014
-
1015
1031
  } else {
1016
- throw 'type:' + type;
1032
+ throw "type:" + type;
1017
1033
  }
1018
1034
  };
1019
1035
 
1020
- _this.getLostPoint = function(qrcode) {
1021
-
1036
+ _this.getLostPoint = function (qrcode) {
1022
1037
  var moduleCount = qrcode.getModuleCount();
1023
1038
 
1024
1039
  var lostPoint = 0;
@@ -1027,18 +1042,15 @@ var qrcode = function() {
1027
1042
 
1028
1043
  for (var row = 0; row < moduleCount; row += 1) {
1029
1044
  for (var col = 0; col < moduleCount; col += 1) {
1030
-
1031
1045
  var sameCount = 0;
1032
1046
  var dark = qrcode.isDark(row, col);
1033
1047
 
1034
1048
  for (var r = -1; r <= 1; r += 1) {
1035
-
1036
1049
  if (row + r < 0 || moduleCount <= row + r) {
1037
1050
  continue;
1038
1051
  }
1039
1052
 
1040
1053
  for (var c = -1; c <= 1; c += 1) {
1041
-
1042
1054
  if (col + c < 0 || moduleCount <= col + c) {
1043
1055
  continue;
1044
1056
  }
@@ -1047,27 +1059,27 @@ var qrcode = function() {
1047
1059
  continue;
1048
1060
  }
1049
1061
 
1050
- if (dark == qrcode.isDark(row + r, col + c) ) {
1062
+ if (dark == qrcode.isDark(row + r, col + c)) {
1051
1063
  sameCount += 1;
1052
1064
  }
1053
1065
  }
1054
1066
  }
1055
1067
 
1056
1068
  if (sameCount > 5) {
1057
- lostPoint += (3 + sameCount - 5);
1069
+ lostPoint += 3 + sameCount - 5;
1058
1070
  }
1059
1071
  }
1060
- };
1072
+ }
1061
1073
 
1062
1074
  // LEVEL2
1063
1075
 
1064
1076
  for (var row = 0; row < moduleCount - 1; row += 1) {
1065
1077
  for (var col = 0; col < moduleCount - 1; col += 1) {
1066
1078
  var count = 0;
1067
- if (qrcode.isDark(row, col) ) count += 1;
1068
- if (qrcode.isDark(row + 1, col) ) count += 1;
1069
- if (qrcode.isDark(row, col + 1) ) count += 1;
1070
- if (qrcode.isDark(row + 1, col + 1) ) count += 1;
1079
+ if (qrcode.isDark(row, col)) count += 1;
1080
+ if (qrcode.isDark(row + 1, col)) count += 1;
1081
+ if (qrcode.isDark(row, col + 1)) count += 1;
1082
+ if (qrcode.isDark(row + 1, col + 1)) count += 1;
1071
1083
  if (count == 0 || count == 4) {
1072
1084
  lostPoint += 3;
1073
1085
  }
@@ -1078,13 +1090,15 @@ var qrcode = function() {
1078
1090
 
1079
1091
  for (var row = 0; row < moduleCount; row += 1) {
1080
1092
  for (var col = 0; col < moduleCount - 6; col += 1) {
1081
- if (qrcode.isDark(row, col)
1082
- && !qrcode.isDark(row, col + 1)
1083
- && qrcode.isDark(row, col + 2)
1084
- && qrcode.isDark(row, col + 3)
1085
- && qrcode.isDark(row, col + 4)
1086
- && !qrcode.isDark(row, col + 5)
1087
- && qrcode.isDark(row, col + 6) ) {
1093
+ if (
1094
+ qrcode.isDark(row, col) &&
1095
+ !qrcode.isDark(row, col + 1) &&
1096
+ qrcode.isDark(row, col + 2) &&
1097
+ qrcode.isDark(row, col + 3) &&
1098
+ qrcode.isDark(row, col + 4) &&
1099
+ !qrcode.isDark(row, col + 5) &&
1100
+ qrcode.isDark(row, col + 6)
1101
+ ) {
1088
1102
  lostPoint += 40;
1089
1103
  }
1090
1104
  }
@@ -1092,13 +1106,15 @@ var qrcode = function() {
1092
1106
 
1093
1107
  for (var col = 0; col < moduleCount; col += 1) {
1094
1108
  for (var row = 0; row < moduleCount - 6; row += 1) {
1095
- if (qrcode.isDark(row, col)
1096
- && !qrcode.isDark(row + 1, col)
1097
- && qrcode.isDark(row + 2, col)
1098
- && qrcode.isDark(row + 3, col)
1099
- && qrcode.isDark(row + 4, col)
1100
- && !qrcode.isDark(row + 5, col)
1101
- && qrcode.isDark(row + 6, col) ) {
1109
+ if (
1110
+ qrcode.isDark(row, col) &&
1111
+ !qrcode.isDark(row + 1, col) &&
1112
+ qrcode.isDark(row + 2, col) &&
1113
+ qrcode.isDark(row + 3, col) &&
1114
+ qrcode.isDark(row + 4, col) &&
1115
+ !qrcode.isDark(row + 5, col) &&
1116
+ qrcode.isDark(row + 6, col)
1117
+ ) {
1102
1118
  lostPoint += 40;
1103
1119
  }
1104
1120
  }
@@ -1110,27 +1126,26 @@ var qrcode = function() {
1110
1126
 
1111
1127
  for (var col = 0; col < moduleCount; col += 1) {
1112
1128
  for (var row = 0; row < moduleCount; row += 1) {
1113
- if (qrcode.isDark(row, col) ) {
1129
+ if (qrcode.isDark(row, col)) {
1114
1130
  darkCount += 1;
1115
1131
  }
1116
1132
  }
1117
1133
  }
1118
1134
 
1119
- var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
1135
+ var ratio = Math.abs((100 * darkCount) / moduleCount / moduleCount - 50) / 5;
1120
1136
  lostPoint += ratio * 10;
1121
1137
 
1122
1138
  return lostPoint;
1123
1139
  };
1124
1140
 
1125
1141
  return _this;
1126
- }();
1142
+ })();
1127
1143
 
1128
1144
  //---------------------------------------------------------------------
1129
1145
  // QRMath
1130
1146
  //---------------------------------------------------------------------
1131
1147
 
1132
- var QRMath = function() {
1133
-
1148
+ var QRMath = (function () {
1134
1149
  var EXP_TABLE = new Array(256);
1135
1150
  var LOG_TABLE = new Array(256);
1136
1151
 
@@ -1139,28 +1154,23 @@ var qrcode = function() {
1139
1154
  EXP_TABLE[i] = 1 << i;
1140
1155
  }
1141
1156
  for (var i = 8; i < 256; i += 1) {
1142
- EXP_TABLE[i] = EXP_TABLE[i - 4]
1143
- ^ EXP_TABLE[i - 5]
1144
- ^ EXP_TABLE[i - 6]
1145
- ^ EXP_TABLE[i - 8];
1157
+ EXP_TABLE[i] = EXP_TABLE[i - 4] ^ EXP_TABLE[i - 5] ^ EXP_TABLE[i - 6] ^ EXP_TABLE[i - 8];
1146
1158
  }
1147
1159
  for (var i = 0; i < 255; i += 1) {
1148
- LOG_TABLE[EXP_TABLE[i] ] = i;
1160
+ LOG_TABLE[EXP_TABLE[i]] = i;
1149
1161
  }
1150
1162
 
1151
1163
  var _this = {};
1152
1164
 
1153
- _this.glog = function(n) {
1154
-
1165
+ _this.glog = function (n) {
1155
1166
  if (n < 1) {
1156
- throw 'glog(' + n + ')';
1167
+ throw "glog(" + n + ")";
1157
1168
  }
1158
1169
 
1159
1170
  return LOG_TABLE[n];
1160
1171
  };
1161
1172
 
1162
- _this.gexp = function(n) {
1163
-
1173
+ _this.gexp = function (n) {
1164
1174
  while (n < 0) {
1165
1175
  n += 255;
1166
1176
  }
@@ -1173,19 +1183,18 @@ var qrcode = function() {
1173
1183
  };
1174
1184
 
1175
1185
  return _this;
1176
- }();
1186
+ })();
1177
1187
 
1178
1188
  //---------------------------------------------------------------------
1179
1189
  // qrPolynomial
1180
1190
  //---------------------------------------------------------------------
1181
1191
 
1182
1192
  function qrPolynomial(num, shift) {
1183
-
1184
- if (typeof num.length == 'undefined') {
1185
- throw num.length + '/' + shift;
1193
+ if (typeof num.length == "undefined") {
1194
+ throw num.length + "/" + shift;
1186
1195
  }
1187
1196
 
1188
- var _num = function() {
1197
+ var _num = (function () {
1189
1198
  var offset = 0;
1190
1199
  while (offset < num.length && num[offset] == 0) {
1191
1200
  offset += 1;
@@ -1195,46 +1204,44 @@ var qrcode = function() {
1195
1204
  _num[i] = num[i + offset];
1196
1205
  }
1197
1206
  return _num;
1198
- }();
1207
+ })();
1199
1208
 
1200
1209
  var _this = {};
1201
1210
 
1202
- _this.getAt = function(index) {
1211
+ _this.getAt = function (index) {
1203
1212
  return _num[index];
1204
1213
  };
1205
1214
 
1206
- _this.getLength = function() {
1215
+ _this.getLength = function () {
1207
1216
  return _num.length;
1208
1217
  };
1209
1218
 
1210
- _this.multiply = function(e) {
1211
-
1219
+ _this.multiply = function (e) {
1212
1220
  var num = new Array(_this.getLength() + e.getLength() - 1);
1213
1221
 
1214
1222
  for (var i = 0; i < _this.getLength(); i += 1) {
1215
1223
  for (var j = 0; j < e.getLength(); j += 1) {
1216
- num[i + j] ^= QRMath.gexp(QRMath.glog(_this.getAt(i) ) + QRMath.glog(e.getAt(j) ) );
1224
+ num[i + j] ^= QRMath.gexp(QRMath.glog(_this.getAt(i)) + QRMath.glog(e.getAt(j)));
1217
1225
  }
1218
1226
  }
1219
1227
 
1220
1228
  return qrPolynomial(num, 0);
1221
1229
  };
1222
1230
 
1223
- _this.mod = function(e) {
1224
-
1231
+ _this.mod = function (e) {
1225
1232
  if (_this.getLength() - e.getLength() < 0) {
1226
1233
  return _this;
1227
1234
  }
1228
1235
 
1229
- var ratio = QRMath.glog(_this.getAt(0) ) - QRMath.glog(e.getAt(0) );
1236
+ var ratio = QRMath.glog(_this.getAt(0)) - QRMath.glog(e.getAt(0));
1230
1237
 
1231
- var num = new Array(_this.getLength() );
1238
+ var num = new Array(_this.getLength());
1232
1239
  for (var i = 0; i < _this.getLength(); i += 1) {
1233
1240
  num[i] = _this.getAt(i);
1234
1241
  }
1235
1242
 
1236
1243
  for (var i = 0; i < e.getLength(); i += 1) {
1237
- num[i] ^= QRMath.gexp(QRMath.glog(e.getAt(i) ) + ratio);
1244
+ num[i] ^= QRMath.gexp(QRMath.glog(e.getAt(i)) + ratio);
1238
1245
  }
1239
1246
 
1240
1247
  // recursive call
@@ -1242,16 +1249,14 @@ var qrcode = function() {
1242
1249
  };
1243
1250
 
1244
1251
  return _this;
1245
- };
1252
+ }
1246
1253
 
1247
1254
  //---------------------------------------------------------------------
1248
1255
  // QRRSBlock
1249
1256
  //---------------------------------------------------------------------
1250
1257
 
1251
- var QRRSBlock = function() {
1252
-
1258
+ var QRRSBlock = (function () {
1253
1259
  var RS_BLOCK_TABLE = [
1254
-
1255
1260
  // L
1256
1261
  // M
1257
1262
  // Q
@@ -1495,10 +1500,10 @@ var qrcode = function() {
1495
1500
  [19, 148, 118, 6, 149, 119],
1496
1501
  [18, 75, 47, 31, 76, 48],
1497
1502
  [34, 54, 24, 34, 55, 25],
1498
- [20, 45, 15, 61, 46, 16]
1503
+ [20, 45, 15, 61, 46, 16],
1499
1504
  ];
1500
1505
 
1501
- var qrRSBlock = function(totalCount, dataCount) {
1506
+ var qrRSBlock = function (totalCount, dataCount) {
1502
1507
  var _this = {};
1503
1508
  _this.totalCount = totalCount;
1504
1509
  _this.dataCount = dataCount;
@@ -1507,29 +1512,31 @@ var qrcode = function() {
1507
1512
 
1508
1513
  var _this = {};
1509
1514
 
1510
- var getRsBlockTable = function(typeNumber, errorCorrectionLevel) {
1511
-
1512
- switch(errorCorrectionLevel) {
1513
- case QRErrorCorrectionLevel.L :
1514
- return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
1515
- case QRErrorCorrectionLevel.M :
1516
- return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
1517
- case QRErrorCorrectionLevel.Q :
1518
- return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
1519
- case QRErrorCorrectionLevel.H :
1520
- return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
1521
- default :
1522
- return undefined;
1515
+ var getRsBlockTable = function (typeNumber, errorCorrectionLevel) {
1516
+ switch (errorCorrectionLevel) {
1517
+ case QRErrorCorrectionLevel.L:
1518
+ return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
1519
+ case QRErrorCorrectionLevel.M:
1520
+ return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
1521
+ case QRErrorCorrectionLevel.Q:
1522
+ return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
1523
+ case QRErrorCorrectionLevel.H:
1524
+ return RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
1525
+ default:
1526
+ return undefined;
1523
1527
  }
1524
1528
  };
1525
1529
 
1526
- _this.getRSBlocks = function(typeNumber, errorCorrectionLevel) {
1527
-
1530
+ _this.getRSBlocks = function (typeNumber, errorCorrectionLevel) {
1528
1531
  var rsBlock = getRsBlockTable(typeNumber, errorCorrectionLevel);
1529
1532
 
1530
- if (typeof rsBlock == 'undefined') {
1531
- throw 'bad rs block @ typeNumber:' + typeNumber +
1532
- '/errorCorrectionLevel:' + errorCorrectionLevel;
1533
+ if (typeof rsBlock == "undefined") {
1534
+ throw (
1535
+ "bad rs block @ typeNumber:" +
1536
+ typeNumber +
1537
+ "/errorCorrectionLevel:" +
1538
+ errorCorrectionLevel
1539
+ );
1533
1540
  }
1534
1541
 
1535
1542
  var length = rsBlock.length / 3;
@@ -1537,13 +1544,12 @@ var qrcode = function() {
1537
1544
  var list = [];
1538
1545
 
1539
1546
  for (var i = 0; i < length; i += 1) {
1540
-
1541
1547
  var count = rsBlock[i * 3 + 0];
1542
1548
  var totalCount = rsBlock[i * 3 + 1];
1543
1549
  var dataCount = rsBlock[i * 3 + 2];
1544
1550
 
1545
1551
  for (var j = 0; j < count; j += 1) {
1546
- list.push(qrRSBlock(totalCount, dataCount) );
1552
+ list.push(qrRSBlock(totalCount, dataCount));
1547
1553
  }
1548
1554
  }
1549
1555
 
@@ -1551,47 +1557,45 @@ var qrcode = function() {
1551
1557
  };
1552
1558
 
1553
1559
  return _this;
1554
- }();
1560
+ })();
1555
1561
 
1556
1562
  //---------------------------------------------------------------------
1557
1563
  // qrBitBuffer
1558
1564
  //---------------------------------------------------------------------
1559
1565
 
1560
- var qrBitBuffer = function() {
1561
-
1566
+ var qrBitBuffer = function () {
1562
1567
  var _buffer = [];
1563
1568
  var _length = 0;
1564
1569
 
1565
1570
  var _this = {};
1566
1571
 
1567
- _this.getBuffer = function() {
1572
+ _this.getBuffer = function () {
1568
1573
  return _buffer;
1569
1574
  };
1570
1575
 
1571
- _this.getAt = function(index) {
1576
+ _this.getAt = function (index) {
1572
1577
  var bufIndex = Math.floor(index / 8);
1573
- return ( (_buffer[bufIndex] >>> (7 - index % 8) ) & 1) == 1;
1578
+ return ((_buffer[bufIndex] >>> (7 - (index % 8))) & 1) == 1;
1574
1579
  };
1575
1580
 
1576
- _this.put = function(num, length) {
1581
+ _this.put = function (num, length) {
1577
1582
  for (var i = 0; i < length; i += 1) {
1578
- _this.putBit( ( (num >>> (length - i - 1) ) & 1) == 1);
1583
+ _this.putBit(((num >>> (length - i - 1)) & 1) == 1);
1579
1584
  }
1580
1585
  };
1581
1586
 
1582
- _this.getLengthInBits = function() {
1587
+ _this.getLengthInBits = function () {
1583
1588
  return _length;
1584
1589
  };
1585
1590
 
1586
- _this.putBit = function(bit) {
1587
-
1591
+ _this.putBit = function (bit) {
1588
1592
  var bufIndex = Math.floor(_length / 8);
1589
1593
  if (_buffer.length <= bufIndex) {
1590
1594
  _buffer.push(0);
1591
1595
  }
1592
1596
 
1593
1597
  if (bit) {
1594
- _buffer[bufIndex] |= (0x80 >>> (_length % 8) );
1598
+ _buffer[bufIndex] |= 0x80 >>> (_length % 8);
1595
1599
  }
1596
1600
 
1597
1601
  _length += 1;
@@ -1604,54 +1608,52 @@ var qrcode = function() {
1604
1608
  // qrNumber
1605
1609
  //---------------------------------------------------------------------
1606
1610
 
1607
- var qrNumber = function(data) {
1608
-
1611
+ var qrNumber = function (data) {
1609
1612
  var _mode = QRMode.MODE_NUMBER;
1610
1613
  var _data = data;
1611
1614
 
1612
1615
  var _this = {};
1613
1616
 
1614
- _this.getMode = function() {
1617
+ _this.getMode = function () {
1615
1618
  return _mode;
1616
1619
  };
1617
1620
 
1618
- _this.getLength = function(buffer) {
1621
+ _this.getLength = function (buffer) {
1619
1622
  return _data.length;
1620
1623
  };
1621
1624
 
1622
- _this.write = function(buffer) {
1623
-
1625
+ _this.write = function (buffer) {
1624
1626
  var data = _data;
1625
1627
 
1626
1628
  var i = 0;
1627
1629
 
1628
1630
  while (i + 2 < data.length) {
1629
- buffer.put(strToNum(data.substring(i, i + 3) ), 10);
1631
+ buffer.put(strToNum(data.substring(i, i + 3)), 10);
1630
1632
  i += 3;
1631
1633
  }
1632
1634
 
1633
1635
  if (i < data.length) {
1634
1636
  if (data.length - i == 1) {
1635
- buffer.put(strToNum(data.substring(i, i + 1) ), 4);
1637
+ buffer.put(strToNum(data.substring(i, i + 1)), 4);
1636
1638
  } else if (data.length - i == 2) {
1637
- buffer.put(strToNum(data.substring(i, i + 2) ), 7);
1639
+ buffer.put(strToNum(data.substring(i, i + 2)), 7);
1638
1640
  }
1639
1641
  }
1640
1642
  };
1641
1643
 
1642
- var strToNum = function(s) {
1644
+ var strToNum = function (s) {
1643
1645
  var num = 0;
1644
1646
  for (var i = 0; i < s.length; i += 1) {
1645
- num = num * 10 + chatToNum(s.charAt(i) );
1647
+ num = num * 10 + chatToNum(s.charAt(i));
1646
1648
  }
1647
1649
  return num;
1648
1650
  };
1649
1651
 
1650
- var chatToNum = function(c) {
1651
- if ('0' <= c && c <= '9') {
1652
- return c.charCodeAt(0) - '0'.charCodeAt(0);
1652
+ var chatToNum = function (c) {
1653
+ if ("0" <= c && c <= "9") {
1654
+ return c.charCodeAt(0) - "0".charCodeAt(0);
1653
1655
  }
1654
- throw 'illegal char :' + c;
1656
+ throw "illegal char :" + c;
1655
1657
  };
1656
1658
 
1657
1659
  return _this;
@@ -1661,58 +1663,62 @@ var qrcode = function() {
1661
1663
  // qrAlphaNum
1662
1664
  //---------------------------------------------------------------------
1663
1665
 
1664
- var qrAlphaNum = function(data) {
1665
-
1666
+ var qrAlphaNum = function (data) {
1666
1667
  var _mode = QRMode.MODE_ALPHA_NUM;
1667
1668
  var _data = data;
1668
1669
 
1669
1670
  var _this = {};
1670
1671
 
1671
- _this.getMode = function() {
1672
+ _this.getMode = function () {
1672
1673
  return _mode;
1673
1674
  };
1674
1675
 
1675
- _this.getLength = function(buffer) {
1676
+ _this.getLength = function (buffer) {
1676
1677
  return _data.length;
1677
1678
  };
1678
1679
 
1679
- _this.write = function(buffer) {
1680
-
1680
+ _this.write = function (buffer) {
1681
1681
  var s = _data;
1682
1682
 
1683
1683
  var i = 0;
1684
1684
 
1685
1685
  while (i + 1 < s.length) {
1686
- buffer.put(
1687
- getCode(s.charAt(i) ) * 45 +
1688
- getCode(s.charAt(i + 1) ), 11);
1686
+ buffer.put(getCode(s.charAt(i)) * 45 + getCode(s.charAt(i + 1)), 11);
1689
1687
  i += 2;
1690
1688
  }
1691
1689
 
1692
1690
  if (i < s.length) {
1693
- buffer.put(getCode(s.charAt(i) ), 6);
1691
+ buffer.put(getCode(s.charAt(i)), 6);
1694
1692
  }
1695
1693
  };
1696
1694
 
1697
- var getCode = function(c) {
1698
-
1699
- if ('0' <= c && c <= '9') {
1700
- return c.charCodeAt(0) - '0'.charCodeAt(0);
1701
- } else if ('A' <= c && c <= 'Z') {
1702
- return c.charCodeAt(0) - 'A'.charCodeAt(0) + 10;
1695
+ var getCode = function (c) {
1696
+ if ("0" <= c && c <= "9") {
1697
+ return c.charCodeAt(0) - "0".charCodeAt(0);
1698
+ } else if ("A" <= c && c <= "Z") {
1699
+ return c.charCodeAt(0) - "A".charCodeAt(0) + 10;
1703
1700
  } else {
1704
1701
  switch (c) {
1705
- case ' ' : return 36;
1706
- case '$' : return 37;
1707
- case '%' : return 38;
1708
- case '*' : return 39;
1709
- case '+' : return 40;
1710
- case '-' : return 41;
1711
- case '.' : return 42;
1712
- case '/' : return 43;
1713
- case ':' : return 44;
1714
- default :
1715
- throw 'illegal char :' + c;
1702
+ case " ":
1703
+ return 36;
1704
+ case "$":
1705
+ return 37;
1706
+ case "%":
1707
+ return 38;
1708
+ case "*":
1709
+ return 39;
1710
+ case "+":
1711
+ return 40;
1712
+ case "-":
1713
+ return 41;
1714
+ case ".":
1715
+ return 42;
1716
+ case "/":
1717
+ return 43;
1718
+ case ":":
1719
+ return 44;
1720
+ default:
1721
+ throw "illegal char :" + c;
1716
1722
  }
1717
1723
  }
1718
1724
  };
@@ -1724,23 +1730,22 @@ var qrcode = function() {
1724
1730
  // qr8BitByte
1725
1731
  //---------------------------------------------------------------------
1726
1732
 
1727
- var qr8BitByte = function(data) {
1728
-
1733
+ var qr8BitByte = function (data) {
1729
1734
  var _mode = QRMode.MODE_8BIT_BYTE;
1730
1735
  var _data = data;
1731
1736
  var _bytes = qrcode.stringToBytes(data);
1732
1737
 
1733
1738
  var _this = {};
1734
1739
 
1735
- _this.getMode = function() {
1740
+ _this.getMode = function () {
1736
1741
  return _mode;
1737
1742
  };
1738
1743
 
1739
- _this.getLength = function(buffer) {
1744
+ _this.getLength = function (buffer) {
1740
1745
  return _bytes.length;
1741
1746
  };
1742
1747
 
1743
- _this.write = function(buffer) {
1748
+ _this.write = function (buffer) {
1744
1749
  for (var i = 0; i < _bytes.length; i += 1) {
1745
1750
  buffer.put(_bytes[i], 8);
1746
1751
  }
@@ -1753,54 +1758,51 @@ var qrcode = function() {
1753
1758
  // qrKanji
1754
1759
  //---------------------------------------------------------------------
1755
1760
 
1756
- var qrKanji = function(data) {
1757
-
1761
+ var qrKanji = function (data) {
1758
1762
  var _mode = QRMode.MODE_KANJI;
1759
1763
  var _data = data;
1760
1764
 
1761
- var stringToBytes = qrcode.stringToBytesFuncs['SJIS'];
1765
+ var stringToBytes = qrcode.stringToBytesFuncs["SJIS"];
1762
1766
  if (!stringToBytes) {
1763
- throw 'sjis not supported.';
1767
+ throw "sjis not supported.";
1764
1768
  }
1765
- !function(c, code) {
1769
+ !(function (c, code) {
1766
1770
  // self test for sjis support.
1767
1771
  var test = stringToBytes(c);
1768
- if (test.length != 2 || ( (test[0] << 8) | test[1]) != code) {
1769
- throw 'sjis not supported.';
1772
+ if (test.length != 2 || ((test[0] << 8) | test[1]) != code) {
1773
+ throw "sjis not supported.";
1770
1774
  }
1771
- }('\u53cb', 0x9746);
1775
+ })("\u53cb", 0x9746);
1772
1776
 
1773
1777
  var _bytes = stringToBytes(data);
1774
1778
 
1775
1779
  var _this = {};
1776
1780
 
1777
- _this.getMode = function() {
1781
+ _this.getMode = function () {
1778
1782
  return _mode;
1779
1783
  };
1780
1784
 
1781
- _this.getLength = function(buffer) {
1785
+ _this.getLength = function (buffer) {
1782
1786
  return ~~(_bytes.length / 2);
1783
1787
  };
1784
1788
 
1785
- _this.write = function(buffer) {
1786
-
1789
+ _this.write = function (buffer) {
1787
1790
  var data = _bytes;
1788
1791
 
1789
1792
  var i = 0;
1790
1793
 
1791
1794
  while (i + 1 < data.length) {
1795
+ var c = ((0xff & data[i]) << 8) | (0xff & data[i + 1]);
1792
1796
 
1793
- var c = ( (0xff & data[i]) << 8) | (0xff & data[i + 1]);
1794
-
1795
- if (0x8140 <= c && c <= 0x9FFC) {
1797
+ if (0x8140 <= c && c <= 0x9ffc) {
1796
1798
  c -= 0x8140;
1797
- } else if (0xE040 <= c && c <= 0xEBBF) {
1798
- c -= 0xC140;
1799
+ } else if (0xe040 <= c && c <= 0xebbf) {
1800
+ c -= 0xc140;
1799
1801
  } else {
1800
- throw 'illegal char at ' + (i + 1) + '/' + c;
1802
+ throw "illegal char at " + (i + 1) + "/" + c;
1801
1803
  }
1802
1804
 
1803
- c = ( (c >>> 8) & 0xff) * 0xC0 + (c & 0xff);
1805
+ c = ((c >>> 8) & 0xff) * 0xc0 + (c & 0xff);
1804
1806
 
1805
1807
  buffer.put(c, 13);
1806
1808
 
@@ -1808,7 +1810,7 @@ var qrcode = function() {
1808
1810
  }
1809
1811
 
1810
1812
  if (i < data.length) {
1811
- throw 'illegal char at ' + (i + 1);
1813
+ throw "illegal char at " + (i + 1);
1812
1814
  }
1813
1815
  };
1814
1816
 
@@ -1823,22 +1825,21 @@ var qrcode = function() {
1823
1825
  // byteArrayOutputStream
1824
1826
  //---------------------------------------------------------------------
1825
1827
 
1826
- var byteArrayOutputStream = function() {
1827
-
1828
+ var byteArrayOutputStream = function () {
1828
1829
  var _bytes = [];
1829
1830
 
1830
1831
  var _this = {};
1831
1832
 
1832
- _this.writeByte = function(b) {
1833
+ _this.writeByte = function (b) {
1833
1834
  _bytes.push(b & 0xff);
1834
1835
  };
1835
1836
 
1836
- _this.writeShort = function(i) {
1837
+ _this.writeShort = function (i) {
1837
1838
  _this.writeByte(i);
1838
1839
  _this.writeByte(i >>> 8);
1839
1840
  };
1840
1841
 
1841
- _this.writeBytes = function(b, off, len) {
1842
+ _this.writeBytes = function (b, off, len) {
1842
1843
  off = off || 0;
1843
1844
  len = len || b.length;
1844
1845
  for (var i = 0; i < len; i += 1) {
@@ -1846,26 +1847,26 @@ var qrcode = function() {
1846
1847
  }
1847
1848
  };
1848
1849
 
1849
- _this.writeString = function(s) {
1850
+ _this.writeString = function (s) {
1850
1851
  for (var i = 0; i < s.length; i += 1) {
1851
- _this.writeByte(s.charCodeAt(i) );
1852
+ _this.writeByte(s.charCodeAt(i));
1852
1853
  }
1853
1854
  };
1854
1855
 
1855
- _this.toByteArray = function() {
1856
+ _this.toByteArray = function () {
1856
1857
  return _bytes;
1857
1858
  };
1858
1859
 
1859
- _this.toString = function() {
1860
- var s = '';
1861
- s += '[';
1860
+ _this.toString = function () {
1861
+ var s = "";
1862
+ s += "[";
1862
1863
  for (var i = 0; i < _bytes.length; i += 1) {
1863
1864
  if (i > 0) {
1864
- s += ',';
1865
+ s += ",";
1865
1866
  }
1866
1867
  s += _bytes[i];
1867
1868
  }
1868
- s += ']';
1869
+ s += "]";
1869
1870
  return s;
1870
1871
  };
1871
1872
 
@@ -1876,20 +1877,19 @@ var qrcode = function() {
1876
1877
  // base64EncodeOutputStream
1877
1878
  //---------------------------------------------------------------------
1878
1879
 
1879
- var base64EncodeOutputStream = function() {
1880
-
1880
+ var base64EncodeOutputStream = function () {
1881
1881
  var _buffer = 0;
1882
1882
  var _buflen = 0;
1883
1883
  var _length = 0;
1884
- var _base64 = '';
1884
+ var _base64 = "";
1885
1885
 
1886
1886
  var _this = {};
1887
1887
 
1888
- var writeEncoded = function(b) {
1889
- _base64 += String.fromCharCode(encode(b & 0x3f) );
1888
+ var writeEncoded = function (b) {
1889
+ _base64 += String.fromCharCode(encode(b & 0x3f));
1890
1890
  };
1891
1891
 
1892
- var encode = function(n) {
1892
+ var encode = function (n) {
1893
1893
  if (n < 0) {
1894
1894
  // error.
1895
1895
  } else if (n < 26) {
@@ -1903,39 +1903,37 @@ var qrcode = function() {
1903
1903
  } else if (n == 63) {
1904
1904
  return 0x2f;
1905
1905
  }
1906
- throw 'n:' + n;
1906
+ throw "n:" + n;
1907
1907
  };
1908
1908
 
1909
- _this.writeByte = function(n) {
1910
-
1909
+ _this.writeByte = function (n) {
1911
1910
  _buffer = (_buffer << 8) | (n & 0xff);
1912
1911
  _buflen += 8;
1913
1912
  _length += 1;
1914
1913
 
1915
1914
  while (_buflen >= 6) {
1916
- writeEncoded(_buffer >>> (_buflen - 6) );
1915
+ writeEncoded(_buffer >>> (_buflen - 6));
1917
1916
  _buflen -= 6;
1918
1917
  }
1919
1918
  };
1920
1919
 
1921
- _this.flush = function() {
1922
-
1920
+ _this.flush = function () {
1923
1921
  if (_buflen > 0) {
1924
- writeEncoded(_buffer << (6 - _buflen) );
1922
+ writeEncoded(_buffer << (6 - _buflen));
1925
1923
  _buffer = 0;
1926
1924
  _buflen = 0;
1927
1925
  }
1928
1926
 
1929
1927
  if (_length % 3 != 0) {
1930
1928
  // padding
1931
- var padlen = 3 - _length % 3;
1929
+ var padlen = 3 - (_length % 3);
1932
1930
  for (var i = 0; i < padlen; i += 1) {
1933
- _base64 += '=';
1931
+ _base64 += "=";
1934
1932
  }
1935
1933
  }
1936
1934
  };
1937
1935
 
1938
- _this.toString = function() {
1936
+ _this.toString = function () {
1939
1937
  return _base64;
1940
1938
  };
1941
1939
 
@@ -1946,8 +1944,7 @@ var qrcode = function() {
1946
1944
  // base64DecodeInputStream
1947
1945
  //---------------------------------------------------------------------
1948
1946
 
1949
- var base64DecodeInputStream = function(str) {
1950
-
1947
+ var base64DecodeInputStream = function (str) {
1951
1948
  var _str = str;
1952
1949
  var _pos = 0;
1953
1950
  var _buffer = 0;
@@ -1955,38 +1952,36 @@ var qrcode = function() {
1955
1952
 
1956
1953
  var _this = {};
1957
1954
 
1958
- _this.read = function() {
1959
-
1955
+ _this.read = function () {
1960
1956
  while (_buflen < 8) {
1961
-
1962
1957
  if (_pos >= _str.length) {
1963
1958
  if (_buflen == 0) {
1964
1959
  return -1;
1965
1960
  }
1966
- throw 'unexpected end of file./' + _buflen;
1961
+ throw "unexpected end of file./" + _buflen;
1967
1962
  }
1968
1963
 
1969
1964
  var c = _str.charAt(_pos);
1970
1965
  _pos += 1;
1971
1966
 
1972
- if (c == '=') {
1967
+ if (c == "=") {
1973
1968
  _buflen = 0;
1974
1969
  return -1;
1975
- } else if (c.match(/^\s$/) ) {
1970
+ } else if (c.match(/^\s$/)) {
1976
1971
  // ignore if whitespace.
1977
1972
  continue;
1978
1973
  }
1979
1974
 
1980
- _buffer = (_buffer << 6) | decode(c.charCodeAt(0) );
1975
+ _buffer = (_buffer << 6) | decode(c.charCodeAt(0));
1981
1976
  _buflen += 6;
1982
1977
  }
1983
1978
 
1984
- var n = (_buffer >>> (_buflen - 8) ) & 0xff;
1979
+ var n = (_buffer >>> (_buflen - 8)) & 0xff;
1985
1980
  _buflen -= 8;
1986
1981
  return n;
1987
1982
  };
1988
1983
 
1989
- var decode = function(c) {
1984
+ var decode = function (c) {
1990
1985
  if (0x41 <= c && c <= 0x5a) {
1991
1986
  return c - 0x41;
1992
1987
  } else if (0x61 <= c && c <= 0x7a) {
@@ -1998,7 +1993,7 @@ var qrcode = function() {
1998
1993
  } else if (c == 0x2f) {
1999
1994
  return 63;
2000
1995
  } else {
2001
- throw 'c:' + c;
1996
+ throw "c:" + c;
2002
1997
  }
2003
1998
  };
2004
1999
 
@@ -2009,24 +2004,22 @@ var qrcode = function() {
2009
2004
  // gifImage (B/W)
2010
2005
  //---------------------------------------------------------------------
2011
2006
 
2012
- var gifImage = function(width, height) {
2013
-
2007
+ var gifImage = function (width, height) {
2014
2008
  var _width = width;
2015
2009
  var _height = height;
2016
2010
  var _data = new Array(width * height);
2017
2011
 
2018
2012
  var _this = {};
2019
2013
 
2020
- _this.setPixel = function(x, y, pixel) {
2014
+ _this.setPixel = function (x, y, pixel) {
2021
2015
  _data[y * _width + x] = pixel;
2022
2016
  };
2023
2017
 
2024
- _this.write = function(out) {
2025
-
2018
+ _this.write = function (out) {
2026
2019
  //---------------------------------
2027
2020
  // GIF Signature
2028
2021
 
2029
- out.writeString('GIF87a');
2022
+ out.writeString("GIF87a");
2030
2023
 
2031
2024
  //---------------------------------
2032
2025
  // Screen Descriptor
@@ -2054,7 +2047,7 @@ var qrcode = function() {
2054
2047
  //---------------------------------
2055
2048
  // Image Descriptor
2056
2049
 
2057
- out.writeString(',');
2050
+ out.writeString(",");
2058
2051
  out.writeShort(0);
2059
2052
  out.writeShort(0);
2060
2053
  out.writeShort(_width);
@@ -2086,27 +2079,25 @@ var qrcode = function() {
2086
2079
 
2087
2080
  //---------------------------------
2088
2081
  // GIF Terminator
2089
- out.writeString(';');
2082
+ out.writeString(";");
2090
2083
  };
2091
2084
 
2092
- var bitOutputStream = function(out) {
2093
-
2085
+ var bitOutputStream = function (out) {
2094
2086
  var _out = out;
2095
2087
  var _bitLength = 0;
2096
2088
  var _bitBuffer = 0;
2097
2089
 
2098
2090
  var _this = {};
2099
2091
 
2100
- _this.write = function(data, length) {
2101
-
2102
- if ( (data >>> length) != 0) {
2103
- throw 'length over';
2092
+ _this.write = function (data, length) {
2093
+ if (data >>> length != 0) {
2094
+ throw "length over";
2104
2095
  }
2105
2096
 
2106
2097
  while (_bitLength + length >= 8) {
2107
- _out.writeByte(0xff & ( (data << _bitLength) | _bitBuffer) );
2108
- length -= (8 - _bitLength);
2109
- data >>>= (8 - _bitLength);
2098
+ _out.writeByte(0xff & ((data << _bitLength) | _bitBuffer));
2099
+ length -= 8 - _bitLength;
2100
+ data >>>= 8 - _bitLength;
2110
2101
  _bitBuffer = 0;
2111
2102
  _bitLength = 0;
2112
2103
  }
@@ -2115,7 +2106,7 @@ var qrcode = function() {
2115
2106
  _bitLength = _bitLength + length;
2116
2107
  };
2117
2108
 
2118
- _this.flush = function() {
2109
+ _this.flush = function () {
2119
2110
  if (_bitLength > 0) {
2120
2111
  _out.writeByte(_bitBuffer);
2121
2112
  }
@@ -2124,8 +2115,7 @@ var qrcode = function() {
2124
2115
  return _this;
2125
2116
  };
2126
2117
 
2127
- var getLZWRaster = function(lzwMinCodeSize) {
2128
-
2118
+ var getLZWRaster = function (lzwMinCodeSize) {
2129
2119
  var clearCode = 1 << lzwMinCodeSize;
2130
2120
  var endCode = (1 << lzwMinCodeSize) + 1;
2131
2121
  var bitLength = lzwMinCodeSize + 1;
@@ -2134,10 +2124,10 @@ var qrcode = function() {
2134
2124
  var table = lzwTable();
2135
2125
 
2136
2126
  for (var i = 0; i < clearCode; i += 1) {
2137
- table.add(String.fromCharCode(i) );
2127
+ table.add(String.fromCharCode(i));
2138
2128
  }
2139
- table.add(String.fromCharCode(clearCode) );
2140
- table.add(String.fromCharCode(endCode) );
2129
+ table.add(String.fromCharCode(clearCode));
2130
+ table.add(String.fromCharCode(endCode));
2141
2131
 
2142
2132
  var byteOut = byteArrayOutputStream();
2143
2133
  var bitOut = bitOutputStream(byteOut);
@@ -2151,21 +2141,16 @@ var qrcode = function() {
2151
2141
  dataIndex += 1;
2152
2142
 
2153
2143
  while (dataIndex < _data.length) {
2154
-
2155
2144
  var c = String.fromCharCode(_data[dataIndex]);
2156
2145
  dataIndex += 1;
2157
2146
 
2158
- if (table.contains(s + c) ) {
2159
-
2147
+ if (table.contains(s + c)) {
2160
2148
  s = s + c;
2161
-
2162
2149
  } else {
2163
-
2164
2150
  bitOut.write(table.indexOf(s), bitLength);
2165
2151
 
2166
2152
  if (table.size() < 0xfff) {
2167
-
2168
- if (table.size() == (1 << bitLength) ) {
2153
+ if (table.size() == 1 << bitLength) {
2169
2154
  bitLength += 1;
2170
2155
  }
2171
2156
 
@@ -2186,31 +2171,30 @@ var qrcode = function() {
2186
2171
  return byteOut.toByteArray();
2187
2172
  };
2188
2173
 
2189
- var lzwTable = function() {
2190
-
2174
+ var lzwTable = function () {
2191
2175
  var _map = {};
2192
2176
  var _size = 0;
2193
2177
 
2194
2178
  var _this = {};
2195
2179
 
2196
- _this.add = function(key) {
2197
- if (_this.contains(key) ) {
2198
- throw 'dup key:' + key;
2180
+ _this.add = function (key) {
2181
+ if (_this.contains(key)) {
2182
+ throw "dup key:" + key;
2199
2183
  }
2200
2184
  _map[key] = _size;
2201
2185
  _size += 1;
2202
2186
  };
2203
2187
 
2204
- _this.size = function() {
2188
+ _this.size = function () {
2205
2189
  return _size;
2206
2190
  };
2207
2191
 
2208
- _this.indexOf = function(key) {
2192
+ _this.indexOf = function (key) {
2209
2193
  return _map[key];
2210
2194
  };
2211
2195
 
2212
- _this.contains = function(key) {
2213
- return typeof _map[key] != 'undefined';
2196
+ _this.contains = function (key) {
2197
+ return typeof _map[key] != "undefined";
2214
2198
  };
2215
2199
 
2216
2200
  return _this;
@@ -2219,11 +2203,11 @@ var qrcode = function() {
2219
2203
  return _this;
2220
2204
  };
2221
2205
 
2222
- var createDataURL = function(width, height, getPixel) {
2206
+ var createDataURL = function (width, height, getPixel) {
2223
2207
  var gif = gifImage(width, height);
2224
2208
  for (var y = 0; y < height; y += 1) {
2225
2209
  for (var x = 0; x < width; x += 1) {
2226
- gif.setPixel(x, y, getPixel(x, y) );
2210
+ gif.setPixel(x, y, getPixel(x, y));
2227
2211
  }
2228
2212
  }
2229
2213
 
@@ -2237,33 +2221,32 @@ var qrcode = function() {
2237
2221
  }
2238
2222
  base64.flush();
2239
2223
 
2240
- return 'data:image/gif;base64,' + base64;
2224
+ return "data:image/gif;base64," + base64;
2241
2225
  };
2242
2226
 
2243
2227
  //---------------------------------------------------------------------
2244
2228
  // returns qrcode function.
2245
2229
 
2246
2230
  return qrcode;
2247
- }();
2231
+ })();
2248
2232
 
2249
2233
  // multibyte support
2250
- !function() {
2251
-
2252
- qrcode.stringToBytesFuncs['UTF-8'] = function(s) {
2234
+ !(function () {
2235
+ qrcode.stringToBytesFuncs["UTF-8"] = function (s) {
2253
2236
  // http://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array
2254
2237
  function toUTF8Array(str) {
2255
2238
  var utf8 = [];
2256
- for (var i=0; i < str.length; i++) {
2239
+ for (var i = 0; i < str.length; i++) {
2257
2240
  var charcode = str.charCodeAt(i);
2258
2241
  if (charcode < 0x80) utf8.push(charcode);
2259
2242
  else if (charcode < 0x800) {
2260
- utf8.push(0xc0 | (charcode >> 6),
2261
- 0x80 | (charcode & 0x3f));
2262
- }
2263
- else if (charcode < 0xd800 || charcode >= 0xe000) {
2264
- utf8.push(0xe0 | (charcode >> 12),
2265
- 0x80 | ((charcode>>6) & 0x3f),
2266
- 0x80 | (charcode & 0x3f));
2243
+ utf8.push(0xc0 | (charcode >> 6), 0x80 | (charcode & 0x3f));
2244
+ } else if (charcode < 0xd800 || charcode >= 0xe000) {
2245
+ utf8.push(
2246
+ 0xe0 | (charcode >> 12),
2247
+ 0x80 | ((charcode >> 6) & 0x3f),
2248
+ 0x80 | (charcode & 0x3f),
2249
+ );
2267
2250
  }
2268
2251
  // surrogate pair
2269
2252
  else {
@@ -2271,27 +2254,27 @@ var qrcode = function() {
2271
2254
  // UTF-16 encodes 0x10000-0x10FFFF by
2272
2255
  // subtracting 0x10000 and splitting the
2273
2256
  // 20 bits of 0x0-0xFFFFF into two halves
2274
- charcode = 0x10000 + (((charcode & 0x3ff)<<10)
2275
- | (str.charCodeAt(i) & 0x3ff));
2276
- utf8.push(0xf0 | (charcode >>18),
2277
- 0x80 | ((charcode>>12) & 0x3f),
2278
- 0x80 | ((charcode>>6) & 0x3f),
2279
- 0x80 | (charcode & 0x3f));
2257
+ charcode = 0x10000 + (((charcode & 0x3ff) << 10) | (str.charCodeAt(i) & 0x3ff));
2258
+ utf8.push(
2259
+ 0xf0 | (charcode >> 18),
2260
+ 0x80 | ((charcode >> 12) & 0x3f),
2261
+ 0x80 | ((charcode >> 6) & 0x3f),
2262
+ 0x80 | (charcode & 0x3f),
2263
+ );
2280
2264
  }
2281
2265
  }
2282
2266
  return utf8;
2283
2267
  }
2284
2268
  return toUTF8Array(s);
2285
2269
  };
2286
-
2287
- }();
2270
+ })();
2288
2271
 
2289
2272
  (function (factory) {
2290
- if (typeof define === 'function' && define.amd) {
2291
- define([], factory);
2292
- } else if (typeof exports === 'object') {
2293
- module.exports = factory();
2273
+ if (typeof define === "function" && define.amd) {
2274
+ define([], factory);
2275
+ } else if (typeof exports === "object") {
2276
+ module.exports = factory();
2294
2277
  }
2295
- }(function () {
2296
- return qrcode;
2297
- }));
2278
+ })(function () {
2279
+ return qrcode;
2280
+ });