mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-07 15:07:11 -04:00
eslint, rec-list dragging indices
This commit is contained in:
parent
d07502d2e1
commit
c9f40928fb
3 changed files with 12 additions and 5 deletions
|
@ -298,7 +298,7 @@ export class COperationLi extends HTMLElement {
|
||||||
const parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
opName = parser.parseFromString(opName, "text/html");
|
opName = parser.parseFromString(opName, "text/html");
|
||||||
|
|
||||||
span.append( ...opName.body.children );
|
span.append(...opName.body.children);
|
||||||
} else {
|
} else {
|
||||||
span.innerText = this.name;
|
span.innerText = this.name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,9 +158,9 @@ export class COperationList extends HTMLElement {
|
||||||
.off(".popover")
|
.off(".popover")
|
||||||
.removeData("bs.popover");
|
.removeData("bs.popover");
|
||||||
},
|
},
|
||||||
onEnd: ({item, to}) => {
|
onEnd: ({item, to, newIndex }) => {
|
||||||
if (item.parentNode.id === targetListId && dragOverRecList) {
|
if (item.parentNode.id === targetListId && dragOverRecList) {
|
||||||
this.app.manager.recipe.addOperation(item.name);
|
this.app.manager.recipe.addOperation(item.name, newIndex);
|
||||||
item.remove();
|
item.remove();
|
||||||
} else if (!dragOverRecList && !to.classList.contains("op-list")) {
|
} else if (!dragOverRecList && !to.classList.contains("op-list")) {
|
||||||
item.remove();
|
item.remove();
|
||||||
|
|
|
@ -240,11 +240,18 @@ class RecipeWaiter {
|
||||||
* @fires Manager#operationadd
|
* @fires Manager#operationadd
|
||||||
* @fires Manager#statechange
|
* @fires Manager#statechange
|
||||||
* @param {string} name - The name of the operation to add
|
* @param {string} name - The name of the operation to add
|
||||||
|
* @param {number} index - The index where the operation should be displayed
|
||||||
*/
|
*/
|
||||||
addOperation(name) {
|
addOperation(name, index = undefined) {
|
||||||
const item = new CRecipeLi(this.app, name, this.app.operations[name].args);
|
const item = new CRecipeLi(this.app, name, this.app.operations[name].args);
|
||||||
|
|
||||||
document.getElementById("rec-list").appendChild(item);
|
const recipeList = document.getElementById("rec-list");
|
||||||
|
|
||||||
|
if (index !== undefined) {
|
||||||
|
recipeList.insertBefore(item, recipeList.children[index + 1]);
|
||||||
|
} else {
|
||||||
|
recipeList.appendChild(item);
|
||||||
|
}
|
||||||
|
|
||||||
$(item).find("[data-toggle='tooltip']").tooltip();
|
$(item).find("[data-toggle='tooltip']").tooltip();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue