diff --git a/src/runtime/javascript/minibar/about.html b/src/runtime/javascript/minibar/about.html
new file mode 100644
index 000000000..ceb18daf1
--- /dev/null
+++ b/src/runtime/javascript/minibar/about.html
@@ -0,0 +1,70 @@
+
+
+About Minibar
+
+
+
+
+About Minibar
+
+Minibar is an alternative implementation of the
+Fridge Poetry web app .
+It doesn't do everything the original Fridge Poetry does (e.g. drag-and-drop is missing),
+so I refer to it as a minibar rather than a full refrigerator :-)
+
+
+Some implementation details:
+
+
+ It is implemented directly in JavaScipt. It does not use Google Web Toolkit or any big JavaScript libraries.
+ It has been tested and found to work in the following browsers:
+
+ On the Mac: Firefox 3.5 & 3.6, Safari 4.0, Opera 10.10 and
+ Google Chrome 4.0.249.49.
+ On Linux: Firefox 3.0.18 & 3.5, Opera 10.10.
+ On the Android Dev Phone: Android Mobile Safari 3.0.4 & 3.1.2
+ and Android Opera Mini 4.2.
+
+ It does not seem work in Internet Explorer 7
+ (there are both styling and scripting issues).
+ The implementation consist of two JavaScript files:
+ minibar.js (186 lines)
+ and support.js (147 lines).
+ The latter is also used in a small web app based on the
+ SALDO web services .
+ To access the GF web service, it uses the
+ JSONP method
+ mentioned in the GF
+ web services paper, which allows the web app to be hosted on a different server
+ from the GF web service. (To demonstrate this, I put the Minibar demo on
+ www.cs.chalmers.se, while the GF server that it calls is on
+ www.grammaticalframework.org.)
+ As an experiment, it does no use the grammars.xml file,
+ but instead calls a little CGI script,
+ grammars.cgi
+ which lists the .pgf in the directory, in JSONP format. (Note: if you want to install
+ this on your own computer,
+
+ if you click on the link,
+ the CGI script will be downloaded as grammars.cgi.txt,
+ but it should be called grammars.cgi and stored on the server
+ in the same directory as the grammar files.
+ for CGI scripts to work with lighttpd, "mod_cgi" needs to be included
+ in the definition of server.modules in the
+ lighttpd.conf file.)
+
+ [Added 2010-02-16] There is a button for generating random sentences.
+ [Added 2010-02-23] All translations are shown, not just the first one, if there are
+ multiple parses.
+ [Added 2010-02-25] Next to each translation, there is now a little tree icon that
+ you can click on to see a drawing of an abstract syntax tree or a parse tree. If you click
+ on a drawing it collapses back into a tree icon.
+
+
+
+
+TH
+
+
+ Last modified: Thu Mar 25 15:06:22 CET 2010
+
diff --git a/src/runtime/javascript/minibar/minibar.css b/src/runtime/javascript/minibar/minibar.css
new file mode 100644
index 000000000..17d7350c9
--- /dev/null
+++ b/src/runtime/javascript/minibar/minibar.css
@@ -0,0 +1,37 @@
+body {
+ background: #ccc url("http://www.grammaticalframework.org:41296/fridge/se.chalmers.cs.gf.gwt.FridgeApp/brushed-metal.png");
+}
+
+h1, h2, h3, small, th { font-family: sans-serif; }
+
+th, td { vertical-align: baseline; text-align: left; }
+
+div#surface {
+ min-height: 3ex;
+ margin: 5px;
+ padding: 5px;
+ border: 3px dashed #e0e0e0;
+}
+
+div#words {
+ min-height: 3ex;
+ margin: 5px;
+ padding: 6px;
+ border: 3px solid #e0e0e0;
+}
+
+div.word, span.word, div#words div {
+ display: inline-block;
+ font-family: sans-serif;
+ background-color: white;
+ border: 1px solid black;
+ padding: 3px;
+ margin: 3px;
+}
+
+.invalid { color: red; }
+
+div.modtime { float: right; }
+.modtime { color: #444; white-space: nowrap; }
+
+ul.space>li { margin-top: 0.5ex; }
diff --git a/src/runtime/javascript/minibar/minibar.html b/src/runtime/javascript/minibar/minibar.html
new file mode 100644
index 000000000..246a68214
--- /dev/null
+++ b/src/runtime/javascript/minibar/minibar.html
@@ -0,0 +1,29 @@
+
+
+Minibar
+
+
+
+
+
+
+Minibar
+
+
+
+
+
+[About Minibar
+| Original Fridge Poetry
+& Translator ]
+
+
+HTML Last modified: Tue Feb 23 20:25:50 CET 2010
+
+
+TH
+
+
+
+
+
diff --git a/src/runtime/javascript/minibar/minibar.js b/src/runtime/javascript/minibar/minibar.js
new file mode 100644
index 000000000..39d741bbd
--- /dev/null
+++ b/src/runtime/javascript/minibar/minibar.js
@@ -0,0 +1,222 @@
+
+var server="http://www.grammaticalframework.org:41296"
+//var server="http://tournesol.cs.chalmers.se:41296";
+//var server="http://localhost:41296";
+var grammars_url=server+"/grammars/";
+var current_grammar_url=grammars_url+"Foods.pgf";
+
+var tree_icon=server+"/translate/se.chalmers.cs.gf.gwt.TranslateApp/tree-btn.png";
+
+function start_minibar() {
+ var minibar=element("minibar");
+ minibar.appendChild(div_id("menubar"));
+ minibar.appendChild(div_id("surface"));
+ minibar.appendChild(div_id("words"));
+ minibar.appendChild(div_id("translations"));
+ jsonp(grammars_url+"grammars.cgi",""); // calls show_grammarlist
+}
+
+function show_grammarlist(grammars) {
+ var menu=empty("select");
+ for(var i=0;i0) box.appendChild(word(s));
+ else emptycnt++;
+ }
+ if(emptycnt>0)
+ //setTimeout(function(){get_translations(menu);},200);
+ get_translations(menu);
+}
+
+function get_translations(menu) {
+ jsonp(current_grammar_url
+ +"?command=translate"
+ +"&from="+encodeURIComponent(menu.current.from)
+ +"&input="+encodeURIComponent(menu.current.input),
+ "show_translations")
+}
+
+function show_translations(translations) {
+ var trans=element("translations");
+ var cnt=translations.length;
+ trans.innerHTML="";
+ trans.appendChild(wrap("h3",text(cnt<1 ? "No translations?" :
+ cnt>1 ? ""+cnt+" translations:":
+ "One translation:")));
+ for(p=0;p
+
+Saldotest
+
+
+
+
+
+
+En liten saldoleksak
+
+
+
+
+[Baserad på SALDOs nättjänster ]
+
+
+HTML Last modified: Tue Feb 23 20:30:14 CET 2010
+
+TH
+
+
+
diff --git a/src/runtime/javascript/minibar/saldotest.js b/src/runtime/javascript/minibar/saldotest.js
new file mode 100644
index 000000000..cc2cdd1b1
--- /dev/null
+++ b/src/runtime/javascript/minibar/saldotest.js
@@ -0,0 +1,240 @@
+
+var Saldo_ws_url = "http://spraakbanken.gu.se/ws/saldo-ws/";
+//var Saldo_ff_url = Saldo_ws_url+"ff/json+remember_completions/";
+var Saldo_lid_url = Saldo_ws_url+"lid/json";
+
+var ordlista=[];
+var current="";
+
+function start_saldotest() {
+ appendChildren(element("saldotest"),
+ [button("Slumpa","random_word()"),
+ button("Rensa","clear_all()"),
+ button("⌫","delete_last()"),
+ button("Ordlista","show_ordlista()"),
+ button("Visa tänkbara drag","show_moves()"),
+ button("Gör ett drag","make_a_move()"),
+ button("Visa prefix","show_prefixes()"),
+ div_id("surface"),
+ div_id("words"),
+ div_id("translations")])
+ clear_all();
+}
+
+function random_word() {
+ jsonp(Saldo_lid_url+"+show_random/rnd?"+Math.random());
+}
+
+function show_random(lid) {
+ var lex=lid.lex;
+ reset_all(lex.substring(0,lex.indexOf('.')));
+}
+
+function clear_all() { reset_all(""); }
+
+function reset_all(s) {
+ current=s;
+ element("surface").innerHTML=s;
+ element("translations").innerHTML="";
+ get_completions();
+}
+
+function delete_last() {
+ var len=current.length;
+ if(len>0) {
+ current=current.substring(0,len-1);
+ var s=element("surface");
+ s.innerHTML=current;
+ element("translations").innerHTML="";
+ get_completions();
+ }
+}
+
+function with_completions(s,cont) {
+ var c=ordlista[s];
+ if(c && c.a) cont(c);
+ else {
+ //if(c) alert("c already has fields"+field_names(c));
+ ordlista[s]={put: function(c) { ordlista[s]=c; cont(c); }};
+ var url=Saldo_ws_url+"ff/json+ordlista[\""+s+"\"].put/"+encodeURIComponent(s);
+ jsonp(url,"");
+ }
+}
+
+function get_completions() {
+ with_completions(current,show_completions);
+}
+
+function word(s) {
+ var w=span_class("word",text(s));
+ if(s==" ") w.innerHTML=" ";
+ w.setAttribute("onclick",'extend_current("'+s+'")');
+ return w;
+}
+
+function extend_current(s) {
+ current+=s;
+ element("words").innerHTML="";
+ element("surface").innerHTML=current;
+ get_completions();
+}
+
+function show_completions(saldo_ff) {
+ var box=element("words");
+ box.innerHTML="";
+ //var c=saldo_ff.c.split("");
+ var c=filter(allowed,saldo_ff.c);
+ sort(c);
+ for(var i=0;i0 ? " "+s : "";
+}
+
+function show_translations(a) {
+ var tr=element("translations");
+ tr.innerHTML="";
+ //if(!a) alert("a undefined in show_translations");
+ if(count_wordforms(a)<1) {
+ tr.appendChild(p(text(a.length<1 ? "Detta är inte en giltig ordform"
+ : "Denna form förekommer bara i sammansättningar")));
+ element("surface").setAttribute("class","invalid");
+ }
+ else {
+ element("surface").setAttribute("class","valid");
+ for(var i=0;iVinnande drag: "+winning;
+ });
+}
+
+function make_a_move() {
+ currently_possible_moves(function(ok) {
+ if(ok.length<1) element("translations").innerHTML="Hittade inga möjliga drag!";
+ else {
+ var i=Math.floor(Math.random()*ok.length);
+ extend_current(ok[i]);
+ }
+ }
+ );
+}
+
+function show_prefixes_of(trans,s) {
+ if(s.length>0) {
+ var p=s.substr(0,s.length-1);
+ with_completions(p,function(c) {
+ if(count_wordforms(c.a)>0) trans.innerHTML+=" "+p;
+ show_prefixes_of(trans,p);
+ });
+ }
+}
+
+function show_prefixes() {
+ var trans=element("translations");
+ trans.innerHTML="Prefix av "+current+":";
+ show_prefixes_of(trans,current);
+}
diff --git a/src/runtime/javascript/minibar/support.js b/src/runtime/javascript/minibar/support.js
new file mode 100644
index 000000000..15ccc38d0
--- /dev/null
+++ b/src/runtime/javascript/minibar/support.js
@@ -0,0 +1,157 @@
+function element(id) {
+ return document.getElementById(id);
+}
+
+// Inspired by the function jsonp from
+// http://www.west-wind.com/Weblog/posts/107136.aspx
+// See also http://niryariv.wordpress.com/2009/05/05/jsonp-quickly/
+// http://en.wikipedia.org/wiki/JSON#JSONP
+function jsonp(url,callback)
+{
+ if (url.indexOf("?") > -1)
+ url += "&jsonp="
+ else
+ url += "?jsonp="
+ url += callback + "&";
+ //url += new Date().getTime().toString(); // prevent caching
+
+ var script = empty("script");
+ script.setAttribute("src",url);
+ script.setAttribute("type","text/javascript");
+ document.body.appendChild(script);
+}
+
+/* --- HTML construction ---------------------------------------------------- */
+function text(s) { return document.createTextNode(s); }
+
+function empty(tag,name,value) {
+ var el=document.createElement(tag);
+ if(name && value) el.setAttribute(name,value);
+ return el;
+}
+
+function empty_id(tag,id) { return empty(tag,"id",id); }
+function empty_class(tag,cls) { return empty(tag,"class",cls); }
+
+function div_id(id) { return empty_id("div",id); }
+
+function wrap(tag,contents) {
+ var el=empty(tag);
+ el.appendChild(contents);
+ return el;
+}
+
+function wrap_class(tag,cls,contents) {
+ var el=empty_class(tag,cls);
+ if(contents) el.appendChild(contents);
+ return el;
+}
+
+function span_class(cls,contents) { return wrap_class("span",cls,contents); }
+function div_class(cls,contents) { return wrap_class("div",cls,contents); }
+
+function p(contents) { return wrap("p",contents); }
+function dt(contents) { return wrap("dt",contents); }
+
+function th(contents) { return wrap("th",contents); }
+function td(contents) { return wrap("td",contents); }
+
+function tr(cells) {
+ var tr=empty("tr");
+ for(var i=0;i";
+ }
+ return result;
+}
+
+function field_names(obj) {
+ var result = "";
+ for (var i in obj) {
+ result += " " + i;
+ }
+ return result;
+}
+
+/* --- Data manipulation ---------------------------------------------------- */
+function swap(a,i,j) { // Note: this doesn't work on strings.
+ var tmp=a[i];
+ a[i]=a[j];
+ a[j]=tmp;
+ return a;
+}
+
+function sort(a) { // Note: this doesn't work on strings.
+ for(var i=0;i