Wide Coverage Demo App updates

+ Add Clear button.
+ Use localstorage to remember entered text between visits.
+ Add a link to it on the GF cloud service start page.
This commit is contained in:
hallgren
2014-04-09 13:59:35 +00:00
parent 6c7f1245ce
commit 02b57c3f79
3 changed files with 28 additions and 1 deletions

View File

@@ -20,6 +20,7 @@
<li><a href="gfse/">GF online editor for simple multilingual grammars</a>
<li><a href="translator/">Simple Translation Tool</a>
(bilingual document editor)
<li><a href="wc.html">Wide Coverage Translation Demo</a>
</ul>
<h2>Documentation</h2>

View File

@@ -6,6 +6,7 @@ wc.e=element("extra")
wc.p=element("pick")
wc.serial=0
wc.os=[]
wc.local=appLocalStorage("gf.wc.")
wc.delayed_translate=function() {
function restart(){ if(wc.f.input.value!=wc.translating) wc.translate() }
@@ -16,6 +17,28 @@ wc.delayed_translate=function() {
if(wc.f.input.clientHeight<h) wc.f.input.style.height=h+15+"px"
}
wc.clear=function() {
wc.f.input.value=""
wc.f.input.style.height=""
clear(wc.o)
wc.delayed_translate()
}
wc.save=function() {
var f=wc.f
wc.local.put("from",f.from.value)
wc.local.put("to",f.to.value)
wc.local.put("input",f.input.value)
}
wc.load=function() {
var f=wc.f
f.input.value=wc.local.get("input",f.input.value)
f.from.value=wc.local.get("from",f.from.value)
f.to.value=wc.local.get("to",f.to.value)
wc.delayed_translate()
}
wc.translate=function() {
var current= ++wc.serial
var f=wc.f, e=wc.e, p=wc.p
@@ -178,6 +201,7 @@ wc.translate=function() {
translate_segment(i)
}
}
wc.save()
return false;
}
@@ -246,4 +270,5 @@ if(wc.cnl) {
wc.pgf_online=pgf_online({});
wc.pgf_online.switch_grammar(wc.cnl+".pgf")
}
wc.load()
wc.f.input.focus()

View File

@@ -43,6 +43,7 @@ small { color: #666; }
<option value=Hin>Hindi</option>
<option value=Swe>Swedish</option>
</select>
<input type=button value="Clear" onclick="wc.clear()">
<td style="text-align: right">
<input type=button name=swap onclick="wc.swap()" value="⇆">
<td>
@@ -77,7 +78,7 @@ small { color: #666; }
</div>
<p>
<div class=modtime><small>
<!-- hhmts start -->Last modified: Tue Apr 8 13:22:42 CEST 2014 <!-- hhmts end -->
<!-- hhmts start -->Last modified: Wed Apr 9 15:43:04 CEST 2014 <!-- hhmts end -->
</small></div>
<script src="js/support.js"></script>
<script src="js/gftranslate.js"></script>