mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
Merge remote-tracking branch 'upstream/master' into feature_xpath
# Conflicts: # Gruntfile.js # src/js/.jshintrc
This commit is contained in:
commit
4c36123fd7
52 changed files with 1938 additions and 1692 deletions
60
Gruntfile.js
60
Gruntfile.js
|
@ -1,21 +1,23 @@
|
||||||
|
/* eslint-env node */
|
||||||
|
|
||||||
module.exports = function(grunt) {
|
module.exports = function(grunt) {
|
||||||
grunt.file.defaultEncoding = "utf8";
|
grunt.file.defaultEncoding = "utf8";
|
||||||
grunt.file.preserveBOM = false;
|
grunt.file.preserveBOM = false;
|
||||||
|
|
||||||
// Tasks
|
// Tasks
|
||||||
grunt.registerTask("dev",
|
grunt.registerTask("dev",
|
||||||
"A persistent task which creates a development build whenever source files are modified.",
|
"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"]);
|
["clean:dev", "concat:css", "concat:js", "copy:html_dev", "copy:static_dev", "chmod:build", "watch"]);
|
||||||
|
|
||||||
grunt.registerTask("prod",
|
grunt.registerTask("prod",
|
||||||
"Creates a production-ready build. Use the --msg flag to add a compile message.",
|
"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"]);
|
"copy:static_dev", "copy:static_prod", "cssmin", "uglify:prod", "inline", "htmlmin", "chmod"]);
|
||||||
|
|
||||||
grunt.registerTask("docs",
|
grunt.registerTask("docs",
|
||||||
"Compiles documentation in the /docs directory.",
|
"Compiles documentation in the /docs directory.",
|
||||||
["clean:docs", "jsdoc", "chmod:docs"]);
|
["clean:docs", "jsdoc", "chmod:docs"]);
|
||||||
|
|
||||||
grunt.registerTask("stats",
|
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.",
|
"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"]);
|
["concat:js", "uglify:prod", "exec:stats", "exec:repo_size", "exec:display_stats"]);
|
||||||
|
@ -23,17 +25,17 @@ module.exports = function(grunt) {
|
||||||
grunt.registerTask("release",
|
grunt.registerTask("release",
|
||||||
"Prepares and deploys a production version of CyberChef to the gh-pages branch.",
|
"Prepares and deploys a production version of CyberChef to the gh-pages branch.",
|
||||||
["copy:gh_pages", "exec:deploy_gh_pages"]);
|
["copy:gh_pages", "exec:deploy_gh_pages"]);
|
||||||
|
|
||||||
grunt.registerTask("default",
|
grunt.registerTask("default",
|
||||||
"Lints the code base and shows stats",
|
"Lints the code base and shows stats",
|
||||||
["jshint", "exec:stats", "exec:display_stats"]);
|
["jshint", "exec:stats", "exec:display_stats"]);
|
||||||
|
|
||||||
grunt.registerTask("doc", "docs");
|
grunt.registerTask("doc", "docs");
|
||||||
grunt.registerTask("lint", "jshint");
|
grunt.registerTask("lint", "eslint");
|
||||||
|
|
||||||
|
|
||||||
// Load tasks provided by each plugin
|
// Load tasks provided by each plugin
|
||||||
grunt.loadNpmTasks("grunt-contrib-jshint");
|
grunt.loadNpmTasks("grunt-eslint");
|
||||||
grunt.loadNpmTasks("grunt-jsdoc");
|
grunt.loadNpmTasks("grunt-jsdoc");
|
||||||
grunt.loadNpmTasks("grunt-contrib-clean");
|
grunt.loadNpmTasks("grunt-contrib-clean");
|
||||||
grunt.loadNpmTasks("grunt-contrib-concat");
|
grunt.loadNpmTasks("grunt-contrib-concat");
|
||||||
|
@ -45,8 +47,8 @@ module.exports = function(grunt) {
|
||||||
grunt.loadNpmTasks("grunt-chmod");
|
grunt.loadNpmTasks("grunt-chmod");
|
||||||
grunt.loadNpmTasks("grunt-exec");
|
grunt.loadNpmTasks("grunt-exec");
|
||||||
grunt.loadNpmTasks("grunt-contrib-watch");
|
grunt.loadNpmTasks("grunt-contrib-watch");
|
||||||
|
|
||||||
|
|
||||||
// JS includes
|
// JS includes
|
||||||
var js_files = [
|
var js_files = [
|
||||||
// Third party framework libraries
|
// Third party framework libraries
|
||||||
|
@ -56,7 +58,7 @@ module.exports = function(grunt) {
|
||||||
"src/js/lib/bootstrap-switch.js",
|
"src/js/lib/bootstrap-switch.js",
|
||||||
"src/js/lib/yahoo.js",
|
"src/js/lib/yahoo.js",
|
||||||
"src/js/lib/snowfall.jquery.js",
|
"src/js/lib/snowfall.jquery.js",
|
||||||
|
|
||||||
// Third party operation libraries
|
// Third party operation libraries
|
||||||
"src/js/lib/cryptojs/core.js",
|
"src/js/lib/cryptojs/core.js",
|
||||||
"src/js/lib/cryptojs/x64-core.js",
|
"src/js/lib/cryptojs/x64-core.js",
|
||||||
|
@ -132,22 +134,22 @@ module.exports = function(grunt) {
|
||||||
|
|
||||||
// Custom libraries
|
// Custom libraries
|
||||||
"src/js/lib/canvas_components.js",
|
"src/js/lib/canvas_components.js",
|
||||||
|
|
||||||
// Utility functions
|
// Utility functions
|
||||||
"src/js/core/Utils.js",
|
"src/js/core/Utils.js",
|
||||||
|
|
||||||
// Operation objects
|
// Operation objects
|
||||||
"src/js/operations/*.js",
|
"src/js/operations/*.js",
|
||||||
|
|
||||||
// Core framework objects
|
// Core framework objects
|
||||||
"src/js/core/*.js",
|
"src/js/core/*.js",
|
||||||
"src/js/config/Categories.js",
|
"src/js/config/Categories.js",
|
||||||
"src/js/config/OperationConfig.js",
|
"src/js/config/OperationConfig.js",
|
||||||
|
|
||||||
// HTML view objects
|
// HTML view objects
|
||||||
"src/js/views/html/*.js",
|
"src/js/views/html/*.js",
|
||||||
"!src/js/views/html/main.js",
|
"!src/js/views/html/main.js",
|
||||||
|
|
||||||
// Start the app!
|
// Start the app!
|
||||||
"src/js/views/html/main.js",
|
"src/js/views/html/main.js",
|
||||||
];
|
];
|
||||||
|
@ -179,12 +181,12 @@ module.exports = function(grunt) {
|
||||||
codebase_stats: grunt.file.read("src/static/stats.txt").split("\n").join("<br>")
|
codebase_stats: grunt.file.read("src/static/stats.txt").split("\n").join("<br>")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Project configuration
|
// Project configuration
|
||||||
grunt.initConfig({
|
grunt.initConfig({
|
||||||
jshint: {
|
eslint: {
|
||||||
options: {
|
options: {
|
||||||
jshintrc: "src/js/.jshintrc"
|
configFile: "src/js/.eslintrc.json"
|
||||||
},
|
},
|
||||||
gruntfile: ["Gruntfile.js"],
|
gruntfile: ["Gruntfile.js"],
|
||||||
core: ["src/js/core/**/*.js"],
|
core: ["src/js/core/**/*.js"],
|
||||||
|
@ -265,7 +267,7 @@ module.exports = function(grunt) {
|
||||||
// TODO: Do all this in Jade
|
// TODO: Do all this in Jade
|
||||||
content = content.replace(
|
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>',
|
'<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);
|
return grunt.template.process(content, template_options);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -404,13 +406,13 @@ module.exports = function(grunt) {
|
||||||
exec: {
|
exec: {
|
||||||
repo_size: {
|
repo_size: {
|
||||||
command: [
|
command: [
|
||||||
"git ls-files | wc -l | xargs printf '\n%b\ttracked files\n'",
|
"git ls-files | wc -l | xargs printf '\n%b\ttracked files\n'",
|
||||||
"du -hs | egrep -o '^[^\t]*' | xargs printf '%b\trepository size\n'"
|
"du -hs | egrep -o '^[^\t]*' | xargs printf '%b\trepository size\n'"
|
||||||
].join(";"),
|
].join(";"),
|
||||||
stderr: false
|
stderr: false
|
||||||
},
|
},
|
||||||
stats: {
|
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'",
|
"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'",
|
"find src/ -regex '.*\..*' -print | xargs cat | wc -l | xargs printf '%b\tlines\n'",
|
||||||
|
@ -430,10 +432,10 @@ module.exports = function(grunt) {
|
||||||
|
|
||||||
"du build/dev/scripts.js -h | egrep -o '^[^\t]*' | xargs printf '\n%b\tuncompressed JavaScript size\n'",
|
"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'",
|
"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+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'",
|
"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;",
|
].join(" >> src/static/stats.txt;") + " >> src/static/stats.txt;",
|
||||||
stderr: false
|
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
File diff suppressed because one or more lines are too long
2
package.json
Executable file → Normal file
2
package.json
Executable file → Normal file
|
@ -36,9 +36,9 @@
|
||||||
"grunt-contrib-copy": "~0.8.2",
|
"grunt-contrib-copy": "~0.8.2",
|
||||||
"grunt-contrib-cssmin": "~0.14.0",
|
"grunt-contrib-cssmin": "~0.14.0",
|
||||||
"grunt-contrib-htmlmin": "~0.6.0",
|
"grunt-contrib-htmlmin": "~0.6.0",
|
||||||
"grunt-contrib-jshint": "~1.0.0",
|
|
||||||
"grunt-contrib-uglify": "~0.11.1",
|
"grunt-contrib-uglify": "~0.11.1",
|
||||||
"grunt-contrib-watch": "~0.6.1",
|
"grunt-contrib-watch": "~0.6.1",
|
||||||
|
"grunt-eslint": "^19.0.0",
|
||||||
"grunt-exec": "~0.4.6",
|
"grunt-exec": "~0.4.6",
|
||||||
"grunt-inline-alt": "~0.3.10",
|
"grunt-inline-alt": "~0.3.10",
|
||||||
"grunt-jsdoc": "^1.1.0",
|
"grunt-jsdoc": "^1.1.0",
|
||||||
|
|
|
@ -176,6 +176,12 @@ textarea.arg {
|
||||||
border-color: #b3dba2 !important;
|
border-color: #b3dba2 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.flow-control-op.break {
|
||||||
|
color: #94312f !important;
|
||||||
|
background-color: #eabfbf !important;
|
||||||
|
border-color: #e2aeb5 !important;
|
||||||
|
}
|
||||||
|
|
||||||
#support-modal textarea {
|
#support-modal textarea {
|
||||||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
93
src/js/.eslintrc.json
Executable file
93
src/js/.eslintrc.json
Executable file
|
@ -0,0 +1,93 @@
|
||||||
|
{
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 6,
|
||||||
|
"ecmaFeatures": {
|
||||||
|
"impliedStrict": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"jquery": true,
|
||||||
|
"es6": true,
|
||||||
|
"node": false
|
||||||
|
},
|
||||||
|
"extends": "eslint:recommended",
|
||||||
|
"rules": {
|
||||||
|
// enable additional rules
|
||||||
|
"no-eval": "error",
|
||||||
|
"no-implied-eval": "error",
|
||||||
|
"dot-notation": "error",
|
||||||
|
"eqeqeq": ["error", "smart"],
|
||||||
|
"no-caller": "error",
|
||||||
|
"no-extra-bind": "error",
|
||||||
|
"no-unused-expressions": "error",
|
||||||
|
"no-useless-call": "error",
|
||||||
|
"no-useless-return": "error",
|
||||||
|
"radix": "warn",
|
||||||
|
|
||||||
|
// modify rules from base configurations
|
||||||
|
"no-unused-vars": ["error", {
|
||||||
|
"args": "none",
|
||||||
|
"vars": "local"
|
||||||
|
}],
|
||||||
|
"no-empty": ["error", {
|
||||||
|
"allowEmptyCatch": true
|
||||||
|
}],
|
||||||
|
|
||||||
|
// disable rules from base configurations
|
||||||
|
"no-console": "off",
|
||||||
|
"no-control-regex": "off",
|
||||||
|
|
||||||
|
// stylistic conventions
|
||||||
|
"brace-style": ["error", "1tbs"],
|
||||||
|
"block-spacing": "error",
|
||||||
|
"array-bracket-spacing": "error",
|
||||||
|
"comma-spacing": "error",
|
||||||
|
"comma-style": "error",
|
||||||
|
"computed-property-spacing": "error",
|
||||||
|
"no-trailing-spaces": ["warn", {
|
||||||
|
"skipBlankLines": true
|
||||||
|
}],
|
||||||
|
"eol-last": "error",
|
||||||
|
"func-call-spacing": "error",
|
||||||
|
"indent": ["error", 4, {
|
||||||
|
"ArrayExpression": "first",
|
||||||
|
"SwitchCase": 1
|
||||||
|
}],
|
||||||
|
"linebreak-style": ["error", "unix"],
|
||||||
|
"quotes": ["error", "double", {
|
||||||
|
"avoidEscape": true
|
||||||
|
}],
|
||||||
|
"semi": ["error", "always"],
|
||||||
|
"unicode-bom": "error"
|
||||||
|
},
|
||||||
|
"globals": {
|
||||||
|
/* core/* */
|
||||||
|
"Chef": false,
|
||||||
|
"Dish": false,
|
||||||
|
"Recipe": false,
|
||||||
|
"Ingredient": false,
|
||||||
|
"Operation": false,
|
||||||
|
"Utils": false,
|
||||||
|
|
||||||
|
/* config/* */
|
||||||
|
"Categories": false,
|
||||||
|
"OperationConfig": false,
|
||||||
|
|
||||||
|
/* views/html/* */
|
||||||
|
"HTMLApp": false,
|
||||||
|
"HTMLCategory": false,
|
||||||
|
"HTMLOperation": false,
|
||||||
|
"HTMLIngredient": false,
|
||||||
|
"Manager": false,
|
||||||
|
"ControlsWaiter": false,
|
||||||
|
"HighlighterWaiter": false,
|
||||||
|
"InputWaiter": false,
|
||||||
|
"OperationsWaiter": false,
|
||||||
|
"OptionsWaiter": false,
|
||||||
|
"OutputWaiter": false,
|
||||||
|
"RecipeWaiter": false,
|
||||||
|
"SeasonalWaiter": false,
|
||||||
|
"WindowWaiter": false
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,39 +0,0 @@
|
||||||
{
|
|
||||||
"esversion": 6,
|
|
||||||
"strict": "implied",
|
|
||||||
"multistr": true,
|
|
||||||
"browser": true,
|
|
||||||
"typed": true,
|
|
||||||
"jquery": true,
|
|
||||||
"node": true,
|
|
||||||
"undef": true,
|
|
||||||
"globals": {
|
|
||||||
/* core/* */
|
|
||||||
"Chef": true,
|
|
||||||
"Dish": true,
|
|
||||||
"Recipe": true,
|
|
||||||
"Ingredient": true,
|
|
||||||
"Operation": true,
|
|
||||||
"Utils": true,
|
|
||||||
|
|
||||||
/* config/* */
|
|
||||||
"Categories": true,
|
|
||||||
"OperationConfig": true,
|
|
||||||
|
|
||||||
/* views/html/* */
|
|
||||||
"HTMLApp": true,
|
|
||||||
"HTMLCategory": true,
|
|
||||||
"HTMLOperation": true,
|
|
||||||
"HTMLIngredient": true,
|
|
||||||
"Manager": true,
|
|
||||||
"ControlsWaiter": true,
|
|
||||||
"HighlighterWaiter": true,
|
|
||||||
"InputWaiter": true,
|
|
||||||
"OperationsWaiter": true,
|
|
||||||
"OptionsWaiter": true,
|
|
||||||
"OutputWaiter": true,
|
|
||||||
"RecipeWaiter": true,
|
|
||||||
"SeasonalWaiter": true,
|
|
||||||
"WindowWaiter": true
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -17,7 +17,7 @@
|
||||||
* @constant
|
* @constant
|
||||||
* @type {CatConf[]}
|
* @type {CatConf[]}
|
||||||
*/
|
*/
|
||||||
var Categories = [
|
const Categories = [
|
||||||
{
|
{
|
||||||
name: "Favourites",
|
name: "Favourites",
|
||||||
ops: []
|
ops: []
|
||||||
|
@ -77,8 +77,11 @@ var Categories = [
|
||||||
"RC4",
|
"RC4",
|
||||||
"RC4 Drop",
|
"RC4 Drop",
|
||||||
"ROT13",
|
"ROT13",
|
||||||
|
"ROT47",
|
||||||
"XOR",
|
"XOR",
|
||||||
"XOR Brute Force",
|
"XOR Brute Force",
|
||||||
|
"Vigenère Encode",
|
||||||
|
"Vigenère Decode",
|
||||||
"Derive PBKDF2 key",
|
"Derive PBKDF2 key",
|
||||||
"Derive EVP key",
|
"Derive EVP key",
|
||||||
]
|
]
|
||||||
|
|
|
@ -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.
|
* single operation object by definition.
|
||||||
*/
|
*/
|
||||||
/* jshint -W117 */
|
/* eslint no-undef: "off" */
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
* @constant
|
* @constant
|
||||||
* @type {Object.<string, OpConf>}
|
* @type {Object.<string, OpConf>}
|
||||||
*/
|
*/
|
||||||
var OperationConfig = {
|
const OperationConfig = {
|
||||||
"Fork": {
|
"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.",
|
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,
|
run: FlowControl.run_fork,
|
||||||
|
@ -1325,6 +1325,36 @@ var OperationConfig = {
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"Vigenère Encode": {
|
||||||
|
description: "The Vigenere cipher is a method of encrypting alphabetic text by using a series of different Caesar ciphers based on the letters of a keyword. It is a simple form of polyalphabetic substitution.",
|
||||||
|
run: Cipher.run_vigenere_enc,
|
||||||
|
highlight: true,
|
||||||
|
highlight_reverse: true,
|
||||||
|
input_type: "string",
|
||||||
|
output_type: "string",
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
name: "Key",
|
||||||
|
type: "string",
|
||||||
|
value: ""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Vigenère Decode": {
|
||||||
|
description: "The Vigenere cipher is a method of encrypting alphabetic text by using a series of different Caesar ciphers based on the letters of a keyword. It is a simple form of polyalphabetic substitution.",
|
||||||
|
run: Cipher.run_vigenere_dec,
|
||||||
|
highlight: true,
|
||||||
|
highlight_reverse: true,
|
||||||
|
input_type: "string",
|
||||||
|
output_type: "string",
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
name: "Key",
|
||||||
|
type: "string",
|
||||||
|
value: ""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"Rotate right": {
|
"Rotate right": {
|
||||||
description: "Rotates each byte to the right by the number of bits specified. Currently only supports 8-bit values.",
|
description: "Rotates each byte to the right by the number of bits specified. Currently only supports 8-bit values.",
|
||||||
run: Rotate.run_rotr,
|
run: Rotate.run_rotr,
|
||||||
|
@ -1390,6 +1420,21 @@ var OperationConfig = {
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"ROT47": {
|
||||||
|
description: "A slightly more complex variation of a caesar cipher, which includes ASCII characters from 33 '!' to 126 '~'. Default rotation: 47.",
|
||||||
|
run: Rotate.run_rot47,
|
||||||
|
highlight: true,
|
||||||
|
highlight_reverse: true,
|
||||||
|
input_type: "byte_array",
|
||||||
|
output_type: "byte_array",
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
name: "Amount",
|
||||||
|
type: "number",
|
||||||
|
value: Rotate.ROT47_AMOUNT
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
"Strip HTTP headers": {
|
"Strip HTTP headers": {
|
||||||
description: "Removes HTTP headers from a request or response by looking for the first instance of a double newline.",
|
description: "Removes HTTP headers from a request or response by looking for the first instance of a double newline.",
|
||||||
run: HTTP.run_strip_headers,
|
run: HTTP.run_strip_headers,
|
||||||
|
@ -2819,4 +2864,4 @@ var OperationConfig = {
|
||||||
output_type: "string",
|
output_type: "string",
|
||||||
args: []
|
args: []
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,33 +35,33 @@ Chef.prototype.bake = function(input_text, recipe_config, options, progress, ste
|
||||||
recipe = new Recipe(recipe_config),
|
recipe = new Recipe(recipe_config),
|
||||||
contains_fc = recipe.contains_flow_control(),
|
contains_fc = recipe.contains_flow_control(),
|
||||||
error = false;
|
error = false;
|
||||||
|
|
||||||
// Reset attempt_highlight flag
|
// Reset attempt_highlight flag
|
||||||
if (options.hasOwnProperty("attempt_highlight")) {
|
if (options.hasOwnProperty("attempt_highlight")) {
|
||||||
options.attempt_highlight = true;
|
options.attempt_highlight = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contains_fc) options.attempt_highlight = false;
|
if (contains_fc) options.attempt_highlight = false;
|
||||||
|
|
||||||
// Clean up progress
|
// Clean up progress
|
||||||
if (progress >= recipe_config.length) {
|
if (progress >= recipe_config.length) {
|
||||||
progress = 0;
|
progress = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (step) {
|
if (step) {
|
||||||
// Unset breakpoint on this step
|
// Unset breakpoint on this step
|
||||||
recipe.set_breakpoint(progress, false);
|
recipe.set_breakpoint(progress, false);
|
||||||
// Set breakpoint on next step
|
// Set breakpoint on next step
|
||||||
recipe.set_breakpoint(progress + 1, true);
|
recipe.set_breakpoint(progress + 1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If stepping with flow control, we have to start from the beginning
|
// If stepping with flow control, we have to start from the beginning
|
||||||
// but still want to skip all previous breakpoints
|
// but still want to skip all previous breakpoints
|
||||||
if (progress > 0 && contains_fc) {
|
if (progress > 0 && contains_fc) {
|
||||||
recipe.remove_breaks_up_to(progress);
|
recipe.remove_breaks_up_to(progress);
|
||||||
progress = 0;
|
progress = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If starting from scratch, load data
|
// If starting from scratch, load data
|
||||||
if (progress === 0) {
|
if (progress === 0) {
|
||||||
this.dish.set(input_text, Dish.STRING);
|
this.dish.set(input_text, Dish.STRING);
|
||||||
|
@ -70,22 +70,22 @@ Chef.prototype.bake = function(input_text, recipe_config, options, progress, ste
|
||||||
try {
|
try {
|
||||||
progress = recipe.execute(this.dish, progress);
|
progress = recipe.execute(this.dish, progress);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// We can't throw the error from here as we will return in the finally block and ignore it
|
// Return the error in the result so that everything else gets correctly updated
|
||||||
// so we return the error in the result instead.
|
// rather than throwing it here and losing state info.
|
||||||
error = err;
|
error = err;
|
||||||
progress = err.progress;
|
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
|
* 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
|
* 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.
|
* 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
|
* 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.
|
* long time and the browser has swapped out all its memory.
|
||||||
*
|
*
|
||||||
* The output will not be modified (hence "silent" bake).
|
* 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
|
* This will only actually execute the recipe if auto-bake is enabled, otherwise it will just load
|
||||||
* the recipe, ingredients and dish.
|
* the recipe, ingredients and dish.
|
||||||
*
|
*
|
||||||
|
@ -110,7 +110,7 @@ Chef.prototype.silent_bake = function(recipe_config) {
|
||||||
var start_time = new Date().getTime(),
|
var start_time = new Date().getTime(),
|
||||||
recipe = new Recipe(recipe_config),
|
recipe = new Recipe(recipe_config),
|
||||||
dish = new Dish("", Dish.STRING);
|
dish = new Dish("", Dish.STRING);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
recipe.execute(dish);
|
recipe.execute(dish);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
|
|
|
@ -115,7 +115,7 @@ Dish.prototype.set = function(value, type) {
|
||||||
* @returns {byte_array|string|number} The value of the output data.
|
* @returns {byte_array|string|number} The value of the output data.
|
||||||
*/
|
*/
|
||||||
Dish.prototype.get = function(type) {
|
Dish.prototype.get = function(type) {
|
||||||
if (this.type != type) {
|
if (this.type !== type) {
|
||||||
this.translate(type);
|
this.translate(type);
|
||||||
}
|
}
|
||||||
return this.value;
|
return this.value;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*
|
*
|
||||||
* @namespace
|
* @namespace
|
||||||
*/
|
*/
|
||||||
var FlowControl = {
|
const FlowControl = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
|
@ -46,7 +46,7 @@ var FlowControl = {
|
||||||
// Create sub_op_list for each tranche to operate on
|
// Create sub_op_list for each tranche to operate on
|
||||||
// (all remaining operations unless we encounter a Merge)
|
// (all remaining operations unless we encounter a Merge)
|
||||||
for (var i = state.progress + 1; i < op_list.length; i++) {
|
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;
|
break;
|
||||||
} else {
|
} else {
|
||||||
sub_op_list.push(op_list[i]);
|
sub_op_list.push(op_list[i]);
|
||||||
|
|
|
@ -67,12 +67,11 @@ Ingredient.prepare = function(data, type) {
|
||||||
return Utils.parse_escaped_chars(data);
|
return Utils.parse_escaped_chars(data);
|
||||||
case "byte_array":
|
case "byte_array":
|
||||||
if (typeof data == "string") {
|
if (typeof data == "string") {
|
||||||
data = data.replace(/\s+/g, '');
|
data = data.replace(/\s+/g, "");
|
||||||
return Utils.hex_to_byte_array(data);
|
return Utils.hex_to_byte_array(data);
|
||||||
} else {
|
} else {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case "number":
|
case "number":
|
||||||
var number = parseFloat(data);
|
var number = parseFloat(data);
|
||||||
if (isNaN(number)) {
|
if (isNaN(number)) {
|
||||||
|
|
|
@ -203,7 +203,7 @@ var Utils = {
|
||||||
*/
|
*/
|
||||||
parse_escaped_chars: function(str) {
|
parse_escaped_chars: function(str) {
|
||||||
return str.replace(/(\\)?\\([nrtbf]|x[\da-f]{2})/g, function(m, a, b) {
|
return str.replace(/(\\)?\\([nrtbf]|x[\da-f]{2})/g, function(m, a, b) {
|
||||||
if (a == "\\") return "\\"+b;
|
if (a === "\\") return "\\"+b;
|
||||||
switch (b[0]) {
|
switch (b[0]) {
|
||||||
case "n":
|
case "n":
|
||||||
return "\n";
|
return "\n";
|
||||||
|
@ -243,8 +243,8 @@ var Utils = {
|
||||||
|
|
||||||
for (var i = 0; i < alph_str.length; i++) {
|
for (var i = 0; i < alph_str.length; i++) {
|
||||||
if (i < alph_str.length - 2 &&
|
if (i < alph_str.length - 2 &&
|
||||||
alph_str[i+1] == "-" &&
|
alph_str[i+1] === "-" &&
|
||||||
alph_str[i] != "\\") {
|
alph_str[i] !== "\\") {
|
||||||
var start = Utils.ord(alph_str[i]),
|
var start = Utils.ord(alph_str[i]),
|
||||||
end = Utils.ord(alph_str[i+2]);
|
end = Utils.ord(alph_str[i+2]);
|
||||||
|
|
||||||
|
@ -253,8 +253,8 @@ var Utils = {
|
||||||
}
|
}
|
||||||
i += 2;
|
i += 2;
|
||||||
} else if (i < alph_str.length - 2 &&
|
} else if (i < alph_str.length - 2 &&
|
||||||
alph_str[i] == "\\" &&
|
alph_str[i] === "\\" &&
|
||||||
alph_str[i+1] == "-") {
|
alph_str[i+1] === "-") {
|
||||||
alph_arr.push("-");
|
alph_arr.push("-");
|
||||||
i++;
|
i++;
|
||||||
} else {
|
} else {
|
||||||
|
@ -278,7 +278,7 @@ var Utils = {
|
||||||
hex_to_byte_array: function(hex_str) {
|
hex_to_byte_array: function(hex_str) {
|
||||||
// TODO: Handle errors i.e. input string is not hex
|
// TODO: Handle errors i.e. input string is not hex
|
||||||
if (!hex_str) return [];
|
if (!hex_str) return [];
|
||||||
hex_str = hex_str.replace(/\s+/g, '');
|
hex_str = hex_str.replace(/\s+/g, "");
|
||||||
var byte_array = [];
|
var byte_array = [];
|
||||||
for (var i = 0; i < hex_str.length; i += 2) {
|
for (var i = 0; i < hex_str.length; i += 2) {
|
||||||
byte_array.push(parseInt(hex_str.substr(i, 2), 16));
|
byte_array.push(parseInt(hex_str.substr(i, 2), 16));
|
||||||
|
@ -351,7 +351,7 @@ var Utils = {
|
||||||
var word_array = CryptoJS.enc.Utf8.parse(str),
|
var word_array = CryptoJS.enc.Utf8.parse(str),
|
||||||
byte_array = Utils.word_array_to_byte_array(word_array);
|
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;
|
window.app.options.attempt_highlight = false;
|
||||||
return byte_array;
|
return byte_array;
|
||||||
},
|
},
|
||||||
|
@ -403,7 +403,7 @@ var Utils = {
|
||||||
var word_array = new CryptoJS.lib.WordArray.init(words, byte_array.length),
|
var word_array = new CryptoJS.lib.WordArray.init(words, byte_array.length),
|
||||||
str = CryptoJS.enc.Utf8.stringify(word_array);
|
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;
|
window.app.options.attempt_highlight = false;
|
||||||
return str;
|
return str;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -553,7 +553,7 @@ var Utils = {
|
||||||
res.push(String.fromCharCode(Utils.UNIC_WIN1251_MAP[ord]));
|
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]));
|
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";
|
return_type = return_type || "string";
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return return_type == "string" ? "" : [];
|
return return_type === "string" ? "" : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
alphabet = alphabet ?
|
alphabet = alphabet ?
|
||||||
|
@ -678,9 +678,9 @@ var Utils = {
|
||||||
enc3 = alphabet.indexOf(data.charAt(i++) || "=");
|
enc3 = alphabet.indexOf(data.charAt(i++) || "=");
|
||||||
enc4 = alphabet.indexOf(data.charAt(i++) || "=");
|
enc4 = alphabet.indexOf(data.charAt(i++) || "=");
|
||||||
|
|
||||||
enc2 = enc2 == -1 ? 64 : enc2;
|
enc2 = enc2 === -1 ? 64 : enc2;
|
||||||
enc3 = enc3 == -1 ? 64 : enc3;
|
enc3 = enc3 === -1 ? 64 : enc3;
|
||||||
enc4 = enc4 == -1 ? 64 : enc4;
|
enc4 = enc4 === -1 ? 64 : enc4;
|
||||||
|
|
||||||
chr1 = (enc1 << 2) | (enc2 >> 4);
|
chr1 = (enc1 << 2) | (enc2 >> 4);
|
||||||
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
||||||
|
@ -688,15 +688,15 @@ var Utils = {
|
||||||
|
|
||||||
output.push(chr1);
|
output.push(chr1);
|
||||||
|
|
||||||
if (enc3 != 64) {
|
if (enc3 !== 64) {
|
||||||
output.push(chr2);
|
output.push(chr2);
|
||||||
}
|
}
|
||||||
if (enc4 != 64) {
|
if (enc4 !== 64) {
|
||||||
output.push(chr3);
|
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
|
// Add \x or 0x to beginning
|
||||||
if (delim == "0x") output = "0x" + output;
|
if (delim === "0x") output = "0x" + output;
|
||||||
if (delim == "\\x") output = "\\x" + output;
|
if (delim === "\\x") output = "\\x" + output;
|
||||||
|
|
||||||
if (delim.length)
|
if (delim.length)
|
||||||
return output.slice(0, -delim.length);
|
return output.slice(0, -delim.length);
|
||||||
|
@ -779,9 +779,9 @@ var Utils = {
|
||||||
from_hex: function(data, delim, byte_len) {
|
from_hex: function(data, delim, byte_len) {
|
||||||
delim = delim || (data.indexOf(" ") >= 0 ? "Space" : "None");
|
delim = delim || (data.indexOf(" ") >= 0 ? "Space" : "None");
|
||||||
byte_len = byte_len || 2;
|
byte_len = byte_len || 2;
|
||||||
if (delim != "None") {
|
if (delim !== "None") {
|
||||||
var delim_regex = Utils.regex_rep[delim];
|
var delim_regex = Utils.regex_rep[delim];
|
||||||
data = data.replace(delim_regex, '');
|
data = data.replace(delim_regex, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
var output = [];
|
var output = [];
|
||||||
|
@ -816,17 +816,17 @@ var Utils = {
|
||||||
if (ignore_next) {
|
if (ignore_next) {
|
||||||
cell += b;
|
cell += b;
|
||||||
ignore_next = false;
|
ignore_next = false;
|
||||||
} else if (b == "\\") {
|
} else if (b === "\\") {
|
||||||
cell += b;
|
cell += b;
|
||||||
ignore_next = true;
|
ignore_next = true;
|
||||||
} else if (b == "\"" && !in_string) {
|
} else if (b === "\"" && !in_string) {
|
||||||
in_string = true;
|
in_string = true;
|
||||||
} else if (b == "\"" && in_string) {
|
} else if (b === "\"" && in_string) {
|
||||||
in_string = false;
|
in_string = false;
|
||||||
} else if (b == "," && !in_string) {
|
} else if (b === "," && !in_string) {
|
||||||
line.push(cell);
|
line.push(cell);
|
||||||
cell = "";
|
cell = "";
|
||||||
} else if ((b == "\n" || b == "\r") && !in_string) {
|
} else if ((b === "\n" || b === "\r") && !in_string) {
|
||||||
line.push(cell);
|
line.push(cell);
|
||||||
cell = "";
|
cell = "";
|
||||||
lines.push(line);
|
lines.push(line);
|
||||||
|
@ -877,7 +877,7 @@ var Utils = {
|
||||||
escape_html: function(str) {
|
escape_html: function(str) {
|
||||||
return str.replace(/</g, "<")
|
return str.replace(/</g, "<")
|
||||||
.replace(/'/g, "'")
|
.replace(/'/g, "'")
|
||||||
.replace(/"/g, '"')
|
.replace(/"/g, """)
|
||||||
.replace(/&/g, "&");
|
.replace(/&/g, "&");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1002,8 +1002,8 @@ $.fn.selectRange = function(start, end) {
|
||||||
} else if (this.createTextRange) {
|
} else if (this.createTextRange) {
|
||||||
var range = this.createTextRange();
|
var range = this.createTextRange();
|
||||||
range.collapse(true);
|
range.collapse(true);
|
||||||
range.moveEnd('character', end);
|
range.moveEnd("character", end);
|
||||||
range.moveStart('character', start);
|
range.moveStart("character", start);
|
||||||
range.select();
|
range.select();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1095,7 +1095,7 @@ Array.prototype.sum = function() {
|
||||||
Array.prototype.equals = function(other) {
|
Array.prototype.equals = function(other) {
|
||||||
if (!other) return false;
|
if (!other) return false;
|
||||||
var i = this.length;
|
var i = this.length;
|
||||||
if (i != other.length) return false;
|
if (i !== other.length) return false;
|
||||||
while (i--) {
|
while (i--) {
|
||||||
if (this[i] !== other[i]) return false;
|
if (this[i] !== other[i]) return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,14 +44,14 @@ var Base64 = {
|
||||||
var alphabet = args[0] || Base64.ALPHABET;
|
var alphabet = args[0] || Base64.ALPHABET;
|
||||||
return Utils.to_base64(input, alphabet);
|
return Utils.to_base64(input, alphabet);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
REMOVE_NON_ALPH_CHARS: true,
|
REMOVE_NON_ALPH_CHARS: true,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* From Base64 operation.
|
* From Base64 operation.
|
||||||
*
|
*
|
||||||
|
@ -62,17 +62,17 @@ var Base64 = {
|
||||||
run_from: function(input, args) {
|
run_from: function(input, args) {
|
||||||
var alphabet = args[0] || Base64.ALPHABET,
|
var alphabet = args[0] || Base64.ALPHABET,
|
||||||
remove_non_alph_chars = args[1];
|
remove_non_alph_chars = args[1];
|
||||||
|
|
||||||
return Utils.from_base64(input, alphabet, "byte_array", remove_non_alph_chars);
|
return Utils.from_base64(input, alphabet, "byte_array", remove_non_alph_chars);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
BASE32_ALPHABET: "A-Z2-7=",
|
BASE32_ALPHABET: "A-Z2-7=",
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To Base32 operation.
|
* To Base32 operation.
|
||||||
*
|
*
|
||||||
|
@ -82,7 +82,7 @@ var Base64 = {
|
||||||
*/
|
*/
|
||||||
run_to_32: function(input, args) {
|
run_to_32: function(input, args) {
|
||||||
if (!input) return "";
|
if (!input) return "";
|
||||||
|
|
||||||
var alphabet = args[0] ?
|
var alphabet = args[0] ?
|
||||||
Utils.expand_alph_range(args[0]).join("") : "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",
|
Utils.expand_alph_range(args[0]).join("") : "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",
|
||||||
output = "",
|
output = "",
|
||||||
|
@ -115,16 +115,16 @@ var Base64 = {
|
||||||
} else if (isNaN(chr5)) {
|
} else if (isNaN(chr5)) {
|
||||||
enc8 = 32;
|
enc8 = 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
output += alphabet.charAt(enc1) + alphabet.charAt(enc2) + alphabet.charAt(enc3) +
|
output += alphabet.charAt(enc1) + alphabet.charAt(enc2) + alphabet.charAt(enc3) +
|
||||||
alphabet.charAt(enc4) + alphabet.charAt(enc5) + alphabet.charAt(enc6) +
|
alphabet.charAt(enc4) + alphabet.charAt(enc5) + alphabet.charAt(enc6) +
|
||||||
alphabet.charAt(enc7) + alphabet.charAt(enc8);
|
alphabet.charAt(enc7) + alphabet.charAt(enc8);
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* From Base32 operation.
|
* From Base32 operation.
|
||||||
*
|
*
|
||||||
|
@ -134,16 +134,16 @@ var Base64 = {
|
||||||
*/
|
*/
|
||||||
run_from_32: function(input, args) {
|
run_from_32: function(input, args) {
|
||||||
if (!input) return [];
|
if (!input) return [];
|
||||||
|
|
||||||
var alphabet = args[0] ?
|
var alphabet = args[0] ?
|
||||||
Utils.expand_alph_range(args[0]).join("") : "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",
|
Utils.expand_alph_range(args[0]).join("") : "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",
|
||||||
remove_non_alph_chars = args[0];
|
remove_non_alph_chars = args[0];
|
||||||
|
|
||||||
var output = [],
|
var output = [],
|
||||||
chr1, chr2, chr3, chr4, chr5,
|
chr1, chr2, chr3, chr4, chr5,
|
||||||
enc1, enc2, enc3, enc4, enc5, enc6, enc7, enc8,
|
enc1, enc2, enc3, enc4, enc5, enc6, enc7, enc8,
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
if (remove_non_alph_chars) {
|
if (remove_non_alph_chars) {
|
||||||
var re = new RegExp("[^" + alphabet.replace(/[\]\\\-^]/g, "\\$&") + "]", "g");
|
var re = new RegExp("[^" + alphabet.replace(/[\]\\\-^]/g, "\\$&") + "]", "g");
|
||||||
input = input.replace(re, "");
|
input = input.replace(re, "");
|
||||||
|
@ -171,11 +171,11 @@ var Base64 = {
|
||||||
if (enc5 & 1 !== 0 || enc6 !== 32) output.push(chr4);
|
if (enc5 & 1 !== 0 || enc6 !== 32) output.push(chr4);
|
||||||
if (enc7 & 7 !== 0 || enc8 !== 32) output.push(chr5);
|
if (enc7 & 7 !== 0 || enc8 !== 32) output.push(chr5);
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
|
@ -186,7 +186,7 @@ var Base64 = {
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
OFFSETS_SHOW_VARIABLE: true,
|
OFFSETS_SHOW_VARIABLE: true,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show Base64 offsets operation.
|
* Show Base64 offsets operation.
|
||||||
*
|
*
|
||||||
|
@ -206,96 +206,96 @@ var Base64 = {
|
||||||
script = "<script type='application/javascript'>$('[data-toggle=\"tooltip\"]').tooltip()</script>",
|
script = "<script type='application/javascript'>$('[data-toggle=\"tooltip\"]').tooltip()</script>",
|
||||||
static_section = "",
|
static_section = "",
|
||||||
padding = "";
|
padding = "";
|
||||||
|
|
||||||
if (input.length < 1) {
|
if (input.length < 1) {
|
||||||
return "Please enter a string.";
|
return "Please enter a string.";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Highlight offset 0
|
// Highlight offset 0
|
||||||
if (len0 % 4 == 2) {
|
if (len0 % 4 === 2) {
|
||||||
static_section = offset0.slice(0, -3);
|
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)) + "'>" +
|
Utils.escape_html(Utils.from_base64(static_section, alphabet).slice(0, -2)) + "'>" +
|
||||||
static_section + "</span>" +
|
static_section + "</span>" +
|
||||||
"<span class='hlgreen'>" + offset0.substr(offset0.length - 3, 1) + "</span>" +
|
"<span class='hlgreen'>" + offset0.substr(offset0.length - 3, 1) + "</span>" +
|
||||||
"<span class='hlred'>" + offset0.substr(offset0.length - 2) + "</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);
|
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)) + "'>" +
|
Utils.escape_html(Utils.from_base64(static_section, alphabet).slice(0, -1)) + "'>" +
|
||||||
static_section + "</span>" +
|
static_section + "</span>" +
|
||||||
"<span class='hlgreen'>" + offset0.substr(offset0.length - 2, 1) + "</span>" +
|
"<span class='hlgreen'>" + offset0.substr(offset0.length - 2, 1) + "</span>" +
|
||||||
"<span class='hlred'>" + offset0.substr(offset0.length - 1) + "</span>";
|
"<span class='hlred'>" + offset0.substr(offset0.length - 1) + "</span>";
|
||||||
} else {
|
} else {
|
||||||
static_section = offset0;
|
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)) + "'>" +
|
Utils.escape_html(Utils.from_base64(static_section, alphabet)) + "'>" +
|
||||||
static_section + "</span>";
|
static_section + "</span>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!show_variable) {
|
if (!show_variable) {
|
||||||
offset0 = static_section;
|
offset0 = static_section;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Highlight offset 1
|
// Highlight offset 1
|
||||||
padding = "<span class='hlred'>" + offset1.substr(0, 1) + "</span>" +
|
padding = "<span class='hlred'>" + offset1.substr(0, 1) + "</span>" +
|
||||||
"<span class='hlgreen'>" + offset1.substr(1, 1) + "</span>";
|
"<span class='hlgreen'>" + offset1.substr(1, 1) + "</span>";
|
||||||
offset1 = offset1.substr(2);
|
offset1 = offset1.substr(2);
|
||||||
if (len1 % 4 == 2) {
|
if (len1 % 4 === 2) {
|
||||||
static_section = offset1.slice(0, -3);
|
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)) + "'>" +
|
Utils.escape_html(Utils.from_base64("AA" + static_section, alphabet).slice(1, -2)) + "'>" +
|
||||||
static_section + "</span>" +
|
static_section + "</span>" +
|
||||||
"<span class='hlgreen'>" + offset1.substr(offset1.length - 3, 1) + "</span>" +
|
"<span class='hlgreen'>" + offset1.substr(offset1.length - 3, 1) + "</span>" +
|
||||||
"<span class='hlred'>" + offset1.substr(offset1.length - 2) + "</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);
|
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)) + "'>" +
|
Utils.escape_html(Utils.from_base64("AA" + static_section, alphabet).slice(1, -1)) + "'>" +
|
||||||
static_section + "</span>" +
|
static_section + "</span>" +
|
||||||
"<span class='hlgreen'>" + offset1.substr(offset1.length - 2, 1) + "</span>" +
|
"<span class='hlgreen'>" + offset1.substr(offset1.length - 2, 1) + "</span>" +
|
||||||
"<span class='hlred'>" + offset1.substr(offset1.length - 1) + "</span>";
|
"<span class='hlred'>" + offset1.substr(offset1.length - 1) + "</span>";
|
||||||
} else {
|
} else {
|
||||||
static_section = offset1;
|
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)) + "'>" +
|
Utils.escape_html(Utils.from_base64("AA" + static_section, alphabet).slice(1)) + "'>" +
|
||||||
static_section + "</span>";
|
static_section + "</span>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!show_variable) {
|
if (!show_variable) {
|
||||||
offset1 = static_section;
|
offset1 = static_section;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Highlight offset 2
|
// Highlight offset 2
|
||||||
padding = "<span class='hlred'>" + offset2.substr(0, 2) + "</span>" +
|
padding = "<span class='hlred'>" + offset2.substr(0, 2) + "</span>" +
|
||||||
"<span class='hlgreen'>" + offset2.substr(2, 1) + "</span>";
|
"<span class='hlgreen'>" + offset2.substr(2, 1) + "</span>";
|
||||||
offset2 = offset2.substr(3);
|
offset2 = offset2.substr(3);
|
||||||
if (len2 % 4 == 2) {
|
if (len2 % 4 === 2) {
|
||||||
static_section = offset2.slice(0, -3);
|
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)) + "'>" +
|
Utils.escape_html(Utils.from_base64("AAA" + static_section, alphabet).slice(2, -2)) + "'>" +
|
||||||
static_section + "</span>" +
|
static_section + "</span>" +
|
||||||
"<span class='hlgreen'>" + offset2.substr(offset2.length - 3, 1) + "</span>" +
|
"<span class='hlgreen'>" + offset2.substr(offset2.length - 3, 1) + "</span>" +
|
||||||
"<span class='hlred'>" + offset2.substr(offset2.length - 2) + "</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);
|
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)) + "'>" +
|
Utils.escape_html(Utils.from_base64("AAA" + static_section, alphabet).slice(2, -2)) + "'>" +
|
||||||
static_section + "</span>" +
|
static_section + "</span>" +
|
||||||
"<span class='hlgreen'>" + offset2.substr(offset2.length - 2, 1) + "</span>" +
|
"<span class='hlgreen'>" + offset2.substr(offset2.length - 2, 1) + "</span>" +
|
||||||
"<span class='hlred'>" + offset2.substr(offset2.length - 1) + "</span>";
|
"<span class='hlred'>" + offset2.substr(offset2.length - 1) + "</span>";
|
||||||
} else {
|
} else {
|
||||||
static_section = offset2;
|
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)) + "'>" +
|
Utils.escape_html(Utils.from_base64("AAA" + static_section, alphabet).slice(2)) + "'>" +
|
||||||
static_section + "</span>";
|
static_section + "</span>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!show_variable) {
|
if (!show_variable) {
|
||||||
offset2 = static_section;
|
offset2 = static_section;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (show_variable ? "Characters highlighted in <span class='hlgreen'>green</span> could change if the input is surrounded by more data." +
|
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." +
|
"\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>." +
|
"\nUnhighlighted characters are <span data-toggle='tooltip' data-placement='top' title='Tooltip on left'>static</span>." +
|
||||||
|
@ -306,8 +306,8 @@ var Base64 = {
|
||||||
script :
|
script :
|
||||||
offset0 + "\n" + offset1 + "\n" + offset2);
|
offset0 + "\n" + offset1 + "\n" + offset2);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Highlight to Base64
|
* Highlight to Base64
|
||||||
*
|
*
|
||||||
|
@ -322,7 +322,7 @@ var Base64 = {
|
||||||
pos[0].end = Math.ceil(pos[0].end / 3 * 4);
|
pos[0].end = Math.ceil(pos[0].end / 3 * 4);
|
||||||
return pos;
|
return pos;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Highlight from Base64
|
* Highlight from Base64
|
||||||
*
|
*
|
||||||
|
@ -337,5 +337,5 @@ var Base64 = {
|
||||||
pos[0].end = Math.floor(pos[0].end / 4 * 3);
|
pos[0].end = Math.floor(pos[0].end / 4 * 3);
|
||||||
return pos;
|
return pos;
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,9 +32,9 @@ var BitwiseOp = {
|
||||||
for (var i = 0; i < input.length; i++) {
|
for (var i = 0; i < input.length; i++) {
|
||||||
k = key[i % key.length];
|
k = key[i % key.length];
|
||||||
o = input[i];
|
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);
|
result.push(x);
|
||||||
if (scheme != "Standard" && !(null_preserving && (o === 0 || o == k))) {
|
if (scheme !== "Standard" && !(null_preserving && (o === 0 || o === k))) {
|
||||||
switch (scheme) {
|
switch (scheme) {
|
||||||
case "Input differential":
|
case "Input differential":
|
||||||
key[i % key.length] = x;
|
key[i % key.length] = x;
|
||||||
|
|
|
@ -26,7 +26,7 @@ var ByteRepr = {
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
BIN_DELIM_OPTIONS: ["Space", "Comma", "Semi-colon", "Colon", "Line feed", "CRLF", "None"],
|
BIN_DELIM_OPTIONS: ["Space", "Comma", "Semi-colon", "Colon", "Line feed", "CRLF", "None"],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To Hex operation.
|
* To Hex operation.
|
||||||
*
|
*
|
||||||
|
@ -38,8 +38,8 @@ var ByteRepr = {
|
||||||
var delim = Utils.char_rep[args[0] || "Space"];
|
var delim = Utils.char_rep[args[0] || "Space"];
|
||||||
return Utils.to_hex(input, delim, 2);
|
return Utils.to_hex(input, delim, 2);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* From Hex operation.
|
* From Hex operation.
|
||||||
*
|
*
|
||||||
|
@ -51,14 +51,14 @@ var ByteRepr = {
|
||||||
var delim = args[0] || "Space";
|
var delim = args[0] || "Space";
|
||||||
return Utils.from_hex(input, delim, 2);
|
return Utils.from_hex(input, delim, 2);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
CHARCODE_BASE: 16,
|
CHARCODE_BASE: 16,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To Charcode operation.
|
* To Charcode operation.
|
||||||
*
|
*
|
||||||
|
@ -72,34 +72,34 @@ var ByteRepr = {
|
||||||
output = "",
|
output = "",
|
||||||
padding = 2,
|
padding = 2,
|
||||||
ordinal;
|
ordinal;
|
||||||
|
|
||||||
if (base < 2 || base > 36) {
|
if (base < 2 || base > 36) {
|
||||||
throw "Error: Base argument must be between 2 and 36";
|
throw "Error: Base argument must be between 2 and 36";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < input.length; i++) {
|
for (var i = 0; i < input.length; i++) {
|
||||||
ordinal = Utils.ord(input[i]);
|
ordinal = Utils.ord(input[i]);
|
||||||
|
|
||||||
if (base == 16) {
|
if (base === 16) {
|
||||||
if (ordinal < 256) padding = 2;
|
if (ordinal < 256) padding = 2;
|
||||||
else if (ordinal < 65536) padding = 4;
|
else if (ordinal < 65536) padding = 4;
|
||||||
else if (ordinal < 16777216) padding = 6;
|
else if (ordinal < 16777216) padding = 6;
|
||||||
else if (ordinal < 4294967296) padding = 8;
|
else if (ordinal < 4294967296) padding = 8;
|
||||||
else padding = 2;
|
else padding = 2;
|
||||||
|
|
||||||
if (padding > 2) app.options.attempt_highlight = false;
|
if (padding > 2) app.options.attempt_highlight = false;
|
||||||
|
|
||||||
output += Utils.hex(ordinal, padding) + delim;
|
output += Utils.hex(ordinal, padding) + delim;
|
||||||
} else {
|
} else {
|
||||||
app.options.attempt_highlight = false;
|
app.options.attempt_highlight = false;
|
||||||
output += ordinal.toString(base) + delim;
|
output += ordinal.toString(base) + delim;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return output.slice(0, -delim.length);
|
return output.slice(0, -delim.length);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* From Charcode operation.
|
* From Charcode operation.
|
||||||
*
|
*
|
||||||
|
@ -112,32 +112,32 @@ var ByteRepr = {
|
||||||
base = args[1],
|
base = args[1],
|
||||||
bites = input.split(delim),
|
bites = input.split(delim),
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
if (base < 2 || base > 36) {
|
if (base < 2 || base > 36) {
|
||||||
throw "Error: Base argument must be between 2 and 36";
|
throw "Error: Base argument must be between 2 and 36";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (base != 16) {
|
if (base !== 16) {
|
||||||
app.options.attempt_highlight = false;
|
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
|
// too long to be a single character
|
||||||
if (bites.length == 1 && input.length > 17) {
|
if (bites.length === 1 && input.length > 17) {
|
||||||
bites = [];
|
bites = [];
|
||||||
for (i = 0; i < input.length; i += 2) {
|
for (i = 0; i < input.length; i += 2) {
|
||||||
bites.push(input.slice(i, i+2));
|
bites.push(input.slice(i, i+2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var latin1 = "";
|
var latin1 = "";
|
||||||
for (i = 0; i < bites.length; i++) {
|
for (i = 0; i < bites.length; i++) {
|
||||||
latin1 += Utils.chr(parseInt(bites[i], base));
|
latin1 += Utils.chr(parseInt(bites[i], base));
|
||||||
}
|
}
|
||||||
return Utils.str_to_byte_array(latin1);
|
return Utils.str_to_byte_array(latin1);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Highlight to hex
|
* Highlight to hex
|
||||||
*
|
*
|
||||||
|
@ -149,20 +149,20 @@ var ByteRepr = {
|
||||||
*/
|
*/
|
||||||
highlight_to: function(pos, args) {
|
highlight_to: function(pos, args) {
|
||||||
var delim = Utils.char_rep[args[0] || "Space"],
|
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].start = pos[0].start * (2 + len);
|
||||||
pos[0].end = pos[0].end * (2 + len) - 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
|
// 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].start += 2;
|
||||||
pos[0].end += 2;
|
pos[0].end += 2;
|
||||||
}
|
}
|
||||||
return pos;
|
return pos;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Highlight to hex
|
* Highlight to hex
|
||||||
*
|
*
|
||||||
|
@ -174,23 +174,23 @@ var ByteRepr = {
|
||||||
*/
|
*/
|
||||||
highlight_from: function(pos, args) {
|
highlight_from: function(pos, args) {
|
||||||
var delim = Utils.char_rep[args[0] || "Space"],
|
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;
|
width = len + 2;
|
||||||
|
|
||||||
// 0x and \x are added to the beginning if they are selected, so increment the positions accordingly
|
// 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;
|
if (pos[0].start > 1) pos[0].start -= 2;
|
||||||
else pos[0].start = 0;
|
else pos[0].start = 0;
|
||||||
if (pos[0].end > 1) pos[0].end -= 2;
|
if (pos[0].end > 1) pos[0].end -= 2;
|
||||||
else pos[0].end = 0;
|
else pos[0].end = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos[0].start = pos[0].start === 0 ? 0 : Math.round(pos[0].start / width);
|
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);
|
pos[0].end = pos[0].end === 0 ? 0 : Math.ceil(pos[0].end / width);
|
||||||
return pos;
|
return pos;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To Decimal operation.
|
* To Decimal operation.
|
||||||
*
|
*
|
||||||
|
@ -202,8 +202,8 @@ var ByteRepr = {
|
||||||
var delim = Utils.char_rep[args[0]];
|
var delim = Utils.char_rep[args[0]];
|
||||||
return input.join(delim);
|
return input.join(delim);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* From Decimal operation.
|
* From Decimal operation.
|
||||||
*
|
*
|
||||||
|
@ -216,14 +216,14 @@ var ByteRepr = {
|
||||||
var byte_str = input.split(delim), output = [];
|
var byte_str = input.split(delim), output = [];
|
||||||
if (byte_str[byte_str.length-1] === "")
|
if (byte_str[byte_str.length-1] === "")
|
||||||
byte_str = byte_str.slice(0, byte_str.length-1);
|
byte_str = byte_str.slice(0, byte_str.length-1);
|
||||||
|
|
||||||
for (var i = 0; i < byte_str.length; i++) {
|
for (var i = 0; i < byte_str.length; i++) {
|
||||||
output[i] = parseInt(byte_str[i]);
|
output[i] = parseInt(byte_str[i], 10);
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To Binary operation.
|
* To Binary operation.
|
||||||
*
|
*
|
||||||
|
@ -235,19 +235,19 @@ var ByteRepr = {
|
||||||
var delim = Utils.char_rep[args[0] || "Space"],
|
var delim = Utils.char_rep[args[0] || "Space"],
|
||||||
output = "",
|
output = "",
|
||||||
padding = 8;
|
padding = 8;
|
||||||
|
|
||||||
for (var i = 0; i < input.length; i++) {
|
for (var i = 0; i < input.length; i++) {
|
||||||
output += Utils.pad(input[i].toString(2), padding) + delim;
|
output += Utils.pad(input[i].toString(2), padding) + delim;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (delim.length) {
|
if (delim.length) {
|
||||||
return output.slice(0, -delim.length);
|
return output.slice(0, -delim.length);
|
||||||
} else {
|
} else {
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* From Binary operation.
|
* From Binary operation.
|
||||||
*
|
*
|
||||||
|
@ -256,11 +256,11 @@ var ByteRepr = {
|
||||||
* @returns {byte_array}
|
* @returns {byte_array}
|
||||||
*/
|
*/
|
||||||
run_from_binary: function(input, args) {
|
run_from_binary: function(input, args) {
|
||||||
if (args[0] != "None") {
|
if (args[0] !== "None") {
|
||||||
var delim_regex = Utils.regex_rep[args[0] || "Space"];
|
var delim_regex = Utils.regex_rep[args[0] || "Space"];
|
||||||
input = input.replace(delim_regex, '');
|
input = input.replace(delim_regex, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
var output = [];
|
var output = [];
|
||||||
var byte_len = 8;
|
var byte_len = 8;
|
||||||
for (var i = 0; i < input.length; i += byte_len) {
|
for (var i = 0; i < input.length; i += byte_len) {
|
||||||
|
@ -268,8 +268,8 @@ var ByteRepr = {
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Highlight to binary
|
* Highlight to binary
|
||||||
*
|
*
|
||||||
|
@ -285,8 +285,8 @@ var ByteRepr = {
|
||||||
pos[0].end = pos[0].end * (8 + delim.length) - delim.length;
|
pos[0].end = pos[0].end * (8 + delim.length) - delim.length;
|
||||||
return pos;
|
return pos;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Highlight from binary
|
* 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));
|
pos[0].end = pos[0].end === 0 ? 0 : Math.ceil(pos[0].end / (8 + delim.length));
|
||||||
return pos;
|
return pos;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
|
@ -314,7 +314,7 @@ var ByteRepr = {
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
HEX_CONTENT_SPACES_BETWEEN_BYTES: false,
|
HEX_CONTENT_SPACES_BETWEEN_BYTES: false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To Hex Content operation.
|
* To Hex Content operation.
|
||||||
*
|
*
|
||||||
|
@ -325,19 +325,19 @@ var ByteRepr = {
|
||||||
run_to_hex_content: function(input, args) {
|
run_to_hex_content: function(input, args) {
|
||||||
var convert = args[0];
|
var convert = args[0];
|
||||||
var spaces = args[1];
|
var spaces = args[1];
|
||||||
if (convert == "All chars") {
|
if (convert === "All chars") {
|
||||||
var result = "|" + Utils.to_hex(input) + "|";
|
var result = "|" + Utils.to_hex(input) + "|";
|
||||||
if (!spaces) result = result.replace(/ /g, "");
|
if (!spaces) result = result.replace(/ /g, "");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
var output = "",
|
var output = "",
|
||||||
in_hex = false,
|
in_hex = false,
|
||||||
convert_spaces = convert == "Only special chars including spaces",
|
convert_spaces = convert === "Only special chars including spaces",
|
||||||
b;
|
b;
|
||||||
for (var i = 0; i < input.length; i++) {
|
for (var i = 0; i < input.length; i++) {
|
||||||
b = input[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) {
|
if (!in_hex) {
|
||||||
output += "|";
|
output += "|";
|
||||||
in_hex = true;
|
in_hex = true;
|
||||||
|
@ -354,8 +354,8 @@ var ByteRepr = {
|
||||||
if (in_hex) output += "|";
|
if (in_hex) output += "|";
|
||||||
return output;
|
return output;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* From Hex Content operation.
|
* From Hex Content operation.
|
||||||
*
|
*
|
||||||
|
@ -366,11 +366,11 @@ var ByteRepr = {
|
||||||
run_from_hex_content: function(input, args) {
|
run_from_hex_content: function(input, args) {
|
||||||
var regex = /\|([a-f\d ]{2,})\|/gi;
|
var regex = /\|([a-f\d ]{2,})\|/gi;
|
||||||
var output = [], m, i = 0;
|
var output = [], m, i = 0;
|
||||||
while (!!(m = regex.exec(input))) {
|
while ((m = regex.exec(input))) {
|
||||||
// Add up to match
|
// Add up to match
|
||||||
for (; i < m.index;)
|
for (; i < m.index;)
|
||||||
output.push(Utils.ord(input[i++]));
|
output.push(Utils.ord(input[i++]));
|
||||||
|
|
||||||
// Add match
|
// Add match
|
||||||
var bytes = Utils.from_hex(m[1]);
|
var bytes = Utils.from_hex(m[1]);
|
||||||
if (bytes) {
|
if (bytes) {
|
||||||
|
@ -381,13 +381,13 @@ var ByteRepr = {
|
||||||
for (; i < regex.lastIndex;)
|
for (; i < regex.lastIndex;)
|
||||||
output.push(Utils.ord(input[i++]));
|
output.push(Utils.ord(input[i++]));
|
||||||
}
|
}
|
||||||
|
|
||||||
i = regex.lastIndex;
|
i = regex.lastIndex;
|
||||||
}
|
}
|
||||||
// Add all after final match
|
// Add all after final match
|
||||||
for (; i < input.length;)
|
for (; i < input.length;)
|
||||||
output.push(Utils.ord(input[i++]));
|
output.push(Utils.ord(input[i++]));
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -28,14 +28,14 @@ var CharEnc = {
|
||||||
var input_format = args[0],
|
var input_format = args[0],
|
||||||
output_format = args[1];
|
output_format = args[1];
|
||||||
|
|
||||||
if (input_format == "Windows-1251") {
|
if (input_format === "Windows-1251") {
|
||||||
input = Utils.win1251_to_unicode(input);
|
input = Utils.win1251_to_unicode(input);
|
||||||
input = CryptoJS.enc.Utf8.parse(input);
|
input = CryptoJS.enc.Utf8.parse(input);
|
||||||
} else {
|
} else {
|
||||||
input = Utils.format[input_format].parse(input);
|
input = Utils.format[input_format].parse(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output_format == "Windows-1251") {
|
if (output_format === "Windows-1251") {
|
||||||
input = CryptoJS.enc.Utf8.stringify(input);
|
input = CryptoJS.enc.Utf8.stringify(input);
|
||||||
return Utils.unicode_to_win1251(input);
|
return Utils.unicode_to_win1251(input);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
* @namespace
|
* @namespace
|
||||||
*/
|
*/
|
||||||
var Cipher = {
|
var Cipher = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
|
@ -46,8 +46,8 @@ var Cipher = {
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
RESULT_TYPE: ["Show all", "Ciphertext", "Key", "IV", "Salt"],
|
RESULT_TYPE: ["Show all", "Ciphertext", "Key", "IV", "Salt"],
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs encryption operations using the CryptoJS framework.
|
* Runs encryption operations using the CryptoJS framework.
|
||||||
*
|
*
|
||||||
|
@ -65,21 +65,21 @@ var Cipher = {
|
||||||
padding = CryptoJS.pad[args[4]],
|
padding = CryptoJS.pad[args[4]],
|
||||||
result_option = args[5].toLowerCase(),
|
result_option = args[5].toLowerCase(),
|
||||||
output_format = args[6];
|
output_format = args[6];
|
||||||
|
|
||||||
if (iv.sigBytes === 0) {
|
if (iv.sigBytes === 0) {
|
||||||
// Use passphrase rather than key. Need to convert it to a string.
|
// Use passphrase rather than key. Need to convert it to a string.
|
||||||
key = key.toString(CryptoJS.enc.Latin1);
|
key = key.toString(CryptoJS.enc.Latin1);
|
||||||
}
|
}
|
||||||
|
|
||||||
var encrypted = algo.encrypt(input, key, {
|
var encrypted = algo.encrypt(input, key, {
|
||||||
salt: salt.sigBytes > 0 ? salt : false,
|
salt: salt.sigBytes > 0 ? salt : false,
|
||||||
iv: iv.sigBytes > 0 ? iv : null,
|
iv: iv.sigBytes > 0 ? iv : null,
|
||||||
mode: mode,
|
mode: mode,
|
||||||
padding: padding
|
padding: padding
|
||||||
});
|
});
|
||||||
|
|
||||||
var result = "";
|
var result = "";
|
||||||
if (result_option == "show all") {
|
if (result_option === "show all") {
|
||||||
result += "Key: " + encrypted.key.toString(Utils.format[output_format]);
|
result += "Key: " + encrypted.key.toString(Utils.format[output_format]);
|
||||||
result += "\nIV: " + encrypted.iv.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]);
|
if (encrypted.salt) result += "\nSalt: " + encrypted.salt.toString(Utils.format[output_format]);
|
||||||
|
@ -87,11 +87,11 @@ var Cipher = {
|
||||||
} else {
|
} else {
|
||||||
result = encrypted[result_option].toString(Utils.format[output_format]);
|
result = encrypted[result_option].toString(Utils.format[output_format]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs decryption operations using the CryptoJS framework.
|
* Runs decryption operations using the CryptoJS framework.
|
||||||
*
|
*
|
||||||
|
@ -109,39 +109,39 @@ var Cipher = {
|
||||||
padding = CryptoJS.pad[args[4]],
|
padding = CryptoJS.pad[args[4]],
|
||||||
input_format = args[5],
|
input_format = args[5],
|
||||||
output_format = args[6];
|
output_format = args[6];
|
||||||
|
|
||||||
// The ZeroPadding option causes a crash when the input length is 0
|
// The ZeroPadding option causes a crash when the input length is 0
|
||||||
if (!input.length) {
|
if (!input.length) {
|
||||||
return "No input";
|
return "No input";
|
||||||
}
|
}
|
||||||
|
|
||||||
var ciphertext = Utils.format[input_format].parse(input);
|
var ciphertext = Utils.format[input_format].parse(input);
|
||||||
|
|
||||||
if (iv.sigBytes === 0) {
|
if (iv.sigBytes === 0) {
|
||||||
// Use passphrase rather than key. Need to convert it to a string.
|
// Use passphrase rather than key. Need to convert it to a string.
|
||||||
key = key.toString(CryptoJS.enc.Latin1);
|
key = key.toString(CryptoJS.enc.Latin1);
|
||||||
}
|
}
|
||||||
|
|
||||||
var decrypted = algo.decrypt({
|
var decrypted = algo.decrypt({
|
||||||
ciphertext: ciphertext,
|
ciphertext: ciphertext,
|
||||||
salt: salt.sigBytes > 0 ? salt : false
|
salt: salt.sigBytes > 0 ? salt : false
|
||||||
}, key, {
|
}, key, {
|
||||||
iv: iv.sigBytes > 0 ? iv : null,
|
iv: iv.sigBytes > 0 ? iv : null,
|
||||||
mode: mode,
|
mode: mode,
|
||||||
padding: padding
|
padding: padding
|
||||||
});
|
});
|
||||||
|
|
||||||
var result;
|
var result;
|
||||||
try {
|
try {
|
||||||
result = decrypted.toString(Utils.format[output_format]);
|
result = decrypted.toString(Utils.format[output_format]);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
result = "Decrypt error: " + err.message;
|
result = "Decrypt error: " + err.message;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AES Encrypt operation.
|
* AES Encrypt operation.
|
||||||
*
|
*
|
||||||
|
@ -152,8 +152,8 @@ var Cipher = {
|
||||||
run_aes_enc: function (input, args) {
|
run_aes_enc: function (input, args) {
|
||||||
return Cipher._enc(CryptoJS.AES, input, args);
|
return Cipher._enc(CryptoJS.AES, input, args);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AES Decrypt operation.
|
* AES Decrypt operation.
|
||||||
*
|
*
|
||||||
|
@ -164,8 +164,8 @@ var Cipher = {
|
||||||
run_aes_dec: function (input, args) {
|
run_aes_dec: function (input, args) {
|
||||||
return Cipher._dec(CryptoJS.AES, input, args);
|
return Cipher._dec(CryptoJS.AES, input, args);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DES Encrypt operation.
|
* DES Encrypt operation.
|
||||||
*
|
*
|
||||||
|
@ -176,8 +176,8 @@ var Cipher = {
|
||||||
run_des_enc: function (input, args) {
|
run_des_enc: function (input, args) {
|
||||||
return Cipher._enc(CryptoJS.DES, input, args);
|
return Cipher._enc(CryptoJS.DES, input, args);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DES Decrypt operation.
|
* DES Decrypt operation.
|
||||||
*
|
*
|
||||||
|
@ -188,8 +188,8 @@ var Cipher = {
|
||||||
run_des_dec: function (input, args) {
|
run_des_dec: function (input, args) {
|
||||||
return Cipher._dec(CryptoJS.DES, input, args);
|
return Cipher._dec(CryptoJS.DES, input, args);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triple DES Encrypt operation.
|
* Triple DES Encrypt operation.
|
||||||
*
|
*
|
||||||
|
@ -200,8 +200,8 @@ var Cipher = {
|
||||||
run_triple_des_enc: function (input, args) {
|
run_triple_des_enc: function (input, args) {
|
||||||
return Cipher._enc(CryptoJS.TripleDES, input, args);
|
return Cipher._enc(CryptoJS.TripleDES, input, args);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triple DES Decrypt operation.
|
* Triple DES Decrypt operation.
|
||||||
*
|
*
|
||||||
|
@ -212,8 +212,8 @@ var Cipher = {
|
||||||
run_triple_des_dec: function (input, args) {
|
run_triple_des_dec: function (input, args) {
|
||||||
return Cipher._dec(CryptoJS.TripleDES, input, args);
|
return Cipher._dec(CryptoJS.TripleDES, input, args);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rabbit Encrypt operation.
|
* Rabbit Encrypt operation.
|
||||||
*
|
*
|
||||||
|
@ -224,8 +224,8 @@ var Cipher = {
|
||||||
run_rabbit_enc: function (input, args) {
|
run_rabbit_enc: function (input, args) {
|
||||||
return Cipher._enc(CryptoJS.Rabbit, input, args);
|
return Cipher._enc(CryptoJS.Rabbit, input, args);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rabbit Decrypt operation.
|
* Rabbit Decrypt operation.
|
||||||
*
|
*
|
||||||
|
@ -236,8 +236,8 @@ var Cipher = {
|
||||||
run_rabbit_dec: function (input, args) {
|
run_rabbit_dec: function (input, args) {
|
||||||
return Cipher._dec(CryptoJS.Rabbit, input, args);
|
return Cipher._dec(CryptoJS.Rabbit, input, args);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
|
@ -248,7 +248,7 @@ var Cipher = {
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
BLOWFISH_OUTPUT_TYPES: ["Base64", "Hex", "String", "Raw"],
|
BLOWFISH_OUTPUT_TYPES: ["Base64", "Hex", "String", "Raw"],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Blowfish Encrypt operation.
|
* Blowfish Encrypt operation.
|
||||||
*
|
*
|
||||||
|
@ -260,19 +260,19 @@ var Cipher = {
|
||||||
var key = Utils.format[args[0].option].parse(args[0].string).toString(Utils.format.Latin1),
|
var key = Utils.format[args[0].option].parse(args[0].string).toString(Utils.format.Latin1),
|
||||||
mode = args[1],
|
mode = args[1],
|
||||||
output_format = args[2];
|
output_format = args[2];
|
||||||
|
|
||||||
if (key.length === 0) return "Enter a key";
|
if (key.length === 0) return "Enter a key";
|
||||||
|
|
||||||
var enc_hex = blowfish.encrypt(input, key, {
|
var enc_hex = blowfish.encrypt(input, key, {
|
||||||
outputType: 1,
|
outputType: 1,
|
||||||
cipherMode: Cipher.BLOWFISH_MODES.indexOf(mode)
|
cipherMode: Cipher.BLOWFISH_MODES.indexOf(mode)
|
||||||
}),
|
}),
|
||||||
enc = CryptoJS.enc.Hex.parse(enc_hex);
|
enc = CryptoJS.enc.Hex.parse(enc_hex);
|
||||||
|
|
||||||
return enc.toString(Utils.format[output_format]);
|
return enc.toString(Utils.format[output_format]);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Blowfish Decrypt operation.
|
* Blowfish Decrypt operation.
|
||||||
*
|
*
|
||||||
|
@ -284,18 +284,18 @@ var Cipher = {
|
||||||
var key = Utils.format[args[0].option].parse(args[0].string).toString(Utils.format.Latin1),
|
var key = Utils.format[args[0].option].parse(args[0].string).toString(Utils.format.Latin1),
|
||||||
mode = args[1],
|
mode = args[1],
|
||||||
input_format = args[2];
|
input_format = args[2];
|
||||||
|
|
||||||
if (key.length === 0) return "Enter a key";
|
if (key.length === 0) return "Enter a key";
|
||||||
|
|
||||||
input = Utils.format[input_format].parse(input);
|
input = Utils.format[input_format].parse(input);
|
||||||
|
|
||||||
return blowfish.decrypt(input.toString(CryptoJS.enc.Base64), key, {
|
return blowfish.decrypt(input.toString(CryptoJS.enc.Base64), key, {
|
||||||
outputType: 0, // This actually means inputType. The library is weird.
|
outputType: 0, // This actually means inputType. The library is weird.
|
||||||
cipherMode: Cipher.BLOWFISH_MODES.indexOf(mode)
|
cipherMode: Cipher.BLOWFISH_MODES.indexOf(mode)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
|
@ -306,7 +306,7 @@ var Cipher = {
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
KDF_ITERATIONS: 1,
|
KDF_ITERATIONS: 1,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Derive PBKDF2 key operation.
|
* Derive PBKDF2 key operation.
|
||||||
*
|
*
|
||||||
|
@ -322,11 +322,11 @@ var Cipher = {
|
||||||
output_format = args[4],
|
output_format = args[4],
|
||||||
passphrase = Utils.format[input_format].parse(input),
|
passphrase = Utils.format[input_format].parse(input),
|
||||||
key = CryptoJS.PBKDF2(passphrase, salt, { keySize: key_size, iterations: iterations });
|
key = CryptoJS.PBKDF2(passphrase, salt, { keySize: key_size, iterations: iterations });
|
||||||
|
|
||||||
return key.toString(Utils.format[output_format]);
|
return key.toString(Utils.format[output_format]);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Derive EVP key operation.
|
* Derive EVP key operation.
|
||||||
*
|
*
|
||||||
|
@ -342,11 +342,11 @@ var Cipher = {
|
||||||
output_format = args[4],
|
output_format = args[4],
|
||||||
passphrase = Utils.format[input_format].parse(input),
|
passphrase = Utils.format[input_format].parse(input),
|
||||||
key = CryptoJS.EvpKDF(passphrase, salt, { keySize: key_size, iterations: iterations });
|
key = CryptoJS.EvpKDF(passphrase, salt, { keySize: key_size, iterations: iterations });
|
||||||
|
|
||||||
return key.toString(Utils.format[output_format]);
|
return key.toString(Utils.format[output_format]);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RC4 operation.
|
* RC4 operation.
|
||||||
*
|
*
|
||||||
|
@ -358,17 +358,17 @@ var Cipher = {
|
||||||
var message = Utils.format[args[1]].parse(input),
|
var message = Utils.format[args[1]].parse(input),
|
||||||
passphrase = Utils.format[args[0].option].parse(args[0].string),
|
passphrase = Utils.format[args[0].option].parse(args[0].string),
|
||||||
encrypted = CryptoJS.RC4.encrypt(message, passphrase);
|
encrypted = CryptoJS.RC4.encrypt(message, passphrase);
|
||||||
|
|
||||||
return encrypted.ciphertext.toString(Utils.format[args[2]]);
|
return encrypted.ciphertext.toString(Utils.format[args[2]]);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
RC4DROP_BYTES: 768,
|
RC4DROP_BYTES: 768,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RC4 Drop operation.
|
* RC4 Drop operation.
|
||||||
*
|
*
|
||||||
|
@ -381,17 +381,107 @@ var Cipher = {
|
||||||
passphrase = Utils.format[args[0].option].parse(args[0].string),
|
passphrase = Utils.format[args[0].option].parse(args[0].string),
|
||||||
drop = args[3],
|
drop = args[3],
|
||||||
encrypted = CryptoJS.RC4Drop.encrypt(message, passphrase, { drop: drop });
|
encrypted = CryptoJS.RC4Drop.encrypt(message, passphrase, { drop: drop });
|
||||||
|
|
||||||
return encrypted.ciphertext.toString(Utils.format[args[2]]);
|
return encrypted.ciphertext.toString(Utils.format[args[2]]);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vigenère Encode operation.
|
||||||
|
*
|
||||||
|
* @author Matt C [matt@artemisbot.pw]
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run_vigenere_enc: function (input, args) {
|
||||||
|
var alphabet = "abcdefghijklmnopqrstuvwxyz",
|
||||||
|
key = args[0].toLowerCase(),
|
||||||
|
output = "",
|
||||||
|
fail = 0,
|
||||||
|
key_index,
|
||||||
|
msg_index,
|
||||||
|
chr;
|
||||||
|
|
||||||
|
if (!key) return "No key entered";
|
||||||
|
if (!/^[a-zA-Z]+$/.test(key)) return "The key must consist only of letters";
|
||||||
|
|
||||||
|
for (var i = 0; i < input.length; i++) {
|
||||||
|
if (alphabet.indexOf(input[i]) >= 0) {
|
||||||
|
// Get the corresponding character of key for the current letter, accounting
|
||||||
|
// for chars not in alphabet
|
||||||
|
chr = key[(i - fail) % key.length];
|
||||||
|
// Get the location in the vigenere square of the key char
|
||||||
|
key_index = alphabet.indexOf(chr);
|
||||||
|
// Get the location in the vigenere square of the message char
|
||||||
|
msg_index = alphabet.indexOf(input[i]);
|
||||||
|
// Get the encoded letter by finding the sum of indexes modulo 26 and finding
|
||||||
|
// the letter corresponding to that
|
||||||
|
output += alphabet[(key_index + msg_index) % 26];
|
||||||
|
} else if (alphabet.indexOf(input[i].toLowerCase()) >= 0) {
|
||||||
|
chr = key[(i - fail) % key.length].toLowerCase();
|
||||||
|
key_index = alphabet.indexOf(chr);
|
||||||
|
msg_index = alphabet.indexOf(input[i].toLowerCase());
|
||||||
|
output += alphabet[(key_index + msg_index) % 26].toUpperCase();
|
||||||
|
} else {
|
||||||
|
output += input[i];
|
||||||
|
fail++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vigenère Decode operation.
|
||||||
|
*
|
||||||
|
* @author Matt C [matt@artemisbot.pw]
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run_vigenere_dec: function (input, args) {
|
||||||
|
var alphabet = "abcdefghijklmnopqrstuvwxyz",
|
||||||
|
key = args[0].toLowerCase(),
|
||||||
|
output = "",
|
||||||
|
fail = 0,
|
||||||
|
key_index,
|
||||||
|
msg_index,
|
||||||
|
chr;
|
||||||
|
|
||||||
|
if (!key) return "No key entered";
|
||||||
|
if (!/^[a-zA-Z]+$/.test(key)) return "The key must consist only of letters";
|
||||||
|
|
||||||
|
for (var i = 0; i < input.length; i++) {
|
||||||
|
if (alphabet.indexOf(input[i]) >= 0) {
|
||||||
|
chr = key[(i - fail) % key.length];
|
||||||
|
key_index = alphabet.indexOf(chr);
|
||||||
|
msg_index = alphabet.indexOf(input[i]);
|
||||||
|
// Subtract indexes from each other, add 26 just in case the value is negative,
|
||||||
|
// modulo to remove if neccessary
|
||||||
|
output += alphabet[(msg_index - key_index + alphabet.length ) % 26];
|
||||||
|
} else if (alphabet.indexOf(input[i].toLowerCase()) >= 0) {
|
||||||
|
chr = key[(i - fail) % key.length].toLowerCase();
|
||||||
|
key_index = alphabet.indexOf(chr);
|
||||||
|
msg_index = alphabet.indexOf(input[i].toLowerCase());
|
||||||
|
output += alphabet[(msg_index + alphabet.length - key_index) % 26].toUpperCase();
|
||||||
|
} else {
|
||||||
|
output += input[i];
|
||||||
|
fail++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overwriting the CryptoJS OpenSSL key derivation function so that it is possible to not pass a
|
* Overwriting the CryptoJS OpenSSL key derivation function so that it is possible to not pass a
|
||||||
* salt in.
|
* salt in.
|
||||||
|
|
||||||
* @param {string} password - The password to derive from.
|
* @param {string} password - The password to derive from.
|
||||||
* @param {number} keySize - The size in words of the key to generate.
|
* @param {number} keySize - The size in words of the key to generate.
|
||||||
* @param {number} ivSize - The size in words of the IV to generate.
|
* @param {number} ivSize - The size in words of the IV to generate.
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
* @namespace
|
* @namespace
|
||||||
*/
|
*/
|
||||||
var Code = {
|
var Code = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
|
@ -21,7 +21,7 @@ var Code = {
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
LINE_NUMS: false,
|
LINE_NUMS: false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Syntax highlighter operation.
|
* Syntax highlighter operation.
|
||||||
*
|
*
|
||||||
|
@ -34,14 +34,14 @@ var Code = {
|
||||||
line_nums = args[1];
|
line_nums = args[1];
|
||||||
return "<code class='prettyprint'>" + prettyPrintOne(Utils.escape_html(input), language, line_nums) + "</code>";
|
return "<code class='prettyprint'>" + prettyPrintOne(Utils.escape_html(input), language, line_nums) + "</code>";
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
BEAUTIFY_INDENT: "\\t",
|
BEAUTIFY_INDENT: "\\t",
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* XML Beautify operation.
|
* XML Beautify operation.
|
||||||
*
|
*
|
||||||
|
@ -53,8 +53,8 @@ var Code = {
|
||||||
var indent_str = args[0];
|
var indent_str = args[0];
|
||||||
return vkbeautify.xml(input, indent_str);
|
return vkbeautify.xml(input, indent_str);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JSON Beautify operation.
|
* JSON Beautify operation.
|
||||||
*
|
*
|
||||||
|
@ -67,8 +67,8 @@ var Code = {
|
||||||
if (!input) return "";
|
if (!input) return "";
|
||||||
return vkbeautify.json(input, indent_str);
|
return vkbeautify.json(input, indent_str);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CSS Beautify operation.
|
* CSS Beautify operation.
|
||||||
*
|
*
|
||||||
|
@ -80,8 +80,8 @@ var Code = {
|
||||||
var indent_str = args[0];
|
var indent_str = args[0];
|
||||||
return vkbeautify.css(input, indent_str);
|
return vkbeautify.css(input, indent_str);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SQL Beautify operation.
|
* SQL Beautify operation.
|
||||||
*
|
*
|
||||||
|
@ -93,14 +93,14 @@ var Code = {
|
||||||
var indent_str = args[0];
|
var indent_str = args[0];
|
||||||
return vkbeautify.sql(input, indent_str);
|
return vkbeautify.sql(input, indent_str);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
PRESERVE_COMMENTS: false,
|
PRESERVE_COMMENTS: false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* XML Minify operation.
|
* XML Minify operation.
|
||||||
*
|
*
|
||||||
|
@ -112,8 +112,8 @@ var Code = {
|
||||||
var preserve_comments = args[0];
|
var preserve_comments = args[0];
|
||||||
return vkbeautify.xmlmin(input, preserve_comments);
|
return vkbeautify.xmlmin(input, preserve_comments);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JSON Minify operation.
|
* JSON Minify operation.
|
||||||
*
|
*
|
||||||
|
@ -125,8 +125,8 @@ var Code = {
|
||||||
if (!input) return "";
|
if (!input) return "";
|
||||||
return vkbeautify.jsonmin(input);
|
return vkbeautify.jsonmin(input);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CSS Minify operation.
|
* CSS Minify operation.
|
||||||
*
|
*
|
||||||
|
@ -138,8 +138,8 @@ var Code = {
|
||||||
var preserve_comments = args[0];
|
var preserve_comments = args[0];
|
||||||
return vkbeautify.cssmin(input, preserve_comments);
|
return vkbeautify.cssmin(input, preserve_comments);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SQL Minify operation.
|
* SQL Minify operation.
|
||||||
*
|
*
|
||||||
|
@ -150,8 +150,8 @@ var Code = {
|
||||||
run_sql_minify: function(input, args) {
|
run_sql_minify: function(input, args) {
|
||||||
return vkbeautify.sqlmin(input);
|
return vkbeautify.sqlmin(input);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic Code Beautify operation.
|
* 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
|
* 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
|
* correctly generates an AST for multiple different languages. I have tried, and I can tell
|
||||||
* you it's pretty much impossible.
|
* you it's pretty much impossible.
|
||||||
*
|
*
|
||||||
* This basically works. That'll have to be good enough. It's not meant to produce working code,
|
* This basically works. That'll have to be good enough. It's not meant to produce working code,
|
||||||
* just slightly more readable code.
|
* just slightly more readable code.
|
||||||
*
|
*
|
||||||
* Things that don't work:
|
* Things that don't work:
|
||||||
* - For loop formatting
|
* - For loop formatting
|
||||||
* - Do-While loop formatting
|
* - Do-While loop formatting
|
||||||
|
@ -180,66 +180,66 @@ var Code = {
|
||||||
t = 0,
|
t = 0,
|
||||||
preserved_tokens = [],
|
preserved_tokens = [],
|
||||||
m;
|
m;
|
||||||
|
|
||||||
// Remove strings
|
// Remove strings
|
||||||
var sstrings = /'([^'\\]|\\.)*'/g;
|
var sstrings = /'([^'\\]|\\.)*'/g;
|
||||||
while (!!(m = sstrings.exec(code))) {
|
while ((m = sstrings.exec(code))) {
|
||||||
code = preserve_token(code, m, t++);
|
code = preserve_token(code, m, t++);
|
||||||
sstrings.lastIndex = m.index;
|
sstrings.lastIndex = m.index;
|
||||||
}
|
}
|
||||||
|
|
||||||
var dstrings = /"([^"\\]|\\.)*"/g;
|
var dstrings = /"([^"\\]|\\.)*"/g;
|
||||||
while (!!(m = dstrings.exec(code))) {
|
while ((m = dstrings.exec(code))) {
|
||||||
code = preserve_token(code, m, t++);
|
code = preserve_token(code, m, t++);
|
||||||
dstrings.lastIndex = m.index;
|
dstrings.lastIndex = m.index;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove comments
|
// Remove comments
|
||||||
var scomments = /\/\/[^\n\r]*/g;
|
var scomments = /\/\/[^\n\r]*/g;
|
||||||
while (!!(m = scomments.exec(code))) {
|
while ((m = scomments.exec(code))) {
|
||||||
code = preserve_token(code, m, t++);
|
code = preserve_token(code, m, t++);
|
||||||
scomments.lastIndex = m.index;
|
scomments.lastIndex = m.index;
|
||||||
}
|
}
|
||||||
|
|
||||||
var mcomments = /\/\*[\s\S]*?\*\//gm;
|
var mcomments = /\/\*[\s\S]*?\*\//gm;
|
||||||
while (!!(m = mcomments.exec(code))) {
|
while ((m = mcomments.exec(code))) {
|
||||||
code = preserve_token(code, m, t++);
|
code = preserve_token(code, m, t++);
|
||||||
mcomments.lastIndex = m.index;
|
mcomments.lastIndex = m.index;
|
||||||
}
|
}
|
||||||
|
|
||||||
var hcomments = /(^|\n)#[^\n\r#]+/g;
|
var hcomments = /(^|\n)#[^\n\r#]+/g;
|
||||||
while (!!(m = hcomments.exec(code))) {
|
while ((m = hcomments.exec(code))) {
|
||||||
code = preserve_token(code, m, t++);
|
code = preserve_token(code, m, t++);
|
||||||
hcomments.lastIndex = m.index;
|
hcomments.lastIndex = m.index;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove regexes
|
// Remove regexes
|
||||||
var regexes = /\/.*?[^\\]\/[gim]{0,3}/gi;
|
var regexes = /\/.*?[^\\]\/[gim]{0,3}/gi;
|
||||||
while (!!(m = regexes.exec(code))) {
|
while ((m = regexes.exec(code))) {
|
||||||
code = preserve_token(code, m, t++);
|
code = preserve_token(code, m, t++);
|
||||||
regexes.lastIndex = m.index;
|
regexes.lastIndex = m.index;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create newlines after ;
|
// Create newlines after ;
|
||||||
code = code.replace(/;/g, ";\n");
|
code = code.replace(/;/g, ";\n");
|
||||||
|
|
||||||
// Create newlines after { and around }
|
// Create newlines after { and around }
|
||||||
code = code.replace(/{/g, "{\n");
|
code = code.replace(/{/g, "{\n");
|
||||||
code = code.replace(/}/g, "\n}\n");
|
code = code.replace(/}/g, "\n}\n");
|
||||||
|
|
||||||
// Remove carriage returns
|
// Remove carriage returns
|
||||||
code = code.replace(/\r/g, "");
|
code = code.replace(/\r/g, "");
|
||||||
|
|
||||||
// Remove all indentation
|
// Remove all indentation
|
||||||
code = code.replace(/^\s+/g, "");
|
code = code.replace(/^\s+/g, "");
|
||||||
code = code.replace(/\n\s+/g, "\n");
|
code = code.replace(/\n\s+/g, "\n");
|
||||||
|
|
||||||
// Remove trailing spaces
|
// Remove trailing spaces
|
||||||
code = code.replace(/\s*$/g, "");
|
code = code.replace(/\s*$/g, "");
|
||||||
|
|
||||||
// Remove newlines before {
|
// Remove newlines before {
|
||||||
code = code.replace(/\n{/g, "{");
|
code = code.replace(/\n{/g, "{");
|
||||||
|
|
||||||
// Indent
|
// Indent
|
||||||
var i = 0,
|
var i = 0,
|
||||||
level = 0;
|
level = 0;
|
||||||
|
@ -250,10 +250,10 @@ var Code = {
|
||||||
break;
|
break;
|
||||||
case "\n":
|
case "\n":
|
||||||
if (i+1 >= code.length) break;
|
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(" ") : "";
|
var indent = (level >= 0) ? Array(level*4+1).join(" ") : "";
|
||||||
|
|
||||||
code = code.substring(0, i+1) + indent + code.substring(i+1);
|
code = code.substring(0, i+1) + indent + code.substring(i+1);
|
||||||
if (level > 0) i += level*4;
|
if (level > 0) i += level*4;
|
||||||
break;
|
break;
|
||||||
|
@ -272,30 +272,30 @@ var Code = {
|
||||||
code = code.replace(/\s*,\s*/g, ", ");
|
code = code.replace(/\s*,\s*/g, ", ");
|
||||||
code = code.replace(/\s*{/g, " {");
|
code = code.replace(/\s*{/g, " {");
|
||||||
code = code.replace(/}\n/g, "}\n\n");
|
code = code.replace(/}\n/g, "}\n\n");
|
||||||
|
|
||||||
// Just... don't look at this
|
// 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]*)\)\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(/(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*\n([^{])/gim, "else\n $1");
|
||||||
code = code.replace(/else\s+([^{])/gim, "else $1");
|
code = code.replace(/else\s+([^{])/gim, "else $1");
|
||||||
|
|
||||||
// Remove strategic spaces
|
// Remove strategic spaces
|
||||||
code = code.replace(/\s+;/g, ";");
|
code = code.replace(/\s+;/g, ";");
|
||||||
code = code.replace(/\{\s+\}/g, "{}");
|
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");
|
code = code.replace(/}\s*(else|catch|except|finally|elif|elseif|else if)/gi, "} $1");
|
||||||
|
|
||||||
|
|
||||||
// Replace preserved tokens
|
// Replace preserved tokens
|
||||||
var ptokens = /###preserved_token(\d+)###/g;
|
var ptokens = /###preserved_token(\d+)###/g;
|
||||||
while (!!(m = ptokens.exec(code))) {
|
while ((m = ptokens.exec(code))) {
|
||||||
var ti = parseInt(m[1]);
|
var ti = parseInt(m[1], 10);
|
||||||
code = code.substring(0, m.index) + preserved_tokens[ti] + code.substring(m.index + m[0].length);
|
code = code.substring(0, m.index) + preserved_tokens[ti] + code.substring(m.index + m[0].length);
|
||||||
ptokens.lastIndex = m.index;
|
ptokens.lastIndex = m.index;
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
function preserve_token(str, match, t) {
|
function preserve_token(str, match, t) {
|
||||||
preserved_tokens[t] = match[0];
|
preserved_tokens[t] = match[0];
|
||||||
return str.substring(0, match.index) +
|
return str.substring(0, match.index) +
|
||||||
|
|
|
@ -108,12 +108,12 @@ var Compress = {
|
||||||
// ]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]...
|
// ]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]....]...
|
||||||
// e.g. Input data of [8b, 1d, dc, 44]
|
// e.g. Input data of [8b, 1d, dc, 44]
|
||||||
// Look for the first two square brackets:
|
// 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
|
// If the first two square brackets are there, check that the others
|
||||||
// are also there. If they are, throw an error. If not, continue.
|
// are also there. If they are, throw an error. If not, continue.
|
||||||
var valid = false;
|
var valid = false;
|
||||||
for (var i = 0; i < 155; i += 5) {
|
for (var i = 0; i < 155; i += 5) {
|
||||||
if (result[i] != 93) {
|
if (result[i] !== 93) {
|
||||||
valid = true;
|
valid = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,12 +172,12 @@ var Compress = {
|
||||||
// Deal with character encoding issues
|
// Deal with character encoding issues
|
||||||
input = Utils.str_to_byte_array(Utils.byte_array_to_utf8(input));
|
input = Utils.str_to_byte_array(Utils.byte_array_to_utf8(input));
|
||||||
var inflate = new Zlib.Inflate(input, {
|
var inflate = new Zlib.Inflate(input, {
|
||||||
index: args[0],
|
index: args[0],
|
||||||
bufferSize: args[1],
|
bufferSize: args[1],
|
||||||
bufferType: Compress.ZLIB_BUFFER_TYPE_LOOKUP[args[2]],
|
bufferType: Compress.ZLIB_BUFFER_TYPE_LOOKUP[args[2]],
|
||||||
resize: args[3],
|
resize: args[3],
|
||||||
verify: args[4]
|
verify: args[4]
|
||||||
});
|
});
|
||||||
return Array.prototype.slice.call(inflate.decompress());
|
return Array.prototype.slice.call(inflate.decompress());
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ var Convert = {
|
||||||
"Centimetres (cm)" : 1e-2,
|
"Centimetres (cm)" : 1e-2,
|
||||||
"Metres (m)" : 1,
|
"Metres (m)" : 1,
|
||||||
"Kilometers (km)" : 1e3,
|
"Kilometers (km)" : 1e3,
|
||||||
|
|
||||||
"Thou (th)" : 0.0000254,
|
"Thou (th)" : 0.0000254,
|
||||||
"Inches (in)" : 0.0254,
|
"Inches (in)" : 0.0254,
|
||||||
"Feet (ft)" : 0.3048,
|
"Feet (ft)" : 0.3048,
|
||||||
|
@ -40,23 +40,23 @@ var Convert = {
|
||||||
"Furlongs (fur)" : 201.168,
|
"Furlongs (fur)" : 201.168,
|
||||||
"Miles (mi)" : 1609.344,
|
"Miles (mi)" : 1609.344,
|
||||||
"Leagues (lea)" : 4828.032,
|
"Leagues (lea)" : 4828.032,
|
||||||
|
|
||||||
"Fathoms (ftm)" : 1.853184,
|
"Fathoms (ftm)" : 1.853184,
|
||||||
"Cables" : 185.3184,
|
"Cables" : 185.3184,
|
||||||
"Nautical miles" : 1853.184,
|
"Nautical miles" : 1853.184,
|
||||||
|
|
||||||
"Cars (4m)" : 4,
|
"Cars (4m)" : 4,
|
||||||
"Buses (8.4m)" : 8.4,
|
"Buses (8.4m)" : 8.4,
|
||||||
"American football fields (91m)": 91,
|
"American football fields (91m)": 91,
|
||||||
"Football pitches (105m)": 105,
|
"Football pitches (105m)": 105,
|
||||||
|
|
||||||
"Earth-to-Moons" : 380000000,
|
"Earth-to-Moons" : 380000000,
|
||||||
"Earth's equators" : 40075016.686,
|
"Earth's equators" : 40075016.686,
|
||||||
"Astronomical units (au)": 149597870700,
|
"Astronomical units (au)": 149597870700,
|
||||||
"Light-years (ly)" : 9460730472580800,
|
"Light-years (ly)" : 9460730472580800,
|
||||||
"Parsecs (pc)" : 3.0856776e16
|
"Parsecs (pc)" : 3.0856776e16
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert distance operation.
|
* Convert distance operation.
|
||||||
*
|
*
|
||||||
|
@ -67,13 +67,13 @@ var Convert = {
|
||||||
run_distance: function (input, args) {
|
run_distance: function (input, args) {
|
||||||
var input_units = args[0],
|
var input_units = args[0],
|
||||||
output_units = args[1];
|
output_units = args[1];
|
||||||
|
|
||||||
input = input * Convert.DISTANCE_FACTOR[input_units];
|
input = input * Convert.DISTANCE_FACTOR[input_units];
|
||||||
return input / Convert.DISTANCE_FACTOR[output_units];
|
return input / Convert.DISTANCE_FACTOR[output_units];
|
||||||
// TODO Remove rounding errors (e.g. 1.000000000001)
|
// TODO Remove rounding errors (e.g. 1.000000000001)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
|
@ -94,7 +94,7 @@ var Convert = {
|
||||||
"Nibbles" : 4,
|
"Nibbles" : 4,
|
||||||
"Octets" : 8,
|
"Octets" : 8,
|
||||||
"Bytes (B)" : 8,
|
"Bytes (B)" : 8,
|
||||||
|
|
||||||
// Binary bits (2^n)
|
// Binary bits (2^n)
|
||||||
"Kibibits (Kib)" : 1024,
|
"Kibibits (Kib)" : 1024,
|
||||||
"Mebibits (Mib)" : 1048576,
|
"Mebibits (Mib)" : 1048576,
|
||||||
|
@ -104,7 +104,7 @@ var Convert = {
|
||||||
"Exbibits (Eib)" : 1152921504606846976,
|
"Exbibits (Eib)" : 1152921504606846976,
|
||||||
"Zebibits (Zib)" : 1180591620717411303424,
|
"Zebibits (Zib)" : 1180591620717411303424,
|
||||||
"Yobibits (Yib)" : 1208925819614629174706176,
|
"Yobibits (Yib)" : 1208925819614629174706176,
|
||||||
|
|
||||||
// Decimal bits (10^n)
|
// Decimal bits (10^n)
|
||||||
"Decabits" : 10,
|
"Decabits" : 10,
|
||||||
"Hectobits" : 100,
|
"Hectobits" : 100,
|
||||||
|
@ -116,7 +116,7 @@ var Convert = {
|
||||||
"Exabits (Eb)" : 1e18,
|
"Exabits (Eb)" : 1e18,
|
||||||
"Zettabits (Zb)" : 1e21,
|
"Zettabits (Zb)" : 1e21,
|
||||||
"Yottabits (Yb)" : 1e24,
|
"Yottabits (Yb)" : 1e24,
|
||||||
|
|
||||||
// Binary bytes (8 x 2^n)
|
// Binary bytes (8 x 2^n)
|
||||||
"Kibibytes (KiB)" : 8192,
|
"Kibibytes (KiB)" : 8192,
|
||||||
"Mebibytes (MiB)" : 8388608,
|
"Mebibytes (MiB)" : 8388608,
|
||||||
|
@ -126,7 +126,7 @@ var Convert = {
|
||||||
"Exbibytes (EiB)" : 9223372036854775808,
|
"Exbibytes (EiB)" : 9223372036854775808,
|
||||||
"Zebibytes (ZiB)" : 9444732965739290427392,
|
"Zebibytes (ZiB)" : 9444732965739290427392,
|
||||||
"Yobibytes (YiB)" : 9671406556917033397649408,
|
"Yobibytes (YiB)" : 9671406556917033397649408,
|
||||||
|
|
||||||
// Decimal bytes (8 x 10^n)
|
// Decimal bytes (8 x 10^n)
|
||||||
"Kilobytes (KB)" : 8e3,
|
"Kilobytes (KB)" : 8e3,
|
||||||
"Megabytes (MB)" : 8e6,
|
"Megabytes (MB)" : 8e6,
|
||||||
|
@ -137,7 +137,7 @@ var Convert = {
|
||||||
"Zettabytes (ZB)" : 8e21,
|
"Zettabytes (ZB)" : 8e21,
|
||||||
"Yottabytes (YB)" : 8e24,
|
"Yottabytes (YB)" : 8e24,
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert data units operation.
|
* Convert data units operation.
|
||||||
*
|
*
|
||||||
|
@ -148,12 +148,12 @@ var Convert = {
|
||||||
run_data_size: function (input, args) {
|
run_data_size: function (input, args) {
|
||||||
var input_units = args[0],
|
var input_units = args[0],
|
||||||
output_units = args[1];
|
output_units = args[1];
|
||||||
|
|
||||||
input = input * Convert.DATA_FACTOR[input_units];
|
input = input * Convert.DATA_FACTOR[input_units];
|
||||||
return input / Convert.DATA_FACTOR[output_units];
|
return input / Convert.DATA_FACTOR[output_units];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
|
@ -173,13 +173,13 @@ var Convert = {
|
||||||
// Metric
|
// Metric
|
||||||
"Square metre (sq m)" : 1,
|
"Square metre (sq m)" : 1,
|
||||||
"Square kilometre (sq km)" : 1e6,
|
"Square kilometre (sq km)" : 1e6,
|
||||||
|
|
||||||
"Centiare (ca)" : 1,
|
"Centiare (ca)" : 1,
|
||||||
"Deciare (da)" : 10,
|
"Deciare (da)" : 10,
|
||||||
"Are (a)" : 100,
|
"Are (a)" : 100,
|
||||||
"Decare (daa)" : 1e3,
|
"Decare (daa)" : 1e3,
|
||||||
"Hectare (ha)" : 1e4,
|
"Hectare (ha)" : 1e4,
|
||||||
|
|
||||||
// Imperial
|
// Imperial
|
||||||
"Square inch (sq in)" : 0.00064516,
|
"Square inch (sq in)" : 0.00064516,
|
||||||
"Square foot (sq ft)" : 0.09290304,
|
"Square foot (sq ft)" : 0.09290304,
|
||||||
|
@ -188,12 +188,12 @@ var Convert = {
|
||||||
"Perch (sq per)" : 42.21,
|
"Perch (sq per)" : 42.21,
|
||||||
"Rood (ro)" : 1011,
|
"Rood (ro)" : 1011,
|
||||||
"International acre (ac)" : 4046.8564224,
|
"International acre (ac)" : 4046.8564224,
|
||||||
|
|
||||||
// US customary units
|
// US customary units
|
||||||
"US survey acre (ac)" : 4046.87261,
|
"US survey acre (ac)" : 4046.87261,
|
||||||
"US survey square mile (sq mi)" : 2589998.470305239,
|
"US survey square mile (sq mi)" : 2589998.470305239,
|
||||||
"US survey township" : 93239944.9309886,
|
"US survey township" : 93239944.9309886,
|
||||||
|
|
||||||
// Nuclear physics
|
// Nuclear physics
|
||||||
"Yoctobarn (yb)" : 1e-52,
|
"Yoctobarn (yb)" : 1e-52,
|
||||||
"Zeptobarn (zb)" : 1e-49,
|
"Zeptobarn (zb)" : 1e-49,
|
||||||
|
@ -206,18 +206,18 @@ var Convert = {
|
||||||
"Barn (b)" : 1e-28,
|
"Barn (b)" : 1e-28,
|
||||||
"Kilobarn (kb)" : 1e-25,
|
"Kilobarn (kb)" : 1e-25,
|
||||||
"Megabarn (Mb)" : 1e-22,
|
"Megabarn (Mb)" : 1e-22,
|
||||||
|
|
||||||
"Planck area" : 2.6e-70,
|
"Planck area" : 2.6e-70,
|
||||||
"Shed" : 1e-52,
|
"Shed" : 1e-52,
|
||||||
"Outhouse" : 1e-34,
|
"Outhouse" : 1e-34,
|
||||||
|
|
||||||
// Comparisons
|
// Comparisons
|
||||||
"Washington D.C." : 176119191.502848,
|
"Washington D.C." : 176119191.502848,
|
||||||
"Isle of Wight" : 380000000,
|
"Isle of Wight" : 380000000,
|
||||||
"Wales" : 20779000000,
|
"Wales" : 20779000000,
|
||||||
"Texas" : 696241000000,
|
"Texas" : 696241000000,
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert area operation.
|
* Convert area operation.
|
||||||
*
|
*
|
||||||
|
@ -228,12 +228,12 @@ var Convert = {
|
||||||
run_area: function (input, args) {
|
run_area: function (input, args) {
|
||||||
var input_units = args[0],
|
var input_units = args[0],
|
||||||
output_units = args[1];
|
output_units = args[1];
|
||||||
|
|
||||||
input = input * Convert.AREA_FACTOR[input_units];
|
input = input * Convert.AREA_FACTOR[input_units];
|
||||||
return input / Convert.AREA_FACTOR[output_units];
|
return input / Convert.AREA_FACTOR[output_units];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
|
@ -274,7 +274,7 @@ var Convert = {
|
||||||
"Exagram (Eg)" : 1e18,
|
"Exagram (Eg)" : 1e18,
|
||||||
"Zettagram (Zg)" : 1e21,
|
"Zettagram (Zg)" : 1e21,
|
||||||
"Yottagram (Yg)" : 1e24,
|
"Yottagram (Yg)" : 1e24,
|
||||||
|
|
||||||
// Imperial Avoirdupois
|
// Imperial Avoirdupois
|
||||||
"Grain (gr)" : 64.79891e-3,
|
"Grain (gr)" : 64.79891e-3,
|
||||||
"Dram (dr)" : 1.7718451953125,
|
"Dram (dr)" : 1.7718451953125,
|
||||||
|
@ -288,14 +288,14 @@ var Convert = {
|
||||||
"Imperial hundredweight (cwt)" : 50.80234544e3,
|
"Imperial hundredweight (cwt)" : 50.80234544e3,
|
||||||
"US ton (t)" : 907.18474e3,
|
"US ton (t)" : 907.18474e3,
|
||||||
"Imperial ton (t)" : 1016.0469088e3,
|
"Imperial ton (t)" : 1016.0469088e3,
|
||||||
|
|
||||||
// Imperial Troy
|
// Imperial Troy
|
||||||
"Pennyweight (dwt)" : 1.55517384,
|
"Pennyweight (dwt)" : 1.55517384,
|
||||||
"Troy dram (dr t)" : 3.8879346,
|
"Troy dram (dr t)" : 3.8879346,
|
||||||
"Troy ounce (oz t)" : 31.1034768,
|
"Troy ounce (oz t)" : 31.1034768,
|
||||||
"Troy pound (lb t)" : 373.2417216,
|
"Troy pound (lb t)" : 373.2417216,
|
||||||
"Mark" : 248.8278144,
|
"Mark" : 248.8278144,
|
||||||
|
|
||||||
// Archaic
|
// Archaic
|
||||||
"Wey" : 76.5e3,
|
"Wey" : 76.5e3,
|
||||||
"Wool wey" : 101.7e3,
|
"Wool wey" : 101.7e3,
|
||||||
|
@ -308,7 +308,7 @@ var Convert = {
|
||||||
"Gunpowder last" : 1090e3,
|
"Gunpowder last" : 1090e3,
|
||||||
"Picul" : 60.478982e3,
|
"Picul" : 60.478982e3,
|
||||||
"Rice last" : 1200e3,
|
"Rice last" : 1200e3,
|
||||||
|
|
||||||
// Comparisons
|
// Comparisons
|
||||||
"Big Ben (14 tonnes)" : 14e6,
|
"Big Ben (14 tonnes)" : 14e6,
|
||||||
"Blue whale (180 tonnes)" : 180e6,
|
"Blue whale (180 tonnes)" : 180e6,
|
||||||
|
@ -317,7 +317,7 @@ var Convert = {
|
||||||
"RMS Titanic (52,000 tonnes)" : 52000e6,
|
"RMS Titanic (52,000 tonnes)" : 52000e6,
|
||||||
"Great Pyramid of Giza (6,000,000 tonnes)" : 6e12,
|
"Great Pyramid of Giza (6,000,000 tonnes)" : 6e12,
|
||||||
"Earth's oceans (1.4 yottagrams)" : 1.4e24,
|
"Earth's oceans (1.4 yottagrams)" : 1.4e24,
|
||||||
|
|
||||||
// Astronomical
|
// Astronomical
|
||||||
"A teaspoon of neutron star (5,500 million tonnes)" : 5.5e15,
|
"A teaspoon of neutron star (5,500 million tonnes)" : 5.5e15,
|
||||||
"Lunar mass (ML)" : 7.342e25,
|
"Lunar mass (ML)" : 7.342e25,
|
||||||
|
@ -328,7 +328,7 @@ var Convert = {
|
||||||
"Milky Way galaxy (1.2 x 10^42 kgs)" : 1.2e45,
|
"Milky Way galaxy (1.2 x 10^42 kgs)" : 1.2e45,
|
||||||
"The observable universe (1.45 x 10^53 kgs)" : 1.45e56,
|
"The observable universe (1.45 x 10^53 kgs)" : 1.45e56,
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert mass operation.
|
* Convert mass operation.
|
||||||
*
|
*
|
||||||
|
@ -339,12 +339,12 @@ var Convert = {
|
||||||
run_mass: function (input, args) {
|
run_mass: function (input, args) {
|
||||||
var input_units = args[0],
|
var input_units = args[0],
|
||||||
output_units = args[1];
|
output_units = args[1];
|
||||||
|
|
||||||
input = input * Convert.MASS_FACTOR[input_units];
|
input = input * Convert.MASS_FACTOR[input_units];
|
||||||
return input / Convert.MASS_FACTOR[output_units];
|
return input / Convert.MASS_FACTOR[output_units];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
|
@ -363,11 +363,11 @@ var Convert = {
|
||||||
// Metric
|
// Metric
|
||||||
"Metres per second (m/s)" : 1,
|
"Metres per second (m/s)" : 1,
|
||||||
"Kilometres per hour (km/h)" : 0.2778,
|
"Kilometres per hour (km/h)" : 0.2778,
|
||||||
|
|
||||||
// Imperial
|
// Imperial
|
||||||
"Miles per hour (mph)" : 0.44704,
|
"Miles per hour (mph)" : 0.44704,
|
||||||
"Knots (kn)" : 0.5144,
|
"Knots (kn)" : 0.5144,
|
||||||
|
|
||||||
// Comparisons
|
// Comparisons
|
||||||
"Human hair growth rate" : 4.8e-9,
|
"Human hair growth rate" : 4.8e-9,
|
||||||
"Bamboo growth rate" : 1.4e-5,
|
"Bamboo growth rate" : 1.4e-5,
|
||||||
|
@ -378,7 +378,7 @@ var Convert = {
|
||||||
"SR-71 Blackbird" : 981,
|
"SR-71 Blackbird" : 981,
|
||||||
"Space Shuttle" : 1400,
|
"Space Shuttle" : 1400,
|
||||||
"International Space Station" : 7700,
|
"International Space Station" : 7700,
|
||||||
|
|
||||||
// Scientific
|
// Scientific
|
||||||
"Sound in standard atmosphere" : 340.3,
|
"Sound in standard atmosphere" : 340.3,
|
||||||
"Sound in water" : 1500,
|
"Sound in water" : 1500,
|
||||||
|
@ -393,7 +393,7 @@ var Convert = {
|
||||||
"Signal in an optical fibre (0.667c)" : 200000000,
|
"Signal in an optical fibre (0.667c)" : 200000000,
|
||||||
"Light (c)" : 299792458,
|
"Light (c)" : 299792458,
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert speed operation.
|
* Convert speed operation.
|
||||||
*
|
*
|
||||||
|
@ -404,9 +404,9 @@ var Convert = {
|
||||||
run_speed: function (input, args) {
|
run_speed: function (input, args) {
|
||||||
var input_units = args[0],
|
var input_units = args[0],
|
||||||
output_units = args[1];
|
output_units = args[1];
|
||||||
|
|
||||||
input = input * Convert.SPEED_FACTOR[input_units];
|
input = input * Convert.SPEED_FACTOR[input_units];
|
||||||
return input / Convert.SPEED_FACTOR[output_units];
|
return input / Convert.SPEED_FACTOR[output_units];
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,16 +30,16 @@ var DateTime = {
|
||||||
|
|
||||||
input = parseFloat(input);
|
input = parseFloat(input);
|
||||||
|
|
||||||
if (units == "Seconds (s)") {
|
if (units === "Seconds (s)") {
|
||||||
d = moment.unix(input);
|
d = moment.unix(input);
|
||||||
return d.tz("UTC").format("ddd D MMMM YYYY HH:mm:ss") + " UTC";
|
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);
|
d = moment(input);
|
||||||
return d.tz("UTC").format("ddd D MMMM YYYY HH:mm:ss.SSS") + " UTC";
|
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);
|
d = moment(input / 1000);
|
||||||
return d.tz("UTC").format("ddd D MMMM YYYY HH:mm:ss.SSS") + " UTC";
|
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);
|
d = moment(input / 1000000);
|
||||||
return d.tz("UTC").format("ddd D MMMM YYYY HH:mm:ss.SSS") + " UTC";
|
return d.tz("UTC").format("ddd D MMMM YYYY HH:mm:ss.SSS") + " UTC";
|
||||||
} else {
|
} else {
|
||||||
|
@ -59,13 +59,13 @@ var DateTime = {
|
||||||
var units = args[0],
|
var units = args[0],
|
||||||
d = moment(input);
|
d = moment(input);
|
||||||
|
|
||||||
if (units == "Seconds (s)") {
|
if (units === "Seconds (s)") {
|
||||||
return d.unix();
|
return d.unix();
|
||||||
} else if (units == "Milliseconds (ms)") {
|
} else if (units === "Milliseconds (ms)") {
|
||||||
return d.valueOf();
|
return d.valueOf();
|
||||||
} else if (units == "Microseconds (μs)") {
|
} else if (units === "Microseconds (μs)") {
|
||||||
return d.valueOf() * 1000;
|
return d.valueOf() * 1000;
|
||||||
} else if (units == "Nanoseconds (ns)") {
|
} else if (units === "Nanoseconds (ns)") {
|
||||||
return d.valueOf() * 1000000;
|
return d.valueOf() * 1000000;
|
||||||
} else {
|
} else {
|
||||||
throw "Unrecognised unit";
|
throw "Unrecognised unit";
|
||||||
|
@ -139,7 +139,7 @@ var DateTime = {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
date = moment.tz(input, input_format, input_timezone);
|
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) {
|
} catch(err) {
|
||||||
return "Invalid format.\n\n" + DateTime.FORMAT_EXAMPLES;
|
return "Invalid format.\n\n" + DateTime.FORMAT_EXAMPLES;
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ var DateTime = {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
date = moment.tz(input, input_format, input_timezone);
|
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) {
|
} catch(err) {
|
||||||
return "Invalid format.\n\n" + DateTime.FORMAT_EXAMPLES;
|
return "Invalid format.\n\n" + DateTime.FORMAT_EXAMPLES;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ var Extract = {
|
||||||
total = 0,
|
total = 0,
|
||||||
match;
|
match;
|
||||||
|
|
||||||
while (!!(match = search_regex.exec(input))) {
|
while ((match = search_regex.exec(input))) {
|
||||||
if (remove_regex && remove_regex.test(match[0]))
|
if (remove_regex && remove_regex.test(match[0]))
|
||||||
continue;
|
continue;
|
||||||
total++;
|
total++;
|
||||||
|
|
|
@ -18,28 +18,28 @@ var FileType = {
|
||||||
*/
|
*/
|
||||||
run_detect: function(input, args) {
|
run_detect: function(input, args) {
|
||||||
var type = FileType._magic_type(input);
|
var type = FileType._magic_type(input);
|
||||||
|
|
||||||
if (!type) {
|
if (!type) {
|
||||||
return "Unknown file type. Have you tried checking the entropy of this data to determine whether it might be encrypted or compressed?";
|
return "Unknown file type. Have you tried checking the entropy of this data to determine whether it might be encrypted or compressed?";
|
||||||
} else {
|
} else {
|
||||||
var output = "File extension: " + type.ext + "\n" +
|
var output = "File extension: " + type.ext + "\n" +
|
||||||
"MIME type: " + type.mime;
|
"MIME type: " + type.mime;
|
||||||
|
|
||||||
if (type.desc && type.desc.length) {
|
if (type.desc && type.desc.length) {
|
||||||
output += "\nDescription: " + type.desc;
|
output += "\nDescription: " + type.desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
IGNORE_COMMON_BYTE_SEQUENCES: true,
|
IGNORE_COMMON_BYTE_SEQUENCES: true,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan for Embedded Files operation.
|
* Scan for Embedded Files operation.
|
||||||
*
|
*
|
||||||
|
@ -54,7 +54,7 @@ var FileType = {
|
||||||
common_exts = ["ico", "ttf", ""],
|
common_exts = ["ico", "ttf", ""],
|
||||||
num_found = 0,
|
num_found = 0,
|
||||||
num_common_found = 0;
|
num_common_found = 0;
|
||||||
|
|
||||||
for (var i = 0; i < input.length; i++) {
|
for (var i = 0; i < input.length; i++) {
|
||||||
type = FileType._magic_type(input.slice(i));
|
type = FileType._magic_type(input.slice(i));
|
||||||
if (type) {
|
if (type) {
|
||||||
|
@ -66,31 +66,31 @@ var FileType = {
|
||||||
output += "\nOffset " + i + " (0x" + Utils.hex(i) + "):\n" +
|
output += "\nOffset " + i + " (0x" + Utils.hex(i) + "):\n" +
|
||||||
" File extension: " + type.ext + "\n" +
|
" File extension: " + type.ext + "\n" +
|
||||||
" MIME type: " + type.mime + "\n";
|
" MIME type: " + type.mime + "\n";
|
||||||
|
|
||||||
if (type.desc && type.desc.length) {
|
if (type.desc && type.desc.length) {
|
||||||
output += " Description: " + type.desc + "\n";
|
output += " Description: " + type.desc + "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num_found === 0) {
|
if (num_found === 0) {
|
||||||
output += "\nNo embedded files were found.";
|
output += "\nNo embedded files were found.";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num_common_found > 0) {
|
if (num_common_found > 0) {
|
||||||
output += "\n\n" + num_common_found;
|
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 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.";
|
output += " Run this operation with the 'Ignore common byte sequences' option unchecked to see details.";
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
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.
|
* extension and mime type.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
|
@ -107,416 +107,416 @@ var FileType = {
|
||||||
|
|
||||||
if (buf[0] === 0xFF && buf[1] === 0xD8 && buf[2] === 0xFF) {
|
if (buf[0] === 0xFF && buf[1] === 0xD8 && buf[2] === 0xFF) {
|
||||||
return {
|
return {
|
||||||
ext: 'jpg',
|
ext: "jpg",
|
||||||
mime: 'image/jpeg'
|
mime: "image/jpeg"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x89 && buf[1] === 0x50 && buf[2] === 0x4E && buf[3] === 0x47) {
|
if (buf[0] === 0x89 && buf[1] === 0x50 && buf[2] === 0x4E && buf[3] === 0x47) {
|
||||||
return {
|
return {
|
||||||
ext: 'png',
|
ext: "png",
|
||||||
mime: 'image/png'
|
mime: "image/png"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x47 && buf[1] === 0x49 && buf[2] === 0x46) {
|
if (buf[0] === 0x47 && buf[1] === 0x49 && buf[2] === 0x46) {
|
||||||
return {
|
return {
|
||||||
ext: 'gif',
|
ext: "gif",
|
||||||
mime: 'image/gif'
|
mime: "image/gif"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[8] === 0x57 && buf[9] === 0x45 && buf[10] === 0x42 && buf[11] === 0x50) {
|
if (buf[8] === 0x57 && buf[9] === 0x45 && buf[10] === 0x42 && buf[11] === 0x50) {
|
||||||
return {
|
return {
|
||||||
ext: 'webp',
|
ext: "webp",
|
||||||
mime: 'image/webp'
|
mime: "image/webp"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// needs to be before `tif` check
|
// 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) {
|
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 {
|
return {
|
||||||
ext: 'cr2',
|
ext: "cr2",
|
||||||
mime: 'image/x-canon-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)) {
|
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 {
|
return {
|
||||||
ext: 'tif',
|
ext: "tif",
|
||||||
mime: 'image/tiff'
|
mime: "image/tiff"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x42 && buf[1] === 0x4D) {
|
if (buf[0] === 0x42 && buf[1] === 0x4D) {
|
||||||
return {
|
return {
|
||||||
ext: 'bmp',
|
ext: "bmp",
|
||||||
mime: 'image/bmp'
|
mime: "image/bmp"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x49 && buf[1] === 0x49 && buf[2] === 0xBC) {
|
if (buf[0] === 0x49 && buf[1] === 0x49 && buf[2] === 0xBC) {
|
||||||
return {
|
return {
|
||||||
ext: 'jxr',
|
ext: "jxr",
|
||||||
mime: 'image/vnd.ms-photo'
|
mime: "image/vnd.ms-photo"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x38 && buf[1] === 0x42 && buf[2] === 0x50 && buf[3] === 0x53) {
|
if (buf[0] === 0x38 && buf[1] === 0x42 && buf[2] === 0x50 && buf[3] === 0x53) {
|
||||||
return {
|
return {
|
||||||
ext: 'psd',
|
ext: "psd",
|
||||||
mime: 'image/vnd.adobe.photoshop'
|
mime: "image/vnd.adobe.photoshop"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// needs to be before `zip` check
|
// 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) {
|
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 {
|
return {
|
||||||
ext: 'epub',
|
ext: "epub",
|
||||||
mime: 'application/epub+zip'
|
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)) {
|
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 {
|
return {
|
||||||
ext: 'zip',
|
ext: "zip",
|
||||||
mime: 'application/zip'
|
mime: "application/zip"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[257] === 0x75 && buf[258] === 0x73 && buf[259] === 0x74 && buf[260] === 0x61 && buf[261] === 0x72) {
|
if (buf[257] === 0x75 && buf[258] === 0x73 && buf[259] === 0x74 && buf[260] === 0x61 && buf[261] === 0x72) {
|
||||||
return {
|
return {
|
||||||
ext: 'tar',
|
ext: "tar",
|
||||||
mime: 'application/x-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)) {
|
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 {
|
return {
|
||||||
ext: 'rar',
|
ext: "rar",
|
||||||
mime: 'application/x-rar-compressed'
|
mime: "application/x-rar-compressed"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x1F && buf[1] === 0x8B && buf[2] === 0x8) {
|
if (buf[0] === 0x1F && buf[1] === 0x8B && buf[2] === 0x8) {
|
||||||
return {
|
return {
|
||||||
ext: 'gz',
|
ext: "gz",
|
||||||
mime: 'application/gzip'
|
mime: "application/gzip"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x42 && buf[1] === 0x5A && buf[2] === 0x68) {
|
if (buf[0] === 0x42 && buf[1] === 0x5A && buf[2] === 0x68) {
|
||||||
return {
|
return {
|
||||||
ext: 'bz2',
|
ext: "bz2",
|
||||||
mime: 'application/x-bzip2'
|
mime: "application/x-bzip2"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x37 && buf[1] === 0x7A && buf[2] === 0xBC && buf[3] === 0xAF && buf[4] === 0x27 && buf[5] === 0x1C) {
|
if (buf[0] === 0x37 && buf[1] === 0x7A && buf[2] === 0xBC && buf[3] === 0xAF && buf[4] === 0x27 && buf[5] === 0x1C) {
|
||||||
return {
|
return {
|
||||||
ext: '7z',
|
ext: "7z",
|
||||||
mime: 'application/x-7z-compressed'
|
mime: "application/x-7z-compressed"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x78 && buf[1] === 0x01) {
|
if (buf[0] === 0x78 && buf[1] === 0x01) {
|
||||||
return {
|
return {
|
||||||
ext: 'dmg',
|
ext: "dmg",
|
||||||
mime: 'application/x-apple-diskimage'
|
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)) {
|
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 {
|
return {
|
||||||
ext: 'mp4',
|
ext: "mp4",
|
||||||
mime: 'video/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)) {
|
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 {
|
return {
|
||||||
ext: 'm4v',
|
ext: "m4v",
|
||||||
mime: 'video/x-m4v'
|
mime: "video/x-m4v"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x4D && buf[1] === 0x54 && buf[2] === 0x68 && buf[3] === 0x64) {
|
if (buf[0] === 0x4D && buf[1] === 0x54 && buf[2] === 0x68 && buf[3] === 0x64) {
|
||||||
return {
|
return {
|
||||||
ext: 'mid',
|
ext: "mid",
|
||||||
mime: 'audio/midi'
|
mime: "audio/midi"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// needs to be before the `webm` check
|
// 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) {
|
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 {
|
return {
|
||||||
ext: 'mkv',
|
ext: "mkv",
|
||||||
mime: 'video/x-matroska'
|
mime: "video/x-matroska"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x1A && buf[1] === 0x45 && buf[2] === 0xDF && buf[3] === 0xA3) {
|
if (buf[0] === 0x1A && buf[1] === 0x45 && buf[2] === 0xDF && buf[3] === 0xA3) {
|
||||||
return {
|
return {
|
||||||
ext: 'webm',
|
ext: "webm",
|
||||||
mime: 'video/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) {
|
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 {
|
return {
|
||||||
ext: 'mov',
|
ext: "mov",
|
||||||
mime: 'video/quicktime'
|
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) {
|
if (buf[0] === 0x52 && buf[1] === 0x49 && buf[2] === 0x46 && buf[3] === 0x46 && buf[8] === 0x41 && buf[9] === 0x56 && buf[10] === 0x49) {
|
||||||
return {
|
return {
|
||||||
ext: 'avi',
|
ext: "avi",
|
||||||
mime: 'video/x-msvideo'
|
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) {
|
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 {
|
return {
|
||||||
ext: 'wmv',
|
ext: "wmv",
|
||||||
mime: 'video/x-ms-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 {
|
return {
|
||||||
ext: 'mpg',
|
ext: "mpg",
|
||||||
mime: 'video/mpeg'
|
mime: "video/mpeg"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((buf[0] === 0x49 && buf[1] === 0x44 && buf[2] === 0x33) || (buf[0] === 0xFF && buf[1] === 0xfb)) {
|
if ((buf[0] === 0x49 && buf[1] === 0x44 && buf[2] === 0x33) || (buf[0] === 0xFF && buf[1] === 0xfb)) {
|
||||||
return {
|
return {
|
||||||
ext: 'mp3',
|
ext: "mp3",
|
||||||
mime: 'audio/mpeg'
|
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)) {
|
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 {
|
return {
|
||||||
ext: 'm4a',
|
ext: "m4a",
|
||||||
mime: 'audio/m4a'
|
mime: "audio/m4a"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x4F && buf[1] === 0x67 && buf[2] === 0x67 && buf[3] === 0x53) {
|
if (buf[0] === 0x4F && buf[1] === 0x67 && buf[2] === 0x67 && buf[3] === 0x53) {
|
||||||
return {
|
return {
|
||||||
ext: 'ogg',
|
ext: "ogg",
|
||||||
mime: 'audio/ogg'
|
mime: "audio/ogg"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x66 && buf[1] === 0x4C && buf[2] === 0x61 && buf[3] === 0x43) {
|
if (buf[0] === 0x66 && buf[1] === 0x4C && buf[2] === 0x61 && buf[3] === 0x43) {
|
||||||
return {
|
return {
|
||||||
ext: 'flac',
|
ext: "flac",
|
||||||
mime: 'audio/x-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) {
|
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 {
|
return {
|
||||||
ext: 'wav',
|
ext: "wav",
|
||||||
mime: 'audio/x-wav'
|
mime: "audio/x-wav"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x23 && buf[1] === 0x21 && buf[2] === 0x41 && buf[3] === 0x4D && buf[4] === 0x52 && buf[5] === 0x0A) {
|
if (buf[0] === 0x23 && buf[1] === 0x21 && buf[2] === 0x41 && buf[3] === 0x4D && buf[4] === 0x52 && buf[5] === 0x0A) {
|
||||||
return {
|
return {
|
||||||
ext: 'amr',
|
ext: "amr",
|
||||||
mime: 'audio/amr'
|
mime: "audio/amr"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x25 && buf[1] === 0x50 && buf[2] === 0x44 && buf[3] === 0x46) {
|
if (buf[0] === 0x25 && buf[1] === 0x50 && buf[2] === 0x44 && buf[3] === 0x46) {
|
||||||
return {
|
return {
|
||||||
ext: 'pdf',
|
ext: "pdf",
|
||||||
mime: 'application/pdf'
|
mime: "application/pdf"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x4D && buf[1] === 0x5A) {
|
if (buf[0] === 0x4D && buf[1] === 0x5A) {
|
||||||
return {
|
return {
|
||||||
ext: 'exe',
|
ext: "exe",
|
||||||
mime: 'application/x-msdownload'
|
mime: "application/x-msdownload"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((buf[0] === 0x43 || buf[0] === 0x46) && buf[1] === 0x57 && buf[2] === 0x53) {
|
if ((buf[0] === 0x43 || buf[0] === 0x46) && buf[1] === 0x57 && buf[2] === 0x53) {
|
||||||
return {
|
return {
|
||||||
ext: 'swf',
|
ext: "swf",
|
||||||
mime: 'application/x-shockwave-flash'
|
mime: "application/x-shockwave-flash"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x7B && buf[1] === 0x5C && buf[2] === 0x72 && buf[3] === 0x74 && buf[4] === 0x66) {
|
if (buf[0] === 0x7B && buf[1] === 0x5C && buf[2] === 0x72 && buf[3] === 0x74 && buf[4] === 0x66) {
|
||||||
return {
|
return {
|
||||||
ext: 'rtf',
|
ext: "rtf",
|
||||||
mime: 'application/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) {
|
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 {
|
return {
|
||||||
ext: 'woff',
|
ext: "woff",
|
||||||
mime: 'application/font-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) {
|
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 {
|
return {
|
||||||
ext: 'woff2',
|
ext: "woff2",
|
||||||
mime: 'application/font-woff'
|
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))) {
|
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 {
|
return {
|
||||||
ext: 'eot',
|
ext: "eot",
|
||||||
mime: 'application/octet-stream'
|
mime: "application/octet-stream"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x00 && buf[1] === 0x01 && buf[2] === 0x00 && buf[3] === 0x00 && buf[4] === 0x00) {
|
if (buf[0] === 0x00 && buf[1] === 0x01 && buf[2] === 0x00 && buf[3] === 0x00 && buf[4] === 0x00) {
|
||||||
return {
|
return {
|
||||||
ext: 'ttf',
|
ext: "ttf",
|
||||||
mime: 'application/font-sfnt'
|
mime: "application/font-sfnt"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x4F && buf[1] === 0x54 && buf[2] === 0x54 && buf[3] === 0x4F && buf[4] === 0x00) {
|
if (buf[0] === 0x4F && buf[1] === 0x54 && buf[2] === 0x54 && buf[3] === 0x4F && buf[4] === 0x00) {
|
||||||
return {
|
return {
|
||||||
ext: 'otf',
|
ext: "otf",
|
||||||
mime: 'application/font-sfnt'
|
mime: "application/font-sfnt"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x00 && buf[1] === 0x00 && buf[2] === 0x01 && buf[3] === 0x00) {
|
if (buf[0] === 0x00 && buf[1] === 0x00 && buf[2] === 0x01 && buf[3] === 0x00) {
|
||||||
return {
|
return {
|
||||||
ext: 'ico',
|
ext: "ico",
|
||||||
mime: 'image/x-icon'
|
mime: "image/x-icon"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x46 && buf[1] === 0x4C && buf[2] === 0x56 && buf[3] === 0x01) {
|
if (buf[0] === 0x46 && buf[1] === 0x4C && buf[2] === 0x56 && buf[3] === 0x01) {
|
||||||
return {
|
return {
|
||||||
ext: 'flv',
|
ext: "flv",
|
||||||
mime: 'video/x-flv'
|
mime: "video/x-flv"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x25 && buf[1] === 0x21) {
|
if (buf[0] === 0x25 && buf[1] === 0x21) {
|
||||||
return {
|
return {
|
||||||
ext: 'ps',
|
ext: "ps",
|
||||||
mime: 'application/postscript'
|
mime: "application/postscript"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0xFD && buf[1] === 0x37 && buf[2] === 0x7A && buf[3] === 0x58 && buf[4] === 0x5A && buf[5] === 0x00) {
|
if (buf[0] === 0xFD && buf[1] === 0x37 && buf[2] === 0x7A && buf[3] === 0x58 && buf[4] === 0x5A && buf[5] === 0x00) {
|
||||||
return {
|
return {
|
||||||
ext: 'xz',
|
ext: "xz",
|
||||||
mime: 'application/x-xz'
|
mime: "application/x-xz"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x53 && buf[1] === 0x51 && buf[2] === 0x4C && buf[3] === 0x69) {
|
if (buf[0] === 0x53 && buf[1] === 0x51 && buf[2] === 0x4C && buf[3] === 0x69) {
|
||||||
return {
|
return {
|
||||||
ext: 'sqlite',
|
ext: "sqlite",
|
||||||
mime: 'application/x-sqlite3'
|
mime: "application/x-sqlite3"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Added by n1474335 [n1474335@gmail.com] from here on
|
// Added by n1474335 [n1474335@gmail.com] from here on
|
||||||
// ################################################################## //
|
// ################################################################## //
|
||||||
if ((buf[0] === 0x1F && buf[1] === 0x9D) || (buf[0] === 0x1F && buf[1] === 0xA0)) {
|
if ((buf[0] === 0x1F && buf[1] === 0x9D) || (buf[0] === 0x1F && buf[1] === 0xA0)) {
|
||||||
return {
|
return {
|
||||||
ext: 'z, tar.z',
|
ext: "z, tar.z",
|
||||||
mime: 'application/x-gtar'
|
mime: "application/x-gtar"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x7F && buf[1] === 0x45 && buf[2] === 0x4C && buf[3] === 0x46) {
|
if (buf[0] === 0x7F && buf[1] === 0x45 && buf[2] === 0x4C && buf[3] === 0x46) {
|
||||||
return {
|
return {
|
||||||
ext: 'none, axf, bin, elf, o, prx, puff, so',
|
ext: "none, axf, bin, elf, o, prx, puff, so",
|
||||||
mime: 'application/x-executable',
|
mime: "application/x-executable",
|
||||||
desc: 'Executable and Linkable Format file. No standard file extension.'
|
desc: "Executable and Linkable Format file. No standard file extension."
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0xCA && buf[1] === 0xFE && buf[2] === 0xBA && buf[3] === 0xBE) {
|
if (buf[0] === 0xCA && buf[1] === 0xFE && buf[2] === 0xBA && buf[3] === 0xBE) {
|
||||||
return {
|
return {
|
||||||
ext: 'class',
|
ext: "class",
|
||||||
mime: 'application/java-vm'
|
mime: "application/java-vm"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0xEF && buf[1] === 0xBB && buf[2] === 0xBF) {
|
if (buf[0] === 0xEF && buf[1] === 0xBB && buf[2] === 0xBF) {
|
||||||
return {
|
return {
|
||||||
ext: 'txt',
|
ext: "txt",
|
||||||
mime: 'text/plain',
|
mime: "text/plain",
|
||||||
desc: 'UTF-8 encoded Unicode byte order mark detected, commonly but not exclusively seen in text files.'
|
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
|
// Must be before Little-endian UTF-16 BOM
|
||||||
if (buf[0] === 0xFF && buf[1] === 0xFE && buf[2] === 0x00 && buf[3] === 0x00) {
|
if (buf[0] === 0xFF && buf[1] === 0xFE && buf[2] === 0x00 && buf[3] === 0x00) {
|
||||||
return {
|
return {
|
||||||
ext: '',
|
ext: "",
|
||||||
mime: '',
|
mime: "",
|
||||||
desc: 'Little-endian UTF-32 encoded Unicode byte order mark detected.'
|
desc: "Little-endian UTF-32 encoded Unicode byte order mark detected."
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0xFF && buf[1] === 0xFE) {
|
if (buf[0] === 0xFF && buf[1] === 0xFE) {
|
||||||
return {
|
return {
|
||||||
ext: '',
|
ext: "",
|
||||||
mime: '',
|
mime: "",
|
||||||
desc: 'Little-endian UTF-16 encoded Unicode byte order mark detected.'
|
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) ||
|
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[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)) {
|
(buf[0x9001] === 0x43 && buf[0x9002] === 0x44 && buf[0x9003] === 0x30 && buf[0x9004] === 0x30 && buf[0x9005] === 0x31)) {
|
||||||
return {
|
return {
|
||||||
ext: 'iso',
|
ext: "iso",
|
||||||
mime: 'application/octet-stream',
|
mime: "application/octet-stream",
|
||||||
desc: 'ISO 9660 CD/DVD image file'
|
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) {
|
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 {
|
return {
|
||||||
ext: 'doc, xls, ppt',
|
ext: "doc, xls, ppt",
|
||||||
mime: 'application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint',
|
mime: "application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint",
|
||||||
desc: 'Microsoft Office documents'
|
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) {
|
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 {
|
return {
|
||||||
ext: 'dex',
|
ext: "dex",
|
||||||
mime: 'application/octet-stream',
|
mime: "application/octet-stream",
|
||||||
desc: 'Dalvik Executable (Android)'
|
desc: "Dalvik Executable (Android)"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] === 0x4B && buf[1] === 0x44 && buf[2] === 0x4D) {
|
if (buf[0] === 0x4B && buf[1] === 0x44 && buf[2] === 0x4D) {
|
||||||
return {
|
return {
|
||||||
ext: 'vmdk',
|
ext: "vmdk",
|
||||||
mime: 'application/vmdk, application/x-virtualbox-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 {
|
return {
|
||||||
ext: 'crx',
|
ext: "crx",
|
||||||
mime: 'application/crx',
|
mime: "application/crx",
|
||||||
desc: 'Google Chrome extension or packaged app'
|
desc: "Google Chrome extension or packaged app"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ var HTML = {
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
CONVERT_OPTIONS: ["Named entities where possible", "Numeric entities", "Hex entities"],
|
CONVERT_OPTIONS: ["Named entities where possible", "Numeric entities", "Hex entities"],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To HTML Entity operation.
|
* To HTML Entity operation.
|
||||||
*
|
*
|
||||||
|
@ -29,12 +29,12 @@ var HTML = {
|
||||||
*/
|
*/
|
||||||
run_to_entity: function(input, args) {
|
run_to_entity: function(input, args) {
|
||||||
var convert_all = args[0],
|
var convert_all = args[0],
|
||||||
numeric = args[1] == "Numeric entities",
|
numeric = args[1] === "Numeric entities",
|
||||||
hexa = args[1] == "Hex entities";
|
hexa = args[1] === "Hex entities";
|
||||||
|
|
||||||
var charcodes = Utils.str_to_charcode(input);
|
var charcodes = Utils.str_to_charcode(input);
|
||||||
var output = "";
|
var output = "";
|
||||||
|
|
||||||
for (var i = 0; i < charcodes.length; i++) {
|
for (var i = 0; i < charcodes.length; i++) {
|
||||||
if (convert_all && numeric) {
|
if (convert_all && numeric) {
|
||||||
output += "&#" + charcodes[i] + ";";
|
output += "&#" + charcodes[i] + ";";
|
||||||
|
@ -64,8 +64,8 @@ var HTML = {
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* From HTML Entity operation.
|
* From HTML Entity operation.
|
||||||
*
|
*
|
||||||
|
@ -78,40 +78,40 @@ var HTML = {
|
||||||
output = "",
|
output = "",
|
||||||
m,
|
m,
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
while (!!(m = regex.exec(input))) {
|
while ((m = regex.exec(input))) {
|
||||||
// Add up to match
|
// Add up to match
|
||||||
for (; i < m.index;)
|
for (; i < m.index;)
|
||||||
output += input[i++];
|
output += input[i++];
|
||||||
|
|
||||||
// Add match
|
// Add match
|
||||||
var bite = HTML._entity_to_byte[m[1]];
|
var bite = HTML._entity_to_byte[m[1]];
|
||||||
if (bite) {
|
if (bite) {
|
||||||
output += Utils.chr(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. )
|
// Numeric entity (e.g. )
|
||||||
var num = m[1].slice(1,m[1].length);
|
var num = m[1].slice(1, m[1].length);
|
||||||
output += Utils.chr(parseInt(num, 10));
|
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. :)
|
// Hex entity (e.g. :)
|
||||||
var hex = m[1].slice(2,m[1].length);
|
var hex = m[1].slice(2, m[1].length);
|
||||||
output += Utils.chr(parseInt(hex, 16));
|
output += Utils.chr(parseInt(hex, 16));
|
||||||
} else {
|
} else {
|
||||||
// Not a valid entity, print as normal
|
// Not a valid entity, print as normal
|
||||||
for (; i < regex.lastIndex;)
|
for (; i < regex.lastIndex;)
|
||||||
output += input[i++];
|
output += input[i++];
|
||||||
}
|
}
|
||||||
|
|
||||||
i = regex.lastIndex;
|
i = regex.lastIndex;
|
||||||
}
|
}
|
||||||
// Add all after final match
|
// Add all after final match
|
||||||
for (; i < input.length;)
|
for (; i < input.length;)
|
||||||
output += input[i++];
|
output += input[i++];
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
|
@ -122,7 +122,7 @@ var HTML = {
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
REMOVE_LINE_BREAKS: true,
|
REMOVE_LINE_BREAKS: true,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strip HTML tags operation.
|
* Strip HTML tags operation.
|
||||||
*
|
*
|
||||||
|
@ -133,22 +133,22 @@ var HTML = {
|
||||||
run_strip_tags: function(input, args) {
|
run_strip_tags: function(input, args) {
|
||||||
var remove_indentation = args[0],
|
var remove_indentation = args[0],
|
||||||
remove_line_breaks = args[1];
|
remove_line_breaks = args[1];
|
||||||
|
|
||||||
input = Utils.strip_html_tags(input);
|
input = Utils.strip_html_tags(input);
|
||||||
|
|
||||||
if (remove_indentation) {
|
if (remove_indentation) {
|
||||||
input = input.replace(/\n[ \f\t]+/g, "\n");
|
input = input.replace(/\n[ \f\t]+/g, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remove_line_breaks) {
|
if (remove_line_breaks) {
|
||||||
input = input.replace(/^\s*\n/, "") // first line
|
input = input.replace(/^\s*\n/, "") // first line
|
||||||
.replace(/(\n\s*){2,}/g, "\n"); // all others
|
.replace(/(\n\s*){2,}/g, "\n"); // all others
|
||||||
}
|
}
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse colour code operation.
|
* Parse colour code operation.
|
||||||
*
|
*
|
||||||
|
@ -159,31 +159,31 @@ var HTML = {
|
||||||
run_parse_colour_code: function(input, args) {
|
run_parse_colour_code: function(input, args) {
|
||||||
var m = null,
|
var m = null,
|
||||||
r = 0, g = 0, b = 0, a = 1;
|
r = 0, g = 0, b = 0, a = 1;
|
||||||
|
|
||||||
// Read in the input
|
// 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
|
// Hex - #d9edf7
|
||||||
r = parseInt(m[1], 16);
|
r = parseInt(m[1], 16);
|
||||||
g = parseInt(m[2], 16);
|
g = parseInt(m[2], 16);
|
||||||
b = parseInt(m[3], 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)
|
// RGB or RGBA - rgb(217,237,247) or rgba(217,237,247,1)
|
||||||
r = parseFloat(m[1]);
|
r = parseFloat(m[1]);
|
||||||
g = parseFloat(m[2]);
|
g = parseFloat(m[2]);
|
||||||
b = parseFloat(m[3]);
|
b = parseFloat(m[3]);
|
||||||
a = m[4] ? parseFloat(m[4]) : 1;
|
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)
|
// HSL or HSLA - hsl(200, 65%, 91%) or hsla(200, 65%, 91%, 1)
|
||||||
var h_ = parseFloat(m[1]) / 360,
|
var h_ = parseFloat(m[1]) / 360,
|
||||||
s_ = parseFloat(m[2]) / 100,
|
s_ = parseFloat(m[2]) / 100,
|
||||||
l_ = parseFloat(m[3]) / 100,
|
l_ = parseFloat(m[3]) / 100,
|
||||||
rgb_ = HTML._hsl_to_rgb(h_, s_, l_);
|
rgb_ = HTML._hsl_to_rgb(h_, s_, l_);
|
||||||
|
|
||||||
r = rgb_[0];
|
r = rgb_[0];
|
||||||
g = rgb_[1];
|
g = rgb_[1];
|
||||||
b = rgb_[2];
|
b = rgb_[2];
|
||||||
a = m[4] ? parseFloat(m[4]) : 1;
|
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)
|
// CMYK - cmyk(0.12, 0.04, 0.00, 0.03)
|
||||||
var c_ = parseFloat(m[1]),
|
var c_ = parseFloat(m[1]),
|
||||||
m_ = parseFloat(m[2]),
|
m_ = parseFloat(m[2]),
|
||||||
|
@ -194,21 +194,21 @@ var HTML = {
|
||||||
g = Math.round(255 * (1 - m_) * (1 - k_));
|
g = Math.round(255 * (1 - m_) * (1 - k_));
|
||||||
b = Math.round(255 * (1 - y_) * (1 - k_));
|
b = Math.round(255 * (1 - y_) * (1 - k_));
|
||||||
}
|
}
|
||||||
|
|
||||||
var hsl_ = HTML._rgb_to_hsl(r, g, b),
|
var hsl_ = HTML._rgb_to_hsl(r, g, b),
|
||||||
h = Math.round(hsl_[0] * 360),
|
h = Math.round(hsl_[0] * 360),
|
||||||
s = Math.round(hsl_[1] * 100),
|
s = Math.round(hsl_[1] * 100),
|
||||||
l = Math.round(hsl_[2] * 100),
|
l = Math.round(hsl_[2] * 100),
|
||||||
k = 1 - Math.max(r/255, g/255, b/255),
|
k = 1 - Math.max(r/255, g/255, b/255),
|
||||||
c = (1 - r/255 - k) / (1 - k),
|
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);
|
y = (1 - b/255 - k) / (1 - k);
|
||||||
|
|
||||||
c = isNaN(c) ? "0" : c.toFixed(2);
|
c = isNaN(c) ? "0" : c.toFixed(2);
|
||||||
m = isNaN(m) ? "0" : m.toFixed(2);
|
m = isNaN(m) ? "0" : m.toFixed(2);
|
||||||
y = isNaN(y) ? "0" : y.toFixed(2);
|
y = isNaN(y) ? "0" : y.toFixed(2);
|
||||||
k = k.toFixed(2);
|
k = k.toFixed(2);
|
||||||
|
|
||||||
var hex = "#" +
|
var hex = "#" +
|
||||||
Utils.pad_left(Math.round(r).toString(16), 2) +
|
Utils.pad_left(Math.round(r).toString(16), 2) +
|
||||||
Utils.pad_left(Math.round(g).toString(16), 2) +
|
Utils.pad_left(Math.round(g).toString(16), 2) +
|
||||||
|
@ -218,9 +218,9 @@ var HTML = {
|
||||||
hsl = "hsl(" + h + ", " + s + "%, " + l + "%)",
|
hsl = "hsl(" + h + ", " + s + "%, " + l + "%)",
|
||||||
hsla = "hsla(" + h + ", " + s + "%, " + l + "%, " + a + ")",
|
hsla = "hsla(" + h + ", " + s + "%, " + l + "%, " + a + ")",
|
||||||
cmyk = "cmyk(" + c + ", " + m + ", " + y + ", " + k + ")";
|
cmyk = "cmyk(" + c + ", " + m + ", " + y + ", " + k + ")";
|
||||||
|
|
||||||
// Generate output
|
// Generate output
|
||||||
return "<div id='colorpicker' style='display: inline-block'></div>" +
|
return "<div id='colorpicker' style='display: inline-block'></div>" +
|
||||||
"Hex: " + hex + "\n" +
|
"Hex: " + hex + "\n" +
|
||||||
"RGB: " + rgb + "\n" +
|
"RGB: " + rgb + "\n" +
|
||||||
"RGBA: " + rgba + "\n" +
|
"RGBA: " + rgba + "\n" +
|
||||||
|
@ -241,9 +241,9 @@ var HTML = {
|
||||||
});\
|
});\
|
||||||
</script>";
|
</script>";
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts an HSL color value to RGB. Conversion formula
|
* Converts an HSL color value to RGB. Conversion formula
|
||||||
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
|
* 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)];
|
return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts an RGB color value to HSL. Conversion formula
|
* Converts an RGB color value to HSL. Conversion formula
|
||||||
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
|
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
|
||||||
|
@ -319,8 +319,8 @@ var HTML = {
|
||||||
|
|
||||||
return [h, s, l];
|
return [h, s, l];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lookup table to translate byte values to their HTML entity codes.
|
* Lookup table to translate byte values to their HTML entity codes.
|
||||||
*
|
*
|
||||||
|
@ -583,8 +583,8 @@ var HTML = {
|
||||||
9829 : "♥",
|
9829 : "♥",
|
||||||
9830 : "♦",
|
9830 : "♦",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lookup table to translate HTML entity codes to their byte values.
|
* Lookup table to translate HTML entity codes to their byte values.
|
||||||
*
|
*
|
||||||
|
|
|
@ -58,7 +58,7 @@ var Hexdump = {
|
||||||
Utils.pad_right(hexa, (length*(padding+1))) +
|
Utils.pad_right(hexa, (length*(padding+1))) +
|
||||||
" |" + Utils.pad_right(Utils.printable(Utils.byte_array_to_chars(buff)), buff.length) + "|\n";
|
" |" + 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";
|
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,
|
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;
|
block, line;
|
||||||
|
|
||||||
while (!!(block = regex.exec(input))) {
|
while ((block = regex.exec(input))) {
|
||||||
line = Utils.from_hex(block[1].replace(/-/g, " "));
|
line = Utils.from_hex(block[1].replace(/-/g, " "));
|
||||||
for (var i = 0; i < line.length; i++) {
|
for (var i = 0; i < line.length; i++) {
|
||||||
output.push(line[i]);
|
output.push(line[i]);
|
||||||
|
@ -89,7 +89,7 @@ var Hexdump = {
|
||||||
var width = input.indexOf("\n");
|
var width = input.indexOf("\n");
|
||||||
var w = (width - 13) / 4;
|
var w = (width - 13) / 4;
|
||||||
// w should be the specified width of the hexdump and therefore a round number
|
// 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;
|
app.options.attempt_highlight = false;
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
|
@ -118,14 +118,17 @@ var Hexdump = {
|
||||||
|
|
||||||
line = Math.floor(pos[0].end / w);
|
line = Math.floor(pos[0].end / w);
|
||||||
offset = 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;
|
pos[0].end = line*width + 10 + offset*3 - 1;
|
||||||
|
|
||||||
// Set up multiple selections for bytes
|
// Set up multiple selections for bytes
|
||||||
var start_line_num = Math.floor(pos[0].start / width);
|
var start_line_num = Math.floor(pos[0].start / width);
|
||||||
var end_line_num = Math.floor(pos[0].end / 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]);
|
pos.push(pos[0]);
|
||||||
} else {
|
} else {
|
||||||
start = pos[0].start;
|
start = pos[0].start;
|
||||||
|
|
|
@ -46,13 +46,13 @@ var IP = {
|
||||||
ipv6_range_regex = /^\s*(((?=.*::)(?!.*::[^-]+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\4)::|:\b|(?![\dA-F])))|(?!\3\4)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4}))\s*-\s*(((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\17)::|:\b|(?![\dA-F])))|(?!\16\17)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4}))\s*$/i,
|
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;
|
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);
|
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);
|
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);
|
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);
|
return IP._ipv6_hyphenated_range(match, include_network_info);
|
||||||
} else {
|
} 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.";
|
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,
|
var match,
|
||||||
output = "";
|
output = "";
|
||||||
|
|
||||||
if (!!(match = IP.IPv6_REGEX.exec(input))) {
|
if ((match = IP.IPv6_REGEX.exec(input))) {
|
||||||
var ipv6 = IP._str_to_ipv6(match[1]),
|
var ipv6 = IP._str_to_ipv6(match[1]),
|
||||||
longhand = IP._ipv6_to_str(ipv6),
|
longhand = IP._ipv6_to_str(ipv6),
|
||||||
shorthand = IP._ipv6_to_str(ipv6, true);
|
shorthand = IP._ipv6_to_str(ipv6, true);
|
||||||
|
@ -90,11 +90,11 @@ var IP = {
|
||||||
output += "Longhand: " + longhand + "\nShorthand: " + shorthand + "\n";
|
output += "Longhand: " + longhand + "\nShorthand: " + shorthand + "\n";
|
||||||
|
|
||||||
// Detect reserved addresses
|
// Detect reserved addresses
|
||||||
if (shorthand == "::") {
|
if (shorthand === "::") {
|
||||||
// Unspecified address
|
// Unspecified address
|
||||||
output += "\nUnspecified address corresponding to 0.0.0.0/32 in IPv4.";
|
output += "\nUnspecified address corresponding to 0.0.0.0/32 in IPv4.";
|
||||||
output += "\nUnspecified address range: ::/128";
|
output += "\nUnspecified address range: ::/128";
|
||||||
} else if (shorthand == "::1") {
|
} else if (shorthand === "::1") {
|
||||||
// Loopback address
|
// Loopback address
|
||||||
output += "\nLoopback address to the local host corresponding to 127.0.0.1/8 in IPv4.";
|
output += "\nLoopback address to the local host corresponding to 127.0.0.1/8 in IPv4.";
|
||||||
output += "\nLoopback addresses range: ::1/128";
|
output += "\nLoopback addresses range: ::1/128";
|
||||||
|
@ -171,18 +171,18 @@ var IP = {
|
||||||
// Benchmarking
|
// 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 += "\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";
|
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
|
// ORCHIDv1
|
||||||
output += "\nDeprecated, previously ORCHIDv1 (Overlay Routable Cryptographic Hash Identifiers).\nORCHIDv1 range: 2001:10::/28\nORCHIDv2 now uses 2001:20::/28.";
|
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
|
// ORCHIDv2
|
||||||
output += "\nORCHIDv2 (Overlay Routable Cryptographic Hash Identifiers).\nThese are non-routed IPv6 addresses used for Cryptographic Hash Identifiers.";
|
output += "\nORCHIDv2 (Overlay Routable Cryptographic Hash Identifiers).\nThese are non-routed IPv6 addresses used for Cryptographic Hash Identifiers.";
|
||||||
output += "\nORCHIDv2 range: 2001:20::/28";
|
output += "\nORCHIDv2 range: 2001:20::/28";
|
||||||
} else if (ipv6[0] == 0x2001 && ipv6[1] == 0xdb8) {
|
} else if (ipv6[0] === 0x2001 && ipv6[1] === 0xdb8) {
|
||||||
// Documentation
|
// 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 += "\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";
|
output += "\nDocumentation range: 2001:db8::/32";
|
||||||
} else if (ipv6[0] == 0x2002) {
|
} else if (ipv6[0] === 0x2002) {
|
||||||
// 6to4
|
// 6to4
|
||||||
output += "\n6to4 transition IPv6 address detected. See RFC 3056 for more details." +
|
output += "\n6to4 transition IPv6 address detected. See RFC 3056 for more details." +
|
||||||
"\n6to4 prefix range: 2002::/16";
|
"\n6to4 prefix range: 2002::/16";
|
||||||
|
@ -241,7 +241,7 @@ var IP = {
|
||||||
if (lines[i] === "") continue;
|
if (lines[i] === "") continue;
|
||||||
var ba_ip = [];
|
var ba_ip = [];
|
||||||
|
|
||||||
if (in_format == out_format) {
|
if (in_format === out_format) {
|
||||||
output += lines[i] + "\n";
|
output += lines[i] + "\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -341,7 +341,7 @@ var IP = {
|
||||||
|
|
||||||
// Parse all IPs and add to network dictionary
|
// Parse all IPs and add to network dictionary
|
||||||
for (var i = 0; i < ips.length; i++) {
|
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;
|
ip = IP._str_to_ipv4(match[1]) >>> 0;
|
||||||
network = ip & ipv4_mask;
|
network = ip & ipv4_mask;
|
||||||
|
|
||||||
|
@ -350,7 +350,7 @@ var IP = {
|
||||||
} else {
|
} else {
|
||||||
ipv4_networks[network] = [ip];
|
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]);
|
ip = IP._str_to_ipv6(match[1]);
|
||||||
network = [];
|
network = [];
|
||||||
network_str = "";
|
network_str = "";
|
||||||
|
@ -478,7 +478,7 @@ var IP = {
|
||||||
ip2[i] = ip1[i] | (~mask[i] & 0x0000FFFF);
|
ip2[i] = ip1[i] | (~mask[i] & 0x0000FFFF);
|
||||||
total_diff = (ip2[i] - ip1[i]).toString(2);
|
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++) {
|
for (var n = 0; n < total_diff.length; n++) {
|
||||||
total[i*16 + 16-(total_diff.length-n)] = total_diff[n];
|
total[i*16 + 16-(total_diff.length-n)] = total_diff[n];
|
||||||
}
|
}
|
||||||
|
@ -599,7 +599,7 @@ var IP = {
|
||||||
|
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
t = (ip2[i] - ip1[i]).toString(2);
|
t = (ip2[i] - ip1[i]).toString(2);
|
||||||
if (t != "0") {
|
if (t !== "0") {
|
||||||
for (var n = 0; n < t.length; n++) {
|
for (var n = 0; n < t.length; n++) {
|
||||||
total[i*16 + 16-(t.length-n)] = t[n];
|
total[i*16 + 16-(t.length-n)] = t[n];
|
||||||
}
|
}
|
||||||
|
@ -640,7 +640,7 @@ var IP = {
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
function parse_blocks(blocks) {
|
function parse_blocks(blocks) {
|
||||||
if (blocks.length != 4)
|
if (blocks.length !== 4)
|
||||||
throw "More than 4 blocks.";
|
throw "More than 4 blocks.";
|
||||||
|
|
||||||
var num_blocks = [];
|
var num_blocks = [];
|
||||||
|
@ -695,7 +695,7 @@ var IP = {
|
||||||
for (var i = 0; i < 8; i++) {
|
for (var i = 0; i < 8; i++) {
|
||||||
if (isNaN(num_blocks[j])) {
|
if (isNaN(num_blocks[j])) {
|
||||||
ipv6[i] = 0;
|
ipv6[i] = 0;
|
||||||
if (i == (8-num_blocks.slice(j).length)) j++;
|
if (i === (8-num_blocks.slice(j).length)) j++;
|
||||||
} else {
|
} else {
|
||||||
ipv6[i] = num_blocks[j];
|
ipv6[i] = num_blocks[j];
|
||||||
j++;
|
j++;
|
||||||
|
@ -734,7 +734,6 @@ var IP = {
|
||||||
*/
|
*/
|
||||||
_ipv6_to_str: function(ipv6, compact) {
|
_ipv6_to_str: function(ipv6, compact) {
|
||||||
var output = "",
|
var output = "",
|
||||||
skips = 0,
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
if (compact) {
|
if (compact) {
|
||||||
|
@ -756,8 +755,8 @@ var IP = {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
if (i != start) {
|
if (i !== start) {
|
||||||
output += Utils.hex(ipv6[i],1) + ":";
|
output += Utils.hex(ipv6[i], 1) + ":";
|
||||||
} else {
|
} else {
|
||||||
output += ":";
|
output += ":";
|
||||||
i = end;
|
i = end;
|
||||||
|
@ -768,10 +767,10 @@ var IP = {
|
||||||
output = ":" + output;
|
output = ":" + output;
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < 8; i++) {
|
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);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,17 +54,17 @@ var MAC = {
|
||||||
macs = input.toLowerCase().split(/[,\s\r\n]+/);
|
macs = input.toLowerCase().split(/[,\s\r\n]+/);
|
||||||
|
|
||||||
macs.forEach(function(mac) {
|
macs.forEach(function(mac) {
|
||||||
var cleanMac = mac.replace(/[:.-]+/g, ''),
|
var cleanMac = mac.replace(/[:.-]+/g, ""),
|
||||||
macHyphen = cleanMac.replace(/(.{2}(?=.))/g, '$1-'),
|
macHyphen = cleanMac.replace(/(.{2}(?=.))/g, "$1-"),
|
||||||
macColon = cleanMac.replace(/(.{2}(?=.))/g, '$1:'),
|
macColon = cleanMac.replace(/(.{2}(?=.))/g, "$1:"),
|
||||||
macCisco = cleanMac.replace(/(.{4}(?=.))/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 (no_delim) output_list.push(cleanMac);
|
||||||
if (dash_delim) output_list.push(macHyphen);
|
if (dash_delim) output_list.push(macHyphen);
|
||||||
if (colon_delim) output_list.push(macColon);
|
if (colon_delim) output_list.push(macColon);
|
||||||
if (cisco_style) output_list.push(macCisco);
|
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 (no_delim) output_list.push(cleanMac.toUpperCase());
|
||||||
if (dash_delim) output_list.push(macHyphen.toUpperCase());
|
if (dash_delim) output_list.push(macHyphen.toUpperCase());
|
||||||
if (colon_delim) output_list.push(macColon.toUpperCase());
|
if (colon_delim) output_list.push(macColon.toUpperCase());
|
||||||
|
@ -82,7 +82,7 @@ var MAC = {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Return the data as a string
|
// Return the data as a string
|
||||||
return output_list.join('\n');
|
return output_list.join("\n");
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -45,12 +45,12 @@ var OS = {
|
||||||
output = "",
|
output = "",
|
||||||
octal = null,
|
octal = null,
|
||||||
textual = null;
|
textual = null;
|
||||||
|
|
||||||
if (input.search(/\s*[0-7]{1,4}\s*/i) === 0) {
|
if (input.search(/\s*[0-7]{1,4}\s*/i) === 0) {
|
||||||
// Input is octal
|
// Input is octal
|
||||||
octal = input.match(/\s*([0-7]{1,4})\s*/i)[1];
|
octal = input.match(/\s*([0-7]{1,4})\s*/i)[1];
|
||||||
|
|
||||||
if (octal.length == 4) {
|
if (octal.length === 4) {
|
||||||
d = parseInt(octal[0], 8);
|
d = parseInt(octal[0], 8);
|
||||||
u = parseInt(octal[1], 8);
|
u = parseInt(octal[1], 8);
|
||||||
g = parseInt(octal[2], 8);
|
g = parseInt(octal[2], 8);
|
||||||
|
@ -60,26 +60,26 @@ var OS = {
|
||||||
if (octal.length > 1) g = parseInt(octal[1], 8);
|
if (octal.length > 1) g = parseInt(octal[1], 8);
|
||||||
if (octal.length > 2) o = parseInt(octal[2], 8);
|
if (octal.length > 2) o = parseInt(octal[2], 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
perms.su = d >> 2 & 0x1;
|
perms.su = d >> 2 & 0x1;
|
||||||
perms.sg = d >> 1 & 0x1;
|
perms.sg = d >> 1 & 0x1;
|
||||||
perms.sb = d & 0x1;
|
perms.sb = d & 0x1;
|
||||||
|
|
||||||
perms.ru = u >> 2 & 0x1;
|
perms.ru = u >> 2 & 0x1;
|
||||||
perms.wu = u >> 1 & 0x1;
|
perms.wu = u >> 1 & 0x1;
|
||||||
perms.eu = u & 0x1;
|
perms.eu = u & 0x1;
|
||||||
|
|
||||||
perms.rg = g >> 2 & 0x1;
|
perms.rg = g >> 2 & 0x1;
|
||||||
perms.wg = g >> 1 & 0x1;
|
perms.wg = g >> 1 & 0x1;
|
||||||
perms.eg = g & 0x1;
|
perms.eg = g & 0x1;
|
||||||
|
|
||||||
perms.ro = o >> 2 & 0x1;
|
perms.ro = o >> 2 & 0x1;
|
||||||
perms.wo = o >> 1 & 0x1;
|
perms.wo = o >> 1 & 0x1;
|
||||||
perms.eo = o & 0x1;
|
perms.eo = o & 0x1;
|
||||||
} else if (input.search(/\s*[dlpcbDrwxsStT-]{1,10}\s*/) === 0) {
|
} else if (input.search(/\s*[dlpcbDrwxsStT-]{1,10}\s*/) === 0) {
|
||||||
// Input is textual
|
// Input is textual
|
||||||
textual = input.match(/\s*([dlpcbDrwxsStT-]{1,10})\s*/)[1];
|
textual = input.match(/\s*([dlpcbDrwxsStT-]{1,10})\s*/)[1];
|
||||||
|
|
||||||
switch (textual[0]) {
|
switch (textual[0]) {
|
||||||
case "d":
|
case "d":
|
||||||
perms.d = true;
|
perms.d = true;
|
||||||
|
@ -103,9 +103,9 @@ var OS = {
|
||||||
perms.dr = true;
|
perms.dr = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (textual.length > 1) perms.ru = textual[1] == "r";
|
if (textual.length > 1) perms.ru = textual[1] === "r";
|
||||||
if (textual.length > 2) perms.wu = textual[2] == "w";
|
if (textual.length > 2) perms.wu = textual[2] === "w";
|
||||||
if (textual.length > 3) {
|
if (textual.length > 3) {
|
||||||
switch (textual[3]) {
|
switch (textual[3]) {
|
||||||
case "x":
|
case "x":
|
||||||
|
@ -120,9 +120,9 @@ var OS = {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (textual.length > 4) perms.rg = textual[4] == "r";
|
if (textual.length > 4) perms.rg = textual[4] === "r";
|
||||||
if (textual.length > 5) perms.wg = textual[5] == "w";
|
if (textual.length > 5) perms.wg = textual[5] === "w";
|
||||||
if (textual.length > 6) {
|
if (textual.length > 6) {
|
||||||
switch (textual[6]) {
|
switch (textual[6]) {
|
||||||
case "x":
|
case "x":
|
||||||
|
@ -137,9 +137,9 @@ var OS = {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (textual.length > 7) perms.ro = textual[7] == "r";
|
if (textual.length > 7) perms.ro = textual[7] === "r";
|
||||||
if (textual.length > 8) perms.wo = textual[8] == "w";
|
if (textual.length > 8) perms.wo = textual[8] === "w";
|
||||||
if (textual.length > 9) {
|
if (textual.length > 9) {
|
||||||
switch (textual[9]) {
|
switch (textual[9]) {
|
||||||
case "x":
|
case "x":
|
||||||
|
@ -157,15 +157,15 @@ var OS = {
|
||||||
} else {
|
} else {
|
||||||
return "Invalid input format.\nPlease enter the permissions in either octal (e.g. 755) or textual (e.g. drwxr-xr-x) format.";
|
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 += "Textual representation: " + OS._perms_to_str(perms);
|
||||||
output += "\nOctal representation: " + OS._perms_to_octal(perms);
|
output += "\nOctal representation: " + OS._perms_to_octal(perms);
|
||||||
|
|
||||||
// File type
|
// File type
|
||||||
if (textual) {
|
if (textual) {
|
||||||
output += "\nFile type: " + OS._ft_from_perms(perms);
|
output += "\nFile type: " + OS._ft_from_perms(perms);
|
||||||
}
|
}
|
||||||
|
|
||||||
// setuid, setgid
|
// setuid, setgid
|
||||||
if (perms.su) {
|
if (perms.su) {
|
||||||
output += "\nThe setuid flag is set";
|
output += "\nThe setuid flag is set";
|
||||||
|
@ -173,15 +173,15 @@ var OS = {
|
||||||
if (perms.sg) {
|
if (perms.sg) {
|
||||||
output += "\nThe setgid flag is set";
|
output += "\nThe setgid flag is set";
|
||||||
}
|
}
|
||||||
|
|
||||||
// sticky bit
|
// sticky bit
|
||||||
if (perms.sb) {
|
if (perms.sb) {
|
||||||
output += "\nThe sticky bit is set";
|
output += "\nThe sticky bit is set";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Permission matrix
|
// Permission matrix
|
||||||
output += "\n\n +---------+-------+-------+-------+\n" +
|
output += "\n\n +---------+-------+-------+-------+\n" +
|
||||||
" | | User | Group | Other |\n" +
|
" | | User | Group | Other |\n" +
|
||||||
" +---------+-------+-------+-------+\n" +
|
" +---------+-------+-------+-------+\n" +
|
||||||
" | Read | " + (perms.ru ? "X" : " ") + " | " + (perms.rg ? "X" : " ") + " | " + (perms.ro ? "X" : " ") + " |\n" +
|
" | Read | " + (perms.ru ? "X" : " ") + " | " + (perms.rg ? "X" : " ") + " | " + (perms.ro ? "X" : " ") + " |\n" +
|
||||||
" +---------+-------+-------+-------+\n" +
|
" +---------+-------+-------+-------+\n" +
|
||||||
|
@ -189,11 +189,11 @@ var OS = {
|
||||||
" +---------+-------+-------+-------+\n" +
|
" +---------+-------+-------+-------+\n" +
|
||||||
" | Execute | " + (perms.eu ? "X" : " ") + " | " + (perms.eg ? "X" : " ") + " | " + (perms.eo ? "X" : " ") + " |\n" +
|
" | Execute | " + (perms.eu ? "X" : " ") + " | " + (perms.eg ? "X" : " ") + " | " + (perms.eo ? "X" : " ") + " |\n" +
|
||||||
" +---------+-------+-------+-------+\n";
|
" +---------+-------+-------+-------+\n";
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a permissions object dictionary, generates a textual permissions string.
|
* Given a permissions object dictionary, generates a textual permissions string.
|
||||||
*
|
*
|
||||||
|
@ -204,7 +204,7 @@ var OS = {
|
||||||
_perms_to_str: function(perms) {
|
_perms_to_str: function(perms) {
|
||||||
var str = "",
|
var str = "",
|
||||||
type = "-";
|
type = "-";
|
||||||
|
|
||||||
if (perms.d) type = "d";
|
if (perms.d) type = "d";
|
||||||
if (perms.sl) type = "l";
|
if (perms.sl) type = "l";
|
||||||
if (perms.np) type = "p";
|
if (perms.np) type = "p";
|
||||||
|
@ -212,9 +212,9 @@ var OS = {
|
||||||
if (perms.cd) type = "c";
|
if (perms.cd) type = "c";
|
||||||
if (perms.bd) type = "b";
|
if (perms.bd) type = "b";
|
||||||
if (perms.dr) type = "D";
|
if (perms.dr) type = "D";
|
||||||
|
|
||||||
str = type;
|
str = type;
|
||||||
|
|
||||||
str += perms.ru ? "r" : "-";
|
str += perms.ru ? "r" : "-";
|
||||||
str += perms.wu ? "w" : "-";
|
str += perms.wu ? "w" : "-";
|
||||||
if (perms.eu && perms.su) {
|
if (perms.eu && perms.su) {
|
||||||
|
@ -226,7 +226,7 @@ var OS = {
|
||||||
} else {
|
} else {
|
||||||
str += "-";
|
str += "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
str += perms.rg ? "r" : "-";
|
str += perms.rg ? "r" : "-";
|
||||||
str += perms.wg ? "w" : "-";
|
str += perms.wg ? "w" : "-";
|
||||||
if (perms.eg && perms.sg) {
|
if (perms.eg && perms.sg) {
|
||||||
|
@ -238,7 +238,7 @@ var OS = {
|
||||||
} else {
|
} else {
|
||||||
str += "-";
|
str += "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
str += perms.ro ? "r" : "-";
|
str += perms.ro ? "r" : "-";
|
||||||
str += perms.wo ? "w" : "-";
|
str += perms.wo ? "w" : "-";
|
||||||
if (perms.eo && perms.sb) {
|
if (perms.eo && perms.sb) {
|
||||||
|
@ -250,11 +250,11 @@ var OS = {
|
||||||
} else {
|
} else {
|
||||||
str += "-";
|
str += "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a permissions object dictionary, generates an octal permissions string.
|
* Given a permissions object dictionary, generates an octal permissions string.
|
||||||
*
|
*
|
||||||
|
@ -267,27 +267,27 @@ var OS = {
|
||||||
u = 0,
|
u = 0,
|
||||||
g = 0,
|
g = 0,
|
||||||
o = 0;
|
o = 0;
|
||||||
|
|
||||||
if (perms.su) d += 4;
|
if (perms.su) d += 4;
|
||||||
if (perms.sg) d += 2;
|
if (perms.sg) d += 2;
|
||||||
if (perms.sb) d += 1;
|
if (perms.sb) d += 1;
|
||||||
|
|
||||||
if (perms.ru) u += 4;
|
if (perms.ru) u += 4;
|
||||||
if (perms.wu) u += 2;
|
if (perms.wu) u += 2;
|
||||||
if (perms.eu) u += 1;
|
if (perms.eu) u += 1;
|
||||||
|
|
||||||
if (perms.rg) g += 4;
|
if (perms.rg) g += 4;
|
||||||
if (perms.wg) g += 2;
|
if (perms.wg) g += 2;
|
||||||
if (perms.eg) g += 1;
|
if (perms.eg) g += 1;
|
||||||
|
|
||||||
if (perms.ro) o += 4;
|
if (perms.ro) o += 4;
|
||||||
if (perms.wo) o += 2;
|
if (perms.wo) o += 2;
|
||||||
if (perms.eo) o += 1;
|
if (perms.eo) o += 1;
|
||||||
|
|
||||||
return d.toString() + u.toString() + g.toString() + o.toString();
|
return d.toString() + u.toString() + g.toString() + o.toString();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a permissions object dictionary, returns the file type.
|
* Given a permissions object dictionary, returns the file type.
|
||||||
*
|
*
|
||||||
|
@ -305,5 +305,5 @@ var OS = {
|
||||||
if (perms.dr) return "Door";
|
if (perms.dr) return "Door";
|
||||||
return "Regular file";
|
return "Regular file";
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -81,7 +81,7 @@ var QuotedPrintable = {
|
||||||
|
|
||||||
for (var i = 0, len = str.length; i < len; i++) {
|
for (var i = 0, len = str.length; i < len; i++) {
|
||||||
chr = str.charAt(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);
|
buffer[bufferPos++] = parseInt(hex, 16);
|
||||||
i += 2;
|
i += 2;
|
||||||
continue;
|
continue;
|
||||||
|
@ -137,9 +137,9 @@ var QuotedPrintable = {
|
||||||
for (var i = ranges.length - 1; i >= 0; i--) {
|
for (var i = ranges.length - 1; i >= 0; i--) {
|
||||||
if (!ranges[i].length)
|
if (!ranges[i].length)
|
||||||
continue;
|
continue;
|
||||||
if (ranges[i].length == 1 && nr == ranges[i][0])
|
if (ranges[i].length === 1 && nr === ranges[i][0])
|
||||||
return true;
|
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 true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -161,7 +161,7 @@ var QuotedPrintable = {
|
||||||
|
|
||||||
encoding = (encoding || "base64").toString().toLowerCase().trim();
|
encoding = (encoding || "base64").toString().toLowerCase().trim();
|
||||||
|
|
||||||
if (encoding == "qp") {
|
if (encoding === "qp") {
|
||||||
return this._addQPSoftLinebreaks(str, lineLengthMax);
|
return this._addQPSoftLinebreaks(str, lineLengthMax);
|
||||||
} else {
|
} else {
|
||||||
return this._addBase64SoftLinebreaks(str, lineLengthMax);
|
return this._addBase64SoftLinebreaks(str, lineLengthMax);
|
||||||
|
@ -208,7 +208,7 @@ var QuotedPrintable = {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.substr(-1) == "\n") {
|
if (line.substr(-1) === "\n") {
|
||||||
// nothing to change here
|
// nothing to change here
|
||||||
result += line;
|
result += line;
|
||||||
pos += line.length;
|
pos += line.length;
|
||||||
|
@ -222,7 +222,7 @@ var QuotedPrintable = {
|
||||||
} else if (line.length > lineLengthMax - lineMargin && (match = line.substr(-lineMargin).match(/[ \t\.,!\?][^ \t\.,!\?]*$/))) {
|
} else if (line.length > lineLengthMax - lineMargin && (match = line.substr(-lineMargin).match(/[ \t\.,!\?][^ \t\.,!\?]*$/))) {
|
||||||
// truncate to nearest space
|
// truncate to nearest space
|
||||||
line = line.substr(0, line.length - (match[0].length - 1));
|
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);
|
line = line.substr(0, line.length - 1);
|
||||||
} else {
|
} else {
|
||||||
if (line.match(/\=[\da-f]{0,2}$/i)) {
|
if (line.match(/\=[\da-f]{0,2}$/i)) {
|
||||||
|
@ -249,10 +249,10 @@ var QuotedPrintable = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pos + line.length < len && line.substr(-1) != "\n") {
|
if (pos + line.length < len && line.substr(-1) !== "\n") {
|
||||||
if (line.length == 76 && line.match(/\=[\da-f]{2}$/i)) {
|
if (line.length === 76 && line.match(/\=[\da-f]{2}$/i)) {
|
||||||
line = line.substr(0, line.length - 3);
|
line = line.substr(0, line.length - 3);
|
||||||
} else if (line.length == 76) {
|
} else if (line.length === 76) {
|
||||||
line = line.substr(0, line.length - 1);
|
line = line.substr(0, line.length - 1);
|
||||||
}
|
}
|
||||||
pos += line.length;
|
pos += line.length;
|
||||||
|
|
|
@ -91,7 +91,7 @@ var Rotate = {
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
ROT13_UPPERCASE: true,
|
ROT13_UPPERCASE: true,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ROT13 operation.
|
* ROT13 operation.
|
||||||
*
|
*
|
||||||
|
@ -124,8 +124,44 @@ var Rotate = {
|
||||||
}
|
}
|
||||||
return output;
|
return output;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constant
|
||||||
|
* @default
|
||||||
|
*/
|
||||||
|
ROT47_AMOUNT: 47,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ROT47 operation.
|
||||||
|
*
|
||||||
|
* @author Matt C [matt@artemisbot.pw]
|
||||||
|
* @param {byte_array} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {byte_array}
|
||||||
|
*/
|
||||||
|
run_rot47: function(input, args) {
|
||||||
|
var amount = args[0],
|
||||||
|
output = input,
|
||||||
|
chr;
|
||||||
|
|
||||||
|
if (amount) {
|
||||||
|
if (amount < 0) {
|
||||||
|
amount = 94 - (Math.abs(amount) % 94);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < input.length; i++) {
|
||||||
|
chr = input[i];
|
||||||
|
if (chr >= 33 && chr <= 126) {
|
||||||
|
chr = (chr - 33 + amount) % 94;
|
||||||
|
output[i] = chr + 33;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rotate right bitwise op.
|
* Rotate right bitwise op.
|
||||||
*
|
*
|
||||||
|
|
|
@ -38,11 +38,11 @@ var SeqUtils = {
|
||||||
order = args[2],
|
order = args[2],
|
||||||
sorted = input.split(delim);
|
sorted = input.split(delim);
|
||||||
|
|
||||||
if (order == "Alphabetical (case sensitive)") {
|
if (order === "Alphabetical (case sensitive)") {
|
||||||
sorted = sorted.sort();
|
sorted = sorted.sort();
|
||||||
} else if (order == "Alphabetical (case insensitive)") {
|
} else if (order === "Alphabetical (case insensitive)") {
|
||||||
sorted = sorted.sort(SeqUtils._case_insensitive_sort);
|
sorted = sorted.sort(SeqUtils._case_insensitive_sort);
|
||||||
} else if (order == "IP address") {
|
} else if (order === "IP address") {
|
||||||
sorted = sorted.sort(SeqUtils._ip_sort);
|
sorted = sorted.sort(SeqUtils._ip_sort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ var SeqUtils = {
|
||||||
var search = args[0].string,
|
var search = args[0].string,
|
||||||
type = args[0].option;
|
type = args[0].option;
|
||||||
|
|
||||||
if (type == "Regex" && search) {
|
if (type === "Regex" && search) {
|
||||||
try {
|
try {
|
||||||
var regex = new RegExp(search, "gi"),
|
var regex = new RegExp(search, "gi"),
|
||||||
matches = input.match(regex);
|
matches = input.match(regex);
|
||||||
|
@ -114,12 +114,12 @@ var SeqUtils = {
|
||||||
* @returns {byte_array}
|
* @returns {byte_array}
|
||||||
*/
|
*/
|
||||||
run_reverse: function (input, args) {
|
run_reverse: function (input, args) {
|
||||||
if (args[0] == "Line") {
|
if (args[0] === "Line") {
|
||||||
var lines = [],
|
var lines = [],
|
||||||
line = [],
|
line = [],
|
||||||
result = [];
|
result = [];
|
||||||
for (var i = 0; i < input.length; i++) {
|
for (var i = 0; i < input.length; i++) {
|
||||||
if (input[i] == 0x0a) {
|
if (input[i] === 0x0a) {
|
||||||
lines.push(line);
|
lines.push(line);
|
||||||
line = [];
|
line = [];
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -108,7 +108,7 @@ var StrUtils = {
|
||||||
if (i) modifiers += "i";
|
if (i) modifiers += "i";
|
||||||
if (m) modifiers += "m";
|
if (m) modifiers += "m";
|
||||||
|
|
||||||
if (user_regex && user_regex != "^" && user_regex != "$") {
|
if (user_regex && user_regex !== "^" && user_regex !== "$") {
|
||||||
try {
|
try {
|
||||||
var regex = new RegExp(user_regex, modifiers);
|
var regex = new RegExp(user_regex, modifiers);
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ var StrUtils = {
|
||||||
if (i) modifiers += "i";
|
if (i) modifiers += "i";
|
||||||
if (m) modifiers += "m";
|
if (m) modifiers += "m";
|
||||||
|
|
||||||
if (type == "Regex") {
|
if (type === "Regex") {
|
||||||
find = new RegExp(find, modifiers);
|
find = new RegExp(find, modifiers);
|
||||||
} else if (type.indexOf("Extended") === 0) {
|
} else if (type.indexOf("Extended") === 0) {
|
||||||
find = Utils.parse_escaped_chars(find);
|
find = Utils.parse_escaped_chars(find);
|
||||||
|
@ -291,7 +291,7 @@ var StrUtils = {
|
||||||
output = "",
|
output = "",
|
||||||
diff;
|
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?";
|
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
|
// Loop through each sample to see if the chars are the same
|
||||||
for (s = 1; s < samples.length; s++) {
|
for (s = 1; s < samples.length; s++) {
|
||||||
if (samples[s][i] != chr) {
|
if (samples[s][i] !== chr) {
|
||||||
match = false;
|
match = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -390,26 +390,26 @@ var StrUtils = {
|
||||||
for (s = 0; s < samples.length; s++) {
|
for (s = 0; s < samples.length; s++) {
|
||||||
if (samples[s].length <= i) {
|
if (samples[s].length <= i) {
|
||||||
if (in_match) outputs[s] += "</span>";
|
if (in_match) outputs[s] += "</span>";
|
||||||
if (s == samples.length - 1) in_match = false;
|
if (s === samples.length - 1) in_match = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match && !in_match) {
|
if (match && !in_match) {
|
||||||
outputs[s] += "<span class='hlgreen'>" + Utils.escape_html(samples[s][i]);
|
outputs[s] += "<span class='hlgreen'>" + Utils.escape_html(samples[s][i]);
|
||||||
if (samples[s].length == i + 1) outputs[s] += "</span>";
|
if (samples[s].length === i + 1) outputs[s] += "</span>";
|
||||||
if (s == samples.length - 1) in_match = true;
|
if (s === samples.length - 1) in_match = true;
|
||||||
} else if (!match && in_match) {
|
} else if (!match && in_match) {
|
||||||
outputs[s] += "</span>" + Utils.escape_html(samples[s][i]);
|
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 {
|
} else {
|
||||||
outputs[s] += Utils.escape_html(samples[s][i]);
|
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>";
|
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>";
|
if (in_match) outputs[s] += "</span>";
|
||||||
outputs[s] += Utils.escape_html(samples[s].substring(i + 1));
|
outputs[s] += Utils.escape_html(samples[s].substring(i + 1));
|
||||||
}
|
}
|
||||||
|
@ -448,7 +448,7 @@ var StrUtils = {
|
||||||
i = 0,
|
i = 0,
|
||||||
total = 0;
|
total = 0;
|
||||||
|
|
||||||
while (!!(m = regex.exec(input))) {
|
while ((m = regex.exec(input))) {
|
||||||
// Add up to match
|
// Add up to match
|
||||||
output += Utils.escape_html(input.slice(i, m.index));
|
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>";
|
output += "<span class='hl"+hl+"'>" + Utils.escape_html(m[0]) + "</span>";
|
||||||
|
|
||||||
// Switch highlight
|
// Switch highlight
|
||||||
hl = hl == 1 ? 2 : 1;
|
hl = hl === 1 ? 2 : 1;
|
||||||
|
|
||||||
i = regex.lastIndex;
|
i = regex.lastIndex;
|
||||||
total++;
|
total++;
|
||||||
|
@ -488,7 +488,7 @@ var StrUtils = {
|
||||||
total = 0,
|
total = 0,
|
||||||
match;
|
match;
|
||||||
|
|
||||||
while (!!(match = regex.exec(input))) {
|
while ((match = regex.exec(input))) {
|
||||||
total++;
|
total++;
|
||||||
if (matches) {
|
if (matches) {
|
||||||
output += match[0] + "\n";
|
output += match[0] + "\n";
|
||||||
|
|
|
@ -121,7 +121,7 @@ var Tidy = {
|
||||||
line = [];
|
line = [];
|
||||||
|
|
||||||
for (var i = 0; i < input.length; i++) {
|
for (var i = 0; i < input.length; i++) {
|
||||||
if (input[i] == 0x0a) {
|
if (input[i] === 0x0a) {
|
||||||
lines.push(line);
|
lines.push(line);
|
||||||
line = [];
|
line = [];
|
||||||
} else {
|
} else {
|
||||||
|
@ -173,7 +173,7 @@ var Tidy = {
|
||||||
line = [];
|
line = [];
|
||||||
|
|
||||||
for (var i = 0; i < input.length; i++) {
|
for (var i = 0; i < input.length; i++) {
|
||||||
if (input[i] == 0x0a) {
|
if (input[i] === 0x0a) {
|
||||||
lines.push(line);
|
lines.push(line);
|
||||||
line = [];
|
line = [];
|
||||||
} else {
|
} else {
|
||||||
|
@ -222,11 +222,11 @@ var Tidy = {
|
||||||
output = "",
|
output = "",
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
if (position == "Start") {
|
if (position === "Start") {
|
||||||
for (i = 0; i < lines.length; i++) {
|
for (i = 0; i < lines.length; i++) {
|
||||||
output += Utils.pad_left(lines[i], lines[i].length+len, chr) + "\n";
|
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++) {
|
for (i = 0; i < lines.length; i++) {
|
||||||
output += Utils.pad_right(lines[i], lines[i].length+len, chr) + "\n";
|
output += Utils.pad_right(lines[i], lines[i].length+len, chr) + "\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ var URL_ = {
|
||||||
|
|
||||||
if (a.protocol) {
|
if (a.protocol) {
|
||||||
var output = "";
|
var output = "";
|
||||||
if (a.hostname != window.location.hostname) {
|
if (a.hostname !== window.location.hostname) {
|
||||||
output = "Protocol:\t" + a.protocol + "\n";
|
output = "Protocol:\t" + a.protocol + "\n";
|
||||||
if (a.hostname) output += "Hostname:\t" + a.hostname + "\n";
|
if (a.hostname) output += "Hostname:\t" + a.hostname + "\n";
|
||||||
if (a.port) output += "Port:\t\t" + a.port + "\n";
|
if (a.port) output += "Port:\t\t" + a.port + "\n";
|
||||||
|
|
|
@ -17,7 +17,7 @@ var UUID = {
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
run_generate_v4: function(input, args) {
|
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),
|
var buf = new Uint32Array(4),
|
||||||
i = 0;
|
i = 0;
|
||||||
window.crypto.getRandomValues(buf);
|
window.crypto.getRandomValues(buf);
|
||||||
|
|
|
@ -29,7 +29,7 @@ var Unicode = {
|
||||||
m,
|
m,
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
while (!!(m = regex.exec(input))) {
|
while ((m = regex.exec(input))) {
|
||||||
// Add up to match
|
// Add up to match
|
||||||
output += input.slice(i, m.index);
|
output += input.slice(i, m.index);
|
||||||
i = m.index;
|
i = m.index;
|
||||||
|
|
|
@ -65,7 +65,7 @@ ControlsWaiter.prototype.adjust_width = function() {
|
||||||
ControlsWaiter.prototype.set_auto_bake = function(value) {
|
ControlsWaiter.prototype.set_auto_bake = function(value) {
|
||||||
var auto_bake_checkbox = document.getElementById("auto-bake");
|
var auto_bake_checkbox = document.getElementById("auto-bake");
|
||||||
|
|
||||||
if (auto_bake_checkbox.checked != value) {
|
if (auto_bake_checkbox.checked !== value) {
|
||||||
auto_bake_checkbox.click();
|
auto_bake_checkbox.click();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -138,9 +138,7 @@ ControlsWaiter.prototype.clear_breaks_click = function() {
|
||||||
ControlsWaiter.prototype.initialise_save_link = function(recipe_config) {
|
ControlsWaiter.prototype.initialise_save_link = function(recipe_config) {
|
||||||
recipe_config = recipe_config || this.app.get_recipe_config();
|
recipe_config = recipe_config || this.app.get_recipe_config();
|
||||||
|
|
||||||
var recipe_str = JSON.stringify(recipe_config),
|
var include_recipe = document.getElementById("save-link-recipe-checkbox").checked,
|
||||||
input_str = Utils.to_base64(this.app.get_input()),
|
|
||||||
include_recipe = document.getElementById("save-link-recipe-checkbox").checked,
|
|
||||||
include_input = document.getElementById("save-link-input-checkbox").checked,
|
include_input = document.getElementById("save-link-input-checkbox").checked,
|
||||||
save_link_el = document.getElementById("save-link"),
|
save_link_el = document.getElementById("save-link"),
|
||||||
save_link = this.generate_state_url(include_recipe, include_input, recipe_config);
|
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() {
|
ControlsWaiter.prototype.save_click = function() {
|
||||||
var recipe_config = this.app.get_recipe_config();
|
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;
|
document.getElementById("save-text").value = recipe_str;
|
||||||
|
|
||||||
this.initialise_save_link(recipe_config);
|
this.initialise_save_link(recipe_config);
|
||||||
|
@ -300,7 +298,7 @@ ControlsWaiter.prototype.load_delete_click = function() {
|
||||||
JSON.parse(localStorage.saved_recipes) : [];
|
JSON.parse(localStorage.saved_recipes) : [];
|
||||||
|
|
||||||
saved_recipes = saved_recipes.filter(function(r) {
|
saved_recipes = saved_recipes.filter(function(r) {
|
||||||
return r.id != id;
|
return r.id !== id;
|
||||||
});
|
});
|
||||||
|
|
||||||
localStorage.saved_recipes = JSON.stringify(saved_recipes);
|
localStorage.saved_recipes = JSON.stringify(saved_recipes);
|
||||||
|
@ -318,7 +316,7 @@ ControlsWaiter.prototype.load_name_change = function(e) {
|
||||||
id = parseInt(el.value, 10);
|
id = parseInt(el.value, 10);
|
||||||
|
|
||||||
var recipe = saved_recipes.filter(function(r) {
|
var recipe = saved_recipes.filter(function(r) {
|
||||||
return r.id == id;
|
return r.id === id;
|
||||||
})[0];
|
})[0];
|
||||||
|
|
||||||
document.getElementById("load-text").value = recipe.recipe;
|
document.getElementById("load-text").value = recipe.recipe;
|
||||||
|
|
|
@ -20,14 +20,14 @@ var HTMLApp = function(categories, operations, default_favourites, default_optio
|
||||||
this.dfavourites = default_favourites;
|
this.dfavourites = default_favourites;
|
||||||
this.doptions = default_options;
|
this.doptions = default_options;
|
||||||
this.options = Utils.extend({}, default_options);
|
this.options = Utils.extend({}, default_options);
|
||||||
|
|
||||||
this.chef = new Chef();
|
this.chef = new Chef();
|
||||||
this.manager = new Manager(this);
|
this.manager = new Manager(this);
|
||||||
|
|
||||||
this.auto_bake_ = false;
|
this.auto_bake_ = false;
|
||||||
this.progress = 0;
|
this.progress = 0;
|
||||||
this.ing_id = 0;
|
this.ing_id = 0;
|
||||||
|
|
||||||
window.chef = this.chef;
|
window.chef = this.chef;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ HTMLApp.prototype.handle_error = function(err) {
|
||||||
*/
|
*/
|
||||||
HTMLApp.prototype.bake = function(step) {
|
HTMLApp.prototype.bake = function(step) {
|
||||||
var response;
|
var response;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
response = this.chef.bake(
|
response = this.chef.bake(
|
||||||
this.get_input(), // The user's input
|
this.get_input(), // The user's input
|
||||||
|
@ -80,24 +80,25 @@ HTMLApp.prototype.bake = function(step) {
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.handle_error(err);
|
this.handle_error(err);
|
||||||
} finally {
|
}
|
||||||
if (!response) return;
|
|
||||||
|
if (!response) return;
|
||||||
if (response.error) {
|
|
||||||
this.handle_error(response.error);
|
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.options = response.options;
|
||||||
this.manager.recipe.update_breakpoint_indicator(response.progress);
|
this.dish_str = response.type === "html" ? Utils.strip_html_tags(response.result, true) : response.result;
|
||||||
this.manager.output.set(response.result, response.type, response.duration);
|
this.progress = response.progress;
|
||||||
|
this.manager.recipe.update_breakpoint_indicator(response.progress);
|
||||||
// If baking took too long, disable auto-bake
|
this.manager.output.set(response.result, response.type, response.duration);
|
||||||
if (response.duration > this.options.auto_bake_threshold && this.auto_bake_) {
|
|
||||||
this.manager.controls.set_auto_bake(false);
|
// If baking took too long, disable auto-bake
|
||||||
this.alert("Baking took longer than " + this.options.auto_bake_threshold +
|
if (response.duration > this.options.auto_bake_threshold && this.auto_bake_) {
|
||||||
"ms, Auto Bake has been disabled.", "warning", 5000);
|
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() {
|
HTMLApp.prototype.silent_bake = function() {
|
||||||
var start_time = new Date().getTime(),
|
var start_time = new Date().getTime(),
|
||||||
recipe_config = this.get_recipe_config();
|
recipe_config = this.get_recipe_config();
|
||||||
|
|
||||||
if (this.auto_bake_) {
|
if (this.auto_bake_) {
|
||||||
this.chef.silent_bake(recipe_config);
|
this.chef.silent_bake(recipe_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Date().getTime() - start_time;
|
return new Date().getTime() - start_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -140,11 +141,11 @@ HTMLApp.prototype.silent_bake = function() {
|
||||||
*/
|
*/
|
||||||
HTMLApp.prototype.get_input = function() {
|
HTMLApp.prototype.get_input = function() {
|
||||||
var input = this.manager.input.get();
|
var input = this.manager.input.get();
|
||||||
|
|
||||||
// Save to session storage in case we need to restore it later
|
// Save to session storage in case we need to restore it later
|
||||||
sessionStorage.setItem("input_length", input.length);
|
sessionStorage.setItem("input_length", input.length);
|
||||||
sessionStorage.setItem("input", input);
|
sessionStorage.setItem("input", input);
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -170,31 +171,31 @@ HTMLApp.prototype.set_input = function(input) {
|
||||||
HTMLApp.prototype.populate_operations_list = function() {
|
HTMLApp.prototype.populate_operations_list = function() {
|
||||||
// Move edit button away before we overwrite it
|
// Move edit button away before we overwrite it
|
||||||
document.body.appendChild(document.getElementById("edit-favourites"));
|
document.body.appendChild(document.getElementById("edit-favourites"));
|
||||||
|
|
||||||
var html = "";
|
var html = "";
|
||||||
|
|
||||||
for (var i = 0; i < this.categories.length; i++) {
|
for (var i = 0; i < this.categories.length; i++) {
|
||||||
var cat_conf = this.categories[i],
|
var cat_conf = this.categories[i],
|
||||||
selected = i === 0,
|
selected = i === 0,
|
||||||
cat = new HTMLCategory(cat_conf.name, selected);
|
cat = new HTMLCategory(cat_conf.name, selected);
|
||||||
|
|
||||||
for (var j = 0; j < cat_conf.ops.length; j++) {
|
for (var j = 0; j < cat_conf.ops.length; j++) {
|
||||||
var op_name = cat_conf.ops[j],
|
var op_name = cat_conf.ops[j],
|
||||||
op = new HTMLOperation(op_name, this.operations[op_name], this, this.manager);
|
op = new HTMLOperation(op_name, this.operations[op_name], this, this.manager);
|
||||||
cat.add_operation(op);
|
cat.add_operation(op);
|
||||||
}
|
}
|
||||||
|
|
||||||
html += cat.to_html();
|
html += cat.to_html();
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById("categories").innerHTML = html;
|
document.getElementById("categories").innerHTML = html;
|
||||||
|
|
||||||
var op_lists = document.querySelectorAll("#categories .op_list");
|
var op_lists = document.querySelectorAll("#categories .op_list");
|
||||||
|
|
||||||
for (i = 0; i < op_lists.length; i++) {
|
for (i = 0; i < op_lists.length; i++) {
|
||||||
op_lists[i].dispatchEvent(this.manager.oplistcreate);
|
op_lists[i].dispatchEvent(this.manager.oplistcreate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add edit button to first category (Favourites)
|
// Add edit button to first category (Favourites)
|
||||||
document.querySelector("#categories a").appendChild(document.getElementById("edit-favourites"));
|
document.querySelector("#categories a").appendChild(document.getElementById("edit-favourites"));
|
||||||
};
|
};
|
||||||
|
@ -210,12 +211,12 @@ HTMLApp.prototype.initialise_splitter = function() {
|
||||||
gutterSize: 4,
|
gutterSize: 4,
|
||||||
onDrag: this.manager.controls.adjust_width.bind(this.manager.controls)
|
onDrag: this.manager.controls.adjust_width.bind(this.manager.controls)
|
||||||
});
|
});
|
||||||
|
|
||||||
Split(["#input", "#output"], {
|
Split(["#input", "#output"], {
|
||||||
direction: "vertical",
|
direction: "vertical",
|
||||||
gutterSize: 4,
|
gutterSize: 4,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.reset_layout();
|
this.reset_layout();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -231,7 +232,7 @@ HTMLApp.prototype.load_local_storage = function() {
|
||||||
l_options = JSON.parse(localStorage.options);
|
l_options = JSON.parse(localStorage.options);
|
||||||
}
|
}
|
||||||
this.manager.options.load(l_options);
|
this.manager.options.load(l_options);
|
||||||
|
|
||||||
// Load favourites
|
// Load favourites
|
||||||
this.load_favourites();
|
this.load_favourites();
|
||||||
};
|
};
|
||||||
|
@ -247,14 +248,14 @@ HTMLApp.prototype.load_favourites = function() {
|
||||||
localStorage.favourites.length > 2 ?
|
localStorage.favourites.length > 2 ?
|
||||||
JSON.parse(localStorage.favourites) :
|
JSON.parse(localStorage.favourites) :
|
||||||
this.dfavourites;
|
this.dfavourites;
|
||||||
|
|
||||||
favourites = this.valid_favourites(favourites);
|
favourites = this.valid_favourites(favourites);
|
||||||
this.save_favourites(favourites);
|
this.save_favourites(favourites);
|
||||||
|
|
||||||
var fav_cat = this.categories.filter(function(c) {
|
var fav_cat = this.categories.filter(function(c) {
|
||||||
return c.name == "Favourites";
|
return c.name === "Favourites";
|
||||||
})[0];
|
})[0];
|
||||||
|
|
||||||
if (fav_cat) {
|
if (fav_cat) {
|
||||||
fav_cat.ops = favourites;
|
fav_cat.ops = favourites;
|
||||||
} else {
|
} 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
|
* 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.
|
* longer available. The user is notified if this is the case.
|
||||||
|
|
||||||
* @param {string[]} favourites - A list of the user's favourite operations
|
* @param {string[]} favourites - A list of the user's favourite operations
|
||||||
* @returns {string[]} A list of the valid favourites
|
* @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);
|
this.alert("'" + name + "' is already in your favourites", "info", 2000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
favourites.push(name);
|
favourites.push(name);
|
||||||
this.save_favourites(favourites);
|
this.save_favourites(favourites);
|
||||||
this.load_favourites();
|
this.load_favourites();
|
||||||
|
@ -339,20 +340,20 @@ HTMLApp.prototype.load_URI_params = function() {
|
||||||
if (a === "") return {};
|
if (a === "") return {};
|
||||||
var b = {};
|
var b = {};
|
||||||
for (var i = 0; i < a.length; i++) {
|
for (var i = 0; i < a.length; i++) {
|
||||||
var p = a[i].split('=');
|
var p = a[i].split("=");
|
||||||
if (p.length != 2) {
|
if (p.length !== 2) {
|
||||||
b[a[i]] = true;
|
b[a[i]] = true;
|
||||||
} else {
|
} else {
|
||||||
b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
|
b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return b;
|
return b;
|
||||||
})(window.location.search.substr(1).split('&'));
|
})(window.location.search.substr(1).split("&"));
|
||||||
|
|
||||||
// Turn off auto-bake while loading
|
// Turn off auto-bake while loading
|
||||||
var auto_bake_val = this.auto_bake_;
|
var auto_bake_val = this.auto_bake_;
|
||||||
this.auto_bake_ = false;
|
this.auto_bake_ = false;
|
||||||
|
|
||||||
// Read in recipe from query string
|
// Read in recipe from query string
|
||||||
if (this.query_string.recipe) {
|
if (this.query_string.recipe) {
|
||||||
try {
|
try {
|
||||||
|
@ -370,15 +371,15 @@ HTMLApp.prototype.load_URI_params = function() {
|
||||||
if (matched_ops.length) {
|
if (matched_ops.length) {
|
||||||
this.manager.recipe.add_operation(matched_ops[0].name);
|
this.manager.recipe.add_operation(matched_ops[0].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate search with the string
|
// Populate search with the string
|
||||||
var search = document.getElementById("search");
|
var search = document.getElementById("search");
|
||||||
|
|
||||||
search.value = this.query_string.op;
|
search.value = this.query_string.op;
|
||||||
search.dispatchEvent(new Event("search"));
|
search.dispatchEvent(new Event("search"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read in input data from query string
|
// Read in input data from query string
|
||||||
if (this.query_string.input) {
|
if (this.query_string.input) {
|
||||||
try {
|
try {
|
||||||
|
@ -386,7 +387,7 @@ HTMLApp.prototype.load_URI_params = function() {
|
||||||
this.set_input(input_data);
|
this.set_input(input_data);
|
||||||
} catch(err) {}
|
} catch(err) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore auto-bake state
|
// Restore auto-bake state
|
||||||
this.auto_bake_ = auto_bake_val;
|
this.auto_bake_ = auto_bake_val;
|
||||||
this.auto_bake();
|
this.auto_bake();
|
||||||
|
@ -423,14 +424,14 @@ HTMLApp.prototype.get_recipe_config = function() {
|
||||||
HTMLApp.prototype.set_recipe_config = function(recipe_config) {
|
HTMLApp.prototype.set_recipe_config = function(recipe_config) {
|
||||||
sessionStorage.setItem("recipe_config", JSON.stringify(recipe_config));
|
sessionStorage.setItem("recipe_config", JSON.stringify(recipe_config));
|
||||||
document.getElementById("rec_list").innerHTML = null;
|
document.getElementById("rec_list").innerHTML = null;
|
||||||
|
|
||||||
for (var i = 0; i < recipe_config.length; i++) {
|
for (var i = 0; i < recipe_config.length; i++) {
|
||||||
var item = this.manager.recipe.add_operation(recipe_config[i].op);
|
var item = this.manager.recipe.add_operation(recipe_config[i].op);
|
||||||
|
|
||||||
// Populate arguments
|
// Populate arguments
|
||||||
var args = item.querySelectorAll(".arg");
|
var args = item.querySelectorAll(".arg");
|
||||||
for (var j = 0; j < args.length; j++) {
|
for (var j = 0; j < args.length; j++) {
|
||||||
if (args[j].getAttribute("type") == "checkbox") {
|
if (args[j].getAttribute("type") === "checkbox") {
|
||||||
// checkbox
|
// checkbox
|
||||||
args[j].checked = recipe_config[i].args[j];
|
args[j].checked = recipe_config[i].args[j];
|
||||||
} else if (args[j].classList.contains("toggle-string")) {
|
} 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];
|
args[j].value = recipe_config[i].args[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set disabled and breakpoint
|
// Set disabled and breakpoint
|
||||||
if (recipe_config[i].disabled) {
|
if (recipe_config[i].disabled) {
|
||||||
item.querySelector(".disable-icon").click();
|
item.querySelector(".disable-icon").click();
|
||||||
|
@ -452,7 +453,7 @@ HTMLApp.prototype.set_recipe_config = function(recipe_config) {
|
||||||
if (recipe_config[i].breakpoint) {
|
if (recipe_config[i].breakpoint) {
|
||||||
item.querySelector(".breakpoint").click();
|
item.querySelector(".breakpoint").click();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.progress = 0;
|
this.progress = 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -467,7 +468,7 @@ HTMLApp.prototype.reset_layout = function() {
|
||||||
document.getElementById("IO").style.width = "calc(50% - 2px)";
|
document.getElementById("IO").style.width = "calc(50% - 2px)";
|
||||||
document.getElementById("input").style.height = "calc(50% - 2px)";
|
document.getElementById("input").style.height = "calc(50% - 2px)";
|
||||||
document.getElementById("output").style.height = "calc(50% - 2px)";
|
document.getElementById("output").style.height = "calc(50% - 2px)";
|
||||||
|
|
||||||
this.manager.controls.adjust_width();
|
this.manager.controls.adjust_width();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -480,12 +481,12 @@ HTMLApp.prototype.set_compile_message = function() {
|
||||||
var now = new Date(),
|
var now = new Date(),
|
||||||
time_since_compile = Utils.fuzzy_time(now.getTime() - window.compile_time),
|
time_since_compile = Utils.fuzzy_time(now.getTime() - window.compile_time),
|
||||||
compile_info = "<span style=\"font-weight: normal\">Last build: " +
|
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 !== "") {
|
if (window.compile_message !== "") {
|
||||||
compile_info += " - " + window.compile_message;
|
compile_info += " - " + window.compile_message;
|
||||||
}
|
}
|
||||||
|
|
||||||
compile_info += "</span>";
|
compile_info += "</span>";
|
||||||
document.getElementById("notice").innerHTML = compile_info;
|
document.getElementById("notice").innerHTML = compile_info;
|
||||||
};
|
};
|
||||||
|
@ -516,36 +517,36 @@ HTMLApp.prototype.set_compile_message = function() {
|
||||||
*/
|
*/
|
||||||
HTMLApp.prototype.alert = function(str, style, timeout, silent) {
|
HTMLApp.prototype.alert = function(str, style, timeout, silent) {
|
||||||
var time = new Date();
|
var time = new Date();
|
||||||
|
|
||||||
console.log("[" + time.toLocaleString() + "] " + str);
|
console.log("[" + time.toLocaleString() + "] " + str);
|
||||||
if (silent) return;
|
if (silent) return;
|
||||||
|
|
||||||
style = style || "danger";
|
style = style || "danger";
|
||||||
timeout = timeout || 0;
|
timeout = timeout || 0;
|
||||||
|
|
||||||
var alert_el = document.getElementById("alert"),
|
var alert_el = document.getElementById("alert"),
|
||||||
alert_content = document.getElementById("alert-content");
|
alert_content = document.getElementById("alert-content");
|
||||||
|
|
||||||
alert_el.classList.remove("alert-danger");
|
alert_el.classList.remove("alert-danger");
|
||||||
alert_el.classList.remove("alert-warning");
|
alert_el.classList.remove("alert-warning");
|
||||||
alert_el.classList.remove("alert-info");
|
alert_el.classList.remove("alert-info");
|
||||||
alert_el.classList.remove("alert-success");
|
alert_el.classList.remove("alert-success");
|
||||||
alert_el.classList.add("alert-" + style);
|
alert_el.classList.add("alert-" + style);
|
||||||
|
|
||||||
// If the box hasn't been closed, append to it rather than replacing
|
// If the box hasn't been closed, append to it rather than replacing
|
||||||
if (alert_el.style.display == "block") {
|
if (alert_el.style.display === "block") {
|
||||||
alert_content.innerHTML +=
|
alert_content.innerHTML +=
|
||||||
"<br><br>[" + time.toLocaleTimeString() + "] " + str;
|
"<br><br>[" + time.toLocaleTimeString() + "] " + str;
|
||||||
} else {
|
} else {
|
||||||
alert_content.innerHTML =
|
alert_content.innerHTML =
|
||||||
"[" + time.toLocaleTimeString() + "] " + str;
|
"[" + time.toLocaleTimeString() + "] " + str;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop the animation if it is in progress
|
// Stop the animation if it is in progress
|
||||||
$("#alert").stop();
|
$("#alert").stop();
|
||||||
alert_el.style.display = "block";
|
alert_el.style.display = "block";
|
||||||
alert_el.style.opacity = 1;
|
alert_el.style.opacity = 1;
|
||||||
|
|
||||||
if (timeout > 0) {
|
if (timeout > 0) {
|
||||||
clearTimeout(this.alert_timeout);
|
clearTimeout(this.alert_timeout);
|
||||||
this.alert_timeout = setTimeout(function(){
|
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-title").innerHTML = title;
|
||||||
document.getElementById("confirm-body").innerHTML = body;
|
document.getElementById("confirm-body").innerHTML = body;
|
||||||
document.getElementById("confirm-modal").style.display = "block";
|
document.getElementById("confirm-modal").style.display = "block";
|
||||||
|
|
||||||
this.confirm_closed = false;
|
this.confirm_closed = false;
|
||||||
$("#confirm-modal").modal()
|
$("#confirm-modal").modal()
|
||||||
.one("show.bs.modal", function(e) {
|
.one("show.bs.modal", function(e) {
|
||||||
|
@ -610,7 +611,7 @@ HTMLApp.prototype.alert_close_click = function() {
|
||||||
*/
|
*/
|
||||||
HTMLApp.prototype.state_change = function(e) {
|
HTMLApp.prototype.state_change = function(e) {
|
||||||
this.auto_bake();
|
this.auto_bake();
|
||||||
|
|
||||||
// Update the current history state (not creating a new one)
|
// Update the current history state (not creating a new one)
|
||||||
if (this.options.update_url) {
|
if (this.options.update_url) {
|
||||||
this.last_state_url = this.manager.controls.generate_state_url(true, true);
|
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 = data || {};
|
||||||
data_type = data_type || undefined;
|
data_type = data_type || undefined;
|
||||||
content_type = content_type || "application/json";
|
content_type = content_type || "application/json";
|
||||||
|
|
||||||
var response = null,
|
var response = null,
|
||||||
success = false;
|
success = false;
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
async: false,
|
async: false,
|
||||||
|
@ -660,7 +661,7 @@ HTMLApp.prototype.call_api = function(url, type, data, data_type, content_type)
|
||||||
response = data;
|
response = data;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
success: success,
|
success: success,
|
||||||
response: response
|
response: response
|
||||||
|
|
|
@ -32,16 +32,16 @@ var HTMLIngredient = function(config, app, manager) {
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
HTMLIngredient.prototype.to_html = function() {
|
HTMLIngredient.prototype.to_html = function() {
|
||||||
var inline = (this.type == "boolean" ||
|
var inline = (this.type === "boolean" ||
|
||||||
this.type == "number" ||
|
this.type === "number" ||
|
||||||
this.type == "option" ||
|
this.type === "option" ||
|
||||||
this.type == "short_string" ||
|
this.type === "short_string" ||
|
||||||
this.type == "binary_short_string"),
|
this.type === "binary_short_string"),
|
||||||
html = inline ? "" : "<div class='clearfix'> </div>",
|
html = inline ? "" : "<div class='clearfix'> </div>",
|
||||||
i, m;
|
i, m;
|
||||||
|
|
||||||
html += "<div class='arg-group" + (inline ? " inline-args" : "") +
|
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>";
|
this.id + "'>" + this.name + "</label>";
|
||||||
|
|
||||||
switch (this.type) {
|
switch (this.type) {
|
||||||
|
@ -92,9 +92,9 @@ HTMLIngredient.prototype.to_html = function() {
|
||||||
html += "<select class='arg' id='" + this.id + "'arg_name='" + this.name + "'" +
|
html += "<select class='arg' id='" + this.id + "'arg_name='" + this.name + "'" +
|
||||||
(this.disabled ? " disabled='disabled'" : "") + ">";
|
(this.disabled ? " disabled='disabled'" : "") + ">";
|
||||||
for (i = 0; i < this.value.length; i++) {
|
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] + "'>";
|
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>";
|
html += "</optgroup>";
|
||||||
} else {
|
} else {
|
||||||
html += "<option>" + this.value[i] + "</option>";
|
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 + "'" +
|
html += "<select class='arg' id='" + this.id + "'arg_name='" + this.name + "'" +
|
||||||
(this.disabled ? " disabled='disabled'" : "") + ">";
|
(this.disabled ? " disabled='disabled'" : "") + ">";
|
||||||
for (i = 0; i < this.value.length; i++) {
|
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] + "'>";
|
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>";
|
html += "</optgroup>";
|
||||||
} else {
|
} else {
|
||||||
html += "<option populate-value='" + this.value[i].value + "'>" +
|
html += "<option populate-value='" + this.value[i].value + "'>" +
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
*/
|
*/
|
||||||
var HighlighterWaiter = function(app) {
|
var HighlighterWaiter = function(app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
|
||||||
this.mouse_button_down = false;
|
this.mouse_button_down = false;
|
||||||
this.mouse_target = null;
|
this.mouse_target = null;
|
||||||
};
|
};
|
||||||
|
@ -40,7 +40,7 @@ HighlighterWaiter.OUTPUT = 1;
|
||||||
HighlighterWaiter.prototype._is_selection_backwards = function() {
|
HighlighterWaiter.prototype._is_selection_backwards = function() {
|
||||||
var backwards = false,
|
var backwards = false,
|
||||||
sel = window.getSelection();
|
sel = window.getSelection();
|
||||||
|
|
||||||
if (!sel.isCollapsed) {
|
if (!sel.isCollapsed) {
|
||||||
var range = document.createRange();
|
var range = document.createRange();
|
||||||
range.setStart(sel.anchorNode, sel.anchorOffset);
|
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) {
|
HighlighterWaiter.prototype._get_output_html_offset = function(node, offset) {
|
||||||
var sel = window.getSelection(),
|
var sel = window.getSelection(),
|
||||||
range = document.createRange();
|
range = document.createRange();
|
||||||
|
|
||||||
range.selectNodeContents(document.getElementById("output-html"));
|
range.selectNodeContents(document.getElementById("output-html"));
|
||||||
range.setEnd(node, offset);
|
range.setEnd(node, offset);
|
||||||
sel.removeAllRanges();
|
sel.removeAllRanges();
|
||||||
sel.addRange(range);
|
sel.addRange(range);
|
||||||
|
|
||||||
return sel.toString().length;
|
return sel.toString().length;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ HighlighterWaiter.prototype._get_output_html_selection_offsets = function() {
|
||||||
start = 0,
|
start = 0,
|
||||||
end = 0,
|
end = 0,
|
||||||
backwards = false;
|
backwards = false;
|
||||||
|
|
||||||
if (sel.rangeCount) {
|
if (sel.rangeCount) {
|
||||||
range = sel.getRangeAt(sel.rangeCount - 1);
|
range = sel.getRangeAt(sel.rangeCount - 1);
|
||||||
backwards = this._is_selection_backwards();
|
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);
|
end = this._get_output_html_offset(range.endContainer, range.endOffset);
|
||||||
sel.removeAllRanges();
|
sel.removeAllRanges();
|
||||||
sel.addRange(range);
|
sel.addRange(range);
|
||||||
|
|
||||||
if (backwards) {
|
if (backwards) {
|
||||||
// If selecting backwards, reverse the start and end offsets for the selection to
|
// If selecting backwards, reverse the start and end offsets for the selection to
|
||||||
// prevent deselecting as the drag continues.
|
// prevent deselecting as the drag continues.
|
||||||
|
@ -103,7 +103,7 @@ HighlighterWaiter.prototype._get_output_html_selection_offsets = function() {
|
||||||
sel.extend(sel.anchorNode, range.startOffset);
|
sel.extend(sel.anchorNode, range.startOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
start: start,
|
start: start,
|
||||||
end: end
|
end: end
|
||||||
|
@ -147,11 +147,11 @@ HighlighterWaiter.prototype.input_mousedown = function(e) {
|
||||||
this.mouse_button_down = true;
|
this.mouse_button_down = true;
|
||||||
this.mouse_target = HighlighterWaiter.INPUT;
|
this.mouse_target = HighlighterWaiter.INPUT;
|
||||||
this.remove_highlights();
|
this.remove_highlights();
|
||||||
|
|
||||||
var el = e.target,
|
var el = e.target,
|
||||||
start = el.selectionStart,
|
start = el.selectionStart,
|
||||||
end = el.selectionEnd;
|
end = el.selectionEnd;
|
||||||
|
|
||||||
if (start !== 0 || end !== 0) {
|
if (start !== 0 || end !== 0) {
|
||||||
document.getElementById("input-selection-info").innerHTML = this.selection_info(start, end);
|
document.getElementById("input-selection-info").innerHTML = this.selection_info(start, end);
|
||||||
this.highlight_output([{start: start, end: 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_button_down = true;
|
||||||
this.mouse_target = HighlighterWaiter.OUTPUT;
|
this.mouse_target = HighlighterWaiter.OUTPUT;
|
||||||
this.remove_highlights();
|
this.remove_highlights();
|
||||||
|
|
||||||
var el = e.target,
|
var el = e.target,
|
||||||
start = el.selectionStart,
|
start = el.selectionStart,
|
||||||
end = el.selectionEnd;
|
end = el.selectionEnd;
|
||||||
|
|
||||||
if (start !== 0 || end !== 0) {
|
if (start !== 0 || end !== 0) {
|
||||||
document.getElementById("output-selection-info").innerHTML = this.selection_info(start, end);
|
document.getElementById("output-selection-info").innerHTML = this.selection_info(start, end);
|
||||||
this.highlight_input([{start: start, end: 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) {
|
HighlighterWaiter.prototype.output_html_mousedown = function(e) {
|
||||||
this.mouse_button_down = true;
|
this.mouse_button_down = true;
|
||||||
this.mouse_target = HighlighterWaiter.OUTPUT;
|
this.mouse_target = HighlighterWaiter.OUTPUT;
|
||||||
|
|
||||||
var sel = this._get_output_html_selection_offsets();
|
var sel = this._get_output_html_selection_offsets();
|
||||||
if (sel.start !== 0 || sel.end !== 0) {
|
if (sel.start !== 0 || sel.end !== 0) {
|
||||||
document.getElementById("output-selection-info").innerHTML = this.selection_info(sel.start, sel.end);
|
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) {
|
HighlighterWaiter.prototype.input_mousemove = function(e) {
|
||||||
// Check that the left mouse button is pressed
|
// Check that the left mouse button is pressed
|
||||||
if (!this.mouse_button_down ||
|
if (!this.mouse_button_down ||
|
||||||
e.which != 1 ||
|
e.which !== 1 ||
|
||||||
this.mouse_target != HighlighterWaiter.INPUT)
|
this.mouse_target !== HighlighterWaiter.INPUT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var el = e.target,
|
var el = e.target,
|
||||||
start = el.selectionStart,
|
start = el.selectionStart,
|
||||||
end = el.selectionEnd;
|
end = el.selectionEnd;
|
||||||
|
@ -261,14 +261,14 @@ HighlighterWaiter.prototype.input_mousemove = function(e) {
|
||||||
HighlighterWaiter.prototype.output_mousemove = function(e) {
|
HighlighterWaiter.prototype.output_mousemove = function(e) {
|
||||||
// Check that the left mouse button is pressed
|
// Check that the left mouse button is pressed
|
||||||
if (!this.mouse_button_down ||
|
if (!this.mouse_button_down ||
|
||||||
e.which != 1 ||
|
e.which !== 1 ||
|
||||||
this.mouse_target != HighlighterWaiter.OUTPUT)
|
this.mouse_target !== HighlighterWaiter.OUTPUT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var el = e.target,
|
var el = e.target,
|
||||||
start = el.selectionStart,
|
start = el.selectionStart,
|
||||||
end = el.selectionEnd;
|
end = el.selectionEnd;
|
||||||
|
|
||||||
if (start !== 0 || end !== 0) {
|
if (start !== 0 || end !== 0) {
|
||||||
document.getElementById("output-selection-info").innerHTML = this.selection_info(start, end);
|
document.getElementById("output-selection-info").innerHTML = this.selection_info(start, end);
|
||||||
this.highlight_input([{start: start, end: 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) {
|
HighlighterWaiter.prototype.output_html_mousemove = function(e) {
|
||||||
// Check that the left mouse button is pressed
|
// Check that the left mouse button is pressed
|
||||||
if (!this.mouse_button_down ||
|
if (!this.mouse_button_down ||
|
||||||
e.which != 1 ||
|
e.which !== 1 ||
|
||||||
this.mouse_target != HighlighterWaiter.OUTPUT)
|
this.mouse_target !== HighlighterWaiter.OUTPUT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var sel = this._get_output_html_selection_offsets();
|
var sel = this._get_output_html_selection_offsets();
|
||||||
if (sel.start !== 0 || sel.end !== 0) {
|
if (sel.start !== 0 || sel.end !== 0) {
|
||||||
document.getElementById("output-selection-info").innerHTML = this.selection_info(sel.start, sel.end);
|
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, " "),
|
var start_str = Utils.pad(start.toString(), width, " ").replace(/ /g, " "),
|
||||||
end_str = Utils.pad(end.toString(), width, " ").replace(/ /g, " "),
|
end_str = Utils.pad(end.toString(), width, " ").replace(/ /g, " "),
|
||||||
len_str = Utils.pad((end-start).toString(), width, " ").replace(/ /g, " ");
|
len_str = Utils.pad((end-start).toString(), width, " ").replace(/ /g, " ");
|
||||||
|
|
||||||
return "start: " + start_str + "<br>end: " + end_str + "<br>length: " + len_str;
|
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.
|
* entire recipe supports highlighting.
|
||||||
*
|
*
|
||||||
* @returns {Object[]} highlights
|
* @returns {Object[]} highlights
|
||||||
|
@ -338,25 +338,25 @@ HighlighterWaiter.prototype.remove_highlights = function() {
|
||||||
HighlighterWaiter.prototype.generate_highlight_list = function() {
|
HighlighterWaiter.prototype.generate_highlight_list = function() {
|
||||||
var recipe_config = this.app.get_recipe_config(),
|
var recipe_config = this.app.get_recipe_config(),
|
||||||
highlights = [];
|
highlights = [];
|
||||||
|
|
||||||
for (var i = 0; i < recipe_config.length; i++) {
|
for (var i = 0; i < recipe_config.length; i++) {
|
||||||
if (recipe_config[i].disabled) continue;
|
if (recipe_config[i].disabled) continue;
|
||||||
|
|
||||||
// If any breakpoints are set, do not attempt to highlight
|
// If any breakpoints are set, do not attempt to highlight
|
||||||
if (recipe_config[i].breakpoint) return false;
|
if (recipe_config[i].breakpoint) return false;
|
||||||
|
|
||||||
var op = this.app.operations[recipe_config[i].op];
|
var op = this.app.operations[recipe_config[i].op];
|
||||||
|
|
||||||
// If any of the operations do not support highlighting, fail immediately.
|
// If any of the operations do not support highlighting, fail immediately.
|
||||||
if (op.highlight === false || op.highlight === undefined) return false;
|
if (op.highlight === false || op.highlight === undefined) return false;
|
||||||
|
|
||||||
highlights.push({
|
highlights.push({
|
||||||
f: op.highlight,
|
f: op.highlight,
|
||||||
b: op.highlight_reverse,
|
b: op.highlight_reverse,
|
||||||
args: recipe_config[i].args
|
args: recipe_config[i].args
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return highlights;
|
return highlights;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -382,12 +382,12 @@ HighlighterWaiter.prototype.highlight_output = function(pos) {
|
||||||
for (var i = 0; i < highlights.length; i++) {
|
for (var i = 0; i < highlights.length; i++) {
|
||||||
// Remove multiple highlights before processing again
|
// Remove multiple highlights before processing again
|
||||||
pos = [pos[0]];
|
pos = [pos[0]];
|
||||||
|
|
||||||
if (typeof highlights[i].f == "function") {
|
if (typeof highlights[i].f == "function") {
|
||||||
pos = highlights[i].f(pos, highlights[i].args);
|
pos = highlights[i].f(pos, highlights[i].args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById("output-selection-info").innerHTML = this.selection_info(pos[0].start, pos[0].end);
|
document.getElementById("output-selection-info").innerHTML = this.selection_info(pos[0].start, pos[0].end);
|
||||||
this.highlight(
|
this.highlight(
|
||||||
document.getElementById("output-text"),
|
document.getElementById("output-text"),
|
||||||
|
@ -409,7 +409,7 @@ HighlighterWaiter.prototype.highlight_output = function(pos) {
|
||||||
*/
|
*/
|
||||||
HighlighterWaiter.prototype.highlight_input = function(pos) {
|
HighlighterWaiter.prototype.highlight_input = function(pos) {
|
||||||
var highlights = this.generate_highlight_list();
|
var highlights = this.generate_highlight_list();
|
||||||
|
|
||||||
if (!highlights || !this.app.auto_bake_) {
|
if (!highlights || !this.app.auto_bake_) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -417,12 +417,12 @@ HighlighterWaiter.prototype.highlight_input = function(pos) {
|
||||||
for (var i = 0; i < highlights.length; i++) {
|
for (var i = 0; i < highlights.length; i++) {
|
||||||
// Remove multiple highlights before processing again
|
// Remove multiple highlights before processing again
|
||||||
pos = [pos[0]];
|
pos = [pos[0]];
|
||||||
|
|
||||||
if (typeof highlights[i].b == "function") {
|
if (typeof highlights[i].b == "function") {
|
||||||
pos = highlights[i].b(pos, highlights[i].args);
|
pos = highlights[i].b(pos, highlights[i].args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById("input-selection-info").innerHTML = this.selection_info(pos[0].start, pos[0].end);
|
document.getElementById("input-selection-info").innerHTML = this.selection_info(pos[0].start, pos[0].end);
|
||||||
this.highlight(
|
this.highlight(
|
||||||
document.getElementById("input-text"),
|
document.getElementById("input-text"),
|
||||||
|
@ -444,21 +444,21 @@ HighlighterWaiter.prototype.highlight_input = function(pos) {
|
||||||
HighlighterWaiter.prototype.highlight = function(textarea, highlighter, pos) {
|
HighlighterWaiter.prototype.highlight = function(textarea, highlighter, pos) {
|
||||||
if (!this.app.options.show_highlighter) return false;
|
if (!this.app.options.show_highlighter) return false;
|
||||||
if (!this.app.options.attempt_highlight) 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
|
// 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.
|
// 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;
|
if (!this.app.dish_str || this.app.dish_str.indexOf("\r") >= 0) return false;
|
||||||
|
|
||||||
var start_placeholder = "[start_highlight]",
|
var start_placeholder = "[start_highlight]",
|
||||||
start_placeholder_regex = /\[start_highlight\]/g,
|
start_placeholder_regex = /\[start_highlight\]/g,
|
||||||
end_placeholder = "[end_highlight]",
|
end_placeholder = "[end_highlight]",
|
||||||
end_placeholder_regex = /\[end_highlight\]/g,
|
end_placeholder_regex = /\[end_highlight\]/g,
|
||||||
text = textarea.value;
|
text = textarea.value;
|
||||||
|
|
||||||
// Put placeholders in position
|
// Put placeholders in position
|
||||||
// If there's only one value, select that
|
// If there's only one value, select that
|
||||||
// If there are multiple, ignore the first one and select all others
|
// 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;
|
if (pos[0].end < pos[0].start) return;
|
||||||
text = text.slice(0, pos[0].start) +
|
text = text.slice(0, pos[0].start) +
|
||||||
start_placeholder + text.slice(pos[0].start, pos[0].end) + end_placeholder +
|
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?
|
// O(n^2) - Can anyone improve this without overwriting placeholders?
|
||||||
var result = "",
|
var result = "",
|
||||||
end_placed = true;
|
end_placed = true;
|
||||||
|
|
||||||
for (var i = 0; i < text.length; i++) {
|
for (var i = 0; i < text.length; i++) {
|
||||||
for (var j = 1; j < pos.length; j++) {
|
for (var j = 1; j < pos.length; j++) {
|
||||||
if (pos[j].end < pos[j].start) continue;
|
if (pos[j].end < pos[j].start) continue;
|
||||||
if (pos[j].start == i) {
|
if (pos[j].start === i) {
|
||||||
result += start_placeholder;
|
result += start_placeholder;
|
||||||
end_placed = false;
|
end_placed = false;
|
||||||
}
|
}
|
||||||
if (pos[j].end == i) {
|
if (pos[j].end === i) {
|
||||||
result += end_placeholder;
|
result += end_placeholder;
|
||||||
end_placed = true;
|
end_placed = true;
|
||||||
}
|
}
|
||||||
|
@ -485,10 +485,10 @@ HighlighterWaiter.prototype.highlight = function(textarea, highlighter, pos) {
|
||||||
if (!end_placed) result += end_placeholder;
|
if (!end_placed) result += end_placeholder;
|
||||||
text = result;
|
text = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
var css_class = "hl1";
|
var css_class = "hl1";
|
||||||
//if (colour) css_class += "-"+colour;
|
//if (colour) css_class += "-"+colour;
|
||||||
|
|
||||||
// Remove HTML tags
|
// Remove HTML tags
|
||||||
text = text.replace(/&/g, "&")
|
text = text.replace(/&/g, "&")
|
||||||
.replace(/</g, "<")
|
.replace(/</g, "<")
|
||||||
|
@ -497,7 +497,7 @@ HighlighterWaiter.prototype.highlight = function(textarea, highlighter, pos) {
|
||||||
// Convert placeholders to tags
|
// Convert placeholders to tags
|
||||||
.replace(start_placeholder_regex, "<span class=\""+css_class+"\">")
|
.replace(start_placeholder_regex, "<span class=\""+css_class+"\">")
|
||||||
.replace(end_placeholder_regex, "</span>") + " ";
|
.replace(end_placeholder_regex, "</span>") + " ";
|
||||||
|
|
||||||
// Adjust width to allow for scrollbars
|
// Adjust width to allow for scrollbars
|
||||||
highlighter.style.width = textarea.clientWidth + "px";
|
highlighter.style.width = textarea.clientWidth + "px";
|
||||||
highlighter.innerHTML = text;
|
highlighter.innerHTML = text;
|
||||||
|
|
|
@ -21,12 +21,12 @@ var InputWaiter = function(app, manager) {
|
||||||
19, //Pause
|
19, //Pause
|
||||||
20, //Caps
|
20, //Caps
|
||||||
27, //Esc
|
27, //Esc
|
||||||
33,34,35,36, //PgUp, PgDn, End, Home
|
33, 34, 35, 36, //PgUp, PgDn, End, Home
|
||||||
37,38,39,40, //Directional
|
37, 38, 39, 40, //Directional
|
||||||
44, //PrntScrn
|
44, //PrntScrn
|
||||||
91,92, //Win
|
91, 92, //Win
|
||||||
93, //Context
|
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
|
144, //Num
|
||||||
145, //Scroll
|
145, //Scroll
|
||||||
];
|
];
|
||||||
|
@ -162,8 +162,8 @@ InputWaiter.prototype.input_drop = function(e) {
|
||||||
|
|
||||||
this.set(input_charcode);
|
this.set(input_charcode);
|
||||||
var recipe_config = this.app.get_recipe_config();
|
var recipe_config = this.app.get_recipe_config();
|
||||||
if (!recipe_config[0] || recipe_config[0].op != "From Hex") {
|
if (!recipe_config[0] || recipe_config[0].op !== "From Hex") {
|
||||||
recipe_config.unshift({op:"From Hex",args:["Space"]});
|
recipe_config.unshift({op:"From Hex", args:["Space"]});
|
||||||
this.app.set_recipe_config(recipe_config);
|
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) + "%";
|
el.value = "Processing... " + Math.round(offset / file.size * 100) + "%";
|
||||||
var slice = file.slice(offset, offset + CHUNK_SIZE);
|
var slice = file.slice(offset, offset + CHUNK_SIZE);
|
||||||
reader.readAsArrayBuffer(slice);
|
reader.readAsArrayBuffer(slice);
|
||||||
}.bind(this);
|
};
|
||||||
|
|
||||||
reader.onload = function(e) {
|
reader.onload = function(e) {
|
||||||
var data = new Uint8Array(reader.result);
|
var data = new Uint8Array(reader.result);
|
||||||
input_charcode += Utils.to_hex_fast(data);
|
input_charcode += Utils.to_hex_fast(data);
|
||||||
offset += CHUNK_SIZE;
|
offset += CHUNK_SIZE;
|
||||||
seek();
|
seek();
|
||||||
}.bind(this);
|
};
|
||||||
|
|
||||||
|
|
||||||
el.classList.remove("dropping-file");
|
el.classList.remove("dropping-file");
|
||||||
|
|
|
@ -136,8 +136,8 @@ Manager.prototype.initialise_event_listeners = function() {
|
||||||
// Options
|
// Options
|
||||||
document.getElementById("options").addEventListener("click", this.options.options_click.bind(this.options));
|
document.getElementById("options").addEventListener("click", this.options.options_click.bind(this.options));
|
||||||
document.getElementById("reset-options").addEventListener("click", this.options.reset_options_click.bind(this.options));
|
document.getElementById("reset-options").addEventListener("click", this.options.reset_options_click.bind(this.options));
|
||||||
$(".option-item input:checkbox").on("switchChange.bootstrapSwitch", this.options.switch_change.bind(this.options));
|
$(document).on("switchChange.bootstrapSwitch", ".option-item input:checkbox", this.options.switch_change.bind(this.options));
|
||||||
$(".option-item input:checkbox").on("switchChange.bootstrapSwitch", this.options.set_word_wrap.bind(this.options));
|
$(document).on("switchChange.bootstrapSwitch", ".option-item input:checkbox", this.options.set_word_wrap.bind(this.options));
|
||||||
this.add_dynamic_listener(".option-item input[type=number]", "keyup", this.options.number_change, this.options);
|
this.add_dynamic_listener(".option-item input[type=number]", "keyup", this.options.number_change, this.options);
|
||||||
this.add_dynamic_listener(".option-item input[type=number]", "change", this.options.number_change, this.options);
|
this.add_dynamic_listener(".option-item input[type=number]", "change", this.options.number_change, this.options);
|
||||||
this.add_dynamic_listener(".option-item select", "change", this.options.select_change, this.options);
|
this.add_dynamic_listener(".option-item select", "change", this.options.select_change, this.options);
|
||||||
|
|
|
@ -29,7 +29,7 @@ var OperationsWaiter = function(app, manager) {
|
||||||
OperationsWaiter.prototype.search_operations = function(e) {
|
OperationsWaiter.prototype.search_operations = function(e) {
|
||||||
var ops, selected;
|
var ops, selected;
|
||||||
|
|
||||||
if (e.type == "search") { // Search
|
if (e.type === "search") { // Search
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
ops = document.querySelectorAll("#search-results li");
|
ops = document.querySelectorAll("#search-results li");
|
||||||
if (ops.length) {
|
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();
|
e.preventDefault();
|
||||||
} else if (e.keyCode == 40) { // Down
|
} else if (e.keyCode === 40) { // Down
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
ops = document.querySelectorAll("#search-results li");
|
ops = document.querySelectorAll("#search-results li");
|
||||||
if (ops.length) {
|
if (ops.length) {
|
||||||
|
@ -51,10 +51,10 @@ OperationsWaiter.prototype.search_operations = function(e) {
|
||||||
if (selected > -1) {
|
if (selected > -1) {
|
||||||
ops[selected].classList.remove("selected-op");
|
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");
|
ops[selected+1].classList.add("selected-op");
|
||||||
}
|
}
|
||||||
} else if (e.keyCode == 38) { // Up
|
} else if (e.keyCode === 38) { // Up
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
ops = document.querySelectorAll("#search-results li");
|
ops = document.querySelectorAll("#search-results li");
|
||||||
if (ops.length) {
|
if (ops.length) {
|
||||||
|
@ -71,6 +71,7 @@ OperationsWaiter.prototype.search_operations = function(e) {
|
||||||
str = el.value;
|
str = el.value;
|
||||||
|
|
||||||
while (search_results_el.firstChild) {
|
while (search_results_el.firstChild) {
|
||||||
|
$(search_results_el.firstChild).popover("destroy");
|
||||||
search_results_el.removeChild(search_results_el.firstChild);
|
search_results_el.removeChild(search_results_el.firstChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +183,7 @@ OperationsWaiter.prototype.edit_favourites_click = function(e) {
|
||||||
|
|
||||||
// Add favourites to modal
|
// Add favourites to modal
|
||||||
var fav_cat = this.app.categories.filter(function(c) {
|
var fav_cat = this.app.categories.filter(function(c) {
|
||||||
return c.name == "Favourites";
|
return c.name === "Favourites";
|
||||||
})[0];
|
})[0];
|
||||||
|
|
||||||
var html = "";
|
var html = "";
|
||||||
|
@ -197,7 +198,7 @@ OperationsWaiter.prototype.edit_favourites_click = function(e) {
|
||||||
this.remove_intent = false;
|
this.remove_intent = false;
|
||||||
|
|
||||||
var editable_list = Sortable.create(edit_favourites_list, {
|
var editable_list = Sortable.create(edit_favourites_list, {
|
||||||
filter: '.remove-icon',
|
filter: ".remove-icon",
|
||||||
onFilter: function (evt) {
|
onFilter: function (evt) {
|
||||||
var el = editable_list.closest(evt.item);
|
var el = editable_list.closest(evt.item);
|
||||||
if (el) {
|
if (el) {
|
||||||
|
@ -211,11 +212,11 @@ OperationsWaiter.prototype.edit_favourites_click = function(e) {
|
||||||
});
|
});
|
||||||
|
|
||||||
Sortable.utils.on(edit_favourites_list, "dragleave", function() {
|
Sortable.utils.on(edit_favourites_list, "dragleave", function() {
|
||||||
this.remove_intent = true;
|
this.remove_intent = true;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
Sortable.utils.on(edit_favourites_list, "dragover", function() {
|
Sortable.utils.on(edit_favourites_list, "dragover", function() {
|
||||||
this.remove_intent = false;
|
this.remove_intent = false;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
$("#edit-favourites-list [data-toggle=popover]").popover();
|
$("#edit-favourites-list [data-toggle=popover]").popover();
|
||||||
|
@ -259,7 +260,7 @@ OperationsWaiter.prototype.reset_favourites_click = function() {
|
||||||
*/
|
*/
|
||||||
OperationsWaiter.prototype.op_icon_mouseover = function(e) {
|
OperationsWaiter.prototype.op_icon_mouseover = function(e) {
|
||||||
var op_el = e.target.parentNode;
|
var op_el = e.target.parentNode;
|
||||||
if (e.target.getAttribute("data-toggle") == "popover") {
|
if (e.target.getAttribute("data-toggle") === "popover") {
|
||||||
$(op_el).popover("hide");
|
$(op_el).popover("hide");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -276,7 +277,7 @@ OperationsWaiter.prototype.op_icon_mouseleave = function(e) {
|
||||||
var op_el = e.target.parentNode,
|
var op_el = e.target.parentNode,
|
||||||
to_el = e.toElement || e.relatedElement;
|
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");
|
$(op_el).popover("show");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -38,7 +38,7 @@ OutputWaiter.prototype.set = function(data_str, type, duration) {
|
||||||
output_highlighter = document.getElementById("output-highlighter"),
|
output_highlighter = document.getElementById("output-highlighter"),
|
||||||
input_highlighter = document.getElementById("input-highlighter");
|
input_highlighter = document.getElementById("input-highlighter");
|
||||||
|
|
||||||
if (type == "html") {
|
if (type === "html") {
|
||||||
output_text.style.display = "none";
|
output_text.style.display = "none";
|
||||||
output_html.style.display = "block";
|
output_html.style.display = "block";
|
||||||
output_highlighter.display = "none";
|
output_highlighter.display = "none";
|
||||||
|
@ -51,7 +51,7 @@ OutputWaiter.prototype.set = function(data_str, type, duration) {
|
||||||
var script_elements = output_html.querySelectorAll("script");
|
var script_elements = output_html.querySelectorAll("script");
|
||||||
for (var i = 0; i < script_elements.length; i++) {
|
for (var i = 0; i < script_elements.length; i++) {
|
||||||
try {
|
try {
|
||||||
eval(script_elements[i].innerHTML); // jshint ignore:line
|
eval(script_elements[i].innerHTML); // eslint-disable-line no-eval
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,7 @@ var RecipeWaiter = function(app, manager) {
|
||||||
* Sets up the drag and drop capability for operations in the operations and recipe areas.
|
* Sets up the drag and drop capability for operations in the operations and recipe areas.
|
||||||
*/
|
*/
|
||||||
RecipeWaiter.prototype.initialise_operation_drag_n_drop = function() {
|
RecipeWaiter.prototype.initialise_operation_drag_n_drop = function() {
|
||||||
var rec_list = document.getElementById("rec_list"),
|
var rec_list = document.getElementById("rec_list");
|
||||||
op_lists = document.querySelectorAll(".category .op_list");
|
|
||||||
|
|
||||||
|
|
||||||
// Recipe list
|
// Recipe list
|
||||||
|
@ -52,6 +51,13 @@ RecipeWaiter.prototype.initialise_operation_drag_n_drop = function() {
|
||||||
this.remove_intent = true;
|
this.remove_intent = true;
|
||||||
this.app.progress = 0;
|
this.app.progress = 0;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
Sortable.utils.on(rec_list, "touchend", function(e) {
|
||||||
|
var loc = e.changedTouches[0],
|
||||||
|
target = document.elementFromPoint(loc.clientX, loc.clientY);
|
||||||
|
|
||||||
|
this.remove_intent = !rec_list.contains(target);
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
// Favourites category
|
// Favourites category
|
||||||
document.querySelector("#categories a").addEventListener("dragover", this.fav_dragover.bind(this));
|
document.querySelector("#categories a").addEventListener("dragover", this.fav_dragover.bind(this));
|
||||||
|
@ -95,7 +101,7 @@ RecipeWaiter.prototype.create_sortable_seed_list = function(list_el) {
|
||||||
*/
|
*/
|
||||||
RecipeWaiter.prototype.op_sort_end = function(evt) {
|
RecipeWaiter.prototype.op_sort_end = function(evt) {
|
||||||
if (this.remove_intent) {
|
if (this.remove_intent) {
|
||||||
if (evt.item.parentNode.id == "rec_list") {
|
if (evt.item.parentNode.id === "rec_list") {
|
||||||
evt.item.remove();
|
evt.item.remove();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -190,7 +196,7 @@ RecipeWaiter.prototype.ing_change = function() {
|
||||||
RecipeWaiter.prototype.disable_click = function(e) {
|
RecipeWaiter.prototype.disable_click = function(e) {
|
||||||
var icon = e.target;
|
var icon = e.target;
|
||||||
|
|
||||||
if (icon.getAttribute("disabled") == "false") {
|
if (icon.getAttribute("disabled") === "false") {
|
||||||
icon.setAttribute("disabled", "true");
|
icon.setAttribute("disabled", "true");
|
||||||
icon.classList.add("disable-icon-selected");
|
icon.classList.add("disable-icon-selected");
|
||||||
icon.parentNode.parentNode.classList.add("disabled");
|
icon.parentNode.parentNode.classList.add("disabled");
|
||||||
|
@ -215,7 +221,7 @@ RecipeWaiter.prototype.disable_click = function(e) {
|
||||||
RecipeWaiter.prototype.breakpoint_click = function(e) {
|
RecipeWaiter.prototype.breakpoint_click = function(e) {
|
||||||
var bp = e.target;
|
var bp = e.target;
|
||||||
|
|
||||||
if (bp.getAttribute("break") == "false") {
|
if (bp.getAttribute("break") === "false") {
|
||||||
bp.setAttribute("break", "true");
|
bp.setAttribute("break", "true");
|
||||||
bp.classList.add("breakpoint-selected");
|
bp.classList.add("breakpoint-selected");
|
||||||
} else {
|
} else {
|
||||||
|
@ -269,7 +275,7 @@ RecipeWaiter.prototype.get_config = function() {
|
||||||
ing_list = operations[i].querySelectorAll(".arg");
|
ing_list = operations[i].querySelectorAll(".arg");
|
||||||
|
|
||||||
for (var j = 0; j < ing_list.length; j++) {
|
for (var j = 0; j < ing_list.length; j++) {
|
||||||
if (ing_list[j].getAttribute("type") == "checkbox") {
|
if (ing_list[j].getAttribute("type") === "checkbox") {
|
||||||
// checkbox
|
// checkbox
|
||||||
ingredients[j] = ing_list[j].checked;
|
ingredients[j] = ing_list[j].checked;
|
||||||
} else if (ing_list[j].classList.contains("toggle-string")) {
|
} else if (ing_list[j].classList.contains("toggle-string")) {
|
||||||
|
@ -289,11 +295,11 @@ RecipeWaiter.prototype.get_config = function() {
|
||||||
args: ingredients
|
args: ingredients
|
||||||
};
|
};
|
||||||
|
|
||||||
if (disabled && disabled.getAttribute("disabled") == "true") {
|
if (disabled && disabled.getAttribute("disabled") === "true") {
|
||||||
item.disabled = true;
|
item.disabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bp && bp.getAttribute("break") == "true") {
|
if (bp && bp.getAttribute("break") === "true") {
|
||||||
item.breakpoint = true;
|
item.breakpoint = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +318,7 @@ RecipeWaiter.prototype.get_config = function() {
|
||||||
RecipeWaiter.prototype.update_breakpoint_indicator = function(position) {
|
RecipeWaiter.prototype.update_breakpoint_indicator = function(position) {
|
||||||
var operations = document.querySelectorAll("#rec_list li.operation");
|
var operations = document.querySelectorAll("#rec_list li.operation");
|
||||||
for (var i = 0; i < operations.length; i++) {
|
for (var i = 0; i < operations.length; i++) {
|
||||||
if (i == position) {
|
if (i === position) {
|
||||||
operations[i].classList.add("break");
|
operations[i].classList.add("break");
|
||||||
} else {
|
} else {
|
||||||
operations[i].classList.remove("break");
|
operations[i].classList.remove("break");
|
||||||
|
@ -353,10 +359,11 @@ RecipeWaiter.prototype.build_recipe_operation = function(el) {
|
||||||
*/
|
*/
|
||||||
RecipeWaiter.prototype.add_operation = function(name) {
|
RecipeWaiter.prototype.add_operation = function(name) {
|
||||||
var item = document.createElement("li");
|
var item = document.createElement("li");
|
||||||
item.classList.add("operation");
|
|
||||||
item.innerHTML = name;
|
item.classList.add("operation");
|
||||||
this.build_recipe_operation(item);
|
item.innerHTML = name;
|
||||||
document.getElementById("rec_list").appendChild(item);
|
this.build_recipe_operation(item);
|
||||||
|
document.getElementById("rec_list").appendChild(item);
|
||||||
|
|
||||||
item.dispatchEvent(this.manager.operationadd);
|
item.dispatchEvent(this.manager.operationadd);
|
||||||
return item;
|
return item;
|
||||||
|
@ -413,4 +420,4 @@ RecipeWaiter.prototype.op_add = function(e) {
|
||||||
*/
|
*/
|
||||||
RecipeWaiter.prototype.op_remove = function(e) {
|
RecipeWaiter.prototype.op_remove = function(e) {
|
||||||
window.dispatchEvent(this.manager.statechange);
|
window.dispatchEvent(this.manager.statechange);
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,23 +20,23 @@ var SeasonalWaiter = function(app, manager) {
|
||||||
*/
|
*/
|
||||||
SeasonalWaiter.prototype.load = function() {
|
SeasonalWaiter.prototype.load = function() {
|
||||||
var now = new Date();
|
var now = new Date();
|
||||||
|
|
||||||
// Snowfall
|
// 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.app.options.snow = false;
|
||||||
this.create_snow_option();
|
this.create_snow_option();
|
||||||
this.manager.add_dynamic_listener(".option-item input:checkbox[option='snow']", "switchChange.bootstrapSwitch", this.let_it_snow, this);
|
$(document).on("switchChange.bootstrapSwitch", ".option-item input:checkbox[option='snow']", this.let_it_snow.bind(this));
|
||||||
this.manager.add_window_listener("resize", this.let_it_snow, this);
|
window.addEventListener("resize", this.let_it_snow.bind(this));
|
||||||
this.manager.add_listeners(".btn", "click", this.shake_off_snow, 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
|
// 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_icons();
|
||||||
// this.insert_spider_text();
|
// this.insert_spider_text();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Konami code
|
// Konami code
|
||||||
this.kkeys = [];
|
this.kkeys = [];
|
||||||
window.addEventListener("keydown", this.konami_code_listener.bind(this));
|
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",
|
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",
|
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=";
|
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
|
// Favicon
|
||||||
document.querySelector("link[rel=icon]").setAttribute("href", "data:image/png;base64," + spider16);
|
document.querySelector("link[rel=icon]").setAttribute("href", "data:image/png;base64," + spider16);
|
||||||
|
|
||||||
// Bake button
|
// Bake button
|
||||||
document.querySelector("#bake img").setAttribute("src", "data:image/png;base64," + spider32);
|
document.querySelector("#bake img").setAttribute("src", "data:image/png;base64," + spider32);
|
||||||
|
|
||||||
// About box
|
// About box
|
||||||
document.querySelector(".about-img-left").setAttribute("src", "data:image/png;base64," + spider64);
|
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() {
|
SeasonalWaiter.prototype.insert_spider_text = function() {
|
||||||
// Title
|
// Title
|
||||||
document.title = document.title.replace(/Cyber/g, "Spider");
|
document.title = document.title.replace(/Cyber/g, "Spider");
|
||||||
|
|
||||||
// Body
|
// Body
|
||||||
SeasonalWaiter.tree_walk(document.body, function(node) {
|
SeasonalWaiter.tree_walk(document.body, function(node) {
|
||||||
// process only text nodes
|
// process only text nodes
|
||||||
if (node.nodeType == 3) {
|
if (node.nodeType === 3) {
|
||||||
node.nodeValue = node.nodeValue.replace(/Cyber/g, "Spider");
|
node.nodeValue = node.nodeValue.replace(/Cyber/g, "Spider");
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
// Bake button
|
// Bake button
|
||||||
SeasonalWaiter.tree_walk(document.getElementById("bake-group"), function(node) {
|
SeasonalWaiter.tree_walk(document.getElementById("bake-group"), function(node) {
|
||||||
// process only text nodes
|
// process only text nodes
|
||||||
if (node.nodeType == 3) {
|
if (node.nodeType === 3) {
|
||||||
node.nodeValue = node.nodeValue.replace(/Bake/g, "Spin");
|
node.nodeValue = node.nodeValue.replace(/Bake/g, "Spin");
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
// Recipe title
|
// Recipe title
|
||||||
document.querySelector("#recipe .title").innerHTML = "Web";
|
document.querySelector("#recipe .title").innerHTML = "Web";
|
||||||
};
|
};
|
||||||
|
@ -99,13 +99,13 @@ SeasonalWaiter.prototype.insert_spider_text = function() {
|
||||||
SeasonalWaiter.prototype.create_snow_option = function() {
|
SeasonalWaiter.prototype.create_snow_option = function() {
|
||||||
var options_body = document.getElementById("options-body"),
|
var options_body = document.getElementById("options-body"),
|
||||||
option_item = document.createElement("div");
|
option_item = document.createElement("div");
|
||||||
|
|
||||||
option_item.className = "option-item";
|
option_item.className = "option-item";
|
||||||
option_item.innerHTML =
|
option_item.innerHTML =
|
||||||
"<input type='checkbox' option='snow' checked />\
|
"<input type='checkbox' option='snow' checked />\
|
||||||
Let it snow";
|
Let it snow";
|
||||||
options_body.appendChild(option_item);
|
options_body.appendChild(option_item);
|
||||||
|
|
||||||
this.manager.options.load();
|
this.manager.options.load();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -117,47 +117,48 @@ SeasonalWaiter.prototype.create_snow_option = function() {
|
||||||
SeasonalWaiter.prototype.let_it_snow = function() {
|
SeasonalWaiter.prototype.let_it_snow = function() {
|
||||||
$(document).snowfall("clear");
|
$(document).snowfall("clear");
|
||||||
if (!this.app.options.snow) return;
|
if (!this.app.options.snow) return;
|
||||||
|
|
||||||
var options = {},
|
var options = {},
|
||||||
firefox_version = navigator.userAgent.match(/Firefox\/(\d\d?)/);
|
firefox_version = navigator.userAgent.match(/Firefox\/(\d\d?)/);
|
||||||
|
|
||||||
if (firefox_version && parseInt(firefox_version[1], 10) < 30) {
|
if (firefox_version && parseInt(firefox_version[1], 10) < 30) {
|
||||||
// Firefox < 30
|
// Firefox < 30
|
||||||
options = {
|
options = {
|
||||||
flakeCount : 10,
|
flakeCount: 10,
|
||||||
flakeColor : '#fff',
|
flakeColor: "#fff",
|
||||||
flakePosition: 'absolute',
|
flakePosition: "absolute",
|
||||||
minSize : 1,
|
minSize: 1,
|
||||||
maxSize : 2,
|
maxSize: 2,
|
||||||
minSpeed : 1,
|
minSpeed: 1,
|
||||||
maxSpeed : 5,
|
maxSpeed: 5,
|
||||||
round : false,
|
round: false,
|
||||||
shadow : false,
|
shadow: false,
|
||||||
collection : false,
|
collection: false,
|
||||||
collectionHeight : 20,
|
collectionHeight: 20,
|
||||||
deviceorientation : true
|
deviceorientation: true
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
// All other browsers
|
// All other browsers
|
||||||
options = {
|
options = {
|
||||||
flakeCount : 35, //35
|
flakeCount: 35,
|
||||||
flakeColor : '#fff',
|
flakeColor: "#fff",
|
||||||
flakePosition: 'absolute',
|
flakePosition: "absolute",
|
||||||
minSize : 5,
|
minSize: 5,
|
||||||
maxSize : 8,
|
maxSize: 8,
|
||||||
minSpeed : 1,
|
minSpeed: 1,
|
||||||
maxSpeed : 5,
|
maxSpeed: 5,
|
||||||
round : true,
|
round: true,
|
||||||
shadow : true,
|
shadow: true,
|
||||||
collection : ".btn",
|
collection: ".btn",
|
||||||
collectionHeight : 20,
|
collectionHeight: 20,
|
||||||
deviceorientation : true
|
deviceorientation: true
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).snowfall(options);
|
$(document).snowfall(options);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When a button is clicked, shake the snow off that button.
|
* When a button is clicked, shake the snow off that button.
|
||||||
* #letitsnow
|
* #letitsnow
|
||||||
|
@ -171,12 +172,12 @@ SeasonalWaiter.prototype.shake_off_snow = function(e) {
|
||||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||||
$(this).fadeIn();
|
$(this).fadeIn();
|
||||||
};
|
};
|
||||||
|
|
||||||
for (var i = 0; i < canvases.length; i++) {
|
for (var i = 0; i < canvases.length; i++) {
|
||||||
canvas = canvases[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");
|
var ctx = canvas.getContext("2d");
|
||||||
|
|
||||||
$(canvas).fadeOut("slow", remove_func);
|
$(canvas).fadeOut("slow", remove_func);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -191,13 +192,13 @@ SeasonalWaiter.prototype.shake_off_snow = function(e) {
|
||||||
*/
|
*/
|
||||||
SeasonalWaiter.prototype.konami_code_listener = function(e) {
|
SeasonalWaiter.prototype.konami_code_listener = function(e) {
|
||||||
this.kkeys.push(e.keyCode);
|
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++) {
|
for (var i = 0; i < this.kkeys.length; i++) {
|
||||||
if (this.kkeys[i] != konami[i]) {
|
if (this.kkeys[i] !== konami[i]) {
|
||||||
this.kkeys = [];
|
this.kkeys = [];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i == konami.length - 1) {
|
if (i === konami.length - 1) {
|
||||||
$("body").children().toggleClass("konami");
|
$("body").children().toggleClass("konami");
|
||||||
this.kkeys = [];
|
this.kkeys = [];
|
||||||
}
|
}
|
||||||
|
@ -216,14 +217,14 @@ SeasonalWaiter.prototype.konami_code_listener = function(e) {
|
||||||
SeasonalWaiter.tree_walk = (function() {
|
SeasonalWaiter.tree_walk = (function() {
|
||||||
// Create closure for constants
|
// Create closure for constants
|
||||||
var skipTags = {
|
var skipTags = {
|
||||||
"SCRIPT": true, "IFRAME": true, "OBJECT": true,
|
"SCRIPT": true, "IFRAME": true, "OBJECT": true,
|
||||||
"EMBED": true, "STYLE": true, "LINK": true, "META": true
|
"EMBED": true, "STYLE": true, "LINK": true, "META": true
|
||||||
};
|
};
|
||||||
|
|
||||||
return function(parent, fn, all_nodes) {
|
return function(parent, fn, all_nodes) {
|
||||||
var node = parent.firstChild;
|
var node = parent.firstChild;
|
||||||
|
|
||||||
while (node && node != parent) {
|
while (node && node !== parent) {
|
||||||
if (all_nodes || node.nodeType === 1) {
|
if (all_nodes || node.nodeType === 1) {
|
||||||
if (fn(node) === false) {
|
if (fn(node) === false) {
|
||||||
return(false);
|
return(false);
|
||||||
|
@ -242,7 +243,7 @@ SeasonalWaiter.tree_walk = (function() {
|
||||||
} else {
|
} else {
|
||||||
// No child and no nextsibling
|
// No child and no nextsibling
|
||||||
// Find parent that has a nextSibling
|
// Find parent that has a nextSibling
|
||||||
while ((node = node.parentNode) != parent) {
|
while ((node = node.parentNode) !== parent) {
|
||||||
if (node.nextSibling) {
|
if (node.nextSibling) {
|
||||||
node = node.nextSibling;
|
node = node.nextSibling;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
203 source files
|
203 source files
|
||||||
104221 lines
|
104466 lines
|
||||||
4.0M size
|
4.0M size
|
||||||
|
|
||||||
136 JavaScript source files
|
136 JavaScript source files
|
||||||
95131 lines
|
95316 lines
|
||||||
3.4M size
|
3.4M size
|
||||||
|
|
||||||
78 third party JavaScript source files
|
78 third party JavaScript source files
|
||||||
|
@ -11,11 +11,11 @@
|
||||||
2.7M size
|
2.7M size
|
||||||
|
|
||||||
58 first party JavaScript source files
|
58 first party JavaScript source files
|
||||||
18754 lines
|
18939 lines
|
||||||
724K size
|
724K size
|
||||||
|
|
||||||
3.1M uncompressed JavaScript size
|
3.2M uncompressed JavaScript size
|
||||||
1.7M compressed JavaScript size
|
1.7M compressed JavaScript size
|
||||||
|
|
||||||
15 categories
|
15 categories
|
||||||
152 operations
|
155 operations
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue