mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-22 09:32:53 -06:00
minibar: use the common interface to localStorage
...for more streamlined code and better browser compatibility.
This commit is contained in:
@@ -40,6 +40,9 @@ function Minibar(server,opts) {
|
|||||||
this.server=server;
|
this.server=server;
|
||||||
if(opts) for(var o in opts) this.options[o]=opts[o];
|
if(opts) for(var o in opts) this.options[o]=opts[o];
|
||||||
|
|
||||||
|
// LocalStorage
|
||||||
|
this.local=appLocalStorage("gf.minibar.")
|
||||||
|
|
||||||
/* --- Syntax editor integration ---------------------------------------- */
|
/* --- Syntax editor integration ---------------------------------------- */
|
||||||
if(!this.options.abstract_action) this.integrate_syntax_editor()
|
if(!this.options.abstract_action) this.integrate_syntax_editor()
|
||||||
|
|
||||||
@@ -159,8 +162,7 @@ Minibar.prototype.show_grammarlist=function(dir,grammar_names,dir_count) {
|
|||||||
appendChildren(grammar_menu,map(opt,grammar_names));
|
appendChildren(grammar_menu,map(opt,grammar_names));
|
||||||
function pick() {
|
function pick() {
|
||||||
var grammar_url=grammar_menu.value
|
var grammar_url=grammar_menu.value
|
||||||
if(window.localStorage)
|
local.put("last_grammar",grammar_url)
|
||||||
localStorage["gf.minibar.last_grammar"]=grammar_url;
|
|
||||||
t.select_grammar(grammar_url);
|
t.select_grammar(grammar_url);
|
||||||
}
|
}
|
||||||
function pick_first_grammar() {
|
function pick_first_grammar() {
|
||||||
@@ -172,8 +174,8 @@ Minibar.prototype.show_grammarlist=function(dir,grammar_names,dir_count) {
|
|||||||
insertFirst(t.menubar,text("Grammar: "));
|
insertFirst(t.menubar,text("Grammar: "));
|
||||||
}
|
}
|
||||||
var grammar0=t.options.initial_grammar
|
var grammar0=t.options.initial_grammar
|
||||||
if(!grammar0 && window.localStorage) {
|
if(!grammar0) {
|
||||||
var last_grammar=localStorage["gf.minibar.last_grammar"];
|
var last_grammar=local.get("last_grammar");
|
||||||
if(last_grammar && elem(last_grammar,t.grammars))
|
if(last_grammar && elem(last_grammar,t.grammars))
|
||||||
grammar0=last_grammar;
|
grammar0=last_grammar;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user