Closed ogallagher closed 4 years ago
The major issue I ran into doing this was attempting to use an http request to post the partial play to the session server; these calls are not consistently supported in event handlers for window.onbeforeunload
. So I added a save-progress button to invoke the sending of the play, rather than trigger automatically when the user leaves a page.
Done.
Currently, when a visitor signs in, their db account can store data of their puzzle completions (full plays), but not their progress (partial plays). Partial plays will be ephimeral and variable so they’ll be stored in the session file as an array of objects taking the following structure:
A partial play is stored/updated using
$(window).on('unload',handler)
. When the user leaves the page, the partial play is stored in the server’s session file.A partial play is optionally restored when the puzzle loads; a button appears in the textile title bar with the
oi-cloud-download
logo, which opens a modal confirming progress restore. It’s automatically triggered when the page loads.EDIT: Partial play restore is not optional, it just restores automatically when the puzzle loads.