diff --git a/src/www/minibar/about.html b/src/www/minibar/about.html
index 4730953c6..7c127fe5f 100644
--- a/src/www/minibar/about.html
+++ b/src/www/minibar/about.html
@@ -231,11 +231,13 @@ Some implementation details:
[Added 2013-04-02] Abstract syntax tree visualizations: click once to
show abstract syntax trees without category names. Click again to add
category names.
+ [Added 2013-04-02] Minibar now remembers from one visit to the next
+ the selected set of target languages for each grammar.
-Last modified: Tue Apr 2 13:55:59 CEST 2013
+Last modified: Tue Apr 2 15:49:32 CEST 2013
TH
diff --git a/src/www/minibar/minibar_translations.js b/src/www/minibar/minibar_translations.js
index 370ef90df..ffb21972f 100644
--- a/src/www/minibar/minibar_translations.js
+++ b/src/www/minibar/minibar_translations.js
@@ -27,7 +27,7 @@ function Translations(server,opts) {
var tom=this.to_menu=node("select",{id:"to_menu",multiple:"",size:5},[]);
appendChildren(this.menus,[text(" To: "), this.to_menu])
- tom.onchange=bind(this.get_translations,this);
+ tom.onchange=bind(this.change_language,this);
/* // This seems triggers weird scrolling behavior in Firefox and Chrome:
tom.onmouseover=function() { var n=tom.options.length;
tom.size=n<12 ? n : 12; }
@@ -37,17 +37,45 @@ function Translations(server,opts) {
}
Translations.prototype.change_grammar=function(grammar) {
- this.grammar=grammar;
+ var t=this
+ t.grammar=grammar;
- update_language_menu(this.to_menu,grammar);
- insertFirst(this.to_menu,option("All","All"));
- this.to_menu.value="All";
+ t.local=mt_local(t.server.current_grammar_url)
+ update_language_menu(t.to_menu,grammar);
+ insertFirst(t.to_menu,option("All","All"));
+ t.to_menu.value="All";
+ var toLangs=t.local.get("toLangs")
+ if(toLangs) {
+ t.toLangs=toLangs
+ t.toSet=toSet(toLangs)
+ var os=to_menu.options
+ for(var i=0;i=imgs.length) current=0;
- i.src=imgs[current]
- }
- var i=button_img(tree_icon,cycle);
- return i
-}
-
Translations.prototype.abstree_button=function(abs) {
var f=this.options.tree_img_format;
var img=this.server.current_grammar_url+"?command=abstrtree&format="+f+"&tree="+encodeURIComponent(abs)
@@ -252,6 +261,20 @@ Translations.prototype.parsetree_button=function(abs,lang) {
return btn;
}
+/* --- Auxiliary functions -------------------------------------------------- */
+
+function tree_button(img_url,opt) {
+ var imgs=[tree_icon,img_url+(opt||"&nofun=true"),img_url]
+ var current=0;
+ function cycle() {
+ current++;
+ if(current>=imgs.length) current=0;
+ i.src=imgs[current]
+ }
+ var i=button_img(tree_icon,cycle);
+ return i
+}
+
function draw_brackets(b) {
return b.token
? span_class("token",text(b.token))
@@ -259,3 +282,35 @@ function draw_brackets(b) {
title:(b.fun||"_")+":"+b.cat+" "+b.fid+":"+b.index},
b.children.map(draw_brackets))
}
+
+
+// Access to localStorage, if available
+function mt_local(grammar_url) {
+ function dummy() {
+ return {
+ get: function(name,def) { return def },
+ put: function(name,value) { }
+ }
+ }
+ function real() {
+ var prefix="gf.minibar_translations."+grammar_url+"."
+ return {
+ get: function (name,def) {
+ var id=prefix+name
+ return localStorage[id] ? JSON.parse(localStorage[id]) : def;
+ },
+ put: function (name,value) {
+ var id=prefix+name;
+ localStorage[id]=JSON.stringify(value);
+ }
+ }
+ }
+ return window.localStorage ? real() : dummy()
+}
+
+// Convert an array of strings to a set (for quick & easy membership tests)
+function toSet(a) {
+ var set={}
+ for(var i=0;i