dimanche 30 septembre 2018

preserving and recreating state via the URL

Imagine the following scenario:

The user goes to https://mywebsite.com, searches for something and hits [submit]. The results are displayed and the URL is now https://mywebsite.com/floobah?q=burp. The user clicks on an anchor which scrolls the page down to a div a choice of ways to visualize the result. The URL is now https://mywebsite.com/floobah?q=burp#viz. The user chooses the pie chart widget and displays the pie and associated data. The URL is now https://mywebsite.com/floobah?q=burp&chart=pie&sort=asc#viz.

Then the user sends the URL to a friend. When its recipient opens that URL, the state is restored exactly as what it was for the sender. In other words, the URL is parsed and the actions performed to restore the state… the query is performed, the page scrolls down to the viz section, the pie chart opens up and the associated data is shown sorted as requested.

I am doing this right now by parsing the URL and replaying all the steps. But surely there must be a library already for doing this, no? To sum, I want the state of a page encoded in the URL which can be shared and then recreated by the recipient of the URL bookmark.




Aucun commentaire:

Enregistrer un commentaire