forked from GitHub/gf-core
Minibar: make it possible to configure a list of preferred grammars
A preferred grammar is selected when a user visits the Minibar for the first time. (Like before, Minibar remembers the selected grammar for future visits.) A preferred list of grammars can be specified in config.js in the .../minibar directory on the server, e.g. like this: preferred_grammars=["/grammars/Foods.pgf","/grammars/ResourceDemo.pgf"] The first available grammar from the list is used.
This commit is contained in:
@@ -243,12 +243,22 @@ Some implementation details:
|
|||||||
the minibar. The rest of the documentation is displayed when you press
|
the minibar. The rest of the documentation is displayed when you press
|
||||||
the <b>More info</b> button (or the <b>i</b> button). The documentation
|
the <b>More info</b> button (or the <b>i</b> button). The documentation
|
||||||
can contain HTML markup. Blank lines are treated as paragraph breaks.
|
can contain HTML markup. Blank lines are treated as paragraph breaks.
|
||||||
|
<li>[Added 2019-11-21] It is now possible to configure a list of preferred
|
||||||
|
grammars.
|
||||||
|
A preferred grammar is selected when a user visits Minibar for the
|
||||||
|
first time. (Like before, Minibar remembers the selected grammar for
|
||||||
|
future visits.)
|
||||||
|
<p>
|
||||||
|
A preferred list of grammars can be specified in <code>config.js</code>
|
||||||
|
in the <code>…/minibar</code> directory on the server, e.g. like this:
|
||||||
|
<pre> preferred_grammars=["/grammars/Foods.pgf","/grammars/ResourceDemo.pgf"]</pre>
|
||||||
|
The first available grammar from the list is used.
|
||||||
</ul>
|
</ul>
|
||||||
</main>
|
</main>
|
||||||
<footer>
|
<footer>
|
||||||
<hr>
|
<hr>
|
||||||
<div class=modtime><small>
|
<div class=modtime><small>
|
||||||
<!-- hhmts start -->Last modified: Mon Aug 5 15:22:46 CEST 2019 <!-- hhmts end -->
|
<!-- hhmts start -->Last modified: Thu Nov 21 14:23:59 CET 2019 <!-- hhmts end -->
|
||||||
</small></div>
|
</small></div>
|
||||||
<address>
|
<address>
|
||||||
<a href="http://www.cse.chalmers.se/~hallgren/">Thomas Hallgren</a>
|
<a href="http://www.cse.chalmers.se/~hallgren/">Thomas Hallgren</a>
|
||||||
|
|||||||
@@ -181,7 +181,15 @@ Minibar.prototype.show_grammarlist=function(dir,grammar_names,dir_count) {
|
|||||||
if(last_grammar && elem(last_grammar,t.grammars))
|
if(last_grammar && elem(last_grammar,t.grammars))
|
||||||
grammar0=last_grammar;
|
grammar0=last_grammar;
|
||||||
}
|
}
|
||||||
|
var pgs=t.options.preferred_grammars
|
||||||
|
if(!grammar0 && pgs)
|
||||||
|
for(var i in pgs)
|
||||||
|
if(elem(pgs[i],t.grammars)) {
|
||||||
|
grammar0=pgs[i]
|
||||||
|
break
|
||||||
|
}
|
||||||
if(!grammar0) grammar0=t.grammars[0];
|
if(!grammar0) grammar0=t.grammars[0];
|
||||||
|
//console.log("grammar0=",grammar0)
|
||||||
t.grammar_menu.value=grammar0;
|
t.grammar_menu.value=grammar0;
|
||||||
t.select_grammar(grammar0);
|
t.select_grammar(grammar0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ var minibar_options= {
|
|||||||
try_google: true
|
try_google: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(window.preferred_grammars)
|
||||||
|
minibar_options.preferred_grammars=preferred_grammars
|
||||||
|
|
||||||
if(/^\?\/(tmp|grammars)\//.test(location.search)) {
|
if(/^\?\/(tmp|grammars)\//.test(location.search)) {
|
||||||
var args=decodeURIComponent(location.search.substr(1)).split(" ")
|
var args=decodeURIComponent(location.search.substr(1)).split(" ")
|
||||||
if(args[0]) online_options.grammars_url=args[0];
|
if(args[0]) online_options.grammars_url=args[0];
|
||||||
|
|||||||
Reference in New Issue
Block a user