Replaced jsHint with eslint. Fixes #4.

This commit is contained in:
n1474335 2016-12-14 16:39:17 +00:00
parent e2e68dd876
commit af4644c9eb
48 changed files with 1741 additions and 1685 deletions

View file

@ -44,14 +44,14 @@ var Base64 = {
var alphabet = args[0] || Base64.ALPHABET;
return Utils.to_base64(input, alphabet);
},
/**
* @constant
* @default
*/
REMOVE_NON_ALPH_CHARS: true,
/**
* From Base64 operation.
*
@ -62,17 +62,17 @@ var Base64 = {
run_from: function(input, args) {
var alphabet = args[0] || Base64.ALPHABET,
remove_non_alph_chars = args[1];
return Utils.from_base64(input, alphabet, "byte_array", remove_non_alph_chars);
},
/**
* @constant
* @default
*/
BASE32_ALPHABET: "A-Z2-7=",
/**
* To Base32 operation.
*
@ -82,7 +82,7 @@ var Base64 = {
*/
run_to_32: function(input, args) {
if (!input) return "";
var alphabet = args[0] ?
Utils.expand_alph_range(args[0]).join("") : "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",
output = "",
@ -115,16 +115,16 @@ var Base64 = {
} else if (isNaN(chr5)) {
enc8 = 32;
}
output += alphabet.charAt(enc1) + alphabet.charAt(enc2) + alphabet.charAt(enc3) +
alphabet.charAt(enc4) + alphabet.charAt(enc5) + alphabet.charAt(enc6) +
alphabet.charAt(enc7) + alphabet.charAt(enc8);
}
return output;
},
/**
* From Base32 operation.
*
@ -134,16 +134,16 @@ var Base64 = {
*/
run_from_32: function(input, args) {
if (!input) return [];
var alphabet = args[0] ?
Utils.expand_alph_range(args[0]).join("") : "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",
remove_non_alph_chars = args[0];
var output = [],
chr1, chr2, chr3, chr4, chr5,
enc1, enc2, enc3, enc4, enc5, enc6, enc7, enc8,
i = 0;
if (remove_non_alph_chars) {
var re = new RegExp("[^" + alphabet.replace(/[\]\\\-^]/g, "\\$&") + "]", "g");
input = input.replace(re, "");
@ -171,11 +171,11 @@ var Base64 = {
if (enc5 & 1 !== 0 || enc6 !== 32) output.push(chr4);
if (enc7 & 7 !== 0 || enc8 !== 32) output.push(chr5);
}
return output;
},
/**
* @constant
* @default
@ -186,7 +186,7 @@ var Base64 = {
* @default
*/
OFFSETS_SHOW_VARIABLE: true,
/**
* Show Base64 offsets operation.
*
@ -206,96 +206,96 @@ var Base64 = {
script = "<script type='application/javascript'>$('[data-toggle=\"tooltip\"]').tooltip()</script>",
static_section = "",
padding = "";
if (input.length < 1) {
return "Please enter a string.";
}
// Highlight offset 0
if (len0 % 4 == 2) {
if (len0 % 4 === 2) {
static_section = offset0.slice(0, -3);
offset0 = "<span data-toggle='tooltip' data-placement='top' title='" +
offset0 = "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.escape_html(Utils.from_base64(static_section, alphabet).slice(0, -2)) + "'>" +
static_section + "</span>" +
"<span class='hlgreen'>" + offset0.substr(offset0.length - 3, 1) + "</span>" +
"<span class='hlred'>" + offset0.substr(offset0.length - 2) + "</span>";
} else if (len0 % 4 == 3) {
} else if (len0 % 4 === 3) {
static_section = offset0.slice(0, -2);
offset0 = "<span data-toggle='tooltip' data-placement='top' title='" +
offset0 = "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.escape_html(Utils.from_base64(static_section, alphabet).slice(0, -1)) + "'>" +
static_section + "</span>" +
"<span class='hlgreen'>" + offset0.substr(offset0.length - 2, 1) + "</span>" +
"<span class='hlred'>" + offset0.substr(offset0.length - 1) + "</span>";
} else {
static_section = offset0;
offset0 = "<span data-toggle='tooltip' data-placement='top' title='" +
offset0 = "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.escape_html(Utils.from_base64(static_section, alphabet)) + "'>" +
static_section + "</span>";
}
if (!show_variable) {
offset0 = static_section;
}
// Highlight offset 1
padding = "<span class='hlred'>" + offset1.substr(0, 1) + "</span>" +
"<span class='hlgreen'>" + offset1.substr(1, 1) + "</span>";
offset1 = offset1.substr(2);
if (len1 % 4 == 2) {
if (len1 % 4 === 2) {
static_section = offset1.slice(0, -3);
offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.escape_html(Utils.from_base64("AA" + static_section, alphabet).slice(1, -2)) + "'>" +
static_section + "</span>" +
"<span class='hlgreen'>" + offset1.substr(offset1.length - 3, 1) + "</span>" +
"<span class='hlred'>" + offset1.substr(offset1.length - 2) + "</span>";
} else if (len1 % 4 == 3) {
} else if (len1 % 4 === 3) {
static_section = offset1.slice(0, -2);
offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.escape_html(Utils.from_base64("AA" + static_section, alphabet).slice(1, -1)) + "'>" +
static_section + "</span>" +
"<span class='hlgreen'>" + offset1.substr(offset1.length - 2, 1) + "</span>" +
"<span class='hlred'>" + offset1.substr(offset1.length - 1) + "</span>";
} else {
static_section = offset1;
offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.escape_html(Utils.from_base64("AA" + static_section, alphabet).slice(1)) + "'>" +
static_section + "</span>";
}
if (!show_variable) {
offset1 = static_section;
}
// Highlight offset 2
padding = "<span class='hlred'>" + offset2.substr(0, 2) + "</span>" +
"<span class='hlgreen'>" + offset2.substr(2, 1) + "</span>";
offset2 = offset2.substr(3);
if (len2 % 4 == 2) {
if (len2 % 4 === 2) {
static_section = offset2.slice(0, -3);
offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.escape_html(Utils.from_base64("AAA" + static_section, alphabet).slice(2, -2)) + "'>" +
static_section + "</span>" +
"<span class='hlgreen'>" + offset2.substr(offset2.length - 3, 1) + "</span>" +
"<span class='hlred'>" + offset2.substr(offset2.length - 2) + "</span>";
} else if (len2 % 4 == 3) {
} else if (len2 % 4 === 3) {
static_section = offset2.slice(0, -2);
offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.escape_html(Utils.from_base64("AAA" + static_section, alphabet).slice(2, -2)) + "'>" +
static_section + "</span>" +
"<span class='hlgreen'>" + offset2.substr(offset2.length - 2, 1) + "</span>" +
"<span class='hlred'>" + offset2.substr(offset2.length - 1) + "</span>";
} else {
static_section = offset2;
offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.escape_html(Utils.from_base64("AAA" + static_section, alphabet).slice(2)) + "'>" +
static_section + "</span>";
}
if (!show_variable) {
offset2 = static_section;
}
return (show_variable ? "Characters highlighted in <span class='hlgreen'>green</span> could change if the input is surrounded by more data." +
"\nCharacters highlighted in <span class='hlred'>red</span> are for padding purposes only." +
"\nUnhighlighted characters are <span data-toggle='tooltip' data-placement='top' title='Tooltip on left'>static</span>." +
@ -306,8 +306,8 @@ var Base64 = {
script :
offset0 + "\n" + offset1 + "\n" + offset2);
},
/**
* Highlight to Base64
*
@ -322,7 +322,7 @@ var Base64 = {
pos[0].end = Math.ceil(pos[0].end / 3 * 4);
return pos;
},
/**
* Highlight from Base64
*
@ -337,5 +337,5 @@ var Base64 = {
pos[0].end = Math.floor(pos[0].end / 4 * 3);
return pos;
},
};

View file

@ -32,9 +32,9 @@ var BitwiseOp = {
for (var i = 0; i < input.length; i++) {
k = key[i % key.length];
o = input[i];
x = null_preserving && (o === 0 || o == k) ? o : func(o, k);
x = null_preserving && (o === 0 || o === k) ? o : func(o, k);
result.push(x);
if (scheme != "Standard" && !(null_preserving && (o === 0 || o == k))) {
if (scheme !== "Standard" && !(null_preserving && (o === 0 || o === k))) {
switch (scheme) {
case "Input differential":
key[i % key.length] = x;

View file

@ -26,7 +26,7 @@ var ByteRepr = {
* @default
*/
BIN_DELIM_OPTIONS: ["Space", "Comma", "Semi-colon", "Colon", "Line feed", "CRLF", "None"],
/**
* To Hex operation.
*
@ -38,8 +38,8 @@ var ByteRepr = {
var delim = Utils.char_rep[args[0] || "Space"];
return Utils.to_hex(input, delim, 2);
},
/**
* From Hex operation.
*
@ -51,14 +51,14 @@ var ByteRepr = {
var delim = args[0] || "Space";
return Utils.from_hex(input, delim, 2);
},
/**
* @constant
* @default
*/
CHARCODE_BASE: 16,
/**
* To Charcode operation.
*
@ -72,34 +72,34 @@ var ByteRepr = {
output = "",
padding = 2,
ordinal;
if (base < 2 || base > 36) {
throw "Error: Base argument must be between 2 and 36";
}
for (var i = 0; i < input.length; i++) {
ordinal = Utils.ord(input[i]);
if (base == 16) {
if (base === 16) {
if (ordinal < 256) padding = 2;
else if (ordinal < 65536) padding = 4;
else if (ordinal < 16777216) padding = 6;
else if (ordinal < 4294967296) padding = 8;
else padding = 2;
if (padding > 2) app.options.attempt_highlight = false;
output += Utils.hex(ordinal, padding) + delim;
} else {
app.options.attempt_highlight = false;
output += ordinal.toString(base) + delim;
}
}
return output.slice(0, -delim.length);
},
/**
* From Charcode operation.
*
@ -112,32 +112,32 @@ var ByteRepr = {
base = args[1],
bites = input.split(delim),
i = 0;
if (base < 2 || base > 36) {
throw "Error: Base argument must be between 2 and 36";
}
if (base != 16) {
if (base !== 16) {
app.options.attempt_highlight = false;
}
// Split into groups of 2 if the whole string is concatenated and
// Split into groups of 2 if the whole string is concatenated and
// too long to be a single character
if (bites.length == 1 && input.length > 17) {
if (bites.length === 1 && input.length > 17) {
bites = [];
for (i = 0; i < input.length; i += 2) {
bites.push(input.slice(i, i+2));
}
}
var latin1 = "";
for (i = 0; i < bites.length; i++) {
latin1 += Utils.chr(parseInt(bites[i], base));
}
return Utils.str_to_byte_array(latin1);
},
/**
* Highlight to hex
*
@ -149,20 +149,20 @@ var ByteRepr = {
*/
highlight_to: function(pos, args) {
var delim = Utils.char_rep[args[0] || "Space"],
len = delim == "\r\n" ? 1 : delim.length;
len = delim === "\r\n" ? 1 : delim.length;
pos[0].start = pos[0].start * (2 + len);
pos[0].end = pos[0].end * (2 + len) - len;
// 0x and \x are added to the beginning if they are selected, so increment the positions accordingly
if (delim == "0x" || delim == "\\x") {
if (delim === "0x" || delim === "\\x") {
pos[0].start += 2;
pos[0].end += 2;
}
return pos;
},
/**
* Highlight to hex
*
@ -174,23 +174,23 @@ var ByteRepr = {
*/
highlight_from: function(pos, args) {
var delim = Utils.char_rep[args[0] || "Space"],
len = delim == "\r\n" ? 1 : delim.length,
len = delim === "\r\n" ? 1 : delim.length,
width = len + 2;
// 0x and \x are added to the beginning if they are selected, so increment the positions accordingly
if (delim == "0x" || delim == "\\x") {
if (delim === "0x" || delim === "\\x") {
if (pos[0].start > 1) pos[0].start -= 2;
else pos[0].start = 0;
if (pos[0].end > 1) pos[0].end -= 2;
else pos[0].end = 0;
}
pos[0].start = pos[0].start === 0 ? 0 : Math.round(pos[0].start / width);
pos[0].end = pos[0].end === 0 ? 0 : Math.ceil(pos[0].end / width);
return pos;
},
/**
* To Decimal operation.
*
@ -202,8 +202,8 @@ var ByteRepr = {
var delim = Utils.char_rep[args[0]];
return input.join(delim);
},
/**
* From Decimal operation.
*
@ -216,14 +216,14 @@ var ByteRepr = {
var byte_str = input.split(delim), output = [];
if (byte_str[byte_str.length-1] === "")
byte_str = byte_str.slice(0, byte_str.length-1);
for (var i = 0; i < byte_str.length; i++) {
output[i] = parseInt(byte_str[i]);
output[i] = parseInt(byte_str[i], 10);
}
return output;
},
/**
* To Binary operation.
*
@ -235,19 +235,19 @@ var ByteRepr = {
var delim = Utils.char_rep[args[0] || "Space"],
output = "",
padding = 8;
for (var i = 0; i < input.length; i++) {
output += Utils.pad(input[i].toString(2), padding) + delim;
}
if (delim.length) {
return output.slice(0, -delim.length);
} else {
return output;
}
},
/**
* From Binary operation.
*
@ -256,11 +256,11 @@ var ByteRepr = {
* @returns {byte_array}
*/
run_from_binary: function(input, args) {
if (args[0] != "None") {
if (args[0] !== "None") {
var delim_regex = Utils.regex_rep[args[0] || "Space"];
input = input.replace(delim_regex, '');
input = input.replace(delim_regex, "");
}
var output = [];
var byte_len = 8;
for (var i = 0; i < input.length; i += byte_len) {
@ -268,8 +268,8 @@ var ByteRepr = {
}
return output;
},
/**
* Highlight to binary
*
@ -285,8 +285,8 @@ var ByteRepr = {
pos[0].end = pos[0].end * (8 + delim.length) - delim.length;
return pos;
},
/**
* Highlight from binary
*
@ -302,8 +302,8 @@ var ByteRepr = {
pos[0].end = pos[0].end === 0 ? 0 : Math.ceil(pos[0].end / (8 + delim.length));
return pos;
},
/**
* @constant
* @default
@ -314,7 +314,7 @@ var ByteRepr = {
* @default
*/
HEX_CONTENT_SPACES_BETWEEN_BYTES: false,
/**
* To Hex Content operation.
*
@ -325,19 +325,19 @@ var ByteRepr = {
run_to_hex_content: function(input, args) {
var convert = args[0];
var spaces = args[1];
if (convert == "All chars") {
if (convert === "All chars") {
var result = "|" + Utils.to_hex(input) + "|";
if (!spaces) result = result.replace(/ /g, "");
return result;
}
var output = "",
in_hex = false,
convert_spaces = convert == "Only special chars including spaces",
convert_spaces = convert === "Only special chars including spaces",
b;
for (var i = 0; i < input.length; i++) {
b = input[i];
if ((b == 32 && convert_spaces) || (b < 48 && b != 32) || (b > 57 && b < 65) || (b > 90 && b < 97) || b > 122) {
if ((b === 32 && convert_spaces) || (b < 48 && b !== 32) || (b > 57 && b < 65) || (b > 90 && b < 97) || b > 122) {
if (!in_hex) {
output += "|";
in_hex = true;
@ -354,8 +354,8 @@ var ByteRepr = {
if (in_hex) output += "|";
return output;
},
/**
* From Hex Content operation.
*
@ -366,11 +366,11 @@ var ByteRepr = {
run_from_hex_content: function(input, args) {
var regex = /\|([a-f\d ]{2,})\|/gi;
var output = [], m, i = 0;
while (!!(m = regex.exec(input))) {
while ((m = regex.exec(input))) {
// Add up to match
for (; i < m.index;)
output.push(Utils.ord(input[i++]));
// Add match
var bytes = Utils.from_hex(m[1]);
if (bytes) {
@ -381,13 +381,13 @@ var ByteRepr = {
for (; i < regex.lastIndex;)
output.push(Utils.ord(input[i++]));
}
i = regex.lastIndex;
}
// Add all after final match
for (; i < input.length;)
output.push(Utils.ord(input[i++]));
return output;
},

View file

@ -28,14 +28,14 @@ var CharEnc = {
var input_format = args[0],
output_format = args[1];
if (input_format == "Windows-1251") {
if (input_format === "Windows-1251") {
input = Utils.win1251_to_unicode(input);
input = CryptoJS.enc.Utf8.parse(input);
} else {
input = Utils.format[input_format].parse(input);
}
if (output_format == "Windows-1251") {
if (output_format === "Windows-1251") {
input = CryptoJS.enc.Utf8.stringify(input);
return Utils.unicode_to_win1251(input);
} else {

View file

@ -10,7 +10,7 @@
* @namespace
*/
var Cipher = {
/**
* @constant
* @default
@ -46,8 +46,8 @@ var Cipher = {
* @default
*/
RESULT_TYPE: ["Show all", "Ciphertext", "Key", "IV", "Salt"],
/**
* Runs encryption operations using the CryptoJS framework.
*
@ -65,21 +65,21 @@ var Cipher = {
padding = CryptoJS.pad[args[4]],
result_option = args[5].toLowerCase(),
output_format = args[6];
if (iv.sigBytes === 0) {
// Use passphrase rather than key. Need to convert it to a string.
key = key.toString(CryptoJS.enc.Latin1);
}
var encrypted = algo.encrypt(input, key, {
salt: salt.sigBytes > 0 ? salt : false,
iv: iv.sigBytes > 0 ? iv : null,
mode: mode,
padding: padding
});
var result = "";
if (result_option == "show all") {
if (result_option === "show all") {
result += "Key: " + encrypted.key.toString(Utils.format[output_format]);
result += "\nIV: " + encrypted.iv.toString(Utils.format[output_format]);
if (encrypted.salt) result += "\nSalt: " + encrypted.salt.toString(Utils.format[output_format]);
@ -87,11 +87,11 @@ var Cipher = {
} else {
result = encrypted[result_option].toString(Utils.format[output_format]);
}
return result;
},
/**
* Runs decryption operations using the CryptoJS framework.
*
@ -109,39 +109,39 @@ var Cipher = {
padding = CryptoJS.pad[args[4]],
input_format = args[5],
output_format = args[6];
// The ZeroPadding option causes a crash when the input length is 0
if (!input.length) {
return "No input";
}
}
var ciphertext = Utils.format[input_format].parse(input);
if (iv.sigBytes === 0) {
// Use passphrase rather than key. Need to convert it to a string.
key = key.toString(CryptoJS.enc.Latin1);
}
var decrypted = algo.decrypt({
ciphertext: ciphertext,
salt: salt.sigBytes > 0 ? salt : false
}, key, {
iv: iv.sigBytes > 0 ? iv : null,
mode: mode,
padding: padding
});
ciphertext: ciphertext,
salt: salt.sigBytes > 0 ? salt : false
}, key, {
iv: iv.sigBytes > 0 ? iv : null,
mode: mode,
padding: padding
});
var result;
try {
result = decrypted.toString(Utils.format[output_format]);
} catch (err) {
result = "Decrypt error: " + err.message;
}
return result;
},
/**
* AES Encrypt operation.
*
@ -152,8 +152,8 @@ var Cipher = {
run_aes_enc: function (input, args) {
return Cipher._enc(CryptoJS.AES, input, args);
},
/**
* AES Decrypt operation.
*
@ -164,8 +164,8 @@ var Cipher = {
run_aes_dec: function (input, args) {
return Cipher._dec(CryptoJS.AES, input, args);
},
/**
* DES Encrypt operation.
*
@ -176,8 +176,8 @@ var Cipher = {
run_des_enc: function (input, args) {
return Cipher._enc(CryptoJS.DES, input, args);
},
/**
* DES Decrypt operation.
*
@ -188,8 +188,8 @@ var Cipher = {
run_des_dec: function (input, args) {
return Cipher._dec(CryptoJS.DES, input, args);
},
/**
* Triple DES Encrypt operation.
*
@ -200,8 +200,8 @@ var Cipher = {
run_triple_des_enc: function (input, args) {
return Cipher._enc(CryptoJS.TripleDES, input, args);
},
/**
* Triple DES Decrypt operation.
*
@ -212,8 +212,8 @@ var Cipher = {
run_triple_des_dec: function (input, args) {
return Cipher._dec(CryptoJS.TripleDES, input, args);
},
/**
* Rabbit Encrypt operation.
*
@ -224,8 +224,8 @@ var Cipher = {
run_rabbit_enc: function (input, args) {
return Cipher._enc(CryptoJS.Rabbit, input, args);
},
/**
* Rabbit Decrypt operation.
*
@ -236,8 +236,8 @@ var Cipher = {
run_rabbit_dec: function (input, args) {
return Cipher._dec(CryptoJS.Rabbit, input, args);
},
/**
* @constant
* @default
@ -248,7 +248,7 @@ var Cipher = {
* @default
*/
BLOWFISH_OUTPUT_TYPES: ["Base64", "Hex", "String", "Raw"],
/**
* Blowfish Encrypt operation.
*
@ -260,19 +260,19 @@ var Cipher = {
var key = Utils.format[args[0].option].parse(args[0].string).toString(Utils.format.Latin1),
mode = args[1],
output_format = args[2];
if (key.length === 0) return "Enter a key";
var enc_hex = blowfish.encrypt(input, key, {
outputType: 1,
cipherMode: Cipher.BLOWFISH_MODES.indexOf(mode)
}),
enc = CryptoJS.enc.Hex.parse(enc_hex);
return enc.toString(Utils.format[output_format]);
},
/**
* Blowfish Decrypt operation.
*
@ -284,18 +284,18 @@ var Cipher = {
var key = Utils.format[args[0].option].parse(args[0].string).toString(Utils.format.Latin1),
mode = args[1],
input_format = args[2];
if (key.length === 0) return "Enter a key";
input = Utils.format[input_format].parse(input);
return blowfish.decrypt(input.toString(CryptoJS.enc.Base64), key, {
outputType: 0, // This actually means inputType. The library is weird.
cipherMode: Cipher.BLOWFISH_MODES.indexOf(mode)
});
},
/**
* @constant
* @default
@ -306,7 +306,7 @@ var Cipher = {
* @default
*/
KDF_ITERATIONS: 1,
/**
* Derive PBKDF2 key operation.
*
@ -322,11 +322,11 @@ var Cipher = {
output_format = args[4],
passphrase = Utils.format[input_format].parse(input),
key = CryptoJS.PBKDF2(passphrase, salt, { keySize: key_size, iterations: iterations });
return key.toString(Utils.format[output_format]);
},
/**
* Derive EVP key operation.
*
@ -342,11 +342,11 @@ var Cipher = {
output_format = args[4],
passphrase = Utils.format[input_format].parse(input),
key = CryptoJS.EvpKDF(passphrase, salt, { keySize: key_size, iterations: iterations });
return key.toString(Utils.format[output_format]);
},
/**
* RC4 operation.
*
@ -358,17 +358,17 @@ var Cipher = {
var message = Utils.format[args[1]].parse(input),
passphrase = Utils.format[args[0].option].parse(args[0].string),
encrypted = CryptoJS.RC4.encrypt(message, passphrase);
return encrypted.ciphertext.toString(Utils.format[args[2]]);
},
/**
* @constant
* @default
*/
RC4DROP_BYTES: 768,
/**
* RC4 Drop operation.
*
@ -381,10 +381,10 @@ var Cipher = {
passphrase = Utils.format[args[0].option].parse(args[0].string),
drop = args[3],
encrypted = CryptoJS.RC4Drop.encrypt(message, passphrase, { drop: drop });
return encrypted.ciphertext.toString(Utils.format[args[2]]);
},
/**
* Vigenère Encode operation.
@ -481,7 +481,7 @@ var Cipher = {
/**
* Overwriting the CryptoJS OpenSSL key derivation function so that it is possible to not pass a
* salt in.
* @param {string} password - The password to derive from.
* @param {number} keySize - The size in words of the key to generate.
* @param {number} ivSize - The size in words of the IV to generate.

View file

@ -10,7 +10,7 @@
* @namespace
*/
var Code = {
/**
* @constant
* @default
@ -21,7 +21,7 @@ var Code = {
* @default
*/
LINE_NUMS: false,
/**
* Syntax highlighter operation.
*
@ -34,14 +34,14 @@ var Code = {
line_nums = args[1];
return "<code class='prettyprint'>" + prettyPrintOne(Utils.escape_html(input), language, line_nums) + "</code>";
},
/**
* @constant
* @default
*/
BEAUTIFY_INDENT: "\\t",
/**
* XML Beautify operation.
*
@ -53,8 +53,8 @@ var Code = {
var indent_str = args[0];
return vkbeautify.xml(input, indent_str);
},
/**
* JSON Beautify operation.
*
@ -67,8 +67,8 @@ var Code = {
if (!input) return "";
return vkbeautify.json(input, indent_str);
},
/**
* CSS Beautify operation.
*
@ -80,8 +80,8 @@ var Code = {
var indent_str = args[0];
return vkbeautify.css(input, indent_str);
},
/**
* SQL Beautify operation.
*
@ -93,14 +93,14 @@ var Code = {
var indent_str = args[0];
return vkbeautify.sql(input, indent_str);
},
/**
* @constant
* @default
*/
PRESERVE_COMMENTS: false,
/**
* XML Minify operation.
*
@ -112,8 +112,8 @@ var Code = {
var preserve_comments = args[0];
return vkbeautify.xmlmin(input, preserve_comments);
},
/**
* JSON Minify operation.
*
@ -125,8 +125,8 @@ var Code = {
if (!input) return "";
return vkbeautify.jsonmin(input);
},
/**
* CSS Minify operation.
*
@ -138,8 +138,8 @@ var Code = {
var preserve_comments = args[0];
return vkbeautify.cssmin(input, preserve_comments);
},
/**
* SQL Minify operation.
*
@ -150,8 +150,8 @@ var Code = {
run_sql_minify: function(input, args) {
return vkbeautify.sqlmin(input);
},
/**
* Generic Code Beautify operation.
*
@ -160,10 +160,10 @@ var Code = {
* I'm not proud of this code, but seriously, try writing a generic lexer and parser that
* correctly generates an AST for multiple different languages. I have tried, and I can tell
* you it's pretty much impossible.
*
*
* This basically works. That'll have to be good enough. It's not meant to produce working code,
* just slightly more readable code.
*
*
* Things that don't work:
* - For loop formatting
* - Do-While loop formatting
@ -180,66 +180,66 @@ var Code = {
t = 0,
preserved_tokens = [],
m;
// Remove strings
var sstrings = /'([^'\\]|\\.)*'/g;
while (!!(m = sstrings.exec(code))) {
while ((m = sstrings.exec(code))) {
code = preserve_token(code, m, t++);
sstrings.lastIndex = m.index;
}
var dstrings = /"([^"\\]|\\.)*"/g;
while (!!(m = dstrings.exec(code))) {
while ((m = dstrings.exec(code))) {
code = preserve_token(code, m, t++);
dstrings.lastIndex = m.index;
}
// Remove comments
var scomments = /\/\/[^\n\r]*/g;
while (!!(m = scomments.exec(code))) {
while ((m = scomments.exec(code))) {
code = preserve_token(code, m, t++);
scomments.lastIndex = m.index;
}
var mcomments = /\/\*[\s\S]*?\*\//gm;
while (!!(m = mcomments.exec(code))) {
while ((m = mcomments.exec(code))) {
code = preserve_token(code, m, t++);
mcomments.lastIndex = m.index;
}
var hcomments = /(^|\n)#[^\n\r#]+/g;
while (!!(m = hcomments.exec(code))) {
while ((m = hcomments.exec(code))) {
code = preserve_token(code, m, t++);
hcomments.lastIndex = m.index;
}
// Remove regexes
var regexes = /\/.*?[^\\]\/[gim]{0,3}/gi;
while (!!(m = regexes.exec(code))) {
while ((m = regexes.exec(code))) {
code = preserve_token(code, m, t++);
regexes.lastIndex = m.index;
}
// Create newlines after ;
code = code.replace(/;/g, ";\n");
// Create newlines after { and around }
code = code.replace(/{/g, "{\n");
code = code.replace(/}/g, "\n}\n");
// Remove carriage returns
code = code.replace(/\r/g, "");
// Remove all indentation
code = code.replace(/^\s+/g, "");
code = code.replace(/\n\s+/g, "\n");
// Remove trailing spaces
code = code.replace(/\s*$/g, "");
// Remove newlines before {
code = code.replace(/\n{/g, "{");
// Indent
var i = 0,
level = 0;
@ -250,10 +250,10 @@ var Code = {
break;
case "\n":
if (i+1 >= code.length) break;
if (code[i+1] == "}") level--;
if (code[i+1] === "}") level--;
var indent = (level >= 0) ? Array(level*4+1).join(" ") : "";
code = code.substring(0, i+1) + indent + code.substring(i+1);
if (level > 0) i += level*4;
break;
@ -272,30 +272,30 @@ var Code = {
code = code.replace(/\s*,\s*/g, ", ");
code = code.replace(/\s*{/g, " {");
code = code.replace(/}\n/g, "}\n\n");
// Just... don't look at this
code = code.replace(/(if|for|while|with|elif|elseif)\s*\(([^\n]*)\)\s*\n([^{])/gim, "$1 ($2)\n $3");
code = code.replace(/(if|for|while|with|elif|elseif)\s*\(([^\n]*)\)([^{])/gim, "$1 ($2) $3");
code = code.replace(/else\s*\n([^{])/gim, "else\n $1");
code = code.replace(/else\s+([^{])/gim, "else $1");
// Remove strategic spaces
code = code.replace(/\s+;/g, ";");
code = code.replace(/\{\s+\}/g, "{}");
code = code.replace(/\[\s+\]/g, "[]");
code = code.replace(/}\s*(else|catch|except|finally|elif|elseif|else if)/gi, "} $1");
// Replace preserved tokens
var ptokens = /###preserved_token(\d+)###/g;
while (!!(m = ptokens.exec(code))) {
var ti = parseInt(m[1]);
while ((m = ptokens.exec(code))) {
var ti = parseInt(m[1], 10);
code = code.substring(0, m.index) + preserved_tokens[ti] + code.substring(m.index + m[0].length);
ptokens.lastIndex = m.index;
}
return code;
function preserve_token(str, match, t) {
preserved_tokens[t] = match[0];
return str.substring(0, match.index) +

View file

@ -108,12 +108,12 @@ var Compress = {
// ]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]...
// e.g. Input data of [8b, 1d, dc, 44]
// Look for the first two square brackets:
if (result.length > 158 && result[0] == 93 && result[5] == 93) {
if (result.length > 158 && result[0] === 93 && result[5] === 93) {
// If the first two square brackets are there, check that the others
// are also there. If they are, throw an error. If not, continue.
var valid = false;
for (var i = 0; i < 155; i += 5) {
if (result[i] != 93) {
if (result[i] !== 93) {
valid = true;
}
}
@ -172,12 +172,12 @@ var Compress = {
// Deal with character encoding issues
input = Utils.str_to_byte_array(Utils.byte_array_to_utf8(input));
var inflate = new Zlib.Inflate(input, {
index: args[0],
bufferSize: args[1],
bufferType: Compress.ZLIB_BUFFER_TYPE_LOOKUP[args[2]],
resize: args[3],
verify: args[4]
});
index: args[0],
bufferSize: args[1],
bufferType: Compress.ZLIB_BUFFER_TYPE_LOOKUP[args[2]],
resize: args[3],
verify: args[4]
});
return Array.prototype.slice.call(inflate.decompress());
},

View file

@ -31,7 +31,7 @@ var Convert = {
"Centimetres (cm)" : 1e-2,
"Metres (m)" : 1,
"Kilometers (km)" : 1e3,
"Thou (th)" : 0.0000254,
"Inches (in)" : 0.0254,
"Feet (ft)" : 0.3048,
@ -40,23 +40,23 @@ var Convert = {
"Furlongs (fur)" : 201.168,
"Miles (mi)" : 1609.344,
"Leagues (lea)" : 4828.032,
"Fathoms (ftm)" : 1.853184,
"Cables" : 185.3184,
"Nautical miles" : 1853.184,
"Cars (4m)" : 4,
"Buses (8.4m)" : 8.4,
"American football fields (91m)": 91,
"Football pitches (105m)": 105,
"Earth-to-Moons" : 380000000,
"Earth-to-Moons" : 380000000,
"Earth's equators" : 40075016.686,
"Astronomical units (au)": 149597870700,
"Light-years (ly)" : 9460730472580800,
"Parsecs (pc)" : 3.0856776e16
},
/**
* Convert distance operation.
*
@ -67,13 +67,13 @@ var Convert = {
run_distance: function (input, args) {
var input_units = args[0],
output_units = args[1];
input = input * Convert.DISTANCE_FACTOR[input_units];
return input / Convert.DISTANCE_FACTOR[output_units];
// TODO Remove rounding errors (e.g. 1.000000000001)
},
/**
* @constant
* @default
@ -94,7 +94,7 @@ var Convert = {
"Nibbles" : 4,
"Octets" : 8,
"Bytes (B)" : 8,
// Binary bits (2^n)
"Kibibits (Kib)" : 1024,
"Mebibits (Mib)" : 1048576,
@ -104,7 +104,7 @@ var Convert = {
"Exbibits (Eib)" : 1152921504606846976,
"Zebibits (Zib)" : 1180591620717411303424,
"Yobibits (Yib)" : 1208925819614629174706176,
// Decimal bits (10^n)
"Decabits" : 10,
"Hectobits" : 100,
@ -116,7 +116,7 @@ var Convert = {
"Exabits (Eb)" : 1e18,
"Zettabits (Zb)" : 1e21,
"Yottabits (Yb)" : 1e24,
// Binary bytes (8 x 2^n)
"Kibibytes (KiB)" : 8192,
"Mebibytes (MiB)" : 8388608,
@ -126,7 +126,7 @@ var Convert = {
"Exbibytes (EiB)" : 9223372036854775808,
"Zebibytes (ZiB)" : 9444732965739290427392,
"Yobibytes (YiB)" : 9671406556917033397649408,
// Decimal bytes (8 x 10^n)
"Kilobytes (KB)" : 8e3,
"Megabytes (MB)" : 8e6,
@ -137,7 +137,7 @@ var Convert = {
"Zettabytes (ZB)" : 8e21,
"Yottabytes (YB)" : 8e24,
},
/**
* Convert data units operation.
*
@ -148,12 +148,12 @@ var Convert = {
run_data_size: function (input, args) {
var input_units = args[0],
output_units = args[1];
input = input * Convert.DATA_FACTOR[input_units];
return input / Convert.DATA_FACTOR[output_units];
},
/**
* @constant
* @default
@ -173,13 +173,13 @@ var Convert = {
// Metric
"Square metre (sq m)" : 1,
"Square kilometre (sq km)" : 1e6,
"Centiare (ca)" : 1,
"Deciare (da)" : 10,
"Are (a)" : 100,
"Decare (daa)" : 1e3,
"Hectare (ha)" : 1e4,
// Imperial
"Square inch (sq in)" : 0.00064516,
"Square foot (sq ft)" : 0.09290304,
@ -188,12 +188,12 @@ var Convert = {
"Perch (sq per)" : 42.21,
"Rood (ro)" : 1011,
"International acre (ac)" : 4046.8564224,
// US customary units
"US survey acre (ac)" : 4046.87261,
"US survey square mile (sq mi)" : 2589998.470305239,
"US survey township" : 93239944.9309886,
// Nuclear physics
"Yoctobarn (yb)" : 1e-52,
"Zeptobarn (zb)" : 1e-49,
@ -206,18 +206,18 @@ var Convert = {
"Barn (b)" : 1e-28,
"Kilobarn (kb)" : 1e-25,
"Megabarn (Mb)" : 1e-22,
"Planck area" : 2.6e-70,
"Shed" : 1e-52,
"Outhouse" : 1e-34,
// Comparisons
"Washington D.C." : 176119191.502848,
"Isle of Wight" : 380000000,
"Wales" : 20779000000,
"Texas" : 696241000000,
},
/**
* Convert area operation.
*
@ -228,12 +228,12 @@ var Convert = {
run_area: function (input, args) {
var input_units = args[0],
output_units = args[1];
input = input * Convert.AREA_FACTOR[input_units];
return input / Convert.AREA_FACTOR[output_units];
},
/**
* @constant
* @default
@ -274,7 +274,7 @@ var Convert = {
"Exagram (Eg)" : 1e18,
"Zettagram (Zg)" : 1e21,
"Yottagram (Yg)" : 1e24,
// Imperial Avoirdupois
"Grain (gr)" : 64.79891e-3,
"Dram (dr)" : 1.7718451953125,
@ -288,14 +288,14 @@ var Convert = {
"Imperial hundredweight (cwt)" : 50.80234544e3,
"US ton (t)" : 907.18474e3,
"Imperial ton (t)" : 1016.0469088e3,
// Imperial Troy
"Pennyweight (dwt)" : 1.55517384,
"Troy dram (dr t)" : 3.8879346,
"Troy ounce (oz t)" : 31.1034768,
"Troy pound (lb t)" : 373.2417216,
"Mark" : 248.8278144,
// Archaic
"Wey" : 76.5e3,
"Wool wey" : 101.7e3,
@ -308,7 +308,7 @@ var Convert = {
"Gunpowder last" : 1090e3,
"Picul" : 60.478982e3,
"Rice last" : 1200e3,
// Comparisons
"Big Ben (14 tonnes)" : 14e6,
"Blue whale (180 tonnes)" : 180e6,
@ -317,7 +317,7 @@ var Convert = {
"RMS Titanic (52,000 tonnes)" : 52000e6,
"Great Pyramid of Giza (6,000,000 tonnes)" : 6e12,
"Earth's oceans (1.4 yottagrams)" : 1.4e24,
// Astronomical
"A teaspoon of neutron star (5,500 million tonnes)" : 5.5e15,
"Lunar mass (ML)" : 7.342e25,
@ -328,7 +328,7 @@ var Convert = {
"Milky Way galaxy (1.2 x 10^42 kgs)" : 1.2e45,
"The observable universe (1.45 x 10^53 kgs)" : 1.45e56,
},
/**
* Convert mass operation.
*
@ -339,12 +339,12 @@ var Convert = {
run_mass: function (input, args) {
var input_units = args[0],
output_units = args[1];
input = input * Convert.MASS_FACTOR[input_units];
return input / Convert.MASS_FACTOR[output_units];
},
/**
* @constant
* @default
@ -363,11 +363,11 @@ var Convert = {
// Metric
"Metres per second (m/s)" : 1,
"Kilometres per hour (km/h)" : 0.2778,
// Imperial
"Miles per hour (mph)" : 0.44704,
"Knots (kn)" : 0.5144,
// Comparisons
"Human hair growth rate" : 4.8e-9,
"Bamboo growth rate" : 1.4e-5,
@ -378,7 +378,7 @@ var Convert = {
"SR-71 Blackbird" : 981,
"Space Shuttle" : 1400,
"International Space Station" : 7700,
// Scientific
"Sound in standard atmosphere" : 340.3,
"Sound in water" : 1500,
@ -393,7 +393,7 @@ var Convert = {
"Signal in an optical fibre (0.667c)" : 200000000,
"Light (c)" : 299792458,
},
/**
* Convert speed operation.
*
@ -404,9 +404,9 @@ var Convert = {
run_speed: function (input, args) {
var input_units = args[0],
output_units = args[1];
input = input * Convert.SPEED_FACTOR[input_units];
return input / Convert.SPEED_FACTOR[output_units];
},
};

View file

@ -30,16 +30,16 @@ var DateTime = {
input = parseFloat(input);
if (units == "Seconds (s)") {
if (units === "Seconds (s)") {
d = moment.unix(input);
return d.tz("UTC").format("ddd D MMMM YYYY HH:mm:ss") + " UTC";
} else if (units == "Milliseconds (ms)") {
} else if (units === "Milliseconds (ms)") {
d = moment(input);
return d.tz("UTC").format("ddd D MMMM YYYY HH:mm:ss.SSS") + " UTC";
} else if (units == "Microseconds (μs)") {
} else if (units === "Microseconds (μs)") {
d = moment(input / 1000);
return d.tz("UTC").format("ddd D MMMM YYYY HH:mm:ss.SSS") + " UTC";
} else if (units == "Nanoseconds (ns)") {
} else if (units === "Nanoseconds (ns)") {
d = moment(input / 1000000);
return d.tz("UTC").format("ddd D MMMM YYYY HH:mm:ss.SSS") + " UTC";
} else {
@ -59,13 +59,13 @@ var DateTime = {
var units = args[0],
d = moment(input);
if (units == "Seconds (s)") {
if (units === "Seconds (s)") {
return d.unix();
} else if (units == "Milliseconds (ms)") {
} else if (units === "Milliseconds (ms)") {
return d.valueOf();
} else if (units == "Microseconds (μs)") {
} else if (units === "Microseconds (μs)") {
return d.valueOf() * 1000;
} else if (units == "Nanoseconds (ns)") {
} else if (units === "Nanoseconds (ns)") {
return d.valueOf() * 1000000;
} else {
throw "Unrecognised unit";
@ -139,7 +139,7 @@ var DateTime = {
try {
date = moment.tz(input, input_format, input_timezone);
if (!date || date.format() == "Invalid date") throw Error;
if (!date || date.format() === "Invalid date") throw Error;
} catch(err) {
return "Invalid format.\n\n" + DateTime.FORMAT_EXAMPLES;
}
@ -163,7 +163,7 @@ var DateTime = {
try {
date = moment.tz(input, input_format, input_timezone);
if (!date || date.format() == "Invalid date") throw Error;
if (!date || date.format() === "Invalid date") throw Error;
} catch(err) {
return "Invalid format.\n\n" + DateTime.FORMAT_EXAMPLES;
}

View file

@ -25,7 +25,7 @@ var Extract = {
total = 0,
match;
while (!!(match = search_regex.exec(input))) {
while ((match = search_regex.exec(input))) {
if (remove_regex && remove_regex.test(match[0]))
continue;
total++;

View file

@ -18,28 +18,28 @@ var FileType = {
*/
run_detect: function(input, args) {
var type = FileType._magic_type(input);
if (!type) {
return "Unknown file type. Have you tried checking the entropy of this data to determine whether it might be encrypted or compressed?";
} else {
var output = "File extension: " + type.ext + "\n" +
"MIME type: " + type.mime;
if (type.desc && type.desc.length) {
output += "\nDescription: " + type.desc;
}
return output;
}
},
/**
* @constant
* @default
*/
IGNORE_COMMON_BYTE_SEQUENCES: true,
/**
* Scan for Embedded Files operation.
*
@ -54,7 +54,7 @@ var FileType = {
common_exts = ["ico", "ttf", ""],
num_found = 0,
num_common_found = 0;
for (var i = 0; i < input.length; i++) {
type = FileType._magic_type(input.slice(i));
if (type) {
@ -66,31 +66,31 @@ var FileType = {
output += "\nOffset " + i + " (0x" + Utils.hex(i) + "):\n" +
" File extension: " + type.ext + "\n" +
" MIME type: " + type.mime + "\n";
if (type.desc && type.desc.length) {
output += " Description: " + type.desc + "\n";
}
}
}
if (num_found === 0) {
output += "\nNo embedded files were found.";
}
if (num_common_found > 0) {
output += "\n\n" + num_common_found;
output += num_common_found == 1 ?
output += num_common_found === 1 ?
" file type was detected that has a common byte sequence. This is likely to be a false positive." :
" file types were detected that have common byte sequences. These are likely to be false positives.";
" file types were detected that have common byte sequences. These are likely to be false positives.";
output += " Run this operation with the 'Ignore common byte sequences' option unchecked to see details.";
}
return output;
},
/**
* Given a buffer, detects magic byte sequences at specific positions and returns the
* Given a buffer, detects magic byte sequences at specific positions and returns the
* extension and mime type.
*
* @private
@ -107,416 +107,416 @@ var FileType = {
if (buf[0] === 0xFF && buf[1] === 0xD8 && buf[2] === 0xFF) {
return {
ext: 'jpg',
mime: 'image/jpeg'
ext: "jpg",
mime: "image/jpeg"
};
}
if (buf[0] === 0x89 && buf[1] === 0x50 && buf[2] === 0x4E && buf[3] === 0x47) {
return {
ext: 'png',
mime: 'image/png'
ext: "png",
mime: "image/png"
};
}
if (buf[0] === 0x47 && buf[1] === 0x49 && buf[2] === 0x46) {
return {
ext: 'gif',
mime: 'image/gif'
ext: "gif",
mime: "image/gif"
};
}
if (buf[8] === 0x57 && buf[9] === 0x45 && buf[10] === 0x42 && buf[11] === 0x50) {
return {
ext: 'webp',
mime: 'image/webp'
ext: "webp",
mime: "image/webp"
};
}
// needs to be before `tif` check
if (((buf[0] === 0x49 && buf[1] === 0x49 && buf[2] === 0x2A && buf[3] === 0x0) || (buf[0] === 0x4D && buf[1] === 0x4D && buf[2] === 0x0 && buf[3] === 0x2A)) && buf[8] === 0x43 && buf[9] === 0x52) {
return {
ext: 'cr2',
mime: 'image/x-canon-cr2'
ext: "cr2",
mime: "image/x-canon-cr2"
};
}
if ((buf[0] === 0x49 && buf[1] === 0x49 && buf[2] === 0x2A && buf[3] === 0x0) || (buf[0] === 0x4D && buf[1] === 0x4D && buf[2] === 0x0 && buf[3] === 0x2A)) {
return {
ext: 'tif',
mime: 'image/tiff'
ext: "tif",
mime: "image/tiff"
};
}
if (buf[0] === 0x42 && buf[1] === 0x4D) {
return {
ext: 'bmp',
mime: 'image/bmp'
ext: "bmp",
mime: "image/bmp"
};
}
if (buf[0] === 0x49 && buf[1] === 0x49 && buf[2] === 0xBC) {
return {
ext: 'jxr',
mime: 'image/vnd.ms-photo'
ext: "jxr",
mime: "image/vnd.ms-photo"
};
}
if (buf[0] === 0x38 && buf[1] === 0x42 && buf[2] === 0x50 && buf[3] === 0x53) {
return {
ext: 'psd',
mime: 'image/vnd.adobe.photoshop'
ext: "psd",
mime: "image/vnd.adobe.photoshop"
};
}
// needs to be before `zip` check
if (buf[0] === 0x50 && buf[1] === 0x4B && buf[2] === 0x3 && buf[3] === 0x4 && buf[30] === 0x6D && buf[31] === 0x69 && buf[32] === 0x6D && buf[33] === 0x65 && buf[34] === 0x74 && buf[35] === 0x79 && buf[36] === 0x70 && buf[37] === 0x65 && buf[38] === 0x61 && buf[39] === 0x70 && buf[40] === 0x70 && buf[41] === 0x6C && buf[42] === 0x69 && buf[43] === 0x63 && buf[44] === 0x61 && buf[45] === 0x74 && buf[46] === 0x69 && buf[47] === 0x6F && buf[48] === 0x6E && buf[49] === 0x2F && buf[50] === 0x65 && buf[51] === 0x70 && buf[52] === 0x75 && buf[53] === 0x62 && buf[54] === 0x2B && buf[55] === 0x7A && buf[56] === 0x69 && buf[57] === 0x70) {
return {
ext: 'epub',
mime: 'application/epub+zip'
ext: "epub",
mime: "application/epub+zip"
};
}
if (buf[0] === 0x50 && buf[1] === 0x4B && (buf[2] === 0x3 || buf[2] === 0x5 || buf[2] === 0x7) && (buf[3] === 0x4 || buf[3] === 0x6 || buf[3] === 0x8)) {
return {
ext: 'zip',
mime: 'application/zip'
ext: "zip",
mime: "application/zip"
};
}
if (buf[257] === 0x75 && buf[258] === 0x73 && buf[259] === 0x74 && buf[260] === 0x61 && buf[261] === 0x72) {
return {
ext: 'tar',
mime: 'application/x-tar'
ext: "tar",
mime: "application/x-tar"
};
}
if (buf[0] === 0x52 && buf[1] === 0x61 && buf[2] === 0x72 && buf[3] === 0x21 && buf[4] === 0x1A && buf[5] === 0x7 && (buf[6] === 0x0 || buf[6] === 0x1)) {
return {
ext: 'rar',
mime: 'application/x-rar-compressed'
ext: "rar",
mime: "application/x-rar-compressed"
};
}
if (buf[0] === 0x1F && buf[1] === 0x8B && buf[2] === 0x8) {
return {
ext: 'gz',
mime: 'application/gzip'
ext: "gz",
mime: "application/gzip"
};
}
if (buf[0] === 0x42 && buf[1] === 0x5A && buf[2] === 0x68) {
return {
ext: 'bz2',
mime: 'application/x-bzip2'
ext: "bz2",
mime: "application/x-bzip2"
};
}
if (buf[0] === 0x37 && buf[1] === 0x7A && buf[2] === 0xBC && buf[3] === 0xAF && buf[4] === 0x27 && buf[5] === 0x1C) {
return {
ext: '7z',
mime: 'application/x-7z-compressed'
ext: "7z",
mime: "application/x-7z-compressed"
};
}
if (buf[0] === 0x78 && buf[1] === 0x01) {
return {
ext: 'dmg',
mime: 'application/x-apple-diskimage'
ext: "dmg",
mime: "application/x-apple-diskimage"
};
}
if ((buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && (buf[3] === 0x18 || buf[3] === 0x20) && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70) || (buf[0] === 0x33 && buf[1] === 0x67 && buf[2] === 0x70 && buf[3] === 0x35) || (buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x1C && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x6D && buf[9] === 0x70 && buf[10] === 0x34 && buf[11] === 0x32 && buf[16] === 0x6D && buf[17] === 0x70 && buf[18] === 0x34 && buf[19] === 0x31 && buf[20] === 0x6D && buf[21] === 0x70 && buf[22] === 0x34 && buf[23] === 0x32 && buf[24] === 0x69 && buf[25] === 0x73 && buf[26] === 0x6F && buf[27] === 0x6D)) {
return {
ext: 'mp4',
mime: 'video/mp4'
ext: "mp4",
mime: "video/mp4"
};
}
if ((buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x1C && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x4D && buf[9] === 0x34 && buf[10] === 0x56)) {
return {
ext: 'm4v',
mime: 'video/x-m4v'
ext: "m4v",
mime: "video/x-m4v"
};
}
if (buf[0] === 0x4D && buf[1] === 0x54 && buf[2] === 0x68 && buf[3] === 0x64) {
return {
ext: 'mid',
mime: 'audio/midi'
ext: "mid",
mime: "audio/midi"
};
}
// needs to be before the `webm` check
if (buf[31] === 0x6D && buf[32] === 0x61 && buf[33] === 0x74 && buf[34] === 0x72 && buf[35] === 0x6f && buf[36] === 0x73 && buf[37] === 0x6B && buf[38] === 0x61) {
return {
ext: 'mkv',
mime: 'video/x-matroska'
ext: "mkv",
mime: "video/x-matroska"
};
}
if (buf[0] === 0x1A && buf[1] === 0x45 && buf[2] === 0xDF && buf[3] === 0xA3) {
return {
ext: 'webm',
mime: 'video/webm'
ext: "webm",
mime: "video/webm"
};
}
if (buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x14 && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70) {
return {
ext: 'mov',
mime: 'video/quicktime'
ext: "mov",
mime: "video/quicktime"
};
}
if (buf[0] === 0x52 && buf[1] === 0x49 && buf[2] === 0x46 && buf[3] === 0x46 && buf[8] === 0x41 && buf[9] === 0x56 && buf[10] === 0x49) {
return {
ext: 'avi',
mime: 'video/x-msvideo'
ext: "avi",
mime: "video/x-msvideo"
};
}
if (buf[0] === 0x30 && buf[1] === 0x26 && buf[2] === 0xB2 && buf[3] === 0x75 && buf[4] === 0x8E && buf[5] === 0x66 && buf[6] === 0xCF && buf[7] === 0x11 && buf[8] === 0xA6 && buf[9] === 0xD9) {
return {
ext: 'wmv',
mime: 'video/x-ms-wmv'
ext: "wmv",
mime: "video/x-ms-wmv"
};
}
if (buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x1 && buf[3].toString(16)[0] === 'b') {
if (buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x1 && buf[3].toString(16)[0] === "b") {
return {
ext: 'mpg',
mime: 'video/mpeg'
ext: "mpg",
mime: "video/mpeg"
};
}
if ((buf[0] === 0x49 && buf[1] === 0x44 && buf[2] === 0x33) || (buf[0] === 0xFF && buf[1] === 0xfb)) {
return {
ext: 'mp3',
mime: 'audio/mpeg'
ext: "mp3",
mime: "audio/mpeg"
};
}
if ((buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x4D && buf[9] === 0x34 && buf[10] === 0x41) || (buf[0] === 0x4D && buf[1] === 0x34 && buf[2] === 0x41 && buf[3] === 0x20)) {
return {
ext: 'm4a',
mime: 'audio/m4a'
ext: "m4a",
mime: "audio/m4a"
};
}
if (buf[0] === 0x4F && buf[1] === 0x67 && buf[2] === 0x67 && buf[3] === 0x53) {
return {
ext: 'ogg',
mime: 'audio/ogg'
ext: "ogg",
mime: "audio/ogg"
};
}
if (buf[0] === 0x66 && buf[1] === 0x4C && buf[2] === 0x61 && buf[3] === 0x43) {
return {
ext: 'flac',
mime: 'audio/x-flac'
ext: "flac",
mime: "audio/x-flac"
};
}
if (buf[0] === 0x52 && buf[1] === 0x49 && buf[2] === 0x46 && buf[3] === 0x46 && buf[8] === 0x57 && buf[9] === 0x41 && buf[10] === 0x56 && buf[11] === 0x45) {
return {
ext: 'wav',
mime: 'audio/x-wav'
ext: "wav",
mime: "audio/x-wav"
};
}
if (buf[0] === 0x23 && buf[1] === 0x21 && buf[2] === 0x41 && buf[3] === 0x4D && buf[4] === 0x52 && buf[5] === 0x0A) {
return {
ext: 'amr',
mime: 'audio/amr'
ext: "amr",
mime: "audio/amr"
};
}
if (buf[0] === 0x25 && buf[1] === 0x50 && buf[2] === 0x44 && buf[3] === 0x46) {
return {
ext: 'pdf',
mime: 'application/pdf'
ext: "pdf",
mime: "application/pdf"
};
}
if (buf[0] === 0x4D && buf[1] === 0x5A) {
return {
ext: 'exe',
mime: 'application/x-msdownload'
ext: "exe",
mime: "application/x-msdownload"
};
}
if ((buf[0] === 0x43 || buf[0] === 0x46) && buf[1] === 0x57 && buf[2] === 0x53) {
return {
ext: 'swf',
mime: 'application/x-shockwave-flash'
ext: "swf",
mime: "application/x-shockwave-flash"
};
}
if (buf[0] === 0x7B && buf[1] === 0x5C && buf[2] === 0x72 && buf[3] === 0x74 && buf[4] === 0x66) {
return {
ext: 'rtf',
mime: 'application/rtf'
ext: "rtf",
mime: "application/rtf"
};
}
if (buf[0] === 0x77 && buf[1] === 0x4F && buf[2] === 0x46 && buf[3] === 0x46 && buf[4] === 0x00 && buf[5] === 0x01 && buf[6] === 0x00 && buf[7] === 0x00) {
return {
ext: 'woff',
mime: 'application/font-woff'
ext: "woff",
mime: "application/font-woff"
};
}
if (buf[0] === 0x77 && buf[1] === 0x4F && buf[2] === 0x46 && buf[3] === 0x32 && buf[4] === 0x00 && buf[5] === 0x01 && buf[6] === 0x00 && buf[7] === 0x00) {
return {
ext: 'woff2',
mime: 'application/font-woff'
ext: "woff2",
mime: "application/font-woff"
};
}
if (buf[34] === 0x4C && buf[35] === 0x50 && ((buf[8] === 0x02 && buf[9] === 0x00 && buf[10] === 0x01) || (buf[8] === 0x01 && buf[9] === 0x00 && buf[10] === 0x00) || (buf[8] === 0x02 && buf[9] === 0x00 && buf[10] === 0x02))) {
return {
ext: 'eot',
mime: 'application/octet-stream'
ext: "eot",
mime: "application/octet-stream"
};
}
if (buf[0] === 0x00 && buf[1] === 0x01 && buf[2] === 0x00 && buf[3] === 0x00 && buf[4] === 0x00) {
return {
ext: 'ttf',
mime: 'application/font-sfnt'
ext: "ttf",
mime: "application/font-sfnt"
};
}
if (buf[0] === 0x4F && buf[1] === 0x54 && buf[2] === 0x54 && buf[3] === 0x4F && buf[4] === 0x00) {
return {
ext: 'otf',
mime: 'application/font-sfnt'
ext: "otf",
mime: "application/font-sfnt"
};
}
if (buf[0] === 0x00 && buf[1] === 0x00 && buf[2] === 0x01 && buf[3] === 0x00) {
return {
ext: 'ico',
mime: 'image/x-icon'
ext: "ico",
mime: "image/x-icon"
};
}
if (buf[0] === 0x46 && buf[1] === 0x4C && buf[2] === 0x56 && buf[3] === 0x01) {
return {
ext: 'flv',
mime: 'video/x-flv'
ext: "flv",
mime: "video/x-flv"
};
}
if (buf[0] === 0x25 && buf[1] === 0x21) {
return {
ext: 'ps',
mime: 'application/postscript'
ext: "ps",
mime: "application/postscript"
};
}
if (buf[0] === 0xFD && buf[1] === 0x37 && buf[2] === 0x7A && buf[3] === 0x58 && buf[4] === 0x5A && buf[5] === 0x00) {
return {
ext: 'xz',
mime: 'application/x-xz'
ext: "xz",
mime: "application/x-xz"
};
}
if (buf[0] === 0x53 && buf[1] === 0x51 && buf[2] === 0x4C && buf[3] === 0x69) {
return {
ext: 'sqlite',
mime: 'application/x-sqlite3'
ext: "sqlite",
mime: "application/x-sqlite3"
};
}
// Added by n1474335 [n1474335@gmail.com] from here on
// ################################################################## //
if ((buf[0] === 0x1F && buf[1] === 0x9D) || (buf[0] === 0x1F && buf[1] === 0xA0)) {
return {
ext: 'z, tar.z',
mime: 'application/x-gtar'
ext: "z, tar.z",
mime: "application/x-gtar"
};
}
if (buf[0] === 0x7F && buf[1] === 0x45 && buf[2] === 0x4C && buf[3] === 0x46) {
return {
ext: 'none, axf, bin, elf, o, prx, puff, so',
mime: 'application/x-executable',
desc: 'Executable and Linkable Format file. No standard file extension.'
ext: "none, axf, bin, elf, o, prx, puff, so",
mime: "application/x-executable",
desc: "Executable and Linkable Format file. No standard file extension."
};
}
if (buf[0] === 0xCA && buf[1] === 0xFE && buf[2] === 0xBA && buf[3] === 0xBE) {
return {
ext: 'class',
mime: 'application/java-vm'
ext: "class",
mime: "application/java-vm"
};
}
if (buf[0] === 0xEF && buf[1] === 0xBB && buf[2] === 0xBF) {
return {
ext: 'txt',
mime: 'text/plain',
desc: 'UTF-8 encoded Unicode byte order mark detected, commonly but not exclusively seen in text files.'
ext: "txt",
mime: "text/plain",
desc: "UTF-8 encoded Unicode byte order mark detected, commonly but not exclusively seen in text files."
};
}
// Must be before Little-endian UTF-16 BOM
if (buf[0] === 0xFF && buf[1] === 0xFE && buf[2] === 0x00 && buf[3] === 0x00) {
return {
ext: '',
mime: '',
desc: 'Little-endian UTF-32 encoded Unicode byte order mark detected.'
ext: "",
mime: "",
desc: "Little-endian UTF-32 encoded Unicode byte order mark detected."
};
}
if (buf[0] === 0xFF && buf[1] === 0xFE) {
return {
ext: '',
mime: '',
desc: 'Little-endian UTF-16 encoded Unicode byte order mark detected.'
ext: "",
mime: "",
desc: "Little-endian UTF-16 encoded Unicode byte order mark detected."
};
}
if ((buf[0x8001] === 0x43 && buf[0x8002] === 0x44 && buf[0x8003] === 0x30 && buf[0x8004] === 0x30 && buf[0x8005] === 0x31) ||
(buf[0x8801] === 0x43 && buf[0x8802] === 0x44 && buf[0x8803] === 0x30 && buf[0x8804] === 0x30 && buf[0x8805] === 0x31) ||
(buf[0x9001] === 0x43 && buf[0x9002] === 0x44 && buf[0x9003] === 0x30 && buf[0x9004] === 0x30 && buf[0x9005] === 0x31)) {
return {
ext: 'iso',
mime: 'application/octet-stream',
desc: 'ISO 9660 CD/DVD image file'
ext: "iso",
mime: "application/octet-stream",
desc: "ISO 9660 CD/DVD image file"
};
}
if (buf[0] === 0xD0 && buf[1] === 0xCF && buf[2] === 0x11 && buf[3] === 0xE0 && buf[4] === 0xA1 && buf[5] === 0xB1 && buf[6] === 0x1A && buf[7] === 0xE1) {
return {
ext: 'doc, xls, ppt',
mime: 'application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint',
desc: 'Microsoft Office documents'
ext: "doc, xls, ppt",
mime: "application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint",
desc: "Microsoft Office documents"
};
}
if (buf[0] === 0x64 && buf[1] === 0x65 && buf[2] === 0x78 && buf[3] === 0x0A && buf[4] === 0x30 && buf[5] === 0x33 && buf[6] === 0x35 && buf[7] === 0x00) {
return {
ext: 'dex',
mime: 'application/octet-stream',
desc: 'Dalvik Executable (Android)'
ext: "dex",
mime: "application/octet-stream",
desc: "Dalvik Executable (Android)"
};
}
if (buf[0] === 0x4B && buf[1] === 0x44 && buf[2] === 0x4D) {
return {
ext: 'vmdk',
mime: 'application/vmdk, application/x-virtualbox-vmdk'
ext: "vmdk",
mime: "application/vmdk, application/x-virtualbox-vmdk"
};
}
if (buf[0] === 0x43 && buf[1] === 0x72 && buf[2] === 0x32 && buf[3] == 0x34) {
if (buf[0] === 0x43 && buf[1] === 0x72 && buf[2] === 0x32 && buf[3] === 0x34) {
return {
ext: 'crx',
mime: 'application/crx',
desc: 'Google Chrome extension or packaged app'
ext: "crx",
mime: "application/crx",
desc: "Google Chrome extension or packaged app"
};
}

View file

@ -19,7 +19,7 @@ var HTML = {
* @default
*/
CONVERT_OPTIONS: ["Named entities where possible", "Numeric entities", "Hex entities"],
/**
* To HTML Entity operation.
*
@ -29,12 +29,12 @@ var HTML = {
*/
run_to_entity: function(input, args) {
var convert_all = args[0],
numeric = args[1] == "Numeric entities",
hexa = args[1] == "Hex entities";
numeric = args[1] === "Numeric entities",
hexa = args[1] === "Hex entities";
var charcodes = Utils.str_to_charcode(input);
var output = "";
for (var i = 0; i < charcodes.length; i++) {
if (convert_all && numeric) {
output += "&#" + charcodes[i] + ";";
@ -64,8 +64,8 @@ var HTML = {
}
return output;
},
/**
* From HTML Entity operation.
*
@ -78,40 +78,40 @@ var HTML = {
output = "",
m,
i = 0;
while (!!(m = regex.exec(input))) {
while ((m = regex.exec(input))) {
// Add up to match
for (; i < m.index;)
output += input[i++];
// Add match
var bite = HTML._entity_to_byte[m[1]];
if (bite) {
output += Utils.chr(bite);
} else if (!bite && m[1][0] == "#" && m[1].length > 1 && /^#\d{1,5}$/.test(m[1])) {
} else if (!bite && m[1][0] === "#" && m[1].length > 1 && /^#\d{1,5}$/.test(m[1])) {
// Numeric entity (e.g. &#10;)
var num = m[1].slice(1,m[1].length);
var num = m[1].slice(1, m[1].length);
output += Utils.chr(parseInt(num, 10));
} else if (!bite && m[1][0] == "#" && m[1].length > 3 && /^#x[\dA-F]{2,8}$/i.test(m[1])) {
} else if (!bite && m[1][0] === "#" && m[1].length > 3 && /^#x[\dA-F]{2,8}$/i.test(m[1])) {
// Hex entity (e.g. &#x3A;)
var hex = m[1].slice(2,m[1].length);
var hex = m[1].slice(2, m[1].length);
output += Utils.chr(parseInt(hex, 16));
} else {
// Not a valid entity, print as normal
for (; i < regex.lastIndex;)
output += input[i++];
}
i = regex.lastIndex;
}
// Add all after final match
for (; i < input.length;)
output += input[i++];
return output;
},
/**
* @constant
* @default
@ -122,7 +122,7 @@ var HTML = {
* @default
*/
REMOVE_LINE_BREAKS: true,
/**
* Strip HTML tags operation.
*
@ -133,22 +133,22 @@ var HTML = {
run_strip_tags: function(input, args) {
var remove_indentation = args[0],
remove_line_breaks = args[1];
input = Utils.strip_html_tags(input);
if (remove_indentation) {
input = input.replace(/\n[ \f\t]+/g, "\n");
}
if (remove_line_breaks) {
input = input.replace(/^\s*\n/, "") // first line
.replace(/(\n\s*){2,}/g, "\n"); // all others
}
return input;
},
/**
* Parse colour code operation.
*
@ -159,31 +159,31 @@ var HTML = {
run_parse_colour_code: function(input, args) {
var m = null,
r = 0, g = 0, b = 0, a = 1;
// Read in the input
if (!!(m = input.match(/#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/i))) {
if ((m = input.match(/#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/i))) {
// Hex - #d9edf7
r = parseInt(m[1], 16);
g = parseInt(m[2], 16);
b = parseInt(m[3], 16);
} else if (!!(m = input.match(/rgba?\((\d{1,3}(?:\.\d+)?),\s?(\d{1,3}(?:\.\d+)?),\s?(\d{1,3}(?:\.\d+)?)(?:,\s?(\d(?:\.\d+)?))?\)/i))) {
} else if ((m = input.match(/rgba?\((\d{1,3}(?:\.\d+)?),\s?(\d{1,3}(?:\.\d+)?),\s?(\d{1,3}(?:\.\d+)?)(?:,\s?(\d(?:\.\d+)?))?\)/i))) {
// RGB or RGBA - rgb(217,237,247) or rgba(217,237,247,1)
r = parseFloat(m[1]);
g = parseFloat(m[2]);
b = parseFloat(m[3]);
a = m[4] ? parseFloat(m[4]) : 1;
} else if (!!(m = input.match(/hsla?\((\d{1,3}(?:\.\d+)?),\s?(\d{1,3}(?:\.\d+)?)%,\s?(\d{1,3}(?:\.\d+)?)%(?:,\s?(\d(?:\.\d+)?))?\)/i))) {
} else if ((m = input.match(/hsla?\((\d{1,3}(?:\.\d+)?),\s?(\d{1,3}(?:\.\d+)?)%,\s?(\d{1,3}(?:\.\d+)?)%(?:,\s?(\d(?:\.\d+)?))?\)/i))) {
// HSL or HSLA - hsl(200, 65%, 91%) or hsla(200, 65%, 91%, 1)
var h_ = parseFloat(m[1]) / 360,
s_ = parseFloat(m[2]) / 100,
l_ = parseFloat(m[3]) / 100,
rgb_ = HTML._hsl_to_rgb(h_, s_, l_);
r = rgb_[0];
g = rgb_[1];
b = rgb_[2];
a = m[4] ? parseFloat(m[4]) : 1;
} else if (!!(m = input.match(/cmyk\((\d(?:\.\d+)?),\s?(\d(?:\.\d+)?),\s?(\d(?:\.\d+)?),\s?(\d(?:\.\d+)?)\)/i))) {
} else if ((m = input.match(/cmyk\((\d(?:\.\d+)?),\s?(\d(?:\.\d+)?),\s?(\d(?:\.\d+)?),\s?(\d(?:\.\d+)?)\)/i))) {
// CMYK - cmyk(0.12, 0.04, 0.00, 0.03)
var c_ = parseFloat(m[1]),
m_ = parseFloat(m[2]),
@ -194,21 +194,21 @@ var HTML = {
g = Math.round(255 * (1 - m_) * (1 - k_));
b = Math.round(255 * (1 - y_) * (1 - k_));
}
var hsl_ = HTML._rgb_to_hsl(r, g, b),
h = Math.round(hsl_[0] * 360),
s = Math.round(hsl_[1] * 100),
l = Math.round(hsl_[2] * 100),
k = 1 - Math.max(r/255, g/255, b/255),
c = (1 - r/255 - k) / (1 - k),
m = (1 - g/255 - k) / (1 - k), // jshint ignore:line
m = (1 - g/255 - k) / (1 - k), // eslint-disable-line no-redeclare
y = (1 - b/255 - k) / (1 - k);
c = isNaN(c) ? "0" : c.toFixed(2);
m = isNaN(m) ? "0" : m.toFixed(2);
y = isNaN(y) ? "0" : y.toFixed(2);
k = k.toFixed(2);
var hex = "#" +
Utils.pad_left(Math.round(r).toString(16), 2) +
Utils.pad_left(Math.round(g).toString(16), 2) +
@ -218,9 +218,9 @@ var HTML = {
hsl = "hsl(" + h + ", " + s + "%, " + l + "%)",
hsla = "hsla(" + h + ", " + s + "%, " + l + "%, " + a + ")",
cmyk = "cmyk(" + c + ", " + m + ", " + y + ", " + k + ")";
// Generate output
return "<div id='colorpicker' style='display: inline-block'></div>" +
return "<div id='colorpicker' style='display: inline-block'></div>" +
"Hex: " + hex + "\n" +
"RGB: " + rgb + "\n" +
"RGBA: " + rgba + "\n" +
@ -241,9 +241,9 @@ var HTML = {
});\
</script>";
},
/**
* Converts an HSL color value to RGB. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
@ -282,8 +282,8 @@ var HTML = {
return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
},
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
@ -319,8 +319,8 @@ var HTML = {
return [h, s, l];
},
/**
* Lookup table to translate byte values to their HTML entity codes.
*
@ -583,8 +583,8 @@ var HTML = {
9829 : "&hearts;",
9830 : "&diams;",
},
/**
* Lookup table to translate HTML entity codes to their byte values.
*

View file

@ -58,7 +58,7 @@ var Hexdump = {
Utils.pad_right(hexa, (length*(padding+1))) +
" |" + Utils.pad_right(Utils.printable(Utils.byte_array_to_chars(buff)), buff.length) + "|\n";
if (include_final_length && i+buff.length == input.length) {
if (include_final_length && i+buff.length === input.length) {
output += Utils.hex(i+buff.length, 8) + "\n";
}
}
@ -79,7 +79,7 @@ var Hexdump = {
regex = /^\s*(?:[\dA-F]{4,16}:?)?\s*((?:[\dA-F]{2}\s){1,8}(?:\s|[\dA-F]{2}-)(?:[\dA-F]{2}\s){1,8}|(?:[\dA-F]{2}\s|[\dA-F]{4}\s)+)/igm,
block, line;
while (!!(block = regex.exec(input))) {
while ((block = regex.exec(input))) {
line = Utils.from_hex(block[1].replace(/-/g, " "));
for (var i = 0; i < line.length; i++) {
output.push(line[i]);
@ -89,7 +89,7 @@ var Hexdump = {
var width = input.indexOf("\n");
var w = (width - 13) / 4;
// w should be the specified width of the hexdump and therefore a round number
if (Math.floor(w) != w || input.indexOf("\r") != -1 || output.indexOf(13) != -1) {
if (Math.floor(w) !== w || input.indexOf("\r") !== -1 || output.indexOf(13) !== -1) {
app.options.attempt_highlight = false;
}
return output;
@ -118,14 +118,17 @@ var Hexdump = {
line = Math.floor(pos[0].end / w);
offset = pos[0].end % w;
if (offset === 0) { line--; offset = w; }
if (offset === 0) {
line--;
offset = w;
}
pos[0].end = line*width + 10 + offset*3 - 1;
// Set up multiple selections for bytes
var start_line_num = Math.floor(pos[0].start / width);
var end_line_num = Math.floor(pos[0].end / width);
if (start_line_num == end_line_num) {
if (start_line_num === end_line_num) {
pos.push(pos[0]);
} else {
start = pos[0].start;

View file

@ -46,13 +46,13 @@ var IP = {
ipv6_range_regex = /^\s*(((?=.*::)(?!.*::[^-]+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\4)::|:\b|(?![\dA-F])))|(?!\3\4)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4}))\s*-\s*(((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\17)::|:\b|(?![\dA-F])))|(?!\16\17)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4}))\s*$/i,
match;
if (!!(match = ipv4_cidr_regex.exec(input))) {
if ((match = ipv4_cidr_regex.exec(input))) {
return IP._ipv4_cidr_range(match, include_network_info, enumerate_addresses, allow_large_list);
} else if (!!(match = ipv4_range_regex.exec(input))) {
} else if ((match = ipv4_range_regex.exec(input))) {
return IP._ipv4_hyphenated_range(match, include_network_info, enumerate_addresses, allow_large_list);
} else if (!!(match = ipv6_cidr_regex.exec(input))) {
} else if ((match = ipv6_cidr_regex.exec(input))) {
return IP._ipv6_cidr_range(match, include_network_info);
} else if (!!(match = ipv6_range_regex.exec(input))) {
} else if ((match = ipv6_range_regex.exec(input))) {
return IP._ipv6_hyphenated_range(match, include_network_info);
} else {
return "Invalid input.\n\nEnter either a CIDR range (e.g. 10.0.0.0/24) or a hyphenated range (e.g. 10.0.0.0 - 10.0.1.0). IPv6 also supported.";
@ -82,7 +82,7 @@ var IP = {
var match,
output = "";
if (!!(match = IP.IPv6_REGEX.exec(input))) {
if ((match = IP.IPv6_REGEX.exec(input))) {
var ipv6 = IP._str_to_ipv6(match[1]),
longhand = IP._ipv6_to_str(ipv6),
shorthand = IP._ipv6_to_str(ipv6, true);
@ -90,11 +90,11 @@ var IP = {
output += "Longhand: " + longhand + "\nShorthand: " + shorthand + "\n";
// Detect reserved addresses
if (shorthand == "::") {
if (shorthand === "::") {
// Unspecified address
output += "\nUnspecified address corresponding to 0.0.0.0/32 in IPv4.";
output += "\nUnspecified address range: ::/128";
} else if (shorthand == "::1") {
} else if (shorthand === "::1") {
// Loopback address
output += "\nLoopback address to the local host corresponding to 127.0.0.1/8 in IPv4.";
output += "\nLoopback addresses range: ::1/128";
@ -171,18 +171,18 @@ var IP = {
// Benchmarking
output += "\nAssigned to the Benchmarking Methodology Working Group (BMWG) for benchmarking IPv6. Corresponds to 198.18.0.0/15 for benchmarking IPv4. See RFC 5180 for more details.";
output += "\nBMWG range: 2001:2::/48";
} else if (ipv6[0] == 0x2001 && ipv6[1] >= 0x10 && ipv6[1] <= 0x1f) {
} else if (ipv6[0] === 0x2001 && ipv6[1] >= 0x10 && ipv6[1] <= 0x1f) {
// ORCHIDv1
output += "\nDeprecated, previously ORCHIDv1 (Overlay Routable Cryptographic Hash Identifiers).\nORCHIDv1 range: 2001:10::/28\nORCHIDv2 now uses 2001:20::/28.";
} else if (ipv6[0] == 0x2001 && ipv6[1] >= 0x20 && ipv6[1] <= 0x2f) {
} else if (ipv6[0] === 0x2001 && ipv6[1] >= 0x20 && ipv6[1] <= 0x2f) {
// ORCHIDv2
output += "\nORCHIDv2 (Overlay Routable Cryptographic Hash Identifiers).\nThese are non-routed IPv6 addresses used for Cryptographic Hash Identifiers.";
output += "\nORCHIDv2 range: 2001:20::/28";
} else if (ipv6[0] == 0x2001 && ipv6[1] == 0xdb8) {
} else if (ipv6[0] === 0x2001 && ipv6[1] === 0xdb8) {
// Documentation
output += "\nThis is a documentation IPv6 address. This range should be used whenever an example IPv6 address is given or to model networking scenarios. Corresponds to 192.0.2.0/24, 198.51.100.0/24, and 203.0.113.0/24 in IPv4.";
output += "\nDocumentation range: 2001:db8::/32";
} else if (ipv6[0] == 0x2002) {
} else if (ipv6[0] === 0x2002) {
// 6to4
output += "\n6to4 transition IPv6 address detected. See RFC 3056 for more details." +
"\n6to4 prefix range: 2002::/16";
@ -241,7 +241,7 @@ var IP = {
if (lines[i] === "") continue;
var ba_ip = [];
if (in_format == out_format) {
if (in_format === out_format) {
output += lines[i] + "\n";
continue;
}
@ -341,7 +341,7 @@ var IP = {
// Parse all IPs and add to network dictionary
for (var i = 0; i < ips.length; i++) {
if (!!(match = IP.IPv4_REGEX.exec(ips[i]))) {
if ((match = IP.IPv4_REGEX.exec(ips[i]))) {
ip = IP._str_to_ipv4(match[1]) >>> 0;
network = ip & ipv4_mask;
@ -350,7 +350,7 @@ var IP = {
} else {
ipv4_networks[network] = [ip];
}
} else if (!!(match = IP.IPv6_REGEX.exec(ips[i]))) {
} else if ((match = IP.IPv6_REGEX.exec(ips[i]))) {
ip = IP._str_to_ipv6(match[1]);
network = [];
network_str = "";
@ -478,7 +478,7 @@ var IP = {
ip2[i] = ip1[i] | (~mask[i] & 0x0000FFFF);
total_diff = (ip2[i] - ip1[i]).toString(2);
if (total_diff != "0") {
if (total_diff !== "0") {
for (var n = 0; n < total_diff.length; n++) {
total[i*16 + 16-(total_diff.length-n)] = total_diff[n];
}
@ -599,7 +599,7 @@ var IP = {
for (i = 0; i < 8; i++) {
t = (ip2[i] - ip1[i]).toString(2);
if (t != "0") {
if (t !== "0") {
for (var n = 0; n < t.length; n++) {
total[i*16 + 16-(t.length-n)] = t[n];
}
@ -640,7 +640,7 @@ var IP = {
return result;
function parse_blocks(blocks) {
if (blocks.length != 4)
if (blocks.length !== 4)
throw "More than 4 blocks.";
var num_blocks = [];
@ -695,7 +695,7 @@ var IP = {
for (var i = 0; i < 8; i++) {
if (isNaN(num_blocks[j])) {
ipv6[i] = 0;
if (i == (8-num_blocks.slice(j).length)) j++;
if (i === (8-num_blocks.slice(j).length)) j++;
} else {
ipv6[i] = num_blocks[j];
j++;
@ -734,7 +734,6 @@ var IP = {
*/
_ipv6_to_str: function(ipv6, compact) {
var output = "",
skips = 0,
i = 0;
if (compact) {
@ -756,8 +755,8 @@ var IP = {
}
for (i = 0; i < 8; i++) {
if (i != start) {
output += Utils.hex(ipv6[i],1) + ":";
if (i !== start) {
output += Utils.hex(ipv6[i], 1) + ":";
} else {
output += ":";
i = end;
@ -768,10 +767,10 @@ var IP = {
output = ":" + output;
} else {
for (i = 0; i < 8; i++) {
output += Utils.hex(ipv6[i],4) + ":";
output += Utils.hex(ipv6[i], 4) + ":";
}
}
return output.slice(0,output.length-1);
return output.slice(0, output.length-1);
},

View file

@ -54,17 +54,17 @@ var MAC = {
macs = input.toLowerCase().split(/[,\s\r\n]+/);
macs.forEach(function(mac) {
var cleanMac = mac.replace(/[:.-]+/g, ''),
macHyphen = cleanMac.replace(/(.{2}(?=.))/g, '$1-'),
macColon = cleanMac.replace(/(.{2}(?=.))/g, '$1:'),
macCisco = cleanMac.replace(/(.{4}(?=.))/g, '$1.');
var cleanMac = mac.replace(/[:.-]+/g, ""),
macHyphen = cleanMac.replace(/(.{2}(?=.))/g, "$1-"),
macColon = cleanMac.replace(/(.{2}(?=.))/g, "$1:"),
macCisco = cleanMac.replace(/(.{4}(?=.))/g, "$1.");
if (output_case == "Lower only") {
if (output_case === "Lower only") {
if (no_delim) output_list.push(cleanMac);
if (dash_delim) output_list.push(macHyphen);
if (colon_delim) output_list.push(macColon);
if (cisco_style) output_list.push(macCisco);
} else if (output_case == "Upper only") {
} else if (output_case === "Upper only") {
if (no_delim) output_list.push(cleanMac.toUpperCase());
if (dash_delim) output_list.push(macHyphen.toUpperCase());
if (colon_delim) output_list.push(macColon.toUpperCase());
@ -82,7 +82,7 @@ var MAC = {
});
// Return the data as a string
return output_list.join('\n');
return output_list.join("\n");
},
};

View file

@ -45,12 +45,12 @@ var OS = {
output = "",
octal = null,
textual = null;
if (input.search(/\s*[0-7]{1,4}\s*/i) === 0) {
// Input is octal
octal = input.match(/\s*([0-7]{1,4})\s*/i)[1];
if (octal.length == 4) {
if (octal.length === 4) {
d = parseInt(octal[0], 8);
u = parseInt(octal[1], 8);
g = parseInt(octal[2], 8);
@ -60,26 +60,26 @@ var OS = {
if (octal.length > 1) g = parseInt(octal[1], 8);
if (octal.length > 2) o = parseInt(octal[2], 8);
}
perms.su = d >> 2 & 0x1;
perms.sg = d >> 1 & 0x1;
perms.sb = d & 0x1;
perms.ru = u >> 2 & 0x1;
perms.wu = u >> 1 & 0x1;
perms.eu = u & 0x1;
perms.rg = g >> 2 & 0x1;
perms.wg = g >> 1 & 0x1;
perms.eg = g & 0x1;
perms.ro = o >> 2 & 0x1;
perms.wo = o >> 1 & 0x1;
perms.eo = o & 0x1;
} else if (input.search(/\s*[dlpcbDrwxsStT-]{1,10}\s*/) === 0) {
// Input is textual
textual = input.match(/\s*([dlpcbDrwxsStT-]{1,10})\s*/)[1];
switch (textual[0]) {
case "d":
perms.d = true;
@ -103,9 +103,9 @@ var OS = {
perms.dr = true;
break;
}
if (textual.length > 1) perms.ru = textual[1] == "r";
if (textual.length > 2) perms.wu = textual[2] == "w";
if (textual.length > 1) perms.ru = textual[1] === "r";
if (textual.length > 2) perms.wu = textual[2] === "w";
if (textual.length > 3) {
switch (textual[3]) {
case "x":
@ -120,9 +120,9 @@ var OS = {
break;
}
}
if (textual.length > 4) perms.rg = textual[4] == "r";
if (textual.length > 5) perms.wg = textual[5] == "w";
if (textual.length > 4) perms.rg = textual[4] === "r";
if (textual.length > 5) perms.wg = textual[5] === "w";
if (textual.length > 6) {
switch (textual[6]) {
case "x":
@ -137,9 +137,9 @@ var OS = {
break;
}
}
if (textual.length > 7) perms.ro = textual[7] == "r";
if (textual.length > 8) perms.wo = textual[8] == "w";
if (textual.length > 7) perms.ro = textual[7] === "r";
if (textual.length > 8) perms.wo = textual[8] === "w";
if (textual.length > 9) {
switch (textual[9]) {
case "x":
@ -157,15 +157,15 @@ var OS = {
} else {
return "Invalid input format.\nPlease enter the permissions in either octal (e.g. 755) or textual (e.g. drwxr-xr-x) format.";
}
output += "Textual representation: " + OS._perms_to_str(perms);
output += "\nOctal representation: " + OS._perms_to_octal(perms);
// File type
if (textual) {
output += "\nFile type: " + OS._ft_from_perms(perms);
}
// setuid, setgid
if (perms.su) {
output += "\nThe setuid flag is set";
@ -173,15 +173,15 @@ var OS = {
if (perms.sg) {
output += "\nThe setgid flag is set";
}
// sticky bit
if (perms.sb) {
output += "\nThe sticky bit is set";
}
// Permission matrix
output += "\n\n +---------+-------+-------+-------+\n" +
" | | User | Group | Other |\n" +
" | | User | Group | Other |\n" +
" +---------+-------+-------+-------+\n" +
" | Read | " + (perms.ru ? "X" : " ") + " | " + (perms.rg ? "X" : " ") + " | " + (perms.ro ? "X" : " ") + " |\n" +
" +---------+-------+-------+-------+\n" +
@ -189,11 +189,11 @@ var OS = {
" +---------+-------+-------+-------+\n" +
" | Execute | " + (perms.eu ? "X" : " ") + " | " + (perms.eg ? "X" : " ") + " | " + (perms.eo ? "X" : " ") + " |\n" +
" +---------+-------+-------+-------+\n";
return output;
},
/**
* Given a permissions object dictionary, generates a textual permissions string.
*
@ -204,7 +204,7 @@ var OS = {
_perms_to_str: function(perms) {
var str = "",
type = "-";
if (perms.d) type = "d";
if (perms.sl) type = "l";
if (perms.np) type = "p";
@ -212,9 +212,9 @@ var OS = {
if (perms.cd) type = "c";
if (perms.bd) type = "b";
if (perms.dr) type = "D";
str = type;
str += perms.ru ? "r" : "-";
str += perms.wu ? "w" : "-";
if (perms.eu && perms.su) {
@ -226,7 +226,7 @@ var OS = {
} else {
str += "-";
}
str += perms.rg ? "r" : "-";
str += perms.wg ? "w" : "-";
if (perms.eg && perms.sg) {
@ -238,7 +238,7 @@ var OS = {
} else {
str += "-";
}
str += perms.ro ? "r" : "-";
str += perms.wo ? "w" : "-";
if (perms.eo && perms.sb) {
@ -250,11 +250,11 @@ var OS = {
} else {
str += "-";
}
return str;
},
/**
* Given a permissions object dictionary, generates an octal permissions string.
*
@ -267,27 +267,27 @@ var OS = {
u = 0,
g = 0,
o = 0;
if (perms.su) d += 4;
if (perms.sg) d += 2;
if (perms.sb) d += 1;
if (perms.ru) u += 4;
if (perms.wu) u += 2;
if (perms.eu) u += 1;
if (perms.rg) g += 4;
if (perms.wg) g += 2;
if (perms.eg) g += 1;
if (perms.ro) o += 4;
if (perms.wo) o += 2;
if (perms.eo) o += 1;
return d.toString() + u.toString() + g.toString() + o.toString();
},
/**
* Given a permissions object dictionary, returns the file type.
*
@ -305,5 +305,5 @@ var OS = {
if (perms.dr) return "Door";
return "Regular file";
},
};

File diff suppressed because it is too large Load diff

View file

@ -81,7 +81,7 @@ var QuotedPrintable = {
for (var i = 0, len = str.length; i < len; i++) {
chr = str.charAt(i);
if (chr == "=" && (hex = str.substr(i + 1, 2)) && /[\da-fA-F]{2}/.test(hex)) {
if (chr === "=" && (hex = str.substr(i + 1, 2)) && /[\da-fA-F]{2}/.test(hex)) {
buffer[bufferPos++] = parseInt(hex, 16);
i += 2;
continue;
@ -137,9 +137,9 @@ var QuotedPrintable = {
for (var i = ranges.length - 1; i >= 0; i--) {
if (!ranges[i].length)
continue;
if (ranges[i].length == 1 && nr == ranges[i][0])
if (ranges[i].length === 1 && nr === ranges[i][0])
return true;
if (ranges[i].length == 2 && nr >= ranges[i][0] && nr <= ranges[i][1])
if (ranges[i].length === 2 && nr >= ranges[i][0] && nr <= ranges[i][1])
return true;
}
return false;
@ -161,7 +161,7 @@ var QuotedPrintable = {
encoding = (encoding || "base64").toString().toLowerCase().trim();
if (encoding == "qp") {
if (encoding === "qp") {
return this._addQPSoftLinebreaks(str, lineLengthMax);
} else {
return this._addBase64SoftLinebreaks(str, lineLengthMax);
@ -208,7 +208,7 @@ var QuotedPrintable = {
continue;
}
if (line.substr(-1) == "\n") {
if (line.substr(-1) === "\n") {
// nothing to change here
result += line;
pos += line.length;
@ -222,7 +222,7 @@ var QuotedPrintable = {
} else if (line.length > lineLengthMax - lineMargin && (match = line.substr(-lineMargin).match(/[ \t\.,!\?][^ \t\.,!\?]*$/))) {
// truncate to nearest space
line = line.substr(0, line.length - (match[0].length - 1));
} else if (line.substr(-1) == "\r") {
} else if (line.substr(-1) === "\r") {
line = line.substr(0, line.length - 1);
} else {
if (line.match(/\=[\da-f]{0,2}$/i)) {
@ -249,10 +249,10 @@ var QuotedPrintable = {
}
}
if (pos + line.length < len && line.substr(-1) != "\n") {
if (line.length == 76 && line.match(/\=[\da-f]{2}$/i)) {
if (pos + line.length < len && line.substr(-1) !== "\n") {
if (line.length === 76 && line.match(/\=[\da-f]{2}$/i)) {
line = line.substr(0, line.length - 3);
} else if (line.length == 76) {
} else if (line.length === 76) {
line = line.substr(0, line.length - 1);
}
pos += line.length;

View file

@ -38,11 +38,11 @@ var SeqUtils = {
order = args[2],
sorted = input.split(delim);
if (order == "Alphabetical (case sensitive)") {
if (order === "Alphabetical (case sensitive)") {
sorted = sorted.sort();
} else if (order == "Alphabetical (case insensitive)") {
} else if (order === "Alphabetical (case insensitive)") {
sorted = sorted.sort(SeqUtils._case_insensitive_sort);
} else if (order == "IP address") {
} else if (order === "IP address") {
sorted = sorted.sort(SeqUtils._ip_sort);
}
@ -81,7 +81,7 @@ var SeqUtils = {
var search = args[0].string,
type = args[0].option;
if (type == "Regex" && search) {
if (type === "Regex" && search) {
try {
var regex = new RegExp(search, "gi"),
matches = input.match(regex);
@ -114,12 +114,12 @@ var SeqUtils = {
* @returns {byte_array}
*/
run_reverse: function (input, args) {
if (args[0] == "Line") {
if (args[0] === "Line") {
var lines = [],
line = [],
result = [];
for (var i = 0; i < input.length; i++) {
if (input[i] == 0x0a) {
if (input[i] === 0x0a) {
lines.push(line);
line = [];
} else {

View file

@ -108,7 +108,7 @@ var StrUtils = {
if (i) modifiers += "i";
if (m) modifiers += "m";
if (user_regex && user_regex != "^" && user_regex != "$") {
if (user_regex && user_regex !== "^" && user_regex !== "$") {
try {
var regex = new RegExp(user_regex, modifiers);
@ -223,7 +223,7 @@ var StrUtils = {
if (i) modifiers += "i";
if (m) modifiers += "m";
if (type == "Regex") {
if (type === "Regex") {
find = new RegExp(find, modifiers);
} else if (type.indexOf("Extended") === 0) {
find = Utils.parse_escaped_chars(find);
@ -291,7 +291,7 @@ var StrUtils = {
output = "",
diff;
if (!samples || samples.length != 2) {
if (!samples || samples.length !== 2) {
return "Incorrect number of samples, perhaps you need to modify the sample delimiter or add more samples?";
}
@ -379,7 +379,7 @@ var StrUtils = {
// Loop through each sample to see if the chars are the same
for (s = 1; s < samples.length; s++) {
if (samples[s][i] != chr) {
if (samples[s][i] !== chr) {
match = false;
break;
}
@ -390,26 +390,26 @@ var StrUtils = {
for (s = 0; s < samples.length; s++) {
if (samples[s].length <= i) {
if (in_match) outputs[s] += "</span>";
if (s == samples.length - 1) in_match = false;
if (s === samples.length - 1) in_match = false;
continue;
}
if (match && !in_match) {
outputs[s] += "<span class='hlgreen'>" + Utils.escape_html(samples[s][i]);
if (samples[s].length == i + 1) outputs[s] += "</span>";
if (s == samples.length - 1) in_match = true;
if (samples[s].length === i + 1) outputs[s] += "</span>";
if (s === samples.length - 1) in_match = true;
} else if (!match && in_match) {
outputs[s] += "</span>" + Utils.escape_html(samples[s][i]);
if (s == samples.length - 1) in_match = false;
if (s === samples.length - 1) in_match = false;
} else {
outputs[s] += Utils.escape_html(samples[s][i]);
if (in_match && samples[s].length == i + 1) {
if (in_match && samples[s].length === i + 1) {
outputs[s] += "</span>";
if (samples[s].length - 1 != i) in_match = false;
if (samples[s].length - 1 !== i) in_match = false;
}
}
if (samples[0].length - 1 == i) {
if (samples[0].length - 1 === i) {
if (in_match) outputs[s] += "</span>";
outputs[s] += Utils.escape_html(samples[s].substring(i + 1));
}
@ -448,7 +448,7 @@ var StrUtils = {
i = 0,
total = 0;
while (!!(m = regex.exec(input))) {
while ((m = regex.exec(input))) {
// Add up to match
output += Utils.escape_html(input.slice(i, m.index));
@ -456,7 +456,7 @@ var StrUtils = {
output += "<span class='hl"+hl+"'>" + Utils.escape_html(m[0]) + "</span>";
// Switch highlight
hl = hl == 1 ? 2 : 1;
hl = hl === 1 ? 2 : 1;
i = regex.lastIndex;
total++;
@ -488,7 +488,7 @@ var StrUtils = {
total = 0,
match;
while (!!(match = regex.exec(input))) {
while ((match = regex.exec(input))) {
total++;
if (matches) {
output += match[0] + "\n";

View file

@ -121,7 +121,7 @@ var Tidy = {
line = [];
for (var i = 0; i < input.length; i++) {
if (input[i] == 0x0a) {
if (input[i] === 0x0a) {
lines.push(line);
line = [];
} else {
@ -173,7 +173,7 @@ var Tidy = {
line = [];
for (var i = 0; i < input.length; i++) {
if (input[i] == 0x0a) {
if (input[i] === 0x0a) {
lines.push(line);
line = [];
} else {
@ -222,11 +222,11 @@ var Tidy = {
output = "",
i = 0;
if (position == "Start") {
if (position === "Start") {
for (i = 0; i < lines.length; i++) {
output += Utils.pad_left(lines[i], lines[i].length+len, chr) + "\n";
}
} else if (position == "End") {
} else if (position === "End") {
for (i = 0; i < lines.length; i++) {
output += Utils.pad_right(lines[i], lines[i].length+len, chr) + "\n";
}

View file

@ -64,7 +64,7 @@ var URL_ = {
if (a.protocol) {
var output = "";
if (a.hostname != window.location.hostname) {
if (a.hostname !== window.location.hostname) {
output = "Protocol:\t" + a.protocol + "\n";
if (a.hostname) output += "Hostname:\t" + a.hostname + "\n";
if (a.port) output += "Port:\t\t" + a.port + "\n";

View file

@ -17,7 +17,7 @@ var UUID = {
* @returns {string}
*/
run_generate_v4: function(input, args) {
if (typeof(window.crypto) !== 'undefined' && typeof(window.crypto.getRandomValues) !== 'undefined') {
if (typeof(window.crypto) !== "undefined" && typeof(window.crypto.getRandomValues) !== "undefined") {
var buf = new Uint32Array(4),
i = 0;
window.crypto.getRandomValues(buf);

View file

@ -29,7 +29,7 @@ var Unicode = {
m,
i = 0;
while (!!(m = regex.exec(input))) {
while ((m = regex.exec(input))) {
// Add up to match
output += input.slice(i, m.index);
i = m.index;