1
0
mirror of synced 2024-11-27 16:10:55 +01:00

Added operation counts to categories and ops list with option to hide by default for categories.

This commit is contained in:
n1474335 2024-05-13 17:48:09 +01:00
parent bbebba6481
commit 57c8c6dbc6
No known key found for this signature in database
GPG Key ID: D15457B7B4AF3F37
8 changed files with 45 additions and 2 deletions

View File

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

View File

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

View File

@ -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>
@ -521,6 +522,13 @@
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>

View File

@ -51,7 +51,8 @@ function main() {
logLevel: "info",
autoMagic: true,
imagePreview: true,
syncTabs: true
syncTabs: true,
showCatCount: false,
};
document.removeEventListener("DOMContentLoaded", main, false);

View File

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

View File

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

View File

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

View File

@ -50,6 +50,7 @@ class OptionsWaiter {
// Initialise options
this.setWordWrap();
this.manager.ops.setCatCount();
}