Refactor js translator to be able to share some code with the ajax version.

This commit is contained in:
bjorn
2008-08-14 18:51:06 +00:00
parent b8de42f050
commit 5939be16b8
2 changed files with 23 additions and 16 deletions

View File

@@ -1,18 +1,5 @@
function updateTranslation (grammar, inputID, fromLangID, toLangID, outputID) {
var input = document.getElementById(inputID).value;
var fromLang = document.getElementById(fromLangID).value;
var toLang = document.getElementById(toLangID).value;
var output = document.getElementById(outputID);
output.appendChild(formatTranslation(grammar.translate(input, fromLang, toLang)));
}
function populateLangs (grammar, fromLang, toLang) {
var f = document.getElementById(fromLang);
var t = document.getElementById(toLang);
for (var c in grammar.concretes) {
addOption(f, c, c);
addOption(t, c, c);
}
function addTranslation (outputID, translation) {
document.getElementById(outputID).appendChild(formatTranslation(translation));
}
function formatTranslation (outputs) {