Setup for Simulating in a Browser



  • I want to put code up that can run in a browser to simulate elections. A peripheral question I am struggling with concerns how from the user's viewpoint to set up the volatile memory of the parameter values.

    I say volatile memory, because at this point I am not planning to tackle allowing people to register and log in so they could store values on the server. So I want to allow that you could fill in form widgets to set up the values you want for the parameters of the simulation, and those would be there in front of you, so long as you didn't navigate to another website. I want to make an encoding of the parameter values available as text that you could copy out and paste somewhere else to save.

    It should be possible to load the volatile memory with a set of preset values from the server; those would be constant for a given version of the server.

    It should be possible to clear out the parameter values and start over.

    It should be possible to edit the volatile memory of the parameters.

    So, a question I have is of whether to provide a way that the user could access several named slots in the volatile memory, each slot to have a complete assignment of values to parameters. The alternative would be to just have a single slot.



  • What do you mean by "volatile memory"? It sounds like you are just speaking of normal JavaScript variables. If you want things to persist, use cookies or localStorage to save and then repopulate them (or save them on the server, of course).

    Otherwise it is simply variables, declared with "var" or "let", or as properties of an object, etc. Easy peasy.


Log in to reply