First working version of the AJAX translation client.

This commit is contained in:
bjorn
2008-08-15 11:14:13 +00:00
parent 0ce04f1a6e
commit 08fae303df
4 changed files with 94 additions and 9 deletions

View File

@@ -1,8 +1,14 @@
function translate (input,from,to,cat) {
httpGetText("gf.fcgi/translate?input="+escape(input)+"&from="+escape(from)+"&to="+escape(to)+"&cat="+escape(cat), function (output) { alert(output); });
}
var gf = new Object();
function httpGetText(url, callback) {
gf.translate = function (input,from,to,cat,callback) {
gf.httpGetText("gf.fcgi/translate?input="+escape(input)+"&from="+escape(from)+"&to="+escape(to)+"&cat="+escape(cat), function (output) { callback(gf.readJSON(output)); });
};
gf.getLanguages = function (callback) {
gf.httpGetText("gf.fcgi/languages", function (output) { callback(gf.readJSON(output)); });
};
gf.httpGetText = function (url, callback) {
var XMLHttpRequestObject = false;
if (window.XMLHttpRequest) {
@@ -25,5 +31,8 @@ function httpGetText(url, callback) {
XMLHttpRequestObject.send(null);
}
};
}
gf.readJSON = function (text) {
return eval("("+text+")");
};