peggy icon indicating copy to clipboard operation
peggy copied to clipboard

Save grammar and test input in online version to localStorage

Open zocky opened this issue 3 years ago • 2 comments

It would be very nice if the online version retained its state between reloads, closed an reopen windows, etc. All that needs to be done is to save the grammar and input to localStorage on change and set them from localStorage on load.

zocky avatar Sep 27 '21 19:09 zocky

I like this idea, but want to think about how it would interact with #179.

hildjj avatar Sep 27 '21 20:09 hildjj

IMO, the URL shouldn't update automatically. It's not needed for remembering the state, though it may be useful for sending links, e.g. in an email. You could have a button that copies the URL with encoded content to the clipboard.

Then, on load:

  • if location.target isn't empty and it decodes correctly
    • save the decoded state to localStorage
    • set location.target to empty (to avoid overwriting the local state on future reload)
  • if localStorage has local state (from earlier or just created), and it decodes correctly
    • load decoded content into textareas/editors
  • else
    • set editors to empty or to example grammar/input

zocky avatar Sep 28 '21 16:09 zocky