Added argSelector ingredient type and reversed rotors in Enigma and Bombe operations.

This commit is contained in:
n1474335 2019-02-28 15:27:35 +00:00 committed by s2224834
parent 4db6199fd9
commit c005c86c27
7 changed files with 344 additions and 209 deletions

View file

@ -393,15 +393,6 @@ class RecipeWaiter {
this.buildRecipeOperation(item);
document.getElementById("rec-list").appendChild(item);
// Trigger populateOption events
const populateOptions = item.querySelectorAll(".populate-option");
const evt = new Event("change", {bubbles: true});
if (populateOptions.length) {
for (const el of populateOptions) {
el.dispatchEvent(evt);
}
}
item.dispatchEvent(this.manager.operationadd);
return item;
}
@ -439,6 +430,23 @@ class RecipeWaiter {
}
/**
* Triggers various change events for operation arguments that have just been initialised.
*
* @param {HTMLElement} op
*/
triggerArgEvents(op) {
// Trigger populateOption and argSelector events
const triggerableOptions = op.querySelectorAll(".populate-option, .arg-selector");
const evt = new Event("change", {bubbles: true});
if (triggerableOptions.length) {
for (const el of triggerableOptions) {
el.dispatchEvent(evt);
}
}
}
/**
* Handler for operationadd events.
*
@ -448,6 +456,8 @@ class RecipeWaiter {
*/
opAdd(e) {
log.debug(`'${e.target.querySelector(".op-title").textContent}' added to recipe`);
this.triggerArgEvents(e.target);
window.dispatchEvent(this.manager.statechange);
}