mirror of
https://github.com/documize/community.git
synced 2025-08-08 15:05:28 +02:00
lint encoding
This commit is contained in:
parent
40d61d4146
commit
f44695186b
1 changed files with 15 additions and 13 deletions
|
@ -28,13 +28,13 @@ var Base64 = {
|
||||||
u = (r & 15) << 2 | i >> 6;
|
u = (r & 15) << 2 | i >> 6;
|
||||||
a = i & 63;
|
a = i & 63;
|
||||||
if (isNaN(r)) {
|
if (isNaN(r)) {
|
||||||
u = a = 64
|
u = a = 64;
|
||||||
} else if (isNaN(i)) {
|
} else if (isNaN(i)) {
|
||||||
a = 64
|
a = 64;
|
||||||
}
|
}
|
||||||
t = t + this._keyStr.charAt(s) + this._keyStr.charAt(o) + this._keyStr.charAt(u) + this._keyStr.charAt(a)
|
t = t + this._keyStr.charAt(s) + this._keyStr.charAt(o) + this._keyStr.charAt(u) + this._keyStr.charAt(a);
|
||||||
}
|
}
|
||||||
return t
|
return t;
|
||||||
},
|
},
|
||||||
decode: function(e) {
|
decode: function(e) {
|
||||||
var t = "";
|
var t = "";
|
||||||
|
@ -51,15 +51,15 @@ var Base64 = {
|
||||||
r = (o & 15) << 4 | u >> 2;
|
r = (o & 15) << 4 | u >> 2;
|
||||||
i = (u & 3) << 6 | a;
|
i = (u & 3) << 6 | a;
|
||||||
t = t + String.fromCharCode(n);
|
t = t + String.fromCharCode(n);
|
||||||
if (u != 64) {
|
if (u !== 64) {
|
||||||
t = t + String.fromCharCode(r)
|
t = t + String.fromCharCode(r);
|
||||||
}
|
}
|
||||||
if (a != 64) {
|
if (a !== 64) {
|
||||||
t = t + String.fromCharCode(i)
|
t = t + String.fromCharCode(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t = Base64._utf8_decode(t);
|
t = Base64._utf8_decode(t);
|
||||||
return t
|
return t;
|
||||||
},
|
},
|
||||||
_utf8_encode: function(e) {
|
_utf8_encode: function(e) {
|
||||||
e = e.replace(/\r\n/g, "\n");
|
e = e.replace(/\r\n/g, "\n");
|
||||||
|
@ -67,10 +67,10 @@ var Base64 = {
|
||||||
for (var n = 0; n < e.length; n++) {
|
for (var n = 0; n < e.length; n++) {
|
||||||
var r = e.charCodeAt(n);
|
var r = e.charCodeAt(n);
|
||||||
if (r < 128) {
|
if (r < 128) {
|
||||||
t += String.fromCharCode(r)
|
t += String.fromCharCode(r);
|
||||||
} else if (r > 127 && r < 2048) {
|
} else if (r > 127 && r < 2048) {
|
||||||
t += String.fromCharCode(r >> 6 | 192);
|
t += String.fromCharCode(r >> 6 | 192);
|
||||||
t += String.fromCharCode(r & 63 | 128)
|
t += String.fromCharCode(r & 63 | 128);
|
||||||
} else {
|
} else {
|
||||||
t += String.fromCharCode(r >> 12 | 224);
|
t += String.fromCharCode(r >> 12 | 224);
|
||||||
t += String.fromCharCode(r >> 6 & 63 | 128);
|
t += String.fromCharCode(r >> 6 & 63 | 128);
|
||||||
|
@ -82,7 +82,9 @@ var Base64 = {
|
||||||
_utf8_decode: function(e) {
|
_utf8_decode: function(e) {
|
||||||
var t = "";
|
var t = "";
|
||||||
var n = 0;
|
var n = 0;
|
||||||
var r = c1 = c2 = 0;
|
let r = 0;
|
||||||
|
// let c1 = 0;
|
||||||
|
let c2 = 0;
|
||||||
while (n < e.length) {
|
while (n < e.length) {
|
||||||
r = e.charCodeAt(n);
|
r = e.charCodeAt(n);
|
||||||
if (r < 128) {
|
if (r < 128) {
|
||||||
|
@ -94,7 +96,7 @@ var Base64 = {
|
||||||
n += 2;
|
n += 2;
|
||||||
} else {
|
} else {
|
||||||
c2 = e.charCodeAt(n + 1);
|
c2 = e.charCodeAt(n + 1);
|
||||||
c3 = e.charCodeAt(n + 2);
|
let c3 = e.charCodeAt(n + 2);
|
||||||
t += String.fromCharCode((r & 15) << 12 | (c2 & 63) << 6 | c3 & 63);
|
t += String.fromCharCode((r & 15) << 12 | (c2 & 63) << 6 | c3 & 63);
|
||||||
n += 3;
|
n += 3;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue