-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
share scenario button / basically, allow scenario to be encoded in URL #2
Comments
What are the advantages of that approach? How does your code slot into the functions storeState() and restoreState()? |
Well, storeState() and restoreState() work only locally in your browser. (* They are untested, and maybe not very efficient or elegant, but should do the trick) I am just setting up a flask environment to take a look at the system myself, maybe I can propose a pull after all |
I see what you are saying. Encoding the scenario in a URL, to allow sharing, is a very good idea. |
This could be used to crowd-source the scenario implementations. You can curate a bookmarked URL list that will load each scenario, room by room. Once someone trustworthy has validated the URL does correspond to the scenario, it can be added under a new Bookmark button or something in the app itself for everyone to use. |
Agreed. This can be a powerful feature. Got me excited enough to pick the project back up again. I did a test of the naive solution, and unfortunately it resulted in 10K URLs. I've got something more sophisticated working. Need to add validation and clean it up. Soon. |
Great idea! Feature added at fb27077. Deploying now. |
Hi!
I am not quite sure, but if you store everything in localStorage anyway, wouldn't is be the easiest way to export and import that whole thing?
// Export localStorage to Base64 encoded JSON to present to user
var toExport = window.btoa( unescape( encodeURIComponent( JSON.stringify( JSON.stringify( localStorage)))));
and
// Import Base64 encoded JSON into localStorage
var tmpdata = JSON.parse( decodeURIComponent( escape( window.atob( toImport))));
Object.keys(tmpdata).forEach(function (k) { localStorage.setItem(k, data[k]); });
I am not that familiar with React, otherwise I might have tried to create a pull request :)
Possible enhancements: Compression, e.g. https://github.com/pieroxy/lz-string/ or https://github.com/tcorral/JSONC
The text was updated successfully, but these errors were encountered: