summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2012-06-18 13:08:15 +0000
committerhallgren <hallgren@chalmers.se>2012-06-18 13:08:15 +0000
commitc3a5840ef90154b7be1d4960c01b4ff6e841479d (patch)
treebea6fb4c7a5f35260d90b666414713cadb85ffbc /src
parentb76d1ecdcd63649db3583c021fcdfcd0196b7512 (diff)
transaltor: reduce code duplication
Diffstat (limited to 'src')
-rw-r--r--src/www/translator/translator.js24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/www/translator/translator.js b/src/www/translator/translator.js
index 800db6611..86f8ff4f5 100644
--- a/src/www/translator/translator.js
+++ b/src/www/translator/translator.js
@@ -124,15 +124,17 @@ Translator.prototype.update_translations=function() {
ts[i].appendChild(text(segment.target+" "))
}
}
+ function update_segment(i,txts) {
+ var segment=ss[i]
+ segment.target=txts[0];
+ segment.options={method:o.method,from:o.from,to:o.to} // no sharing!
+ if(txts.length>1) segment.choices=txts
+ else delete segment.choices
+ replace(i)
+ }
function update_apertium_translation(i,afrom,ato) {
var segment=ss[i]
- function upd3(txts) {
- segment.target=txts[0];
- segment.options={method:o.method,from:o.from,to:o.to} // no sharing!
- if(txts.length>1) segment.choices=txts
- else delete segment.choices
- replace(i)
- }
+ function upd3(txts) { update_segment(i,txts) }
function upd1(res) {
//console.log(translate_output)
if(res.translation) upd3([res.translation])
@@ -150,13 +152,7 @@ Translator.prototype.update_translations=function() {
function update_gf_translation(i,gfrom,gto) {
var segment=ss[i]
- function upd3(txts) {
- segment.target=txts[0];
- segment.options={method:o.method,from:o.from,to:o.to} // no sharing!
- if(txts.length>1) segment.choices=txts
- else delete segment.choices
- replace(i)
- }
+ function upd3(txts) { update_segment(i,txts) }
function upd2(ts) {
function unlex(txt,cont) { gfshell('ps -unlextext "'+txt+'"',cont) }