diff options
| author | hallgren <hallgren@chalmers.se> | 2011-02-17 14:38:46 +0000 |
|---|---|---|
| committer | hallgren <hallgren@chalmers.se> | 2011-02-17 14:38:46 +0000 |
| commit | cc2f9d012cc965e03034c6276e7bb9461066f561 (patch) | |
| tree | bdf2cc8b9529cedaaf478587bdeb5ea9ec4da159 /src/editor/simple/localstorage.js | |
| parent | c6825f38dfee0ea966f65901876e3704f4f7253c (diff) | |
Adding the prototype GF editor for simple multilingual grammars
Diffstat (limited to 'src/editor/simple/localstorage.js')
| -rw-r--r-- | src/editor/simple/localstorage.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/editor/simple/localstorage.js b/src/editor/simple/localstorage.js new file mode 100644 index 000000000..31201998c --- /dev/null +++ b/src/editor/simple/localstorage.js @@ -0,0 +1,21 @@ + +// We use localStorage to store the grammars, +// see http://diveintohtml5.org/storage.html + +var local={ + prefix:"gf.editor.simple.grammar", + get: function (name,def) { + var id=this.prefix+name + return localStorage[id] ? JSON.parse(localStorage[id]) : def; + }, + put: function (name,value) { + var id=this.prefix+name; + localStorage[id]=JSON.stringify(value); + }, + remove: function(name) { + var id=this.prefix+name; + localStorage.removeItem(id); + }, + get count() { return this.get("count",0); }, + set count(v) { this.put("count",v); } +} |
