mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-07 15:07:11 -04:00
move and remove some redundant code
This commit is contained in:
parent
c110e5a59f
commit
6a11d14794
4 changed files with 13 additions and 24 deletions
|
@ -154,7 +154,6 @@ class Manager {
|
||||||
this.addDynamicListener(".arg:not(select)", "input", this.recipe.ingChange, this.recipe);
|
this.addDynamicListener(".arg:not(select)", "input", this.recipe.ingChange, this.recipe);
|
||||||
this.addDynamicListener(".arg[type=checkbox], .arg[type=radio], select.arg", "change", this.recipe.ingChange, this.recipe);
|
this.addDynamicListener(".arg[type=checkbox], .arg[type=radio], select.arg", "change", this.recipe.ingChange, this.recipe);
|
||||||
this.addDynamicListener("#rec-list .dropdown-menu.toggle-dropdown a", "click", this.recipe.dropdownToggleClick, this.recipe);
|
this.addDynamicListener("#rec-list .dropdown-menu.toggle-dropdown a", "click", this.recipe.dropdownToggleClick, this.recipe);
|
||||||
this.addDynamicListener("#rec-list", "operationremove", this.recipe.clearRecipe.bind(this.recipe));
|
|
||||||
this.addDynamicListener("textarea.arg", "dragover", this.recipe.textArgDragover, this.recipe);
|
this.addDynamicListener("textarea.arg", "dragover", this.recipe.textArgDragover, this.recipe);
|
||||||
this.addDynamicListener("textarea.arg", "dragleave", this.recipe.textArgDragLeave, this.recipe);
|
this.addDynamicListener("textarea.arg", "dragleave", this.recipe.textArgDragLeave, this.recipe);
|
||||||
this.addDynamicListener("textarea.arg", "drop", this.recipe.textArgDrop, this.recipe);
|
this.addDynamicListener("textarea.arg", "drop", this.recipe.textArgDrop, this.recipe);
|
||||||
|
|
|
@ -24,6 +24,9 @@ export class CRecipeLi extends HTMLElement {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.args = [];
|
this.args = [];
|
||||||
|
|
||||||
|
this.flowControl = this.app.operations[this.name].flowControl;
|
||||||
|
this.manualBake = this.app.operations[this.name].manualBake;
|
||||||
|
|
||||||
for (let i = 0; i < args.length; i++) {
|
for (let i = 0; i < args.length; i++) {
|
||||||
const ing = new HTMLIngredient(args[i], this.app, this.app.manager);
|
const ing = new HTMLIngredient(args[i], this.app, this.app.manager);
|
||||||
this.args.push(ing);
|
this.args.push(ing);
|
||||||
|
@ -132,10 +135,15 @@ export class CRecipeLi extends HTMLElement {
|
||||||
|
|
||||||
const clearfixDiv = document.createElement("div");
|
const clearfixDiv = document.createElement("div");
|
||||||
|
|
||||||
if (this.app.operations[this.name].flowControl) {
|
if (this.flowControl) {
|
||||||
li.classList.add("flow-control-op");
|
li.classList.add("flow-control-op");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.manualBake && this.app.autoBake_) {
|
||||||
|
this.manager.controls.setAutoBake(false);
|
||||||
|
this.app.alert("Auto-Bake is disabled by default when using this operation.", 5000);
|
||||||
|
}
|
||||||
|
|
||||||
li.appendChild(icons);
|
li.appendChild(icons);
|
||||||
li.appendChild(clearfixDiv);
|
li.appendChild(clearfixDiv);
|
||||||
|
|
||||||
|
|
|
@ -280,7 +280,6 @@ class OperationsWaiter {
|
||||||
* @param {string} className - the className to update
|
* @param {string} className - the className to update
|
||||||
*/
|
*/
|
||||||
updateListItemsClasses(srcListSelector, className) {
|
updateListItemsClasses(srcListSelector, className) {
|
||||||
console.log("li update");
|
|
||||||
const listItems = document.querySelectorAll(`${srcListSelector} li`);
|
const listItems = document.querySelectorAll(`${srcListSelector} li`);
|
||||||
const ops = document.querySelectorAll("c-operation-li > li.operation");
|
const ops = document.querySelectorAll("c-operation-li > li.operation");
|
||||||
|
|
||||||
|
|
|
@ -234,25 +234,6 @@ class RecipeWaiter {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given an operation stub element, this function converts it into a full recipe element with
|
|
||||||
* arguments.
|
|
||||||
*
|
|
||||||
* @param {string} name - The operation stub element from the operations pane
|
|
||||||
*/
|
|
||||||
buildRecipeOperation(name) {
|
|
||||||
const op = new CRecipeLi(this.app, name, this.app.operations[name].args);
|
|
||||||
|
|
||||||
// Disable auto-bake if this is a manual op
|
|
||||||
if (op.manualBake && this.app.autoBake_) {
|
|
||||||
this.manager.controls.setAutoBake(false);
|
|
||||||
this.app.alert("Auto-Bake is disabled by default when using this operation.", 5000);
|
|
||||||
}
|
|
||||||
|
|
||||||
return op;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the specified operation to the recipe
|
* Adds the specified operation to the recipe
|
||||||
*
|
*
|
||||||
|
@ -261,7 +242,8 @@ class RecipeWaiter {
|
||||||
* @param {string} name - The name of the operation to add
|
* @param {string} name - The name of the operation to add
|
||||||
*/
|
*/
|
||||||
addOperation(name) {
|
addOperation(name) {
|
||||||
const item = this.buildRecipeOperation(name);
|
const item = new CRecipeLi(this.app, name, this.app.operations[name].args);
|
||||||
|
|
||||||
document.getElementById("rec-list").appendChild(item);
|
document.getElementById("rec-list").appendChild(item);
|
||||||
|
|
||||||
$(item).find("[data-toggle='tooltip']").tooltip();
|
$(item).find("[data-toggle='tooltip']").tooltip();
|
||||||
|
@ -285,7 +267,9 @@ class RecipeWaiter {
|
||||||
recList.removeChild(recList.firstChild);
|
recList.removeChild(recList.firstChild);
|
||||||
}
|
}
|
||||||
recList.dispatchEvent(this.manager.operationremove);
|
recList.dispatchEvent(this.manager.operationremove);
|
||||||
|
|
||||||
window.dispatchEvent(this.app.manager.statechange);
|
window.dispatchEvent(this.app.manager.statechange);
|
||||||
|
|
||||||
this.app.manager.ops.updateListItemsClasses("#rec-list", "selected");
|
this.app.manager.ops.updateListItemsClasses("#rec-list", "selected");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,7 +319,6 @@ class RecipeWaiter {
|
||||||
opAdd(e) {
|
opAdd(e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
log.debug(`'${e.target.querySelector("li").getAttribute("data-name")}' added to recipe`);
|
log.debug(`'${e.target.querySelector("li").getAttribute("data-name")}' added to recipe`);
|
||||||
console.log(e.target.querySelector("li").getAttribute("data-name"));
|
|
||||||
this.triggerArgEvents(e.target);
|
this.triggerArgEvents(e.target);
|
||||||
window.dispatchEvent(this.manager.statechange);
|
window.dispatchEvent(this.manager.statechange);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue