Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var LZString = {
- _f: String.fromCharCode,
- _keyStrBase64: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
- _keyStrUriSafe: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",
- _getBaseValue: function(a, b) {
- if (LZString._baseReverseDic || (LZString._baseReverseDic = {}), !LZString._baseReverseDic[a]) {
- LZString._baseReverseDic[a] = {};
- for (var c = 0; c < a.length; c++) LZString._baseReverseDic[a][a[c]] = c;
- }
- return LZString._baseReverseDic[a][b];
- },
- compressToBase64: function(a) {
- if (null == a) return "";
- var b = LZString._compress(a, 6, function(a) {
- return LZString._keyStrBase64.charAt(a);
- });
- switch (b.length % 4) {
- default:
- case 0:
- return b;
- case 1:
- return b + "===";
- case 2:
- return b + "==";
- case 3:
- return b + "=";
- }
- },
- decompressFromBase64: function(a) {
- return null == a ? "" : "" == a ? null : LZString._decompress(a.length, 32, function(b) {
- return LZString._getBaseValue(LZString._keyStrBase64, a.charAt(b));
- });
- },
- compressToUTF16: function(a) {
- return null == a ? "" : LZString._compress(a, 15, function(a) {
- return String.fromCharCode(a + 32);
- }) + " ";
- },
- decompressFromUTF16: function(a) {
- return null == a ? "" : "" == a ? null : LZString._decompress(a.length, 16384, function(b) {
- return a.charCodeAt(b) - 32;
- });
- },
- compressToUint8Array: function(a) {
- for (var b = LZString.compress(a), c = new Uint8Array(2 * b.length), d = 0, e = b.length; e > d; d++) {
- var f = b.charCodeAt(d);
- c[2 * d] = f >>> 8, c[2 * d + 1] = f % 256;
- }
- return c;
- },
- decompressFromUint8Array: function(a) {
- if (null === a || void 0 === a) return LZString.decompress(a);
- for (var b = new Array(a.length / 2), c = 0, d = b.length; d > c; c++) b[c] = 256 * a[2 * c] + a[2 * c + 1];
- var e = [];
- return b.forEach(function(a) {
- e.push(String.fromCharCode(a));
- }), LZString.decompress(e.join(""));
- },
- compressToEncodedURIComponent: function(a) {
- return null == a ? "" : LZString._compress(a, 6, function(a) {
- return LZString._keyStrUriSafe.charAt(a);
- });
- },
- decompressFromEncodedURIComponent: function(a) {
- return null == a ? "" : "" == a ? null : (a = a.replace(/ /g, "+"), LZString._decompress(a.length, 32, function(b) {
- return LZString._getBaseValue(LZString._keyStrUriSafe, a.charAt(b));
- }));
- },
- compress: function(a) {
- return LZString._compress(a, 16, function(a) {
- return String.fromCharCode(a);
- });
- },
- _compress: function(a, b, c) {
- if (null == a) return "";
- var d, e, f, g = {}, h = {}, i = "", j = "", k = "", l = 2, m = 3, n = 2, o = [], p = 0, q = 0;
- LZString._f;
- for (f = 0; f < a.length; f += 1) if (i = a[f], Object.prototype.hasOwnProperty.call(g, i) || (g[i] = m++,
- h[i] = !0), j = k + i, Object.prototype.hasOwnProperty.call(g, j)) k = j; else {
- if (Object.prototype.hasOwnProperty.call(h, k)) {
- if (k.charCodeAt(0) < 256) {
- for (d = 0; n > d; d++) p <<= 1, q == b - 1 ? (q = 0, o.push(c(p)), p = 0) : q++;
- for (e = k.charCodeAt(0), d = 0; 8 > d; d++) p = p << 1 | 1 & e, q == b - 1 ? (q = 0,
- o.push(c(p)), p = 0) : q++, e >>= 1;
- } else {
- for (e = 1, d = 0; n > d; d++) p = p << 1 | e, q == b - 1 ? (q = 0, o.push(c(p)),
- p = 0) : q++, e = 0;
- for (e = k.charCodeAt(0), d = 0; 16 > d; d++) p = p << 1 | 1 & e, q == b - 1 ? (q = 0,
- o.push(c(p)), p = 0) : q++, e >>= 1;
- }
- l--, 0 == l && (l = Math.pow(2, n), n++), delete h[k];
- } else for (e = g[k], d = 0; n > d; d++) p = p << 1 | 1 & e, q == b - 1 ? (q = 0,
- o.push(c(p)), p = 0) : q++, e >>= 1;
- l--, 0 == l && (l = Math.pow(2, n), n++), g[j] = m++, k = String(i);
- }
- if ("" !== k) {
- if (Object.prototype.hasOwnProperty.call(h, k)) {
- if (k.charCodeAt(0) < 256) {
- for (d = 0; n > d; d++) p <<= 1, q == b - 1 ? (q = 0, o.push(c(p)), p = 0) : q++;
- for (e = k.charCodeAt(0), d = 0; 8 > d; d++) p = p << 1 | 1 & e, q == b - 1 ? (q = 0,
- o.push(c(p)), p = 0) : q++, e >>= 1;
- } else {
- for (e = 1, d = 0; n > d; d++) p = p << 1 | e, q == b - 1 ? (q = 0, o.push(c(p)),
- p = 0) : q++, e = 0;
- for (e = k.charCodeAt(0), d = 0; 16 > d; d++) p = p << 1 | 1 & e, q == b - 1 ? (q = 0,
- o.push(c(p)), p = 0) : q++, e >>= 1;
- }
- l--, 0 == l && (l = Math.pow(2, n), n++), delete h[k];
- } else for (e = g[k], d = 0; n > d; d++) p = p << 1 | 1 & e, q == b - 1 ? (q = 0,
- o.push(c(p)), p = 0) : q++, e >>= 1;
- l--, 0 == l && (l = Math.pow(2, n), n++);
- }
- for (e = 2, d = 0; n > d; d++) p = p << 1 | 1 & e, q == b - 1 ? (q = 0, o.push(c(p)),
- p = 0) : q++, e >>= 1;
- for (;;) {
- if (p <<= 1, q == b - 1) {
- o.push(c(p));
- break;
- }
- q++;
- }
- return o.join("");
- },
- decompress: function(a) {
- return null == a ? "" : "" == a ? null : LZString._decompress(a.length, 32768, function(b) {
- return a.charCodeAt(b);
- });
- },
- _decompress: function(a, b, c) {
- var d, e, f, g, h, i, j, k, l = [], m = 4, n = 4, o = 3, p = "", q = [], r = LZString._f, s = {
- val: c(0),
- position: b,
- index: 1
- };
- for (e = 0; 3 > e; e += 1) l[e] = e;
- for (g = 0, i = Math.pow(2, 2), j = 1; j != i; ) h = s.val & s.position, s.position >>= 1,
- 0 == s.position && (s.position = b, s.val = c(s.index++)), g |= (h > 0 ? 1 : 0) * j,
- j <<= 1;
- switch (d = g) {
- case 0:
- for (g = 0, i = Math.pow(2, 8), j = 1; j != i; ) h = s.val & s.position, s.position >>= 1,
- 0 == s.position && (s.position = b, s.val = c(s.index++)), g |= (h > 0 ? 1 : 0) * j,
- j <<= 1;
- k = r(g);
- break;
- case 1:
- for (g = 0, i = Math.pow(2, 16), j = 1; j != i; ) h = s.val & s.position, s.position >>= 1,
- 0 == s.position && (s.position = b, s.val = c(s.index++)), g |= (h > 0 ? 1 : 0) * j,
- j <<= 1;
- k = r(g);
- break;
- case 2:
- return "";
- }
- for (l[3] = k, f = k, q.push(k); ;) {
- if (s.index > a) return "";
- for (g = 0, i = Math.pow(2, o), j = 1; j != i; ) h = s.val & s.position, s.position >>= 1,
- 0 == s.position && (s.position = b, s.val = c(s.index++)), g |= (h > 0 ? 1 : 0) * j,
- j <<= 1;
- switch (k = g) {
- case 0:
- for (g = 0, i = Math.pow(2, 8), j = 1; j != i; ) h = s.val & s.position, s.position >>= 1,
- 0 == s.position && (s.position = b, s.val = c(s.index++)), g |= (h > 0 ? 1 : 0) * j,
- j <<= 1;
- l[n++] = r(g), k = n - 1, m--;
- break;
- case 1:
- for (g = 0, i = Math.pow(2, 16), j = 1; j != i; ) h = s.val & s.position, s.position >>= 1,
- 0 == s.position && (s.position = b, s.val = c(s.index++)), g |= (h > 0 ? 1 : 0) * j,
- j <<= 1;
- l[n++] = r(g), k = n - 1, m--;
- break;
- case 2:
- return q.join("");
- }
- if (0 == m && (m = Math.pow(2, o), o++), l[k]) p = l[k]; else {
- if (k !== n) return null;
- p = f + f[0];
- }
- q.push(p), l[n++] = f + p[0], m--, f = p, 0 == m && (m = Math.pow(2, o), o++);
- }
- }
- };
- "undefined" != typeof module && null != module && (module.exports = LZString);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement