Structuring input of data for localStorage
Posted
by WmasterJ
on Stack Overflow
See other posts from Stack Overflow
or by WmasterJ
Published on 2010-05-10T02:24:17Z
Indexed on
2010/05/10
2:28 UTC
Read the original article
Hit count: 274
html5
|localstorage
It is nice when there isn't a DB to maintain and users to authenticate. My professor has asked me to convert a recent research project of his that uses Bespin and calculates errors made by users in a code editor as part of his research.
The goal is to convert from MySQL to using HTML5 localStorage
completely. Doesn't seem so hard to do, even though digging in his code might take some time.
Question:
I need to store files and state (last placement of cursor and active file). I have already done so by implementing the recommendations in another stackoverflow thread. But would like your input considering how to structure the content to use.
My current solution > Hashmap like solution with javascript objects:
files = {};
// later, saving
files[fileName] = data;
And then storing in localStorage using some recommendations
localStorage.setObject(files):
Currently I'm also considering using some type of numeric id. So that names can be changed without any hassle renaming the key in the hashmap. What is your opinion on the way it is solved and would you do it any differently?
© Stack Overflow or respective owner