mirror of
https://github.com/gchq/CyberChef
synced 2024-11-15 00:57:08 +00:00
Replaced jsHint with eslint. Fixes #4.
This commit is contained in:
parent
e2e68dd876
commit
af4644c9eb
48 changed files with 1741 additions and 1685 deletions
14
Gruntfile.js
14
Gruntfile.js
|
@ -1,3 +1,5 @@
|
|||
/* eslint-env node */
|
||||
|
||||
module.exports = function(grunt) {
|
||||
grunt.file.defaultEncoding = "utf8";
|
||||
grunt.file.preserveBOM = false;
|
||||
|
@ -9,7 +11,7 @@ module.exports = function(grunt) {
|
|||
|
||||
grunt.registerTask("prod",
|
||||
"Creates a production-ready build. Use the --msg flag to add a compile message.",
|
||||
["jshint", "exec:stats", "clean", "jsdoc", "concat", "copy:html_dev", "copy:html_prod", "copy:html_inline",
|
||||
["eslint", "exec:stats", "clean", "jsdoc", "concat", "copy:html_dev", "copy:html_prod", "copy:html_inline",
|
||||
"copy:static_dev", "copy:static_prod", "cssmin", "uglify:prod", "inline", "htmlmin", "chmod"]);
|
||||
|
||||
grunt.registerTask("docs",
|
||||
|
@ -29,11 +31,11 @@ module.exports = function(grunt) {
|
|||
["jshint", "exec:stats", "exec:display_stats"]);
|
||||
|
||||
grunt.registerTask("doc", "docs");
|
||||
grunt.registerTask("lint", "jshint");
|
||||
grunt.registerTask("lint", "eslint");
|
||||
|
||||
|
||||
// Load tasks provided by each plugin
|
||||
grunt.loadNpmTasks("grunt-contrib-jshint");
|
||||
grunt.loadNpmTasks("grunt-eslint");
|
||||
grunt.loadNpmTasks("grunt-jsdoc");
|
||||
grunt.loadNpmTasks("grunt-contrib-clean");
|
||||
grunt.loadNpmTasks("grunt-contrib-concat");
|
||||
|
@ -181,9 +183,9 @@ module.exports = function(grunt) {
|
|||
|
||||
// Project configuration
|
||||
grunt.initConfig({
|
||||
jshint: {
|
||||
eslint: {
|
||||
options: {
|
||||
jshintrc: "src/js/.jshintrc"
|
||||
configFile: "src/js/.eslintrc.json"
|
||||
},
|
||||
gruntfile: ["Gruntfile.js"],
|
||||
core: ["src/js/core/**/*.js"],
|
||||
|
@ -264,7 +266,7 @@ module.exports = function(grunt) {
|
|||
// TODO: Do all this in Jade
|
||||
content = content.replace(
|
||||
'<a href="cyberchef.htm" style="float: left; margin-left: 10px; margin-right: 80px;" download>Download CyberChef<img src="images/download-24x24.png" /></a>',
|
||||
'<span style="float: left; margin-left: 10px;">Compile time: ' + grunt.template.today("dd/mm/yyyy HH:MM:ss") + ' UTC</span>');
|
||||
'<span style="float: left; margin-left: 10px;">Compile time: ' + grunt.template.today("dd/mm/yyyy HH:MM:ss") + " UTC</span>");
|
||||
return grunt.template.process(content, template_options);
|
||||
}
|
||||
},
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
package.json
Executable file → Normal file
2
package.json
Executable file → Normal file
|
@ -36,9 +36,9 @@
|
|||
"grunt-contrib-copy": "~0.8.2",
|
||||
"grunt-contrib-cssmin": "~0.14.0",
|
||||
"grunt-contrib-htmlmin": "~0.6.0",
|
||||
"grunt-contrib-jshint": "~1.0.0",
|
||||
"grunt-contrib-uglify": "~0.11.1",
|
||||
"grunt-contrib-watch": "~0.6.1",
|
||||
"grunt-eslint": "^19.0.0",
|
||||
"grunt-exec": "~0.4.6",
|
||||
"grunt-inline-alt": "~0.3.10",
|
||||
"grunt-jsdoc": "^1.1.0",
|
||||
|
|
93
src/js/.eslintrc.json
Executable file
93
src/js/.eslintrc.json
Executable file
|
@ -0,0 +1,93 @@
|
|||
{
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 6,
|
||||
"ecmaFeatures": {
|
||||
"impliedStrict": true
|
||||
}
|
||||
},
|
||||
"env": {
|
||||
"browser": true,
|
||||
"jquery": true,
|
||||
"es6": true,
|
||||
"node": false
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"rules": {
|
||||
// enable additional rules
|
||||
"no-eval": "error",
|
||||
"no-implied-eval": "error",
|
||||
"dot-notation": "error",
|
||||
"eqeqeq": ["error", "smart"],
|
||||
"no-caller": "error",
|
||||
"no-extra-bind": "error",
|
||||
"no-unused-expressions": "error",
|
||||
"no-useless-call": "error",
|
||||
"no-useless-return": "error",
|
||||
"radix": "warn",
|
||||
|
||||
// modify rules from base configurations
|
||||
"no-unused-vars": ["error", {
|
||||
"args": "none",
|
||||
"vars": "local"
|
||||
}],
|
||||
"no-empty": ["error", {
|
||||
"allowEmptyCatch": true
|
||||
}],
|
||||
|
||||
// disable rules from base configurations
|
||||
"no-console": "off",
|
||||
"no-control-regex": "off",
|
||||
|
||||
// stylistic conventions
|
||||
"brace-style": ["error", "1tbs"],
|
||||
"block-spacing": "error",
|
||||
"array-bracket-spacing": "error",
|
||||
"comma-spacing": "error",
|
||||
"comma-style": "error",
|
||||
"computed-property-spacing": "error",
|
||||
"no-trailing-spaces": ["warn", {
|
||||
"skipBlankLines": true
|
||||
}],
|
||||
"eol-last": "error",
|
||||
"func-call-spacing": "error",
|
||||
"indent": ["error", 4, {
|
||||
"ArrayExpression": "first",
|
||||
"SwitchCase": 1
|
||||
}],
|
||||
"linebreak-style": ["error", "unix"],
|
||||
"quotes": ["error", "double", {
|
||||
"avoidEscape": true
|
||||
}],
|
||||
"semi": ["error", "always"],
|
||||
"unicode-bom": "error"
|
||||
},
|
||||
"globals": {
|
||||
/* core/* */
|
||||
"Chef": false,
|
||||
"Dish": false,
|
||||
"Recipe": false,
|
||||
"Ingredient": false,
|
||||
"Operation": false,
|
||||
"Utils": false,
|
||||
|
||||
/* config/* */
|
||||
"Categories": false,
|
||||
"OperationConfig": false,
|
||||
|
||||
/* views/html/* */
|
||||
"HTMLApp": false,
|
||||
"HTMLCategory": false,
|
||||
"HTMLOperation": false,
|
||||
"HTMLIngredient": false,
|
||||
"Manager": false,
|
||||
"ControlsWaiter": false,
|
||||
"HighlighterWaiter": false,
|
||||
"InputWaiter": false,
|
||||
"OperationsWaiter": false,
|
||||
"OptionsWaiter": false,
|
||||
"OutputWaiter": false,
|
||||
"RecipeWaiter": false,
|
||||
"SeasonalWaiter": false,
|
||||
"WindowWaiter": false
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
{
|
||||
"strict": "implied",
|
||||
"multistr": true,
|
||||
"browser": true,
|
||||
"typed": true,
|
||||
"jquery": true,
|
||||
"node": true,
|
||||
"undef": true,
|
||||
"globals": {
|
||||
/* core/* */
|
||||
"Chef": true,
|
||||
"Dish": true,
|
||||
"Recipe": true,
|
||||
"Ingredient": true,
|
||||
"Operation": true,
|
||||
"Utils": true,
|
||||
|
||||
/* config/* */
|
||||
"Categories": true,
|
||||
"OperationConfig": true,
|
||||
|
||||
/* views/html/* */
|
||||
"HTMLApp": true,
|
||||
"HTMLCategory": true,
|
||||
"HTMLOperation": true,
|
||||
"HTMLIngredient": true,
|
||||
"Manager": true,
|
||||
"ControlsWaiter": true,
|
||||
"HighlighterWaiter": true,
|
||||
"InputWaiter": true,
|
||||
"OperationsWaiter": true,
|
||||
"OptionsWaiter": true,
|
||||
"OutputWaiter": true,
|
||||
"RecipeWaiter": true,
|
||||
"SeasonalWaiter": true,
|
||||
"WindowWaiter": true
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
* @constant
|
||||
* @type {CatConf[]}
|
||||
*/
|
||||
var Categories = [
|
||||
const Categories = [
|
||||
{
|
||||
name: "Favourites",
|
||||
ops: []
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Tell JSHint to ignore "'Object' is not defined" errors in this file, as it references every
|
||||
* Tell eslint to ignore "'Object' is not defined" errors in this file, as it references every
|
||||
* single operation object by definition.
|
||||
*/
|
||||
/* jshint -W117 */
|
||||
/* eslint no-undef: "off" */
|
||||
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@
|
|||
* @constant
|
||||
* @type {Object.<string, OpConf>}
|
||||
*/
|
||||
var OperationConfig = {
|
||||
const OperationConfig = {
|
||||
"Fork": {
|
||||
description: "Split the input data up based on the specified delimiter and run all subsequent operations on each branch separately.<br><br>For example, to decode multiple Base64 strings, enter them all on separate lines then add the 'Fork' and 'From Base64' operations to the recipe. Each string will be decoded separately.",
|
||||
run: FlowControl.run_fork,
|
||||
|
|
|
@ -70,13 +70,14 @@ Chef.prototype.bake = function(input_text, recipe_config, options, progress, ste
|
|||
try {
|
||||
progress = recipe.execute(this.dish, progress);
|
||||
} catch (err) {
|
||||
// We can't throw the error from here as we will return in the finally block and ignore it
|
||||
// so we return the error in the result instead.
|
||||
// Return the error in the result so that everything else gets correctly updated
|
||||
// rather than throwing it here and losing state info.
|
||||
error = err;
|
||||
progress = err.progress;
|
||||
} finally {
|
||||
}
|
||||
|
||||
return {
|
||||
result: this.dish.type == Dish.HTML ?
|
||||
result: this.dish.type === Dish.HTML ?
|
||||
this.dish.get(Dish.HTML) :
|
||||
this.dish.get(Dish.STRING),
|
||||
type: Dish.enum_lookup(this.dish.type),
|
||||
|
@ -85,7 +86,6 @@ Chef.prototype.bake = function(input_text, recipe_config, options, progress, ste
|
|||
duration: new Date().getTime() - start_time,
|
||||
error: error
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ Dish.prototype.set = function(value, type) {
|
|||
* @returns {byte_array|string|number} The value of the output data.
|
||||
*/
|
||||
Dish.prototype.get = function(type) {
|
||||
if (this.type != type) {
|
||||
if (this.type !== type) {
|
||||
this.translate(type);
|
||||
}
|
||||
return this.value;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* @namespace
|
||||
*/
|
||||
var FlowControl = {
|
||||
const FlowControl = {
|
||||
|
||||
/**
|
||||
* @constant
|
||||
|
@ -46,7 +46,7 @@ var FlowControl = {
|
|||
// Create sub_op_list for each tranche to operate on
|
||||
// (all remaining operations unless we encounter a Merge)
|
||||
for (var i = state.progress + 1; i < op_list.length; i++) {
|
||||
if (op_list[i].name == "Merge" && !op_list[i].is_disabled()) {
|
||||
if (op_list[i].name === "Merge" && !op_list[i].is_disabled()) {
|
||||
break;
|
||||
} else {
|
||||
sub_op_list.push(op_list[i]);
|
||||
|
|
|
@ -67,12 +67,11 @@ Ingredient.prepare = function(data, type) {
|
|||
return Utils.parse_escaped_chars(data);
|
||||
case "byte_array":
|
||||
if (typeof data == "string") {
|
||||
data = data.replace(/\s+/g, '');
|
||||
data = data.replace(/\s+/g, "");
|
||||
return Utils.hex_to_byte_array(data);
|
||||
} else {
|
||||
return data;
|
||||
}
|
||||
break;
|
||||
case "number":
|
||||
var number = parseFloat(data);
|
||||
if (isNaN(number)) {
|
||||
|
|
|
@ -203,7 +203,7 @@ var Utils = {
|
|||
*/
|
||||
parse_escaped_chars: function(str) {
|
||||
return str.replace(/(\\)?\\([nrtbf]|x[\da-f]{2})/g, function(m, a, b) {
|
||||
if (a == "\\") return "\\"+b;
|
||||
if (a === "\\") return "\\"+b;
|
||||
switch (b[0]) {
|
||||
case "n":
|
||||
return "\n";
|
||||
|
@ -243,8 +243,8 @@ var Utils = {
|
|||
|
||||
for (var i = 0; i < alph_str.length; i++) {
|
||||
if (i < alph_str.length - 2 &&
|
||||
alph_str[i+1] == "-" &&
|
||||
alph_str[i] != "\\") {
|
||||
alph_str[i+1] === "-" &&
|
||||
alph_str[i] !== "\\") {
|
||||
var start = Utils.ord(alph_str[i]),
|
||||
end = Utils.ord(alph_str[i+2]);
|
||||
|
||||
|
@ -253,8 +253,8 @@ var Utils = {
|
|||
}
|
||||
i += 2;
|
||||
} else if (i < alph_str.length - 2 &&
|
||||
alph_str[i] == "\\" &&
|
||||
alph_str[i+1] == "-") {
|
||||
alph_str[i] === "\\" &&
|
||||
alph_str[i+1] === "-") {
|
||||
alph_arr.push("-");
|
||||
i++;
|
||||
} else {
|
||||
|
@ -278,7 +278,7 @@ var Utils = {
|
|||
hex_to_byte_array: function(hex_str) {
|
||||
// TODO: Handle errors i.e. input string is not hex
|
||||
if (!hex_str) return [];
|
||||
hex_str = hex_str.replace(/\s+/g, '');
|
||||
hex_str = hex_str.replace(/\s+/g, "");
|
||||
var byte_array = [];
|
||||
for (var i = 0; i < hex_str.length; i += 2) {
|
||||
byte_array.push(parseInt(hex_str.substr(i, 2), 16));
|
||||
|
@ -351,7 +351,7 @@ var Utils = {
|
|||
var word_array = CryptoJS.enc.Utf8.parse(str),
|
||||
byte_array = Utils.word_array_to_byte_array(word_array);
|
||||
|
||||
if (str.length != word_array.sigBytes)
|
||||
if (str.length !== word_array.sigBytes)
|
||||
window.app.options.attempt_highlight = false;
|
||||
return byte_array;
|
||||
},
|
||||
|
@ -403,7 +403,7 @@ var Utils = {
|
|||
var word_array = new CryptoJS.lib.WordArray.init(words, byte_array.length),
|
||||
str = CryptoJS.enc.Utf8.stringify(word_array);
|
||||
|
||||
if (str.length != word_array.sigBytes)
|
||||
if (str.length !== word_array.sigBytes)
|
||||
window.app.options.attempt_highlight = false;
|
||||
return str;
|
||||
} catch (err) {
|
||||
|
@ -553,7 +553,7 @@ var Utils = {
|
|||
res.push(String.fromCharCode(Utils.UNIC_WIN1251_MAP[ord]));
|
||||
}
|
||||
|
||||
return res.join('');
|
||||
return res.join("");
|
||||
},
|
||||
|
||||
|
||||
|
@ -577,7 +577,7 @@ var Utils = {
|
|||
res.push(String.fromCharCode(Utils.WIN1251_UNIC_MAP[ord]));
|
||||
}
|
||||
|
||||
return res.join('');
|
||||
return res.join("");
|
||||
},
|
||||
|
||||
|
||||
|
@ -653,7 +653,7 @@ var Utils = {
|
|||
return_type = return_type || "string";
|
||||
|
||||
if (!data) {
|
||||
return return_type == "string" ? "" : [];
|
||||
return return_type === "string" ? "" : [];
|
||||
}
|
||||
|
||||
alphabet = alphabet ?
|
||||
|
@ -678,9 +678,9 @@ var Utils = {
|
|||
enc3 = alphabet.indexOf(data.charAt(i++) || "=");
|
||||
enc4 = alphabet.indexOf(data.charAt(i++) || "=");
|
||||
|
||||
enc2 = enc2 == -1 ? 64 : enc2;
|
||||
enc3 = enc3 == -1 ? 64 : enc3;
|
||||
enc4 = enc4 == -1 ? 64 : enc4;
|
||||
enc2 = enc2 === -1 ? 64 : enc2;
|
||||
enc3 = enc3 === -1 ? 64 : enc3;
|
||||
enc4 = enc4 === -1 ? 64 : enc4;
|
||||
|
||||
chr1 = (enc1 << 2) | (enc2 >> 4);
|
||||
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
||||
|
@ -688,15 +688,15 @@ var Utils = {
|
|||
|
||||
output.push(chr1);
|
||||
|
||||
if (enc3 != 64) {
|
||||
if (enc3 !== 64) {
|
||||
output.push(chr2);
|
||||
}
|
||||
if (enc4 != 64) {
|
||||
if (enc4 !== 64) {
|
||||
output.push(chr3);
|
||||
}
|
||||
}
|
||||
|
||||
return return_type == "string" ? Utils.byte_array_to_utf8(output) : output;
|
||||
return return_type === "string" ? Utils.byte_array_to_utf8(output) : output;
|
||||
},
|
||||
|
||||
|
||||
|
@ -727,8 +727,8 @@ var Utils = {
|
|||
}
|
||||
|
||||
// Add \x or 0x to beginning
|
||||
if (delim == "0x") output = "0x" + output;
|
||||
if (delim == "\\x") output = "\\x" + output;
|
||||
if (delim === "0x") output = "0x" + output;
|
||||
if (delim === "\\x") output = "\\x" + output;
|
||||
|
||||
if (delim.length)
|
||||
return output.slice(0, -delim.length);
|
||||
|
@ -779,9 +779,9 @@ var Utils = {
|
|||
from_hex: function(data, delim, byte_len) {
|
||||
delim = delim || (data.indexOf(" ") >= 0 ? "Space" : "None");
|
||||
byte_len = byte_len || 2;
|
||||
if (delim != "None") {
|
||||
if (delim !== "None") {
|
||||
var delim_regex = Utils.regex_rep[delim];
|
||||
data = data.replace(delim_regex, '');
|
||||
data = data.replace(delim_regex, "");
|
||||
}
|
||||
|
||||
var output = [];
|
||||
|
@ -816,17 +816,17 @@ var Utils = {
|
|||
if (ignore_next) {
|
||||
cell += b;
|
||||
ignore_next = false;
|
||||
} else if (b == "\\") {
|
||||
} else if (b === "\\") {
|
||||
cell += b;
|
||||
ignore_next = true;
|
||||
} else if (b == "\"" && !in_string) {
|
||||
} else if (b === "\"" && !in_string) {
|
||||
in_string = true;
|
||||
} else if (b == "\"" && in_string) {
|
||||
} else if (b === "\"" && in_string) {
|
||||
in_string = false;
|
||||
} else if (b == "," && !in_string) {
|
||||
} else if (b === "," && !in_string) {
|
||||
line.push(cell);
|
||||
cell = "";
|
||||
} else if ((b == "\n" || b == "\r") && !in_string) {
|
||||
} else if ((b === "\n" || b === "\r") && !in_string) {
|
||||
line.push(cell);
|
||||
cell = "";
|
||||
lines.push(line);
|
||||
|
@ -877,7 +877,7 @@ var Utils = {
|
|||
escape_html: function(str) {
|
||||
return str.replace(/</g, "<")
|
||||
.replace(/'/g, "'")
|
||||
.replace(/"/g, '"')
|
||||
.replace(/"/g, """)
|
||||
.replace(/&/g, "&");
|
||||
},
|
||||
|
||||
|
@ -1002,8 +1002,8 @@ $.fn.selectRange = function(start, end) {
|
|||
} else if (this.createTextRange) {
|
||||
var range = this.createTextRange();
|
||||
range.collapse(true);
|
||||
range.moveEnd('character', end);
|
||||
range.moveStart('character', start);
|
||||
range.moveEnd("character", end);
|
||||
range.moveStart("character", start);
|
||||
range.select();
|
||||
}
|
||||
});
|
||||
|
@ -1095,7 +1095,7 @@ Array.prototype.sum = function() {
|
|||
Array.prototype.equals = function(other) {
|
||||
if (!other) return false;
|
||||
var i = this.length;
|
||||
if (i != other.length) return false;
|
||||
if (i !== other.length) return false;
|
||||
while (i--) {
|
||||
if (this[i] !== other[i]) return false;
|
||||
}
|
||||
|
|
|
@ -212,14 +212,14 @@ var Base64 = {
|
|||
}
|
||||
|
||||
// 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='" +
|
||||
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='" +
|
||||
Utils.escape_html(Utils.from_base64(static_section, alphabet).slice(0, -1)) + "'>" +
|
||||
|
@ -242,14 +242,14 @@ var Base64 = {
|
|||
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='" +
|
||||
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='" +
|
||||
Utils.escape_html(Utils.from_base64("AA" + static_section, alphabet).slice(1, -1)) + "'>" +
|
||||
|
@ -271,14 +271,14 @@ var Base64 = {
|
|||
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='" +
|
||||
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='" +
|
||||
Utils.escape_html(Utils.from_base64("AAA" + static_section, alphabet).slice(2, -2)) + "'>" +
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -80,7 +80,7 @@ var ByteRepr = {
|
|||
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;
|
||||
|
@ -117,13 +117,13 @@ var ByteRepr = {
|
|||
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
|
||||
// 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));
|
||||
|
@ -149,13 +149,13 @@ 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;
|
||||
}
|
||||
|
@ -174,11 +174,11 @@ 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;
|
||||
|
@ -218,7 +218,7 @@ var ByteRepr = {
|
|||
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;
|
||||
},
|
||||
|
@ -256,9 +256,9 @@ 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 = [];
|
||||
|
@ -325,7 +325,7 @@ 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;
|
||||
|
@ -333,11 +333,11 @@ var ByteRepr = {
|
|||
|
||||
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;
|
||||
|
@ -366,7 +366,7 @@ 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++]));
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -79,7 +79,7 @@ var Cipher = {
|
|||
});
|
||||
|
||||
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]);
|
||||
|
|
|
@ -183,39 +183,39 @@ var Code = {
|
|||
|
||||
// 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;
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ var Code = {
|
|||
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);
|
||||
|
@ -288,8 +288,8 @@ var Code = {
|
|||
|
||||
// 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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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++;
|
||||
|
|
|
@ -79,7 +79,7 @@ var FileType = {
|
|||
|
||||
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.";
|
||||
output += " Run this operation with the 'Ignore common byte sequences' option unchecked to see details.";
|
||||
|
@ -107,326 +107,326 @@ 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"
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -434,48 +434,48 @@ var FileType = {
|
|||
// ################################################################## //
|
||||
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."
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -483,40 +483,40 @@ var FileType = {
|
|||
(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"
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ 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 = "";
|
||||
|
@ -79,7 +79,7 @@ var HTML = {
|
|||
m,
|
||||
i = 0;
|
||||
|
||||
while (!!(m = regex.exec(input))) {
|
||||
while ((m = regex.exec(input))) {
|
||||
// Add up to match
|
||||
for (; i < m.index;)
|
||||
output += input[i++];
|
||||
|
@ -88,11 +88,11 @@ var HTML = {
|
|||
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. )
|
||||
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. :)
|
||||
var hex = m[1].slice(2, m[1].length);
|
||||
output += Utils.chr(parseInt(hex, 16));
|
||||
|
@ -161,18 +161,18 @@ var HTML = {
|
|||
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,
|
||||
|
@ -183,7 +183,7 @@ var HTML = {
|
|||
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]),
|
||||
|
@ -201,7 +201,7 @@ var HTML = {
|
|||
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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,7 +755,7 @@ var IP = {
|
|||
}
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (i != start) {
|
||||
if (i !== start) {
|
||||
output += Utils.hex(ipv6[i], 1) + ":";
|
||||
} else {
|
||||
output += ":";
|
||||
|
|
|
@ -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");
|
||||
},
|
||||
|
||||
};
|
||||
|
|
|
@ -50,7 +50,7 @@ var OS = {
|
|||
// 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);
|
||||
|
@ -104,8 +104,8 @@ var OS = {
|
|||
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":
|
||||
|
@ -121,8 +121,8 @@ var OS = {
|
|||
}
|
||||
}
|
||||
|
||||
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":
|
||||
|
@ -138,8 +138,8 @@ var OS = {
|
|||
}
|
||||
}
|
||||
|
||||
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":
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -65,7 +65,7 @@ ControlsWaiter.prototype.adjust_width = function() {
|
|||
ControlsWaiter.prototype.set_auto_bake = function(value) {
|
||||
var auto_bake_checkbox = document.getElementById("auto-bake");
|
||||
|
||||
if (auto_bake_checkbox.checked != value) {
|
||||
if (auto_bake_checkbox.checked !== value) {
|
||||
auto_bake_checkbox.click();
|
||||
}
|
||||
};
|
||||
|
@ -138,9 +138,7 @@ ControlsWaiter.prototype.clear_breaks_click = function() {
|
|||
ControlsWaiter.prototype.initialise_save_link = function(recipe_config) {
|
||||
recipe_config = recipe_config || this.app.get_recipe_config();
|
||||
|
||||
var recipe_str = JSON.stringify(recipe_config),
|
||||
input_str = Utils.to_base64(this.app.get_input()),
|
||||
include_recipe = document.getElementById("save-link-recipe-checkbox").checked,
|
||||
var include_recipe = document.getElementById("save-link-recipe-checkbox").checked,
|
||||
include_input = document.getElementById("save-link-input-checkbox").checked,
|
||||
save_link_el = document.getElementById("save-link"),
|
||||
save_link = this.generate_state_url(include_recipe, include_input, recipe_config);
|
||||
|
@ -200,7 +198,7 @@ ControlsWaiter.prototype.save_text_change = function() {
|
|||
*/
|
||||
ControlsWaiter.prototype.save_click = function() {
|
||||
var recipe_config = this.app.get_recipe_config();
|
||||
var recipe_str = JSON.stringify(recipe_config).replace(/},{/g, '},\n{');
|
||||
var recipe_str = JSON.stringify(recipe_config).replace(/},{/g, "},\n{");
|
||||
document.getElementById("save-text").value = recipe_str;
|
||||
|
||||
this.initialise_save_link(recipe_config);
|
||||
|
@ -300,7 +298,7 @@ ControlsWaiter.prototype.load_delete_click = function() {
|
|||
JSON.parse(localStorage.saved_recipes) : [];
|
||||
|
||||
saved_recipes = saved_recipes.filter(function(r) {
|
||||
return r.id != id;
|
||||
return r.id !== id;
|
||||
});
|
||||
|
||||
localStorage.saved_recipes = JSON.stringify(saved_recipes);
|
||||
|
@ -318,7 +316,7 @@ ControlsWaiter.prototype.load_name_change = function(e) {
|
|||
id = parseInt(el.value, 10);
|
||||
|
||||
var recipe = saved_recipes.filter(function(r) {
|
||||
return r.id == id;
|
||||
return r.id === id;
|
||||
})[0];
|
||||
|
||||
document.getElementById("load-text").value = recipe.recipe;
|
||||
|
|
|
@ -80,14 +80,16 @@ HTMLApp.prototype.bake = function(step) {
|
|||
);
|
||||
} catch (err) {
|
||||
this.handle_error(err);
|
||||
} finally {
|
||||
}
|
||||
|
||||
if (!response) return;
|
||||
|
||||
if (response.error) {
|
||||
this.handle_error(response.error);
|
||||
}
|
||||
|
||||
this.options = response.options;
|
||||
this.dish_str = response.type == "html" ? Utils.strip_html_tags(response.result, true) : response.result;
|
||||
this.dish_str = response.type === "html" ? Utils.strip_html_tags(response.result, true) : response.result;
|
||||
this.progress = response.progress;
|
||||
this.manager.recipe.update_breakpoint_indicator(response.progress);
|
||||
this.manager.output.set(response.result, response.type, response.duration);
|
||||
|
@ -98,7 +100,6 @@ HTMLApp.prototype.bake = function(step) {
|
|||
this.alert("Baking took longer than " + this.options.auto_bake_threshold +
|
||||
"ms, Auto Bake has been disabled.", "warning", 5000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -252,7 +253,7 @@ HTMLApp.prototype.load_favourites = function() {
|
|||
this.save_favourites(favourites);
|
||||
|
||||
var fav_cat = this.categories.filter(function(c) {
|
||||
return c.name == "Favourites";
|
||||
return c.name === "Favourites";
|
||||
})[0];
|
||||
|
||||
if (fav_cat) {
|
||||
|
@ -339,15 +340,15 @@ HTMLApp.prototype.load_URI_params = function() {
|
|||
if (a === "") return {};
|
||||
var b = {};
|
||||
for (var i = 0; i < a.length; i++) {
|
||||
var p = a[i].split('=');
|
||||
if (p.length != 2) {
|
||||
var p = a[i].split("=");
|
||||
if (p.length !== 2) {
|
||||
b[a[i]] = true;
|
||||
} else {
|
||||
b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
|
||||
}
|
||||
}
|
||||
return b;
|
||||
})(window.location.search.substr(1).split('&'));
|
||||
})(window.location.search.substr(1).split("&"));
|
||||
|
||||
// Turn off auto-bake while loading
|
||||
var auto_bake_val = this.auto_bake_;
|
||||
|
@ -430,7 +431,7 @@ HTMLApp.prototype.set_recipe_config = function(recipe_config) {
|
|||
// Populate arguments
|
||||
var args = item.querySelectorAll(".arg");
|
||||
for (var j = 0; j < args.length; j++) {
|
||||
if (args[j].getAttribute("type") == "checkbox") {
|
||||
if (args[j].getAttribute("type") === "checkbox") {
|
||||
// checkbox
|
||||
args[j].checked = recipe_config[i].args[j];
|
||||
} else if (args[j].classList.contains("toggle-string")) {
|
||||
|
@ -533,7 +534,7 @@ HTMLApp.prototype.alert = function(str, style, timeout, silent) {
|
|||
alert_el.classList.add("alert-" + style);
|
||||
|
||||
// If the box hasn't been closed, append to it rather than replacing
|
||||
if (alert_el.style.display == "block") {
|
||||
if (alert_el.style.display === "block") {
|
||||
alert_content.innerHTML +=
|
||||
"<br><br>[" + time.toLocaleTimeString() + "] " + str;
|
||||
} else {
|
||||
|
|
|
@ -32,16 +32,16 @@ var HTMLIngredient = function(config, app, manager) {
|
|||
* @returns {string}
|
||||
*/
|
||||
HTMLIngredient.prototype.to_html = function() {
|
||||
var inline = (this.type == "boolean" ||
|
||||
this.type == "number" ||
|
||||
this.type == "option" ||
|
||||
this.type == "short_string" ||
|
||||
this.type == "binary_short_string"),
|
||||
var inline = (this.type === "boolean" ||
|
||||
this.type === "number" ||
|
||||
this.type === "option" ||
|
||||
this.type === "short_string" ||
|
||||
this.type === "binary_short_string"),
|
||||
html = inline ? "" : "<div class='clearfix'> </div>",
|
||||
i, m;
|
||||
|
||||
html += "<div class='arg-group" + (inline ? " inline-args" : "") +
|
||||
(this.type == "text" ? " arg-group-text" : "") + "'><label class='arg-label' for='" +
|
||||
(this.type === "text" ? " arg-group-text" : "") + "'><label class='arg-label' for='" +
|
||||
this.id + "'>" + this.name + "</label>";
|
||||
|
||||
switch (this.type) {
|
||||
|
@ -92,9 +92,9 @@ HTMLIngredient.prototype.to_html = function() {
|
|||
html += "<select class='arg' id='" + this.id + "'arg_name='" + this.name + "'" +
|
||||
(this.disabled ? " disabled='disabled'" : "") + ">";
|
||||
for (i = 0; i < this.value.length; i++) {
|
||||
if (!!(m = this.value[i].match(/\[([a-z0-9 -()^]+)\]/i))) {
|
||||
if ((m = this.value[i].match(/\[([a-z0-9 -()^]+)\]/i))) {
|
||||
html += "<optgroup label='" + m[1] + "'>";
|
||||
} else if (!!(m = this.value[i].match(/\[\/([a-z0-9 -()^]+)\]/i))) {
|
||||
} else if ((m = this.value[i].match(/\[\/([a-z0-9 -()^]+)\]/i))) {
|
||||
html += "</optgroup>";
|
||||
} else {
|
||||
html += "<option>" + this.value[i] + "</option>";
|
||||
|
@ -106,9 +106,9 @@ HTMLIngredient.prototype.to_html = function() {
|
|||
html += "<select class='arg' id='" + this.id + "'arg_name='" + this.name + "'" +
|
||||
(this.disabled ? " disabled='disabled'" : "") + ">";
|
||||
for (i = 0; i < this.value.length; i++) {
|
||||
if (!!(m = this.value[i].name.match(/\[([a-z0-9 -()^]+)\]/i))) {
|
||||
if ((m = this.value[i].name.match(/\[([a-z0-9 -()^]+)\]/i))) {
|
||||
html += "<optgroup label='" + m[1] + "'>";
|
||||
} else if (!!(m = this.value[i].name.match(/\[\/([a-z0-9 -()^]+)\]/i))) {
|
||||
} else if ((m = this.value[i].name.match(/\[\/([a-z0-9 -()^]+)\]/i))) {
|
||||
html += "</optgroup>";
|
||||
} else {
|
||||
html += "<option populate-value='" + this.value[i].value + "'>" +
|
||||
|
|
|
@ -237,8 +237,8 @@ HighlighterWaiter.prototype.output_html_mouseup = function(e) {
|
|||
HighlighterWaiter.prototype.input_mousemove = function(e) {
|
||||
// Check that the left mouse button is pressed
|
||||
if (!this.mouse_button_down ||
|
||||
e.which != 1 ||
|
||||
this.mouse_target != HighlighterWaiter.INPUT)
|
||||
e.which !== 1 ||
|
||||
this.mouse_target !== HighlighterWaiter.INPUT)
|
||||
return;
|
||||
|
||||
var el = e.target,
|
||||
|
@ -261,8 +261,8 @@ HighlighterWaiter.prototype.input_mousemove = function(e) {
|
|||
HighlighterWaiter.prototype.output_mousemove = function(e) {
|
||||
// Check that the left mouse button is pressed
|
||||
if (!this.mouse_button_down ||
|
||||
e.which != 1 ||
|
||||
this.mouse_target != HighlighterWaiter.OUTPUT)
|
||||
e.which !== 1 ||
|
||||
this.mouse_target !== HighlighterWaiter.OUTPUT)
|
||||
return;
|
||||
|
||||
var el = e.target,
|
||||
|
@ -285,8 +285,8 @@ HighlighterWaiter.prototype.output_mousemove = function(e) {
|
|||
HighlighterWaiter.prototype.output_html_mousemove = function(e) {
|
||||
// Check that the left mouse button is pressed
|
||||
if (!this.mouse_button_down ||
|
||||
e.which != 1 ||
|
||||
this.mouse_target != HighlighterWaiter.OUTPUT)
|
||||
e.which !== 1 ||
|
||||
this.mouse_target !== HighlighterWaiter.OUTPUT)
|
||||
return;
|
||||
|
||||
var sel = this._get_output_html_selection_offsets();
|
||||
|
@ -458,7 +458,7 @@ HighlighterWaiter.prototype.highlight = function(textarea, highlighter, pos) {
|
|||
// Put placeholders in position
|
||||
// If there's only one value, select that
|
||||
// If there are multiple, ignore the first one and select all others
|
||||
if (pos.length == 1) {
|
||||
if (pos.length === 1) {
|
||||
if (pos[0].end < pos[0].start) return;
|
||||
text = text.slice(0, pos[0].start) +
|
||||
start_placeholder + text.slice(pos[0].start, pos[0].end) + end_placeholder +
|
||||
|
@ -471,11 +471,11 @@ HighlighterWaiter.prototype.highlight = function(textarea, highlighter, pos) {
|
|||
for (var i = 0; i < text.length; i++) {
|
||||
for (var j = 1; j < pos.length; j++) {
|
||||
if (pos[j].end < pos[j].start) continue;
|
||||
if (pos[j].start == i) {
|
||||
if (pos[j].start === i) {
|
||||
result += start_placeholder;
|
||||
end_placed = false;
|
||||
}
|
||||
if (pos[j].end == i) {
|
||||
if (pos[j].end === i) {
|
||||
result += end_placeholder;
|
||||
end_placed = true;
|
||||
}
|
||||
|
|
|
@ -162,7 +162,7 @@ InputWaiter.prototype.input_drop = function(e) {
|
|||
|
||||
this.set(input_charcode);
|
||||
var recipe_config = this.app.get_recipe_config();
|
||||
if (!recipe_config[0] || recipe_config[0].op != "From Hex") {
|
||||
if (!recipe_config[0] || recipe_config[0].op !== "From Hex") {
|
||||
recipe_config.unshift({op:"From Hex", args:["Space"]});
|
||||
this.app.set_recipe_config(recipe_config);
|
||||
}
|
||||
|
@ -178,14 +178,14 @@ InputWaiter.prototype.input_drop = function(e) {
|
|||
el.value = "Processing... " + Math.round(offset / file.size * 100) + "%";
|
||||
var slice = file.slice(offset, offset + CHUNK_SIZE);
|
||||
reader.readAsArrayBuffer(slice);
|
||||
}.bind(this);
|
||||
};
|
||||
|
||||
reader.onload = function(e) {
|
||||
var data = new Uint8Array(reader.result);
|
||||
input_charcode += Utils.to_hex_fast(data);
|
||||
offset += CHUNK_SIZE;
|
||||
seek();
|
||||
}.bind(this);
|
||||
};
|
||||
|
||||
|
||||
el.classList.remove("dropping-file");
|
||||
|
|
|
@ -29,7 +29,7 @@ var OperationsWaiter = function(app, manager) {
|
|||
OperationsWaiter.prototype.search_operations = function(e) {
|
||||
var ops, selected;
|
||||
|
||||
if (e.type == "search") { // Search
|
||||
if (e.type === "search") { // Search
|
||||
e.preventDefault();
|
||||
ops = document.querySelectorAll("#search-results li");
|
||||
if (ops.length) {
|
||||
|
@ -41,9 +41,9 @@ OperationsWaiter.prototype.search_operations = function(e) {
|
|||
}
|
||||
}
|
||||
|
||||
if (e.keyCode == 13) { // Return
|
||||
if (e.keyCode === 13) { // Return
|
||||
e.preventDefault();
|
||||
} else if (e.keyCode == 40) { // Down
|
||||
} else if (e.keyCode === 40) { // Down
|
||||
e.preventDefault();
|
||||
ops = document.querySelectorAll("#search-results li");
|
||||
if (ops.length) {
|
||||
|
@ -51,10 +51,10 @@ OperationsWaiter.prototype.search_operations = function(e) {
|
|||
if (selected > -1) {
|
||||
ops[selected].classList.remove("selected-op");
|
||||
}
|
||||
if (selected == ops.length-1) selected = -1;
|
||||
if (selected === ops.length-1) selected = -1;
|
||||
ops[selected+1].classList.add("selected-op");
|
||||
}
|
||||
} else if (e.keyCode == 38) { // Up
|
||||
} else if (e.keyCode === 38) { // Up
|
||||
e.preventDefault();
|
||||
ops = document.querySelectorAll("#search-results li");
|
||||
if (ops.length) {
|
||||
|
@ -183,7 +183,7 @@ OperationsWaiter.prototype.edit_favourites_click = function(e) {
|
|||
|
||||
// Add favourites to modal
|
||||
var fav_cat = this.app.categories.filter(function(c) {
|
||||
return c.name == "Favourites";
|
||||
return c.name === "Favourites";
|
||||
})[0];
|
||||
|
||||
var html = "";
|
||||
|
@ -198,7 +198,7 @@ OperationsWaiter.prototype.edit_favourites_click = function(e) {
|
|||
this.remove_intent = false;
|
||||
|
||||
var editable_list = Sortable.create(edit_favourites_list, {
|
||||
filter: '.remove-icon',
|
||||
filter: ".remove-icon",
|
||||
onFilter: function (evt) {
|
||||
var el = editable_list.closest(evt.item);
|
||||
if (el) {
|
||||
|
@ -260,7 +260,7 @@ OperationsWaiter.prototype.reset_favourites_click = function() {
|
|||
*/
|
||||
OperationsWaiter.prototype.op_icon_mouseover = function(e) {
|
||||
var op_el = e.target.parentNode;
|
||||
if (e.target.getAttribute("data-toggle") == "popover") {
|
||||
if (e.target.getAttribute("data-toggle") === "popover") {
|
||||
$(op_el).popover("hide");
|
||||
}
|
||||
};
|
||||
|
@ -277,7 +277,7 @@ OperationsWaiter.prototype.op_icon_mouseleave = function(e) {
|
|||
var op_el = e.target.parentNode,
|
||||
to_el = e.toElement || e.relatedElement;
|
||||
|
||||
if (e.target.getAttribute("data-toggle") == "popover" && to_el === op_el) {
|
||||
if (e.target.getAttribute("data-toggle") === "popover" && to_el === op_el) {
|
||||
$(op_el).popover("show");
|
||||
}
|
||||
};
|
||||
|
|
|
@ -38,7 +38,7 @@ OutputWaiter.prototype.set = function(data_str, type, duration) {
|
|||
output_highlighter = document.getElementById("output-highlighter"),
|
||||
input_highlighter = document.getElementById("input-highlighter");
|
||||
|
||||
if (type == "html") {
|
||||
if (type === "html") {
|
||||
output_text.style.display = "none";
|
||||
output_html.style.display = "block";
|
||||
output_highlighter.display = "none";
|
||||
|
@ -51,7 +51,7 @@ OutputWaiter.prototype.set = function(data_str, type, duration) {
|
|||
var script_elements = output_html.querySelectorAll("script");
|
||||
for (var i = 0; i < script_elements.length; i++) {
|
||||
try {
|
||||
eval(script_elements[i].innerHTML); // jshint ignore:line
|
||||
eval(script_elements[i].innerHTML); // eslint-disable-line no-eval
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
|
|
@ -22,8 +22,7 @@ var RecipeWaiter = function(app, manager) {
|
|||
* Sets up the drag and drop capability for operations in the operations and recipe areas.
|
||||
*/
|
||||
RecipeWaiter.prototype.initialise_operation_drag_n_drop = function() {
|
||||
var rec_list = document.getElementById("rec_list"),
|
||||
op_lists = document.querySelectorAll(".category .op_list");
|
||||
var rec_list = document.getElementById("rec_list");
|
||||
|
||||
|
||||
// Recipe list
|
||||
|
@ -102,7 +101,7 @@ RecipeWaiter.prototype.create_sortable_seed_list = function(list_el) {
|
|||
*/
|
||||
RecipeWaiter.prototype.op_sort_end = function(evt) {
|
||||
if (this.remove_intent) {
|
||||
if (evt.item.parentNode.id == "rec_list") {
|
||||
if (evt.item.parentNode.id === "rec_list") {
|
||||
evt.item.remove();
|
||||
}
|
||||
return;
|
||||
|
@ -197,7 +196,7 @@ RecipeWaiter.prototype.ing_change = function() {
|
|||
RecipeWaiter.prototype.disable_click = function(e) {
|
||||
var icon = e.target;
|
||||
|
||||
if (icon.getAttribute("disabled") == "false") {
|
||||
if (icon.getAttribute("disabled") === "false") {
|
||||
icon.setAttribute("disabled", "true");
|
||||
icon.classList.add("disable-icon-selected");
|
||||
icon.parentNode.parentNode.classList.add("disabled");
|
||||
|
@ -222,7 +221,7 @@ RecipeWaiter.prototype.disable_click = function(e) {
|
|||
RecipeWaiter.prototype.breakpoint_click = function(e) {
|
||||
var bp = e.target;
|
||||
|
||||
if (bp.getAttribute("break") == "false") {
|
||||
if (bp.getAttribute("break") === "false") {
|
||||
bp.setAttribute("break", "true");
|
||||
bp.classList.add("breakpoint-selected");
|
||||
} else {
|
||||
|
@ -276,7 +275,7 @@ RecipeWaiter.prototype.get_config = function() {
|
|||
ing_list = operations[i].querySelectorAll(".arg");
|
||||
|
||||
for (var j = 0; j < ing_list.length; j++) {
|
||||
if (ing_list[j].getAttribute("type") == "checkbox") {
|
||||
if (ing_list[j].getAttribute("type") === "checkbox") {
|
||||
// checkbox
|
||||
ingredients[j] = ing_list[j].checked;
|
||||
} else if (ing_list[j].classList.contains("toggle-string")) {
|
||||
|
@ -296,11 +295,11 @@ RecipeWaiter.prototype.get_config = function() {
|
|||
args: ingredients
|
||||
};
|
||||
|
||||
if (disabled && disabled.getAttribute("disabled") == "true") {
|
||||
if (disabled && disabled.getAttribute("disabled") === "true") {
|
||||
item.disabled = true;
|
||||
}
|
||||
|
||||
if (bp && bp.getAttribute("break") == "true") {
|
||||
if (bp && bp.getAttribute("break") === "true") {
|
||||
item.breakpoint = true;
|
||||
}
|
||||
|
||||
|
@ -319,7 +318,7 @@ RecipeWaiter.prototype.get_config = function() {
|
|||
RecipeWaiter.prototype.update_breakpoint_indicator = function(position) {
|
||||
var operations = document.querySelectorAll("#rec_list li.operation");
|
||||
for (var i = 0; i < operations.length; i++) {
|
||||
if (i == position) {
|
||||
if (i === position) {
|
||||
operations[i].classList.add("break");
|
||||
} else {
|
||||
operations[i].classList.remove("break");
|
||||
|
@ -360,6 +359,7 @@ RecipeWaiter.prototype.build_recipe_operation = function(el) {
|
|||
*/
|
||||
RecipeWaiter.prototype.add_operation = function(name) {
|
||||
var item = document.createElement("li");
|
||||
|
||||
item.classList.add("operation");
|
||||
item.innerHTML = name;
|
||||
this.build_recipe_operation(item);
|
||||
|
|
|
@ -22,17 +22,17 @@ SeasonalWaiter.prototype.load = function() {
|
|||
var now = new Date();
|
||||
|
||||
// Snowfall
|
||||
if (now.getMonth() == 11 && now.getDate() > 12) { // Dec 13 -> Dec 31
|
||||
if (now.getMonth() === 11 && now.getDate() > 12) { // Dec 13 -> Dec 31
|
||||
this.app.options.snow = false;
|
||||
this.create_snow_option();
|
||||
$(document).on("switchChange.bootstrapSwitch", ".option-item input:checkbox[option='snow']", this.let_it_snow.bind(this));
|
||||
window.addEventListener("resize", this.let_it_snow.bind(this));
|
||||
this.manager.add_listeners(".btn", "click", this.shake_off_snow, this);
|
||||
if (now.getDate() == 25) this.let_it_snow();
|
||||
if (now.getDate() === 25) this.let_it_snow();
|
||||
}
|
||||
|
||||
// SpiderChef
|
||||
// if (now.getMonth() == 3 && now.getDate() == 1) { // Apr 1
|
||||
// if (now.getMonth() === 3 && now.getDate() === 1) { // Apr 1
|
||||
// this.insert_spider_icons();
|
||||
// this.insert_spider_text();
|
||||
// }
|
||||
|
@ -74,7 +74,7 @@ SeasonalWaiter.prototype.insert_spider_text = function() {
|
|||
// Body
|
||||
SeasonalWaiter.tree_walk(document.body, function(node) {
|
||||
// process only text nodes
|
||||
if (node.nodeType == 3) {
|
||||
if (node.nodeType === 3) {
|
||||
node.nodeValue = node.nodeValue.replace(/Cyber/g, "Spider");
|
||||
}
|
||||
}, true);
|
||||
|
@ -82,7 +82,7 @@ SeasonalWaiter.prototype.insert_spider_text = function() {
|
|||
// Bake button
|
||||
SeasonalWaiter.tree_walk(document.getElementById("bake-group"), function(node) {
|
||||
// process only text nodes
|
||||
if (node.nodeType == 3) {
|
||||
if (node.nodeType === 3) {
|
||||
node.nodeValue = node.nodeValue.replace(/Bake/g, "Spin");
|
||||
}
|
||||
}, true);
|
||||
|
@ -125,8 +125,8 @@ SeasonalWaiter.prototype.let_it_snow = function() {
|
|||
// Firefox < 30
|
||||
options = {
|
||||
flakeCount: 10,
|
||||
flakeColor : '#fff',
|
||||
flakePosition: 'absolute',
|
||||
flakeColor: "#fff",
|
||||
flakePosition: "absolute",
|
||||
minSize: 1,
|
||||
maxSize: 2,
|
||||
minSpeed: 1,
|
||||
|
@ -140,9 +140,9 @@ SeasonalWaiter.prototype.let_it_snow = function() {
|
|||
} else {
|
||||
// All other browsers
|
||||
options = {
|
||||
flakeCount : 35, //35
|
||||
flakeColor : '#fff',
|
||||
flakePosition: 'absolute',
|
||||
flakeCount: 35,
|
||||
flakeColor: "#fff",
|
||||
flakePosition: "absolute",
|
||||
minSize: 5,
|
||||
maxSize: 8,
|
||||
minSpeed: 1,
|
||||
|
@ -175,7 +175,7 @@ SeasonalWaiter.prototype.shake_off_snow = function(e) {
|
|||
|
||||
for (var i = 0; i < canvases.length; i++) {
|
||||
canvas = canvases[i];
|
||||
if (canvas.style.left == rect.left + "px" && canvas.style.top == (rect.top - 20) + "px") {
|
||||
if (canvas.style.left === rect.left + "px" && canvas.style.top === (rect.top - 20) + "px") {
|
||||
var ctx = canvas.getContext("2d");
|
||||
|
||||
$(canvas).fadeOut("slow", remove_func);
|
||||
|
@ -194,11 +194,11 @@ SeasonalWaiter.prototype.konami_code_listener = function(e) {
|
|||
this.kkeys.push(e.keyCode);
|
||||
var konami = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65];
|
||||
for (var i = 0; i < this.kkeys.length; i++) {
|
||||
if (this.kkeys[i] != konami[i]) {
|
||||
if (this.kkeys[i] !== konami[i]) {
|
||||
this.kkeys = [];
|
||||
break;
|
||||
}
|
||||
if (i == konami.length - 1) {
|
||||
if (i === konami.length - 1) {
|
||||
$("body").children().toggleClass("konami");
|
||||
this.kkeys = [];
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ SeasonalWaiter.tree_walk = (function() {
|
|||
return function(parent, fn, all_nodes) {
|
||||
var node = parent.firstChild;
|
||||
|
||||
while (node && node != parent) {
|
||||
while (node && node !== parent) {
|
||||
if (all_nodes || node.nodeType === 1) {
|
||||
if (fn(node) === false) {
|
||||
return(false);
|
||||
|
@ -243,7 +243,7 @@ SeasonalWaiter.tree_walk = (function() {
|
|||
} else {
|
||||
// No child and no nextsibling
|
||||
// Find parent that has a nextSibling
|
||||
while ((node = node.parentNode) != parent) {
|
||||
while ((node = node.parentNode) !== parent) {
|
||||
if (node.nextSibling) {
|
||||
node = node.nextSibling;
|
||||
break;
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
203 source files
|
||||
104410 lines
|
||||
104466 lines
|
||||
4.0M size
|
||||
|
||||
136 JavaScript source files
|
||||
95314 lines
|
||||
3.5M size
|
||||
95316 lines
|
||||
3.4M size
|
||||
|
||||
78 third party JavaScript source files
|
||||
76377 lines
|
||||
2.7M size
|
||||
|
||||
58 first party JavaScript source files
|
||||
18937 lines
|
||||
728K size
|
||||
18939 lines
|
||||
724K size
|
||||
|
||||
3.2M uncompressed JavaScript size
|
||||
compressed JavaScript size
|
||||
1.7M compressed JavaScript size
|
||||
|
||||
15 categories
|
||||
155 operations
|
||||
|
|
Loading…
Reference in a new issue