+ */
+ serialize: function(inp) {
+ var type = HTML_AJAX_Util.getType(inp);
+ var val;
+ switch (type) {
+ case "undefined":
+ val = "N";
+ break;
+ case "boolean":
+ val = "b:" + (inp ? "1" : "0");
+ break;
+ case "number":
+ val = (Math.round(inp) == inp ? "i" : "d") + ":" + inp;
+ break;
+ case "string":
+ val = "s:" + inp.length + ":\"" + inp + "\"";
+ break;
+ case "array":
+ val = "a";
+ case "object":
+ if (type == "object") {
+ var objname = inp.constructor.toString().match(/(\w+)\(\)/);
+ if (objname == undefined) {
+ return;
+ }
+ objname[1] = this.serialize(objname[1]);
+ val = "O" + objname[1].substring(1, objname[1].length - 1);
+ }
+ var count = 0;
+ var vals = "";
+ var okey;
+ for (key in inp) {
+ okey = (key.match(/^[0-9]+$/) ? parseInt(key) : key);
+ vals += this.serialize(okey) +
+ this.serialize(inp[key]);
+ count++;
+ }
+ val += ":" + count + ":{" + vals + "}";
+ break;
+ }
+ if (type != "object" && type != "array") val += ";";
+ return val;
+ },
+ // }}}
+ // {{{ unserialize
+ /**
+ * Reconstructs a serialized variable
+ *
+ * @param string inp the string to reconstruct
+ * @return mixed the variable represented by the input string, or void on failure
+ */
+ unserialize: function(inp) {
+ this.error = 0;
+ if (inp == "" || inp.length < 2) {
+ this.raiseError("input is too short");
+ return;
+ }
+ var val, kret, vret, cval;
+ var type = inp.charAt(0);
+ var cont = inp.substring(2);
+ var size = 0, divpos = 0, endcont = 0, rest = "", next = "";
+
+ switch (type) {
+ case "N": // null
+ if (inp.charAt(1) != ";") {
+ this.raiseError("missing ; for null", cont);
+ }
+ // leave val undefined
+ rest = cont;
+ break;
+ case "b": // boolean
+ if (!/[01];/.test(cont.substring(0,2))) {
+ this.raiseError("value not 0 or 1, or missing ; for boolean", cont);
+ }
+ val = (cont.charAt(0) == "1");
+ rest = cont.substring(1);
+ break;
+ case "s": // string
+ val = "";
+ divpos = cont.indexOf(":");
+ if (divpos == -1) {
+ this.raiseError("missing : for string", cont);
+ break;
+ }
+ size = parseInt(cont.substring(0, divpos));
+ if (size == 0) {
+ if (cont.length - divpos < 4) {
+ this.raiseError("string is too short", cont);
+ break;
+ }
+ rest = cont.substring(divpos + 4);
+ break;
+ }
+ if ((cont.length - divpos - size) < 4) {
+ this.raiseError("string is too short", cont);
+ break;
+ }
+ if (cont.substring(divpos + 2 + size, divpos + 4 + size) != "\";") {
+ this.raiseError("string is too long, or missing \";", cont);
+ }
+ val = cont.substring(divpos + 2, divpos + 2 + size);
+ rest = cont.substring(divpos + 4 + size);
+ break;
+ case "i": // integer
+ case "d": // float
+ var dotfound = 0;
+ for (var i = 0; i < cont.length; i++) {
+ cval = cont.charAt(i);
+ if (isNaN(parseInt(cval)) && !(type == "d" && cval == "." && !dotfound++)) {
+ endcont = i;
+ break;
+ }
+ }
+ if (!endcont || cont.charAt(endcont) != ";") {
+ this.raiseError("missing or invalid value, or missing ; for int/float", cont);
+ }
+ val = cont.substring(0, endcont);
+ val = (type == "i" ? parseInt(val) : parseFloat(val));
+ rest = cont.substring(endcont + 1);
+ break;
+ case "a": // array
+ if (cont.length < 4) {
+ this.raiseError("array is too short", cont);
+ return;
+ }
+ divpos = cont.indexOf(":", 1);
+ if (divpos == -1) {
+ this.raiseError("missing : for array", cont);
+ return;
+ }
+ size = parseInt(cont.substring(0, divpos));
+ cont = cont.substring(divpos + 2);
+ val = new Array();
+ if (cont.length < 1) {
+ this.raiseError("array is too short", cont);
+ return;
+ }
+ for (var i = 0; i < size; i++) {
+ kret = this.unserialize(cont, 1);
+ if (this.error || kret[0] == undefined || kret[1] == "") {
+ this.raiseError("missing or invalid key, or missing value for array", cont);
+ return;
+ }
+ vret = this.unserialize(kret[1], 1);
+ if (this.error) {
+ this.raiseError("invalid value for array", cont);
+ return;
+ }
+ val[kret[0]] = vret[0];
+ cont = vret[1];
+ }
+ if (cont.charAt(0) != "}") {
+ this.raiseError("missing ending }, or too many values for array", cont);
+ return;
+ }
+ rest = cont.substring(1);
+ break;
+ case "O": // object
+ divpos = cont.indexOf(":");
+ if (divpos == -1) {
+ this.raiseError("missing : for object", cont);
+ return;
+ }
+ size = parseInt(cont.substring(0, divpos));
+ var objname = cont.substring(divpos + 2, divpos + 2 + size);
+ if (cont.substring(divpos + 2 + size, divpos + 4 + size) != "\":") {
+ this.raiseError("object name is too long, or missing \":", cont);
+ return;
+ }
+ var objprops = this.unserialize("a:" + cont.substring(divpos + 4 + size), 1);
+ if (this.error) {
+ this.raiseError("invalid object properties", cont);
+ return;
+ }
+ rest = objprops[1];
+ var objout = "function " + objname + "(){";
+ for (key in objprops[0]) {
+ objout += "this." + key + "=objprops[0]['" + key + "'];";
+ }
+ objout += "}val=new " + objname + "();";
+ eval(objout);
+ break;
+ default:
+ this.raiseError("invalid input type", cont);
+ }
+ return (arguments.length == 1 ? val : [val, rest]);
+ },
+ // }}}
+ // {{{ getError
+ /**
+ * Gets the last error message
+ *
+ * @return string the last error message from unserialize()
+ */
+ getError: function() {
+ return this.message + "\n" + this.cont;
+ },
+ // }}}
+ // {{{ raiseError
+ /**
+ * Raises an eror (called by unserialize().)
+ *
+ * @param string message the error message
+ * @param string cont the remaining unserialized content
+ */
+ raiseError: function(message, cont) {
+ this.error = 1;
+ this.message = message;
+ this.cont = cont;
+ }
+ // }}}
+}
+// }}}
+
diff --git a/utils/qrcode.js b/utils/qrcode.js
new file mode 100644
index 0000000..7f3826e
--- /dev/null
+++ b/utils/qrcode.js
@@ -0,0 +1,769 @@
+var QR = (function () {
+
+ // alignment pattern
+ var adelta = [
+ 0, 11, 15, 19, 23, 27, 31, // force 1 pat
+ 16, 18, 20, 22, 24, 26, 28, 20, 22, 24, 24, 26, 28, 28, 22, 24, 24,
+ 26, 26, 28, 28, 24, 24, 26, 26, 26, 28, 28, 24, 26, 26, 26, 28, 28
+ ];
+
+ // version block
+ var vpat = [
+ 0xc94, 0x5bc, 0xa99, 0x4d3, 0xbf6, 0x762, 0x847, 0x60d,
+ 0x928, 0xb78, 0x45d, 0xa17, 0x532, 0x9a6, 0x683, 0x8c9,
+ 0x7ec, 0xec4, 0x1e1, 0xfab, 0x08e, 0xc1a, 0x33f, 0xd75,
+ 0x250, 0x9d5, 0x6f0, 0x8ba, 0x79f, 0xb0b, 0x42e, 0xa64,
+ 0x541, 0xc69
+ ];
+
+ // final format bits with mask: level << 3 | mask
+ var fmtword = [
+ 0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976, //L
+ 0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0, //M
+ 0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed, //Q
+ 0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b //H
+ ];
+
+ // 4 per version: number of blocks 1,2; data width; ecc width
+ var eccblocks = [
+ 1, 0, 19, 7, 1, 0, 16, 10, 1, 0, 13, 13, 1, 0, 9, 17,
+ 1, 0, 34, 10, 1, 0, 28, 16, 1, 0, 22, 22, 1, 0, 16, 28,
+ 1, 0, 55, 15, 1, 0, 44, 26, 2, 0, 17, 18, 2, 0, 13, 22,
+ 1, 0, 80, 20, 2, 0, 32, 18, 2, 0, 24, 26, 4, 0, 9, 16,
+ 1, 0, 108, 26, 2, 0, 43, 24, 2, 2, 15, 18, 2, 2, 11, 22,
+ 2, 0, 68, 18, 4, 0, 27, 16, 4, 0, 19, 24, 4, 0, 15, 28,
+ 2, 0, 78, 20, 4, 0, 31, 18, 2, 4, 14, 18, 4, 1, 13, 26,
+ 2, 0, 97, 24, 2, 2, 38, 22, 4, 2, 18, 22, 4, 2, 14, 26,
+ 2, 0, 116, 30, 3, 2, 36, 22, 4, 4, 16, 20, 4, 4, 12, 24,
+ 2, 2, 68, 18, 4, 1, 43, 26, 6, 2, 19, 24, 6, 2, 15, 28,
+ 4, 0, 81, 20, 1, 4, 50, 30, 4, 4, 22, 28, 3, 8, 12, 24,
+ 2, 2, 92, 24, 6, 2, 36, 22, 4, 6, 20, 26, 7, 4, 14, 28,
+ 4, 0, 107, 26, 8, 1, 37, 22, 8, 4, 20, 24, 12, 4, 11, 22,
+ 3, 1, 115, 30, 4, 5, 40, 24, 11, 5, 16, 20, 11, 5, 12, 24,
+ 5, 1, 87, 22, 5, 5, 41, 24, 5, 7, 24, 30, 11, 7, 12, 24,
+ 5, 1, 98, 24, 7, 3, 45, 28, 15, 2, 19, 24, 3, 13, 15, 30,
+ 1, 5, 107, 28, 10, 1, 46, 28, 1, 15, 22, 28, 2, 17, 14, 28,
+ 5, 1, 120, 30, 9, 4, 43, 26, 17, 1, 22, 28, 2, 19, 14, 28,
+ 3, 4, 113, 28, 3, 11, 44, 26, 17, 4, 21, 26, 9, 16, 13, 26,
+ 3, 5, 107, 28, 3, 13, 41, 26, 15, 5, 24, 30, 15, 10, 15, 28,
+ 4, 4, 116, 28, 17, 0, 42, 26, 17, 6, 22, 28, 19, 6, 16, 30,
+ 2, 7, 111, 28, 17, 0, 46, 28, 7, 16, 24, 30, 34, 0, 13, 24,
+ 4, 5, 121, 30, 4, 14, 47, 28, 11, 14, 24, 30, 16, 14, 15, 30,
+ 6, 4, 117, 30, 6, 14, 45, 28, 11, 16, 24, 30, 30, 2, 16, 30,
+ 8, 4, 106, 26, 8, 13, 47, 28, 7, 22, 24, 30, 22, 13, 15, 30,
+ 10, 2, 114, 28, 19, 4, 46, 28, 28, 6, 22, 28, 33, 4, 16, 30,
+ 8, 4, 122, 30, 22, 3, 45, 28, 8, 26, 23, 30, 12, 28, 15, 30,
+ 3, 10, 117, 30, 3, 23, 45, 28, 4, 31, 24, 30, 11, 31, 15, 30,
+ 7, 7, 116, 30, 21, 7, 45, 28, 1, 37, 23, 30, 19, 26, 15, 30,
+ 5, 10, 115, 30, 19, 10, 47, 28, 15, 25, 24, 30, 23, 25, 15, 30,
+ 13, 3, 115, 30, 2, 29, 46, 28, 42, 1, 24, 30, 23, 28, 15, 30,
+ 17, 0, 115, 30, 10, 23, 46, 28, 10, 35, 24, 30, 19, 35, 15, 30,
+ 17, 1, 115, 30, 14, 21, 46, 28, 29, 19, 24, 30, 11, 46, 15, 30,
+ 13, 6, 115, 30, 14, 23, 46, 28, 44, 7, 24, 30, 59, 1, 16, 30,
+ 12, 7, 121, 30, 12, 26, 47, 28, 39, 14, 24, 30, 22, 41, 15, 30,
+ 6, 14, 121, 30, 6, 34, 47, 28, 46, 10, 24, 30, 2, 64, 15, 30,
+ 17, 4, 122, 30, 29, 14, 46, 28, 49, 10, 24, 30, 24, 46, 15, 30,
+ 4, 18, 122, 30, 13, 32, 46, 28, 48, 14, 24, 30, 42, 32, 15, 30,
+ 20, 4, 117, 30, 40, 7, 47, 28, 43, 22, 24, 30, 10, 67, 15, 30,
+ 19, 6, 118, 30, 18, 31, 47, 28, 34, 34, 24, 30, 20, 61, 15, 30
+ ];
+
+ // Galois field log table
+ var glog = [
+ 0xff, 0x00, 0x01, 0x19, 0x02, 0x32, 0x1a, 0xc6, 0x03, 0xdf, 0x33, 0xee, 0x1b, 0x68, 0xc7, 0x4b,
+ 0x04, 0x64, 0xe0, 0x0e, 0x34, 0x8d, 0xef, 0x81, 0x1c, 0xc1, 0x69, 0xf8, 0xc8, 0x08, 0x4c, 0x71,
+ 0x05, 0x8a, 0x65, 0x2f, 0xe1, 0x24, 0x0f, 0x21, 0x35, 0x93, 0x8e, 0xda, 0xf0, 0x12, 0x82, 0x45,
+ 0x1d, 0xb5, 0xc2, 0x7d, 0x6a, 0x27, 0xf9, 0xb9, 0xc9, 0x9a, 0x09, 0x78, 0x4d, 0xe4, 0x72, 0xa6,
+ 0x06, 0xbf, 0x8b, 0x62, 0x66, 0xdd, 0x30, 0xfd, 0xe2, 0x98, 0x25, 0xb3, 0x10, 0x91, 0x22, 0x88,
+ 0x36, 0xd0, 0x94, 0xce, 0x8f, 0x96, 0xdb, 0xbd, 0xf1, 0xd2, 0x13, 0x5c, 0x83, 0x38, 0x46, 0x40,
+ 0x1e, 0x42, 0xb6, 0xa3, 0xc3, 0x48, 0x7e, 0x6e, 0x6b, 0x3a, 0x28, 0x54, 0xfa, 0x85, 0xba, 0x3d,
+ 0xca, 0x5e, 0x9b, 0x9f, 0x0a, 0x15, 0x79, 0x2b, 0x4e, 0xd4, 0xe5, 0xac, 0x73, 0xf3, 0xa7, 0x57,
+ 0x07, 0x70, 0xc0, 0xf7, 0x8c, 0x80, 0x63, 0x0d, 0x67, 0x4a, 0xde, 0xed, 0x31, 0xc5, 0xfe, 0x18,
+ 0xe3, 0xa5, 0x99, 0x77, 0x26, 0xb8, 0xb4, 0x7c, 0x11, 0x44, 0x92, 0xd9, 0x23, 0x20, 0x89, 0x2e,
+ 0x37, 0x3f, 0xd1, 0x5b, 0x95, 0xbc, 0xcf, 0xcd, 0x90, 0x87, 0x97, 0xb2, 0xdc, 0xfc, 0xbe, 0x61,
+ 0xf2, 0x56, 0xd3, 0xab, 0x14, 0x2a, 0x5d, 0x9e, 0x84, 0x3c, 0x39, 0x53, 0x47, 0x6d, 0x41, 0xa2,
+ 0x1f, 0x2d, 0x43, 0xd8, 0xb7, 0x7b, 0xa4, 0x76, 0xc4, 0x17, 0x49, 0xec, 0x7f, 0x0c, 0x6f, 0xf6,
+ 0x6c, 0xa1, 0x3b, 0x52, 0x29, 0x9d, 0x55, 0xaa, 0xfb, 0x60, 0x86, 0xb1, 0xbb, 0xcc, 0x3e, 0x5a,
+ 0xcb, 0x59, 0x5f, 0xb0, 0x9c, 0xa9, 0xa0, 0x51, 0x0b, 0xf5, 0x16, 0xeb, 0x7a, 0x75, 0x2c, 0xd7,
+ 0x4f, 0xae, 0xd5, 0xe9, 0xe6, 0xe7, 0xad, 0xe8, 0x74, 0xd6, 0xf4, 0xea, 0xa8, 0x50, 0x58, 0xaf
+ ];
+
+ // Galios field exponent table
+ var gexp = [
+ 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1d, 0x3a, 0x74, 0xe8, 0xcd, 0x87, 0x13, 0x26,
+ 0x4c, 0x98, 0x2d, 0x5a, 0xb4, 0x75, 0xea, 0xc9, 0x8f, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0,
+ 0x9d, 0x27, 0x4e, 0x9c, 0x25, 0x4a, 0x94, 0x35, 0x6a, 0xd4, 0xb5, 0x77, 0xee, 0xc1, 0x9f, 0x23,
+ 0x46, 0x8c, 0x05, 0x0a, 0x14, 0x28, 0x50, 0xa0, 0x5d, 0xba, 0x69, 0xd2, 0xb9, 0x6f, 0xde, 0xa1,
+ 0x5f, 0xbe, 0x61, 0xc2, 0x99, 0x2f, 0x5e, 0xbc, 0x65, 0xca, 0x89, 0x0f, 0x1e, 0x3c, 0x78, 0xf0,
+ 0xfd, 0xe7, 0xd3, 0xbb, 0x6b, 0xd6, 0xb1, 0x7f, 0xfe, 0xe1, 0xdf, 0xa3, 0x5b, 0xb6, 0x71, 0xe2,
+ 0xd9, 0xaf, 0x43, 0x86, 0x11, 0x22, 0x44, 0x88, 0x0d, 0x1a, 0x34, 0x68, 0xd0, 0xbd, 0x67, 0xce,
+ 0x81, 0x1f, 0x3e, 0x7c, 0xf8, 0xed, 0xc7, 0x93, 0x3b, 0x76, 0xec, 0xc5, 0x97, 0x33, 0x66, 0xcc,
+ 0x85, 0x17, 0x2e, 0x5c, 0xb8, 0x6d, 0xda, 0xa9, 0x4f, 0x9e, 0x21, 0x42, 0x84, 0x15, 0x2a, 0x54,
+ 0xa8, 0x4d, 0x9a, 0x29, 0x52, 0xa4, 0x55, 0xaa, 0x49, 0x92, 0x39, 0x72, 0xe4, 0xd5, 0xb7, 0x73,
+ 0xe6, 0xd1, 0xbf, 0x63, 0xc6, 0x91, 0x3f, 0x7e, 0xfc, 0xe5, 0xd7, 0xb3, 0x7b, 0xf6, 0xf1, 0xff,
+ 0xe3, 0xdb, 0xab, 0x4b, 0x96, 0x31, 0x62, 0xc4, 0x95, 0x37, 0x6e, 0xdc, 0xa5, 0x57, 0xae, 0x41,
+ 0x82, 0x19, 0x32, 0x64, 0xc8, 0x8d, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0, 0xdd, 0xa7, 0x53, 0xa6,
+ 0x51, 0xa2, 0x59, 0xb2, 0x79, 0xf2, 0xf9, 0xef, 0xc3, 0x9b, 0x2b, 0x56, 0xac, 0x45, 0x8a, 0x09,
+ 0x12, 0x24, 0x48, 0x90, 0x3d, 0x7a, 0xf4, 0xf5, 0xf7, 0xf3, 0xfb, 0xeb, 0xcb, 0x8b, 0x0b, 0x16,
+ 0x2c, 0x58, 0xb0, 0x7d, 0xfa, 0xe9, 0xcf, 0x83, 0x1b, 0x36, 0x6c, 0xd8, 0xad, 0x47, 0x8e, 0x00
+ ];
+
+ // Working buffers:
+ // data input and ecc append, image working buffer, fixed part of image, run lengths for badness
+ var strinbuf = [], eccbuf = [], qrframe = [], framask = [], rlens = [];
+ // Control values - width is based on version, last 4 are from table.
+ var version, width, neccblk1, neccblk2, datablkw, eccblkwid;
+ var ecclevel = 2;
+ // set bit to indicate cell in qrframe is immutable. symmetric around diagonal
+ function setmask(x, y) {
+ var bt;
+ if (x > y) {
+ bt = x;
+ x = y;
+ y = bt;
+ }
+ // y*y = 1+3+5...
+ bt = y;
+ bt *= y;
+ bt += y;
+ bt >>= 1;
+ bt += x;
+ framask[bt] = 1;
+ }
+
+ // enter alignment pattern - black to qrframe, white to mask (later black frame merged to mask)
+ function putalign(x, y) {
+ var j;
+
+ qrframe[x + width * y] = 1;
+ for (j = -2; j < 2; j++) {
+ qrframe[(x + j) + width * (y - 2)] = 1;
+ qrframe[(x - 2) + width * (y + j + 1)] = 1;
+ qrframe[(x + 2) + width * (y + j)] = 1;
+ qrframe[(x + j + 1) + width * (y + 2)] = 1;
+ }
+ for (j = 0; j < 2; j++) {
+ setmask(x - 1, y + j);
+ setmask(x + 1, y - j);
+ setmask(x - j, y - 1);
+ setmask(x + j, y + 1);
+ }
+ }
+
+ //========================================================================
+ // Reed Solomon error correction
+ // exponentiation mod N
+ function modnn(x) {
+ while (x >= 255) {
+ x -= 255;
+ x = (x >> 8) + (x & 255);
+ }
+ return x;
+ }
+
+ var genpoly = [];
+
+ // Calculate and append ECC data to data block. Block is in strinbuf, indexes to buffers given.
+ function appendrs(data, dlen, ecbuf, eclen) {
+ var i, j, fb;
+
+ for (i = 0; i < eclen; i++)
+ strinbuf[ecbuf + i] = 0;
+ for (i = 0; i < dlen; i++) {
+ fb = glog[strinbuf[data + i] ^ strinbuf[ecbuf]];
+ if (fb != 255) /* fb term is non-zero */
+ for (j = 1; j < eclen; j++)
+ strinbuf[ecbuf + j - 1] = strinbuf[ecbuf + j] ^ gexp[modnn(fb + genpoly[eclen - j])];
+ else
+ for (j = ecbuf; j < ecbuf + eclen; j++)
+ strinbuf[j] = strinbuf[j + 1];
+ strinbuf[ecbuf + eclen - 1] = fb == 255 ? 0 : gexp[modnn(fb + genpoly[0])];
+ }
+ }
+
+ //========================================================================
+ // Frame data insert following the path rules
+
+ // check mask - since symmetrical use half.
+ function ismasked(x, y) {
+ var bt;
+ if (x > y) {
+ bt = x;
+ x = y;
+ y = bt;
+ }
+ bt = y;
+ bt += y * y;
+ bt >>= 1;
+ bt += x;
+ return framask[bt];
+ }
+
+ //========================================================================
+ // Apply the selected mask out of the 8.
+ function applymask(m) {
+ var x, y, r3x, r3y;
+
+ switch (m) {
+ case 0:
+ for (y = 0; y < width; y++)
+ for (x = 0; x < width; x++)
+ if (!((x + y) & 1) && !ismasked(x, y))
+ qrframe[x + y * width] ^= 1;
+ break;
+ case 1:
+ for (y = 0; y < width; y++)
+ for (x = 0; x < width; x++)
+ if (!(y & 1) && !ismasked(x, y))
+ qrframe[x + y * width] ^= 1;
+ break;
+ case 2:
+ for (y = 0; y < width; y++)
+ for (r3x = 0, x = 0; x < width; x++ , r3x++) {
+ if (r3x == 3)
+ r3x = 0;
+ if (!r3x && !ismasked(x, y))
+ qrframe[x + y * width] ^= 1;
+ }
+ break;
+ case 3:
+ for (r3y = 0, y = 0; y < width; y++ , r3y++) {
+ if (r3y == 3)
+ r3y = 0;
+ for (r3x = r3y, x = 0; x < width; x++ , r3x++) {
+ if (r3x == 3)
+ r3x = 0;
+ if (!r3x && !ismasked(x, y))
+ qrframe[x + y * width] ^= 1;
+ }
+ }
+ break;
+ case 4:
+ for (y = 0; y < width; y++)
+ for (r3x = 0, r3y = ((y >> 1) & 1), x = 0; x < width; x++ , r3x++) {
+ if (r3x == 3) {
+ r3x = 0;
+ r3y = !r3y;
+ }
+ if (!r3y && !ismasked(x, y))
+ qrframe[x + y * width] ^= 1;
+ }
+ break;
+ case 5:
+ for (r3y = 0, y = 0; y < width; y++ , r3y++) {
+ if (r3y == 3)
+ r3y = 0;
+ for (r3x = 0, x = 0; x < width; x++ , r3x++) {
+ if (r3x == 3)
+ r3x = 0;
+ if (!((x & y & 1) + !(!r3x | !r3y)) && !ismasked(x, y))
+ qrframe[x + y * width] ^= 1;
+ }
+ }
+ break;
+ case 6:
+ for (r3y = 0, y = 0; y < width; y++ , r3y++) {
+ if (r3y == 3)
+ r3y = 0;
+ for (r3x = 0, x = 0; x < width; x++ , r3x++) {
+ if (r3x == 3)
+ r3x = 0;
+ if (!(((x & y & 1) + (r3x && (r3x == r3y))) & 1) && !ismasked(x, y))
+ qrframe[x + y * width] ^= 1;
+ }
+ }
+ break;
+ case 7:
+ for (r3y = 0, y = 0; y < width; y++ , r3y++) {
+ if (r3y == 3)
+ r3y = 0;
+ for (r3x = 0, x = 0; x < width; x++ , r3x++) {
+ if (r3x == 3)
+ r3x = 0;
+ if (!(((r3x && (r3x == r3y)) + ((x + y) & 1)) & 1) && !ismasked(x, y))
+ qrframe[x + y * width] ^= 1;
+ }
+ }
+ break;
+ }
+ return;
+ }
+
+ // Badness coefficients.
+ var N1 = 3, N2 = 3, N3 = 40, N4 = 10;
+
+ // Using the table of the length of each run, calculate the amount of bad image
+ // - long runs or those that look like finders; called twice, once each for X and Y
+ function badruns(length) {
+ var i;
+ var runsbad = 0;
+ for (i = 0; i <= length; i++)
+ if (rlens[i] >= 5)
+ runsbad += N1 + rlens[i] - 5;
+ // BwBBBwB as in finder
+ for (i = 3; i < length - 1; i += 2)
+ if (rlens[i - 2] == rlens[i + 2]
+ && rlens[i + 2] == rlens[i - 1]
+ && rlens[i - 1] == rlens[i + 1]
+ && rlens[i - 1] * 3 == rlens[i]
+ // white around the black pattern? Not part of spec
+ && (rlens[i - 3] == 0 // beginning
+ || i + 3 > length // end
+ || rlens[i - 3] * 3 >= rlens[i] * 4 || rlens[i + 3] * 3 >= rlens[i] * 4)
+ )
+ runsbad += N3;
+ return runsbad;
+ }
+
+ // Calculate how bad the masked image is - blocks, imbalance, runs, or finders.
+ function badcheck() {
+ var x, y, h, b, b1;
+ var thisbad = 0;
+ var bw = 0;
+
+ // blocks of same color.
+ for (y = 0; y < width - 1; y++)
+ for (x = 0; x < width - 1; x++)
+ if ((qrframe[x + width * y] && qrframe[(x + 1) + width * y]
+ && qrframe[x + width * (y + 1)] && qrframe[(x + 1) + width * (y + 1)]) // all black
+ || !(qrframe[x + width * y] || qrframe[(x + 1) + width * y]
+ || qrframe[x + width * (y + 1)] || qrframe[(x + 1) + width * (y + 1)])) // all white
+ thisbad += N2;
+
+ // X runs
+ for (y = 0; y < width; y++) {
+ rlens[0] = 0;
+ for (h = b = x = 0; x < width; x++) {
+ if ((b1 = qrframe[x + width * y]) == b)
+ rlens[h]++;
+ else
+ rlens[++h] = 1;
+ b = b1;
+ bw += b ? 1 : -1;
+ }
+ thisbad += badruns(h);
+ }
+
+ // black/white imbalance
+ if (bw < 0)
+ bw = -bw;
+
+ var big = bw;
+ var count = 0;
+ big += big << 2;
+ big <<= 1;
+ while (big > width * width)
+ big -= width * width, count++;
+ thisbad += count * N4;
+
+ // Y runs
+ for (x = 0; x < width; x++) {
+ rlens[0] = 0;
+ for (h = b = y = 0; y < width; y++) {
+ if ((b1 = qrframe[x + width * y]) == b)
+ rlens[h]++;
+ else
+ rlens[++h] = 1;
+ b = b1;
+ }
+ thisbad += badruns(h);
+ }
+ return thisbad;
+ }
+
+ function genframe(instring) {
+ var x, y, k, t, v, i, j, m;
+
+ // find the smallest version that fits the string
+ t = instring.length;
+ version = 0;
+ do {
+ version++;
+ k = (ecclevel - 1) * 4 + (version - 1) * 16;
+ neccblk1 = eccblocks[k++];
+ neccblk2 = eccblocks[k++];
+ datablkw = eccblocks[k++];
+ eccblkwid = eccblocks[k];
+ k = datablkw * (neccblk1 + neccblk2) + neccblk2 - 3 + (version <= 9);
+ if (t <= k)
+ break;
+ } while (version < 40);
+
+ // FIXME - insure that it fits insted of being truncated
+ width = 17 + 4 * version;
+
+ // allocate, clear and setup data structures
+ v = datablkw + (datablkw + eccblkwid) * (neccblk1 + neccblk2) + neccblk2;
+ for (t = 0; t < v; t++)
+ eccbuf[t] = 0;
+ strinbuf = instring.slice(0);
+
+ for (t = 0; t < width * width; t++)
+ qrframe[t] = 0;
+
+ for (t = 0; t < (width * (width + 1) + 1) / 2; t++)
+ framask[t] = 0;
+
+ // insert finders - black to frame, white to mask
+ for (t = 0; t < 3; t++) {
+ k = 0;
+ y = 0;
+ if (t == 1)
+ k = (width - 7);
+ if (t == 2)
+ y = (width - 7);
+ qrframe[(y + 3) + width * (k + 3)] = 1;
+ for (x = 0; x < 6; x++) {
+ qrframe[(y + x) + width * k] = 1;
+ qrframe[y + width * (k + x + 1)] = 1;
+ qrframe[(y + 6) + width * (k + x)] = 1;
+ qrframe[(y + x + 1) + width * (k + 6)] = 1;
+ }
+ for (x = 1; x < 5; x++) {
+ setmask(y + x, k + 1);
+ setmask(y + 1, k + x + 1);
+ setmask(y + 5, k + x);
+ setmask(y + x + 1, k + 5);
+ }
+ for (x = 2; x < 4; x++) {
+ qrframe[(y + x) + width * (k + 2)] = 1;
+ qrframe[(y + 2) + width * (k + x + 1)] = 1;
+ qrframe[(y + 4) + width * (k + x)] = 1;
+ qrframe[(y + x + 1) + width * (k + 4)] = 1;
+ }
+ }
+
+ // alignment blocks
+ if (version > 1) {
+ t = adelta[version];
+ y = width - 7;
+ for (; ;) {
+ x = width - 7;
+ while (x > t - 3) {
+ putalign(x, y);
+ if (x < t)
+ break;
+ x -= t;
+ }
+ if (y <= t + 9)
+ break;
+ y -= t;
+ putalign(6, y);
+ putalign(y, 6);
+ }
+ }
+
+ // single black
+ qrframe[8 + width * (width - 8)] = 1;
+
+ // timing gap - mask only
+ for (y = 0; y < 7; y++) {
+ setmask(7, y);
+ setmask(width - 8, y);
+ setmask(7, y + width - 7);
+ }
+ for (x = 0; x < 8; x++) {
+ setmask(x, 7);
+ setmask(x + width - 8, 7);
+ setmask(x, width - 8);
+ }
+
+ // reserve mask-format area
+ for (x = 0; x < 9; x++)
+ setmask(x, 8);
+ for (x = 0; x < 8; x++) {
+ setmask(x + width - 8, 8);
+ setmask(8, x);
+ }
+ for (y = 0; y < 7; y++)
+ setmask(8, y + width - 7);
+
+ // timing row/col
+ for (x = 0; x < width - 14; x++)
+ if (x & 1) {
+ setmask(8 + x, 6);
+ setmask(6, 8 + x);
+ }
+ else {
+ qrframe[(8 + x) + width * 6] = 1;
+ qrframe[6 + width * (8 + x)] = 1;
+ }
+
+ // version block
+ if (version > 6) {
+ t = vpat[version - 7];
+ k = 17;
+ for (x = 0; x < 6; x++)
+ for (y = 0; y < 3; y++ , k--)
+ if (1 & (k > 11 ? version >> (k - 12) : t >> k)) {
+ qrframe[(5 - x) + width * (2 - y + width - 11)] = 1;
+ qrframe[(2 - y + width - 11) + width * (5 - x)] = 1;
+ }
+ else {
+ setmask(5 - x, 2 - y + width - 11);
+ setmask(2 - y + width - 11, 5 - x);
+ }
+ }
+
+ // sync mask bits - only set above for white spaces, so add in black bits
+ for (y = 0; y < width; y++)
+ for (x = 0; x <= y; x++)
+ if (qrframe[x + width * y])
+ setmask(x, y);
+
+ // convert string to bitstream
+ // 8 bit data to QR-coded 8 bit data (numeric or alphanum, or kanji not supported)
+ v = strinbuf.length;
+
+ // string to array
+ for (i = 0; i < v; i++)
+ eccbuf[i] = strinbuf.charCodeAt(i);
+ strinbuf = eccbuf.slice(0);
+
+ // calculate max string length
+ x = datablkw * (neccblk1 + neccblk2) + neccblk2;
+ if (v >= x - 2) {
+ v = x - 2;
+ if (version > 9)
+ v--;
+ }
+
+ // shift and repack to insert length prefix
+ i = v;
+ if (version > 9) {
+ strinbuf[i + 2] = 0;
+ strinbuf[i + 3] = 0;
+ while (i--) {
+ t = strinbuf[i];
+ strinbuf[i + 3] |= 255 & (t << 4);
+ strinbuf[i + 2] = t >> 4;
+ }
+ strinbuf[2] |= 255 & (v << 4);
+ strinbuf[1] = v >> 4;
+ strinbuf[0] = 0x40 | (v >> 12);
+ }
+ else {
+ strinbuf[i + 1] = 0;
+ strinbuf[i + 2] = 0;
+ while (i--) {
+ t = strinbuf[i];
+ strinbuf[i + 2] |= 255 & (t << 4);
+ strinbuf[i + 1] = t >> 4;
+ }
+ strinbuf[1] |= 255 & (v << 4);
+ strinbuf[0] = 0x40 | (v >> 4);
+ }
+ // fill to end with pad pattern
+ i = v + 3 - (version < 10);
+ while (i < x) {
+ strinbuf[i++] = 0xec;
+ // buffer has room if (i == x) break;
+ strinbuf[i++] = 0x11;
+ }
+
+ // calculate and append ECC
+
+ // calculate generator polynomial
+ genpoly[0] = 1;
+ for (i = 0; i < eccblkwid; i++) {
+ genpoly[i + 1] = 1;
+ for (j = i; j > 0; j--)
+ genpoly[j] = genpoly[j]
+ ? genpoly[j - 1] ^ gexp[modnn(glog[genpoly[j]] + i)] : genpoly[j - 1];
+ genpoly[0] = gexp[modnn(glog[genpoly[0]] + i)];
+ }
+ for (i = 0; i <= eccblkwid; i++)
+ genpoly[i] = glog[genpoly[i]]; // use logs for genpoly[] to save calc step
+
+ // append ecc to data buffer
+ k = x;
+ y = 0;
+ for (i = 0; i < neccblk1; i++) {
+ appendrs(y, datablkw, k, eccblkwid);
+ y += datablkw;
+ k += eccblkwid;
+ }
+ for (i = 0; i < neccblk2; i++) {
+ appendrs(y, datablkw + 1, k, eccblkwid);
+ y += datablkw + 1;
+ k += eccblkwid;
+ }
+ // interleave blocks
+ y = 0;
+ for (i = 0; i < datablkw; i++) {
+ for (j = 0; j < neccblk1; j++)
+ eccbuf[y++] = strinbuf[i + j * datablkw];
+ for (j = 0; j < neccblk2; j++)
+ eccbuf[y++] = strinbuf[(neccblk1 * datablkw) + i + (j * (datablkw + 1))];
+ }
+ for (j = 0; j < neccblk2; j++)
+ eccbuf[y++] = strinbuf[(neccblk1 * datablkw) + i + (j * (datablkw + 1))];
+ for (i = 0; i < eccblkwid; i++)
+ for (j = 0; j < neccblk1 + neccblk2; j++)
+ eccbuf[y++] = strinbuf[x + i + j * eccblkwid];
+ strinbuf = eccbuf;
+
+ // pack bits into frame avoiding masked area.
+ x = y = width - 1;
+ k = v = 1; // up, minus
+ /* inteleaved data and ecc codes */
+ m = (datablkw + eccblkwid) * (neccblk1 + neccblk2) + neccblk2;
+ for (i = 0; i < m; i++) {
+ t = strinbuf[i];
+ for (j = 0; j < 8; j++ , t <<= 1) {
+ if (0x80 & t)
+ qrframe[x + width * y] = 1;
+ do { // find next fill position
+ if (v)
+ x--;
+ else {
+ x++;
+ if (k) {
+ if (y != 0)
+ y--;
+ else {
+ x -= 2;
+ k = !k;
+ if (x == 6) {
+ x--;
+ y = 9;
+ }
+ }
+ }
+ else {
+ if (y != width - 1)
+ y++;
+ else {
+ x -= 2;
+ k = !k;
+ if (x == 6) {
+ x--;
+ y -= 8;
+ }
+ }
+ }
+ }
+ v = !v;
+ } while (ismasked(x, y));
+ }
+ }
+
+ // save pre-mask copy of frame
+ strinbuf = qrframe.slice(0);
+ t = 0; // best
+ y = 30000; // demerit
+ // for instead of while since in original arduino code
+ // if an early mask was "good enough" it wouldn't try for a better one
+ // since they get more complex and take longer.
+ for (k = 0; k < 8; k++) {
+ applymask(k); // returns black-white imbalance
+ x = badcheck();
+ if (x < y) { // current mask better than previous best?
+ y = x;
+ t = k;
+ }
+ if (t == 7)
+ break; // don't increment i to a void redoing mask
+ qrframe = strinbuf.slice(0); // reset for next pass
+ }
+ if (t != k) // redo best mask - none good enough, last wasn't t
+ applymask(t);
+
+ // add in final mask/ecclevel bytes
+ y = fmtword[t + ((ecclevel - 1) << 3)];
+ // low byte
+ for (k = 0; k < 8; k++ , y >>= 1)
+ if (y & 1) {
+ qrframe[(width - 1 - k) + width * 8] = 1;
+ if (k < 6)
+ qrframe[8 + width * k] = 1;
+ else
+ qrframe[8 + width * (k + 1)] = 1;
+ }
+ // high byte
+ for (k = 0; k < 7; k++ , y >>= 1)
+ if (y & 1) {
+ qrframe[8 + width * (width - 7 + k)] = 1;
+ if (k)
+ qrframe[(6 - k) + width * 8] = 1;
+ else
+ qrframe[7 + width * 8] = 1;
+ }
+
+ // return image
+ return qrframe;
+ }
+
+ var _canvas = null,
+ _size = null;
+
+ var api = {
+
+ get ecclevel() {
+ return ecclevel;
+ },
+
+ set ecclevel(val) {
+ ecclevel = val;
+ },
+
+ get size() {
+ return _size;
+ },
+
+ set size(val) {
+ _size = val
+ },
+
+ get canvas() {
+ return _canvas;
+ },
+
+ set canvas(el) {
+ _canvas = el;
+ },
+
+ getFrame: function (string) {
+ return genframe(string);
+ },
+
+ draw: function (string, canvas, size, ecc) {
+
+ ecclevel = ecc || ecclevel;
+ canvas = canvas || _canvas;
+
+ if (!canvas) {
+ console.warn('No canvas provided to draw QR code in!')
+ return;
+ }
+
+ size = size || _size || Math.min(canvas.width, canvas.height);
+
+ var frame = genframe(string),
+ ctx = canvas.ctx,
+ px = Math.round(size / (width + 8));
+
+ var roundedSize = px * (width + 8),
+ offset = Math.floor((size - roundedSize) / 2);
+
+ size = roundedSize;
+
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.setFillStyle('#000000');
+
+ for (var i = 0; i < width; i++) {
+ for (var j = 0; j < width; j++) {
+ if (frame[j * width + i]) {
+ ctx.fillRect(px * (4 + i) + offset, px * (4 + j) + offset, px, px);
+ }
+ }
+ }
+ ctx.draw();
+ }
+ }
+
+ module.exports = {
+ api: api
+ }
+
+})()
\ No newline at end of file
diff --git a/utils/regions/Regions.js b/utils/regions/Regions.js
new file mode 100644
index 0000000..d0f824d
--- /dev/null
+++ b/utils/regions/Regions.js
@@ -0,0 +1,77 @@
+function e(e, t, s) {
+ return t in e ? Object.defineProperty(e, t, {
+ value: s,
+ enumerable: !0,
+ configurable: !0,
+ writable: !0
+ }) : e[t] = s, e;
+}
+
+function t(e, t) {
+ if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
+}
+
+Object.defineProperty(exports, "__esModule", {
+ value: !0
+});
+var s = function() {
+ function e(e, t) {
+ for (var s = 0; s < t.length; s++) {
+ var a = t[s];
+ a.enumerable = a.enumerable || !1, a.configurable = !0, "value" in a && (a.writable = !0),
+ Object.defineProperty(e, a.key, a);
+ }
+ }
+ return function(t, s, a) {
+ return s && e(t.prototype, s), a && e(t, a), t;
+ };
+}(), a = function() {
+ function a(s, i, n) {
+ t(this, a), this.page = s, this.options = n, this.address = {}, this.currentArea = 0;
+ var r = this;
+ this.page.openRegionsModal = function(e) {
+ r.openRegionsModal(e);
+ }, this.page.closeRegionsModal = function() {
+ r.closeRegionsModal();
+ }, this.dataName = i, this.page.setData(e({}, i, {}));
+ }
+ return s(a, [ {
+ key: "openRegionsModal",
+ value: function(t) {
+ var s = this, a = t.currentTarget.dataset.id, i = t.currentTarget.dataset.name;
+ isNaN(parseInt(a)) || !parseInt(a) ? (a = 0, this.currentArea = 0) : (0 == this.currentArea ? (this.address.province_name = i,
+ this.address.province = a, this.address.city_name = "", this.address.city = 0, this.address.district_name = "",
+ this.address.district = 0, this.address.twon_name = "", this.address.twon = 0) : 1 == this.currentArea ? (this.address.city_name = i,
+ this.address.city = a) : 2 == this.currentArea ? (this.address.district_name = i,
+ this.address.district = a) : 3 == this.currentArea && (this.address.twon_name = i,
+ this.address.twon = a), this.currentArea++), "function" == typeof this.options.selectCall && this.options.selectCall(t, a, i, this.address),
+ this.currentArea !== this.options.endAreaLevel ?
+ getApp().request.get("/api/weshop/region/page", {
+ data: {
+ parent_id: a,
+ pageSize:1000
+ },
+ success: function(t) {
+ t.data.data.pageData && t.data.data.pageData.length > 0 ? s.page.setData(e({}, s.dataName, {
+ regions: t.data.data.pageData,
+ showRegionsModal: !0
+ })) : s.endCall(a, i);
+ }
+ }) : this.endCall(a, i);
+ }
+ }, {
+ key: "closeRegionsModal",
+ value: function() {
+ this.page.setData(e({}, this.dataName, {
+ showCategoryModal: !1
+ }));
+ }
+ }, {
+ key: "endCall",
+ value: function(e, t) {
+ this.closeRegionsModal(), "function" == typeof this.options.endAreaLevelCall && this.options.endAreaLevelCall(e, t, this.address);
+ }
+ } ]), a;
+}();
+
+exports.default = a;
\ No newline at end of file
diff --git a/utils/regions/regions.wxml b/utils/regions/regions.wxml
new file mode 100644
index 0000000..9566a09
--- /dev/null
+++ b/utils/regions/regions.wxml
@@ -0,0 +1,8 @@
+
+
+
+
+ {{item.name}}
+
+
+
diff --git a/utils/regions/regions.wxss b/utils/regions/regions.wxss
new file mode 100644
index 0000000..3946540
--- /dev/null
+++ b/utils/regions/regions.wxss
@@ -0,0 +1,19 @@
+.regions {
+ z-index: 20;
+ position: fixed;
+ top: 0;
+ bottom: 0;
+ right: 0;
+ left: 100rpx;
+ overflow-x: hidden;
+ font-size: 28rpx;
+ color: #afafaf;
+ background-color: white;
+ padding: 0 25rpx;
+ color: #444;
+}
+
+.region {
+ line-height: 84rpx;
+ border-bottom: 1rpx solid #e8ecf1;
+}
diff --git a/utils/request.js b/utils/request.js
new file mode 100644
index 0000000..351a1be
--- /dev/null
+++ b/utils/request.js
@@ -0,0 +1,204 @@
+var t = require("util.js");
+
+module.exports = {
+ uniqueId: "",
+ request: function(e, i, o) {
+ var n = this, a = o.header ? o.header : {
+ "content-type": "application/x-www-form-urlencoded"
+ //"content-type": "application/texts"
+ }, s = "GET" != (e = e.toUpperCase()) && o.data ? t.json2Form(o.data) : o.data;
+ i = this.modifyUrl(i, o), o.isShowLoading = void 0 === o.isShowLoading || o.isShowLoading,
+ o.isShowLoading && this.showLoading(), console.log("app.request", i, o), wx.request(Object.assign({}, o, {
+ url: i,
+ method: e,
+ data: s,
+ header: a,
+ success: function(t) {
+ o.isShowLoading && n.hideLoading(), n.doSuccess(o, t);
+ },
+ fail: function(t) {
+ o.isShowLoading && n.hideLoading(), n.doFail(o, t);
+ }
+ }));
+ },
+ get: function (t, e) {
+ this.request("GET", t, e);
+ },
+ post: function (t, e) {
+ this.request("POST", t, e);
+ },
+ delete: function (t, e) {
+ this.request("DELETE", t, e);
+ },
+ put: function (t, e) {
+ this.request("PUT", t, e);
+ },
+
+
+ uploadFile: function(t, e) {
+ var i = this;
+ t = this.modifyUrl(t, e), console.log("app.request", t, e), e.isShowLoading = void 0 === e.isShowLoading || e.isShowLoading,
+ e.isShowLoading && this.showLoading(), wx.uploadFile(Object.assign({}, e, {
+ url: t,
+ filePath: e.filePath,
+ name: e.name,
+ success: function(t) {
+ i.hideLoading(), console.log("app.request", t), t.data = JSON.parse(i.filterJsonData(t.data)),
+ i.doSuccess(e, t);
+ },
+ fail: function(t) {
+ i.hideLoading(), i.doFail(e, t);
+ }
+ }));
+ },
+
+ doSuccess: function(t, e) {
+ if (console.log("app.request", e), 1 != t.successReload) {
+ if (200 != e.statusCode) return this.showError("请求出错[" + e.statusCode + "]", t),
+ !1;
+
+ if(e.data.status!=undefined){
+ if (1 != e.data.status) {
+ if ("function" == typeof t.failStatus && 0 == t.failStatus(e)) return !1;
+ if (-100 == e.data.status || -101 == e.data.status || -102 == e.data.status) {
+ var i = getApp();
+ return i.auth.clearAuth(), i.showWarning("正在重新登录", function() {
+ var t = getCurrentPages();
+ "pages/user/index/index" != t[t.length - 1].route ? wx.switchTab({
+ url: "/pages/user/index/index"
+ }) : wx.switchTab({
+ url: "/pages/index/index/index"
+ });
+ }, null, !0), !1;
+ }
+ var o = "string" == typeof e.data.msg ? e.data.msg : "数据格式错误";
+ return this.showError(o, t), !1;
+ }
+ }
+ "function" == typeof t.success && t.success(e);
+ } else "function" == typeof t.success && t.success(e);
+ },
+ doFail: function(t, e) {
+ if (console.log("app.request", e), "function" == typeof t.fail && 0 == t.fail(e)) return !1;
+ this.showError("请求失败", t);
+ },
+ filterJsonData: function(t) {
+ for (var e = t, i = 0; i < t.length && (e = t.substr(i), "{" != t.charAt(i)); i++) ;
+ return e;
+ },
+ modifyUrl: function(t, e) {
+ if (void 0 === e && (e = {}), 0 != t.indexOf("http") && ("string" == typeof e.baseUrl ? t = e.baseUrl + t : void 0 === e.baseUrl && (t = getApp().globalData.setting.url + t)),
+ "boolean" == typeof e.notAuthParam && 1 == e.notAuthParam) return t;
+ //var i = "is_json=1&unique_id=" + this.getUniqueId() + "&token=" + this.getToken();
+ return t += (t.indexOf("?") > 0 ? "&" : "?");// + i;
+ },
+
+ modifyUrl2: function (t, e) {
+ if (void 0 === e && (e = {}), 0 != t.indexOf("http") && ("string" == typeof e.baseUrl ? t = e.baseUrl + t : void 0 === e.baseUrl && (t = getApp().globalData.setting.hurl + t)),
+ "boolean" == typeof e.notAuthParam && 1 == e.notAuthParam) return t;
+ //var i = "is_json=1&unique_id=" + this.getUniqueId() + "&token=" + this.getToken();
+ return t += (t.indexOf("?") > 0 ? "&" : "?");// + i;
+ },
+
+
+ getToken: function() {
+ var t = getApp();
+ return null == t.globalData.userInfo ? "" : t.globalData.userInfo.token;
+ },
+ getUniqueId: function() {
+ return this.uniqueId ? this.uniqueId : (this.uniqueId = "miniapp" + t.randomString(17),
+ this.uniqueId);
+ },
+ showLoading: function() {
+ wx.showLoading({
+ title: "加载中"
+ });
+ },
+ hideLoading: function() {
+ wx.hideLoading();
+ },
+ showError: function(t, e) {
+ wx.showModal({
+ title: t,
+ showCancel: !1,
+ complete: function() {
+ 1 == e.failRollback && wx.navigateBack();
+ }
+ });
+ },
+
+ request2: function (e, i, o) {
+ var n = this, a = o.header ? o.header : {
+ "content-type": "application/x-www-form-urlencoded"
+ }, s = "GET" != (e = e.toUpperCase()) && o.data ? t.json2Form(o.data) : o.data;
+ i = this.modifyUrl2(i, o), o.isShowLoading = void 0 === o.isShowLoading || o.isShowLoading,
+ o.isShowLoading && this.showLoading(), console.log("app.request", i, o), wx.request(Object.assign({}, o, {
+ url: i,
+ method: e,
+ data: s,
+ header: a,
+ success: function (t) {
+ o.isShowLoading && n.hideLoading(), n.doSuccess2(o, t);
+ },
+ fail: function (t) {
+ o.isShowLoading && n.hideLoading(), n.doFail(o, t);
+ }
+ }));
+ },
+ get2: function (t, e) {
+ this.request2("GET", t, e);
+ },
+ doSuccess2: function (t, e){
+ if (console.log("app.request", e), 1 != t.successReload) {
+ if (200 != e.statusCode) return this.showError("请求出错[" + e.statusCode + "]", t),
+ !1;
+ if (0 != e.data.code) {
+ if ("function" == typeof t.failStatus && 0 == t.failStatus(e)) return !1;
+ var o = "string" == typeof e.data.msg ? e.data.msg : "数据格式错误";
+ return this.showError(o, t), !1;
+ }
+ "function" == typeof t.success && t.success(e);
+ } else "function" == typeof t.success && t.success(e);
+ },
+
+ //---promise的使用get----
+ promiseGet:function(url,data){
+ var th=this;
+ if(url.indexOf("http")==-1) url=getApp().globalData.setting.url +url;
+ return new Promise((resolve, reject) => {
+ data.isShowLoading && th.showLoading();
+ wx.request({
+ url,
+ method: 'GET',
+ header: {"content-type": "application/x-www-form-urlencoded" },
+ data:data.data,
+ success(res) {
+ data.isShowLoading && th.hideLoading();
+ resolve(res);
+ },
+ fail(err) { data.isShowLoading && th.hideLoading(); reject(err); }
+ })
+ })
+ },
+
+ //---promise的使用get----
+ promisePost:function(url,data){
+ var th=this;
+ if(url.indexOf("http")==-1) url=getApp().globalData.setting.url +url;
+ return new Promise((resolve, reject) => {
+ data.isShowLoading && th.showLoading();
+ wx.request({
+ url,
+ method: 'POST',
+ header: {"content-type": "application/x-www-form-urlencoded" },
+ data:data.data,
+ success(res) {
+ data.isShowLoading && th.hideLoading();
+ resolve(res);
+ },
+ fail(err) { data.isShowLoading && th.hideLoading(); reject(err); }
+ })
+ })
+ }
+
+};
\ No newline at end of file
diff --git a/utils/runtime.js b/utils/runtime.js
new file mode 100644
index 0000000..51056c6
--- /dev/null
+++ b/utils/runtime.js
@@ -0,0 +1,710 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+var regeneratorRuntime = (function (exports) {
+ "use strict";
+
+ var Op = Object.prototype;
+ var hasOwn = Op.hasOwnProperty;
+ var undefined; // More compressible than void 0.
+ var $Symbol = typeof Symbol === "function" ? Symbol : {};
+ var iteratorSymbol = $Symbol.iterator || "@@iterator";
+ var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
+ var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
+
+ function wrap(innerFn, outerFn, self, tryLocsList) {
+ // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
+ var generator = Object.create(protoGenerator.prototype);
+ var context = new Context(tryLocsList || []);
+
+ // The ._invoke method unifies the implementations of the .next,
+ // .throw, and .return methods.
+ generator._invoke = makeInvokeMethod(innerFn, self, context);
+
+ return generator;
+ }
+ exports.wrap = wrap;
+
+ // Try/catch helper to minimize deoptimizations. Returns a completion
+ // record like context.tryEntries[i].completion. This interface could
+ // have been (and was previously) designed to take a closure to be
+ // invoked without arguments, but in all the cases we care about we
+ // already have an existing method we want to call, so there's no need
+ // to create a new function object. We can even get away with assuming
+ // the method takes exactly one argument, since that happens to be true
+ // in every case, so we don't have to touch the arguments object. The
+ // only additional allocation required is the completion record, which
+ // has a stable shape and so hopefully should be cheap to allocate.
+ function tryCatch(fn, obj, arg) {
+ try {
+ return { type: "normal", arg: fn.call(obj, arg) };
+ } catch (err) {
+ return { type: "throw", arg: err };
+ }
+ }
+
+ var GenStateSuspendedStart = "suspendedStart";
+ var GenStateSuspendedYield = "suspendedYield";
+ var GenStateExecuting = "executing";
+ var GenStateCompleted = "completed";
+
+ // Returning this object from the innerFn has the same effect as
+ // breaking out of the dispatch switch statement.
+ var ContinueSentinel = {};
+
+ // Dummy constructor functions that we use as the .constructor and
+ // .constructor.prototype properties for functions that return Generator
+ // objects. For full spec compliance, you may wish to configure your
+ // minifier not to mangle the names of these two functions.
+ function Generator() {}
+ function GeneratorFunction() {}
+ function GeneratorFunctionPrototype() {}
+
+ // This is a polyfill for %IteratorPrototype% for environments that
+ // don't natively support it.
+ var IteratorPrototype = {};
+ IteratorPrototype[iteratorSymbol] = function () {
+ return this;
+ };
+
+ var getProto = Object.getPrototypeOf;
+ var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
+ if (NativeIteratorPrototype &&
+ NativeIteratorPrototype !== Op &&
+ hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
+ // This environment has a native %IteratorPrototype%; use it instead
+ // of the polyfill.
+ IteratorPrototype = NativeIteratorPrototype;
+ }
+
+ var Gp = GeneratorFunctionPrototype.prototype =
+ Generator.prototype = Object.create(IteratorPrototype);
+ GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
+ GeneratorFunctionPrototype.constructor = GeneratorFunction;
+ GeneratorFunctionPrototype[toStringTagSymbol] =
+ GeneratorFunction.displayName = "GeneratorFunction";
+
+ // Helper for defining the .next, .throw, and .return methods of the
+ // Iterator interface in terms of a single ._invoke method.
+ function defineIteratorMethods(prototype) {
+ ["next", "throw", "return"].forEach(function(method) {
+ prototype[method] = function(arg) {
+ return this._invoke(method, arg);
+ };
+ });
+ }
+
+ exports.isGeneratorFunction = function(genFun) {
+ var ctor = typeof genFun === "function" && genFun.constructor;
+ return ctor
+ ? ctor === GeneratorFunction ||
+ // For the native GeneratorFunction constructor, the best we can
+ // do is to check its .name property.
+ (ctor.displayName || ctor.name) === "GeneratorFunction"
+ : false;
+ };
+
+ exports.mark = function(genFun) {
+ if (Object.setPrototypeOf) {
+ Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
+ } else {
+ genFun.__proto__ = GeneratorFunctionPrototype;
+ if (!(toStringTagSymbol in genFun)) {
+ genFun[toStringTagSymbol] = "GeneratorFunction";
+ }
+ }
+ genFun.prototype = Object.create(Gp);
+ return genFun;
+ };
+
+ // Within the body of any async function, `await x` is transformed to
+ // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
+ // `hasOwn.call(value, "__await")` to determine if the yielded value is
+ // meant to be awaited.
+ exports.awrap = function(arg) {
+ return { __await: arg };
+ };
+
+ function AsyncIterator(generator) {
+ function invoke(method, arg, resolve, reject) {
+ var record = tryCatch(generator[method], generator, arg);
+ if (record.type === "throw") {
+ reject(record.arg);
+ } else {
+ var result = record.arg;
+ var value = result.value;
+ if (value &&
+ typeof value === "object" &&
+ hasOwn.call(value, "__await")) {
+ return Promise.resolve(value.__await).then(function(value) {
+ invoke("next", value, resolve, reject);
+ }, function(err) {
+ invoke("throw", err, resolve, reject);
+ });
+ }
+
+ return Promise.resolve(value).then(function(unwrapped) {
+ // When a yielded Promise is resolved, its final value becomes
+ // the .value of the Promise<{value,done}> result for the
+ // current iteration.
+ result.value = unwrapped;
+ resolve(result);
+ }, function(error) {
+ // If a rejected Promise was yielded, throw the rejection back
+ // into the async generator function so it can be handled there.
+ return invoke("throw", error, resolve, reject);
+ });
+ }
+ }
+
+ var previousPromise;
+
+ function enqueue(method, arg) {
+ function callInvokeWithMethodAndArg() {
+ return new Promise(function(resolve, reject) {
+ invoke(method, arg, resolve, reject);
+ });
+ }
+
+ return previousPromise =
+ // If enqueue has been called before, then we want to wait until
+ // all previous Promises have been resolved before calling invoke,
+ // so that results are always delivered in the correct order. If
+ // enqueue has not been called before, then it is important to
+ // call invoke immediately, without waiting on a callback to fire,
+ // so that the async generator function has the opportunity to do
+ // any necessary setup in a predictable way. This predictability
+ // is why the Promise constructor synchronously invokes its
+ // executor callback, and why async functions synchronously
+ // execute code before the first await. Since we implement simple
+ // async functions in terms of async generators, it is especially
+ // important to get this right, even though it requires care.
+ previousPromise ? previousPromise.then(
+ callInvokeWithMethodAndArg,
+ // Avoid propagating failures to Promises returned by later
+ // invocations of the iterator.
+ callInvokeWithMethodAndArg
+ ) : callInvokeWithMethodAndArg();
+ }
+
+ // Define the unified helper method that is used to implement .next,
+ // .throw, and .return (see defineIteratorMethods).
+ this._invoke = enqueue;
+ }
+
+ defineIteratorMethods(AsyncIterator.prototype);
+ AsyncIterator.prototype[asyncIteratorSymbol] = function () {
+ return this;
+ };
+ exports.AsyncIterator = AsyncIterator;
+
+ // Note that simple async functions are implemented on top of
+ // AsyncIterator objects; they just return a Promise for the value of
+ // the final result produced by the iterator.
+ exports.async = function(innerFn, outerFn, self, tryLocsList) {
+ var iter = new AsyncIterator(
+ wrap(innerFn, outerFn, self, tryLocsList)
+ );
+
+ return exports.isGeneratorFunction(outerFn)
+ ? iter // If outerFn is a generator, return the full iterator.
+ : iter.next().then(function(result) {
+ return result.done ? result.value : iter.next();
+ });
+ };
+
+ function makeInvokeMethod(innerFn, self, context) {
+ var state = GenStateSuspendedStart;
+
+ return function invoke(method, arg) {
+ if (state === GenStateExecuting) {
+ throw new Error("Generator is already running");
+ }
+
+ if (state === GenStateCompleted) {
+ if (method === "throw") {
+ throw arg;
+ }
+
+ // Be forgiving, per 25.3.3.3.3 of the spec:
+ // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
+ return doneResult();
+ }
+
+ context.method = method;
+ context.arg = arg;
+
+ while (true) {
+ var delegate = context.delegate;
+ if (delegate) {
+ var delegateResult = maybeInvokeDelegate(delegate, context);
+ if (delegateResult) {
+ if (delegateResult === ContinueSentinel) continue;
+ return delegateResult;
+ }
+ }
+
+ if (context.method === "next") {
+ // Setting context._sent for legacy support of Babel's
+ // function.sent implementation.
+ context.sent = context._sent = context.arg;
+
+ } else if (context.method === "throw") {
+ if (state === GenStateSuspendedStart) {
+ state = GenStateCompleted;
+ throw context.arg;
+ }
+
+ context.dispatchException(context.arg);
+
+ } else if (context.method === "return") {
+ context.abrupt("return", context.arg);
+ }
+
+ state = GenStateExecuting;
+
+ var record = tryCatch(innerFn, self, context);
+ if (record.type === "normal") {
+ // If an exception is thrown from innerFn, we leave state ===
+ // GenStateExecuting and loop back for another invocation.
+ state = context.done
+ ? GenStateCompleted
+ : GenStateSuspendedYield;
+
+ if (record.arg === ContinueSentinel) {
+ continue;
+ }
+
+ return {
+ value: record.arg,
+ done: context.done
+ };
+
+ } else if (record.type === "throw") {
+ state = GenStateCompleted;
+ // Dispatch the exception by looping back around to the
+ // context.dispatchException(context.arg) call above.
+ context.method = "throw";
+ context.arg = record.arg;
+ }
+ }
+ };
+ }
+
+ // Call delegate.iterator[context.method](context.arg) and handle the
+ // result, either by returning a { value, done } result from the
+ // delegate iterator, or by modifying context.method and context.arg,
+ // setting context.delegate to null, and returning the ContinueSentinel.
+ function maybeInvokeDelegate(delegate, context) {
+ var method = delegate.iterator[context.method];
+ if (method === undefined) {
+ // A .throw or .return when the delegate iterator has no .throw
+ // method always terminates the yield* loop.
+ context.delegate = null;
+
+ if (context.method === "throw") {
+ if (delegate.iterator.return) {
+ // If the delegate iterator has a return method, give it a
+ // chance to clean up.
+ context.method = "return";
+ context.arg = undefined;
+ maybeInvokeDelegate(delegate, context);
+
+ if (context.method === "throw") {
+ // If maybeInvokeDelegate(context) changed context.method from
+ // "return" to "throw", let that override the TypeError below.
+ return ContinueSentinel;
+ }
+ }
+
+ context.method = "throw";
+ context.arg = new TypeError(
+ "The iterator does not provide a 'throw' method");
+ }
+
+ return ContinueSentinel;
+ }
+
+ var record = tryCatch(method, delegate.iterator, context.arg);
+
+ if (record.type === "throw") {
+ context.method = "throw";
+ context.arg = record.arg;
+ context.delegate = null;
+ return ContinueSentinel;
+ }
+
+ var info = record.arg;
+
+ if (! info) {
+ context.method = "throw";
+ context.arg = new TypeError("iterator result is not an object");
+ context.delegate = null;
+ return ContinueSentinel;
+ }
+
+ if (info.done) {
+ // Assign the result of the finished delegate to the temporary
+ // variable specified by delegate.resultName (see delegateYield).
+ context[delegate.resultName] = info.value;
+
+ // Resume execution at the desired location (see delegateYield).
+ context.next = delegate.nextLoc;
+
+ // If context.method was "throw" but the delegate handled the
+ // exception, let the outer generator proceed normally. If
+ // context.method was "next", forget context.arg since it has been
+ // "consumed" by the delegate iterator. If context.method was
+ // "return", allow the original .return call to continue in the
+ // outer generator.
+ if (context.method !== "return") {
+ context.method = "next";
+ context.arg = undefined;
+ }
+
+ } else {
+ // Re-yield the result returned by the delegate method.
+ return info;
+ }
+
+ // The delegate iterator is finished, so forget it and continue with
+ // the outer generator.
+ context.delegate = null;
+ return ContinueSentinel;
+ }
+
+ // Define Generator.prototype.{next,throw,return} in terms of the
+ // unified ._invoke helper method.
+ defineIteratorMethods(Gp);
+
+ Gp[toStringTagSymbol] = "Generator";
+
+ // A Generator should always return itself as the iterator object when the
+ // @@iterator function is called on it. Some browsers' implementations of the
+ // iterator prototype chain incorrectly implement this, causing the Generator
+ // object to not be returned from this call. This ensures that doesn't happen.
+ // See https://github.com/facebook/regenerator/issues/274 for more details.
+ Gp[iteratorSymbol] = function() {
+ return this;
+ };
+
+ Gp.toString = function() {
+ return "[object Generator]";
+ };
+
+ function pushTryEntry(locs) {
+ var entry = { tryLoc: locs[0] };
+
+ if (1 in locs) {
+ entry.catchLoc = locs[1];
+ }
+
+ if (2 in locs) {
+ entry.finallyLoc = locs[2];
+ entry.afterLoc = locs[3];
+ }
+
+ this.tryEntries.push(entry);
+ }
+
+ function resetTryEntry(entry) {
+ var record = entry.completion || {};
+ record.type = "normal";
+ delete record.arg;
+ entry.completion = record;
+ }
+
+ function Context(tryLocsList) {
+ // The root entry object (effectively a try statement without a catch
+ // or a finally block) gives us a place to store values thrown from
+ // locations where there is no enclosing try statement.
+ this.tryEntries = [{ tryLoc: "root" }];
+ tryLocsList.forEach(pushTryEntry, this);
+ this.reset(true);
+ }
+
+ exports.keys = function(object) {
+ var keys = [];
+ for (var key in object) {
+ keys.push(key);
+ }
+ keys.reverse();
+
+ // Rather than returning an object with a next method, we keep
+ // things simple and return the next function itself.
+ return function next() {
+ while (keys.length) {
+ var key = keys.pop();
+ if (key in object) {
+ next.value = key;
+ next.done = false;
+ return next;
+ }
+ }
+
+ // To avoid creating an additional object, we just hang the .value
+ // and .done properties off the next function object itself. This
+ // also ensures that the minifier will not anonymize the function.
+ next.done = true;
+ return next;
+ };
+ };
+
+ function values(iterable) {
+ if (iterable) {
+ var iteratorMethod = iterable[iteratorSymbol];
+ if (iteratorMethod) {
+ return iteratorMethod.call(iterable);
+ }
+
+ if (typeof iterable.next === "function") {
+ return iterable;
+ }
+
+ if (!isNaN(iterable.length)) {
+ var i = -1, next = function next() {
+ while (++i < iterable.length) {
+ if (hasOwn.call(iterable, i)) {
+ next.value = iterable[i];
+ next.done = false;
+ return next;
+ }
+ }
+
+ next.value = undefined;
+ next.done = true;
+
+ return next;
+ };
+
+ return next.next = next;
+ }
+ }
+
+ // Return an iterator with no values.
+ return { next: doneResult };
+ }
+ exports.values = values;
+
+ function doneResult() {
+ return { value: undefined, done: true };
+ }
+
+ Context.prototype = {
+ constructor: Context,
+
+ reset: function(skipTempReset) {
+ this.prev = 0;
+ this.next = 0;
+ // Resetting context._sent for legacy support of Babel's
+ // function.sent implementation.
+ this.sent = this._sent = undefined;
+ this.done = false;
+ this.delegate = null;
+
+ this.method = "next";
+ this.arg = undefined;
+
+ this.tryEntries.forEach(resetTryEntry);
+
+ if (!skipTempReset) {
+ for (var name in this) {
+ // Not sure about the optimal order of these conditions:
+ if (name.charAt(0) === "t" &&
+ hasOwn.call(this, name) &&
+ !isNaN(+name.slice(1))) {
+ this[name] = undefined;
+ }
+ }
+ }
+ },
+
+ stop: function() {
+ this.done = true;
+
+ var rootEntry = this.tryEntries[0];
+ var rootRecord = rootEntry.completion;
+ if (rootRecord.type === "throw") {
+ throw rootRecord.arg;
+ }
+
+ return this.rval;
+ },
+
+ dispatchException: function(exception) {
+ if (this.done) {
+ throw exception;
+ }
+
+ var context = this;
+ function handle(loc, caught) {
+ record.type = "throw";
+ record.arg = exception;
+ context.next = loc;
+
+ if (caught) {
+ // If the dispatched exception was caught by a catch block,
+ // then let that catch block handle the exception normally.
+ context.method = "next";
+ context.arg = undefined;
+ }
+
+ return !! caught;
+ }
+
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
+ var entry = this.tryEntries[i];
+ var record = entry.completion;
+
+ if (entry.tryLoc === "root") {
+ // Exception thrown outside of any try block that could handle
+ // it, so set the completion value of the entire function to
+ // throw the exception.
+ return handle("end");
+ }
+
+ if (entry.tryLoc <= this.prev) {
+ var hasCatch = hasOwn.call(entry, "catchLoc");
+ var hasFinally = hasOwn.call(entry, "finallyLoc");
+
+ if (hasCatch && hasFinally) {
+ if (this.prev < entry.catchLoc) {
+ return handle(entry.catchLoc, true);
+ } else if (this.prev < entry.finallyLoc) {
+ return handle(entry.finallyLoc);
+ }
+
+ } else if (hasCatch) {
+ if (this.prev < entry.catchLoc) {
+ return handle(entry.catchLoc, true);
+ }
+
+ } else if (hasFinally) {
+ if (this.prev < entry.finallyLoc) {
+ return handle(entry.finallyLoc);
+ }
+
+ } else {
+ throw new Error("try statement without catch or finally");
+ }
+ }
+ }
+ },
+
+ abrupt: function(type, arg) {
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
+ var entry = this.tryEntries[i];
+ if (entry.tryLoc <= this.prev &&
+ hasOwn.call(entry, "finallyLoc") &&
+ this.prev < entry.finallyLoc) {
+ var finallyEntry = entry;
+ break;
+ }
+ }
+
+ if (finallyEntry &&
+ (type === "break" ||
+ type === "continue") &&
+ finallyEntry.tryLoc <= arg &&
+ arg <= finallyEntry.finallyLoc) {
+ // Ignore the finally entry if control is not jumping to a
+ // location outside the try/catch block.
+ finallyEntry = null;
+ }
+
+ var record = finallyEntry ? finallyEntry.completion : {};
+ record.type = type;
+ record.arg = arg;
+
+ if (finallyEntry) {
+ this.method = "next";
+ this.next = finallyEntry.finallyLoc;
+ return ContinueSentinel;
+ }
+
+ return this.complete(record);
+ },
+
+ complete: function(record, afterLoc) {
+ if (record.type === "throw") {
+ throw record.arg;
+ }
+
+ if (record.type === "break" ||
+ record.type === "continue") {
+ this.next = record.arg;
+ } else if (record.type === "return") {
+ this.rval = this.arg = record.arg;
+ this.method = "return";
+ this.next = "end";
+ } else if (record.type === "normal" && afterLoc) {
+ this.next = afterLoc;
+ }
+
+ return ContinueSentinel;
+ },
+
+ finish: function(finallyLoc) {
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
+ var entry = this.tryEntries[i];
+ if (entry.finallyLoc === finallyLoc) {
+ this.complete(entry.completion, entry.afterLoc);
+ resetTryEntry(entry);
+ return ContinueSentinel;
+ }
+ }
+ },
+
+ "catch": function(tryLoc) {
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
+ var entry = this.tryEntries[i];
+ if (entry.tryLoc === tryLoc) {
+ var record = entry.completion;
+ if (record.type === "throw") {
+ var thrown = record.arg;
+ resetTryEntry(entry);
+ }
+ return thrown;
+ }
+ }
+
+ // The context.catch method must only be called with a location
+ // argument that corresponds to a known catch block.
+ throw new Error("illegal catch attempt");
+ },
+
+ delegateYield: function(iterable, resultName, nextLoc) {
+ this.delegate = {
+ iterator: values(iterable),
+ resultName: resultName,
+ nextLoc: nextLoc
+ };
+
+ if (this.method === "next") {
+ // Deliberately forget the last sent value so that we don't
+ // accidentally pass it on to the delegate.
+ this.arg = undefined;
+ }
+
+ return ContinueSentinel;
+ }
+ };
+
+ // Regardless of whether this script is executing as a CommonJS module
+ // or not, return the runtime object so that we can declare the variable
+ // regeneratorRuntime in the outer scope, which allows this module to be
+ // injected easily by `bin/regenerator --include-runtime script.js`.
+ return exports;
+
+}(
+ // If this script is executing as a CommonJS module, use module.exports
+ // as the regeneratorRuntime namespace. Otherwise create a new empty
+ // object. Either way, the resulting object will be used to initialize
+ // the regeneratorRuntime variable at the top of this file.
+ typeof module === "object" ? module.exports : {}
+));
diff --git a/utils/selectFiles.js b/utils/selectFiles.js
new file mode 100644
index 0000000..09371c9
--- /dev/null
+++ b/utils/selectFiles.js
@@ -0,0 +1,32 @@
+module.exports = {
+ selectPhotos: function(e, s, o) {
+ if (void 0 === e[s]) {
+ var c = 5 - e.length;
+ c > 0 && wx.chooseImage({
+ count: c,
+ sizeType: [ "compressed" ],
+ sourceType: [ "camera", "album" ],
+ success: function(s) {
+ e = e.concat(s.tempFilePaths), o(e);
+ }
+ });
+ } else wx.chooseImage({
+ count: 1,
+ sizeType: [ "compressed" ],
+ sourceType: [ "camera", "album" ],
+ success: function(c) {
+ e[s] = c.tempFilePaths[0], o(e);
+ }
+ });
+ },
+ removePhoto: function(e, s, o) {
+ if (void 0 !== e[s]) {
+ wx.showModal({
+ title: "确定删除该图片?",
+ success: function(c) {
+ c.confirm && (e.splice(s, 1), o(e));
+ }
+ });
+ } else o(e);
+ }
+};
\ No newline at end of file
diff --git a/utils/util.js b/utils/util.js
new file mode 100644
index 0000000..26779aa
--- /dev/null
+++ b/utils/util.js
@@ -0,0 +1,290 @@
+
+function isString(str) {
+ return (typeof str == 'string') && str.constructor == String;
+}
+function isArray(obj) {
+ return (typeof obj == 'object') && obj.constructor == Array;
+}
+
+function sub_last(str){
+ return str.substring(0, str.length - 1)
+}
+function trim(str) { return str.replace(/(^s*)|(s*$)/g, "");}
+function e(e) {
+ var r = ""; for (var t in e) r += (r ? "&" : "") + t + "=" + e[t]; return r;
+}
+
+function utf16to8(str) {
+ var out, i, len, c; out = ""; len = str.length;
+ for (i = 0; i < len; i++) {
+ c = str.charCodeAt(i);
+ if ((c >= 0x0001) && (c <= 0x007F)) {
+ out += str.charAt(i);
+ } else if (c > 0x07FF) {
+ out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
+ out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
+ out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
+ } else {
+ out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
+ out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
+ }
+ }
+ return out;
+}
+
+function utf8to16(str) {
+ var out, i, len, c; var char2, char3;
+ out = "";len = str.length; i = 0;
+ while (i < len) {
+ c = str.charCodeAt(i++);
+ switch (c >> 4) {
+ case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
+ // 0xxxxxxx
+ out += str.charAt(i - 1);
+ break;
+ case 12: case 13:
+ // 110x xxxx 10xx xxxx
+ char2 = str.charCodeAt(i++);
+ out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
+ break;
+ case 14:
+ // 1110 xxxx 10xx xxxx 10xx xxxx
+ char2 = str.charCodeAt(i++);
+ char3 = str.charCodeAt(i++);
+ out += String.fromCharCode(((c & 0x0F) << 12) |
+ ((char2 & 0x3F) << 6) |
+ ((char3 & 0x3F) << 0));
+ break;
+ }
+ }
+ return out;
+}
+
+
+function unserialize_o(ss) {
+ var p = 0, ht = [], hv = 1,r = null;
+ function unser_null() { p++; return null; }
+ function unser_boolean() { p++; var b = (ss.charAt(p++) == '1'); p++; return b; }
+ function unser_integer() { p++;
+ var i = parseInt(ss.substring(p, p = ss.indexOf(';', p))); p++; return i;}
+ function unser_double() {
+ p++;var d = ss.substring(p, p = ss.indexOf(';', p));
+ switch (d) {
+ case 'INF': d = Number.POSITIVE_INFINITY; break;
+ case '-INF': d = Number.NEGATIVE_INFINITY; break;
+ default: d = parseFloat(d);
+ }
+ p++; return d;
+ }
+ function unser_string() {
+ p++;var l = parseInt(ss.substring(p, p = ss.indexOf(':', p)));
+ p += 2; var s = utf8to16(ss.substring(p, p += l));
+ p += 2; return s;
+ }
+ function unser_array() {
+ p++; var n = parseInt(ss.substring(p, p = ss.indexOf(':', p)));
+ p += 2; var a = []; ht[hv++] = a;
+ for (var i = 0; i < n; i++) {
+ var k;
+ switch (ss.charAt(p++)) {
+ case 'i': k = unser_integer(); break;
+ case 's': k = unser_string(); break;
+ case 'U': k = unser_unicode_string(); break;
+ default: return false;
+ }
+ a[k] = __unserialize();
+ }
+ p++; return a;
+ }
+ function unser_object() {
+ p++;
+ var l = parseInt(ss.substring(p, p = ss.indexOf(':', p)));
+ p += 2;
+ var cn = utf8to16(ss.substring(p, p += l));
+ p += 2;
+ var n = parseInt(ss.substring(p, p = ss.indexOf(':', p)));
+ p += 2;
+ if (eval(['typeof(', cn, ') == "undefined"'].join(''))) {
+ eval(['function ', cn, '(){}'].join(''));
+ }
+ var o = eval(['new ', cn, '()'].join(''));
+ ht[hv++] = o;
+ for (var i = 0; i < n; i++) {
+ var k;
+ switch (ss.charAt(p++)) {
+ case 's': k = unser_string(); break;
+ case 'U': k = unser_unicode_string(); break;
+ default: return false;
+ }
+ if (k.charAt(0) == '\0') {
+ k = k.substring(k.indexOf('\0', 1) + 1, k.length);
+ }
+ o[k] = __unserialize();
+ }
+ p++;
+ if (typeof (o.__wakeup) == 'function') o.__wakeup();
+ return o;
+ }
+ function unser_custom_object() {
+ p++;
+ var l = parseInt(ss.substring(p, p = ss.indexOf(':', p)));
+ p += 2;
+ var cn = utf8to16(ss.substring(p, p += l));
+ p += 2;
+ var n = parseInt(ss.substring(p, p = ss.indexOf(':', p)));
+ p += 2;
+ if (eval(['typeof(', cn, ') == "undefined"'].join(''))) {
+ eval(['function ', cn, '(){}'].join(''));
+ }
+ var o = eval(['new ', cn, '()'].join(''));
+ ht[hv++] = o;
+ if (typeof (o.unserialize) != 'function') p += n;
+ else o.unserialize(ss.substring(p, p += n));
+ p++;
+ return o;
+ }
+
+ function unser_unicode_string() {
+ p++; var l = parseInt(ss.substring(p, p = ss.indexOf(':', p)));
+ p += 2; var sb = [];
+ for (i = 0; i < l; i++) {
+ if ((sb[i] = ss.charAt(p++)) == '\\') {
+ sb[i] = String.fromCharCode(parseInt(ss.substring(p, p += 4), 16));
+ }
+ }
+ p += 2; return sb.join('');
+ }
+ function unser_ref() { p++; var r = parseInt(ss.substring(p, p = ss.indexOf(';', p))); p++; return ht[r];}
+ function __unserialize() {
+ switch (ss.charAt(p++)) {
+ case 'N': return ht[hv++] = unser_null();
+ case 'b': return ht[hv++] = unser_boolean();
+ case 'i': return ht[hv++] = unser_integer();
+ case 'd': return ht[hv++] = unser_double();
+ case 's': return ht[hv++] = unser_string();
+ case 'U': return ht[hv++] = unser_unicode_string();
+ case 'r': return ht[hv++] = unser_ref();
+ case 'a': return unser_array();
+ case 'O': return unser_object();
+ case 'C': return unser_custom_object();
+ case 'R': return unser_ref();
+ default: return false;
+ }
+ }
+ return __unserialize();
+}
+
+//---数组序列化的反转---
+function unserialize(ss) {
+ if (ss=="" || ss==undefined || ss==null) return '';
+ //ss ='a:2:{i:0;s:60:"/public/upload/comment/8704/2017/10-14/15079840099736199.png";i:1;s:60:"/public/upload/comment/8704/2017/10-14/15079840132718554.jpg";}';
+ ss=ss.substring(7);
+ var arr = ss.split('i:'), rs=new Array();
+ for (var i = 0; i < arr.length;i++){
+ var ind0 = arr[i].indexOf('/public');
+ var ind1 = arr[i].indexOf('";');
+ var txt = arr[i].substring(ind0, ind1);
+ rs.push(txt);
+ }
+ return rs;
+}
+
+//-----判断一个对象是不是空对象--------
+function isEmptyObject(obj) {
+ for (var key in obj) { return false };
+ return true
+};
+
+function gettimestamp(){
+ var timestamp = Date.parse(new Date());
+ timestamp = timestamp / 1000;
+ return timestamp;
+}
+module.exports = {
+ formatTime: function(e, r) {
+ var t = e ? new Date(1e3 * e) : new Date(), n = t.getFullYear(), o = t.getMonth() + 1, a = t.getDate(), u = t.getHours(), i = t.getMinutes(), f = t.getSeconds(), s = function(e) {
+ return (e = e.toString())[1] ? e : "0" + e;
+ };
+ return void 0 !== r && 0 == r ? [ n, o, a ].map(s).join("-") + " " + [ u, i ].map(s).join(":") : [ n, o, a ].map(s).join("-") + " " + [ u, i, f ].map(s).join(":");
+ },
+ format: function(e, r) {
+ var t = new Date();
+ t.setTime(1e3 * e);
+ var n = {
+ "M+": t.getMonth() + 1,
+ "d+": t.getDate(),
+ "h+": t.getHours(),
+ "m+": t.getMinutes(),
+ "s+": t.getSeconds(),
+ "q+": Math.floor((t.getMonth() + 3) / 3),
+ S: t.getMilliseconds()
+ };
+ void 0 === r && (r = "yyyy-MM-dd hh:mm:ss"), /(y+)/.test(r) && (r = r.replace(RegExp.$1, (t.getFullYear() + "").substr(4 - RegExp.$1.length)));
+ for (var o in n) new RegExp("(" + o + ")").test(r) && (r = r.replace(RegExp.$1, 1 == RegExp.$1.length ? n[o] : ("00" + n[o]).substr(("" + n[o]).length)));
+ return r;
+ },
+ json2Form: function(e) {
+ var r = [];
+ for (var t in e) r.push(encodeURIComponent(t) + "=" + encodeURIComponent(e[t]));
+ return r.join("&");
+ },
+ randomString: function(e) {
+ e = e || 32;
+ for (var r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", t = r.length, n = "", o = 0; o < e; o++) n += r.charAt(Math.floor(Math.random() * (t + 1)));
+ return n;
+ },
+ inArray: function(e, r) {
+ for (var t = 0; t < r.length; t++) if (e == r[t]) return !0;
+ return !1;
+ },
+ sortSize: function(e, r) {
+ return void 0 === r && (r = 0), r ? e.sort(function(e, r) {
+ return r - e;
+ }) : e.sort(function(e, r) {
+ return e - r;
+ }), e;
+ },
+ convertRequestArray: function(e, r) {
+ for (var t = {}, n = 0; n < r.length; n++) t[e + "[" + n + "]"] = r[n];
+ return t;
+ },
+ remainTime: function(e) {
+ var r = "", t = !1, n = Math.floor(e / 864e5);
+ r = n ? n + "天" : "", t = !!n, e -= 864e5 * n;
+ var o = Math.floor(e / 36e5);
+ r += o ? o + "时" : t ? "0时" : "", t = !!o, e -= 36e5 * o;
+ var a = Math.floor(e / 6e4);
+ r += a ? a + "分" : t ? "0分" : "", e -= 6e4 * a;
+ var u = Math.floor(e / 1e3);
+ return r += u ? u + "秒" : "0秒";
+ },
+ transTime: function(e) {
+ var r = {
+ hour: 0,
+ minute: 0,
+ second: 0
+ }, t = Math.floor(e / 36e5);
+ r.hour = t || "0", e -= 36e5 * t;
+ var n = Math.floor(e / 6e4);
+ r.minute = n || "0", e -= 6e4 * n;
+ var o = Math.floor(e / 1e3);
+ return r.second = o || "0", r;
+ },
+ Obj2Str: e,
+ JumpTo: function(r, t, n) {
+ var o = e(t);
+ n ? wx.redirectTo({
+ url: r + o
+ }) : wx.navigateTo({
+ url: r + o
+ });
+ },
+ unserialize: unserialize,
+ unserialize_o: unserialize_o,
+ trim: trim, //去空格
+ isEmptyObject: isEmptyObject, //判断空对象
+ gettimestamp: gettimestamp, //获取时间戳
+ isString: isString,
+ isArray: isArray,
+ sub_last: sub_last,//去掉末尾一个字符
+};
diff --git a/utils/wxParse/html2json.js b/utils/wxParse/html2json.js
new file mode 100644
index 0000000..671e6a2
--- /dev/null
+++ b/utils/wxParse/html2json.js
@@ -0,0 +1,105 @@
+function e(e) {
+ for (var t = {}, r = e.split(","), s = 0; s < r.length; s++) t[r[s]] = !0;
+ return t;
+}
+
+function t(e) {
+ return e.replace(/<\?xml.*\?>\n/, "").replace(/<.*!doctype.*\>\n/, "").replace(/<.*!DOCTYPE.*\>\n/, "");
+}
+
+function r(e) {
+ return e.replace(/\r?\n+/g, "").replace(//gi, "").replace(/\/\*.*?\*\//gi, "").replace(/[ ]+ 0 && void 0 !== arguments[0] ? arguments[0] : "", t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "/wxParse/emojis/", r = arguments[2];
+ a = e, o = t, i = r;
+ }
+};
\ No newline at end of file
diff --git a/utils/wxParse/htmlparser.js b/utils/wxParse/htmlparser.js
new file mode 100644
index 0000000..de7b6e9
--- /dev/null
+++ b/utils/wxParse/htmlparser.js
@@ -0,0 +1,48 @@
+function e(e) {
+ for (var t = {}, r = e.split(","), s = 0; s < r.length; s++) t[r[s]] = !0;
+ return t;
+}
+
+var t = /^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/, r = /^<\/([-A-Za-z0-9_]+)[^>]*>/, s = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g, a = e("area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr"), n = e("a,address,code,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video"), i = e("abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var"), o = e("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr"), l = e("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"), c = e("wxxxcode-style,script,style,view,scroll-view,block");
+
+module.exports = function(e, d) {
+ function f(e, t) {
+ if (t) for (t = t.toLowerCase(), r = b.length - 1; r >= 0 && b[r] != t; r--) ; else var r = 0;
+ if (r >= 0) {
+ for (var s = b.length - 1; s >= r; s--) d.end && d.end(b[s]);
+ b.length = r;
+ }
+ }
+ var p, u, h, b = [], m = e;
+ for (b.last = function() {
+ return this[this.length - 1];
+ }; e; ) {
+ if (u = !0, b.last() && c[b.last()]) e = e.replace(new RegExp("([\\s\\S]*?)" + b.last() + "[^>]*>"), function(e, t) {
+ return t = t.replace(/|/g, "$1$2"), d.chars && d.chars(t),
+ "";
+ }), f(0, b.last()); else if (0 == e.indexOf("\x3c!--") ? (p = e.indexOf("--\x3e")) >= 0 && (d.comment && d.comment(e.substring(4, p)),
+ e = e.substring(p + 3), u = !1) : 0 == e.indexOf("") ? (h = e.match(r)) && (e = e.substring(h[0].length),
+ h[0].replace(r, f), u = !1) : 0 == e.indexOf("<") && (h = e.match(t)) && (e = e.substring(h[0].length),
+ h[0].replace(t, function(e, t, r, c) {
+ if (t = t.toLowerCase(), n[t]) for (;b.last() && i[b.last()]; ) f(0, b.last());
+ if (o[t] && b.last() == t && f(0, t), (c = a[t] || !!c) || b.push(t), d.start) {
+ var p = [];
+ r.replace(s, function(e, t) {
+ var r = arguments[2] ? arguments[2] : arguments[3] ? arguments[3] : arguments[4] ? arguments[4] : l[t] ? t : "";
+ p.push({
+ name: t,
+ value: r,
+ escaped: r.replace(/(^|[^\\])"/g, '$1\\"')
+ });
+ }), d.start && d.start(t, p, c);
+ }
+ }), u = !1), u) {
+ p = e.indexOf("<");
+ for (var g = ""; 0 === p; ) g += "<", p = (e = e.substring(1)).indexOf("<");
+ g += p < 0 ? e : e.substring(0, p), e = p < 0 ? "" : e.substring(p), d.chars && d.chars(g);
+ }
+ if (e == m) throw "Parse Error: " + e;
+ m = e;
+ }
+ f();
+};
\ No newline at end of file
diff --git a/utils/wxParse/showdown.js b/utils/wxParse/showdown.js
new file mode 100644
index 0000000..e6ea9e8
--- /dev/null
+++ b/utils/wxParse/showdown.js
@@ -0,0 +1,693 @@
+function e(e) {
+ var r = {
+ omitExtraWLInCodeBlocks: {
+ defaultValue: !1,
+ describe: "Omit the default extra whiteline added to code blocks",
+ type: "boolean"
+ },
+ noHeaderId: {
+ defaultValue: !1,
+ describe: "Turn on/off generated header id",
+ type: "boolean"
+ },
+ prefixHeaderId: {
+ defaultValue: !1,
+ describe: "Specify a prefix to generated header ids",
+ type: "string"
+ },
+ headerLevelStart: {
+ defaultValue: !1,
+ describe: "The header blocks level start",
+ type: "integer"
+ },
+ parseImgDimensions: {
+ defaultValue: !1,
+ describe: "Turn on/off image dimension parsing",
+ type: "boolean"
+ },
+ simplifiedAutoLink: {
+ defaultValue: !1,
+ describe: "Turn on/off GFM autolink style",
+ type: "boolean"
+ },
+ literalMidWordUnderscores: {
+ defaultValue: !1,
+ describe: "Parse midword underscores as literal underscores",
+ type: "boolean"
+ },
+ strikethrough: {
+ defaultValue: !1,
+ describe: "Turn on/off strikethrough support",
+ type: "boolean"
+ },
+ tables: {
+ defaultValue: !1,
+ describe: "Turn on/off tables support",
+ type: "boolean"
+ },
+ tablesHeaderId: {
+ defaultValue: !1,
+ describe: "Add an id to table headers",
+ type: "boolean"
+ },
+ ghCodeBlocks: {
+ defaultValue: !0,
+ describe: "Turn on/off GFM fenced code blocks support",
+ type: "boolean"
+ },
+ tasklists: {
+ defaultValue: !1,
+ describe: "Turn on/off GFM tasklist support",
+ type: "boolean"
+ },
+ smoothLivePreview: {
+ defaultValue: !1,
+ describe: "Prevents weird effects in live previews due to incomplete input",
+ type: "boolean"
+ },
+ smartIndentationFix: {
+ defaultValue: !1,
+ description: "Tries to smartly fix identation in es6 strings",
+ type: "boolean"
+ }
+ };
+ if (!1 === e) return JSON.parse(JSON.stringify(r));
+ var t = {};
+ for (var n in r) r.hasOwnProperty(n) && (t[n] = r[n].defaultValue);
+ return t;
+}
+
+function r(e, r) {
+ var t = r ? "Error in " + r + " extension->" : "Error in unnamed extension", a = {
+ valid: !0,
+ error: ""
+ };
+ s.helper.isArray(e) || (e = [ e ]);
+ for (var o = 0; o < e.length; ++o) {
+ var i = t + " sub-extension " + o + ": ", l = e[o];
+ if ("object" !== (void 0 === l ? "undefined" : n(l))) return a.valid = !1, a.error = i + "must be an object, but " + (void 0 === l ? "undefined" : n(l)) + " given",
+ a;
+ if (!s.helper.isString(l.type)) return a.valid = !1, a.error = i + 'property "type" must be a string, but ' + n(l.type) + " given",
+ a;
+ var c = l.type = l.type.toLowerCase();
+ if ("language" === c && (c = l.type = "lang"), "html" === c && (c = l.type = "output"),
+ "lang" !== c && "output" !== c && "listener" !== c) return a.valid = !1, a.error = i + "type " + c + ' is not recognized. Valid values: "lang/language", "output/html" or "listener"',
+ a;
+ if ("listener" === c) {
+ if (s.helper.isUndefined(l.listeners)) return a.valid = !1, a.error = i + '. Extensions of type "listener" must have a property called "listeners"',
+ a;
+ } else if (s.helper.isUndefined(l.filter) && s.helper.isUndefined(l.regex)) return a.valid = !1,
+ a.error = i + c + ' extensions must define either a "regex" property or a "filter" method',
+ a;
+ if (l.listeners) {
+ if ("object" !== n(l.listeners)) return a.valid = !1, a.error = i + '"listeners" property must be an object but ' + n(l.listeners) + " given",
+ a;
+ for (var u in l.listeners) if (l.listeners.hasOwnProperty(u) && "function" != typeof l.listeners[u]) return a.valid = !1,
+ a.error = i + '"listeners" property must be an hash of [event name]: [callback]. listeners.' + u + " must be a function but " + n(l.listeners[u]) + " given",
+ a;
+ }
+ if (l.filter) {
+ if ("function" != typeof l.filter) return a.valid = !1, a.error = i + '"filter" must be a function, but ' + n(l.filter) + " given",
+ a;
+ } else if (l.regex) {
+ if (s.helper.isString(l.regex) && (l.regex = new RegExp(l.regex, "g")), !l.regex instanceof RegExp) return a.valid = !1,
+ a.error = i + '"regex" property must either be a string or a RegExp object, but ' + n(l.regex) + " given",
+ a;
+ if (s.helper.isUndefined(l.replace)) return a.valid = !1, a.error = i + '"regex" extensions must implement a replace string or function',
+ a;
+ }
+ }
+ return a;
+}
+
+function t(e, r) {
+ return "~E" + r.charCodeAt(0) + "E";
+}
+
+var n = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
+ return typeof e;
+} : function(e) {
+ return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
+}, s = {}, a = {}, o = {}, i = e(!0), l = {
+ github: {
+ omitExtraWLInCodeBlocks: !0,
+ prefixHeaderId: "user-content-",
+ simplifiedAutoLink: !0,
+ literalMidWordUnderscores: !0,
+ strikethrough: !0,
+ tables: !0,
+ tablesHeaderId: !0,
+ ghCodeBlocks: !0,
+ tasklists: !0
+ },
+ vanilla: e(!0)
+};
+
+s.helper = {}, s.extensions = {}, s.setOption = function(e, r) {
+ return i[e] = r, this;
+}, s.getOption = function(e) {
+ return i[e];
+}, s.getOptions = function() {
+ return i;
+}, s.resetOptions = function() {
+ i = e(!0);
+}, s.setFlavor = function(e) {
+ if (l.hasOwnProperty(e)) {
+ var r = l[e];
+ for (var t in r) r.hasOwnProperty(t) && (i[t] = r[t]);
+ }
+}, s.getDefaultOptions = function(r) {
+ return e(r);
+}, s.subParser = function(e, r) {
+ if (s.helper.isString(e)) {
+ if (void 0 === r) {
+ if (a.hasOwnProperty(e)) return a[e];
+ throw Error("SubParser named " + e + " not registered!");
+ }
+ a[e] = r;
+ }
+}, s.extension = function(e, t) {
+ if (!s.helper.isString(e)) throw Error("Extension 'name' must be a string");
+ if (e = s.helper.stdExtName(e), s.helper.isUndefined(t)) {
+ if (!o.hasOwnProperty(e)) throw Error("Extension named " + e + " is not registered!");
+ return o[e];
+ }
+ "function" == typeof t && (t = t()), s.helper.isArray(t) || (t = [ t ]);
+ var n = r(t, e);
+ if (!n.valid) throw Error(n.error);
+ o[e] = t;
+}, s.getAllExtensions = function() {
+ return o;
+}, s.removeExtension = function(e) {
+ delete o[e];
+}, s.resetExtensions = function() {
+ o = {};
+}, s.validateExtension = function(e) {
+ var t = r(e, null);
+ return !!t.valid || (console.warn(t.error), !1);
+}, s.hasOwnProperty("helper") || (s.helper = {}), s.helper.isString = function(e) {
+ return "string" == typeof e || e instanceof String;
+}, s.helper.isFunction = function(e) {
+ var r = {};
+ return e && "[object Function]" === r.toString.call(e);
+}, s.helper.forEach = function(e, r) {
+ if ("function" == typeof e.forEach) e.forEach(r); else for (var t = 0; t < e.length; t++) r(e[t], t, e);
+}, s.helper.isArray = function(e) {
+ return e.constructor === Array;
+}, s.helper.isUndefined = function(e) {
+ return void 0 === e;
+}, s.helper.stdExtName = function(e) {
+ return e.replace(/[_-]||\s/g, "").toLowerCase();
+}, s.helper.escapeCharactersCallback = t, s.helper.escapeCharacters = function(e, r, n) {
+ var s = "([" + r.replace(/([\[\]\\])/g, "\\$1") + "])";
+ n && (s = "\\\\" + s);
+ var a = new RegExp(s, "g");
+ return e = e.replace(a, t);
+};
+
+var c = function(e, r, t, n) {
+ var s, a, o, i, l, c = n || "", u = c.indexOf("g") > -1, p = new RegExp(r + "|" + t, "g" + c.replace(/g/g, "")), h = new RegExp(r, c.replace(/g/g, "")), d = [];
+ do {
+ for (s = 0; o = p.exec(e); ) if (h.test(o[0])) s++ || (i = (a = p.lastIndex) - o[0].length); else if (s && !--s) {
+ l = o.index + o[0].length;
+ var f = {
+ left: {
+ start: i,
+ end: a
+ },
+ match: {
+ start: a,
+ end: o.index
+ },
+ right: {
+ start: o.index,
+ end: l
+ },
+ wholeMatch: {
+ start: i,
+ end: l
+ }
+ };
+ if (d.push(f), !u) return d;
+ }
+ } while (s && (p.lastIndex = a));
+ return d;
+};
+
+s.helper.matchRecursiveRegExp = function(e, r, t, n) {
+ for (var s = c(e, r, t, n), a = [], o = 0; o < s.length; ++o) a.push([ e.slice(s[o].wholeMatch.start, s[o].wholeMatch.end), e.slice(s[o].match.start, s[o].match.end), e.slice(s[o].left.start, s[o].left.end), e.slice(s[o].right.start, s[o].right.end) ]);
+ return a;
+}, s.helper.replaceRecursiveRegExp = function(e, r, t, n, a) {
+ if (!s.helper.isFunction(r)) {
+ var o = r;
+ r = function() {
+ return o;
+ };
+ }
+ var i = c(e, t, n, a), l = e, u = i.length;
+ if (u > 0) {
+ var p = [];
+ 0 !== i[0].wholeMatch.start && p.push(e.slice(0, i[0].wholeMatch.start));
+ for (var h = 0; h < u; ++h) p.push(r(e.slice(i[h].wholeMatch.start, i[h].wholeMatch.end), e.slice(i[h].match.start, i[h].match.end), e.slice(i[h].left.start, i[h].left.end), e.slice(i[h].right.start, i[h].right.end))),
+ h < u - 1 && p.push(e.slice(i[h].wholeMatch.end, i[h + 1].wholeMatch.start));
+ i[u - 1].wholeMatch.end < e.length && p.push(e.slice(i[u - 1].wholeMatch.end)),
+ l = p.join("");
+ }
+ return l;
+}, s.helper.isUndefined(console) && (console = {
+ warn: function(e) {
+ alert(e);
+ },
+ log: function(e) {
+ alert(e);
+ },
+ error: function(e) {
+ throw e;
+ }
+}), s.Converter = function(e) {
+ function t(e, t) {
+ if (t = t || null, s.helper.isString(e)) {
+ if (e = s.helper.stdExtName(e), t = e, s.extensions[e]) return console.warn("DEPRECATION WARNING: " + e + " is an old extension that uses a deprecated loading method.Please inform the developer that the extension should be updated!"),
+ void a(s.extensions[e], e);
+ if (s.helper.isUndefined(o[e])) throw Error('Extension "' + e + '" could not be loaded. It was either not found or is not a valid extension.');
+ e = o[e];
+ }
+ "function" == typeof e && (e = e()), s.helper.isArray(e) || (e = [ e ]);
+ var n = r(e, t);
+ if (!n.valid) throw Error(n.error);
+ for (var i = 0; i < e.length; ++i) {
+ switch (e[i].type) {
+ case "lang":
+ h.push(e[i]);
+ break;
+
+ case "output":
+ d.push(e[i]);
+ }
+ if (e[i].hasOwnProperty(f)) for (var l in e[i].listeners) e[i].listeners.hasOwnProperty(l) && c(l, e[i].listeners[l]);
+ }
+ }
+ function a(e, t) {
+ "function" == typeof e && (e = e(new s.Converter())), s.helper.isArray(e) || (e = [ e ]);
+ var n = r(e, t);
+ if (!n.valid) throw Error(n.error);
+ for (var a = 0; a < e.length; ++a) switch (e[a].type) {
+ case "lang":
+ h.push(e[a]);
+ break;
+
+ case "output":
+ d.push(e[a]);
+ break;
+
+ default:
+ throw Error("Extension loader error: Type unrecognized!!!");
+ }
+ }
+ function c(e, r) {
+ if (!s.helper.isString(e)) throw Error("Invalid argument in converter.listen() method: name must be a string, but " + (void 0 === e ? "undefined" : n(e)) + " given");
+ if ("function" != typeof r) throw Error("Invalid argument in converter.listen() method: callback must be a function, but " + (void 0 === r ? "undefined" : n(r)) + " given");
+ f.hasOwnProperty(e) || (f[e] = []), f[e].push(r);
+ }
+ function u(e) {
+ var r = e.match(/^\s*/)[0].length, t = new RegExp("^\\s{0," + r + "}", "gm");
+ return e.replace(t, "");
+ }
+ var p = {}, h = [], d = [], f = {};
+ !function() {
+ e = e || {};
+ for (var r in i) i.hasOwnProperty(r) && (p[r] = i[r]);
+ if ("object" !== (void 0 === e ? "undefined" : n(e))) throw Error("Converter expects the passed parameter to be an object, but " + (void 0 === e ? "undefined" : n(e)) + " was passed instead.");
+ for (var a in e) e.hasOwnProperty(a) && (p[a] = e[a]);
+ p.extensions && s.helper.forEach(p.extensions, t);
+ }(), this._dispatch = function(e, r, t, n) {
+ if (f.hasOwnProperty(e)) for (var s = 0; s < f[e].length; ++s) {
+ var a = f[e][s](e, r, this, t, n);
+ a && void 0 !== a && (r = a);
+ }
+ return r;
+ }, this.listen = function(e, r) {
+ return c(e, r), this;
+ }, this.makeHtml = function(e) {
+ if (!e) return e;
+ var r = {
+ gHtmlBlocks: [],
+ gHtmlMdBlocks: [],
+ gHtmlSpans: [],
+ gUrls: {},
+ gTitles: {},
+ gDimensions: {},
+ gListLevel: 0,
+ hashLinkCounts: {},
+ langExtensions: h,
+ outputModifiers: d,
+ converter: this,
+ ghCodeBlocks: []
+ };
+ return e = e.replace(/~/g, "~T"), e = e.replace(/\$/g, "~D"), e = e.replace(/\r\n/g, "\n"),
+ e = e.replace(/\r/g, "\n"), p.smartIndentationFix && (e = u(e)), e = e, e = s.subParser("detab")(e, p, r),
+ e = s.subParser("stripBlankLines")(e, p, r), s.helper.forEach(h, function(t) {
+ e = s.subParser("runExtension")(t, e, p, r);
+ }), e = s.subParser("hashPreCodeTags")(e, p, r), e = s.subParser("githubCodeBlocks")(e, p, r),
+ e = s.subParser("hashHTMLBlocks")(e, p, r), e = s.subParser("hashHTMLSpans")(e, p, r),
+ e = s.subParser("stripLinkDefinitions")(e, p, r), e = s.subParser("blockGamut")(e, p, r),
+ e = s.subParser("unhashHTMLSpans")(e, p, r), e = s.subParser("unescapeSpecialChars")(e, p, r),
+ e = e.replace(/~D/g, "$$"), e = e.replace(/~T/g, "~"), s.helper.forEach(d, function(t) {
+ e = s.subParser("runExtension")(t, e, p, r);
+ }), e;
+ }, this.setOption = function(e, r) {
+ p[e] = r;
+ }, this.getOption = function(e) {
+ return p[e];
+ }, this.getOptions = function() {
+ return p;
+ }, this.addExtension = function(e, r) {
+ t(e, r = r || null);
+ }, this.useExtension = function(e) {
+ t(e);
+ }, this.setFlavor = function(e) {
+ if (l.hasOwnProperty(e)) {
+ var r = l[e];
+ for (var t in r) r.hasOwnProperty(t) && (p[t] = r[t]);
+ }
+ }, this.removeExtension = function(e) {
+ s.helper.isArray(e) || (e = [ e ]);
+ for (var r = 0; r < e.length; ++r) {
+ for (var t = e[r], n = 0; n < h.length; ++n) h[n] === t && h[n].splice(n, 1);
+ for (;0 < d.length; ++n) d[0] === t && d[0].splice(n, 1);
+ }
+ }, this.getAllExtensions = function() {
+ return {
+ language: h,
+ output: d
+ };
+ };
+}, s.subParser("anchors", function(e, r, t) {
+ var n = function(e, r, n, a, o, i, l, c) {
+ s.helper.isUndefined(c) && (c = ""), e = r;
+ var u = n, p = a.toLowerCase(), h = o, d = c;
+ if (!h) if (p || (p = u.toLowerCase().replace(/ ?\n/g, " ")), h = "#" + p, s.helper.isUndefined(t.gUrls[p])) {
+ if (!(e.search(/\(\s*\)$/m) > -1)) return e;
+ h = "";
+ } else h = t.gUrls[p], s.helper.isUndefined(t.gTitles[p]) || (d = t.gTitles[p]);
+ var f = '" + u + " ";
+ };
+ return e = (e = t.converter._dispatch("anchors.before", e, r, t)).replace(/(\[((?:\[[^\]]*]|[^\[\]])*)][ ]?(?:\n[ ]*)?\[(.*?)])()()()()/g, n),
+ e = e.replace(/(\[((?:\[[^\]]*]|[^\[\]])*)]\([ \t]*()(.*?(?:\(.*?\).*?)?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g, n),
+ e = e.replace(/(\[([^\[\]]+)])()()()()()/g, n), e = t.converter._dispatch("anchors.after", e, r, t);
+}), s.subParser("autoLinks", function(e, r, t) {
+ function n(e, r) {
+ var t = r;
+ return /^www\./i.test(r) && (r = r.replace(/^www\./i, "http://www.")), '' + t + " ";
+ }
+ function a(e, r) {
+ var t = s.subParser("unescapeSpecialChars")(r);
+ return s.subParser("encodeEmailAddress")(t);
+ }
+ var o = /\b(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+)(?=\s|$)(?!["<>])/gi, i = /<(((https?|ftp|dict):\/\/|www\.)[^'">\s]+)>/gi, l = /(?:^|[ \n\t])([A-Za-z0-9!#$%&'*+-/=?^_`\{|}~\.]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)(?:$|[ \n\t])/gi, c = /<(?:mailto:)?([-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi;
+ return e = (e = t.converter._dispatch("autoLinks.before", e, r, t)).replace(i, n),
+ e = e.replace(c, a), r.simplifiedAutoLink && (e = (e = e.replace(o, n)).replace(l, a)),
+ e = t.converter._dispatch("autoLinks.after", e, r, t);
+}), s.subParser("blockGamut", function(e, r, t) {
+ e = t.converter._dispatch("blockGamut.before", e, r, t), e = s.subParser("blockQuotes")(e, r, t),
+ e = s.subParser("headers")(e, r, t);
+ var n = s.subParser("hashBlock")(" ", r, t);
+ return e = e.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm, n), e = e.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm, n),
+ e = e.replace(/^[ ]{0,2}([ ]?_[ ]?){3,}[ \t]*$/gm, n), e = s.subParser("lists")(e, r, t),
+ e = s.subParser("codeBlocks")(e, r, t), e = s.subParser("tables")(e, r, t), e = s.subParser("hashHTMLBlocks")(e, r, t),
+ e = s.subParser("paragraphs")(e, r, t), e = t.converter._dispatch("blockGamut.after", e, r, t);
+}), s.subParser("blockQuotes", function(e, r, t) {
+ return e = t.converter._dispatch("blockQuotes.before", e, r, t), e = e.replace(/((^[ \t]{0,3}>[ \t]?.+\n(.+\n)*\n*)+)/gm, function(e, n) {
+ var a = n;
+ return a = a.replace(/^[ \t]*>[ \t]?/gm, "~0"), a = a.replace(/~0/g, ""), a = a.replace(/^[ \t]+$/gm, ""),
+ a = s.subParser("githubCodeBlocks")(a, r, t), a = s.subParser("blockGamut")(a, r, t),
+ a = a.replace(/(^|\n)/g, "$1 "), a = a.replace(/(\s*[^\r]+?<\/pre>)/gm, function(e, r) {
+ var t = r;
+ return t = t.replace(/^ /gm, "~0"), t = t.replace(/~0/g, "");
+ }), s.subParser("hashBlock")("\n" + a + "\n ", r, t);
+ }), e = t.converter._dispatch("blockQuotes.after", e, r, t);
+}), s.subParser("codeBlocks", function(e, r, t) {
+ e = t.converter._dispatch("codeBlocks.before", e, r, t);
+ var n = /(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g;
+ return e = (e += "~0").replace(n, function(e, n, a) {
+ var o = n, i = a, l = "\n";
+ return o = s.subParser("outdent")(o), o = s.subParser("encodeCode")(o), o = s.subParser("detab")(o),
+ o = o.replace(/^\n+/g, ""), o = o.replace(/\n+$/g, ""), r.omitExtraWLInCodeBlocks && (l = ""),
+ o = "" + o + l + "
", s.subParser("hashBlock")(o, r, t) + i;
+ }), e = e.replace(/~0/, ""), e = t.converter._dispatch("codeBlocks.after", e, r, t);
+}), s.subParser("codeSpans", function(e, r, t) {
+ return void 0 === (e = t.converter._dispatch("codeSpans.before", e, r, t)) && (e = ""),
+ e = e.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm, function(e, r, t, n) {
+ var a = n;
+ return a = a.replace(/^([ \t]*)/g, ""), a = a.replace(/[ \t]*$/g, ""), a = s.subParser("encodeCode")(a),
+ r + "" + a + "
";
+ }), e = t.converter._dispatch("codeSpans.after", e, r, t);
+}), s.subParser("detab", function(e) {
+ return e = e.replace(/\t(?=\t)/g, " "), e = e.replace(/\t/g, "~A~B"), e = e.replace(/~B(.+?)~A/g, function(e, r) {
+ for (var t = r, n = 4 - t.length % 4, s = 0; s < n; s++) t += " ";
+ return t;
+ }), e = e.replace(/~A/g, " "), e = e.replace(/~B/g, "");
+}), s.subParser("encodeAmpsAndAngles", function(e) {
+ return e = e.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g, "&"), e = e.replace(/<(?![a-z\/?\$!])/gi, "<");
+}), s.subParser("encodeBackslashEscapes", function(e) {
+ return e = e.replace(/\\(\\)/g, s.helper.escapeCharactersCallback), e = e.replace(/\\([`*_{}\[\]()>#+-.!])/g, s.helper.escapeCharactersCallback);
+}), s.subParser("encodeCode", function(e) {
+ return e = e.replace(/&/g, "&"), e = e.replace(//g, ">"),
+ e = s.helper.escapeCharacters(e, "*_{}[]\\", !1);
+}), s.subParser("encodeEmailAddress", function(e) {
+ var r = [ function(e) {
+ return "" + e.charCodeAt(0) + ";";
+ }, function(e) {
+ return "" + e.charCodeAt(0).toString(16) + ";";
+ }, function(e) {
+ return e;
+ } ];
+ return e = "mailto:" + e, e = e.replace(/./g, function(e) {
+ if ("@" === e) e = r[Math.floor(2 * Math.random())](e); else if (":" !== e) {
+ var t = Math.random();
+ e = t > .9 ? r[2](e) : t > .45 ? r[1](e) : r[0](e);
+ }
+ return e;
+ }), e = '' + e + " ", e = e.replace(/">.+:/g, '">');
+}), s.subParser("escapeSpecialCharsWithinTagAttributes", function(e) {
+ var r = /(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|)/gi;
+ return e = e.replace(r, function(e) {
+ var r = e.replace(/(.)<\/?code>(?=.)/g, "$1`");
+ return r = s.helper.escapeCharacters(r, "\\`*_", !1);
+ });
+}), s.subParser("githubCodeBlocks", function(e, r, t) {
+ return r.ghCodeBlocks ? (e = t.converter._dispatch("githubCodeBlocks.before", e, r, t),
+ e += "~0", e = e.replace(/(?:^|\n)```(.*)\n([\s\S]*?)\n```/g, function(e, n, a) {
+ var o = r.omitExtraWLInCodeBlocks ? "" : "\n";
+ return a = s.subParser("encodeCode")(a), a = s.subParser("detab")(a), a = a.replace(/^\n+/g, ""),
+ a = a.replace(/\n+$/g, ""), a = "" + a + o + "
",
+ a = s.subParser("hashBlock")(a, r, t), "\n\n~G" + (t.ghCodeBlocks.push({
+ text: e,
+ codeblock: a
+ }) - 1) + "G\n\n";
+ }), e = e.replace(/~0/, ""), t.converter._dispatch("githubCodeBlocks.after", e, r, t)) : e;
+}), s.subParser("hashBlock", function(e, r, t) {
+ return e = e.replace(/(^\n+|\n+$)/g, ""), "\n\n~K" + (t.gHtmlBlocks.push(e) - 1) + "K\n\n";
+}), s.subParser("hashElement", function(e, r, t) {
+ return function(e, r) {
+ var n = r;
+ return n = n.replace(/\n\n/g, "\n"), n = n.replace(/^\n/, ""), n = n.replace(/\n+$/g, ""),
+ n = "\n\n~K" + (t.gHtmlBlocks.push(n) - 1) + "K\n\n";
+ };
+}), s.subParser("hashHTMLBlocks", function(e, r, t) {
+ for (var n = [ "pre", "div", "h1", "h2", "h3", "h4", "h5", "h6", "blockquote", "table", "dl", "ol", "ul", "script", "noscript", "form", "fieldset", "iframe", "math", "style", "section", "header", "footer", "nav", "article", "aside", "address", "audio", "canvas", "figure", "hgroup", "output", "video", "p" ], a = 0; a < n.length; ++a) e = s.helper.replaceRecursiveRegExp(e, function(e, r, n, s) {
+ var a = e;
+ return -1 !== n.search(/\bmarkdown\b/) && (a = n + t.converter.makeHtml(r) + s),
+ "\n\n~K" + (t.gHtmlBlocks.push(a) - 1) + "K\n\n";
+ }, "^(?: |\\t){0,3}<" + n[a] + "\\b[^>]*>", "" + n[a] + ">", "gim");
+ return e = e.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g, s.subParser("hashElement")(e, r, t)),
+ e = e.replace(/()/g, s.subParser("hashElement")(e, r, t)), e = e.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g, s.subParser("hashElement")(e, r, t));
+}), s.subParser("hashHTMLSpans", function(e, r, t) {
+ for (var n = s.helper.matchRecursiveRegExp(e, "]*>", "
", "gi"), a = 0; a < n.length; ++a) e = e.replace(n[a][0], "~L" + (t.gHtmlSpans.push(n[a][0]) - 1) + "L");
+ return e;
+}), s.subParser("unhashHTMLSpans", function(e, r, t) {
+ for (var n = 0; n < t.gHtmlSpans.length; ++n) e = e.replace("~L" + n + "L", t.gHtmlSpans[n]);
+ return e;
+}), s.subParser("hashPreCodeTags", function(e, r, t) {
+ return e = s.helper.replaceRecursiveRegExp(e, function(e, r, n, a) {
+ var o = n + s.subParser("encodeCode")(r) + a;
+ return "\n\n~G" + (t.ghCodeBlocks.push({
+ text: e,
+ codeblock: o
+ }) - 1) + "G\n\n";
+ }, "^(?: |\\t){0,3}]*>\\s*]*>", "^(?: |\\t){0,3}
\\s* ", "gim");
+}), s.subParser("headers", function(e, r, t) {
+ function n(e) {
+ var r, n = e.replace(/[^\w]/g, "").toLowerCase();
+ return t.hashLinkCounts[n] ? r = n + "-" + t.hashLinkCounts[n]++ : (r = n, t.hashLinkCounts[n] = 1),
+ !0 === a && (a = "section"), s.helper.isString(a) ? a + r : r;
+ }
+ e = t.converter._dispatch("headers.before", e, r, t);
+ var a = r.prefixHeaderId, o = isNaN(parseInt(r.headerLevelStart)) ? 1 : parseInt(r.headerLevelStart), i = r.smoothLivePreview ? /^(.+)[ \t]*\n={2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n=+[ \t]*\n+/gm, l = r.smoothLivePreview ? /^(.+)[ \t]*\n-{2,}[ \t]*\n+/gm : /^(.+)[ \t]*\n-+[ \t]*\n+/gm;
+ return e = e.replace(i, function(e, a) {
+ var i = s.subParser("spanGamut")(a, r, t), l = r.noHeaderId ? "" : ' id="' + n(a) + '"', c = o, u = "" + i + " ";
+ return s.subParser("hashBlock")(u, r, t);
+ }), e = e.replace(l, function(e, a) {
+ var i = s.subParser("spanGamut")(a, r, t), l = r.noHeaderId ? "" : ' id="' + n(a) + '"', c = o + 1, u = "" + i + " ";
+ return s.subParser("hashBlock")(u, r, t);
+ }), e = e.replace(/^(#{1,6})[ \t]*(.+?)[ \t]*#*\n+/gm, function(e, a, i) {
+ var l = s.subParser("spanGamut")(i, r, t), c = r.noHeaderId ? "" : ' id="' + n(i) + '"', u = o - 1 + a.length, p = "" + l + " ";
+ return s.subParser("hashBlock")(p, r, t);
+ }), e = t.converter._dispatch("headers.after", e, r, t);
+}), s.subParser("images", function(e, r, t) {
+ function n(e, r, n, a, o, i, l, c) {
+ var u = t.gUrls, p = t.gTitles, h = t.gDimensions;
+ if (n = n.toLowerCase(), c || (c = ""), "" === a || null === a) {
+ if ("" !== n && null !== n || (n = r.toLowerCase().replace(/ ?\n/g, " ")), a = "#" + n,
+ s.helper.isUndefined(u[n])) return e;
+ a = u[n], s.helper.isUndefined(p[n]) || (c = p[n]), s.helper.isUndefined(h[n]) || (o = h[n].width,
+ i = h[n].height);
+ }
+ r = r.replace(/"/g, """), r = s.helper.escapeCharacters(r, "*_", !1);
+ var d = ' ";
+ }
+ var a = /!\[(.*?)]\s?\([ \t]*()(\S+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(['"])(.*?)\6[ \t]*)?\)/g, o = /!\[([^\]]*?)] ?(?:\n *)?\[(.*?)]()()()()()/g;
+ return e = (e = t.converter._dispatch("images.before", e, r, t)).replace(o, n),
+ e = e.replace(a, n), e = t.converter._dispatch("images.after", e, r, t);
+}), s.subParser("italicsAndBold", function(e, r, t) {
+ return e = t.converter._dispatch("italicsAndBold.before", e, r, t), e = r.literalMidWordUnderscores ? (e = (e = (e = e.replace(/(^|\s|>|\b)__(?=\S)([\s\S]+?)__(?=\b|<|\s|$)/gm, "$1$2 ")).replace(/(^|\s|>|\b)_(?=\S)([\s\S]+?)_(?=\b|<|\s|$)/gm, "$1$2 ")).replace(/(\*\*)(?=\S)([^\r]*?\S[*]*)\1/g, "$2 ")).replace(/(\*)(?=\S)([^\r]*?\S)\1/g, "$2 ") : (e = e.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g, "$2 ")).replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g, "$2 "),
+ e = t.converter._dispatch("italicsAndBold.after", e, r, t);
+}), s.subParser("lists", function(e, r, t) {
+ function n(e, n) {
+ t.gListLevel++, e = e.replace(/\n{2,}$/, "\n"), e += "~0";
+ var a = /(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+((\[(x|X| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm, o = /\n[ \t]*\n(?!~0)/.test(e);
+ return e = e.replace(a, function(e, n, a, i, l, c, u) {
+ u = u && "" !== u.trim();
+ var p = s.subParser("outdent")(l, r, t), h = "";
+ return c && r.tasklists && (h = ' class="task-list-item" style="list-style-type: none;"',
+ p = p.replace(/^[ \t]*\[(x|X| )?]/m, function() {
+ var e = ' ";
+ })), n || p.search(/\n{2,}/) > -1 ? (p = s.subParser("githubCodeBlocks")(p, r, t),
+ p = s.subParser("blockGamut")(p, r, t)) : (p = (p = s.subParser("lists")(p, r, t)).replace(/\n$/, ""),
+ p = o ? s.subParser("paragraphs")(p, r, t) : s.subParser("spanGamut")(p, r, t)),
+ p = "\n " + p + " \n";
+ }), e = e.replace(/~0/g, ""), t.gListLevel--, n && (e = e.replace(/\s+$/, "")),
+ e;
+ }
+ function a(e, r, t) {
+ var s = "ul" === r ? /^ {0,2}\d+\.[ \t]/gm : /^ {0,2}[*+-][ \t]/gm, a = [], o = "";
+ if (-1 !== e.search(s)) {
+ !function e(a) {
+ var i = a.search(s);
+ -1 !== i ? (o += "\n\n<" + r + ">" + n(a.slice(0, i), !!t) + "" + r + ">\n\n",
+ s = "ul" === (r = "ul" === r ? "ol" : "ul") ? /^ {0,2}\d+\.[ \t]/gm : /^ {0,2}[*+-][ \t]/gm,
+ e(a.slice(i))) : o += "\n\n<" + r + ">" + n(a, !!t) + "" + r + ">\n\n";
+ }(e);
+ for (var i = 0; i < a.length; ++i) ;
+ } else o = "\n\n<" + r + ">" + n(e, !!t) + "" + r + ">\n\n";
+ return o;
+ }
+ e = t.converter._dispatch("lists.before", e, r, t), e += "~0";
+ var o = /^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;
+ return t.gListLevel ? e = e.replace(o, function(e, r, t) {
+ return a(r, t.search(/[*+-]/g) > -1 ? "ul" : "ol", !0);
+ }) : (o = /(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm,
+ e = e.replace(o, function(e, r, t, n) {
+ return a(t, n.search(/[*+-]/g) > -1 ? "ul" : "ol");
+ })), e = e.replace(/~0/, ""), e = t.converter._dispatch("lists.after", e, r, t);
+}), s.subParser("outdent", function(e) {
+ return e = e.replace(/^(\t|[ ]{1,4})/gm, "~0"), e = e.replace(/~0/g, "");
+}), s.subParser("paragraphs", function(e, r, t) {
+ for (var n = (e = (e = (e = t.converter._dispatch("paragraphs.before", e, r, t)).replace(/^\n+/g, "")).replace(/\n+$/g, "")).split(/\n{2,}/g), a = [], o = n.length, i = 0; i < o; i++) {
+ var l = n[i];
+ l.search(/~(K|G)(\d+)\1/g) >= 0 ? a.push(l) : (l = (l = s.subParser("spanGamut")(l, r, t)).replace(/^([ \t]*)/g, ""),
+ l += "
", a.push(l));
+ }
+ for (o = a.length, i = 0; i < o; i++) {
+ for (var c = "", u = a[i], p = !1; u.search(/~(K|G)(\d+)\1/) >= 0; ) {
+ var h = RegExp.$1, d = RegExp.$2;
+ c = (c = "K" === h ? t.gHtmlBlocks[d] : p ? s.subParser("encodeCode")(t.ghCodeBlocks[d].text) : t.ghCodeBlocks[d].codeblock).replace(/\$/g, "$$$$"),
+ u = u.replace(/(\n\n)?~(K|G)\d+\2(\n\n)?/, c), /^]*>\s*]*>/.test(u) && (p = !0);
+ }
+ a[i] = u;
+ }
+ return e = a.join("\n\n"), e = e.replace(/^\n+/g, ""), e = e.replace(/\n+$/g, ""),
+ t.converter._dispatch("paragraphs.after", e, r, t);
+}), s.subParser("runExtension", function(e, r, t, n) {
+ if (e.filter) r = e.filter(r, n.converter, t); else if (e.regex) {
+ var s = e.regex;
+ !s instanceof RegExp && (s = new RegExp(s, "g")), r = r.replace(s, e.replace);
+ }
+ return r;
+}), s.subParser("spanGamut", function(e, r, t) {
+ return e = t.converter._dispatch("spanGamut.before", e, r, t), e = s.subParser("codeSpans")(e, r, t),
+ e = s.subParser("escapeSpecialCharsWithinTagAttributes")(e, r, t), e = s.subParser("encodeBackslashEscapes")(e, r, t),
+ e = s.subParser("images")(e, r, t), e = s.subParser("anchors")(e, r, t), e = s.subParser("autoLinks")(e, r, t),
+ e = s.subParser("encodeAmpsAndAngles")(e, r, t), e = s.subParser("italicsAndBold")(e, r, t),
+ e = s.subParser("strikethrough")(e, r, t), e = e.replace(/ +\n/g, " \n"),
+ e = t.converter._dispatch("spanGamut.after", e, r, t);
+}), s.subParser("strikethrough", function(e, r, t) {
+ return r.strikethrough && (e = (e = t.converter._dispatch("strikethrough.before", e, r, t)).replace(/(?:~T){2}([\s\S]+?)(?:~T){2}/g, "$1"),
+ e = t.converter._dispatch("strikethrough.after", e, r, t)), e;
+}), s.subParser("stripBlankLines", function(e) {
+ return e.replace(/^[ \t]+$/gm, "");
+}), s.subParser("stripLinkDefinitions", function(e, r, t) {
+ var n = /^ {0,3}\[(.+)]:[ \t]*\n?[ \t]*(\S+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n+|(?=~0))/gm;
+ return e += "~0", e = e.replace(n, function(e, n, a, o, i, l, c) {
+ return n = n.toLowerCase(), t.gUrls[n] = s.subParser("encodeAmpsAndAngles")(a),
+ l ? l + c : (c && (t.gTitles[n] = c.replace(/"|'/g, """)), r.parseImgDimensions && o && i && (t.gDimensions[n] = {
+ width: o,
+ height: i
+ }), "");
+ }), e = e.replace(/~0/, "");
+}), s.subParser("tables", function(e, r, t) {
+ function n(e) {
+ return /^:[ \t]*--*$/.test(e) ? ' style="text-align:left;"' : /^--*[ \t]*:[ \t]*$/.test(e) ? ' style="text-align:right;"' : /^:[ \t]*--*[ \t]*:$/.test(e) ? ' style="text-align:center;"' : "";
+ }
+ function a(e, n) {
+ var a = "";
+ return e = e.trim(), r.tableHeaderId && (a = ' id="' + e.replace(/ /g, "_").toLowerCase() + '"'),
+ e = s.subParser("spanGamut")(e, r, t), "" + e + " \n";
+ }
+ function o(e, n) {
+ return "" + s.subParser("spanGamut")(e, r, t) + " \n";
+ }
+ function i(e, r) {
+ for (var t = "\n\n\n", n = e.length, s = 0; s < n; ++s) t += e[s];
+ for (t += " \n \n\n", s = 0; s < r.length; ++s) {
+ t += "\n";
+ for (var a = 0; a < n; ++a) t += r[s][a];
+ t += " \n";
+ }
+ return t += " \n
\n";
+ }
+ if (!r.tables) return e;
+ var l = /^[ \t]{0,3}\|?.+\|.+\n[ \t]{0,3}\|?[ \t]*:?[ \t]*(?:-|=){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:-|=){2,}[\s\S]+?(?:\n\n|~0)/gm;
+ return e = t.converter._dispatch("tables.before", e, r, t), e = e.replace(l, function(e) {
+ var r, t = e.split("\n");
+ for (r = 0; r < t.length; ++r) /^[ \t]{0,3}\|/.test(t[r]) && (t[r] = t[r].replace(/^[ \t]{0,3}\|/, "")),
+ /\|[ \t]*$/.test(t[r]) && (t[r] = t[r].replace(/\|[ \t]*$/, ""));
+ var l = t[0].split("|").map(function(e) {
+ return e.trim();
+ }), c = t[1].split("|").map(function(e) {
+ return e.trim();
+ }), u = [], p = [], h = [], d = [];
+ for (t.shift(), t.shift(), r = 0; r < t.length; ++r) "" !== t[r].trim() && u.push(t[r].split("|").map(function(e) {
+ return e.trim();
+ }));
+ if (l.length < c.length) return e;
+ for (r = 0; r < c.length; ++r) h.push(n(c[r]));
+ for (r = 0; r < l.length; ++r) s.helper.isUndefined(h[r]) && (h[r] = ""), p.push(a(l[r], h[r]));
+ for (r = 0; r < u.length; ++r) {
+ for (var f = [], g = 0; g < p.length; ++g) s.helper.isUndefined(u[r][g]), f.push(o(u[r][g], h[g]));
+ d.push(f);
+ }
+ return i(p, d);
+ }), e = t.converter._dispatch("tables.after", e, r, t);
+}), s.subParser("unescapeSpecialChars", function(e) {
+ return e = e.replace(/~E(\d+)E/g, function(e, r) {
+ var t = parseInt(r);
+ return String.fromCharCode(t);
+ });
+}), module.exports = s;
\ No newline at end of file
diff --git a/utils/wxParse/wxDiscode.js b/utils/wxParse/wxDiscode.js
new file mode 100644
index 0000000..50dc774
--- /dev/null
+++ b/utils/wxParse/wxDiscode.js
@@ -0,0 +1,74 @@
+function e(e) {
+ return e = e.replace(/∀/g, "∀"), e = e.replace(/∂/g, "∂"), e = e.replace(/&exists;/g, "∃"),
+ e = e.replace(/∅/g, "∅"), e = e.replace(/∇/g, "∇"), e = e.replace(/∈/g, "∈"),
+ e = e.replace(/∉/g, "∉"), e = e.replace(/∋/g, "∋"), e = e.replace(/∏/g, "∏"),
+ e = e.replace(/∑/g, "∑"), e = e.replace(/−/g, "−"), e = e.replace(/∗/g, "∗"),
+ e = e.replace(/√/g, "√"), e = e.replace(/∝/g, "∝"), e = e.replace(/∞/g, "∞"),
+ e = e.replace(/∠/g, "∠"), e = e.replace(/∧/g, "∧"), e = e.replace(/∨/g, "∨"),
+ e = e.replace(/∩/g, "∩"), e = e.replace(/∩/g, "∪"), e = e.replace(/∫/g, "∫"),
+ e = e.replace(/∴/g, "∴"), e = e.replace(/∼/g, "∼"), e = e.replace(/≅/g, "≅"),
+ e = e.replace(/≈/g, "≈"), e = e.replace(/≠/g, "≠"), e = e.replace(/≤/g, "≤"),
+ e = e.replace(/≥/g, "≥"), e = e.replace(/⊂/g, "⊂"), e = e.replace(/⊃/g, "⊃"),
+ e = e.replace(/⊄/g, "⊄"), e = e.replace(/⊆/g, "⊆"), e = e.replace(/⊇/g, "⊇"),
+ e = e.replace(/⊕/g, "⊕"), e = e.replace(/⊗/g, "⊗"), e = e.replace(/⊥/g, "⊥"),
+ e = e.replace(/⋅/g, "⋅");
+}
+
+function a(e) {
+ return e = e.replace(/Α/g, "Α"), e = e.replace(/Β/g, "Β"), e = e.replace(/Γ/g, "Γ"),
+ e = e.replace(/Δ/g, "Δ"), e = e.replace(/Ε/g, "Ε"), e = e.replace(/Ζ/g, "Ζ"),
+ e = e.replace(/Η/g, "Η"), e = e.replace(/Θ/g, "Θ"), e = e.replace(/Ι/g, "Ι"),
+ e = e.replace(/Κ/g, "Κ"), e = e.replace(/Λ/g, "Λ"), e = e.replace(/Μ/g, "Μ"),
+ e = e.replace(/Ν/g, "Ν"), e = e.replace(/Ξ/g, "Ν"), e = e.replace(/Ο/g, "Ο"),
+ e = e.replace(/Π/g, "Π"), e = e.replace(/Ρ/g, "Ρ"), e = e.replace(/Σ/g, "Σ"),
+ e = e.replace(/Τ/g, "Τ"), e = e.replace(/Υ/g, "Υ"), e = e.replace(/Φ/g, "Φ"),
+ e = e.replace(/Χ/g, "Χ"), e = e.replace(/Ψ/g, "Ψ"), e = e.replace(/Ω/g, "Ω"),
+ e = e.replace(/α/g, "α"), e = e.replace(/β/g, "β"), e = e.replace(/γ/g, "γ"),
+ e = e.replace(/δ/g, "δ"), e = e.replace(/ε/g, "ε"), e = e.replace(/ζ/g, "ζ"),
+ e = e.replace(/η/g, "η"), e = e.replace(/θ/g, "θ"), e = e.replace(/ι/g, "ι"),
+ e = e.replace(/κ/g, "κ"), e = e.replace(/λ/g, "λ"), e = e.replace(/μ/g, "μ"),
+ e = e.replace(/ν/g, "ν"), e = e.replace(/ξ/g, "ξ"), e = e.replace(/ο/g, "ο"),
+ e = e.replace(/π/g, "π"), e = e.replace(/ρ/g, "ρ"), e = e.replace(/ς/g, "ς"),
+ e = e.replace(/σ/g, "σ"), e = e.replace(/τ/g, "τ"), e = e.replace(/υ/g, "υ"),
+ e = e.replace(/φ/g, "φ"), e = e.replace(/χ/g, "χ"), e = e.replace(/ψ/g, "ψ"),
+ e = e.replace(/ω/g, "ω"), e = e.replace(/ϑ/g, "ϑ"), e = e.replace(/ϒ/g, "ϒ"),
+ e = e.replace(/ϖ/g, "ϖ"), e = e.replace(/·/g, "·");
+}
+
+function r(e) {
+ return e = e.replace(/ /g, " "), e = e.replace(/"/g, "'"), e = e.replace(/&/g, "&"),
+ e = e.replace(/</g, "<"), e = e.replace(/>/g, ">"), e = e.replace(/•/g, "•");
+}
+
+function l(e) {
+ return e = e.replace(/Œ/g, "Œ"), e = e.replace(/œ/g, "œ"), e = e.replace(/Š/g, "Š"),
+ e = e.replace(/š/g, "š"), e = e.replace(/Ÿ/g, "Ÿ"), e = e.replace(/ƒ/g, "ƒ"),
+ e = e.replace(/ˆ/g, "ˆ"), e = e.replace(/˜/g, "˜"), e = e.replace(/ /g, ""),
+ e = e.replace(/ /g, ""), e = e.replace(/ /g, ""), e = e.replace(//g, ""),
+ e = e.replace(//g, ""), e = e.replace(//g, ""), e = e.replace(//g, ""),
+ e = e.replace(/–/g, "–"), e = e.replace(/—/g, "—"), e = e.replace(/‘/g, "‘"),
+ e = e.replace(/’/g, "’"), e = e.replace(/‚/g, "‚"), e = e.replace(/“/g, "“"),
+ e = e.replace(/”/g, "”"), e = e.replace(/„/g, "„"), e = e.replace(/†/g, "†"),
+ e = e.replace(/‡/g, "‡"), e = e.replace(/•/g, "•"), e = e.replace(/…/g, "…"),
+ e = e.replace(/‰/g, "‰"), e = e.replace(/′/g, "′"), e = e.replace(/″/g, "″"),
+ e = e.replace(/‹/g, "‹"), e = e.replace(/›/g, "›"), e = e.replace(/‾/g, "‾"),
+ e = e.replace(/€/g, "€"), e = e.replace(/™/g, "™"), e = e.replace(/←/g, "←"),
+ e = e.replace(/↑/g, "↑"), e = e.replace(/→/g, "→"), e = e.replace(/↓/g, "↓"),
+ e = e.replace(/↔/g, "↔"), e = e.replace(/↵/g, "↵"), e = e.replace(/⌈/g, "⌈"),
+ e = e.replace(/⌉/g, "⌉"), e = e.replace(/⌊/g, "⌊"), e = e.replace(/⌋/g, "⌋"),
+ e = e.replace(/◊/g, "◊"), e = e.replace(/♠/g, "♠"), e = e.replace(/♣/g, "♣"),
+ e = e.replace(/♥/g, "♥"), e = e.replace(/♦/g, "♦"), e = e.replace(/'/g, "'");
+}
+
+function p(e) {
+ return e = e.replace(/\r\n/g, ""), e = e.replace(/\n/g, ""), e = e.replace(/code/g, "wxxxcode-style");
+}
+
+module.exports = {
+ strDiscode: function(c) {
+ return c = e(c), c = a(c), c = r(c), c = l(c), c = p(c);
+ },
+ urlToHttpUrl: function(e, a) {
+ return new RegExp("^//").test(e) && (e = a + ":" + e), e;
+ }
+};
\ No newline at end of file
diff --git a/utils/wxParse/wxParse.js b/utils/wxParse/wxParse.js
new file mode 100644
index 0000000..d35ffaf
--- /dev/null
+++ b/utils/wxParse/wxParse.js
@@ -0,0 +1,83 @@
+function e(e) {
+ return e && e.__esModule ? e : {
+ default: e
+ };
+}
+
+function t(e, t, a) {
+ return t in e ? Object.defineProperty(e, t, {
+ value: a,
+ enumerable: !0,
+ configurable: !0,
+ writable: !0
+ }) : e[t] = a, e;
+}
+
+function a(e) {
+ var t = this, a = e.target.dataset.src, i = e.target.dataset.from;
+ void 0 !== i && i.length > 0 && wx.previewImage({
+ current: a,
+ urls: t.data[i].imageUrls
+ });
+}
+
+function i(e) {
+ var t = this, a = e.target.dataset.from, i = e.target.dataset.idx;
+ void 0 !== a && a.length > 0 && r(e, i, t, a);
+}
+
+function r(e, a, i, r) {
+ var o, d = i.data[r];
+ if (d && 0 != d.images.length) {
+ var s = d.images, l = n(e.detail.width, e.detail.height, i, r), g = s[a].index, h = "" + r, m = !0, u = !1, v = void 0;
+ try {
+ for (var f, w = g.split(".")[Symbol.iterator](); !(m = (f = w.next()).done); m = !0) h += ".nodes[" + f.value + "]";
+ } catch (e) {
+ u = !0, v = e;
+ } finally {
+ try {
+ !m && w.return && w.return();
+ } finally {
+ if (u) throw v;
+ }
+ }
+ var c = h + ".width", x = h + ".height";
+ i.setData((o = {}, t(o, c, l.imageWidth), t(o, x, l.imageheight), o));
+ }
+}
+
+function n(e, t, a, i) {
+ var r = 0, n = 0, o = 0, d = {}, g = a.data[i].view.imagePadding;
+ return r = s - 2 * g, l, e > r ? (o = (n = r) * t / e, d.imageWidth = n, d.imageheight = o) : (d.imageWidth = e,
+ d.imageheight = t), d;
+}
+
+var o = e(require("./showdown.js")), d = e(require("./html2json.js")), s = 0, l = 0;
+
+wx.getSystemInfo({
+ success: function(e) {
+ s = e.windowWidth, l = e.windowHeight;
+ }
+}), module.exports = {
+ wxParse: function() {
+ var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "wxParseData", t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "html", r = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : '数据不能为空
', n = arguments[3], s = arguments[4], l = n, g = {};
+ if ("html" == t) g = d.default.html2json(r, e), console.log(JSON.stringify(g, " ", " ")); else if ("md" == t || "markdown" == t) {
+ var h = new o.default.Converter().makeHtml(r);
+ g = d.default.html2json(h, e), console.log(JSON.stringify(g, " ", " "));
+ }
+ g.view = {}, g.view.imagePadding = 0, void 0 !== s && (g.view.imagePadding = s);
+ var m = {};
+ m[e] = g, l.setData(m), l.wxParseImgLoad = i, l.wxParseImgTap = a;
+ },
+ wxParseTemArray: function(e, t, a, i) {
+ for (var r = [], n = i.data, o = null, d = 0; d < a; d++) {
+ var s = n[t + d].nodes;
+ r.push(s);
+ }
+ e = e || "wxParseTemArray", (o = JSON.parse('{"' + e + '":""}'))[e] = r, i.setData(o);
+ },
+ emojisInit: function() {
+ var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "", t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "/wxParse/emojis/", a = arguments[2];
+ d.default.emojisInit(e, t, a);
+ }
+};
\ No newline at end of file
diff --git a/utils/wxParse/wxParse.wxml b/utils/wxParse/wxParse.wxml
new file mode 100644
index 0000000..6a73bec
--- /dev/null
+++ b/utils/wxParse/wxParse.wxml
@@ -0,0 +1,386 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{item.text}}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/utils/wxParse/wxParse.wxss b/utils/wxParse/wxParse.wxss
new file mode 100644
index 0000000..11f43ac
--- /dev/null
+++ b/utils/wxParse/wxParse.wxss
@@ -0,0 +1,256 @@
+.wxParse {
+ margin: 0 5px;
+ font-family: Helvetica,sans-serif;
+ font-size: 28rpx;
+ color: #666;
+ line-height: 1.8;
+}
+
+view.wxParse {
+ word-break: break-all;
+ overflow: auto;
+ margin-top: 20rpx;
+}
+
+view.wxParse view{
+ word-break: break-all;
+ overflow: auto;
+}
+
+.wxParse-inline {
+ display: inline;
+ margin: 0;
+ padding: 0;
+}
+
+.wxParse-div {
+ margin: 0;
+ padding: 0;
+}
+
+.wxParse-h1 {
+ font-size: 2em;
+ margin: .67em 0;
+}
+
+.wxParse-h2 {
+ font-size: 1.5em;
+ margin: .75em 0;
+}
+
+.wxParse-h3 {
+ font-size: 1.17em;
+ margin: .83em 0;
+}
+
+.wxParse-h4 {
+ margin: 1.12em 0;
+}
+
+.wxParse-h5 {
+ font-size: .83em;
+ margin: 1.5em 0;
+}
+
+.wxParse-h6 {
+ font-size: .75em;
+ margin: 1.67em 0;
+}
+
+.wxParse-h1 {
+ font-size: 18px;
+ font-weight: 400;
+ margin-bottom: .9em;
+}
+
+.wxParse-h2 {
+ font-size: 16px;
+ font-weight: 400;
+ margin-bottom: .34em;
+}
+
+.wxParse-h3 {
+ font-weight: 400;
+ font-size: 15px;
+ margin-bottom: .34em;
+}
+
+.wxParse-h4 {
+ font-weight: 400;
+ font-size: 14px;
+ margin-bottom: .24em;
+}
+
+.wxParse-h5 {
+ font-weight: 400;
+ font-size: 13px;
+ margin-bottom: .14em;
+}
+
+.wxParse-h6 {
+ font-weight: 400;
+ font-size: 12px;
+ margin-bottom: .04em;
+}
+
+.wxParse-h1,.wxParse-h2,.wxParse-h3,.wxParse-h4,.wxParse-h5,.wxParse-h6,.wxParse-b,.wxParse-strong {
+ font-weight: bolder;
+}
+
+.wxParse-i,.wxParse-cite,.wxParse-em,.wxParse-var,.wxParse-address {
+ font-style: italic;
+}
+
+.wxParse-pre,.wxParse-tt,.wxParse-code,.wxParse-kbd,.wxParse-samp {
+ font-family: monospace;
+}
+
+.wxParse-pre {
+ white-space: pre;
+}
+
+.wxParse-big {
+ font-size: 1.17em;
+}
+
+.wxParse-small,.wxParse-sub,.wxParse-sup {
+ font-size: .83em;
+}
+
+.wxParse-sub {
+ vertical-align: sub;
+}
+
+.wxParse-sup {
+ vertical-align: super;
+}
+
+.wxParse-s,.wxParse-strike,.wxParse-del {
+ text-decoration: line-through;
+}
+
+.wxParse-strong,.wxParse-s {
+ display: inline;
+}
+
+.wxParse-a {
+ color: deepskyblue;
+ word-break: break-all;
+ overflow: auto;
+}
+
+.wxParse-video {
+ text-align: center;
+ margin: 10px 0;
+}
+
+.wxParse-video-video {
+ width: 100%;
+}
+
+.wxParse-img {
+ overflow: hidden;
+}
+
+.wxParse-blockquote {
+ margin: 0;
+ padding: 10px 0 10px 5px;
+ font-family: Courier,Calibri,"宋体";
+ background: #f5f5f5;
+ border-left: 3px solid #dbdbdb;
+}
+
+.wxParse-code,.wxParse-wxxxcode-style {
+ display: inline;
+ background: #f5f5f5;
+}
+
+.wxParse-ul {
+ margin: 20rpx 10rpx;
+}
+
+.wxParse-li,.wxParse-li-inner {
+ display: flex;
+ align-items: baseline;
+ margin: 10rpx 0;
+}
+
+.wxParse-li-text {
+ align-items: center;
+ line-height: 20px;
+}
+
+.wxParse-li-circle {
+ display: inline-flex;
+ width: 5px;
+ height: 5px;
+ background-color: #333;
+ margin-right: 5px;
+}
+
+.wxParse-li-square {
+ display: inline-flex;
+ width: 10rpx;
+ height: 10rpx;
+ background-color: #333;
+ margin-right: 5px;
+}
+
+.wxParse-li-ring {
+ display: inline-flex;
+ width: 10rpx;
+ height: 10rpx;
+ border: 2rpx solid #333;
+ border-radius: 50%;
+ background-color: #fff;
+ margin-right: 5px;
+}
+
+.wxParse-u {
+ text-decoration: underline;
+}
+
+.wxParse-hide {
+ display: none;
+}
+
+.WxEmojiView {
+ align-items: center;
+}
+
+.wxEmoji {
+ width: 16px;
+ height: 16px;
+}
+
+.wxParse-tr {
+ display: flex;
+ border-right: 1px solid #e0e0e0;
+ border-bottom: 1px solid #e0e0e0;
+ border-top: 1px solid #e0e0e0;
+}
+
+.wxParse-th,.wxParse-td {
+ flex: 1;
+ padding: 5px;
+ font-size: 28rpx;
+ border-left: 1px solid #e0e0e0;
+ word-break: break-all;
+}
+
+.wxParse-td:last {
+ border-top: 1px solid #e0e0e0;
+}
+
+.wxParse-th {
+ background: #f0f0f0;
+ border-top: 1px solid #e0e0e0;
+}
+
+.wxParse-del {
+ display: inline;
+}
+
+.wxParse-figure {
+ overflow: hidden;
+}
\ No newline at end of file