window.JZ as a mini-framework — your own tool panel from actions
A single action is a button and some code. But actions can call each other — and from that moment you hold a small framework. window.JZ lets you build complex, multi-step workflows out of buttons.
What window.JZ is
In the code of any rule or action, the window.JZ object is available — an API to drive the JustZix action bar:
JZ.click('LBL')— programmatically click the action labelled "LBL".JZ.action('LBL')— get the button's DOM element.JZ.actions()— an array of all visible actions.JZ.labels()— an array of labels.
The lookup ignores case: JZ.click('save') equals JZ.click('SAVE').
Pattern 1 — an orchestrator action
Three actions each do one thing, a fourth composes them into a sequence:
// Action "AUTO" — runs three others in order
JZ.click('LOAD');
setTimeout(() => JZ.click('PROC'), 500);
setTimeout(() => JZ.click('SAVE'), 1500);
You test each of the three component actions on its own; "AUTO" only conducts them. It is the same principle as functions calling functions.
Pattern 2 — a conditional action
// Action "SMART" — behavior depends on page state
if (document.querySelector('.logged-in')) {
JZ.click('EXPORT');
} else {
JZ.click('LOGIN');
}
Pattern 3 — a loop over actions
JZ.actions() and JZ.labels() let you treat the bar as data:
// Action "ALL" — fires every action whose label starts with "T"
JZ.labels()
.filter(l => l.startsWith('T'))
.forEach(l => JZ.click(l));
Why this works like a framework
You have units (actions), a way to invoke them (JZ.click), introspection (JZ.actions/labels) and composition (an action calling actions). That is enough to build a multi-step tool out of a button bar — with no external library.
Pitfalls
- Timing.
JZ.clickis immediate, but an action's effect (e.g. a fetch) is not. That is why the orchestrator usessetTimeout; better still, have actions signal completion through a shared variable. - Labels are a contract. An orchestrator action calls others by label — renaming the "LOAD" label disconnects "AUTO". Treat labels like function names.
See also
- window.JZ helpers — the full action API
- The BUTTON action — the unit you orchestrate
- Three actions worth a slot — ready actions to compose
Install JustZix — and build something bigger than a button out of buttons.
Rate this post
No ratings yet — be the first.