mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-10 19:52:50 -06:00
Adding the prototype GF editor for simple multilingual grammars
This commit is contained in:
21
src/editor/simple/localstorage.js
Normal file
21
src/editor/simple/localstorage.js
Normal file
@@ -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); }
|
||||
}
|
||||
Reference in New Issue
Block a user