minibar: add a button to display word alignment

This commit is contained in:
hallgren
2011-03-03 19:18:09 +00:00
parent 2c1feccd17
commit 527e000a12
2 changed files with 26 additions and 6 deletions

View File

@@ -49,3 +49,5 @@ div#saldospel input.incorrect { color: red; }
span.field { background-color: #eee; }
pre.feedbacklist { background: white }
img.button { padding: 1px; }

View File

@@ -1,6 +1,7 @@
// minibar.js, assumes that support.js has also been loaded
var tree_icon="tree-btn.png";
var alignment_icon="align-btn.png";
/*
// This is essentially what happens when you call start_minibar:
@@ -387,8 +388,11 @@ Minibar.prototype.show_translations=function(translationResults) {
var lin=t.linearizations;
var tbody=empty("tbody");
if(options.show_abstract && t.tree)
tbody.appendChild(tr([th(text("Abstract: ")),
tdt(abstree_button(t.tree),text(" "+t.tree))]));
tbody.appendChild(
tr([th(text("Abstract: ")),
tdt(node("span",{},[abstree_button(t.tree),
alignment_button(t.tree)]),
text(" "+t.tree))]));
for(var i=0;i<lin.length;i++) {
if(lin[i].to==to)
trans.single_translation.push(lin[i].text);
@@ -499,16 +503,30 @@ function langpart(conc,abs) { // langpart("FoodsEng","Foods") == "Eng"
return hasPrefix(conc,abs) ? conc.substr(abs.length) : conc;
}
function button_img(url,action) {
var i=img(url);
i.setAttribute("class","button");
i.setAttribute("onclick",action);
return i;
}
function abstree_button(abs) {
var i=img(tree_icon);
i.setAttribute("onclick","toggle_img(this)");
var i=button_img(tree_icon,"toggle_img(this)");
i.title="Click to display abstract syntax tree"
i.other=server.current_grammar_url+"?command=abstrtree&tree="+encodeURIComponent(abs);
return i;
}
function alignment_button(abs) {
var i=button_img(alignment_icon,"toggle_img(this)");
i.title="Click to display word alignment"
i.other=server.current_grammar_url+"?command=alignment&tree="+encodeURIComponent(abs);
return i;
}
function parsetree_button(abs,lang) {
var i=img(tree_icon);
i.setAttribute("onclick","toggle_img(this)");
var i=button_img(tree_icon,"toggle_img(this)");
i.title="Click to display parse tree"
i.other=server.current_grammar_url
+"?command=parsetree&from="+lang+"&tree="+encodeURIComponent(abs);
return i;