summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2015-03-19 15:26:18 +0000
committerhallgren <hallgren@chalmers.se>2015-03-19 15:26:18 +0000
commite475fb10917dce2e86a11ea9cd6ffa04d03bdbee (patch)
treef4645aa4d1767f1594d31ea878bac6f522a82a8e /src
parent5db57b1a58960e24cc468f234ff6fcc9c2ccca60 (diff)
Wide Coverage Translation Demo: draw abstract trees and parse trees
You can now click on a tree to toggle between the abstract syntax tree and the parse tree. Also, the implementation now uses the new C run-time requests, e.g. App14.pgf?command=c-abstrtree&tree=... so no need to install AppEng.pgf on the server any more.
Diffstat (limited to 'src')
-rw-r--r--src/www/js/wc.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/www/js/wc.js b/src/www/js/wc.js
index a858ada0a..85629b588 100644
--- a/src/www/js/wc.js
+++ b/src/www/js/wc.js
@@ -114,9 +114,22 @@ wc.translate=function() {
e.innerHTML=prob+"<br>"
if(r.tree) {
var t=wrap("span",text(r.tree))
- var imgurl="/robust/AppEng.pgf?command=abstrtree&tree="+encodeURIComponent(r.tree)+"&format=svg"
e.appendChild(t)
- if(!r.img) r.img=node("img",{src:imgurl},[])
+ var g=gftranslate.jsonurl
+ var u="format=svg&tree="+encodeURIComponent(r.tree)
+ var from="&from="+gftranslate.grammar+f.to.value
+ r.imgurls=[g+"?command=c-abstrtree&"+u,
+ g+"?command=c-parsetree&"+u+from]
+ if(!r.img) {
+ r.img=node("img",{src:r.imgurls[0]},[])
+ r.img_ix=0
+ r.img.onclick=function() {
+ r.img_ix=1-r.img_ix
+ r.img.src=r.imgurls[r.img_ix]
+ }
+ }
+ else if(r.img.src!=r.imgurls[r.img_ix]) // language change?
+ r.img.src=r.imgurls[r.img_ix]
e.appendChild(empty("br"))
e.appendChild(r.img)
}