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
|
@ -158,9 +158,9 @@ export class COperationList extends HTMLElement {
|
|||
.off(".popover")
|
||||
.removeData("bs.popover");
|
||||
},
|
||||
onEnd: ({item, to}) => {
|
||||
onEnd: ({item, to, newIndex }) => {
|
||||
if (item.parentNode.id === targetListId && dragOverRecList) {
|
||||
this.app.manager.recipe.addOperation(item.name);
|
||||
this.app.manager.recipe.addOperation(item.name, newIndex);
|
||||
item.remove();
|
||||
} else if (!dragOverRecList && !to.classList.contains("op-list")) {
|
||||
item.remove();
|
||||
|
|
|
@ -240,11 +240,18 @@ class RecipeWaiter {
|
|||
* @fires Manager#operationadd
|
||||
* @fires Manager#statechange
|
||||
* @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);
|
||||
|
||||
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();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue