Skip to content

Commit

Permalink
Added operation counts to categories and ops list with option to hide…
Browse files Browse the repository at this point in the history
… by default for categories.
  • Loading branch information
n1474335 committed May 13, 2024
1 parent bbebba6 commit 57c8c6d
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/web/HTMLCategory.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class HTMLCategory {
let html = `<div class="panel category">
<a class="category-title" data-toggle="collapse" data-target="#${catName}">
${this.name}
<span class="op-count hidden">
${this.opList.length}
</span>
</a>
<div id="${catName}" class="panel-collapse collapse ${(this.selected ? " show" : "")}" data-parent="#categories">
<ul class="op-list">`;
Expand Down
1 change: 1 addition & 0 deletions src/web/Manager.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ class Manager {
this.addDynamicListener(".option-item input[type=checkbox]", "change", this.options.switchChange, this.options);
this.addDynamicListener(".option-item input[type=checkbox]#wordWrap", "change", this.options.setWordWrap, this.options);
this.addDynamicListener(".option-item input[type=checkbox]#useMetaKey", "change", this.bindings.updateKeybList, this.bindings);
this.addDynamicListener(".option-item input[type=checkbox]#showCatCount", "change", this.ops.setCatCount, this.ops);
this.addDynamicListener(".option-item input[type=number]", "keyup", this.options.numberChange, this.options);
this.addDynamicListener(".option-item input[type=number]", "change", this.options.numberChange, this.options);
this.addDynamicListener(".option-item select", "change", this.options.selectChange, this.options);
Expand Down
8 changes: 8 additions & 0 deletions src/web/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
<div id="operations" class="split split-horizontal no-select">
<div class="title no-select" data-help-title="Operations list" data-help="<p>The Operations list contains all the operations in CyberChef arranged into categories. Some operations may be present in multiple categories. You can search for operations using the search box.</p><p>To use an operation, either double click it, or drag it into the Recipe pane. You will then be able to configure its arguments (or 'Ingredients' in CyberChef terminology).</p>">
Operations
<span class="op-count"></span>
</div>
<input id="search" type="search" class="form-control" placeholder="Search..." autocomplete="off" tabindex="2" data-help-title="Searching for operations" data-help="<p>Use the search box to find useful operations.</p><p>Both operation names and descriptions are queried using a fuzzy matching algorithm.</p>">
<ul id="search-results" class="op-list"></ul>
Expand Down Expand Up @@ -521,6 +522,13 @@ <h5 class="modal-title">Options</h5>
Keep the current tab in sync between the input and output
</label>
</div>

<div class="checkbox option-item">
<label for="showCatCount">
<input type="checkbox" option="showCatCount" id="showCatCount">
Show the number of operations in each category
</label>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" id="reset-options">Reset options to default</button>
Expand Down
3 changes: 2 additions & 1 deletion src/web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ function main() {
logLevel: "info",
autoMagic: true,
imagePreview: true,
syncTabs: true
syncTabs: true,
showCatCount: false,
};

document.removeEventListener("DOMContentLoaded", main, false);
Expand Down
11 changes: 10 additions & 1 deletion src/web/stylesheets/components/_list.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,13 @@
margin: 0 !important;
border-radius: 0 !important;
border: none;
}
}

.op-count {
float: right;
color: var(--subtext-font-colour);
font-weight: normal;
font-size: xx-small;
opacity: 0.5;
padding-left: .5em;
}
4 changes: 4 additions & 0 deletions src/web/stylesheets/utils/_general.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ body {
line-height: 0;
}

.hidden {
display: none;
}

.blur {
color: transparent !important;
text-shadow: rgba(0, 0, 0, 0.95) 0 0 10px !important;
Expand Down
16 changes: 16 additions & 0 deletions src/web/waiters/OperationsWaiter.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ class OperationsWaiter {
*/
opListCreate(e) {
this.manager.recipe.createSortableSeedList(e.target);

// Populate ops total
document.querySelector("#operations .title .op-count").innerText = Object.keys(this.app.operations).length;

this.enableOpsListPopovers(e.target);
}

Expand Down Expand Up @@ -293,6 +297,18 @@ class OperationsWaiter {
this.app.resetFavourites();
}


/**
* Sets whether operation counts are displayed next to a category title
*/
setCatCount() {
if (this.app.options.showCatCount) {
document.querySelectorAll(".category-title .op-count").forEach(el => el.classList.remove("hidden"));
} else {
document.querySelectorAll(".category-title .op-count").forEach(el => el.classList.add("hidden"));
}
}

}

export default OperationsWaiter;
1 change: 1 addition & 0 deletions src/web/waiters/OptionsWaiter.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class OptionsWaiter {

// Initialise options
this.setWordWrap();
this.manager.ops.setCatCount();
}


Expand Down

0 comments on commit 57c8c6d

Please sign in to comment.