Replaced jsHint with eslint. Fixes #4.

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

View file

@ -1,21 +1,23 @@
/* eslint-env node */
module.exports = function(grunt) {
grunt.file.defaultEncoding = "utf8";
grunt.file.preserveBOM = false;
// Tasks
grunt.registerTask("dev",
"A persistent task which creates a development build whenever source files are modified.",
["clean:dev", "concat:css", "concat:js", "copy:html_dev", "copy:static_dev", "chmod:build", "watch"]);
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",
"Compiles documentation in the /docs directory.",
["clean:docs", "jsdoc", "chmod:docs"]);
grunt.registerTask("stats",
"Provides statistics about the code base such as how many lines there are as well as details of file sizes before and after compression.",
["concat:js", "uglify:prod", "exec:stats", "exec:repo_size", "exec:display_stats"]);
@ -23,17 +25,17 @@ module.exports = function(grunt) {
grunt.registerTask("release",
"Prepares and deploys a production version of CyberChef to the gh-pages branch.",
["copy:gh_pages", "exec:deploy_gh_pages"]);
grunt.registerTask("default",
"Lints the code base and shows stats",
["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");
@ -45,8 +47,8 @@ module.exports = function(grunt) {
grunt.loadNpmTasks("grunt-chmod");
grunt.loadNpmTasks("grunt-exec");
grunt.loadNpmTasks("grunt-contrib-watch");
// JS includes
var js_files = [
// Third party framework libraries
@ -56,7 +58,7 @@ module.exports = function(grunt) {
"src/js/lib/bootstrap-switch.js",
"src/js/lib/yahoo.js",
"src/js/lib/snowfall.jquery.js",
// Third party operation libraries
"src/js/lib/cryptojs/core.js",
"src/js/lib/cryptojs/x64-core.js",
@ -128,25 +130,25 @@ module.exports = function(grunt) {
"src/js/lib/vkbeautify.js",
"src/js/lib/Sortable.js",
"src/js/lib/bootstrap-colorpicker.js",
// Custom libraries
"src/js/lib/canvas_components.js",
// Utility functions
"src/js/core/Utils.js",
// Operation objects
"src/js/operations/*.js",
// Core framework objects
"src/js/core/*.js",
"src/js/config/Categories.js",
"src/js/config/OperationConfig.js",
// HTML view objects
"src/js/views/html/*.js",
"!src/js/views/html/main.js",
// Start the app!
"src/js/views/html/main.js",
];
@ -178,12 +180,12 @@ module.exports = function(grunt) {
codebase_stats: grunt.file.read("src/static/stats.txt").split("\n").join("<br>")
}
};
// 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);
}
},
@ -403,13 +405,13 @@ module.exports = function(grunt) {
exec: {
repo_size: {
command: [
"git ls-files | wc -l | xargs printf '\n%b\ttracked files\n'",
"du -hs | egrep -o '^[^\t]*' | xargs printf '%b\trepository size\n'"
].join(";"),
"git ls-files | wc -l | xargs printf '\n%b\ttracked files\n'",
"du -hs | egrep -o '^[^\t]*' | xargs printf '%b\trepository size\n'"
].join(";"),
stderr: false
},
stats: {
command: "rm src/static/stats.txt;" +
command: "rm src/static/stats.txt;" +
[
"ls src/ -R1 | grep '^$' -v | grep ':$' -v | wc -l | xargs printf '%b\tsource files\n'",
"find src/ -regex '.*\..*' -print | xargs cat | wc -l | xargs printf '%b\tlines\n'",
@ -429,10 +431,10 @@ module.exports = function(grunt) {
"du build/dev/scripts.js -h | egrep -o '^[^\t]*' | xargs printf '\n%b\tuncompressed JavaScript size\n'",
"du build/prod/scripts.js -h | egrep -o '^[^\t]*' | xargs printf '%b\tcompressed JavaScript size\n'",
"grep -E '^\\s+name: ' src/js/config/Categories.js | wc -l | xargs printf '\n%b\tcategories\n'",
"grep -E '^\\s+\"[A-Za-z0-9 \\-]+\": {' src/js/config/OperationConfig.js | wc -l | xargs printf '%b\toperations\n'",
].join(" >> src/static/stats.txt;") + " >> src/static/stats.txt;",
stderr: false
},

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
View 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
View 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
}
}

View file

@ -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
}
}

View file

@ -17,7 +17,7 @@
* @constant
* @type {CatConf[]}
*/
var Categories = [
const Categories = [
{
name: "Favourites",
ops: []

View file

@ -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,
@ -2828,4 +2828,4 @@ var OperationConfig = {
output_type: "string",
args: []
}
};
};

View file

@ -35,33 +35,33 @@ Chef.prototype.bake = function(input_text, recipe_config, options, progress, ste
recipe = new Recipe(recipe_config),
contains_fc = recipe.contains_flow_control(),
error = false;
// Reset attempt_highlight flag
if (options.hasOwnProperty("attempt_highlight")) {
options.attempt_highlight = true;
}
if (contains_fc) options.attempt_highlight = false;
// Clean up progress
if (progress >= recipe_config.length) {
progress = 0;
}
if (step) {
// Unset breakpoint on this step
recipe.set_breakpoint(progress, false);
// Set breakpoint on next step
recipe.set_breakpoint(progress + 1, true);
}
// If stepping with flow control, we have to start from the beginning
// but still want to skip all previous breakpoints
if (progress > 0 && contains_fc) {
recipe.remove_breaks_up_to(progress);
progress = 0;
}
// If starting from scratch, load data
if (progress === 0) {
this.dish.set(input_text, Dish.STRING);
@ -70,22 +70,22 @@ 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 ?
this.dish.get(Dish.HTML) :
this.dish.get(Dish.STRING),
type: Dish.enum_lookup(this.dish.type),
progress: progress,
options: options,
duration: new Date().getTime() - start_time,
error: error
};
}
return {
result: this.dish.type === Dish.HTML ?
this.dish.get(Dish.HTML) :
this.dish.get(Dish.STRING),
type: Dish.enum_lookup(this.dish.type),
progress: progress,
options: options,
duration: new Date().getTime() - start_time,
error: error
};
};
@ -94,12 +94,12 @@ Chef.prototype.bake = function(input_text, recipe_config, options, progress, ste
* it swaps out the memory for that tab. If the CyberChef tab has been unfocused for more than a
* minute, we run a silent bake which will force the browser to load and cache all the relevant
* JavaScript code needed to do a real bake.
*
*
* This will stop baking taking a long time when the CyberChef browser tab has been unfocused for a
* long time and the browser has swapped out all its memory.
*
*
* The output will not be modified (hence "silent" bake).
*
*
* This will only actually execute the recipe if auto-bake is enabled, otherwise it will just load
* the recipe, ingredients and dish.
*
@ -110,7 +110,7 @@ Chef.prototype.silent_bake = function(recipe_config) {
var start_time = new Date().getTime(),
recipe = new Recipe(recipe_config),
dish = new Dish("", Dish.STRING);
try {
recipe.execute(dish);
} catch(err) {

View file

@ -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;

View file

@ -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]);

View file

@ -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)) {

View file

@ -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, "&lt;")
.replace(/'/g, "&apos;")
.replace(/"/g, '&quot;')
.replace(/"/g, "&quot;")
.replace(/&/g, "&amp;");
},
@ -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;
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

File diff suppressed because it is too large Load diff

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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;

View file

@ -20,14 +20,14 @@ var HTMLApp = function(categories, operations, default_favourites, default_optio
this.dfavourites = default_favourites;
this.doptions = default_options;
this.options = Utils.extend({}, default_options);
this.chef = new Chef();
this.manager = new Manager(this);
this.auto_bake_ = false;
this.progress = 0;
this.ing_id = 0;
window.chef = this.chef;
};
@ -69,7 +69,7 @@ HTMLApp.prototype.handle_error = function(err) {
*/
HTMLApp.prototype.bake = function(step) {
var response;
try {
response = this.chef.bake(
this.get_input(), // The user's input
@ -80,24 +80,25 @@ 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.progress = response.progress;
this.manager.recipe.update_breakpoint_indicator(response.progress);
this.manager.output.set(response.result, response.type, response.duration);
// If baking took too long, disable auto-bake
if (response.duration > this.options.auto_bake_threshold && this.auto_bake_) {
this.manager.controls.set_auto_bake(false);
this.alert("Baking took longer than " + this.options.auto_bake_threshold +
"ms, Auto Bake has been disabled.", "warning", 5000);
}
}
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.progress = response.progress;
this.manager.recipe.update_breakpoint_indicator(response.progress);
this.manager.output.set(response.result, response.type, response.duration);
// If baking took too long, disable auto-bake
if (response.duration > this.options.auto_bake_threshold && this.auto_bake_) {
this.manager.controls.set_auto_bake(false);
this.alert("Baking took longer than " + this.options.auto_bake_threshold +
"ms, Auto Bake has been disabled.", "warning", 5000);
}
};
@ -124,11 +125,11 @@ HTMLApp.prototype.auto_bake = function() {
HTMLApp.prototype.silent_bake = function() {
var start_time = new Date().getTime(),
recipe_config = this.get_recipe_config();
if (this.auto_bake_) {
this.chef.silent_bake(recipe_config);
}
return new Date().getTime() - start_time;
};
@ -140,11 +141,11 @@ HTMLApp.prototype.silent_bake = function() {
*/
HTMLApp.prototype.get_input = function() {
var input = this.manager.input.get();
// Save to session storage in case we need to restore it later
sessionStorage.setItem("input_length", input.length);
sessionStorage.setItem("input", input);
return input;
};
@ -170,31 +171,31 @@ HTMLApp.prototype.set_input = function(input) {
HTMLApp.prototype.populate_operations_list = function() {
// Move edit button away before we overwrite it
document.body.appendChild(document.getElementById("edit-favourites"));
var html = "";
for (var i = 0; i < this.categories.length; i++) {
var cat_conf = this.categories[i],
selected = i === 0,
cat = new HTMLCategory(cat_conf.name, selected);
for (var j = 0; j < cat_conf.ops.length; j++) {
var op_name = cat_conf.ops[j],
op = new HTMLOperation(op_name, this.operations[op_name], this, this.manager);
cat.add_operation(op);
}
html += cat.to_html();
}
document.getElementById("categories").innerHTML = html;
var op_lists = document.querySelectorAll("#categories .op_list");
for (i = 0; i < op_lists.length; i++) {
op_lists[i].dispatchEvent(this.manager.oplistcreate);
}
// Add edit button to first category (Favourites)
document.querySelector("#categories a").appendChild(document.getElementById("edit-favourites"));
};
@ -210,12 +211,12 @@ HTMLApp.prototype.initialise_splitter = function() {
gutterSize: 4,
onDrag: this.manager.controls.adjust_width.bind(this.manager.controls)
});
Split(["#input", "#output"], {
direction: "vertical",
gutterSize: 4,
});
this.reset_layout();
};
@ -231,7 +232,7 @@ HTMLApp.prototype.load_local_storage = function() {
l_options = JSON.parse(localStorage.options);
}
this.manager.options.load(l_options);
// Load favourites
this.load_favourites();
};
@ -247,14 +248,14 @@ HTMLApp.prototype.load_favourites = function() {
localStorage.favourites.length > 2 ?
JSON.parse(localStorage.favourites) :
this.dfavourites;
favourites = this.valid_favourites(favourites);
this.save_favourites(favourites);
var fav_cat = this.categories.filter(function(c) {
return c.name == "Favourites";
return c.name === "Favourites";
})[0];
if (fav_cat) {
fav_cat.ops = favourites;
} else {
@ -269,7 +270,7 @@ HTMLApp.prototype.load_favourites = function() {
/**
* Filters the list of favourite operations that the user had stored and removes any that are no
* longer available. The user is notified if this is the case.
* @param {string[]} favourites - A list of the user's favourite operations
* @returns {string[]} A list of the valid favourites
*/
@ -321,7 +322,7 @@ HTMLApp.prototype.add_favourite = function(name) {
this.alert("'" + name + "' is already in your favourites", "info", 2000);
return;
}
favourites.push(name);
this.save_favourites(favourites);
this.load_favourites();
@ -339,20 +340,20 @@ 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_;
this.auto_bake_ = false;
// Read in recipe from query string
if (this.query_string.recipe) {
try {
@ -370,15 +371,15 @@ HTMLApp.prototype.load_URI_params = function() {
if (matched_ops.length) {
this.manager.recipe.add_operation(matched_ops[0].name);
}
// Populate search with the string
var search = document.getElementById("search");
search.value = this.query_string.op;
search.dispatchEvent(new Event("search"));
}
}
// Read in input data from query string
if (this.query_string.input) {
try {
@ -386,7 +387,7 @@ HTMLApp.prototype.load_URI_params = function() {
this.set_input(input_data);
} catch(err) {}
}
// Restore auto-bake state
this.auto_bake_ = auto_bake_val;
this.auto_bake();
@ -423,14 +424,14 @@ HTMLApp.prototype.get_recipe_config = function() {
HTMLApp.prototype.set_recipe_config = function(recipe_config) {
sessionStorage.setItem("recipe_config", JSON.stringify(recipe_config));
document.getElementById("rec_list").innerHTML = null;
for (var i = 0; i < recipe_config.length; i++) {
var item = this.manager.recipe.add_operation(recipe_config[i].op);
// 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")) {
@ -444,7 +445,7 @@ HTMLApp.prototype.set_recipe_config = function(recipe_config) {
args[j].value = recipe_config[i].args[j];
}
}
// Set disabled and breakpoint
if (recipe_config[i].disabled) {
item.querySelector(".disable-icon").click();
@ -452,7 +453,7 @@ HTMLApp.prototype.set_recipe_config = function(recipe_config) {
if (recipe_config[i].breakpoint) {
item.querySelector(".breakpoint").click();
}
this.progress = 0;
}
};
@ -467,7 +468,7 @@ HTMLApp.prototype.reset_layout = function() {
document.getElementById("IO").style.width = "calc(50% - 2px)";
document.getElementById("input").style.height = "calc(50% - 2px)";
document.getElementById("output").style.height = "calc(50% - 2px)";
this.manager.controls.adjust_width();
};
@ -480,12 +481,12 @@ HTMLApp.prototype.set_compile_message = function() {
var now = new Date(),
time_since_compile = Utils.fuzzy_time(now.getTime() - window.compile_time),
compile_info = "<span style=\"font-weight: normal\">Last build: " +
time_since_compile.substr(0,1).toUpperCase() + time_since_compile.substr(1) + " ago";
time_since_compile.substr(0, 1).toUpperCase() + time_since_compile.substr(1) + " ago";
if (window.compile_message !== "") {
compile_info += " - " + window.compile_message;
}
compile_info += "</span>";
document.getElementById("notice").innerHTML = compile_info;
};
@ -516,36 +517,36 @@ HTMLApp.prototype.set_compile_message = function() {
*/
HTMLApp.prototype.alert = function(str, style, timeout, silent) {
var time = new Date();
console.log("[" + time.toLocaleString() + "] " + str);
if (silent) return;
style = style || "danger";
timeout = timeout || 0;
var alert_el = document.getElementById("alert"),
alert_content = document.getElementById("alert-content");
alert_el.classList.remove("alert-danger");
alert_el.classList.remove("alert-warning");
alert_el.classList.remove("alert-info");
alert_el.classList.remove("alert-success");
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") {
alert_content.innerHTML +=
if (alert_el.style.display === "block") {
alert_content.innerHTML +=
"<br><br>[" + time.toLocaleTimeString() + "] " + str;
} else {
alert_content.innerHTML =
"[" + time.toLocaleTimeString() + "] " + str;
}
// Stop the animation if it is in progress
$("#alert").stop();
alert_el.style.display = "block";
alert_el.style.opacity = 1;
if (timeout > 0) {
clearTimeout(this.alert_timeout);
this.alert_timeout = setTimeout(function(){
@ -573,7 +574,7 @@ HTMLApp.prototype.confirm = function(title, body, callback, scope) {
document.getElementById("confirm-title").innerHTML = title;
document.getElementById("confirm-body").innerHTML = body;
document.getElementById("confirm-modal").style.display = "block";
this.confirm_closed = false;
$("#confirm-modal").modal()
.one("show.bs.modal", function(e) {
@ -610,7 +611,7 @@ HTMLApp.prototype.alert_close_click = function() {
*/
HTMLApp.prototype.state_change = function(e) {
this.auto_bake();
// Update the current history state (not creating a new one)
if (this.options.update_url) {
this.last_state_url = this.manager.controls.generate_state_url(true, true);
@ -640,10 +641,10 @@ HTMLApp.prototype.call_api = function(url, type, data, data_type, content_type)
data = data || {};
data_type = data_type || undefined;
content_type = content_type || "application/json";
var response = null,
success = false;
$.ajax({
url: url,
async: false,
@ -660,7 +661,7 @@ HTMLApp.prototype.call_api = function(url, type, data, data_type, content_type)
response = data;
},
});
return {
success: success,
response: response

View file

@ -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'>&nbsp;</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 + "'>" +

View file

@ -10,7 +10,7 @@
*/
var HighlighterWaiter = function(app) {
this.app = app;
this.mouse_button_down = false;
this.mouse_target = null;
};
@ -40,7 +40,7 @@ HighlighterWaiter.OUTPUT = 1;
HighlighterWaiter.prototype._is_selection_backwards = function() {
var backwards = false,
sel = window.getSelection();
if (!sel.isCollapsed) {
var range = document.createRange();
range.setStart(sel.anchorNode, sel.anchorOffset);
@ -63,12 +63,12 @@ HighlighterWaiter.prototype._is_selection_backwards = function() {
HighlighterWaiter.prototype._get_output_html_offset = function(node, offset) {
var sel = window.getSelection(),
range = document.createRange();
range.selectNodeContents(document.getElementById("output-html"));
range.setEnd(node, offset);
sel.removeAllRanges();
sel.addRange(range);
return sel.toString().length;
};
@ -87,7 +87,7 @@ HighlighterWaiter.prototype._get_output_html_selection_offsets = function() {
start = 0,
end = 0,
backwards = false;
if (sel.rangeCount) {
range = sel.getRangeAt(sel.rangeCount - 1);
backwards = this._is_selection_backwards();
@ -95,7 +95,7 @@ HighlighterWaiter.prototype._get_output_html_selection_offsets = function() {
end = this._get_output_html_offset(range.endContainer, range.endOffset);
sel.removeAllRanges();
sel.addRange(range);
if (backwards) {
// If selecting backwards, reverse the start and end offsets for the selection to
// prevent deselecting as the drag continues.
@ -103,7 +103,7 @@ HighlighterWaiter.prototype._get_output_html_selection_offsets = function() {
sel.extend(sel.anchorNode, range.startOffset);
}
}
return {
start: start,
end: end
@ -147,11 +147,11 @@ HighlighterWaiter.prototype.input_mousedown = function(e) {
this.mouse_button_down = true;
this.mouse_target = HighlighterWaiter.INPUT;
this.remove_highlights();
var el = e.target,
start = el.selectionStart,
end = el.selectionEnd;
if (start !== 0 || end !== 0) {
document.getElementById("input-selection-info").innerHTML = this.selection_info(start, end);
this.highlight_output([{start: start, end: end}]);
@ -169,11 +169,11 @@ HighlighterWaiter.prototype.output_mousedown = function(e) {
this.mouse_button_down = true;
this.mouse_target = HighlighterWaiter.OUTPUT;
this.remove_highlights();
var el = e.target,
start = el.selectionStart,
end = el.selectionEnd;
if (start !== 0 || end !== 0) {
document.getElementById("output-selection-info").innerHTML = this.selection_info(start, end);
this.highlight_input([{start: start, end: end}]);
@ -190,7 +190,7 @@ HighlighterWaiter.prototype.output_mousedown = function(e) {
HighlighterWaiter.prototype.output_html_mousedown = function(e) {
this.mouse_button_down = true;
this.mouse_target = HighlighterWaiter.OUTPUT;
var sel = this._get_output_html_selection_offsets();
if (sel.start !== 0 || sel.end !== 0) {
document.getElementById("output-selection-info").innerHTML = this.selection_info(sel.start, sel.end);
@ -237,10 +237,10 @@ 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,
start = el.selectionStart,
end = el.selectionEnd;
@ -261,14 +261,14 @@ 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,
start = el.selectionStart,
end = el.selectionEnd;
if (start !== 0 || end !== 0) {
document.getElementById("output-selection-info").innerHTML = this.selection_info(start, end);
this.highlight_input([{start: start, end: end}]);
@ -285,10 +285,10 @@ 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();
if (sel.start !== 0 || sel.end !== 0) {
document.getElementById("output-selection-info").innerHTML = this.selection_info(sel.start, sel.end);
@ -310,7 +310,7 @@ HighlighterWaiter.prototype.selection_info = function(start, end) {
var start_str = Utils.pad(start.toString(), width, " ").replace(/ /g, "&nbsp;"),
end_str = Utils.pad(end.toString(), width, " ").replace(/ /g, "&nbsp;"),
len_str = Utils.pad((end-start).toString(), width, " ").replace(/ /g, "&nbsp;");
return "start: " + start_str + "<br>end: " + end_str + "<br>length: " + len_str;
};
@ -327,7 +327,7 @@ HighlighterWaiter.prototype.remove_highlights = function() {
/**
* Generates a list of all the highlight functions assigned to operations in the recipe, if the
* Generates a list of all the highlight functions assigned to operations in the recipe, if the
* entire recipe supports highlighting.
*
* @returns {Object[]} highlights
@ -338,25 +338,25 @@ HighlighterWaiter.prototype.remove_highlights = function() {
HighlighterWaiter.prototype.generate_highlight_list = function() {
var recipe_config = this.app.get_recipe_config(),
highlights = [];
for (var i = 0; i < recipe_config.length; i++) {
if (recipe_config[i].disabled) continue;
// If any breakpoints are set, do not attempt to highlight
if (recipe_config[i].breakpoint) return false;
var op = this.app.operations[recipe_config[i].op];
// If any of the operations do not support highlighting, fail immediately.
if (op.highlight === false || op.highlight === undefined) return false;
highlights.push({
f: op.highlight,
b: op.highlight_reverse,
args: recipe_config[i].args
});
}
return highlights;
};
@ -382,12 +382,12 @@ HighlighterWaiter.prototype.highlight_output = function(pos) {
for (var i = 0; i < highlights.length; i++) {
// Remove multiple highlights before processing again
pos = [pos[0]];
if (typeof highlights[i].f == "function") {
pos = highlights[i].f(pos, highlights[i].args);
}
}
document.getElementById("output-selection-info").innerHTML = this.selection_info(pos[0].start, pos[0].end);
this.highlight(
document.getElementById("output-text"),
@ -409,7 +409,7 @@ HighlighterWaiter.prototype.highlight_output = function(pos) {
*/
HighlighterWaiter.prototype.highlight_input = function(pos) {
var highlights = this.generate_highlight_list();
if (!highlights || !this.app.auto_bake_) {
return false;
}
@ -417,12 +417,12 @@ HighlighterWaiter.prototype.highlight_input = function(pos) {
for (var i = 0; i < highlights.length; i++) {
// Remove multiple highlights before processing again
pos = [pos[0]];
if (typeof highlights[i].b == "function") {
pos = highlights[i].b(pos, highlights[i].args);
}
}
document.getElementById("input-selection-info").innerHTML = this.selection_info(pos[0].start, pos[0].end);
this.highlight(
document.getElementById("input-text"),
@ -444,21 +444,21 @@ HighlighterWaiter.prototype.highlight_input = function(pos) {
HighlighterWaiter.prototype.highlight = function(textarea, highlighter, pos) {
if (!this.app.options.show_highlighter) return false;
if (!this.app.options.attempt_highlight) return false;
// Check if there is a carriage return in the output dish as this will not
// be displayed by the HTML textarea and will mess up highlighting offsets.
if (!this.app.dish_str || this.app.dish_str.indexOf("\r") >= 0) return false;
var start_placeholder = "[start_highlight]",
start_placeholder_regex = /\[start_highlight\]/g,
end_placeholder = "[end_highlight]",
end_placeholder_regex = /\[end_highlight\]/g,
text = textarea.value;
// 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 +
@ -467,15 +467,15 @@ HighlighterWaiter.prototype.highlight = function(textarea, highlighter, pos) {
// O(n^2) - Can anyone improve this without overwriting placeholders?
var result = "",
end_placed = true;
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;
}
@ -485,10 +485,10 @@ HighlighterWaiter.prototype.highlight = function(textarea, highlighter, pos) {
if (!end_placed) result += end_placeholder;
text = result;
}
var css_class = "hl1";
//if (colour) css_class += "-"+colour;
// Remove HTML tags
text = text.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
@ -497,7 +497,7 @@ HighlighterWaiter.prototype.highlight = function(textarea, highlighter, pos) {
// Convert placeholders to tags
.replace(start_placeholder_regex, "<span class=\""+css_class+"\">")
.replace(end_placeholder_regex, "</span>") + "&nbsp;";
// Adjust width to allow for scrollbars
highlighter.style.width = textarea.clientWidth + "px";
highlighter.innerHTML = text;

View file

@ -21,12 +21,12 @@ var InputWaiter = function(app, manager) {
19, //Pause
20, //Caps
27, //Esc
33,34,35,36, //PgUp, PgDn, End, Home
37,38,39,40, //Directional
33, 34, 35, 36, //PgUp, PgDn, End, Home
37, 38, 39, 40, //Directional
44, //PrntScrn
91,92, //Win
91, 92, //Win
93, //Context
112,113,114,115,116,117,118,119,120,121,122,123, //F1-12
112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, //F1-12
144, //Num
145, //Scroll
];
@ -162,8 +162,8 @@ 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") {
recipe_config.unshift({op:"From Hex",args:["Space"]});
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");

View 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) {
@ -212,11 +212,11 @@ OperationsWaiter.prototype.edit_favourites_click = function(e) {
});
Sortable.utils.on(edit_favourites_list, "dragleave", function() {
this.remove_intent = true;
this.remove_intent = true;
}.bind(this));
Sortable.utils.on(edit_favourites_list, "dragover", function() {
this.remove_intent = false;
this.remove_intent = false;
}.bind(this));
$("#edit-favourites-list [data-toggle=popover]").popover();
@ -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");
}
};

View file

@ -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);
}

View file

@ -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,10 +359,11 @@ 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);
document.getElementById("rec_list").appendChild(item);
item.classList.add("operation");
item.innerHTML = name;
this.build_recipe_operation(item);
document.getElementById("rec_list").appendChild(item);
item.dispatchEvent(this.manager.operationadd);
return item;
@ -420,4 +420,4 @@ RecipeWaiter.prototype.op_add = function(e) {
*/
RecipeWaiter.prototype.op_remove = function(e) {
window.dispatchEvent(this.manager.statechange);
};
};

View file

@ -20,23 +20,23 @@ var SeasonalWaiter = function(app, manager) {
*/
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();
// }
// Konami code
this.kkeys = [];
window.addEventListener("keydown", this.konami_code_listener.bind(this));
@ -51,13 +51,13 @@ SeasonalWaiter.prototype.insert_spider_icons = function() {
var spider16 = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB3UlEQVQ4y2NgGJaAmYGBgVnf0oKJgYGBobWtXamqqoYTn2I4CI+LTzM2NTulpKbu+vPHz2dV5RWlluZmi3j5+KqFJSSEzpw8uQPdAEYYIzo5Kfjrl28rWFlZzjAzMYuEBQao3Lh+g+HGvbsMzExMDN++fWf4/PXLBzY2tqYNK1f2+4eHM2xcuRLigsT09Igf3384MTExbf767etBI319jU8fPsi+//jx/72HDxh5uLkZ7ty7y/Dz1687Avz8n2UUFR3Z2NjOySoqfmdhYGBg+PbtuwI7O8e5H79+8X379t357PnzYo+ePP7y6cuXc9++f69nYGRsvf/w4XdtLS2R799/bBUWFHr57sP7Jbs3b/ZkzswvUP3165fZ7z9//r988WIVAyPDr8tXr576+u3bpb9//7YwMjKeV1dV41NWVGoVEhDgPH761DJREeHaz1+/lqlpafUx6+jrRfz4+fPy+w8fTu/fsf3uw7t3L39+//4cv7DwGQYGhpdPbt9m4BcRFlNWVJC4fuvWASszs4C379792Ldt2xZBUdEdDP5hYSqQGIjDGa965uYKCalpZQwMDAxhMTG9DAwMDLaurhIkJY7A8IgGBgYGBgd3Dz2yUpeFo6O4rasrA9T24ZRxAAMTwMpgEJwLAAAAAElFTkSuQmCC",
spider32 = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAACYVBMVEUAAAAcJSU2Pz85QkM9RUWEhIWMjI2MkJEcJSU2Pz85QkM9RUWWlpc9RUVXXl4cJSU2Pz85QkM8REU9RUVRWFh6ens9RUVCSkpNVFRdY2McJSU5QkM7REQ9RUVGTk5KUlJQVldcY2Rla2uTk5WampscJSVUWltZX2BrcHF1e3scJSUjLCw9RUVASEhFTU1HTk9bYWJeZGRma2xudHV1eHiZmZocJSUyOjpJUFFQVldSWlpTWVpXXl5YXl5rb3B9fX6RkZIcJSUmLy8tNTU9RUVFTU1IT1BOVldRV1hTWlp0enocJSUfKChJUFBWXV1hZ2hnbGwcJSVETExLUlJLU1NNVVVPVlZYXl9cY2RiaGlobW5rcXFyd3h0eHgcJSUpMTFDS0tQV1dRV1hSWFlWXF1bYWJma2tobW5uc3SsrK0cJSVJUFBMVFROVlZVW1xZX2BdYmNhZ2hjaGhla2tqcHBscHE4Pz9KUlJRWVlSWVlXXF1aYGFbYWFfZWZlampqbW4cJSUgKSkiKysuNjY0PD01PT07QkNES0tHTk5JUFBMUlNMU1NOU1ROVVVPVVZRVlZRV1dSWVlWXFxXXV5aX2BbYWFbYWJcYmJcYmNcY2RdYmNgZmZhZmdkaWpkampkamtlamtla2tma2tma2xnbG1obW5pbG1pb3Bqb3Brb3BtcXJudHVvcHFvcXJvc3NwcXNwdXVxc3RzeXl1eXp2eXl3ent6e3x+gYKAhISBg4SKi4yLi4yWlpeampudnZ6fn6CkpaanqKiur6+vr7C4uLm6urq6u7u8vLy9vb3Av8DR0dL2b74UAAAAgHRSTlMAEBAQEBAQECAgICAgMDBAQEBAQEBAUFBQUGBgYGBgYGBgYGBgcHBwcHCAgICAgICAgICAgICPj4+Pj4+Pj4+Pj5+fn5+fn5+fn5+vr6+vr6+/v7+/v7+/v7+/v7+/z8/Pz8/Pz8/Pz8/P39/f39/f39/f39/f7+/v7+/v7+/v78x6RlYAAAGBSURBVDjLY2AYWUCSgUGAk4GBTdlUhQebvP7yjIgCPQbWzBMnjx5wwJSX37Rwfm1isqj9/iPHTuxYlyeMJi+yunfptBkZOw/uWj9h3vatcycu8eRGlldb3Vsts3ph/cFTh7fN3bCoe2Vf8+TZoQhTvBa6REozVC7cuPvQnmULJm1e2z+308eyJieEBSLPXbKQIUqQIczk+N6eNaumtnZMaWhaHM89m8XVCqJA02Y5w0xmga6yfVsamtrN4xoXNzS0JTHkK3CXy4EVFMumcxUy2LbENTVkZfEzMDAudtJyTmNwS2XQreAFyvOlK9louDNVaXurmjkGgnTMkWDgXswtNouFISEX6Awv+RihQi5OcYY4DtVARpCCFCMGhiJ1hjwFBpagEAaWEpFoC0WQOCOjFMRRwXYMDB4BDLJ+QLYsg7GBGjtasLnEMjCIrWBgyAZ7058FI9x1SoFEnTCDsCyIhynPILYYSFgbYpUDA5bpQBluXzxpI1yYAbd2sCMYRhwAAHB9ZPztbuMUAAAAAElFTkSuQmCC",
spider64 = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAJZUlEQVR42u1ZaXMU1xXlJ+gHpFITOy5sAcnIYCi2aIL2bTSSZrSP1NpHK41kISQBHgFaQIJBCMwi4TFUGYcPzggwEMcxHVGxQaag5QR/np/QP+Hmnsdr0hpmtEACwulb9aq7p7d3zz333Pt61q2zzTbbbLPNNttss80222yzzTbbVmu7MzKcJRWVkXjntqam6jyURPeGQqeTpqbOqp+evxC5dGlam5m5rE3PzGi8Hzx/4aLzbXDe09HdYxwZHaPc4mLFXVoW9pRXGNv3pDngeHlNLfE2Ljjj4xPOUGjSYKfpq6/+TLdv36bbX39Nt27epGvXvqSLl6bp3LlPtdOnz7jWrPNZ7kLCKCovp5bOTmP/4EHq6vmYMtzuSKbbbQCAHE8Rxd47MjrmuHjxkjF3/z4tLCzQkyc6PX78mB49ekQPHjygub/P0d27f6FrX/6JpqbO0YkT48E1R/sCr9cYHZ+gqrp64mPq+riXcoqKKC0vP9q6VyV/fQOiH+LrsPVY7z82PBKZnb1Bd+7cpfn5eQbgCT1hAADC/MN5uj83R99881eanZ2lL5gN/nrxjihAXwvOJ7l9vuiBQ4dF9LEtLC0V+2rv/ijTX6luaCS3rxT57wADAMTBQ4c9PIIDg4PBwYOHaHhklM5MnSWkwLff/o0+v3qVHv34Iz344QEDc4d8VVXUEAhQXXMzVdQqzKweKq6oABARzOGNOZ+Wl6fD6T25ubQrPT0E5xF93o82tbdjkkZ+iZfAAgbD6fZ6o339A8S0p7HjJ2h4eIQOHf6EujlV9nX3UOj0JDXzfXje+KlTdOPGDeF0T1+fGHg+2JSen08tHZ0CiPySEoPn8vq1IaOgIAzneQK0UzjcQd6qaqrlCVfV1+tpubnRnv5+2p2ZqYMF/oZGPTh0xLhy5Sr9wLn9j++/p5nLn9FxBoLZQJ1dKrkys6iYNeTExEnx3PqWFuF4W9deKq2upkEGCyzyMBC709MFC7r391Fjayv9MSdHZyCU1xJ5FjrNdN6VnU1KS4CjU4Yoh/m8CsezCguFJgAMV05ueP+BfhF5OL+gL9A/f/qJ7t3TaPLMFB09eoy6mTkMGg2PjTELOsS20OcTACgMKqJugqA0NtE7ycn0202b6A+ZmYIVAAKApGZlgRHB/0lqQPAqFEVE9hntM0R0ZblTzeswWdCeU8HAtYW+Uu0AUx+0f/jwoXD+56c/073v7tHU2XMiFbrUfVTNAtfL10FIAQL2QftsBrOEnavld5kg7E7PoF+99x79ev162rJrV9RMi6a2dvKUlQsR5uAgII7/ivMsbEE4g2hggjzC7LQL1OftovoO0WJKUn0gYEAn2hmMXo4QHIXQIfLfsfOXPwuLvB86cpQqamooyEzg1BLMwv04RkoE+B3B4BBBMHEcCwIP0N+ByJdUVhpgBJ7j4WvdANDjeTUglOaWEChfJF7uJzPX2HEPaj1vg7EAbHO5QnAeIPgqKvUB7gtAdbBgcvKMqOnc/NAIVwCcq21qElFnCgvaI9cBBFKhlSPbPzBIbbzduGULpWzfLkDAdZs++sgEwSlZqoIJMg2CzFSNGzODwdBfOi26+w4YTCm9LhDQwQDzdzguFf4FALjciTws8/u1yyx2N2/dovPnL9DRY8PkZ204xtuhoSM0wI7V8DEiirQCCHD+99u2CUdx3Lmvmz7kfemoGDgPEDr4HNKAf1MlAC4wgMGLWFJXQUrklZSEX6rLE2rOyDIQGlhgBUAyYFEZkm2vAGVi4qQ+x83M0389pevXr6OToy07d4qcR+krr/KzqpeJ/IfjGO+npDx3FCKHVPjd1q2LAMBI3ryZ9vL7U56BEzLfD80ACFba876OlGCQV9dAcT0Pyw7PgWij6zPP5Xt9EYgg+n3LosdVzdfz5CI8KY1LH31+5Yro9KanZwjHmPzmHTsoOeVDemfDBuE8dGVnWpqx3unUrE4CDLCAG64XAHB88IFgQV5xMY7DFmc16A6CZvnNBYYVcW+yKj0A/VHTsQ8dwMPNc6X+Gg0VIGbVpzYGWundjRujmGQWi9Eol7+TJ0/R2Nhx2sNlM9YJRPDdDRsM5DGPJB4KHOIhngHhAwixAGAAuDZ2lsuiYnFWBQOYrdEYNochilyiV6YHoH+rRNJkAG+fUw31PzU7Z1EFKPD69CIuQ1Bm6URoh8tFmVym3nc6rZOPyi0cD8HxeHPg3x2InNrbS79JTsYzNXmPuBclsO3ZvKwAOJEGsmI5rT0M+gSf3y9K5LIA1LUEIlL1k0AhCYBH5r9TCqBqib4D+c/1PyInGOThkvuaHCYALhlpbQWBMGR/4IpzTqlpbKQyf0045vdoe0zATHagSYMeWFMkbscnHRYPZjoFJaIiUkz9EJy15j/X3qCsAIqMcFjSWrNE1Iygg0fEmrtLzEUTdT/OhBFht9fHDVCbEUt3LJxi08B8Xj6vTDESriq9lVWqBECgHujqiqAUmufb1X3cfRXoluhjZWiwkOnSUcUS6ZD8LUmmhks6b5j1ezkAkAKZBe5QvPPcNBnoCawMwT66Qxk0R2xwwRAui2iSDGuaPDcubzo3EJq8wcx/9Vmk3QryH42QBQCFF0UagIiJtjX6DskIXTLEucJSHIIIMuO0BOcjn3A3ybU/lu5RCUBc5qA0Ih0Q2EWiCPRk7VfMNhjLW1zETic1tLYZDMKyuSsdfh5l6bwho5+0il4kyA0VohlNcF5FP8DlWo/VB16HYB2hJ0pzgIe2mcXxP2IOumPRY17U0tll8KIkZNb+sppafOxYkQPSaYfchyYoL9GMqWYpTLRIq1QUcT4O3aPQgqVqPwIOIMwDhzX6mQUFIQAgo+9MzcrWrML3mj6+YIKiFCZyhL87RqVQKrEskF+P1BUvfLCAkfRwoPUtq6l5o5+lZb5SolJo6oT8avTCl+c9OTmat6pKW8mLkvBpGzlvsiGuQr4ZEEwA1EQgoR/gNtxIxKBluz+OtMJiF31jHxqXBiAqAUj4WRxpADFM0DCFlv1khvX7Wol4vF4AIldVVxdZqlrIfiCYQPHDy6bAGv7nKYRVY6JewExZVAP+ey5Rv+Ba97aaUHMW5NauLmMZFkegBb/EP14d6NoS9QLWFSzWBmuZza8CQmSpXsAqmGtVy14VALWuuYWWy+W3OteXa4jwceQX6+BKG6J1/8+2VCNkm2222WabbbbZZpttttlmm22rt38DCdA0vq3bcAkAAAAASUVORK5CYII=";
// Favicon
document.querySelector("link[rel=icon]").setAttribute("href", "data:image/png;base64," + spider16);
// Bake button
document.querySelector("#bake img").setAttribute("src", "data:image/png;base64," + spider32);
// About box
document.querySelector(".about-img-left").setAttribute("src", "data:image/png;base64," + spider64);
};
@ -70,23 +70,23 @@ SeasonalWaiter.prototype.insert_spider_icons = function() {
SeasonalWaiter.prototype.insert_spider_text = function() {
// Title
document.title = document.title.replace(/Cyber/g, "Spider");
// 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);
// 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);
// Recipe title
document.querySelector("#recipe .title").innerHTML = "Web";
};
@ -99,13 +99,13 @@ SeasonalWaiter.prototype.insert_spider_text = function() {
SeasonalWaiter.prototype.create_snow_option = function() {
var options_body = document.getElementById("options-body"),
option_item = document.createElement("div");
option_item.className = "option-item";
option_item.innerHTML =
option_item.innerHTML =
"<input type='checkbox' option='snow' checked />\
Let it snow";
options_body.appendChild(option_item);
this.manager.options.load();
};
@ -117,44 +117,44 @@ SeasonalWaiter.prototype.create_snow_option = function() {
SeasonalWaiter.prototype.let_it_snow = function() {
$(document).snowfall("clear");
if (!this.app.options.snow) return;
var options = {},
firefox_version = navigator.userAgent.match(/Firefox\/(\d\d?)/);
if (firefox_version && parseInt(firefox_version[1], 10) < 30) {
// Firefox < 30
options = {
flakeCount : 10,
flakeColor : '#fff',
flakePosition: 'absolute',
minSize : 1,
maxSize : 2,
minSpeed : 1,
maxSpeed : 5,
round : false,
shadow : false,
collection : false,
collectionHeight : 20,
deviceorientation : true
flakeCount: 10,
flakeColor: "#fff",
flakePosition: "absolute",
minSize: 1,
maxSize: 2,
minSpeed: 1,
maxSpeed: 5,
round: false,
shadow: false,
collection: false,
collectionHeight: 20,
deviceorientation: true
};
} else {
// All other browsers
options = {
flakeCount : 35, //35
flakeColor : '#fff',
flakePosition: 'absolute',
minSize : 5,
maxSize : 8,
minSpeed : 1,
maxSpeed : 5,
round : true,
shadow : true,
collection : ".btn",
collectionHeight : 20,
deviceorientation : true
flakeCount: 35,
flakeColor: "#fff",
flakePosition: "absolute",
minSize: 5,
maxSize: 8,
minSpeed: 1,
maxSpeed: 5,
round: true,
shadow: true,
collection: ".btn",
collectionHeight: 20,
deviceorientation: true
};
}
$(document).snowfall(options);
};
@ -172,12 +172,12 @@ SeasonalWaiter.prototype.shake_off_snow = function(e) {
ctx.clearRect(0, 0, canvas.width, canvas.height);
$(this).fadeIn();
};
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);
break;
}
@ -192,13 +192,13 @@ SeasonalWaiter.prototype.shake_off_snow = function(e) {
*/
SeasonalWaiter.prototype.konami_code_listener = function(e) {
this.kkeys.push(e.keyCode);
var konami = [38,38,40,40,37,39,37,39,66,65];
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 = [];
}
@ -217,14 +217,14 @@ SeasonalWaiter.prototype.konami_code_listener = function(e) {
SeasonalWaiter.tree_walk = (function() {
// Create closure for constants
var skipTags = {
"SCRIPT": true, "IFRAME": true, "OBJECT": true,
"SCRIPT": true, "IFRAME": true, "OBJECT": true,
"EMBED": true, "STYLE": true, "LINK": true, "META": true
};
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;

View file

@ -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