www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

commit dc465060b27d05d0c9dcca26af261dfeb13f6637
parent 95e6ca37f507d6f9bd340861f3626028d5b5acb3
Author: Suzanne Soy <ligo@suzanne.soy>
Date:   Thu,  1 Apr 2021 00:00:01 +0100

undo,redo

Diffstat:
Mindex.html | 18++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/index.html b/index.html @@ -547,10 +547,22 @@ var module = function(customization) { } function set_current_mod(state, mod) { - state.current = state.stack.length; + state.stack.splice(state.current + 1, state.stack.length - state.current - 1); + state.current++; return state.stack[state.current] = mod; } + function undo(state) { + state.current--; + } + + function redo(state) { + state.current++; + if (state.current >= state.stack.length) { + state.current = state.stack.length - 1; + } + } + function create_state_from_mod(initial_mod) { return { current: 0, stack: [initial_mod] }; } @@ -618,7 +630,9 @@ var module = function(customization) { create_state, serialize, deserialize, - update_state + update_state, + undo, + redo } }