-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmenu.js
40 lines (31 loc) · 916 Bytes
/
menu.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const makeMenuCtx = imports => {
function setup(modeButton, nextButton, indicatorNode, outputNode, runner) {
const indicators = indicatorNode.children;
// should receive all needed values as args
function updateUI(isStepping, stepIndex, mode) {
nextButton.disabled = !(mode == "macnu" && isStepping);
modeButton.disabled = isStepping;
modeButton.textContent = mode;
for (let i = 0; i < indicators.length; i++) {
indicators[i].disabled = (i >= stepIndex) && isStepping;
}
}
modeButton.addEventListener("click", function(e) {
runner.switchMode();
});
nextButton.addEventListener("click", function(e) {
runner.next();
});
for (let i = 0; i < indicators.length; i++) {
indicators[i].addEventListener("click", function(e) {
runner.finish();
runner.displayStepIndex(i);
});
}
runner.addHook(updateUI);
runner.runHooks();
}
return {
setup
};
};