summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2015-07-13 18:54:21 +0200
committerPatrick Simianer <p@simianer.de>2015-07-13 18:54:21 +0200
commit43606c760142acd646ae4421e422ec3814842697 (patch)
treeb9e0a9d1d38e03bd88a7f442f56dbb781db2d021
parent57a22fcd9d3f32d66cbb0a2b4f41641c21dd4236 (diff)
js fixes
-rw-r--r--lfpe.js42
1 files changed, 36 insertions, 6 deletions
diff --git a/lfpe.js b/lfpe.js
index ca1ecde..e78332d 100644
--- a/lfpe.js
+++ b/lfpe.js
@@ -41,8 +41,9 @@ function init()
document.getElementById("paused").value = "";
document.getElementById("oov_correct").value = false;
document.getElementById("displayed_oov_hint").value = false;
- document.getElementById("next").removeAttribute("disabled");
- document.getElementById("pause_button").removeAttribute("disabled");
+ document.getElementById("target_textarea").setAttribute("disabled", "disabled");
+ document.getElementById("next").removeAttribute("disabled");
+ document.getElementById("pause_button").removeAttribute("disabled");
return false;
}
@@ -99,12 +100,30 @@ function pause()
}
}
+/*
+ * hacky way to remove class from node
+ *
+ */
function removeClass(node, className)
{
node.className =
node.className.replace(" "+className,'');
+ node.className =
+ node.className.replace(" "+className,''); // ???
+
+ return false;
+}
+
+/*
+ * trim string
+ *
+ */
+function trim(s)
+{
+ return s.replace(/^\s+|\s+$/g, '');
}
+
/*
* next button
*
@@ -133,17 +152,28 @@ function Next()
next_url = base_url+"/next?key="+key;
- var post_edit = target_textarea.value;
+ var post_edit = trim(target_textarea.value);
if (oov_correct.value=="false" && post_edit != "") {
// compose request
next_url += "&example="+source.value+" %7C%7C%7C "+post_edit+"&duration="+Timer.get();
// update document overview
document.getElementById("seg_"+(current_seg_id.value)+"_t").innerHTML=post_edit;
- } else if (oov_correct.value=="true" && post_edit != "") {
+ } else if (oov_correct.value=="true") {
+ if (post_edit == "") {
+ alert("Please provide translations for each word in the 'Source' text area, separated by ';'.");
+ target_textarea.removeAttribute("disabled", "disabled");
+ pause_button.removeAttribute("disabled", "disabled");
+ button.removeAttribute("disabled", "disabled");
+ return;
+ }
next_url += "&correct="+raw_source_textarea.value+" %7C%7C%7C "+post_edit
} else {
if (source.value != "") {
- alert("Error: 1"); // FIXME: do something reasonable
+ alert("Please provide a post-edit.");
+ target_textarea.removeAttribute("disabled", "disabled");
+ pause_button.removeAttribute("disabled", "disabled");
+ button.removeAttribute("disabled", "disabled");
+ return;
}
}
@@ -227,7 +257,7 @@ function Next()
target_textarea.removeAttribute("disabled", "disabled");
pause_button.removeAttribute("disabled", "disabled");
document.getElementById("seg_"+id).className += " bold";
- if (x[0] > 0) {
+ if (id > 0) {
removeClass(document.getElementById("seg_"+(id-1)), "bold");
}
target_textarea.rows = Math.round(translation.length/80)+1;