diff --git a/src/web/App.mjs b/src/web/App.mjs index 911f51b8..9f43a9d2 100755 --- a/src/web/App.mjs +++ b/src/web/App.mjs @@ -246,8 +246,6 @@ class App { /** * Sets up the adjustable splitter to allow the user to resize areas of the page. - * - * @param {boolean} [minimise=false] - Set this flag if attempting to minimise frames to 0 width */ buildUI() { if (this.isMobileView()) { @@ -259,6 +257,8 @@ class App { /** * Set desktop splitters + * + * @param {boolean} minimise */ setDesktopSplitter(minimise) { if (this.columnSplitter) this.columnSplitter.destroy(); @@ -269,7 +269,7 @@ class App { minSize: minimise ? [0, 0, 0] : [360, 330, 310], gutterSize: 4, expandToMin: true, - onDrag: debounce(function() { + onDrag: debounce(() => { this.adjustComponentSizes(); }, 50, "dragSplitter", this, []) }); diff --git a/src/web/HTMLOperation.mjs b/src/web/HTMLOperation.mjs deleted file mode 100755 index 0b076c34..00000000 --- a/src/web/HTMLOperation.mjs +++ /dev/null @@ -1,83 +0,0 @@ -/** - * @author n1474335 [n1474335@gmail.com] - * @copyright Crown Copyright 2016 - * @license Apache-2.0 - */ - -/** - * Object to handle the creation of operations. - */ -class HTMLOperation { - - /** - * HTMLOperation constructor. - * - * @param {string} name - The name of the operation. - * @param {Object} config - The configuration object for this operation. - * @param {App} app - The main view object for CyberChef. - * @param {Manager} manager - The CyberChef event manager. - */ - constructor(name, config, app, manager) { - this.app = app; - this.manager = manager; - - this.name = name; - this.description = config.description; - this.infoURL = config.infoURL; - this.manualBake = config.manualBake || false; - this.config = config; - } - - - /** - * Highlights searched strings in the name and description of the operation. - * - * @param {[[number]]} nameIdxs - Indexes of the search strings in the operation name [[start, length]] - * @param {[[number]]} descIdxs - Indexes of the search strings in the operation description [[start, length]] - */ - highlightSearchStrings(nameIdxs, descIdxs) { - if (nameIdxs.length && typeof nameIdxs[0][0] === "number") { - let opName = "", - pos = 0; - - nameIdxs.forEach(idxs => { - const [start, length] = idxs; - if (typeof start !== "number") return; - opName += this.name.slice(pos, start) + "" + - this.name.slice(start, start + length) + ""; - pos = start + length; - }); - opName += this.name.slice(pos, this.name.length); - this.name = opName; - } - - if (this.description && descIdxs.length && descIdxs[0][0] >= 0) { - // Find HTML tag offsets - const re = /<[^>]+>/g; - let match; - while ((match = re.exec(this.description))) { - // If the search string occurs within an HTML tag, return without highlighting it. - const inHTMLTag = descIdxs.reduce((acc, idxs) => { - const start = idxs[0]; - return start >= match.index && start <= (match.index + match[0].length); - }, false); - - if (inHTMLTag) return; - } - - let desc = "", - pos = 0; - - descIdxs.forEach(idxs => { - const [start, length] = idxs; - desc += this.description.slice(pos, start) + "" + - this.description.slice(start, start + length) + ""; - pos = start + length; - }); - desc += this.description.slice(pos, this.description.length); - this.description = desc; - } - } -} - -export default HTMLOperation; diff --git a/src/web/TODO.md b/src/web/TODO.md index d5ba0870..f7b669d5 100644 --- a/src/web/TODO.md +++ b/src/web/TODO.md @@ -1,5 +1,8 @@ - ignore dropped item outside of rec-list -- search-results dropdown - can only drag an op to favourites 1 time - stupid popovers on deleting favs for instance ( dont always close nicely ) - UI tests etc. +- esc on selected-op search results will add that op to recipe +- highlight strings +- initial search is kinda slow + diff --git a/src/web/components/c-operation-li.mjs b/src/web/components/c-operation-li.mjs index 365a6a2e..112d4b26 100644 --- a/src/web/components/c-operation-li.mjs +++ b/src/web/components/c-operation-li.mjs @@ -50,7 +50,7 @@ export class COperationLi extends HTMLElement { } /** - * @fires OperationsWaiter#operationDblclick on double click + * Handle double click * @param {Event} e */ handleDoubleClick(e) { @@ -72,7 +72,6 @@ export class COperationLi extends HTMLElement { } } - /** * Disable or enable popover for an element * @@ -252,6 +251,57 @@ export class COperationLi extends HTMLElement { const { app, name, icon, includeStarIcon } = this; return new COperationLi( app, name, icon, includeStarIcon ); } + + + /** + * Highlights searched strings in the name and description of the operation. + * + * @param {[[number]]} nameIdxs - Indexes of the search strings in the operation name [[start, length]] + * @param {[[number]]} descIdxs - Indexes of the search strings in the operation description [[start, length]] + */ + highlightSearchStrings(nameIdxs, descIdxs) { + if (nameIdxs.length && typeof nameIdxs[0][0] === "number") { + let opName = "", + pos = 0; + + nameIdxs.forEach(idxs => { + const [start, length] = idxs; + if (typeof start !== "number") return; + opName += this.name.slice(pos, start) + "" + + this.name.slice(start, start + length) + ""; + pos = start + length; + }); + opName += this.name.slice(pos, this.name.length); + this.name = opName; + } + + if (this.description && descIdxs.length && descIdxs[0][0] >= 0) { + // Find HTML tag offsets + const re = /<[^>]+>/g; + let match; + while ((match = re.exec(this.description))) { + // If the search string occurs within an HTML tag, return without highlighting it. + const inHTMLTag = descIdxs.reduce((acc, idxs) => { + const start = idxs[0]; + return start >= match.index && start <= (match.index + match[0].length); + }, false); + + if (inHTMLTag) return; + } + + let desc = "", + pos = 0; + + descIdxs.forEach(idxs => { + const [start, length] = idxs; + desc += this.description.slice(pos, start) + "" + + this.description.slice(start, start + length) + ""; + pos = start + length; + }); + desc += this.description.slice(pos, this.description.length); + this.description = desc; + } + } } diff --git a/src/web/components/c-operation-list.mjs b/src/web/components/c-operation-list.mjs index 17944b53..d922a6ec 100644 --- a/src/web/components/c-operation-list.mjs +++ b/src/web/components/c-operation-list.mjs @@ -16,8 +16,7 @@ export class COperationList extends HTMLElement { includeStarIcon, isSortable = false, isCloneable = true, - icon, - + icon ) { super(); @@ -118,7 +117,6 @@ export class COperationList extends HTMLElement { .off(".popover") .removeData("bs.popover"); }, - // @todo: popovers dont display anymore after dragging into recipe list and then hovering the op onEnd: ({item}) => { if (item.parentNode.id === targetListId) { this.app.manager.recipe.addOperation(item.name); diff --git a/src/web/html/index.html b/src/web/html/index.html index 77647e2d..ddd47add 100755 --- a/src/web/html/index.html +++ b/src/web/html/index.html @@ -204,12 +204,12 @@ class="form-control" placeholder="Search..." autocomplete="off" - tabindex="2" + tabindex="0" data-help-title="Searching for operations" data-help="
Use the search box to find useful operations.
Both operation names and descriptions are queried using a fuzzy matching algorithm.
" /> -