mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-08 15:25:01 -04:00
add c-operation-list so any of these elements ( category list, category list item, operation list, operation list item ) can be created individually or simply through their parent. Also fix some annotations across the app that used event instead of Event, causing the IDE to get confused
This commit is contained in:
parent
b1b0be254b
commit
6f6e9cce39
16 changed files with 235 additions and 197 deletions
45
src/web/components/c-operation-list.mjs
Normal file
45
src/web/components/c-operation-list.mjs
Normal file
|
@ -0,0 +1,45 @@
|
|||
import {COperationLi} from "./c-operation-li.mjs";
|
||||
|
||||
/**
|
||||
* c(ustom element)-operation-list
|
||||
*
|
||||
* @param {App} app - The main view object for CyberChef
|
||||
* @param {string[]} opNames - A list of operation names
|
||||
* @param {boolean} includeStarIcon - optionally add the 'star' icon to the left of the operation
|
||||
* @param {Object} icon ( { class: string, innerText: string } ). check-icon by default
|
||||
*/
|
||||
export class COperationList extends HTMLElement {
|
||||
constructor(app, opNames, includeStarIcon, icon) {
|
||||
super();
|
||||
|
||||
this.app = app;
|
||||
this.opNames = opNames;
|
||||
this.includeStarIcon = includeStarIcon;
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
build() {
|
||||
const ul = document.createElement("ul");
|
||||
ul.classList.add("op-list");
|
||||
|
||||
this.opNames.forEach((opName => {
|
||||
const li = new COperationLi(
|
||||
this.app,
|
||||
opName,
|
||||
{
|
||||
class: this.icon ? this.icon.class : "check-icon",
|
||||
innerText: this.icon ? this.icon.innerText : "check"
|
||||
},
|
||||
this.includeStarIcon
|
||||
);
|
||||
|
||||
ul.appendChild(li);
|
||||
}))
|
||||
|
||||
ul.dispatchEvent(this.app.manager.oplistcreate);
|
||||
|
||||
this.append(ul);
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define("c-operation-list", COperationList);
|
Loading…
Add table
Add a link
Reference in a new issue