Define a hash url for each example automaton
continuous-integration/drone/push Build is passing Details

main
Clément FRÉVILLE 2 months ago
parent 5f780c751a
commit 2e33a9cda9

@ -21,6 +21,7 @@ for (const [displayName, automaton] of Object.entries(AUTOMATONS)) {
const handleEvent = () => {
automatonSelector.setAttribute('hidden', 'hidden');
app.removeAttribute('hidden');
history.replaceState({ automaton }, '', `#${encodeURIComponent(displayName)}`);
openAutomaton(trUserContent(displayName), automaton);
};
card.addEventListener('click', handleEvent);
@ -46,7 +47,15 @@ create.addEventListener('click', () => {
openAutomaton('', [], true);
});
const hash = decodeURIComponent(location.hash.slice(1));
if (AUTOMATONS.hasOwnProperty(hash)) {
openAutomaton(trUserContent(hash), AUTOMATONS[/** @type {keyof typeof AUTOMATONS} */ (hash)]);
automatonSelector.setAttribute('hidden', 'hidden');
app.removeAttribute('hidden');
}
backButton.addEventListener('click', () => {
app.setAttribute('hidden', 'hidden');
automatonSelector.removeAttribute('hidden');
history.replaceState({}, '', '#');
});

Loading…
Cancel
Save