{"title":"$:/plugins/tiddlywiki/qrcode","name":"QR Code","description":"QR Code generator","author":"Zeno Zeng","list":"readme usage examples license","version":"5.2.2","plugin-type":"plugin","dependents":"","type":"application/json","tiddlers":{"$:/plugins/tiddlywiki/qrcode/MakeContactQR":{"title":"$:/plugins/tiddlywiki/qrcode/MakeContactQR","tags":"$:/tags/MakeQR","caption":"Contact","text":"\\define wifi-url()\nWIFI:wifi name;T:WPA;S:SSID;P:password;\n\\end\n\n\\define image(firstname,lastname,address,tel,email)\n<img src=<<makeqr text:\"\"\"MECARD:N:$lastname$,$firstname$;ADR:$address$;TEL:$tel$;EMAIL:$email$;;\"\"\" size:\"350\">>/>\n\\end\n\n! Enter the contact details\n\nFirst name: <$edit-text tiddler=\"$:/config/plugins/tiddlywiki/qrcode/contact/firstname\" tag=\"input\" default=\"\"/>\n\nLast name: <$edit-text tiddler=\"$:/config/plugins/tiddlywiki/qrcode/contact/lastname\" tag=\"input\" default=\"\"/>\n\nAddress: <$edit-text tiddler=\"$:/config/plugins/tiddlywiki/qrcode/contact/address\" tag=\"input\" default=\"\"/>\n\nTelephone: <$edit-text tiddler=\"$:/config/plugins/tiddlywiki/qrcode/contact/tel\" tag=\"input\" default=\"\"/>\n\nEmail: <$edit-text tiddler=\"$:/config/plugins/tiddlywiki/qrcode/contact/email\" tag=\"input\" default=\"\"/>\n\n! Here is your QR code\n\n<$macrocall $name=\"image\" firstname={{$:/config/plugins/tiddlywiki/qrcode/contact/firstname}} lastname={{$:/config/plugins/tiddlywiki/qrcode/contact/lastname}} address={{$:/config/plugins/tiddlywiki/qrcode/contact/address}} tel={{$:/config/plugins/tiddlywiki/qrcode/contact/tel}} email={{$:/config/plugins/tiddlywiki/qrcode/contact/email}}/>\n"},"$:/plugins/tiddlywiki/qrcode/MakeGenericQR":{"title":"$:/plugins/tiddlywiki/qrcode/MakeGenericQR","tags":"$:/tags/MakeQR","caption":"Generic","text":"\\define image(content)\n<img src=<<makeqr text:\"\"\"$content$\"\"\" size:\"350\">>/>\n\\end\n\n! Enter the details\n\nYou can also use this form to encode URLs.\n\n<$edit-text tiddler=\"$:/config/plugins/tiddlywiki/qrcode/generic\" default=\"\" class=\"tc-edit-texteditor\"/>\n\n! Here is your QR code\n\n<$macrocall $name=\"image\" content={{$:/config/plugins/tiddlywiki/qrcode/generic}}/>\n"},"$:/plugins/tiddlywiki/qrcode/MakeWifiQR":{"title":"$:/plugins/tiddlywiki/qrcode/MakeWifiQR","tags":"$:/tags/MakeQR","caption":"Wifi","text":"\\define wifi-url()\nWIFI:T:WPA;S:SSID;P:password;;\n\\end\n\n\\define image(network,encryption,ssid,password)\n<img src=<<makeqr text:\"\"\"WIFI:T:$encryption$;S:$ssid$;P:$password$;;\"\"\" size:\"350\">>/>\n\\end\n\n! Enter the details of your wifi network\n\nEncryption: <$select tiddler=\"$:/config/plugins/tiddlywiki/qrcode/wifi/encryption\" default=\"none\">\n<option value=\"none\">None</option>\n<option value=\"WEP\">WEP</option>\n<option value=\"WPA\">WPA</option>\n<option value=\"WPA2\">WPA2</option>\n</$select>\n\nSSID: <$edit-text tiddler=\"$:/config/plugins/tiddlywiki/qrcode/wifi/ssid\" tag=\"input\" default=\"\"/>\n\nPassword: <$edit-text tiddler=\"$:/config/plugins/tiddlywiki/qrcode/wifi/password\" tag=\"input\" default=\"\"/>\n\n! Here is your QR code\n\n<$macrocall $name=\"image\" network={{$:/config/plugins/tiddlywiki/qrcode/wifi/network}} encryption={{$:/config/plugins/tiddlywiki/qrcode/wifi/encryption}} ssid={{$:/config/plugins/tiddlywiki/qrcode/wifi/ssid}} password={{$:/config/plugins/tiddlywiki/qrcode/wifi/password}}/>\n"},"$:/plugins/tiddlywiki/qrcode/ViewToolbarButton":{"title":"$:/plugins/tiddlywiki/qrcode/ViewToolbarButton","tags":"$:/tags/ViewToolbar","list-before":"$:/core/ui/Buttons/close","caption":"{{$:/plugins/tiddlywiki/qrcode/icon}} QR code","short-caption":"QR code","description":"Generate QR code for this tiddler","text":"\\whitespace trim\n<span class=\"tc-popup-keep\">\n<$button popup=<<qualify \"$:/state/popup/qrcode\">> tooltip={{$:/plugins/tiddlywiki/qrcode/ViewToolbarButton!!description}} aria-label={{$:/plugins/tiddlywiki/qrcode/ViewToolbarButton!!short-caption}} class=<<tv-config-toolbar-class>> class=<<tv-config-toolbar-class>> selectedClass=\"tc-selected\">\n<$list filter=\"[<tv-config-toolbar-icons>match[yes]]\">\n{{$:/plugins/tiddlywiki/qrcode/icon}}\n</$list>\n<$list filter=\"[<tv-config-toolbar-text>match[yes]]\">\n<span class=\"tc-btn-text\">\n<$text text={{$:/plugins/tiddlywiki/qrcode/ViewToolbarButton!!short-caption}}/>\n</span>\n</$list>\n</$button>\n</span>\n<$reveal state=<<qualify \"$:/state/popup/qrcode\">> type=\"popup\" position=\"below\" animate=\"yes\">\n\n<div class=\"tc-drop-down\">\n\n{{$:/plugins/tiddlywiki/qrcode/ViewToolbarButton||description}}\n\n<$set name=\"tv-config-toolbar-icons\" value=\"yes\">\n\n<$set name=\"tv-config-toolbar-text\" value=\"yes\">\n\n<$set name=\"tv-config-toolbar-class\" value=\"tc-btn-invisible\">\n\n<$set name=\"targetTiddler\" value=<<currentTiddler>>>\n\n<$list filter=\"[all[shadows+tiddlers]tag[$:/tags/ViewToolbarButton/QRcode]!has[draft.of]]\">\n\n<$button popup=<<qualify \"$:/state/popup/qrcode/type\">> class=\"tc-btn-invisible\" selectedClass=\"tc-selected\">\n\n<$action-sendmessage $message=\"tm-modal\" $param=<<currentTiddler>> currentTiddler=<<targetTiddler>>/>\n\n<$transclude field=\"caption\" mode=\"inline\"/>\n\n</$button>\n\n</$list>\n\n</$set>\n\n</$set>\n\n</$set>\n\n</$set>\n\n</div>\n\n</$reveal>\n"},"$:/plugins/tiddlywiki/qrcode/ViewToolbarButton/Raw":{"title":"$:/plugins/tiddlywiki/qrcode/ViewToolbarButton/Raw","tags":"$:/tags/ViewToolbarButton/QRcode","caption":"Raw content of this tiddler","subtitle":"QR code of raw tiddler content","text":"\\define image()\n<img src=<<makeqr text:\"\"\"$(content)$\"\"\" size:\"350\">>/>\n\\end\n\n<$set name=\"content\" value={{!!text}}>\n<<image>>\n</$set>\n"},"$:/plugins/tiddlywiki/qrcode/ViewToolbarButton/Rendered":{"title":"$:/plugins/tiddlywiki/qrcode/ViewToolbarButton/Rendered","tags":"$:/tags/ViewToolbarButton/QRcode","caption":"Rendered content of this tiddler","subtitle":"QR code of rendered tiddler content","text":"\\define image()\n<img src=<<makeqr text:\"\"\"$(content)$\"\"\" size:\"350\">>/>\n\\end\n\n<$wikify name=\"content\" text={{!!text}} type=\"text\" mode=\"block\" output=\"formattedtext\">\n<<image>>\n</$wikify>\n"},"$:/plugins/tiddlywiki/qrcode/ViewToolbarButton/URL":{"title":"$:/plugins/tiddlywiki/qrcode/ViewToolbarButton/URL","tags":"$:/tags/ViewToolbarButton/QRcode","caption":"URL of this tiddler","subtitle":"QR code of URL of this tiddler","text":"\\define image()\n<img src=<<makeqr text:\"\"\"$(url)$#$(hash)$\"\"\" size:\"350\">>/>\n\\end\n\n<$set name=\"url\" value={{$:/info/url/full}}>\n<$set name=\"hash\" filter=\"[<currentTiddler>encodeuricomponent[]]\" select=\"0\">\n<<image>>\n</$set>\n</$set>\n"},"$:/plugins/tiddlywiki/qrcode/styles":{"title":"$:/plugins/tiddlywiki/qrcode/styles","tags":"[[$:/tags/Stylesheet]]","text":"\\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline\n\n.tc-drop-down .tc-qrcode-drop-down img {\n\twidth: 100%;\n\theight: 100%;\n}\n"},"$:/plugins/tiddlywiki/qrcode/examples":{"title":"$:/plugins/tiddlywiki/qrcode/examples","text":"<<tabs \"[all[shadows+tiddlers]tag[$:/tags/MakeQR]!has[draft.of]]\" \"$:/plugins/tiddlywiki/qrcode/MakeGenericQR\">>"},"$:/plugins/tiddlywiki/qrcode/readme":{"title":"$:/plugins/tiddlywiki/qrcode/readme","text":"The QR code plugin provides a macro that enables any text to be rendered as a [[QR code|https://en.wikipedia.org/wiki/QR_code]]. QR codes are a type of 2-dimensional bar code that encodes arbitrary data: text, numbers, links. QR code readers are available or built-in for smartphones, making them a convenient means to transfer information between devices\n\nThe QR code plugin adds the following features to TiddlyWiki:\n\n* A new [[makeqr Macro]] that renders specified text as a QR code image that can be displayed or printed\n* A new toolbar button that can display several QR code renderings of the content of a tiddler:\n** Raw content\n** Rendered, formatted content\n** URL of tiddler\n\nThe QR code plugin is based on the library [[qrcode.js by Zeno Zeng|https://github.com/zenozeng/node-yaqrcode]]."},"$:/plugins/tiddlywiki/qrcode/usage":{"title":"$:/plugins/tiddlywiki/qrcode/usage","text":"! `makeqr` Macro\n\nThe <<.def makeqr>> [[macro|Macros]] converts text data into an image of the corresponding QR code. The image is returned as [[base64-encoded data URI|https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs]].\n\n!! Parameters\n\n;text\n: The text to encode\n;size\n: The size of the image in pixels (defaults to 500)\n;errorCorrectLevel\n: Determines the amount of error correction applied to the image; see below (defaults to \"M\").\n;fallback\n: The fallback image to be returned in case of an error (see below)\n\nThe conversion will fail if the text is too long and/or complex and the macro will return the provided fallback image. If no fallback image is provided then an error image is generated.\n\nThe error correction level is a [[QR code feature|http://www.qrcode.com/en/about/error_correction.html]]:\n\n<<<\nQR Code has error correction capability to restore data if the code is dirty or damaged. ... Level Q or H may be selected for factory environment where QR Code get dirty, whereas Level L may be selected for clean environment with the large amount of data. Typically, Level M (15%) is most frequently selected.\n<<<\n\n!! Examples\n\nMaking a QR code for a simple string of text:\n\n```\n<<makeqr \"Hello there!\">>\n```\n\nMaking a QR code for the URL field of the current tiddler:\n\n```\n<$macrocall $name=\"makeqr\" text={{!!url}}/>\n```\n\nMaking a QR code for the URL of the current wiki:\n\n```\n<$macrocall $name=\"makeqr\" text={{$:/info/url/full}}/>\n```\n"},"$:/plugins/tiddlywiki/qrcode/qrcode.js":{"text":"//---------------------------------------------------------------------\n//\n// QR Code Generator for JavaScript\n//\n// Copyright (c) 2009 Kazuhiko Arase\n//\n// URL: http://www.d-project.com/\n//\n// Licensed under the MIT license:\n//\thttp://www.opensource.org/licenses/mit-license.php\n//\n// The word 'QR Code' is registered trademark of\n// DENSO WAVE INCORPORATED\n//\thttp://www.denso-wave.com/qrcode/faqpatent-e.html\n//\n//---------------------------------------------------------------------\n\n//---------------------------------------------------------------------\n// qrcode\n//---------------------------------------------------------------------\n\n/**\n * qrcode\n * @param typeNumber 1 to 40\n * @param errorCorrectLevel 'L','M','Q','H'\n */\nvar qrcode = function(typeNumber, errorCorrectLevel) {\n\n    var PAD0 = 0xEC;\n    var PAD1 = 0x11;\n\n    var _typeNumber = typeNumber;\n    var _errorCorrectLevel = QRErrorCorrectLevel[errorCorrectLevel];\n    var _modules = null;\n    var _moduleCount = 0;\n    var _dataCache = null;\n    var _dataList = new Array();\n\n    var _this = {};\n\n    var makeImpl = function(test, maskPattern) {\n\n\t_moduleCount = _typeNumber * 4 + 17;\n\t_modules = function(moduleCount) {\n\t    var modules = new Array(moduleCount);\n\t    for (var row = 0; row < moduleCount; row += 1) {\n\t\tmodules[row] = new Array(moduleCount);\n\t\tfor (var col = 0; col < moduleCount; col += 1) {\n\t\t    modules[row][col] = null;\n\t\t}\n\t    }\n\t    return modules;\n\t}(_moduleCount);\n\n\tsetupPositionProbePattern(0, 0);\n\tsetupPositionProbePattern(_moduleCount - 7, 0);\n\tsetupPositionProbePattern(0, _moduleCount - 7);\n\tsetupPositionAdjustPattern();\n\tsetupTimingPattern();\n\tsetupTypeInfo(test, maskPattern);\n\n\tif (_typeNumber >= 7) {\n\t    setupTypeNumber(test);\n\t}\n\n\tif (_dataCache == null) {\n\t    _dataCache = createData(_typeNumber, _errorCorrectLevel, _dataList);\n\t}\n\n\tmapData(_dataCache, maskPattern);\n    };\n\n    var setupPositionProbePattern = function(row, col) {\n\n\tfor (var r = -1; r <= 7; r += 1) {\n\n\t    if (row + r <= -1 || _moduleCount <= row + r) continue;\n\n\t    for (var c = -1; c <= 7; c += 1) {\n\n\t\tif (col + c <= -1 || _moduleCount <= col + c) continue;\n\n\t\tif ( (0 <= r && r <= 6 && (c == 0 || c == 6) )\n\t\t     || (0 <= c && c <= 6 && (r == 0 || r == 6) )\n\t\t     || (2 <= r && r <= 4 && 2 <= c && c <= 4) ) {\n\t\t    _modules[row + r][col + c] = true;\n\t\t} else {\n\t\t    _modules[row + r][col + c] = false;\n\t\t}\n\t    }\n\t}\n    };\n\n    var getBestMaskPattern = function() {\n\n\tvar minLostPoint = 0;\n\tvar pattern = 0;\n\n\tfor (var i = 0; i < 8; i += 1) {\n\n\t    makeImpl(true, i);\n\n\t    var lostPoint = QRUtil.getLostPoint(_this);\n\n\t    if (i == 0 || minLostPoint > lostPoint) {\n\t\tminLostPoint = lostPoint;\n\t\tpattern = i;\n\t    }\n\t}\n\n\treturn pattern;\n    };\n\n    var setupTimingPattern = function() {\n\n\tfor (var r = 8; r < _moduleCount - 8; r += 1) {\n\t    if (_modules[r][6] != null) {\n\t\tcontinue;\n\t    }\n\t    _modules[r][6] = (r % 2 == 0);\n\t}\n\n\tfor (var c = 8; c < _moduleCount - 8; c += 1) {\n\t    if (_modules[6][c] != null) {\n\t\tcontinue;\n\t    }\n\t    _modules[6][c] = (c % 2 == 0);\n\t}\n    };\n\n    var setupPositionAdjustPattern = function() {\n\n\tvar pos = QRUtil.getPatternPosition(_typeNumber);\n\n\tfor (var i = 0; i < pos.length; i += 1) {\n\n\t    for (var j = 0; j < pos.length; j += 1) {\n\n\t\tvar row = pos[i];\n\t\tvar col = pos[j];\n\n\t\tif (_modules[row][col] != null) {\n\t\t    continue;\n\t\t}\n\n\t\tfor (var r = -2; r <= 2; r += 1) {\n\n\t\t    for (var c = -2; c <= 2; c += 1) {\n\n\t\t\tif (r == -2 || r == 2 || c == -2 || c == 2\n\t\t\t    || (r == 0 && c == 0) ) {\n\t\t\t    _modules[row + r][col + c] = true;\n\t\t\t} else {\n\t\t\t    _modules[row + r][col + c] = false;\n\t\t\t}\n\t\t    }\n\t\t}\n\t    }\n\t}\n    };\n\n    var setupTypeNumber = function(test) {\n\n\tvar bits = QRUtil.getBCHTypeNumber(_typeNumber);\n\n\tfor (var i = 0; i < 18; i += 1) {\n\t    var mod = (!test && ( (bits >> i) & 1) == 1);\n\t    _modules[Math.floor(i / 3)][i % 3 + _moduleCount - 8 - 3] = mod;\n\t}\n\n\tfor (var i = 0; i < 18; i += 1) {\n\t    var mod = (!test && ( (bits >> i) & 1) == 1);\n\t    _modules[i % 3 + _moduleCount - 8 - 3][Math.floor(i / 3)] = mod;\n\t}\n    };\n\n    var setupTypeInfo = function(test, maskPattern) {\n\n\tvar data = (_errorCorrectLevel << 3) | maskPattern;\n\tvar bits = QRUtil.getBCHTypeInfo(data);\n\n\t// vertical\n\tfor (var i = 0; i < 15; i += 1) {\n\n\t    var mod = (!test && ( (bits >> i) & 1) == 1);\n\n\t    if (i < 6) {\n\t\t_modules[i][8] = mod;\n\t    } else if (i < 8) {\n\t\t_modules[i + 1][8] = mod;\n\t    } else {\n\t\t_modules[_moduleCount - 15 + i][8] = mod;\n\t    }\n\t}\n\n\t// horizontal\n\tfor (var i = 0; i < 15; i += 1) {\n\n\t    var mod = (!test && ( (bits >> i) & 1) == 1);\n\n\t    if (i < 8) {\n\t\t_modules[8][_moduleCount - i - 1] = mod;\n\t    } else if (i < 9) {\n\t\t_modules[8][15 - i - 1 + 1] = mod;\n\t    } else {\n\t\t_modules[8][15 - i - 1] = mod;\n\t    }\n\t}\n\n\t// fixed module\n\t_modules[_moduleCount - 8][8] = (!test);\n    };\n\n    var mapData = function(data, maskPattern) {\n\n\tvar inc = -1;\n\tvar row = _moduleCount - 1;\n\tvar bitIndex = 7;\n\tvar byteIndex = 0;\n\tvar maskFunc = QRUtil.getMaskFunction(maskPattern);\n\n\tfor (var col = _moduleCount - 1; col > 0; col -= 2) {\n\n\t    if (col == 6) col -= 1;\n\n\t    while (true) {\n\n\t\tfor (var c = 0; c < 2; c += 1) {\n\n\t\t    if (_modules[row][col - c] == null) {\n\n\t\t\tvar dark = false;\n\n\t\t\tif (byteIndex < data.length) {\n\t\t\t    dark = ( ( (data[byteIndex] >>> bitIndex) & 1) == 1);\n\t\t\t}\n\n\t\t\tvar mask = maskFunc(row, col - c);\n\n\t\t\tif (mask) {\n\t\t\t    dark = !dark;\n\t\t\t}\n\n\t\t\t_modules[row][col - c] = dark;\n\t\t\tbitIndex -= 1;\n\n\t\t\tif (bitIndex == -1) {\n\t\t\t    byteIndex += 1;\n\t\t\t    bitIndex = 7;\n\t\t\t}\n\t\t    }\n\t\t}\n\n\t\trow += inc;\n\n\t\tif (row < 0 || _moduleCount <= row) {\n\t\t    row -= inc;\n\t\t    inc = -inc;\n\t\t    break;\n\t\t}\n\t    }\n\t}\n    };\n\n    var createBytes = function(buffer, rsBlocks) {\n\n\tvar offset = 0;\n\n\tvar maxDcCount = 0;\n\tvar maxEcCount = 0;\n\n\tvar dcdata = new Array(rsBlocks.length);\n\tvar ecdata = new Array(rsBlocks.length);\n\n\tfor (var r = 0; r < rsBlocks.length; r += 1) {\n\n\t    var dcCount = rsBlocks[r].dataCount;\n\t    var ecCount = rsBlocks[r].totalCount - dcCount;\n\n\t    maxDcCount = Math.max(maxDcCount, dcCount);\n\t    maxEcCount = Math.max(maxEcCount, ecCount);\n\n\t    dcdata[r] = new Array(dcCount);\n\n\t    for (var i = 0; i < dcdata[r].length; i += 1) {\n\t\tdcdata[r][i] = 0xff & buffer.getBuffer()[i + offset];\n\t    }\n\t    offset += dcCount;\n\n\t    var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount);\n\t    var rawPoly = qrPolynomial(dcdata[r], rsPoly.getLength() - 1);\n\n\t    var modPoly = rawPoly.mod(rsPoly);\n\t    ecdata[r] = new Array(rsPoly.getLength() - 1);\n\t    for (var i = 0; i < ecdata[r].length; i += 1) {\n\t\tvar modIndex = i + modPoly.getLength() - ecdata[r].length;\n\t\tecdata[r][i] = (modIndex >= 0)? modPoly.getAt(modIndex) : 0;\n\t    }\n\t}\n\n\tvar totalCodeCount = 0;\n\tfor (var i = 0; i < rsBlocks.length; i += 1) {\n\t    totalCodeCount += rsBlocks[i].totalCount;\n\t}\n\n\tvar data = new Array(totalCodeCount);\n\tvar index = 0;\n\n\tfor (var i = 0; i < maxDcCount; i += 1) {\n\t    for (var r = 0; r < rsBlocks.length; r += 1) {\n\t\tif (i < dcdata[r].length) {\n\t\t    data[index] = dcdata[r][i];\n\t\t    index += 1;\n\t\t}\n\t    }\n\t}\n\n\tfor (var i = 0; i < maxEcCount; i += 1) {\n\t    for (var r = 0; r < rsBlocks.length; r += 1) {\n\t\tif (i < ecdata[r].length) {\n\t\t    data[index] = ecdata[r][i];\n\t\t    index += 1;\n\t\t}\n\t    }\n\t}\n\n\treturn data;\n    };\n\n    var createData = function(typeNumber, errorCorrectLevel, dataList) {\n\n\tvar rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectLevel);\n\n\tvar buffer = qrBitBuffer();\n\n\tfor (var i = 0; i < dataList.length; i += 1) {\n\t    var data = dataList[i];\n\t    buffer.put(data.getMode(), 4);\n\t    buffer.put(data.getLength(), QRUtil.getLengthInBits(data.getMode(), typeNumber) );\n\t    data.write(buffer);\n\t}\n\n\t// calc num max data.\n\tvar totalDataCount = 0;\n\tfor (var i = 0; i < rsBlocks.length; i += 1) {\n\t    totalDataCount += rsBlocks[i].dataCount;\n\t}\n\n\tif (buffer.getLengthInBits() > totalDataCount * 8) {\n\t    throw new Error('code length overflow. ('\n\t\t\t    + buffer.getLengthInBits()\n\t\t\t    + '>'\n\t\t\t    + totalDataCount * 8\n\t\t\t    + ')');\n\t}\n\n\t// end code\n\tif (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {\n\t    buffer.put(0, 4);\n\t}\n\n\t// padding\n\twhile (buffer.getLengthInBits() % 8 != 0) {\n\t    buffer.putBit(false);\n\t}\n\n\t// padding\n\twhile (true) {\n\n\t    if (buffer.getLengthInBits() >= totalDataCount * 8) {\n\t\tbreak;\n\t    }\n\t    buffer.put(PAD0, 8);\n\n\t    if (buffer.getLengthInBits() >= totalDataCount * 8) {\n\t\tbreak;\n\t    }\n\t    buffer.put(PAD1, 8);\n\t}\n\n\treturn createBytes(buffer, rsBlocks);\n    };\n\n    _this.addData = function(data) {\n\tvar newData = qr8BitByte(data);\n\t_dataList.push(newData);\n\t_dataCache = null;\n    };\n\n    _this.isDark = function(row, col) {\n\tif (row < 0 || _moduleCount <= row || col < 0 || _moduleCount <= col) {\n\t    throw new Error(row + ',' + col);\n\t}\n\treturn _modules[row][col];\n    };\n\n    _this.getModuleCount = function() {\n\treturn _moduleCount;\n    };\n\n    _this.make = function() {\n\tmakeImpl(false, getBestMaskPattern() );\n    };\n\n    _this.createTableTag = function(cellSize, margin) {\n\n\tcellSize = cellSize || 2;\n\tmargin = (typeof margin == 'undefined')? cellSize * 4 : margin;\n\n\tvar qrHtml = '';\n\n\tqrHtml += '<table style=\"';\n\tqrHtml += ' border-width: 0px; border-style: none;';\n\tqrHtml += ' border-collapse: collapse;';\n\tqrHtml += ' padding: 0px; margin: ' + margin + 'px;';\n\tqrHtml += '\">';\n\tqrHtml += '<tbody>';\n\n\tfor (var r = 0; r < _this.getModuleCount(); r += 1) {\n\n\t    qrHtml += '<tr>';\n\n\t    for (var c = 0; c < _this.getModuleCount(); c += 1) {\n\t\tqrHtml += '<td style=\"';\n\t\tqrHtml += ' border-width: 0px; border-style: none;';\n\t\tqrHtml += ' border-collapse: collapse;';\n\t\tqrHtml += ' padding: 0px; margin: 0px;';\n\t\tqrHtml += ' width: ' + cellSize + 'px;';\n\t\tqrHtml += ' height: ' + cellSize + 'px;';\n\t\tqrHtml += ' background-color: ';\n\t\tqrHtml += _this.isDark(r, c)? '#000000' : '#ffffff';\n\t\tqrHtml += ';';\n\t\tqrHtml += '\"/>';\n\t    }\n\n\t    qrHtml += '</tr>';\n\t}\n\n\tqrHtml += '</tbody>';\n\tqrHtml += '</table>';\n\n\treturn qrHtml;\n    };\n\n    _this.createImgTag = function(cellSize, margin, size) {\n\n\tcellSize = cellSize || 2;\n\tmargin = (typeof margin == 'undefined')? cellSize * 4 : margin;\n\n\tvar min = margin;\n\tvar max = _this.getModuleCount() * cellSize + margin;\n\n\treturn createImgTag(size, size, function(x, y) {\n\t    if (min <= x && x < max && min <= y && y < max) {\n\t\tvar c = Math.floor( (x - min) / cellSize);\n\t\tvar r = Math.floor( (y - min) / cellSize);\n\t\treturn _this.isDark(r, c)? 0 : 1;\n\t    } else {\n\t\treturn 1;\n\t    }\n\t} );\n    };\n\n    return _this;\n};\n\n//---------------------------------------------------------------------\n// qrcode.stringToBytes\n//---------------------------------------------------------------------\n\nqrcode.stringToBytes = function(s) {\n    var bytes = new Array();\n    for (var i = 0; i < s.length; i += 1) {\n\tvar c = s.charCodeAt(i);\n\tbytes.push(c & 0xff);\n    }\n    return bytes;\n};\n\n//---------------------------------------------------------------------\n// qrcode.createStringToBytes\n//---------------------------------------------------------------------\n\n/**\n * @param unicodeData base64 string of byte array.\n * [16bit Unicode],[16bit Bytes], ...\n * @param numChars\n */\nqrcode.createStringToBytes = function(unicodeData, numChars) {\n\n    // create conversion map.\n\n    var unicodeMap = function() {\n\n\tvar bin = base64DecodeInputStream(unicodeData);\n\tvar read = function() {\n\t    var b = bin.read();\n\t    if (b == -1) throw new Error();\n\t    return b;\n\t};\n\n\tvar count = 0;\n\tvar unicodeMap = {};\n\twhile (true) {\n\t    var b0 = bin.read();\n\t    if (b0 == -1) break;\n\t    var b1 = read();\n\t    var b2 = read();\n\t    var b3 = read();\n\t    var k = String.fromCharCode( (b0 << 8) | b1);\n\t    var v = (b2 << 8) | b3;\n\t    unicodeMap[k] = v;\n\t    count += 1;\n\t}\n\tif (count != numChars) {\n\t    throw new Error(count + ' != ' + numChars);\n\t}\n\n\treturn unicodeMap;\n    }();\n\n    var unknownChar = '?'.charCodeAt(0);\n\n    return function(s) {\n\tvar bytes = new Array();\n\tfor (var i = 0; i < s.length; i += 1) {\n\t    var c = s.charCodeAt(i);\n\t    if (c < 128) {\n\t\tbytes.push(c);\n\t    } else {\n\t\tvar b = unicodeMap[s.charAt(i)];\n\t\tif (typeof b == 'number') {\n\t\t    if ( (b & 0xff) == b) {\n\t\t\t// 1byte\n\t\t\tbytes.push(b);\n\t\t    } else {\n\t\t\t// 2bytes\n\t\t\tbytes.push(b >>> 8);\n\t\t\tbytes.push(b & 0xff);\n\t\t    }\n\t\t} else {\n\t\t    bytes.push(unknownChar);\n\t\t}\n\t    }\n\t}\n\treturn bytes;\n    };\n};\n\n//---------------------------------------------------------------------\n// QRMode\n//---------------------------------------------------------------------\n\nvar QRMode = {\n    MODE_NUMBER :\t\t1 << 0,\n    MODE_ALPHA_NUM : \t1 << 1,\n    MODE_8BIT_BYTE : \t1 << 2,\n    MODE_KANJI :\t\t1 << 3\n};\n\n//---------------------------------------------------------------------\n// QRErrorCorrectLevel\n//---------------------------------------------------------------------\n\nvar QRErrorCorrectLevel = {\n    L : 1,\n    M : 0,\n    Q : 3,\n    H : 2\n};\n\n//---------------------------------------------------------------------\n// QRMaskPattern\n//---------------------------------------------------------------------\n\nvar QRMaskPattern = {\n    PATTERN000 : 0,\n    PATTERN001 : 1,\n    PATTERN010 : 2,\n    PATTERN011 : 3,\n    PATTERN100 : 4,\n    PATTERN101 : 5,\n    PATTERN110 : 6,\n    PATTERN111 : 7\n};\n\n//---------------------------------------------------------------------\n// QRUtil\n//---------------------------------------------------------------------\n\nvar QRUtil = function() {\n\n    var PATTERN_POSITION_TABLE = [\n\t[],\n\t[6, 18],\n\t[6, 22],\n\t[6, 26],\n\t[6, 30],\n\t[6, 34],\n\t[6, 22, 38],\n\t[6, 24, 42],\n\t[6, 26, 46],\n\t[6, 28, 50],\n\t[6, 30, 54],\n\t[6, 32, 58],\n\t[6, 34, 62],\n\t[6, 26, 46, 66],\n\t[6, 26, 48, 70],\n\t[6, 26, 50, 74],\n\t[6, 30, 54, 78],\n\t[6, 30, 56, 82],\n\t[6, 30, 58, 86],\n\t[6, 34, 62, 90],\n\t[6, 28, 50, 72, 94],\n\t[6, 26, 50, 74, 98],\n\t[6, 30, 54, 78, 102],\n\t[6, 28, 54, 80, 106],\n\t[6, 32, 58, 84, 110],\n\t[6, 30, 58, 86, 114],\n\t[6, 34, 62, 90, 118],\n\t[6, 26, 50, 74, 98, 122],\n\t[6, 30, 54, 78, 102, 126],\n\t[6, 26, 52, 78, 104, 130],\n\t[6, 30, 56, 82, 108, 134],\n\t[6, 34, 60, 86, 112, 138],\n\t[6, 30, 58, 86, 114, 142],\n\t[6, 34, 62, 90, 118, 146],\n\t[6, 30, 54, 78, 102, 126, 150],\n\t[6, 24, 50, 76, 102, 128, 154],\n\t[6, 28, 54, 80, 106, 132, 158],\n\t[6, 32, 58, 84, 110, 136, 162],\n\t[6, 26, 54, 82, 110, 138, 166],\n\t[6, 30, 58, 86, 114, 142, 170]\n    ];\n    var G15 = (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0);\n    var G18 = (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0);\n    var G15_MASK = (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1);\n\n    var _this = {};\n\n    var getBCHDigit = function(data) {\n\tvar digit = 0;\n\twhile (data != 0) {\n\t    digit += 1;\n\t    data >>>= 1;\n\t}\n\treturn digit;\n    };\n\n    _this.getBCHTypeInfo = function(data) {\n\tvar d = data << 10;\n\twhile (getBCHDigit(d) - getBCHDigit(G15) >= 0) {\n\t    d ^= (G15 << (getBCHDigit(d) - getBCHDigit(G15) ) );\n\t}\n\treturn ( (data << 10) | d) ^ G15_MASK;\n    };\n\n    _this.getBCHTypeNumber = function(data) {\n\tvar d = data << 12;\n\twhile (getBCHDigit(d) - getBCHDigit(G18) >= 0) {\n\t    d ^= (G18 << (getBCHDigit(d) - getBCHDigit(G18) ) );\n\t}\n\treturn (data << 12) | d;\n    };\n\n    _this.getPatternPosition = function(typeNumber) {\n\treturn PATTERN_POSITION_TABLE[typeNumber - 1];\n    };\n\n    _this.getMaskFunction = function(maskPattern) {\n\n\tswitch (maskPattern) {\n\n\t    case QRMaskPattern.PATTERN000 :\n\t\treturn function(i, j) { return (i + j) % 2 == 0; };\n\t    case QRMaskPattern.PATTERN001 :\n\t\treturn function(i, j) { return i % 2 == 0; };\n\t    case QRMaskPattern.PATTERN010 :\n\t\treturn function(i, j) { return j % 3 == 0; };\n\t    case QRMaskPattern.PATTERN011 :\n\t\treturn function(i, j) { return (i + j) % 3 == 0; };\n\t    case QRMaskPattern.PATTERN100 :\n\t\treturn function(i, j) { return (Math.floor(i / 2) + Math.floor(j / 3) ) % 2 == 0; };\n\t    case QRMaskPattern.PATTERN101 :\n\t\treturn function(i, j) { return (i * j) % 2 + (i * j) % 3 == 0; };\n\t    case QRMaskPattern.PATTERN110 :\n\t\treturn function(i, j) { return ( (i * j) % 2 + (i * j) % 3) % 2 == 0; };\n\t    case QRMaskPattern.PATTERN111 :\n\t\treturn function(i, j) { return ( (i * j) % 3 + (i + j) % 2) % 2 == 0; };\n\n\t\tdefault :\n\t\tthrow new Error('bad maskPattern:' + maskPattern);\n\t}\n    };\n\n    _this.getErrorCorrectPolynomial = function(errorCorrectLength) {\n\tvar a = qrPolynomial([1], 0);\n\tfor (var i = 0; i < errorCorrectLength; i += 1) {\n\t    a = a.multiply(qrPolynomial([1, QRMath.gexp(i)], 0) );\n\t}\n\treturn a;\n    };\n\n    _this.getLengthInBits = function(mode, type) {\n\n\tif (1 <= type && type < 10) {\n\n\t    // 1 - 9\n\n\t    switch(mode) {\n\t\tcase QRMode.MODE_NUMBER \t: return 10;\n\t\tcase QRMode.MODE_ALPHA_NUM \t: return 9;\n\t\tcase QRMode.MODE_8BIT_BYTE\t: return 8;\n\t\tcase QRMode.MODE_KANJI\t\t: return 8;\n\t\t    default :\n\t\t    throw new Error('mode:' + mode);\n\t    }\n\n\t} else if (type < 27) {\n\n\t    // 10 - 26\n\n\t    switch(mode) {\n\t\tcase QRMode.MODE_NUMBER \t: return 12;\n\t\tcase QRMode.MODE_ALPHA_NUM \t: return 11;\n\t\tcase QRMode.MODE_8BIT_BYTE\t: return 16;\n\t\tcase QRMode.MODE_KANJI\t\t: return 10;\n\t\t    default :\n\t\t    throw new Error('mode:' + mode);\n\t    }\n\n\t} else if (type < 41) {\n\n\t    // 27 - 40\n\n\t    switch(mode) {\n\t\tcase QRMode.MODE_NUMBER \t: return 14;\n\t\tcase QRMode.MODE_ALPHA_NUM\t: return 13;\n\t\tcase QRMode.MODE_8BIT_BYTE\t: return 16;\n\t\tcase QRMode.MODE_KANJI\t\t: return 12;\n\t\t    default :\n\t\t    throw new Error('mode:' + mode);\n\t    }\n\n\t} else {\n\t    throw new Error('type:' + type);\n\t}\n    };\n\n    _this.getLostPoint = function(qrcode) {\n\n\tvar moduleCount = qrcode.getModuleCount();\n\n\tvar lostPoint = 0;\n\n\t// LEVEL1\n\n\tfor (var row = 0; row < moduleCount; row += 1) {\n\t    for (var col = 0; col < moduleCount; col += 1) {\n\n\t\tvar sameCount = 0;\n\t\tvar dark = qrcode.isDark(row, col);\n\n\t\tfor (var r = -1; r <= 1; r += 1) {\n\n\t\t    if (row + r < 0 || moduleCount <= row + r) {\n\t\t\tcontinue;\n\t\t    }\n\n\t\t    for (var c = -1; c <= 1; c += 1) {\n\n\t\t\tif (col + c < 0 || moduleCount <= col + c) {\n\t\t\t    continue;\n\t\t\t}\n\n\t\t\tif (r == 0 && c == 0) {\n\t\t\t    continue;\n\t\t\t}\n\n\t\t\tif (dark == qrcode.isDark(row + r, col + c) ) {\n\t\t\t    sameCount += 1;\n\t\t\t}\n\t\t    }\n\t\t}\n\n\t\tif (sameCount > 5) {\n\t\t    lostPoint += (3 + sameCount - 5);\n\t\t}\n\t    }\n\t};\n\n\t// LEVEL2\n\n\tfor (var row = 0; row < moduleCount - 1; row += 1) {\n\t    for (var col = 0; col < moduleCount - 1; col += 1) {\n\t\tvar count = 0;\n\t\tif (qrcode.isDark(row, col) ) count += 1;\n\t\tif (qrcode.isDark(row + 1, col) ) count += 1;\n\t\tif (qrcode.isDark(row, col + 1) ) count += 1;\n\t\tif (qrcode.isDark(row + 1, col + 1) ) count += 1;\n\t\tif (count == 0 || count == 4) {\n\t\t    lostPoint += 3;\n\t\t}\n\t    }\n\t}\n\n\t// LEVEL3\n\n\tfor (var row = 0; row < moduleCount; row += 1) {\n\t    for (var col = 0; col < moduleCount - 6; col += 1) {\n\t\tif (qrcode.isDark(row, col)\n\t\t    && !qrcode.isDark(row, col + 1)\n\t\t    &&  qrcode.isDark(row, col + 2)\n\t\t    &&  qrcode.isDark(row, col + 3)\n\t\t    &&  qrcode.isDark(row, col + 4)\n\t\t    && !qrcode.isDark(row, col + 5)\n\t\t    &&  qrcode.isDark(row, col + 6) ) {\n\t\t    lostPoint += 40;\n\t\t}\n\t    }\n\t}\n\n\tfor (var col = 0; col < moduleCount; col += 1) {\n\t    for (var row = 0; row < moduleCount - 6; row += 1) {\n\t\tif (qrcode.isDark(row, col)\n\t\t    && !qrcode.isDark(row + 1, col)\n\t\t    &&  qrcode.isDark(row + 2, col)\n\t\t    &&  qrcode.isDark(row + 3, col)\n\t\t    &&  qrcode.isDark(row + 4, col)\n\t\t    && !qrcode.isDark(row + 5, col)\n\t\t    &&  qrcode.isDark(row + 6, col) ) {\n\t\t    lostPoint += 40;\n\t\t}\n\t    }\n\t}\n\n\t// LEVEL4\n\n\tvar darkCount = 0;\n\n\tfor (var col = 0; col < moduleCount; col += 1) {\n\t    for (var row = 0; row < moduleCount; row += 1) {\n\t\tif (qrcode.isDark(row, col) ) {\n\t\t    darkCount += 1;\n\t\t}\n\t    }\n\t}\n\n\tvar ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;\n\tlostPoint += ratio * 10;\n\n\treturn lostPoint;\n    };\n\n    return _this;\n}();\n\n//---------------------------------------------------------------------\n// QRMath\n//---------------------------------------------------------------------\n\nvar QRMath = function() {\n\n    var EXP_TABLE = new Array(256);\n    var LOG_TABLE = new Array(256);\n\n    // initialize tables\n    for (var i = 0; i < 8; i += 1) {\n\tEXP_TABLE[i] = 1 << i;\n    }\n    for (var i = 8; i < 256; i += 1) {\n\tEXP_TABLE[i] = EXP_TABLE[i - 4]\n\t    ^ EXP_TABLE[i - 5]\n\t    ^ EXP_TABLE[i - 6]\n\t    ^ EXP_TABLE[i - 8];\n    }\n    for (var i = 0; i < 255; i += 1) {\n\tLOG_TABLE[EXP_TABLE[i] ] = i;\n    }\n\n    var _this = {};\n\n    _this.glog = function(n) {\n\n\tif (n < 1) {\n\t    throw new Error('glog(' + n + ')');\n\t}\n\n\treturn LOG_TABLE[n];\n    };\n\n    _this.gexp = function(n) {\n\n\twhile (n < 0) {\n\t    n += 255;\n\t}\n\n\twhile (n >= 256) {\n\t    n -= 255;\n\t}\n\n\treturn EXP_TABLE[n];\n    };\n\n    return _this;\n}();\n\n//---------------------------------------------------------------------\n// qrPolynomial\n//---------------------------------------------------------------------\n\nfunction qrPolynomial(num, shift) {\n\n    if (typeof num.length == 'undefined') {\n\tthrow new Error(num.length + '/' + shift);\n    }\n\n    var _num = function() {\n\tvar offset = 0;\n\twhile (offset < num.length && num[offset] == 0) {\n\t    offset += 1;\n\t}\n\tvar _num = new Array(num.length - offset + shift);\n\tfor (var i = 0; i < num.length - offset; i += 1) {\n\t    _num[i] = num[i + offset];\n\t}\n\treturn _num;\n    }();\n\n    var _this = {};\n\n    _this.getAt = function(index) {\n\treturn _num[index];\n    };\n\n    _this.getLength = function() {\n\treturn _num.length;\n    };\n\n    _this.multiply = function(e) {\n\n\tvar num = new Array(_this.getLength() + e.getLength() - 1);\n\n\tfor (var i = 0; i < _this.getLength(); i += 1) {\n\t    for (var j = 0; j < e.getLength(); j += 1) {\n\t\tnum[i + j] ^= QRMath.gexp(QRMath.glog(_this.getAt(i) ) + QRMath.glog(e.getAt(j) ) );\n\t    }\n\t}\n\n\treturn qrPolynomial(num, 0);\n    };\n\n    _this.mod = function(e) {\n\n\tif (_this.getLength() - e.getLength() < 0) {\n\t    return _this;\n\t}\n\n\tvar ratio = QRMath.glog(_this.getAt(0) ) - QRMath.glog(e.getAt(0) );\n\n\tvar num = new Array(_this.getLength() );\n\tfor (var i = 0; i < _this.getLength(); i += 1) {\n\t    num[i] = _this.getAt(i);\n\t}\n\n\tfor (var i = 0; i < e.getLength(); i += 1) {\n\t    num[i] ^= QRMath.gexp(QRMath.glog(e.getAt(i) ) + ratio);\n\t}\n\n\t// recursive call\n\treturn qrPolynomial(num, 0).mod(e);\n    };\n\n    return _this;\n};\n\n//---------------------------------------------------------------------\n// QRRSBlock\n//---------------------------------------------------------------------\n\nvar QRRSBlock = function() {\n\n\n    // [1: [L, M, Q, H], ..]\n    var RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]];\n\n    var qrRSBlock = function(totalCount, dataCount) {\n\tvar _this = {};\n\t_this.totalCount = totalCount;\n\t_this.dataCount = dataCount;\n\treturn _this;\n    };\n\n    var _this = {};\n\n    var getRsBlockTable = function(typeNumber, errorCorrectLevel) {\n\n\tswitch(errorCorrectLevel) {\n\t    case QRErrorCorrectLevel.L :\n\t\treturn RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];\n\t    case QRErrorCorrectLevel.M :\n\t\treturn RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];\n\t    case QRErrorCorrectLevel.Q :\n\t\treturn RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];\n\t    case QRErrorCorrectLevel.H :\n\t\treturn RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];\n\t\tdefault :\n\t\treturn undefined;\n\t}\n    };\n\n    _this.getRSBlocks = function(typeNumber, errorCorrectLevel) {\n\n\tvar rsBlock = getRsBlockTable(typeNumber, errorCorrectLevel);\n\n\tif (typeof rsBlock == 'undefined') {\n\t    throw new Error('bad rs block @ typeNumber:' + typeNumber +\n\t\t\t    '/errorCorrectLevel:' + errorCorrectLevel);\n\t}\n\n\tvar length = rsBlock.length / 3;\n\n\tvar list = new Array();\n\n\tfor (var i = 0; i < length; i += 1) {\n\n\t    var count = rsBlock[i * 3 + 0];\n\t    var totalCount = rsBlock[i * 3 + 1];\n\t    var dataCount = rsBlock[i * 3 + 2];\n\n\t    for (var j = 0; j < count; j += 1) {\n\t\tlist.push(qrRSBlock(totalCount, dataCount) );\n\t    }\n\t}\n\n\treturn list;\n    };\n\n    return _this;\n}();\n\n//---------------------------------------------------------------------\n// qrBitBuffer\n//---------------------------------------------------------------------\n\nvar qrBitBuffer = function() {\n\n    var _buffer = new Array();\n    var _length = 0;\n\n    var _this = {};\n\n    _this.getBuffer = function() {\n\treturn _buffer;\n    };\n\n    _this.getAt = function(index) {\n\tvar bufIndex = Math.floor(index / 8);\n\treturn ( (_buffer[bufIndex] >>> (7 - index % 8) ) & 1) == 1;\n    };\n\n    _this.put = function(num, length) {\n\tfor (var i = 0; i < length; i += 1) {\n\t    _this.putBit( ( (num >>> (length - i - 1) ) & 1) == 1);\n\t}\n    };\n\n    _this.getLengthInBits = function() {\n\treturn _length;\n    };\n\n    _this.putBit = function(bit) {\n\n\tvar bufIndex = Math.floor(_length / 8);\n\tif (_buffer.length <= bufIndex) {\n\t    _buffer.push(0);\n\t}\n\n\tif (bit) {\n\t    _buffer[bufIndex] |= (0x80 >>> (_length % 8) );\n\t}\n\n\t_length += 1;\n    };\n\n    return _this;\n};\n\n//---------------------------------------------------------------------\n// qr8BitByte\n//---------------------------------------------------------------------\n\nvar qr8BitByte = function(data) {\n\n    var _mode = QRMode.MODE_8BIT_BYTE;\n    var _data = data;\n    var _parsedData = [];\n\n    var _this = {};\n\n\n    // Added to support UTF-8 Characters\n    for (var i = 0, l = _data.length; i < l; i++) {\n\tvar byteArray = [];\n\tvar code = _data.charCodeAt(i);\n\n\tif (code > 0x10000) {\n\t    byteArray[0] = 0xF0 | ((code & 0x1C0000) >>> 18);\n\t    byteArray[1] = 0x80 | ((code & 0x3F000) >>> 12);\n\t    byteArray[2] = 0x80 | ((code & 0xFC0) >>> 6);\n\t    byteArray[3] = 0x80 | (code & 0x3F);\n\t} else if (code > 0x800) {\n\t    byteArray[0] = 0xE0 | ((code & 0xF000) >>> 12);\n\t    byteArray[1] = 0x80 | ((code & 0xFC0) >>> 6);\n\t    byteArray[2] = 0x80 | (code & 0x3F);\n\t} else if (code > 0x80) {\n\t    byteArray[0] = 0xC0 | ((code & 0x7C0) >>> 6);\n\t    byteArray[1] = 0x80 | (code & 0x3F);\n\t} else {\n\t    byteArray[0] = code;\n\t}\n\n        // Fix Unicode corruption bug\n        _parsedData.push(byteArray);\n    }\n\n    _parsedData = Array.prototype.concat.apply([], _parsedData);\n\n    if (_parsedData.length != _data.length) {\n\t_parsedData.unshift(191);\n\t_parsedData.unshift(187);\n\t_parsedData.unshift(239);\n    }\n\n    var _bytes = _parsedData;\n\n    _this.getMode = function() {\n\treturn _mode;\n    };\n\n    _this.getLength = function(buffer) {\n\treturn _bytes.length;\n    };\n\n    _this.write = function(buffer) {\n\tfor (var i = 0; i < _bytes.length; i += 1) {\n\t    buffer.put(_bytes[i], 8);\n\t}\n    };\n\n    return _this;\n};\n\n//=====================================================================\n// GIF Support etc.\n//\n\n//---------------------------------------------------------------------\n// byteArrayOutputStream\n//---------------------------------------------------------------------\n\nvar byteArrayOutputStream = function() {\n\n    var _bytes = new Array();\n\n    var _this = {};\n\n    _this.writeByte = function(b) {\n\t_bytes.push(b & 0xff);\n    };\n\n    _this.writeShort = function(i) {\n\t_this.writeByte(i);\n\t_this.writeByte(i >>> 8);\n    };\n\n    _this.writeBytes = function(b, off, len) {\n\toff = off || 0;\n\tlen = len || b.length;\n\tfor (var i = 0; i < len; i += 1) {\n\t    _this.writeByte(b[i + off]);\n\t}\n    };\n\n    _this.writeString = function(s) {\n\tfor (var i = 0; i < s.length; i += 1) {\n\t    _this.writeByte(s.charCodeAt(i) );\n\t}\n    };\n\n    _this.toByteArray = function() {\n\treturn _bytes;\n    };\n\n    _this.toString = function() {\n\tvar s = '';\n\ts += '[';\n\tfor (var i = 0; i < _bytes.length; i += 1) {\n\t    if (i > 0) {\n\t\ts += ',';\n\t    }\n\t    s += _bytes[i];\n\t}\n\ts += ']';\n\treturn s;\n    };\n\n    return _this;\n};\n\n//---------------------------------------------------------------------\n// base64EncodeOutputStream\n//---------------------------------------------------------------------\n\nvar base64EncodeOutputStream = function() {\n\n    var _buffer = 0;\n    var _buflen = 0;\n    var _length = 0;\n    var _base64 = '';\n\n    var _this = {};\n\n    var writeEncoded = function(b) {\n\t_base64 += String.fromCharCode(encode(b & 0x3f) );\n    };\n\n    var encode = function(n) {\n\tif (n < 0) {\n\t    // error.\n\t} else if (n < 26) {\n\t    return 0x41 + n;\n\t} else if (n < 52) {\n\t    return 0x61 + (n - 26);\n\t} else if (n < 62) {\n\t    return 0x30 + (n - 52);\n\t} else if (n == 62) {\n\t    return 0x2b;\n\t} else if (n == 63) {\n\t    return 0x2f;\n\t}\n\tthrow new Error('n:' + n);\n    };\n\n    _this.writeByte = function(n) {\n\n\t_buffer = (_buffer << 8) | (n & 0xff);\n\t_buflen += 8;\n\t_length += 1;\n\n\twhile (_buflen >= 6) {\n\t    writeEncoded(_buffer >>> (_buflen - 6) );\n\t    _buflen -= 6;\n\t}\n    };\n\n    _this.flush = function() {\n\n\tif (_buflen > 0) {\n\t    writeEncoded(_buffer << (6 - _buflen) );\n\t    _buffer = 0;\n\t    _buflen = 0;\n\t}\n\n\tif (_length % 3 != 0) {\n\t    // padding\n\t    var padlen = 3 - _length % 3;\n\t    for (var i = 0; i < padlen; i += 1) {\n\t\t_base64 += '=';\n\t    }\n\t}\n    };\n\n    _this.toString = function() {\n\treturn _base64;\n    };\n\n    return _this;\n};\n\n//---------------------------------------------------------------------\n// base64DecodeInputStream\n//---------------------------------------------------------------------\n\nvar base64DecodeInputStream = function(str) {\n\n    var _str = str;\n    var _pos = 0;\n    var _buffer = 0;\n    var _buflen = 0;\n\n    var _this = {};\n\n    _this.read = function() {\n\n\twhile (_buflen < 8) {\n\n\t    if (_pos >= _str.length) {\n\t\tif (_buflen == 0) {\n\t\t    return -1;\n\t\t}\n\t\tthrow new Error('unexpected end of file./' + _buflen);\n\t    }\n\n\t    var c = _str.charAt(_pos);\n\t    _pos += 1;\n\n\t    if (c == '=') {\n\t\t_buflen = 0;\n\t\treturn -1;\n\t    } else if (c.match(/^\\s$/) ) {\n\t\t// ignore if whitespace.\n\t\tcontinue;\n\t    }\n\n\t    _buffer = (_buffer << 6) | decode(c.charCodeAt(0) );\n\t    _buflen += 6;\n\t}\n\n\tvar n = (_buffer >>> (_buflen - 8) ) & 0xff;\n\t_buflen -= 8;\n\treturn n;\n    };\n\n    var decode = function(c) {\n\tif (0x41 <= c && c <= 0x5a) {\n\t    return c - 0x41;\n\t} else if (0x61 <= c && c <= 0x7a) {\n\t    return c - 0x61 + 26;\n\t} else if (0x30 <= c && c <= 0x39) {\n\t    return c - 0x30 + 52;\n\t} else if (c == 0x2b) {\n\t    return 62;\n\t} else if (c == 0x2f) {\n\t    return 63;\n\t} else {\n\t    throw new Error('c:' + c);\n\t}\n    };\n\n    return _this;\n};\n\n//---------------------------------------------------------------------\n// gifImage (B/W)\n//---------------------------------------------------------------------\n\nvar gifImage = function(width, height) {\n\n    var _width = width;\n    var _height = height;\n    var _data = new Array(width * height);\n\n    var _this = {};\n\n    _this.setPixel = function(x, y, pixel) {\n\t_data[y * _width + x] = pixel;\n    };\n\n    _this.write = function(out) {\n\n\t//---------------------------------\n\t// GIF Signature\n\n\tout.writeString('GIF87a');\n\n\t//---------------------------------\n\t// Screen Descriptor\n\n\tout.writeShort(_width);\n\tout.writeShort(_height);\n\n\tout.writeByte(0x80); // 2bit\n\tout.writeByte(0);\n\tout.writeByte(0);\n\n\t//---------------------------------\n\t// Global Color Map\n\n\t// black\n\tout.writeByte(0x00);\n\tout.writeByte(0x00);\n\tout.writeByte(0x00);\n\n\t// white\n\tout.writeByte(0xff);\n\tout.writeByte(0xff);\n\tout.writeByte(0xff);\n\n\t//---------------------------------\n\t// Image Descriptor\n\n\tout.writeString(',');\n\tout.writeShort(0);\n\tout.writeShort(0);\n\tout.writeShort(_width);\n\tout.writeShort(_height);\n\tout.writeByte(0);\n\n\t//---------------------------------\n\t// Local Color Map\n\n\t//---------------------------------\n\t// Raster Data\n\n\tvar lzwMinCodeSize = 2;\n\tvar raster = getLZWRaster(lzwMinCodeSize);\n\n\tout.writeByte(lzwMinCodeSize);\n\n\tvar offset = 0;\n\n\twhile (raster.length - offset > 255) {\n\t    out.writeByte(255);\n\t    out.writeBytes(raster, offset, 255);\n\t    offset += 255;\n\t}\n\n\tout.writeByte(raster.length - offset);\n\tout.writeBytes(raster, offset, raster.length - offset);\n\tout.writeByte(0x00);\n\n\t//---------------------------------\n\t// GIF Terminator\n\tout.writeString(';');\n    };\n\n    var bitOutputStream = function(out) {\n\n\tvar _out = out;\n\tvar _bitLength = 0;\n\tvar _bitBuffer = 0;\n\n\tvar _this = {};\n\n\t_this.write = function(data, length) {\n\n\t    if ( (data >>> length) != 0) {\n\t\tthrow new Error('length over');\n\t    }\n\n\t    while (_bitLength + length >= 8) {\n\t\t_out.writeByte(0xff & ( (data << _bitLength) | _bitBuffer) );\n\t\tlength -= (8 - _bitLength);\n\t\tdata >>>= (8 - _bitLength);\n\t\t_bitBuffer = 0;\n\t\t_bitLength = 0;\n\t    }\n\n\t    _bitBuffer = (data << _bitLength) | _bitBuffer;\n\t    _bitLength = _bitLength + length;\n\t};\n\n\t_this.flush = function() {\n\t    if (_bitLength > 0) {\n\t\t_out.writeByte(_bitBuffer);\n\t    }\n\t};\n\n\treturn _this;\n    };\n\n    var getLZWRaster = function(lzwMinCodeSize) {\n\n\tvar clearCode = 1 << lzwMinCodeSize;\n\tvar endCode = (1 << lzwMinCodeSize) + 1;\n\tvar bitLength = lzwMinCodeSize + 1;\n\n\t// Setup LZWTable\n\tvar table = lzwTable();\n\n\tfor (var i = 0; i < clearCode; i += 1) {\n\t    table.add(String.fromCharCode(i) );\n\t}\n\ttable.add(String.fromCharCode(clearCode) );\n\ttable.add(String.fromCharCode(endCode) );\n\n\tvar byteOut = byteArrayOutputStream();\n\tvar bitOut = bitOutputStream(byteOut);\n\n\t// clear code\n\tbitOut.write(clearCode, bitLength);\n\n\tvar dataIndex = 0;\n\n\tvar s = String.fromCharCode(_data[dataIndex]);\n\tdataIndex += 1;\n\n\twhile (dataIndex < _data.length) {\n\n\t    var c = String.fromCharCode(_data[dataIndex]);\n\t    dataIndex += 1;\n\n\t    if (table.contains(s + c) ) {\n\n\t\ts = s + c;\n\n\t    } else {\n\n\t\tbitOut.write(table.indexOf(s), bitLength);\n\n\t\tif (table.size() < 0xfff) {\n\n\t\t    if (table.size() == (1 << bitLength) ) {\n\t\t\tbitLength += 1;\n\t\t    }\n\n\t\t    table.add(s + c);\n\t\t}\n\n\t\ts = c;\n\t    }\n\t}\n\n\tbitOut.write(table.indexOf(s), bitLength);\n\n\t// end code\n\tbitOut.write(endCode, bitLength);\n\n\tbitOut.flush();\n\n\treturn byteOut.toByteArray();\n    };\n\n    var lzwTable = function() {\n\n\tvar _map = {};\n\tvar _size = 0;\n\n\tvar _this = {};\n\n\t_this.add = function(key) {\n\t    if (_this.contains(key) ) {\n\t\tthrow new Error('dup key:' + key);\n\t    }\n\t    _map[key] = _size;\n\t    _size += 1;\n\t};\n\n\t_this.size = function() {\n\t    return _size;\n\t};\n\n\t_this.indexOf = function(key) {\n\t    return _map[key];\n\t};\n\n\t_this.contains = function(key) {\n\t    return typeof _map[key] != 'undefined';\n\t};\n\n\treturn _this;\n    };\n\n    return _this;\n};\n\nvar createImgTag = function(width, height, getPixel, alt) {\n\n    var gif = gifImage(width, height);\n    for (var y = 0; y < height; y += 1) {\n\tfor (var x = 0; x < width; x += 1) {\n\t    gif.setPixel(x, y, getPixel(x, y) );\n\t}\n    }\n\n    var b = byteArrayOutputStream();\n    gif.write(b);\n\n    var base64 = base64EncodeOutputStream();\n    var bytes = b.toByteArray();\n    for (var i = 0; i < bytes.length; i += 1) {\n\tbase64.writeByte(bytes[i]);\n    }\n    base64.flush();\n\n    var img = '';\n    img += 'data:image/gif;base64,';\n    img += base64;\n\n    return img;\n};\n\n//---------------------------------------------------------------------\n// returns qrcode function.\n\nmodule.exports = qrcode;\n","type":"application/javascript","title":"$:/plugins/tiddlywiki/qrcode/qrcode.js","module-type":"library"},"$:/plugins/tiddlywiki/qrcode/license":{"text":"The MIT License (MIT)\n\nCopyright (c) 2013 Zeno Zeng\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","type":"text/plain","title":"$:/plugins/tiddlywiki/qrcode/license"},"$:/plugins/tiddlywiki/qrcode/icon":{"title":"$:/plugins/tiddlywiki/qrcode/icon","tags":"$:/tags/Image","text":"<svg class=\"tc-image-qrcode tc-image-button\" viewBox=\"0 0 128 128\" width=\"22pt\" height=\"22pt\">\n    <g fill-rule=\"evenodd\">\n        <path d=\"M0,15.9969199 C0,7.16206498 7.16987059,0 15.9969199,0 L64.0030801,0 C72.837935,0 80,7.16987059 80,15.9969199 L80,64.0030801 C80,72.837935 72.8301294,80 64.0030801,80 L15.9969199,80 C7.16206498,80 0,72.8301294 0,64.0030801 L0,15.9969199 Z M16,22.0063866 C16,18.6891509 18.6835413,16 22.0063866,16 L57.9936134,16 C61.3108491,16 64,18.6835413 64,22.0063866 L64,57.9936134 C64,61.3108491 61.3164587,64 57.9936134,64 L22.0063866,64 C18.6891509,64 16,61.3164587 16,57.9936134 L16,22.0063866 Z M28,31.990053 C28,29.7864076 29.7842933,28 31.990053,28 L48.009947,28 C50.2135924,28 52,29.7842933 52,31.990053 L52,48.009947 C52,50.2135924 50.2157067,52 48.009947,52 L31.990053,52 C29.7864076,52 28,50.2157067 28,48.009947 L28,31.990053 Z\"></path>\n        <path d=\"M112,16 L112,8.49833453 L112,6.00333095 C112,2.68778282 114.67804,0 118.003331,0 L121.996669,0 C125.312217,0 128,2.67804027 128,6.00333095 L128,8.49833453 L128,23.0016655 L128,25.9966691 C128,29.3122172 125.32196,32 121.996669,32 L119.001665,32 L104.998335,32 L102.003331,32 C98.6877828,32 96,29.3219597 96,25.9966691 L96,22.0033309 C96,18.6877828 98.6780403,16 102.003331,16 L104.998335,16 L112,16 Z\"></path>\n        <path d=\"M96,56.9983345 L96,54.0033309 C96,50.6877828 98.6780403,48 102.003331,48 L104.998335,48 L119.001665,48 L121.996669,48 C125.312217,48 128,50.6780403 128,54.0033309 L128,57.9966691 C128,61.3122172 125.32196,64 121.996669,64 L119.001665,64 L112,64 L112,71.0016655 L112,73.9966691 C112,77.3122172 109.32196,80 105.996669,80 L102.003331,80 C98.6877828,80 96,77.3219597 96,73.9966691 L96,71.0016655 L96,56.9983345 Z\"></path>\n        <path d=\"M16,112 L23.0016655,112 L24.9983345,112 L32,112 L32,104.998335 L32,102.003331 C32,98.6877828 34.6780403,96 38.0033309,96 L40.9983345,96 L55.0016655,96 L57.9966691,96 C61.3122172,96 64,98.6780403 64,102.003331 L64,105.996669 C64,109.312217 61.3219597,112 57.9966691,112 L55.0016655,112 L48,112 L48,119.001665 L48,121.996669 C48,125.312217 45.3219597,128 41.9966691,128 L39.0016655,128 L24.9983345,128 L23.0016655,128 L8.99833453,128 L6.00333095,128 C2.68778282,128 0,125.32196 0,121.996669 L0,119.001665 L0,104.998335 L0,102.003331 C0,98.6877828 2.67804027,96 6.00333095,96 L9.99666905,96 C13.3122172,96 16,98.6780403 16,102.003331 L16,104.998335 L16,112 Z\"></path>\n        <path d=\"M103.001665,96 L105.996669,96 C109.312217,96 112,98.6780403 112,102.003331 L112,105.996669 C112,109.312217 109.32196,112 105.996669,112 L103.001665,112 L88.9983345,112 L86.0033309,112 C82.6877828,112 80,109.32196 80,105.996669 L80,102.003331 C80,98.6877828 82.6780403,96 86.0033309,96 L88.9983345,96 L103.001665,96 Z\"></path>\n        <path d=\"M72.9983345,112 L70.0033309,112 C66.6780403,112 64,114.687783 64,118.003331 L64,121.996669 C64,125.32196 66.6877828,128 70.0033309,128 L72.9983345,128 L87.0016655,128 L89.9966691,128 C93.3219597,128 96,125.312217 96,121.996669 L96,118.003331 C96,114.67804 93.3122172,112 89.9966691,112 L87.0016655,112 L72.9983345,112 Z\"></path>\n        <rect x=\"112\" y=\"80\" width=\"16\" height=\"16\" rx=\"6\"></rect>\n        <rect x=\"112\" y=\"112\" width=\"16\" height=\"16\" rx=\"6\"></rect>\n    </g>\n</svg>"},"$:/plugins/tiddlywiki/qrcode/makeqr.js":{"title":"$:/plugins/tiddlywiki/qrcode/makeqr.js","text":"/*\\\ntitle: $:/plugins/tiddlywiki/qrcode/makeqr.js\ntype: application/javascript\nmodule-type: macro\n\nMacro to convert a string into a QR Code\n\n\\*/\n(function(){\n\n/*jslint node: true, browser: true */\n/*global $tw: false */\n\"use strict\";\n\n/*\nInformation about this macro\n*/\n\nvar qrcode = require(\"$:/plugins/tiddlywiki/qrcode/qrcode.js\");\n\nvar QRCODE_GENERATION_ERROR_PREFIX = '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 300 300\"><text x=\"0\" y=\"30\" fill=\"red\" font-family=\"Helvetica, sans-serif\" font-size=\"18\">',\n\tQRCODE_GENERATION_ERROR_SUFFIX = '</text></svg>';\n\nexports.name = \"makeqr\";\n\nexports.params = [\n\t{name: \"text\"},\n\t{name: \"size\"},\n\t{name: \"errorCorrectLevel\"},\n\t{name: \"fallback\"}\n];\n\n/*\nRun the macro\n*/\nexports.run = function(text,size,errorCorrectLevel,fallback) {\n\tvar result;\n\ttry {\n\t\tresult = generateQrCode(text,{size: size, errorCorrectLevel: errorCorrectLevel});\n\t} catch (ex) {\n\t\tconsole.log(\"makeqr error: \" + ex);\n\t\tresult = fallback || (\"data:image/svg+xml,\" + encodeURI(QRCODE_GENERATION_ERROR_PREFIX + ex + QRCODE_GENERATION_ERROR_SUFFIX));\n\t}\n\treturn result || \"\";\n};\n\nfunction generateQrCode(text,options) {\n\toptions = options || {};\n\tvar typeNumber = options.typeNumber || 4,\n\t\terrorCorrectLevel = options.errorCorrectLevel || \"M\",\n\t\tsize = options.size || 500,\n\t\tqr;\n\ttry {\n\t\tqr = qrcode(typeNumber,errorCorrectLevel);\n\t\tqr.addData(text);\n\t\tqr.make();\n\t} catch (e) {\n\t\tif(typeNumber >= 40) {\n\t\t\tthrow new Error(\"Text too long to encode\");\n\t\t} else {\n\t\t\treturn generateQrCode(text, {\n\t\t\t\tsize: size,\n\t\t\t\terrorCorrectLevel: errorCorrectLevel,\n\t\t\t\ttypeNumber: typeNumber + 1\n\t\t\t});\n\t\t}\n\t}\n\tvar cellsize = parseInt(size / qr.getModuleCount()),\n\t\tmargin = parseInt((size - qr.getModuleCount() * cellsize) / 2);\n\treturn qr.createImgTag(cellsize, margin, size);\n}\n\n\n})();\n","type":"application/javascript","module-type":"macro"}}}