From 640f555b8aa417b5c09b266a7509f55ec4a66ed6 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Tue, 29 Nov 2016 01:58:58 +0000 Subject: [PATCH] fix eslint:recommended errors this should find most of the imports --- .eslintrc.json | 12 ++++++-- package.json | 1 + src/js/config/Categories.js | 2 ++ src/js/config/OperationConfig.js | 38 ++++++++++++++++++++++++++ src/js/core/Chef.js | 7 +++-- src/js/core/Dish.js | 6 ++-- src/js/core/FlowControl.js | 5 ++++ src/js/core/Ingredient.js | 7 +++-- src/js/core/Operation.js | 7 +++-- src/js/core/Recipe.js | 3 ++ src/js/core/Utils.js | 4 +++ src/js/operations/Base.js | 2 ++ src/js/operations/Base64.js | 4 +++ src/js/operations/BitwiseOp.js | 4 +++ src/js/operations/ByteRepr.js | 4 +++ src/js/operations/CharEnc.js | 4 +++ src/js/operations/Checksum.js | 4 +++ src/js/operations/Cipher.js | 3 ++ src/js/operations/Code.js | 4 +++ src/js/operations/Compress.js | 5 ++++ src/js/operations/Convert.js | 2 ++ src/js/operations/DateTime.js | 2 ++ src/js/operations/Endian.js | 3 ++ src/js/operations/Entropy.js | 3 ++ src/js/operations/Extract.js | 2 ++ src/js/operations/FileType.js | 4 +++ src/js/operations/HTML.js | 4 ++- src/js/operations/HTTP.js | 2 ++ src/js/operations/Hash.js | 4 +++ src/js/operations/Hexdump.js | 4 +++ src/js/operations/IP.js | 4 +++ src/js/operations/JS.js | 2 ++ src/js/operations/MAC.js | 2 ++ src/js/operations/Numberwang.js | 2 ++ src/js/operations/OS.js | 2 ++ src/js/operations/PublicKey.js | 4 +++ src/js/operations/Punycode.js | 2 ++ src/js/operations/QuotedPrintable.js | 2 ++ src/js/operations/Rotate.js | 2 ++ src/js/operations/SeqUtils.js | 4 +++ src/js/operations/StrUtils.js | 4 +++ src/js/operations/Tidy.js | 4 +++ src/js/operations/URL.js | 3 ++ src/js/operations/UUID.js | 4 +++ src/js/operations/Unicode.js | 4 +++ src/js/views/html/ControlsWaiter.js | 10 +++++-- src/js/views/html/HTMLApp.js | 21 +++++++++++--- src/js/views/html/HTMLCategory.js | 4 +-- src/js/views/html/HTMLIngredient.js | 4 +-- src/js/views/html/HTMLOperation.js | 6 ++-- src/js/views/html/HighlighterWaiter.js | 5 ++-- src/js/views/html/InputWaiter.js | 6 ++-- src/js/views/html/Manager.js | 12 ++++++++ src/js/views/html/OperationsWaiter.js | 7 +++-- src/js/views/html/OptionsWaiter.js | 6 ++-- src/js/views/html/OutputWaiter.js | 6 ++-- src/js/views/html/RecipeWaiter.js | 10 ++++--- src/js/views/html/SeasonalWaiter.js | 6 ++-- src/js/views/html/WindowWaiter.js | 4 +-- src/js/views/html/main.js | 3 ++ yarn.lock | 2 +- 61 files changed, 269 insertions(+), 44 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 573dfac3..6f413948 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,13 +1,21 @@ { - "extends": "airbnb-base", + + "extends": "eslint:recommended", "parser": "babel-eslint", "plugins": ["babel"], + "rules": { + "no-unused-vars": 0, + "no-console": 0, + "no-cond-assign": 0, + "no-unsafe-finally": 0 + }, "settings": { "import/resolver": { "webpack": {} } }, "env": { - "browser": true + "browser": true, + "node": true } } diff --git a/package.json b/package.json index 8eec627d..51cfc726 100755 --- a/package.json +++ b/package.json @@ -67,6 +67,7 @@ "webpack-dev-server": "2.1.0-beta.12" }, "dependencies": { + "core-js": "^2.4.1", "esprima": "^3.1.2", "estraverse": "^4.2.0", "jquery": "^3.1.1", diff --git a/src/js/config/Categories.js b/src/js/config/Categories.js index 02305f80..7131a8e3 100755 --- a/src/js/config/Categories.js +++ b/src/js/config/Categories.js @@ -264,3 +264,5 @@ const Categories = [ ], }, ]; + +export default Categories; diff --git a/src/js/config/OperationConfig.js b/src/js/config/OperationConfig.js index f8c74a9a..1f6625d4 100755 --- a/src/js/config/OperationConfig.js +++ b/src/js/config/OperationConfig.js @@ -1,3 +1,39 @@ +import FlowControl from '../core/FlowControl'; +import Base64 from '../operations/Base64'; +import BitwiseOp from '../operations/BitwiseOp'; +import ByteRepr from '../operations/ByteRepr'; +import Hexdump from '../operations/Hexdump'; +import Base from '../operations/Base'; +import HTML from '../operations/HTML'; +import URL_ from '../operations/URL'; +import Unicode from '../operations/Unicode'; +import QuotedPrintable from '../operations/QuotedPrintable'; +import Punycode from '../operations/Punycode'; +import IP from '../operations/IP'; +import CharEnc from '../operations/CharEnc'; +import Cipher from '../operations/Cipher'; +import Rotate from '../operations/Rotate'; +import HTTP from '../operations/HTTP'; +import MAC from '../operations/MAC'; +import StrUtils from '../operations/StrUtils'; +import Tidy from '../operations/Tidy'; +import SeqUtils from '../operations/SeqUtils'; +import Extract from '../operations/Extract'; +import DateTime from '../operations/DateTime'; +import Convert from '../operations/Convert'; +import Compress from '../operations/Compress'; +import JS from '../operations/JS'; +import Code from '../operations/Code'; +import Hash from '../operations/Hash'; +import Checksum from '../operations/Checksum'; +import Entropy from '../operations/Entropy'; +import Numberwang from '../operations/Numberwang'; +import PublicKey from '../operations/PublicKey'; +import FileType from '../operations/FileType'; +import OS from '../operations/OS'; +import Endian from '../operations/Endian'; +import UUID from '../operations/UUID'; + /* * Tell JSHint to ignore "'Object' is not defined" errors in this file, as it references every * single operation object by definition. @@ -2784,3 +2820,5 @@ const OperationConfig = { args: [], }, }; + +export default OperationConfig; diff --git a/src/js/core/Chef.js b/src/js/core/Chef.js index 5edf2f7e..79de0353 100755 --- a/src/js/core/Chef.js +++ b/src/js/core/Chef.js @@ -1,3 +1,6 @@ +import Dish from './Dish'; +import Recipe from './Recipe'; + /** * The main controller for CyberChef. * @@ -7,9 +10,9 @@ * * @class */ -const Chef = function () { +export default function Chef() { this.dish = new Dish(); -}; +} /** diff --git a/src/js/core/Dish.js b/src/js/core/Dish.js index 37e531cb..2c520474 100755 --- a/src/js/core/Dish.js +++ b/src/js/core/Dish.js @@ -1,3 +1,5 @@ +import Utils from './Utils'; + /** * The data being operated on by each operation. * @@ -9,10 +11,10 @@ * @param {byte_array|string|number} value - The value of the input data. * @param {number} type - The data type of value, see Dish enums. */ -const Dish = function (value, type) { +export default function Dish(value, type) { this.value = value || typeof value === 'string' ? value : null; this.type = type || Dish.BYTE_ARRAY; -}; +} /** diff --git a/src/js/core/FlowControl.js b/src/js/core/FlowControl.js index 1824c1f0..e0315158 100755 --- a/src/js/core/FlowControl.js +++ b/src/js/core/FlowControl.js @@ -1,3 +1,6 @@ +import Recipe from './Recipe'; +import Dish from './Dish'; + /** * Flow Control operations. * @@ -170,3 +173,5 @@ const FlowControl = { }, }; + +export default FlowControl; diff --git a/src/js/core/Ingredient.js b/src/js/core/Ingredient.js index 534d6ca9..600104fd 100755 --- a/src/js/core/Ingredient.js +++ b/src/js/core/Ingredient.js @@ -1,3 +1,5 @@ +import Utils from './Utils'; + /** * The arguments to operations. * @@ -8,7 +10,7 @@ * @class * @param {Object} ingredient_config */ -const Ingredient = function (ingredient_config) { +export default function Ingredient(ingredient_config) { this.name = ''; this.type = ''; this.value = null; @@ -16,7 +18,7 @@ const Ingredient = function (ingredient_config) { if (ingredient_config) { this._parse_config(ingredient_config); } -}; +} /** @@ -72,7 +74,6 @@ Ingredient.prepare = function (data, type) { } else { return data; } - break; case 'number': var number = parseFloat(data); if (isNaN(number)) { diff --git a/src/js/core/Operation.js b/src/js/core/Operation.js index 9c6bd150..7217b618 100755 --- a/src/js/core/Operation.js +++ b/src/js/core/Operation.js @@ -1,3 +1,6 @@ +import Dish from './Dish'; +import Ingredient from './Ingredient'; + /** * The Operation specified by the user to be run. * @@ -9,7 +12,7 @@ * @param {string} operation_name * @param {Object} operation_config */ -const Operation = function (operation_name, operation_config) { +export default function Operation(operation_name, operation_config) { this.name = operation_name; this.description = ''; this.input_type = -1; @@ -24,7 +27,7 @@ const Operation = function (operation_name, operation_config) { if (operation_config) { this._parse_config(operation_config); } -}; +} /** diff --git a/src/js/core/Recipe.js b/src/js/core/Recipe.js index a4ba7542..f58e8bae 100755 --- a/src/js/core/Recipe.js +++ b/src/js/core/Recipe.js @@ -1,3 +1,6 @@ +import OperationConfig from '../config/OperationConfig'; +import Operation from './Operation'; + /** * The Recipe controls a list of Operations and the Dish they operate on. * diff --git a/src/js/core/Utils.js b/src/js/core/Utils.js index 41951035..0f3c6121 100755 --- a/src/js/core/Utils.js +++ b/src/js/core/Utils.js @@ -1,3 +1,5 @@ +import $ from 'jquery'; + /* globals CryptoJS, moment */ /** @@ -1156,3 +1158,5 @@ CryptoJS.enc.Hex.parse = function (hexStr) { return new CryptoJS.lib.WordArray.init(words, hexStrLength / 2); }; + +export default Utils; diff --git a/src/js/operations/Base.js b/src/js/operations/Base.js index 62af6436..16a7c394 100755 --- a/src/js/operations/Base.js +++ b/src/js/operations/Base.js @@ -50,3 +50,5 @@ const Base = { }, }; + +export default Base; diff --git a/src/js/operations/Base64.js b/src/js/operations/Base64.js index 9b3e6969..8ae8cf5b 100755 --- a/src/js/operations/Base64.js +++ b/src/js/operations/Base64.js @@ -1,3 +1,5 @@ +import Utils from '../core/Utils'; + /** * Base64 operations. * @@ -361,3 +363,5 @@ const Base64 = { }, }; + +export default Base64; diff --git a/src/js/operations/BitwiseOp.js b/src/js/operations/BitwiseOp.js index 2eb02e7e..3b08287c 100755 --- a/src/js/operations/BitwiseOp.js +++ b/src/js/operations/BitwiseOp.js @@ -1,3 +1,5 @@ +import Utils from '../core/Utils'; + /* globals CryptoJS */ /** @@ -298,3 +300,5 @@ const BitwiseOp = { }, }; + +export default BitwiseOp; diff --git a/src/js/operations/ByteRepr.js b/src/js/operations/ByteRepr.js index 85cbfe6a..e84c20ee 100755 --- a/src/js/operations/ByteRepr.js +++ b/src/js/operations/ByteRepr.js @@ -1,3 +1,5 @@ +import Utils from '../core/Utils'; + /* globals app */ /** @@ -396,3 +398,5 @@ const ByteRepr = { }, }; + +export default ByteRepr; diff --git a/src/js/operations/CharEnc.js b/src/js/operations/CharEnc.js index 8f089f6f..a419986b 100755 --- a/src/js/operations/CharEnc.js +++ b/src/js/operations/CharEnc.js @@ -1,3 +1,5 @@ +import Utils from '../core/Utils'; + /* globals CryptoJS */ /** @@ -44,3 +46,5 @@ const CharEnc = { }, }; + +export default CharEnc; diff --git a/src/js/operations/Checksum.js b/src/js/operations/Checksum.js index 09372ae7..263f98e2 100755 --- a/src/js/operations/Checksum.js +++ b/src/js/operations/Checksum.js @@ -1,3 +1,5 @@ +import Utils from '../core/Utils'; + /** * Checksum operations. * @@ -128,3 +130,5 @@ const Checksum = { }, }; + +export default Checksum; diff --git a/src/js/operations/Cipher.js b/src/js/operations/Cipher.js index 2d59d48c..693e2012 100755 --- a/src/js/operations/Cipher.js +++ b/src/js/operations/Cipher.js @@ -1,3 +1,4 @@ +import Utils from '../core/Utils'; /* globals CryptoJS, blowfish */ /** @@ -427,3 +428,5 @@ CryptoJS.kdf.OpenSSL.execute = function (password, keySize, ivSize, salt) { // Return params return CryptoJS.lib.CipherParams.create({ key, iv, salt }); }; + +export default Cipher; diff --git a/src/js/operations/Code.js b/src/js/operations/Code.js index 2f0edae8..78503859 100755 --- a/src/js/operations/Code.js +++ b/src/js/operations/Code.js @@ -1,3 +1,5 @@ +import Utils from '../core/Utils'; + /* globals prettyPrintOne, vkbeautify */ /** @@ -303,3 +305,5 @@ const Code = { }, }; + +export default Code; diff --git a/src/js/operations/Compress.js b/src/js/operations/Compress.js index 9a7207e6..f5a328ee 100755 --- a/src/js/operations/Compress.js +++ b/src/js/operations/Compress.js @@ -1,3 +1,6 @@ +import Utils from '../core/Utils'; +import Uint8Array from 'core-js/modules/es6.typed.uint8-array'; + /* globals Zlib, bzip2 */ /** @@ -346,3 +349,5 @@ const Compress = { }, }; + +export default Compress; diff --git a/src/js/operations/Convert.js b/src/js/operations/Convert.js index 97861721..bbe087cd 100755 --- a/src/js/operations/Convert.js +++ b/src/js/operations/Convert.js @@ -410,3 +410,5 @@ const Convert = { }, }; + +export default Convert; diff --git a/src/js/operations/DateTime.js b/src/js/operations/DateTime.js index 29b00299..c5a859ec 100755 --- a/src/js/operations/DateTime.js +++ b/src/js/operations/DateTime.js @@ -452,3 +452,5 @@ const DateTime = { }; + +export default DateTime; diff --git a/src/js/operations/Endian.js b/src/js/operations/Endian.js index ae852983..8e4ea25f 100755 --- a/src/js/operations/Endian.js +++ b/src/js/operations/Endian.js @@ -1,3 +1,4 @@ +import Utils from '../core/Utils'; /** * Endian operations. * @@ -92,3 +93,5 @@ const Endian = { }, }; + +export default Endian; diff --git a/src/js/operations/Entropy.js b/src/js/operations/Entropy.js index b22f8dd9..f10cfb5c 100755 --- a/src/js/operations/Entropy.js +++ b/src/js/operations/Entropy.js @@ -1,3 +1,4 @@ +import Utils from '../core/Utils'; /** * Entropy operations. * @@ -164,3 +165,5 @@ const Entropy = { }, }; + +export default Entropy; diff --git a/src/js/operations/Extract.js b/src/js/operations/Extract.js index f381c58e..eb8b122c 100755 --- a/src/js/operations/Extract.js +++ b/src/js/operations/Extract.js @@ -297,3 +297,5 @@ const Extract = { }, }; + +export default Extract; diff --git a/src/js/operations/FileType.js b/src/js/operations/FileType.js index f98f0566..8b16e92e 100755 --- a/src/js/operations/FileType.js +++ b/src/js/operations/FileType.js @@ -1,3 +1,5 @@ +import Utils from '../core/Utils'; + /** * File type operations. * @@ -524,3 +526,5 @@ const FileType = { }, }; + +export default FileType; diff --git a/src/js/operations/HTML.js b/src/js/operations/HTML.js index f9a72358..25389b10 100755 --- a/src/js/operations/HTML.js +++ b/src/js/operations/HTML.js @@ -1,3 +1,5 @@ +import Utils from '../core/Utils'; + /** * HTML operations. * @@ -205,9 +207,9 @@ const HTML = { l = Math.round(hsl_[2] * 100), k = 1 - Math.max(r / 255, g / 255, b / 255), c = (1 - r / 255 - k) / (1 - k), - m = (1 - g / 255 - k) / (1 - k), // jshint ignore:line y = (1 - b / 255 - k) / (1 - k); + m = (1 - g / 255 - k) / (1 - k); c = isNaN(c) ? '0' : c.toFixed(2); m = isNaN(m) ? '0' : m.toFixed(2); y = isNaN(y) ? '0' : y.toFixed(2); diff --git a/src/js/operations/HTTP.js b/src/js/operations/HTTP.js index 3dd80143..d3cc0073 100755 --- a/src/js/operations/HTTP.js +++ b/src/js/operations/HTTP.js @@ -51,3 +51,5 @@ const HTTP = { }, }; + +export default HTTP; diff --git a/src/js/operations/Hash.js b/src/js/operations/Hash.js index 0211a018..23719a32 100755 --- a/src/js/operations/Hash.js +++ b/src/js/operations/Hash.js @@ -1,3 +1,5 @@ +import Utils from '../core/Utils'; + /* globals CryptoJS, Checksum */ /** @@ -339,3 +341,5 @@ const Hash = { }, }; + +export default Hash; diff --git a/src/js/operations/Hexdump.js b/src/js/operations/Hexdump.js index 0deeac9e..dc4adc3a 100755 --- a/src/js/operations/Hexdump.js +++ b/src/js/operations/Hexdump.js @@ -1,3 +1,5 @@ +import Utils from '../core/Utils'; + /* globals app */ /** @@ -196,3 +198,5 @@ const Hexdump = { }, }; + +export default Hexdump; diff --git a/src/js/operations/IP.js b/src/js/operations/IP.js index 8f3701c0..a075a632 100755 --- a/src/js/operations/IP.js +++ b/src/js/operations/IP.js @@ -1,3 +1,5 @@ +import Utils from '../core/Utils'; + /* globals BigInteger */ /** @@ -802,3 +804,5 @@ const IP = { }, }; + +export default IP; diff --git a/src/js/operations/JS.js b/src/js/operations/JS.js index 03f38a1d..1ffe102d 100755 --- a/src/js/operations/JS.js +++ b/src/js/operations/JS.js @@ -158,3 +158,5 @@ const JS = { }, }; + +export default JS; diff --git a/src/js/operations/MAC.js b/src/js/operations/MAC.js index 91b97b27..51d7bd47 100755 --- a/src/js/operations/MAC.js +++ b/src/js/operations/MAC.js @@ -86,3 +86,5 @@ const MAC = { }, }; + +export default MAC; diff --git a/src/js/operations/Numberwang.js b/src/js/operations/Numberwang.js index c7555489..f02743f1 100755 --- a/src/js/operations/Numberwang.js +++ b/src/js/operations/Numberwang.js @@ -25,3 +25,5 @@ const Numberwang = { }, }; + +export default Numberwang; diff --git a/src/js/operations/OS.js b/src/js/operations/OS.js index 1a4228c9..d3cd0e43 100755 --- a/src/js/operations/OS.js +++ b/src/js/operations/OS.js @@ -307,3 +307,5 @@ const OS = { }, }; + +export default OS; diff --git a/src/js/operations/PublicKey.js b/src/js/operations/PublicKey.js index 32b06155..a7800ae9 100755 --- a/src/js/operations/PublicKey.js +++ b/src/js/operations/PublicKey.js @@ -1,3 +1,5 @@ +import Utils from '../core/Utils'; + /* globals X509, KJUR, ASN1HEX, KEYUTIL, BigInteger */ /** @@ -1051,3 +1053,5 @@ X509.DN_ATTRHEX = { '060355080101': 'rsa', '0603604c0101': 'DPC', }; + +export default PublicKey; diff --git a/src/js/operations/Punycode.js b/src/js/operations/Punycode.js index e6b80968..45433a09 100755 --- a/src/js/operations/Punycode.js +++ b/src/js/operations/Punycode.js @@ -53,3 +53,5 @@ const Punycode = { }, }; + +export default Punycode; diff --git a/src/js/operations/QuotedPrintable.js b/src/js/operations/QuotedPrintable.js index 8ce6b188..f864a81c 100755 --- a/src/js/operations/QuotedPrintable.js +++ b/src/js/operations/QuotedPrintable.js @@ -266,3 +266,5 @@ const QuotedPrintable = { }, }; + +export default QuotedPrintable; diff --git a/src/js/operations/Rotate.js b/src/js/operations/Rotate.js index 568e9204..53bd47f3 100755 --- a/src/js/operations/Rotate.js +++ b/src/js/operations/Rotate.js @@ -204,3 +204,5 @@ const Rotate = { }, }; + +export default Rotate; diff --git a/src/js/operations/SeqUtils.js b/src/js/operations/SeqUtils.js index 16bb4cf5..b1d0b0a5 100755 --- a/src/js/operations/SeqUtils.js +++ b/src/js/operations/SeqUtils.js @@ -1,3 +1,5 @@ +import Utils from '../core/Utils'; + /** * Sequence utility operations. * @@ -218,3 +220,5 @@ const SeqUtils = { }, }; + +export default SeqUtils; diff --git a/src/js/operations/StrUtils.js b/src/js/operations/StrUtils.js index 67b808f5..9d2a9103 100755 --- a/src/js/operations/StrUtils.js +++ b/src/js/operations/StrUtils.js @@ -1,3 +1,5 @@ +import Utils from '../core/Utils'; + /* globals JsDiff */ /** @@ -502,3 +504,5 @@ const StrUtils = { }, }; + +export default StrUtils; diff --git a/src/js/operations/Tidy.js b/src/js/operations/Tidy.js index 00fe817f..bc622876 100755 --- a/src/js/operations/Tidy.js +++ b/src/js/operations/Tidy.js @@ -1,3 +1,5 @@ +import Utils from '../core/Utils'; + /** * Tidy operations. * @@ -240,3 +242,5 @@ const Tidy = { }, }; + +export default Tidy; diff --git a/src/js/operations/URL.js b/src/js/operations/URL.js index 0704494e..d9295290 100755 --- a/src/js/operations/URL.js +++ b/src/js/operations/URL.js @@ -1,3 +1,4 @@ +import Utils from '../core/Utils'; /* globals unescape */ /** @@ -131,3 +132,5 @@ const URL_ = { }, }; + +export default URL_; diff --git a/src/js/operations/UUID.js b/src/js/operations/UUID.js index 1909f9ad..fc24a6bd 100755 --- a/src/js/operations/UUID.js +++ b/src/js/operations/UUID.js @@ -1,3 +1,5 @@ +import Uint32Array from 'core-js/modules/es6.typed.uint32-array'; + /** * UUID operations. * @@ -37,3 +39,5 @@ const UUID = { }, }; + +export default UUID; diff --git a/src/js/operations/Unicode.js b/src/js/operations/Unicode.js index e7d62b40..1c17c1d4 100755 --- a/src/js/operations/Unicode.js +++ b/src/js/operations/Unicode.js @@ -1,3 +1,5 @@ +import Utils from '../core/Utils'; + /** * Unicode operations. * @@ -60,3 +62,5 @@ const Unicode = { }, }; + +export default Unicode; diff --git a/src/js/views/html/ControlsWaiter.js b/src/js/views/html/ControlsWaiter.js index e00c8cd4..ed162fa7 100755 --- a/src/js/views/html/ControlsWaiter.js +++ b/src/js/views/html/ControlsWaiter.js @@ -1,3 +1,5 @@ +import $ from 'jquery'; +import Utils from '../../core/Utils'; /** * Waiter to handle events related to the CyberChef controls (i.e. Bake, Step, Save, Load etc.) * @@ -9,10 +11,10 @@ * @param {HTMLApp} app - The main view object for CyberChef. * @param {Manager} manager - The CyberChef event manager. */ -const ControlsWaiter = function (app, manager) { +export default function ControlsWaiter(app, manager) { this.app = app; this.manager = manager; -}; +} /** @@ -191,7 +193,9 @@ ControlsWaiter.prototype.save_text_change = function () { try { const recipe_config = JSON.parse(document.getElementById('save-text').value); this.initialise_save_link(recipe_config); - } catch (err) {} + } catch (err) { + // ignore error + } }; diff --git a/src/js/views/html/HTMLApp.js b/src/js/views/html/HTMLApp.js index 2ce1ace8..c1ffdb7e 100755 --- a/src/js/views/html/HTMLApp.js +++ b/src/js/views/html/HTMLApp.js @@ -1,3 +1,12 @@ +import $ from 'jquery'; + +import Utils from '../../core/Utils'; +import Chef from '../../core/Chef'; +import Manager from './Manager'; +import HTMLCategory from './HTMLCategory'; +import HTMLOperation from './HTMLOperation'; + + /* globals Split */ /** @@ -14,7 +23,7 @@ * @param {String[]} default_favourites - A list of default favourite operations. * @param {Object} options - Default setting for app options. */ -const HTMLApp = function (categories, operations, default_favourites, default_options) { +export default function HTMLApp(categories, operations, default_favourites, default_options) { this.categories = categories; this.operations = operations; this.dfavourites = default_favourites; @@ -29,7 +38,7 @@ const HTMLApp = function (categories, operations, default_favourites, default_op this.ing_id = 0; window.chef = this.chef; -}; +} /** @@ -356,7 +365,9 @@ HTMLApp.prototype.load_URI_params = function () { try { const recipe_config = JSON.parse(this.query_string.recipe); this.set_recipe_config(recipe_config); - } catch (err) {} + } catch (err) { + // ignore error + } } else if (this.query_string.op) { // If there's no recipe, look for single operations this.manager.recipe.clear_recipe(); @@ -382,7 +393,9 @@ HTMLApp.prototype.load_URI_params = function () { try { const input_data = Utils.from_base64(this.query_string.input); this.set_input(input_data); - } catch (err) {} + } catch (err) { + // ignore error + } } // Restore auto-bake state diff --git a/src/js/views/html/HTMLCategory.js b/src/js/views/html/HTMLCategory.js index 3a3ed925..d418550c 100755 --- a/src/js/views/html/HTMLCategory.js +++ b/src/js/views/html/HTMLCategory.js @@ -9,11 +9,11 @@ * @param {string} name - The name of the category. * @param {boolean} selected - Whether this category is pre-selected or not. */ -const HTMLCategory = function (name, selected) { +export default function HTMLCategory(name, selected) { this.name = name; this.selected = selected; this.op_list = []; -}; +} /** diff --git a/src/js/views/html/HTMLIngredient.js b/src/js/views/html/HTMLIngredient.js index a5ea0a8f..d4089954 100755 --- a/src/js/views/html/HTMLIngredient.js +++ b/src/js/views/html/HTMLIngredient.js @@ -10,7 +10,7 @@ * @param {HTMLApp} app - The main view object for CyberChef. * @param {Manager} manager - The CyberChef event manager. */ -const HTMLIngredient = function (config, app, manager) { +export default function HTMLIngredient(config, app, manager) { this.app = app; this.manager = manager; @@ -23,7 +23,7 @@ const HTMLIngredient = function (config, app, manager) { this.target = config.target; this.toggle_values = config.toggle_values; this.id = `ing-${this.app.next_ing_id()}`; -}; +} /** diff --git a/src/js/views/html/HTMLOperation.js b/src/js/views/html/HTMLOperation.js index 1405fa8d..2f6acfe9 100755 --- a/src/js/views/html/HTMLOperation.js +++ b/src/js/views/html/HTMLOperation.js @@ -1,3 +1,5 @@ +import HTMLIngredient from './HTMLIngredient'; + /** * Object to handle the creation of operations. * @@ -11,7 +13,7 @@ * @param {HTMLApp} app - The main view object for CyberChef. * @param {Manager} manager - The CyberChef event manager. */ -const HTMLOperation = function (name, config, app, manager) { +export default function HTMLOperation(name, config, app, manager) { this.app = app; this.manager = manager; @@ -25,7 +27,7 @@ const HTMLOperation = function (name, config, app, manager) { const ing = new HTMLIngredient(config.args[i], this.app, this.manager); this.ing_list.push(ing); } -}; +} /** diff --git a/src/js/views/html/HighlighterWaiter.js b/src/js/views/html/HighlighterWaiter.js index 51de90e3..931cbdc4 100755 --- a/src/js/views/html/HighlighterWaiter.js +++ b/src/js/views/html/HighlighterWaiter.js @@ -1,3 +1,4 @@ +import Utils from '../../core/Utils'; /** * Waiter to handle events related to highlighting in CyberChef. * @@ -8,12 +9,12 @@ * @constructor * @param {HTMLApp} app - The main view object for CyberChef. */ -const HighlighterWaiter = function (app) { +export default function HighlighterWaiter(app) { this.app = app; this.mouse_button_down = false; this.mouse_target = null; -}; +} /** diff --git a/src/js/views/html/InputWaiter.js b/src/js/views/html/InputWaiter.js index a70e217b..275144e7 100755 --- a/src/js/views/html/InputWaiter.js +++ b/src/js/views/html/InputWaiter.js @@ -1,3 +1,5 @@ +import Uint8Array from 'core-js/modules/es6.typed.uint8-array'; +import Utils from '../../core/Utils'; /** * Waiter to handle events related to the input. * @@ -9,7 +11,7 @@ * @param {HTMLApp} app - The main view object for CyberChef. * @param {Manager} manager - The CyberChef event manager. */ -const InputWaiter = function (app, manager) { +export default function InputWaiter(app, manager) { this.app = app; this.manager = manager; @@ -30,7 +32,7 @@ const InputWaiter = function (app, manager) { 144, // Num 145, //Scroll ]; -}; +} /** diff --git a/src/js/views/html/Manager.js b/src/js/views/html/Manager.js index 6abdf37a..d64154f4 100755 --- a/src/js/views/html/Manager.js +++ b/src/js/views/html/Manager.js @@ -1,3 +1,15 @@ +import $ from 'jquery'; + +import WindowWaiter from './WindowWaiter'; +import ControlsWaiter from './ControlsWaiter'; +import RecipeWaiter from './RecipeWaiter'; +import OperationsWaiter from './OperationsWaiter'; +import InputWaiter from './InputWaiter'; +import OutputWaiter from './OutputWaiter'; +import HighlighterWaiter from './HighlighterWaiter'; +import SeasonalWaiter from './SeasonalWaiter'; +import OptionsWaiter from './OptionsWaiter'; + /** * This object controls the Waiters responsible for handling events from all areas of the app. * diff --git a/src/js/views/html/OperationsWaiter.js b/src/js/views/html/OperationsWaiter.js index 878ba62f..83315fb0 100755 --- a/src/js/views/html/OperationsWaiter.js +++ b/src/js/views/html/OperationsWaiter.js @@ -1,3 +1,6 @@ +import $ from 'jquery'; +import HTMLOperation from './HTMLOperation'; + /* globals Sortable */ /** @@ -11,13 +14,13 @@ * @param {HTMLApp} app - The main view object for CyberChef. * @param {Manager} manager - The CyberChef event manager. */ -const OperationsWaiter = function (app, manager) { +export default function OperationsWaiter(app, manager) { this.app = app; this.manager = manager; this.options = {}; this.remove_intent = false; -}; +} /** diff --git a/src/js/views/html/OptionsWaiter.js b/src/js/views/html/OptionsWaiter.js index 63162afe..65a5a2f8 100755 --- a/src/js/views/html/OptionsWaiter.js +++ b/src/js/views/html/OptionsWaiter.js @@ -1,3 +1,5 @@ +import $ from 'jquery'; + /** * Waiter to handle events related to the CyberChef options. * @@ -8,9 +10,9 @@ * @constructor * @param {HTMLApp} app - The main view object for CyberChef. */ -const OptionsWaiter = function (app) { +export default function OptionsWaiter(app) { this.app = app; -}; +} /** diff --git a/src/js/views/html/OutputWaiter.js b/src/js/views/html/OutputWaiter.js index e00df9d0..73ba94d2 100755 --- a/src/js/views/html/OutputWaiter.js +++ b/src/js/views/html/OutputWaiter.js @@ -1,3 +1,5 @@ +import Utils from '../../core/Utils'; + /** * Waiter to handle events related to the output. * @@ -9,10 +11,10 @@ * @param {HTMLApp} app - The main view object for CyberChef. * @param {Manager} manager - The CyberChef event manager. */ -const OutputWaiter = function (app, manager) { +export default function OutputWaiter(app, manager) { this.app = app; this.manager = manager; -}; +} /** diff --git a/src/js/views/html/RecipeWaiter.js b/src/js/views/html/RecipeWaiter.js index 8f016bc6..54d67215 100755 --- a/src/js/views/html/RecipeWaiter.js +++ b/src/js/views/html/RecipeWaiter.js @@ -1,3 +1,5 @@ +import $ from 'jquery'; +import HTMLOperation from './HTMLOperation'; /* globals Sortable */ /** @@ -11,11 +13,11 @@ * @param {HTMLApp} app - The main view object for CyberChef. * @param {Manager} manager - The CyberChef event manager. */ -const RecipeWaiter = function (app, manager) { +export default function RecipeWaiter(app, manager) { this.app = app; this.manager = manager; this.remove_intent = false; -}; +} /** @@ -405,7 +407,7 @@ RecipeWaiter.prototype.dropdown_toggle_click = function (e) { * @fires Manager#statechange * @param {event} e */ -RecipeWaiter.prototype.op_add = function (e) { +RecipeWaiter.prototype.op_add = function () { window.dispatchEvent(this.manager.statechange); }; @@ -417,6 +419,6 @@ RecipeWaiter.prototype.op_add = function (e) { * @fires Manager#statechange * @param {event} e */ -RecipeWaiter.prototype.op_remove = function (e) { +RecipeWaiter.prototype.op_remove = function () { window.dispatchEvent(this.manager.statechange); }; diff --git a/src/js/views/html/SeasonalWaiter.js b/src/js/views/html/SeasonalWaiter.js index 3a36897d..5d9b03d4 100755 --- a/src/js/views/html/SeasonalWaiter.js +++ b/src/js/views/html/SeasonalWaiter.js @@ -1,3 +1,5 @@ +import $ from 'jquery'; + /** * Waiter to handle seasonal events and easter eggs. * @@ -9,10 +11,10 @@ * @param {HTMLApp} app - The main view object for CyberChef. * @param {Manager} manager - The CyberChef event manager. */ -const SeasonalWaiter = function (app, manager) { +export default function SeasonalWaiter(app, manager) { this.app = app; this.manager = manager; -}; +} /** diff --git a/src/js/views/html/WindowWaiter.js b/src/js/views/html/WindowWaiter.js index 3b32fe76..803fed89 100755 --- a/src/js/views/html/WindowWaiter.js +++ b/src/js/views/html/WindowWaiter.js @@ -8,9 +8,9 @@ * @constructor * @param {HTMLApp} app - The main view object for CyberChef. */ -const WindowWaiter = function (app) { +export default function WindowWaiter(app) { this.app = app; -}; +} /** diff --git a/src/js/views/html/main.js b/src/js/views/html/main.js index 16977685..16fa2c57 100755 --- a/src/js/views/html/main.js +++ b/src/js/views/html/main.js @@ -1,3 +1,6 @@ +import HTMLApp from './HTMLApp'; +import Categories from '../../config/Categories'; +import OperationConfig from '../../config/OperationConfig'; /* globals moment */ /** diff --git a/yarn.lock b/yarn.lock index 740be2d9..2b05477d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1185,7 +1185,7 @@ cookie@0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" -core-js@^2.4.0: +core-js@^2.4.0, core-js@^2.4.1: version "2.4.1" resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.4.1.tgz#4de911e667b0eae9124e34254b53aea6fc618d3e"