diff options
author | Thierry Crozat | 2016-09-06 00:43:25 +0100 |
---|---|---|
committer | Thierry Crozat | 2016-09-06 00:43:25 +0100 |
commit | fa5a5bf865e86f02257f3b1bec84ba74e71319b1 (patch) | |
tree | 65fe939a958c8d9d588a9b7a0ed4895b8f3fb6c4 /dists/networking/wwwroot/ajax.js | |
parent | b8948c332643da2be296cf3df4daa1fa6eeb1f08 (diff) | |
download | scummvm-rg350-fa5a5bf865e86f02257f3b1bec84ba74e71319b1.tar.gz scummvm-rg350-fa5a5bf865e86f02257f3b1bec84ba74e71319b1.tar.bz2 scummvm-rg350-fa5a5bf865e86f02257f3b1bec84ba74e71319b1.zip |
CLOUD: Move wwwroot archive to dists and script to devtools
Both the data used to generate the archive and the archive itself
were moved to dists/ instead of being in backends/.
The script was also improved to optionally take a path as a command
line argument to indicate where the wwwroot data are instead of
assuming they are in the working directory.
Finally a 'wwwroot' make target was also added to invoke the python script and generate the archive.
with the expected path to
Diffstat (limited to 'dists/networking/wwwroot/ajax.js')
-rw-r--r-- | dists/networking/wwwroot/ajax.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/dists/networking/wwwroot/ajax.js b/dists/networking/wwwroot/ajax.js new file mode 100644 index 0000000000..c01d7e93fc --- /dev/null +++ b/dists/networking/wwwroot/ajax.js @@ -0,0 +1,48 @@ +// the following is snippet from http://stackoverflow.com/a/18078705 +// I changed a few things though + +var ajax = {}; +ajax.x = function () { return new XMLHttpRequest(); }; // "no one uses IE6" + +ajax.send = function (url, callback, errorCallback, method, data, async) { + if (async === undefined) async = true; + + var x = ajax.x(); + x.open(method, url, async); + x.onreadystatechange = function () { + if (x.readyState == XMLHttpRequest.DONE) { + if (x.status == 200) + callback(x.responseText); + else + errorCallback(x); + } + }; + if (method == 'POST') { + x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + } + x.send(data) +}; + +ajax.get = function (url, data, callback, errorCallback, async) { + var query = []; + for (var key in data) { + query.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key])); + } + ajax.send(url + (query.length ? '?' + query.join('&') : ''), callback, errorCallback, 'GET', null, async) +}; + +ajax.post = function (url, data, callback, errorCallback, async) { + var query = []; + for (var key in data) { + query.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key])); + } + ajax.send(url, callback, errorCallback, 'POST', query.join('&'), async) +}; + +ajax.getAndParseJson = function (url, data, callback) { + ajax.get( + url, data, + function (responseText) { callback(JSON.parse(responseText)); }, + function (x) { console.log("error: " + x.status); } + ); +};
\ No newline at end of file |