mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-18 09:19:32 -06:00
First working version of the AJAX translation client.
This commit is contained in:
@@ -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+")");
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user